00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 }