Message ID | 1492200452-4653-1-git-send-email-ynorov@caviumnetworks.com |
---|---|
State | New |
Headers | show |
On 04/14/2017 10:07 PM, Yury Norov wrote: > SYSCALL_CANCEL() currently calls INLINE_SYSCALL_CALL() both in true and > false branches of the "if (SINGLE_THREAD_P)" condition. If arguments that > passed in INLINE_SYSCALL_CALL() are wrapped with tricky macros or require > other additional handling, the code that does it becomes duplicated, and > it may increase the size of function that use it significantly. It also widens the window for the race, so I'm not sure if this is a good idea. I think this code will change with the cancellation fixes anyway. Thanks, Florian
diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h index 38c2432..f0fa9da 100644 --- a/sysdeps/unix/sysdep.h +++ b/sysdeps/unix/sysdep.h @@ -91,14 +91,13 @@ #define SYSCALL_CANCEL(...) \ ({ \ long int sc_ret; \ - if (SINGLE_THREAD_P) \ - sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \ - else \ - { \ - int sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \ - sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \ - LIBC_CANCEL_RESET (sc_cancel_oldtype); \ - } \ + int sc_cancel_oldtype; \ + bool multithread = !SINGLE_THREAD_P; \ + if (multithread) \ + sc_cancel_oldtype = LIBC_CANCEL_ASYNC (); \ + sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \ + if (multithread) \ + LIBC_CANCEL_RESET (sc_cancel_oldtype); \ sc_ret; \ })