/home/ntakagi/work/STLport-5.1.5/stlport/stl/_sparc_atomic.hGo to the documentation of this file.00001 00002 // Currently, SUN CC requires object file 00003 00004 #if defined (__GNUC__) 00005 00006 /* 00007 ** int _STLP_atomic_exchange (__stl_atomic_t *pvalue, __stl_atomic_t value) 00008 */ 00009 00010 # if defined(__sparc_v9__) || defined (__sparcv9) 00011 00012 # ifdef __arch64__ 00013 00014 # define _STLP_EXCH_ASM asm volatile ("casx [%3], %4, %0 ; membar #LoadLoad | #LoadStore " : \ 00015 "=r" (_L_value2), "=m" (*_L_pvalue1) : \ 00016 "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) ) 00017 00018 # else /* __arch64__ */ 00019 00020 # define _STLP_EXCH_ASM asm volatile ("cas [%3], %4, %0" : \ 00021 "=r" (_L_value2), "=m" (*_L_pvalue1) : \ 00022 "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) ) 00023 # endif 00024 00025 # else /* __sparc_v9__ */ 00026 00027 # define _STLP_EXCH_ASM asm volatile ("swap [%3], %0 " : \ 00028 "=r" (_L_value2), "=m" (*_L_pvalue1) : \ 00029 "m" (*_L_pvalue1), "r" (_L_pvalue1), "0" (_L_value2) ) 00030 # endif 00031 00032 00033 # define _STLP_ATOMIC_EXCHANGE(__pvalue1, __value2) \ 00034 ({ register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \ 00035 register __stl_atomic_t _L_value1, _L_value2 = __value2 ; \ 00036 do { _L_value1 = *_L_pvalue1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \ 00037 _L_value1; }) 00038 00039 # define _STLP_ATOMIC_INCREMENT(__pvalue1) \ 00040 ({ register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \ 00041 register __stl_atomic_t _L_value1, _L_value2; \ 00042 do { _L_value1 = *_L_pvalue1; _L_value2 = _L_value1+1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \ 00043 (_L_value2 + 1); }) 00044 00045 # define _STLP_ATOMIC_DECREMENT(__pvalue1) \ 00046 ({ register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \ 00047 register __stl_atomic_t _L_value1, _L_value2; \ 00048 do { _L_value1 = *_L_pvalue1; _L_value2 = _L_value1-1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \ 00049 (_L_value2 - 1); }) 00050 00051 # elif ! defined (_STLP_NO_EXTERN_INLINE) 00052 00053 extern "C" __stl_atomic_t _STLP_atomic_exchange(__stl_atomic_t * __x, __stl_atomic_t __v); 00054 extern "C" void _STLP_atomic_decrement(__stl_atomic_t* i); 00055 extern "C" void _STLP_atomic_increment(__stl_atomic_t* i); 00056 00057 # define _STLP_ATOMIC_INCREMENT(__x) _STLP_atomic_increment((__stl_atomic_t*)__x) 00058 # define _STLP_ATOMIC_DECREMENT(__x) _STLP_atomic_decrement((__stl_atomic_t*)__x) 00059 # define _STLP_ATOMIC_EXCHANGE(__x, __y) _STLP_atomic_exchange((__stl_atomic_t*)__x, (__stl_atomic_t)__y) 00060 00061 # endif 00062
Generated on Mon Mar 10 15:32:36 2008 by ![]() |