1169695Skan/* Copyright (C) 2005 Free Software Foundation, Inc. 2169695Skan Contributed by Richard Henderson <rth@redhat.com>. 3169695Skan 4169695Skan This file is part of the GNU OpenMP Library (libgomp). 5169695Skan 6169695Skan Libgomp is free software; you can redistribute it and/or modify it 7169695Skan under the terms of the GNU Lesser General Public License as published by 8169695Skan the Free Software Foundation; either version 2.1 of the License, or 9169695Skan (at your option) any later version. 10169695Skan 11169695Skan Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY 12169695Skan WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13169695Skan FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 14169695Skan more details. 15169695Skan 16169695Skan You should have received a copy of the GNU Lesser General Public License 17169695Skan along with libgomp; see the file COPYING.LIB. If not, write to the 18169695Skan Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19169695Skan MA 02110-1301, USA. */ 20169695Skan 21169695Skan/* As a special exception, if you link this library with other files, some 22169695Skan of which are compiled with GCC, to produce an executable, this library 23169695Skan does not by itself cause the resulting executable to be covered by the 24169695Skan GNU General Public License. This exception does not however invalidate 25169695Skan any other reasons why the executable file might be covered by the GNU 26169695Skan General Public License. */ 27169695Skan 28169695Skan/* Provide target-specific access to the futex system call. */ 29169695Skan 30169695Skan#include <sys/syscall.h> 31169695Skan 32169695Skan#define FUTEX_WAIT 0 33169695Skan#define FUTEX_WAKE 1 34169695Skan 35169695Skan 36169695Skanstatic inline void 37169695Skansys_futex0(int *addr, int op, int val) 38169695Skan{ 39169695Skan register long out0 asm ("out0") = (long) addr; 40169695Skan register long out1 asm ("out1") = op; 41169695Skan register long out2 asm ("out2") = val; 42169695Skan register long out3 asm ("out3") = 0; 43169695Skan register long r15 asm ("r15") = SYS_futex; 44169695Skan 45169695Skan __asm __volatile ("break 0x100000" 46169695Skan : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3) 47169695Skan : "r"(r15), "r"(out0), "r"(out1), "r"(out2), "r"(out3) 48169695Skan : "memory", "r8", "r10", "out4", "out5", "out6", "out7", 49169695Skan /* Non-stacked integer registers, minus r8, r10, r15. */ 50169695Skan "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", 51169695Skan "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", 52169695Skan "r28", "r29", "r30", "r31", 53169695Skan /* Predicate registers. */ 54169695Skan "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", 55169695Skan /* Non-rotating fp registers. */ 56169695Skan "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", 57169695Skan /* Branch registers. */ 58169695Skan "b6"); 59169695Skan} 60169695Skan 61169695Skanstatic inline void 62169695Skanfutex_wait (int *addr, int val) 63169695Skan{ 64169695Skan sys_futex0 (addr, FUTEX_WAIT, val); 65169695Skan} 66169695Skan 67169695Skanstatic inline void 68169695Skanfutex_wake (int *addr, int count) 69169695Skan{ 70169695Skan sys_futex0 (addr, FUTEX_WAKE, count); 71169695Skan} 72