< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-atomic-private.hh

Print this page




  72 
  73 #elif !defined(HB_NO_MT) && defined(__APPLE__)
  74 
  75 #include <libkern/OSAtomic.h>
  76 #ifdef __MAC_OS_X_MIN_REQUIRED
  77 #include <AvailabilityMacros.h>
  78 #elif defined(__IPHONE_OS_MIN_REQUIRED)
  79 #include <Availability.h>
  80 #endif
  81 
  82 
  83 typedef int32_t hb_atomic_int_impl_t;
  84 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  85 #define hb_atomic_int_impl_add(AI, V)           (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
  86 
  87 #define hb_atomic_ptr_impl_get(P)               (OSMemoryBarrier (), (void *) *(P))
  88 #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
  89 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
  90 #else
  91 #if __ppc64__ || __x86_64__ || __aarch64__
  92 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P))
  93 #else
  94 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P))
  95 #endif
  96 #endif
  97 
  98 
  99 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
 100 
 101 typedef int hb_atomic_int_impl_t;
 102 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 103 #define hb_atomic_int_impl_add(AI, V)           __sync_fetch_and_add (&(AI), (V))
 104 
 105 #define hb_atomic_ptr_impl_get(P)               (void *) (__sync_synchronize (), *(P))
 106 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       __sync_bool_compare_and_swap ((P), (O), (N))
 107 
 108 
 109 #elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS)
 110 
 111 #include <atomic.h>
 112 #include <mbarrier.h>
 113 
 114 typedef unsigned int hb_atomic_int_impl_t;
 115 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 116 #define hb_atomic_int_impl_add(AI, V)           ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V))
 117 
 118 #define hb_atomic_ptr_impl_get(P)               ( ({__machine_rw_barrier ();}), (void *) *(P))
 119 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false)
 120 
 121 
 122 #elif !defined(HB_NO_MT) && defined(_AIX) && defined(__IBMCPP__)
 123 
 124 #include <builtins.h>
 125 
 126 
 127 static inline int hb_fetch_and_add(volatile int* AI, unsigned int V) {
 128   __lwsync();
 129   int result = __fetch_and_add(AI, V);
 130   __isync();
 131   return result;
 132 }
 133 static inline int hb_compare_and_swaplp(volatile long* P, long O, long N) {
 134   __sync();
 135   int result = __compare_and_swaplp (P, &O, N);
 136   __sync();
 137   return result;
 138 }
 139 
 140 typedef int hb_atomic_int_impl_t;
 141 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 142 #define hb_atomic_int_impl_add(AI, V)           hb_fetch_and_add (&(AI), (V))
 143 
 144 #define hb_atomic_ptr_impl_get(P)               (__sync(), (void *) *(P))
 145 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))
 146 
 147 #elif !defined(HB_NO_MT)
 148 
 149 #define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */
 150 
 151 typedef volatile int hb_atomic_int_impl_t;
 152 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 153 #define hb_atomic_int_impl_add(AI, V)           (((AI) += (V)) - (V))
 154 
 155 #define hb_atomic_ptr_impl_get(P)               ((void *) *(P))
 156 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false)
 157 
 158 
 159 #else /* HB_NO_MT */
 160 
 161 typedef int hb_atomic_int_impl_t;
 162 #define HB_ATOMIC_INT_IMPL_INIT(V)              (V)
 163 #define hb_atomic_int_impl_add(AI, V)           (((AI) += (V)) - (V))
 164 
 165 #define hb_atomic_ptr_impl_get(P)               ((void *) *(P))




  72 
  73 #elif !defined(HB_NO_MT) && defined(__APPLE__)
  74 
  75 #include <libkern/OSAtomic.h>
  76 #ifdef __MAC_OS_X_MIN_REQUIRED
  77 #include <AvailabilityMacros.h>
  78 #elif defined(__IPHONE_OS_MIN_REQUIRED)
  79 #include <Availability.h>
  80 #endif
  81 
  82 
  83 typedef int32_t hb_atomic_int_impl_t;
  84 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
  85 #define hb_atomic_int_impl_add(AI, V)           (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
  86 
  87 #define hb_atomic_ptr_impl_get(P)               (OSMemoryBarrier (), (void *) *(P))
  88 #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
  89 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
  90 #else
  91 #if __ppc64__ || __x86_64__ || __aarch64__
  92 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       OSAtomicCompareAndSwap64Barrier ((int64_t) (void *) (O), (int64_t) (void *) (N), (int64_t*) (P))
  93 #else
  94 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       OSAtomicCompareAndSwap32Barrier ((int32_t) (void *) (O), (int32_t) (void *) (N), (int32_t*) (P))
  95 #endif
  96 #endif
  97 
  98 
  99 #elif !defined(HB_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
 100 
 101 typedef int hb_atomic_int_impl_t;
 102 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 103 #define hb_atomic_int_impl_add(AI, V)           __sync_fetch_and_add (&(AI), (V))
 104 
 105 #define hb_atomic_ptr_impl_get(P)               (void *) (__sync_synchronize (), *(P))
 106 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       __sync_bool_compare_and_swap ((P), (O), (N))
 107 
 108 
 109 #elif !defined(HB_NO_MT) && defined(HAVE_SOLARIS_ATOMIC_OPS)
 110 
 111 #include <atomic.h>
 112 #include <mbarrier.h>
 113 
 114 typedef unsigned int hb_atomic_int_impl_t;
 115 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 116 #define hb_atomic_int_impl_add(AI, V)           ( ({__machine_rw_barrier ();}), atomic_add_int_nv (&(AI), (V)) - (V))
 117 
 118 #define hb_atomic_ptr_impl_get(P)               ( ({__machine_rw_barrier ();}), (void *) *(P))
 119 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false)
 120 
 121 
 122 #elif !defined(HB_NO_MT) && defined(_AIX) && defined(__IBMCPP__)
 123 
 124 #include <builtins.h>
 125 
 126 
 127 static inline int _hb_fetch_and_add(volatile int* AI, unsigned int V) {
 128   __lwsync();
 129   int result = __fetch_and_add(AI, V);
 130   __isync();
 131   return result;
 132 }
 133 static inline int _hb_compare_and_swaplp(volatile long* P, long O, long N) {
 134   __sync();
 135   int result = __compare_and_swaplp (P, &O, N);
 136   __sync();
 137   return result;
 138 }
 139 
 140 typedef int hb_atomic_int_impl_t;
 141 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 142 #define hb_atomic_int_impl_add(AI, V)           _hb_fetch_and_add (&(AI), (V))
 143 
 144 #define hb_atomic_ptr_impl_get(P)               (__sync(), (void *) *(P))
 145 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       _hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))
 146 
 147 #elif !defined(HB_NO_MT)
 148 
 149 #define HB_ATOMIC_INT_NIL 1 /* Warn that fallback implementation is in use. */
 150 
 151 typedef volatile int hb_atomic_int_impl_t;
 152 #define HB_ATOMIC_INT_IMPL_INIT(V) (V)
 153 #define hb_atomic_int_impl_add(AI, V)           (((AI) += (V)) - (V))
 154 
 155 #define hb_atomic_ptr_impl_get(P)               ((void *) *(P))
 156 #define hb_atomic_ptr_impl_cmpexch(P,O,N)       (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false)
 157 
 158 
 159 #else /* HB_NO_MT */
 160 
 161 typedef int hb_atomic_int_impl_t;
 162 #define HB_ATOMIC_INT_IMPL_INIT(V)              (V)
 163 #define hb_atomic_int_impl_add(AI, V)           (((AI) += (V)) - (V))
 164 
 165 #define hb_atomic_ptr_impl_get(P)               ((void *) *(P))


< prev index next >