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 {
00012   int volatile cnt;
00013 } oro_atomic_t;
00014 
00015 #define ORO_ATOMIC_SETUP        oro_atomic_set
00016 #define ORO_ATOMIC_CLEANUP(a_int)
00017 
00018 #define oro_atomic_read(a_int)          ((a_int)->cnt)
00019 
00020 #define oro_atomic_set(a_int,n)         (((a_int)->cnt) = (n))
00021 
00025 static __inline__ void oro_atomic_add(oro_atomic_t *a_int, int n)
00026 {
00027   (void)__sync_add_and_fetch(&a_int->cnt, n);
00028 }
00029 
00033 static __inline__ void oro_atomic_sub(oro_atomic_t *a_int, int n)
00034 {
00035   (void)__sync_sub_and_fetch(&a_int->cnt, n);
00036 }
00037 
00041 static __inline__ int oro_atomic_sub_and_test(oro_atomic_t *a_int, int n)
00042 {
00043   return !(__sync_sub_and_fetch(&a_int->cnt, n));
00044 }
00045 
00049 static __inline__ void oro_atomic_inc(oro_atomic_t *a_int)
00050 {
00051   (void)__sync_fetch_and_add(&a_int->cnt, 1);
00052 }
00053 
00057 static __inline__ void oro_atomic_dec(oro_atomic_t *a_int)
00058 {
00059   (void)__sync_fetch_and_sub(&a_int->cnt, 1);
00060 }
00061 
00065 static __inline__ int oro_atomic_dec_and_test(oro_atomic_t *a_int)
00066 {
00067   return !(__sync_sub_and_fetch(&a_int->cnt, 1));
00068 }
00069 
00073 static __inline__ int oro_atomic_inc_and_test(oro_atomic_t *a_int)
00074 {
00075   return !(__sync_add_and_fetch(&a_int->cnt, 1));
00076 }
00077 
00081 #define oro_cmpxchg(ptr,o,n)\
00082     ((__typeof__(*(ptr)))__sync_val_compare_and_swap((ptr),(o),(n)))
00083 
00084 #endif // __GCC_ORO_ARCH__


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:01