1 /* Copyright (C) 2005, 2008, 2009 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 General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
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 General Public License for
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 /* Provide target-specific access to the futex system call. */
27 #include <sys/syscall.h>
32 sys_futex0(int *addr
, long op
, int val
)
34 register long out0
asm ("out0") = (long) addr
;
35 register long out1
asm ("out1") = op
;
36 register long out2
asm ("out2") = val
;
37 register long out3
asm ("out3") = 0;
38 register long r8
asm ("r8");
39 register long r10
asm ("r10");
40 register long r15
asm ("r15") = SYS_futex
;
42 __asm
__volatile ("break 0x100000"
43 : "=r"(r15
), "=r"(out0
), "=r"(out1
), "=r"(out2
), "=r"(out3
),
45 : "r"(r15
), "r"(out0
), "r"(out1
), "r"(out2
), "r"(out3
)
46 : "memory", "out4", "out5", "out6", "out7",
47 /* Non-stacked integer registers, minus r8, r10, r15. */
48 "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18",
49 "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",
50 "r28", "r29", "r30", "r31",
51 /* Predicate registers. */
52 "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",
53 /* Non-rotating fp registers. */
54 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
55 /* Branch registers. */
61 futex_wait (int *addr
, int val
)
63 long err
= sys_futex0 (addr
, gomp_futex_wait
, val
);
64 if (__builtin_expect (err
== ENOSYS
, 0))
66 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
67 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
68 sys_futex0 (addr
, gomp_futex_wait
, val
);
73 futex_wake (int *addr
, int count
)
75 long err
= sys_futex0 (addr
, gomp_futex_wake
, count
);
76 if (__builtin_expect (err
== ENOSYS
, 0))
78 gomp_futex_wait
&= ~FUTEX_PRIVATE_FLAG
;
79 gomp_futex_wake
&= ~FUTEX_PRIVATE_FLAG
;
80 sys_futex0 (addr
, gomp_futex_wake
, count
);
87 __asm
volatile ("hint @pause" : : : "memory");