diff options
Diffstat (limited to 'mach/lowlevellock.h')
-rw-r--r-- | mach/lowlevellock.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/mach/lowlevellock.h b/mach/lowlevellock.h index cf67ccd589..0a22a030b4 100644 --- a/mach/lowlevellock.h +++ b/mach/lowlevellock.h @@ -36,16 +36,20 @@ /* Wait on address PTR, without blocking if its contents * are different from VAL. */ -#define lll_wait(ptr, val, flags) \ +#define __lll_wait(ptr, val, flags) \ __gsync_wait (__mach_task_self (), \ (vm_offset_t)(ptr), (val), 0, 0, (flags)) +#define lll_wait(var, val, flags) \ + __lll_wait (&(var), val, flags) /* Wake one or more threads waiting on address PTR. */ -#define lll_wake(ptr, flags) \ +#define __lll_wake(ptr, flags) \ __gsync_wake (__mach_task_self (), (vm_offset_t)(ptr), 0, (flags)) +#define lll_wake(var, flags) \ + __lll_wake (&(var), flags) /* Acquire the lock at PTR. */ -#define lll_lock(ptr, flags) \ +#define __lll_lock(ptr, flags) \ ({ \ int *__iptr = (int *)(ptr); \ int __flags = (flags); \ @@ -55,27 +59,33 @@ { \ if (atomic_exchange_acq (__iptr, 2) == 0) \ break; \ - lll_wait (__iptr, 2, __flags); \ + __lll_wait (__iptr, 2, __flags); \ } \ (void)0; \ }) +#define lll_lock(var, flags) \ + __lll_lock (&(var), flags) /* Try to acquire the lock at PTR, without blocking. Evaluates to zero on success. */ -#define lll_trylock(ptr) \ +#define __lll_trylock(ptr) \ ({ \ int *__iptr = (int *)(ptr); \ *__iptr == 0 \ && atomic_compare_and_exchange_bool_acq (__iptr, 1, 0) == 0 ? 0 : -1; \ }) +#define lll_trylock(var) \ + __lll_trylock (&(var)) /* Release the lock at PTR. */ -#define lll_unlock(ptr, flags) \ +#define __lll_unlock(ptr, flags) \ ({ \ int *__iptr = (int *)(ptr); \ if (atomic_exchange_rel (__iptr, 0) == 2) \ - lll_wake (__iptr, (flags)); \ + __lll_wake (__iptr, (flags)); \ (void)0; \ }) +#define lll_unlock(var, flags) \ + __lll_unlock (&(var), flags) #endif |