]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgomp/config/linux/mips/futex.h
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / libgomp / config / linux / mips / futex.h
CommitLineData
318e8c3f
IG
1/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2 Contributed by Ilie Garbacea <ilie@mips.com>, Chao-ying Fu <fu@mips.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
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.
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
13 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 more details.
15
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. */
20
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. */
27
28/* Provide target-specific access to the futex system call. */
29
30#include <sys/syscall.h>
31#define FUTEX_WAIT 0
32#define FUTEX_WAKE 1
33
34static inline void
35sys_futex0 (int *addr, int op, int val)
36{
37 register unsigned long __v0 asm("$2") = (unsigned long) SYS_futex;
38 register unsigned long __a0 asm("$4") = (unsigned long) addr;
39 register unsigned long __a1 asm("$5") = (unsigned long) op;
40 register unsigned long __a2 asm("$6") = (unsigned long) val;
41 register unsigned long __a3 asm("$7") = 0;
42
43 __asm volatile ("syscall"
44 /* returns $a3 (errno), $v0 (return value) */
45 : "=r" (__v0), "=r" (__a3)
46 /* arguments in v0 (syscall) a0-a3 */
47 : "r" (__v0), "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a3)
48 /* clobbers at, v1, t0-t9, memory */
49 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14",
50 "$15", "$24", "$25", "memory");
51}
52
53static inline void
54futex_wait (int *addr, int val)
55{
56 sys_futex0 (addr, FUTEX_WAIT, val);
57}
58
59static inline void
60futex_wake (int *addr, int count)
61{
62 sys_futex0 (addr, FUTEX_WAKE, count);
63}
64
65static inline void
66cpu_relax (void)
67{
68 __asm volatile ("" : : : "memory");
69}
70
71static inline void
72atomic_write_barrier (void)
73{
74 __sync_synchronize ();
75}