00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "./aligned_atomic_load_store.h"
00023
00024
00025 #include "./ordered_except_wr.h"
00026
00027
00028 #include "./test_and_set_t_is_char.h"
00029
00030 AO_INLINE AO_TS_VAL_t
00031 AO_test_and_set_full(volatile AO_TS_t *addr) {
00032 AO_TS_VAL_t oldval;
00033
00034 __asm__ __volatile__("ldstub %1,%0"
00035 : "=r"(oldval), "=m"(*addr)
00036 : "m"(*addr) : "memory");
00037 return oldval;
00038 }
00039
00040 #define AO_HAVE_test_and_set_full
00041
00042 #ifndef AO_NO_SPARC_V9
00043
00044 AO_INLINE int
00045 AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {
00046 char ret;
00047 __asm__ __volatile__ ("membar #StoreLoad | #LoadLoad\n\t"
00048 # if defined(__arch64__)
00049 "casx [%2],%0,%1\n\t"
00050 # else
00051 "cas [%2],%0,%1\n\t"
00052 # endif
00053 "membar #StoreLoad | #StoreStore\n\t"
00054 "cmp %0,%1\n\t"
00055 "be,a 0f\n\t"
00056 "mov 1,%0\n\t"
00057 "clr %0\n\t"
00058 "0:\n\t"
00059 : "=r" (ret), "+r" (new_val)
00060 : "r" (addr), "0" (old)
00061 : "memory", "cc");
00062 return (int)ret;
00063 }
00064
00065 #define AO_HAVE_compare_and_swap_full
00066 #endif
00067
00068
00069
00070
00071
00072