< prev index next >

src/os_cpu/linux_aarch64/vm/atomic_linux_aarch64.hpp

Print this page
rev 13452 : [mq]: coleen_review1


  74 
  75 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest)
  76 {
  77   jint res = __sync_lock_test_and_set (dest, exchange_value);
  78   FULL_MEM_BARRIER;
  79   return res;
  80 }
  81 
  82 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest)
  83 {
  84   return (void *) xchg_ptr((intptr_t) exchange_value,
  85                            (volatile intptr_t*) dest);
  86 }
  87 
  88 template<size_t byte_size>
  89 template<typename T>
  90 inline T Atomic::PlatformCmpxchg<byte_size>::operator()(T exchange_value,
  91                                                         T volatile* dest,
  92                                                         T compare_value,
  93                                                         cmpxchg_memory_order) const {

  94   if (order == memory_order_relaxed) {
  95     T value = compare_value;
  96     __atomic_compare_exchange(dest, &value, &exchange_value, /*weak*/false,
  97                               __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  98     return value;
  99   } else {
 100     return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
 101   }
 102 }
 103 
 104 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; }
 105 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; }
 106 
 107 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest)
 108 {
 109  return __sync_add_and_fetch(dest, add_value);
 110 }
 111 
 112 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest)
 113 {




  74 
  75 inline jint Atomic::xchg (jint exchange_value, volatile jint* dest)
  76 {
  77   jint res = __sync_lock_test_and_set (dest, exchange_value);
  78   FULL_MEM_BARRIER;
  79   return res;
  80 }
  81 
  82 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest)
  83 {
  84   return (void *) xchg_ptr((intptr_t) exchange_value,
  85                            (volatile intptr_t*) dest);
  86 }
  87 
  88 template<size_t byte_size>
  89 template<typename T>
  90 inline T Atomic::PlatformCmpxchg<byte_size>::operator()(T exchange_value,
  91                                                         T volatile* dest,
  92                                                         T compare_value,
  93                                                         cmpxchg_memory_order) const {
  94   STATIC_ASSERT(byte_size == sizeof(T));
  95   if (order == memory_order_relaxed) {
  96     T value = compare_value;
  97     __atomic_compare_exchange(dest, &value, &exchange_value, /*weak*/false,
  98                               __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  99     return value;
 100   } else {
 101     return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
 102   }
 103 }
 104 
 105 inline void Atomic::store (jlong store_value, jlong* dest) { *dest = store_value; }
 106 inline void Atomic::store (jlong store_value, volatile jlong* dest) { *dest = store_value; }
 107 
 108 inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest)
 109 {
 110  return __sync_add_and_fetch(dest, add_value);
 111 }
 112 
 113 inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest)
 114 {


< prev index next >