epoc32/include/tools/stlport/stl/_sparc_atomic.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 
     2 // Currently, SUN CC requires object file
     3 
     4 #if defined (__GNUC__)
     5 
     6 /*
     7 **  int _STLP_atomic_exchange (__stl_atomic_t *pvalue, __stl_atomic_t value)
     8 */
     9 
    10 # ifdef __sparc_v9__
    11 
    12 #  ifdef __arch64__
    13 
    14 #   define _STLP_EXCH_ASM  asm volatile ("casx [%3], %4, %0 ;  membar  #LoadLoad | #LoadStore " : \
    15                    "=r" (_L_value2), "=m" (*_L_pvalue1) : \
    16                    "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) )
    17 
    18 #  else /* __arch64__ */
    19 
    20 #   define _STLP_EXCH_ASM  asm volatile ("cas [%3], %4, %0" : \
    21                    "=r" (_L_value2), "=m" (*_L_pvalue1) : \
    22                    "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) )
    23 #  endif
    24 
    25 # else /* __sparc_v9__ */
    26 
    27 #  define _STLP_EXCH_ASM asm volatile ("swap [%3], %0 " : \
    28                                        "=r" (_L_value2), "=m" (*_L_pvalue1) : \
    29                                        "m" (*_L_pvalue1), "r" (_L_pvalue1),  "0" (_L_value2) )
    30 # endif
    31 
    32 
    33 #  define _STLP_ATOMIC_EXCHANGE(__pvalue1, __value2) \
    34  ({  register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \
    35      register __stl_atomic_t _L_value1, _L_value2 =  __value2 ; \
    36      do { _L_value1 = *_L_pvalue1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \
    37      _L_value1; })
    38 
    39 #  define _STLP_ATOMIC_INCREMENT(__pvalue1) \
    40  {  register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \
    41     register __stl_atomic_t _L_value1, _L_value2; \
    42     do { _L_value1 = *_L_pvalue1;  _L_value2 = _L_value1+1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; }
    43 
    44 #  define _STLP_ATOMIC_DECREMENT(__pvalue1) \
    45  {  register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \
    46     register __stl_atomic_t _L_value1, _L_value2; \
    47     do { _L_value1 = *_L_pvalue1;  _L_value2 = _L_value1-1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; }
    48 
    49 # elif ! defined (_STLP_NO_EXTERN_INLINE)
    50 
    51 extern "C" __stl_atomic_t _STLP_atomic_exchange(__stl_atomic_t * __x, __stl_atomic_t __v);
    52 extern "C" void _STLP_atomic_decrement(__stl_atomic_t* i);
    53 extern "C" void _STLP_atomic_increment(__stl_atomic_t* i);
    54 
    55 #  define _STLP_ATOMIC_INCREMENT(__x)           _STLP_atomic_increment((__stl_atomic_t*)__x)
    56 #  define _STLP_ATOMIC_DECREMENT(__x)           _STLP_atomic_decrement((__stl_atomic_t*)__x)
    57 #  define _STLP_ATOMIC_EXCHANGE(__x, __y)       _STLP_atomic_exchange((__stl_atomic_t*)__x, (__stl_atomic_t)__y)
    58 
    59 # endif
    60