]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/config/linux/ia64/futex.h
1 /* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.com>.
4 This file is part of the GNU OpenMP Library (libgomp).
6 Libgomp is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16 You should have received a copy of the GNU Lesser General Public License
17 along with libgomp; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* As a special exception, if you link this library with other files, some
22 of which are compiled with GCC, to produce an executable, this library
23 does not by itself cause the resulting executable to be covered by the
24 GNU General Public License. This exception does not however invalidate
25 any other reasons why the executable file might be covered by the GNU
26 General Public License. */
28 /* Provide target-specific access to the futex system call. */
30 #include <sys/syscall.h>
35 sys_futex0(int *addr
, long op
, int val
)
37 register long out0
asm ("out0") = (long) addr
;
38 register long out1
asm ("out1") = op
;
39 register long out2
asm ("out2") = val
;
40 register long out3
asm ("out3") = 0;
41 register long r8
asm ("r8");
42 register long r10
asm ("r10");
43 register long r15
asm ("r15") = SYS_futex
;
45 __asm
__volatile ("break 0x100000"
46 : "=r"(r15
), "=r"(out0
), "=r"(out1
), "=r"(out2
), "=r"(out3
),
48 : "r"(r15
), "r"(out0
), "r"(out1
), "r"(out2
), "r"(out3
)
49 : "memory", "out4", "out5", "out6", "out7",
50 /* Non-stacked integer registers, minus r8, r10, r15. */
51 "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18",
52 "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",
53 "r28", "r29", "r30", "r31",
54 /* Predicate registers. */
55 "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",
56 /* Non-rotating fp registers. */
57 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
58 /* Branch registers. */
64 futex_wait (int *addr
, int val
)
66 long err
= sys_futex0 (addr
, gomp_futex_wait
, val
);
67 if (__builtin_expect (err
== ENOSYS
, 0))
69 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
70 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
71 sys_futex0 (addr
, gomp_futex_wait
, val
);
76 futex_wake (int *addr
, int count
)
78 long err
= sys_futex0 (addr
, gomp_futex_wake
, count
);
79 if (__builtin_expect (err
== ENOSYS
, 0))
81 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
82 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
83 sys_futex0 (addr
, gomp_futex_wake
, count
);
90 __asm
volatile ("hint @pause" : : : "memory");
94 atomic_write_barrier (void)
96 __sync_synchronize ();