Merged revisions 195034,195219,195245,195357,195374,195428,195599,195673,195809 via...
[official-gcc.git] / main / libgomp / config / linux / tile / futex.h
blob2691cc198aa19f8a281bdf1894070db0e600e46c
1 /* Copyright (C) 2011-2013 Free Software Foundation, Inc.
2 Contributed by Walter Lee (walt@tilera.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)
9 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 General Public License for
14 more details.
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>
28 #include <linux/futex.h>
30 static inline void
31 sys_futex0 (int *addr, int op, int val)
33 long _sys_result;
34 long _clobber_r2, _clobber_r3, _clobber_r4, _clobber_r5, _clobber_r10;
35 int err;
37 __asm__ __volatile__ (
38 "swint1"
39 : "=R00" (_sys_result), "=R01" (err), "=R02" (_clobber_r2),
40 "=R03" (_clobber_r3), "=R04" (_clobber_r4), "=R05" (_clobber_r5),
41 "=R10" (_clobber_r10)
42 : "R10" (SYS_futex), "R00" (addr), "R01" (op), "R02" (val),
43 "R03" (0)
44 : "r6", "r7",
45 "r8", "r9", "r11", "r12", "r13", "r14", "r15",
46 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
47 "r24", "r25", "r26", "r27", "r28", "r29", "memory");
50 static inline void
51 futex_wait (int *addr, int val)
53 sys_futex0 (addr, FUTEX_WAIT, val);
56 static inline void
57 futex_wake (int *addr, int count)
59 sys_futex0 (addr, FUTEX_WAKE, count);
62 static inline void
63 cpu_relax (void)
65 __asm volatile ("" : : : "memory");
68 static inline void
69 atomic_write_barrier (void)
71 __sync_synchronize ();