config/linux/alpha/futex.h

Go to the documentation of this file.
00001 /* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
00002    Contributed by Richard Henderson <rth@redhat.com>.
00003 
00004    This file is part of the GNU OpenMP Library (libgomp).
00005 
00006    Libgomp is free software; you can redistribute it and/or modify it
00007    under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3, or (at your option)
00009    any later version.
00010 
00011    Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
00012    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00014    more details.
00015 
00016    Under Section 7 of GPL version 3, you are granted additional
00017    permissions described in the GCC Runtime Library Exception, version
00018    3.1, as published by the Free Software Foundation.
00019 
00020    You should have received a copy of the GNU General Public License and
00021    a copy of the GCC Runtime Library Exception along with this program;
00022    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023    <http://www.gnu.org/licenses/>.  */
00024 
00025 /* Provide target-specific access to the futex system call.  */
00026 
00027 #ifndef SYS_futex
00028 #define SYS_futex               394
00029 #endif
00030 
00031 
00032 static inline void
00033 futex_wait (int *addr, int val)
00034 {
00035   register long sc_0 __asm__("$0");
00036   register long sc_16 __asm__("$16");
00037   register long sc_17 __asm__("$17");
00038   register long sc_18 __asm__("$18");
00039   register long sc_19 __asm__("$19");
00040 
00041   sc_0 = SYS_futex;
00042   sc_16 = (long) addr;
00043   sc_17 = gomp_futex_wait;
00044   sc_18 = val;
00045   sc_19 = 0;
00046   __asm volatile ("callsys"
00047           : "=r" (sc_0), "=r"(sc_19)
00048           : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18), "1"(sc_19)
00049           : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
00050             "$22", "$23", "$24", "$25", "$27", "$28", "memory");
00051   if (__builtin_expect (sc_19, 0) && sc_0 == ENOSYS)
00052     {
00053       gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
00054       gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
00055       sc_0 = SYS_futex;
00056       sc_17 &= ~FUTEX_PRIVATE_FLAG;
00057       sc_19 = 0;
00058       __asm volatile ("callsys"
00059               : "=r" (sc_0), "=r"(sc_19)
00060               : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18),
00061             "1"(sc_19)
00062               : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
00063             "$22", "$23", "$24", "$25", "$27", "$28", "memory");
00064     }
00065 }
00066 
00067 static inline void
00068 futex_wake (int *addr, int count)
00069 {
00070   register long sc_0 __asm__("$0");
00071   register long sc_16 __asm__("$16");
00072   register long sc_17 __asm__("$17");
00073   register long sc_18 __asm__("$18");
00074   register long sc_19 __asm__("$19");
00075 
00076   sc_0 = SYS_futex;
00077   sc_16 = (long) addr;
00078   sc_17 = gomp_futex_wake;
00079   sc_18 = count;
00080   __asm volatile ("callsys"
00081           : "=r" (sc_0), "=r"(sc_19)
00082           : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18)
00083           : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
00084             "$22", "$23", "$24", "$25", "$27", "$28", "memory");
00085   if (__builtin_expect (sc_19, 0) && sc_0 == ENOSYS)
00086     {
00087       gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
00088       gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
00089       sc_0 = SYS_futex;
00090       sc_17 &= ~FUTEX_PRIVATE_FLAG;
00091       __asm volatile ("callsys"
00092               : "=r" (sc_0), "=r"(sc_19)
00093               : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18)
00094               : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
00095             "$22", "$23", "$24", "$25", "$27", "$28", "memory");
00096     }
00097 }
00098 
00099 static inline void
00100 cpu_relax (void)
00101 {
00102   __asm volatile ("" : : : "memory");
00103 }
00104 
00105 static inline void
00106 atomic_write_barrier (void)
00107 {
00108   __asm volatile ("wmb" : : : "memory");
00109 }

Generated on Fri Apr 5 05:38:09 2013 for Libgomp by  doxygen 1.4.7