Mercurial > hg > CbC > CbC_gcc
diff libgomp/config/linux/x86/futex.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | a06113de4d67 |
children | 84e7813d76e9 |
line wrap: on
line diff
--- a/libgomp/config/linux/x86/futex.h Sun Aug 21 07:07:55 2011 +0900 +++ b/libgomp/config/linux/x86/futex.h Fri Oct 27 22:46:09 2017 +0900 @@ -1,7 +1,8 @@ -/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2005-2017 Free Software Foundation, Inc. Contributed by Richard Henderson <rth@redhat.com>. - This file is part of the GNU OpenMP Library (libgomp). + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). Libgomp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +25,7 @@ /* Provide target-specific access to the futex system call. */ -#ifdef __LP64__ +#ifdef __x86_64__ # ifndef SYS_futex # define SYS_futex 202 # endif @@ -32,10 +33,9 @@ static inline void futex_wait (int *addr, int val) { - register long r10 __asm__("%r10"); long res; - r10 = 0; + register long r10 __asm__("%r10") = 0; __asm volatile ("syscall" : "=a" (res) : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait), @@ -45,7 +45,6 @@ { gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; - r10 = 0; __asm volatile ("syscall" : "=a" (res) : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait), @@ -80,74 +79,53 @@ # define SYS_futex 240 # endif -# ifdef __PIC__ - -static inline long -sys_futex0 (int *addr, int op, int val) -{ - long res; - - __asm volatile ("xchgl\t%%ebx, %2\n\t" - "int\t$0x80\n\t" - "xchgl\t%%ebx, %2" - : "=a" (res) - : "0"(SYS_futex), "r" (addr), "c"(op), - "d"(val), "S"(0) - : "memory"); - return res; -} - -# else - -static inline long -sys_futex0 (int *addr, int op, int val) +static inline void +futex_wait (int *addr, int val) { long res; __asm volatile ("int $0x80" : "=a" (res) - : "0"(SYS_futex), "b" (addr), "c"(op), - "d"(val), "S"(0) + : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wait), + "d" (val), "S" (0) : "memory"); - return res; -} - -# endif /* __PIC__ */ - -static inline void -futex_wait (int *addr, int val) -{ - long res = sys_futex0 (addr, gomp_futex_wait, val); if (__builtin_expect (res == -ENOSYS, 0)) { gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; - sys_futex0 (addr, gomp_futex_wait, val); + __asm volatile ("int $0x80" + : "=a" (res) + : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wait), + "d" (val), "S" (0) + : "memory"); } } static inline void futex_wake (int *addr, int count) { - long res = sys_futex0 (addr, gomp_futex_wake, count); + long res; + + __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; - sys_futex0 (addr, gomp_futex_wake, count); + __asm volatile ("int $0x80" + : "=a" (res) + : "0" (SYS_futex), "b" (addr), "c" (gomp_futex_wake), + "d" (count) + : "memory"); } } - -#endif /* __LP64__ */ +#endif /* __x86_64__ */ static inline void cpu_relax (void) { - __asm volatile ("rep; nop" : : : "memory"); + __builtin_ia32_pause (); } - -static inline void -atomic_write_barrier (void) -{ - __sync_synchronize (); -}