oro_arch.h
Go to the documentation of this file.
00001 #ifndef __GCC_ORO_ARCH__
00002 #define __GCC_ORO_ARCH__
00003 
00004 #include "../../rtt-config.h"
00005 
00010 typedef struct {
00011     int volatile cnt;
00012 } oro_atomic_t;
00013 
00014 #define ORO_ATOMIC_SETUP        oro_atomic_set
00015 #define ORO_ATOMIC_CLEANUP(a_int)
00016 
00017 #define oro_atomic_read(a_int)          ((a_int)->cnt)
00018 
00019 #define oro_atomic_set(a_int,n)         (((a_int)->cnt) = (n))
00020 
00024 static __inline__ void oro_atomic_add(oro_atomic_t *a_int, int n)
00025 {
00026     (void)__sync_add_and_fetch(&a_int->cnt, n);
00027 }
00028 
00032 static __inline__ void oro_atomic_sub(oro_atomic_t *a_int, int n)
00033 {
00034     (void)__sync_sub_and_fetch(&a_int->cnt, n);
00035 }
00036 
00040 static __inline__ int oro_atomic_sub_and_test(oro_atomic_t *a_int, int n)
00041 {
00042     return !(__sync_sub_and_fetch(&a_int->cnt, n));
00043 }
00044 
00048 static __inline__ void oro_atomic_inc(oro_atomic_t *a_int)
00049 {
00050     (void)__sync_fetch_and_add(&a_int->cnt, 1);
00051 }
00052 
00056 static __inline__ void oro_atomic_dec(oro_atomic_t *a_int)
00057 {
00058     (void)__sync_fetch_and_sub(&a_int->cnt, 1);
00059 }
00060 
00064 static __inline__ int oro_atomic_dec_and_test(oro_atomic_t *a_int)
00065 {
00066     return !(__sync_sub_and_fetch(&a_int->cnt, 1));
00067 }
00068 
00072 static __inline__ int oro_atomic_inc_and_test(oro_atomic_t *a_int)
00073 {
00074     return !(__sync_add_and_fetch(&a_int->cnt, 1));
00075 }
00076 
00080 #define oro_cmpxchg(ptr,o,n)\
00081     ((__typeof__(*(ptr)))__sync_val_compare_and_swap((ptr),(o),(n)))
00082 
00083 
00084 #endif // __GCC_ORO_ARCH__


rtt
Author(s): RTT Developers
autogenerated on Fri Sep 9 2016 04:01:55