]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgomp/config/linux/mips/futex.h
1 /* Copyright (C) 2005-2018 Free Software Foundation, Inc.
2 Contributed by Ilie Garbacea <ilie@mips.com>, Chao-ying Fu <fu@mips.com>.
4 This file is part of the GNU Offloading and Multi Processing Library
7 Libgomp is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 /* Provide target-specific access to the futex system call. */
28 #include <sys/syscall.h>
30 #if !defined (SYS_futex)
31 #define SYS_futex __NR_futex
38 static void __attribute__((noinline
,nomips16
))
42 sys_futex0 (int *addr
, int op
, int val
)
44 register unsigned long __v0
asm("$2");
45 register unsigned long __a0
asm("$4") = (unsigned long) addr
;
46 register unsigned long __a1
asm("$5") = (unsigned long) op
;
47 register unsigned long __a2
asm("$6") = (unsigned long) val
;
48 register unsigned long __a3
asm("$7") = 0;
50 __asm
volatile ("li $2, %6\n\t"
52 /* returns $a3 (errno), $v0 (return value) */
53 : "=r" (__v0
), "=r" (__a3
)
54 /* arguments in a0-a3, and syscall number */
55 : "r" (__a0
), "r" (__a1
), "r" (__a2
), "r" (__a3
),
57 /* clobbers at, v1, t0-t9, memory */
58 : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14",
59 "$15", "$24", "$25", "memory");
63 futex_wait (int *addr
, int val
)
65 sys_futex0 (addr
, FUTEX_WAIT
, val
);
69 futex_wake (int *addr
, int count
)
71 sys_futex0 (addr
, FUTEX_WAKE
, count
);
77 __asm
volatile ("" : : : "memory");