diff mbox

[4/4] nptl: Add default cancellable futex calls

Message ID 541C2DE0.80100@linux.vnet.ibm.com
State New
Headers show

Commit Message

Adhemerval Zanella Sept. 19, 2014, 1:21 p.m. UTC
This patch adds default cancellable futex calls used in cancellation
entrypoints in NPTL code.

--

	* sysdeps/unix/sysv/linux/lowlevellock-futex.h
	(lll_futex_wait_cancel): New define: cancellable wait futex call.
	(lll_futex_timed_wait_cancel): New define: cancellable timed wait
	futex call.
	(lll_futex_timed_wait_bitset_cancel): New define: cancellable timed
	wait bitsel futex call.
	(lll_futex_wait_requeue_pi_cancel): New define: cancellable wait
	requeue PI futex call.
	(lll_futex_timed_wait_requeue_pi_cancel): New define: cancellable
	timed wait requeue PI futex call.

---

Comments

Joseph Myers Sept. 19, 2014, 5:02 p.m. UTC | #1
On Fri, 19 Sep 2014, Adhemerval Zanella wrote:

> diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
> index 343afd6..2967ebb 100644
> --- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h
> +++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
> @@ -97,6 +97,49 @@
>  		     val, timeout, NULL /* Unused.  */,                 \
>  		     FUTEX_BITSET_MATCH_ANY)
>  
> +#define lll_futex_wait_cancel(futexp, val, private) \
> +  lll_futex_timed_wait_cancel (futexp, val, NULL, private)
> +
> +#define lll_futex_timed_wait_cancel(futexp, val, timespec, private)           \
> +  ({                                                                          \
> +    long int __ret;                                                           \
> +    int __op = FUTEX_WAIT;                                                    \
> +                                                                              \
> +    __ret = __syscall_cancel (__NR_futex, (long int) (futexp),                \
> +                              (long int)__lll_private_flag (__op, private),   \
> +                              (long int)(val), (long int)(timespec), 0, 0);   \

As with other patches, do not hardcode the use of "long" for syscall 
arguments.
Adhemerval Zanella Sept. 22, 2014, 1:14 p.m. UTC | #2
Hi Joseph, thanks for the review.


On 19-09-2014 14:02, Joseph S. Myers wrote:
> On Fri, 19 Sep 2014, Adhemerval Zanella wrote:
>
>> diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
>> index 343afd6..2967ebb 100644
>> --- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h
>> +++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
>> @@ -97,6 +97,49 @@
>>  		     val, timeout, NULL /* Unused.  */,                 \
>>  		     FUTEX_BITSET_MATCH_ANY)
>>  
>> +#define lll_futex_wait_cancel(futexp, val, private) \
>> +  lll_futex_timed_wait_cancel (futexp, val, NULL, private)
>> +
>> +#define lll_futex_timed_wait_cancel(futexp, val, timespec, private)           \
>> +  ({                                                                          \
>> +    long int __ret;                                                           \
>> +    int __op = FUTEX_WAIT;                                                    \
>> +                                                                              \
>> +    __ret = __syscall_cancel (__NR_futex, (long int) (futexp),                \
>> +                              (long int)__lll_private_flag (__op, private),   \
>> +                              (long int)(val), (long int)(timespec), 0, 0);   \
> As with other patches, do not hardcode the use of "long" for syscall 
> arguments.

Right, I will adjust it.

>
diff mbox

Patch

diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
index 343afd6..2967ebb 100644
--- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h
+++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
@@ -97,6 +97,49 @@ 
 		     val, timeout, NULL /* Unused.  */,                 \
 		     FUTEX_BITSET_MATCH_ANY)
 
+#define lll_futex_wait_cancel(futexp, val, private) \
+  lll_futex_timed_wait_cancel (futexp, val, NULL, private)
+
+#define lll_futex_timed_wait_cancel(futexp, val, timespec, private)           \
+  ({                                                                          \
+    long int __ret;                                                           \
+    int __op = FUTEX_WAIT;                                                    \
+                                                                              \
+    __ret = __syscall_cancel (__NR_futex, (long int) (futexp),                \
+                              (long int)__lll_private_flag (__op, private),   \
+                              (long int)(val), (long int)(timespec), 0, 0);   \
+    __ret;                                                                    \
+  })
+
+#define lll_futex_timed_wait_bitset_cancel(futexp, val, timespec, clockbit,   \
+                                           private)                           \
+  ({                                                                          \
+    long int __ret;                                                           \
+    int __op = FUTEX_WAIT_BITSET | clockbit;                                  \
+                                                                              \
+    __ret = __syscall_cancel (__NR_futex, (long int) (futexp),                \
+                              (long int)__lll_private_flag (__op, private),   \
+                              (long int)(val), (long int)(timespec), 0,       \
+                              FUTEX_BITSET_MATCH_ANY);                        \
+    __ret;                                                                    \
+  })
+
+#define lll_futex_wait_requeue_pi_cancel(futexp, val, mutex, private) \
+  lll_futex_timed_wait_requeue_pi_cancel (futexp, val, NULL, 0, mutex, private)
+
+#define lll_futex_timed_wait_requeue_pi_cancel(futexp, val, timespec,         \
+                                               clockbit, mutex, private)      \
+  ({                                                                          \
+    long int __ret;                                                           \
+    int __op = FUTEX_WAIT_REQUEUE_PI | clockbit;                              \
+                                                                              \
+    __ret = __syscall_cancel (__NR_futex, (long int) (futexp),                \
+                              (long int) __lll_private_flag (__op, private),  \
+                              (long int )(val), (long int) (timespec),        \
+                              (long int ) mutex, 0);                          \
+    __ret;                                                                    \
+  })
+
 #define lll_futex_wake(futexp, nr, private)                             \
   lll_futex_syscall (4, futexp,                                         \
 		     __lll_private_flag (FUTEX_WAKE, private), nr, 0)