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#ifndef SYS_futex 31169695Skan#define SYS_futex 394 32169695Skan#endif 33169695Skan#define FUTEX_WAIT 0 34169695Skan#define FUTEX_WAKE 1 35169695Skan 36169695Skan 37169695Skanstatic inline void 38169695Skanfutex_wait (int *addr, int val) 39169695Skan{ 40169695Skan register long sc_0 __asm__("$0"); 41169695Skan register long sc_16 __asm__("$16"); 42169695Skan register long sc_17 __asm__("$17"); 43169695Skan register long sc_18 __asm__("$18"); 44169695Skan register long sc_19 __asm__("$19"); 45169695Skan 46169695Skan sc_0 = SYS_futex; 47169695Skan sc_16 = (long) addr; 48169695Skan sc_17 = FUTEX_WAIT; 49169695Skan sc_18 = val; 50169695Skan sc_19 = 0; 51169695Skan __asm volatile ("callsys" 52169695Skan : "=r" (sc_0), "=r"(sc_19) 53169695Skan : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18), "1"(sc_19) 54169695Skan : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", 55169695Skan "$22", "$23", "$24", "$25", "$27", "$28", "memory"); 56169695Skan} 57169695Skan 58169695Skanstatic inline void 59169695Skanfutex_wake (int *addr, int count) 60169695Skan{ 61169695Skan register long sc_0 __asm__("$0"); 62169695Skan register long sc_16 __asm__("$16"); 63169695Skan register long sc_17 __asm__("$17"); 64169695Skan register long sc_18 __asm__("$18"); 65169695Skan register long sc_19 __asm__("$19"); 66169695Skan 67169695Skan sc_0 = SYS_futex; 68169695Skan sc_16 = (long) addr; 69169695Skan sc_17 = FUTEX_WAKE; 70169695Skan sc_18 = count; 71169695Skan __asm volatile ("callsys" 72169695Skan : "=r" (sc_0), "=r"(sc_19) 73169695Skan : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18) 74169695Skan : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", 75169695Skan "$22", "$23", "$24", "$25", "$27", "$28", "memory"); 76169695Skan} 77