]> gcc.gnu.org Git - gcc.git/blame - libgomp/config/linux/ia64/futex.h
Update copyright years.
[gcc.git] / libgomp / config / linux / ia64 / futex.h
CommitLineData
5624e564 1/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
953ff289
DN
2 Contributed by Richard Henderson <rth@redhat.com>.
3
4 This file is part of the GNU OpenMP Library (libgomp).
5
6 Libgomp is free software; you can redistribute it and/or modify it
748086b7
JJ
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)
9 any later version.
953ff289
DN
10
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
748086b7 13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
953ff289
DN
14 more details.
15
748086b7
JJ
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.
19
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/>. */
953ff289
DN
24
25/* Provide target-specific access to the futex system call. */
26
27#include <sys/syscall.h>
28
953ff289
DN
29
30
a68ab351
JJ
31static inline long
32sys_futex0(int *addr, long op, int val)
953ff289
DN
33{
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;
a68ab351
JJ
38 register long r8 asm ("r8");
39 register long r10 asm ("r10");
953ff289
DN
40 register long r15 asm ("r15") = SYS_futex;
41
42 __asm __volatile ("break 0x100000"
a68ab351
JJ
43 : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3),
44 "=r"(r8), "=r"(r10)
953ff289 45 : "r"(r15), "r"(out0), "r"(out1), "r"(out2), "r"(out3)
a68ab351 46 : "memory", "out4", "out5", "out6", "out7",
953ff289
DN
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. */
56 "b6");
a68ab351 57 return r8 & r10;
953ff289
DN
58}
59
60static inline void
61futex_wait (int *addr, int val)
62{
a68ab351
JJ
63 long err = sys_futex0 (addr, gomp_futex_wait, val);
64 if (__builtin_expect (err == ENOSYS, 0))
65 {
66 gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
67 gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
68 sys_futex0 (addr, gomp_futex_wait, val);
69 }
953ff289
DN
70}
71
72static inline void
73futex_wake (int *addr, int count)
74{
a68ab351
JJ
75 long err = sys_futex0 (addr, gomp_futex_wake, count);
76 if (__builtin_expect (err == ENOSYS, 0))
77 {
78 gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
79 gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
80 sys_futex0 (addr, gomp_futex_wake, count);
81 }
82}
83
84static inline void
85cpu_relax (void)
86{
87 __asm volatile ("hint @pause" : : : "memory");
88}
This page took 0.742747 seconds and 5 git commands to generate.