Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_FUTEX_H |
| 2 | #define _LINUX_FUTEX_H |
| 3 | |
| 4 | /* Second argument to futex syscall */ |
| 5 | |
| 6 | |
Jakub Jelinek | 4732efb | 2005-09-06 15:16:25 -0700 | [diff] [blame] | 7 | #define FUTEX_WAIT 0 |
| 8 | #define FUTEX_WAKE 1 |
| 9 | #define FUTEX_FD 2 |
| 10 | #define FUTEX_REQUEUE 3 |
| 11 | #define FUTEX_CMP_REQUEUE 4 |
| 12 | #define FUTEX_WAKE_OP 5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | long do_futex(unsigned long uaddr, int op, int val, |
| 15 | unsigned long timeout, unsigned long uaddr2, int val2, |
| 16 | int val3); |
| 17 | |
Jakub Jelinek | 4732efb | 2005-09-06 15:16:25 -0700 | [diff] [blame] | 18 | #define FUTEX_OP_SET 0 /* *(int *)UADDR2 = OPARG; */ |
| 19 | #define FUTEX_OP_ADD 1 /* *(int *)UADDR2 += OPARG; */ |
| 20 | #define FUTEX_OP_OR 2 /* *(int *)UADDR2 |= OPARG; */ |
| 21 | #define FUTEX_OP_ANDN 3 /* *(int *)UADDR2 &= ~OPARG; */ |
| 22 | #define FUTEX_OP_XOR 4 /* *(int *)UADDR2 ^= OPARG; */ |
| 23 | |
| 24 | #define FUTEX_OP_OPARG_SHIFT 8 /* Use (1 << OPARG) instead of OPARG. */ |
| 25 | |
| 26 | #define FUTEX_OP_CMP_EQ 0 /* if (oldval == CMPARG) wake */ |
| 27 | #define FUTEX_OP_CMP_NE 1 /* if (oldval != CMPARG) wake */ |
| 28 | #define FUTEX_OP_CMP_LT 2 /* if (oldval < CMPARG) wake */ |
| 29 | #define FUTEX_OP_CMP_LE 3 /* if (oldval <= CMPARG) wake */ |
| 30 | #define FUTEX_OP_CMP_GT 4 /* if (oldval > CMPARG) wake */ |
| 31 | #define FUTEX_OP_CMP_GE 5 /* if (oldval >= CMPARG) wake */ |
| 32 | |
| 33 | /* FUTEX_WAKE_OP will perform atomically |
| 34 | int oldval = *(int *)UADDR2; |
| 35 | *(int *)UADDR2 = oldval OP OPARG; |
| 36 | if (oldval CMP CMPARG) |
| 37 | wake UADDR2; */ |
| 38 | |
| 39 | #define FUTEX_OP(op, oparg, cmp, cmparg) \ |
| 40 | (((op & 0xf) << 28) | ((cmp & 0xf) << 24) \ |
| 41 | | ((oparg & 0xfff) << 12) | (cmparg & 0xfff)) |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #endif |