00001
00002
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
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _ATOMIC_H_
00058 # define _ATOMIC_H_
00059
00060 # include <atomic_ops.h>
00061
00062 typedef AO_t atomic_t;
00063
00064 # ifdef NO_AO
00065
00066 # define ATOMIC_CAS_FULL(a, e, v) (*(a) = (v), 1)
00067 # define ATOMIC_FETCH_INC_FULL(a) ((*(a))++)
00068 # define ATOMIC_FETCH_DEC_FULL(a) ((*(a))--)
00069 # define ATOMIC_FETCH_ADD_FULL(a, v) ((*(a)) += (v))
00070 # define ATOMIC_LOAD_ACQ(a) (*(a))
00071 # define ATOMIC_LOAD(a) (*(a))
00072 # define ATOMIC_STORE_REL(a, v) (*(a) = (v))
00073 # define ATOMIC_STORE(a, v) (*(a) = (v))
00074 # define ATOMIC_MB_READ
00075 # define ATOMIC_MB_WRITE
00076 # define ATOMIC_MB_FULL
00077 # else
00078 # define ATOMIC_CAS_FULL(a, e, v) (AO_compare_and_swap_full((volatile AO_t *)(a), (AO_t)(e), (AO_t)(v)))
00079 # define ATOMIC_FETCH_INC_FULL(a) (AO_fetch_and_add1_full((volatile AO_t *)(a)))
00080 # define ATOMIC_FETCH_DEC_FULL(a) (AO_fetch_and_sub1_full((volatile AO_t *)(a)))
00081 # define ATOMIC_FETCH_ADD_FULL(a, v) (AO_fetch_and_add_full((volatile AO_t *)(a), (AO_t)(v)))
00082 # ifdef SAFE
00083 # define ATOMIC_LOAD_ACQ(a) (AO_load_full((volatile AO_t *)(a)))
00084 # define ATOMIC_LOAD(a) (AO_load_full((volatile AO_t *)(a)))
00085 # define ATOMIC_STORE_REL(a, v) (AO_store_full((volatile AO_t *)(a), (AO_t)(v)))
00086 # define ATOMIC_STORE(a, v) (AO_store_full((volatile AO_t *)(a), (AO_t)(v)))
00087 # define ATOMIC_MB_READ AO_nop_full()
00088 # define ATOMIC_MB_WRITE AO_nop_full()
00089 # define ATOMIC_MB_FULL AO_nop_full()
00090 # else
00091 # define ATOMIC_LOAD_ACQ(a) (AO_load_acquire_read((volatile AO_t *)(a)))
00092 # define ATOMIC_LOAD(a) (*((volatile AO_t *)(a)))
00093 # define ATOMIC_STORE_REL(a, v) (AO_store_release((volatile AO_t *)(a), (AO_t)(v)))
00094 # define ATOMIC_STORE(a, v) (*((volatile AO_t *)(a)) = (AO_t)(v))
00095 # define ATOMIC_MB_READ AO_nop_read()
00096 # define ATOMIC_MB_WRITE AO_nop_write()
00097 # define ATOMIC_MB_FULL AO_nop_full()
00098 # endif
00099 # endif
00100
00101
00102 #endif