Go to the documentation of this file.00001 #ifndef BOOST_DETAIL_ATOMIC_LINUX_ARM_HPP
00002 #define BOOST_DETAIL_ATOMIC_LINUX_ARM_HPP
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
00028
00029
00030
00031
00032
00033 #include <boost/memory_order.hpp>
00034 #include <boost/atomic/detail/base.hpp>
00035
00036 #define BOOST_ATOMIC_CHAR_LOCK_FREE 2
00037 #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 2
00038 #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 2
00039 #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2
00040 #define BOOST_ATOMIC_SHORT_LOCK_FREE 2
00041 #define BOOST_ATOMIC_INT_LOCK_FREE 2
00042 #define BOOST_ATOMIC_LONG_LOCK_FREE 2
00043 #define BOOST_ATOMIC_LLONG_LOCK_FREE 0
00044 #define BOOST_ATOMIC_ADDRESS_LOCK_FREE 2
00045 #define BOOST_ATOMIC_BOOL_LOCK_FREE 2
00046
00047 namespace boost {
00048 namespace detail {
00049 namespace atomic {
00050
00051 static inline void
00052 arm_barrier(void)
00053 {
00054 void (*kernel_dmb)(void) = (void (*)(void)) 0xffff0fa0;
00055 kernel_dmb();
00056 }
00057
00058 static inline void
00059 platform_fence_before(memory_order order)
00060 {
00061 switch(order) {
00062 case memory_order_release:
00063 case memory_order_acq_rel:
00064 case memory_order_seq_cst:
00065 arm_barrier();
00066 case memory_order_consume:
00067 default:;
00068 }
00069 }
00070
00071 static inline void
00072 platform_fence_after(memory_order order)
00073 {
00074 switch(order) {
00075 case memory_order_acquire:
00076 case memory_order_acq_rel:
00077 case memory_order_seq_cst:
00078 arm_barrier();
00079 default:;
00080 }
00081 }
00082
00083 static inline void
00084 platform_fence_before_store(memory_order order)
00085 {
00086 platform_fence_before(order);
00087 }
00088
00089 static inline void
00090 platform_fence_after_store(memory_order order)
00091 {
00092 if (order == memory_order_seq_cst)
00093 arm_barrier();
00094 }
00095
00096 static inline void
00097 platform_fence_after_load(memory_order order)
00098 {
00099 platform_fence_after(order);
00100 }
00101
00102 template<typename T>
00103 bool
00104 platform_cmpxchg32(T & expected, T desired, volatile T * ptr)
00105 {
00106 typedef T (*kernel_cmpxchg32_t)(T oldval, T newval, volatile T * ptr);
00107
00108 if (((kernel_cmpxchg32_t) 0xffff0fc0)(expected, desired, ptr) == 0) {
00109 return true;
00110 } else {
00111 expected = *ptr;
00112 return false;
00113 }
00114 }
00115
00116 }
00117 }
00118
00119 #define BOOST_ATOMIC_THREAD_FENCE 2
00120 static inline void
00121 atomic_thread_fence(memory_order order)
00122 {
00123 switch(order) {
00124 case memory_order_acquire:
00125 case memory_order_release:
00126 case memory_order_acq_rel:
00127 case memory_order_seq_cst:
00128 detail::atomic::arm_barrier();
00129 default:;
00130 }
00131 }
00132
00133 #define BOOST_ATOMIC_SIGNAL_FENCE 2
00134 static inline void
00135 atomic_signal_fence(memory_order)
00136 {
00137 __asm__ __volatile__ ("" ::: "memory");
00138 }
00139
00140 }
00141
00142 #include <boost/atomic/detail/cas32weak.hpp>
00143
00144 #endif