From: Uros Bizjak Date: Thu, 11 Feb 2021 21:48:47 +0000 (+0100) Subject: libgomp/i386: Move syscall asms to static inline wrapper. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c36ad24e8a4098e2b3e59f682a6ae751d656102c;p=gcc.git libgomp/i386: Move syscall asms to static inline wrapper. Move syscall asms to static inline wrapper functions to improve #ifdeffery. Also correct output type to int and timeout type to void *. 2021-02-11 Uroš Bizjak libgomp/ * config/linux/x86/futex.h (__futex_wait): New static inline wrapper function. Correct output type to int and timeout type to void *. (__futex_wake): New static inline wrapper function. Correct output type to int. (futex_wait): Use __futex_wait. (futex_wake): Use __futex_wake. --- diff --git a/libgomp/config/linux/x86/futex.h b/libgomp/config/linux/x86/futex.h index 1e01b681401..7807e88e2e0 100644 --- a/libgomp/config/linux/x86/futex.h +++ b/libgomp/config/linux/x86/futex.h @@ -30,99 +30,92 @@ # define SYS_futex 202 # endif -static inline void -futex_wait (int *addr, int val) +static inline int +__futex_wait (int *addr, int futex_op, int val) { - long res; + int res; - register long r10 __asm__("%r10") = 0; + register void *timeout __asm ("r10") = NULL; __asm volatile ("syscall" : "=a" (res) - : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait), - "d" (val), "r" (r10) + : "0" (SYS_futex), "D" (addr), "S" (futex_op), + "d" (val), "r" (timeout) : "r11", "rcx", "memory"); - if (__builtin_expect (res == -ENOSYS, 0)) - { - gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; - gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; - __asm volatile ("syscall" - : "=a" (res) - : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait), - "d" (val), "r" (r10) - : "r11", "rcx", "memory"); - } + return res; } -static inline void -futex_wake (int *addr, int count) +static inline int +__futex_wake (int *addr, int futex_op, int count) { - long res; + int res; __asm volatile ("syscall" : "=a" (res) - : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wake), + : "0" (SYS_futex), "D" (addr), "S" (futex_op), "d" (count) : "r11", "rcx", "memory"); - if (__builtin_expect (res == -ENOSYS, 0)) - { - gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; - gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; - __asm volatile ("syscall" - : "=a" (res) - : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wake), - "d" (count) - : "r11", "rcx", "memory"); - } + return res; } #else # ifndef SYS_futex # define SYS_futex 240 # endif -static inline void -futex_wait (int *addr, int val) +static inline int +__futex_wait (int *addr, int futex_op, int val) +{ + int res; + + void *timeout = NULL; + __asm volatile ("int $0x80" + : "=a" (res) + : "0" (SYS_futex), "b" (addr), "c" (futex_op), + "d" (val), "S" (timeout) + : "memory"); + return res; +} + +static inline int +__futex_wake (int *addr, int futex_op, int count) { - long res; + int res; __asm volatile ("int $0x80" : "=a" (res) - : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wait), - "d" (val), "S" (0) + : "0" (SYS_futex), "b" (addr), "c" (futex_op), + "d" (count) : "memory"); + return res; +} +#endif /* __x86_64__ */ + +static inline void +futex_wait (int *addr, int val) +{ + int res = __futex_wait (addr, gomp_futex_wait, val); + if (__builtin_expect (res == -ENOSYS, 0)) { gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; - __asm volatile ("int $0x80" - : "=a" (res) - : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wait), - "d" (val), "S" (0) - : "memory"); + + __futex_wait (addr, gomp_futex_wait, val); } } static inline void futex_wake (int *addr, int count) { - long res; + int res = __futex_wake (addr, gomp_futex_wake, count); - __asm volatile ("int $0x80" - : "=a" (res) - : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wake), - "d" (count) - : "memory"); if (__builtin_expect (res == -ENOSYS, 0)) { gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; - __asm volatile ("int $0x80" - : "=a" (res) - : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wake), - "d" (count) - : "memory"); + + __futex_wake (addr, gomp_futex_wake, count); } } -#endif /* __x86_64__ */ static inline void cpu_relax (void)