| OLD | NEW |
| 1 #include <futex_emulation.h> | 1 #include <futex_emulation.h> |
| 2 | 2 |
| 3 #include <assert.h> | 3 #include <assert.h> |
| 4 #include <errno.h> | 4 #include <errno.h> |
| 5 #include <irt_syscalls.h> | 5 #include <irt_syscalls.h> |
| 6 #include <tls.h> | 6 #include <tls.h> |
| 7 | 7 |
| 8 | 8 |
| 9 static int global_futex_emulation_mutex_desc = -1; | 9 static int global_futex_emulation_mutex_desc = -1; |
| 10 static LIST_HEAD (waiters_list); | 10 static LIST_HEAD (waiters_list); |
| 11 | 11 |
| 12 void __nacl_futex_init (void) | 12 void __nacl_futex_init (void) |
| 13 { | 13 { |
| 14 assert (global_futex_emulation_mutex_desc == -1); | 14 assert (global_futex_emulation_mutex_desc == -1); |
| 15 __nacl_irt_mutex_create (&global_futex_emulation_mutex_desc); | 15 __nacl_irt_mutex_create (&global_futex_emulation_mutex_desc); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void __nacl_futex_fini (void) | |
| 19 { | |
| 20 __nacl_irt_mutex_destroy (global_futex_emulation_mutex_desc); | |
| 21 } | |
| 22 | |
| 23 int __nacl_futex_wait (volatile int *addr, int val, unsigned int bitset, | 18 int __nacl_futex_wait (volatile int *addr, int val, unsigned int bitset, |
| 24 const struct timespec *timeout) | 19 const struct timespec *timeout) |
| 25 { | 20 { |
| 26 int retcode = -EINTR; | 21 int retcode = -EINTR; |
| 27 | 22 |
| 28 if (__nacl_irt_mutex_lock (global_futex_emulation_mutex_desc)) | 23 if (__nacl_irt_mutex_lock (global_futex_emulation_mutex_desc)) |
| 29 goto ret_no_unlock; | 24 goto ret_no_unlock; |
| 30 | 25 |
| 31 if (*addr != val) | 26 if (*addr != val) |
| 32 { | 27 { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 __nacl_irt_mutex_unlock (global_futex_emulation_mutex_desc); | 281 __nacl_irt_mutex_unlock (global_futex_emulation_mutex_desc); |
| 287 return retcode; | 282 return retcode; |
| 288 } | 283 } |
| 289 | 284 |
| 290 ret_unlock: | 285 ret_unlock: |
| 291 if (!__nacl_irt_mutex_unlock (global_futex_emulation_mutex_desc)) | 286 if (!__nacl_irt_mutex_unlock (global_futex_emulation_mutex_desc)) |
| 292 retcode = 0; | 287 retcode = 0; |
| 293 ret_no_unlock: | 288 ret_no_unlock: |
| 294 return retcode; | 289 return retcode; |
| 295 } | 290 } |
| OLD | NEW |