diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-12-13 10:37:24 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-12-16 01:58:33 +0100 |
commit | bec412424e949c900b01767ce32b6743bdaaac93 (patch) | |
tree | d4244ee3b644f5e8e68dfb5f22aeeb30065bca75 /mach/lowlevellock.h | |
parent | 18c2ab9a094f6a6cb3a107d66dafaf32f8f969f0 (diff) | |
download | glibc-bec412424e949c900b01767ce32b6743bdaaac93.tar.gz glibc-bec412424e949c900b01767ce32b6743bdaaac93.tar.xz glibc-bec412424e949c900b01767ce32b6743bdaaac93.zip |
hurd: make lll_* take a variable instead of a ptr
To be coherent with other ports, let's make lll_* take a variable, and rename those that keep taking a ptr into __lll_*.
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 |