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 #ifndef _RTAI_ASM_I386_ATOMIC_H
00046 #define _RTAI_ASM_I386_ATOMIC_H
00047
00048 #include <linux/bitops.h>
00049 #include <asm/atomic.h>
00050
00051 #ifdef __KERNEL__
00052
00053 #include <asm/system.h>
00054
00055 #define atomic_xchg(ptr,v) xchg(ptr,v)
00056 #define atomic_cmpxchg(ptr,o,n) cmpxchg(ptr,o,n)
00057 #define xnarch_memory_barrier() smp_mb()
00058
00059 #else
00060
00061 struct __rtai_xchg_dummy { unsigned long a[100]; };
00062 #define __rtai_xg(x) ((struct __rtai_xchg_dummy *)(x))
00063
00064 static inline unsigned long atomic_xchg (volatile void *ptr,
00065 unsigned long x)
00066 {
00067 __asm__ __volatile__(LOCK_PREFIX "xchgl %0,%1"
00068 :"=r" (x)
00069 :"m" (*__rtai_xg(ptr)), "0" (x)
00070 :"memory");
00071 return x;
00072 }
00073
00074 static inline unsigned long atomic_cmpxchg (volatile void *ptr,
00075 unsigned long o,
00076 unsigned long n)
00077 {
00078 unsigned long prev;
00079
00080 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
00081 : "=a"(prev)
00082 : "q"(n), "m" (*__rtai_xg(ptr)), "0" (o)
00083 : "memory");
00084
00085 return prev;
00086 }
00087
00088 #define xnarch_memory_barrier() __asm__ __volatile__("": : :"memory")
00089
00090
00091 #undef ADDR
00092
00093 #endif
00094
00095 typedef atomic_t atomic_counter_t;
00096 typedef unsigned long atomic_flags_t;
00097
00098 #define xnarch_atomic_set(pcounter,i) atomic_set(pcounter,i)
00099 #define xnarch_atomic_get(pcounter) atomic_read(pcounter)
00100 #define xnarch_atomic_inc(pcounter) atomic_inc(pcounter)
00101 #define xnarch_atomic_dec(pcounter) atomic_dec(pcounter)
00102 #define xnarch_atomic_inc_and_test(pcounter) atomic_inc_and_test(pcounter)
00103 #define xnarch_atomic_dec_and_test(pcounter) atomic_dec_and_test(pcounter)
00104 #define xnarch_atomic_set_mask(pflags,mask) atomic_set_mask(mask,pflags)
00105 #define xnarch_atomic_clear_mask(pflags,mask) atomic_clear_mask(mask,pflags)
00106
00107 #define xnarch_atomic_xchg(ptr,x) atomic_xchg(ptr,x)
00108
00109 #endif