]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/config/linux/x86/futex.h
1 /* Copyright (C) 2005-2016 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.com>.
4 This file is part of the GNU Offloading and Multi Processing Library
7 Libgomp is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 /* Provide target-specific access to the futex system call. */
30 # define SYS_futex 202
34 futex_wait (int *addr
, int val
)
38 register long r10
__asm__("%r10") = 0;
39 __asm
volatile ("syscall"
41 : "0" (SYS_futex
), "D" (addr
), "S" (gomp_futex_wait
),
43 : "r11", "rcx", "memory");
44 if (__builtin_expect (res
== -ENOSYS
, 0))
46 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
47 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
48 __asm
volatile ("syscall"
50 : "0" (SYS_futex
), "D" (addr
), "S" (gomp_futex_wait
),
52 : "r11", "rcx", "memory");
57 futex_wake (int *addr
, int count
)
61 __asm
volatile ("syscall"
63 : "0" (SYS_futex
), "D" (addr
), "S" (gomp_futex_wake
),
65 : "r11", "rcx", "memory");
66 if (__builtin_expect (res
== -ENOSYS
, 0))
68 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
69 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
70 __asm
volatile ("syscall"
72 : "0" (SYS_futex
), "D" (addr
), "S" (gomp_futex_wake
),
74 : "r11", "rcx", "memory");
79 # define SYS_futex 240
83 futex_wait (int *addr
, int val
)
87 __asm
volatile ("int $0x80"
89 : "0" (SYS_futex
), "b" (addr
), "c" (gomp_futex_wait
),
92 if (__builtin_expect (res
== -ENOSYS
, 0))
94 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
95 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
96 __asm
volatile ("int $0x80"
98 : "0" (SYS_futex
), "b" (addr
), "c" (gomp_futex_wait
),
105 futex_wake (int *addr
, int count
)
109 __asm
volatile ("int $0x80"
111 : "0" (SYS_futex
), "b" (addr
), "c" (gomp_futex_wake
),
114 if (__builtin_expect (res
== -ENOSYS
, 0))
116 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
117 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
118 __asm
volatile ("int $0x80"
120 : "0" (SYS_futex
), "b" (addr
), "c" (gomp_futex_wake
),
125 #endif /* __x86_64__ */
130 __builtin_ia32_pause ();