Skip to content

Commit

Permalink
(FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define. (lll_futex_wa…
Browse files Browse the repository at this point in the history
…ke_unlock): Define.
  • Loading branch information
Ulrich Drepper committed Sep 8, 2005
1 parent 4043787 commit b9b8cf0
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
16 changes: 16 additions & 0 deletions nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
#define FUTEX_WAKE_OP 5
#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)

/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
Expand Down Expand Up @@ -73,6 +75,20 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})

/* Returns non-zero if error happened, zero if success. */
#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret; \
__ret = INTERNAL_SYSCALL (futex, __err, 6, \
(futexp), FUTEX_WAKE_OP, (nr_wake), \
(nr_wake2), (futexp2), \
FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})




static inline int __attribute__((always_inline))
__lll_mutex_trylock(int *futex)
Expand Down
11 changes: 11 additions & 0 deletions nptl/sysdeps/unix/sysv/linux/ia64/lowlevellock.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
#define FUTEX_WAKE_OP 5
#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)

/* Delay in spinlock loop. */
#define BUSY_WAIT_NOP asm ("hint @pause")
Expand Down Expand Up @@ -62,6 +64,15 @@
_r10 == -1; \
})

/* Returns non-zero if error happened, zero if success. */
#define lll_futex_wake_unlock(ftx, nr_wake, nr_wake2, ftx2) \
({ \
DO_INLINE_SYSCALL(futex, 6, (long) (ftx), FUTEX_WAKE_OP, \
(int) (nr_wake), (int) (nr_wake2), (long) (ftx2), \
FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
_r10 == -1; \
})


#define __lll_mutex_trylock(futex) \
(atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0)
Expand Down
15 changes: 15 additions & 0 deletions nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
#define FUTEX_WAKE_OP 5
#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)

/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
Expand Down Expand Up @@ -79,6 +81,19 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})

/* Returns non-zero if error happened, zero if success. */
#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret; \
\
__ret = INTERNAL_SYSCALL (futex, __err, 6, \
(futexp), FUTEX_WAKE_OP, (nr_wake), \
(nr_wake2), (futexp2), \
FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})

#ifdef UP
# define __lll_acq_instr ""
# define __lll_rel_instr ""
Expand Down
23 changes: 23 additions & 0 deletions nptl/sysdeps/unix/sysv/linux/s390/lowlevellock.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
#define FUTEX_WAKE_OP 5
#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)

/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
Expand Down Expand Up @@ -103,6 +105,27 @@
})


/* Returns non-zero if error happened, zero if success. */
#define lll_futex_wake_unlock(futex, nr_wake, nr_wake2, futex2) \
({ \
register unsigned long int __r2 asm ("2") = (unsigned long int) (futex); \
register unsigned long int __r3 asm ("3") = FUTEX_WAKE_OP; \
register unsigned long int __r4 asm ("4") = (long int) (nr_wake); \
register unsigned long int __r5 asm ("5") = (long int) (nr_wake2); \
register unsigned long int __r6 asm ("6") = (unsigned long int) (futex2); \
register unsigned long int __r7 asm ("7") \
= (int) FUTEX_OP_CLEAR_WAKE_IF_GT_ONE; \
register unsigned long __result asm ("2"); \
\
__asm __volatile ("svc %b1" \
: "=d" (__result) \
: "i" (SYS_futex), "0" (__r2), "d" (__r3), \
"d" (__r4), "d" (__r5), "d" (__r6), "d" (__r7) \
: "cc", "memory" ); \
__result > -4096UL; \
})


#define lll_compare_and_swap(futex, oldval, newval, operation) \
do { \
__typeof (futex) __futex = (futex); \
Expand Down
15 changes: 15 additions & 0 deletions nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
#define FUTEX_WAKE_OP 5
#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)

/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
Expand Down Expand Up @@ -76,6 +78,19 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})

/* Returns non-zero if error happened, zero if success. */
#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
long int __ret; \
\
__ret = INTERNAL_SYSCALL (futex, __err, 6, \
(futexp), FUTEX_WAKE_OP, (nr_wake), \
(nr_wake2), (futexp2), \
FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})

#ifdef __sparc32_atomic_do_lock
#error SPARC < v9 does not support compare and swap which is essential for futex based locking
#endif
Expand Down

0 comments on commit b9b8cf0

Please sign in to comment.