atomic.h00001
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 #ifndef _M68HC11_ATOMIC_H
00029 #define _M68HC11_ATOMIC_H
00030
00075
00076 typedef struct { int counter; } atomic_t;
00077
00078 #define ATOMIC_INIT(i) { (i) }
00079
00080 #define atomic_read(v) ((v)->counter)
00081 #define atomic_set(v,i) (((v)->counter) = (i))
00082
00083 static __inline__ void
00084 atomic_short_add(short i, volatile atomic_short_t *v)
00085 {
00086 unsigned short mask;
00087
00088 mask = lock ();
00089 v->counter += i;
00090 restore (mask);
00091 }
00092
00093 static __inline__ void
00094 atomic_short_sub(short i, volatile atomic_t *v)
00095 {
00096 unsigned short mask;
00097
00098 mask = lock ();
00099 v->counter -= i;
00100 restore (mask);
00101 }
00102
00105 #endif
|