X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=share%2Fkernelcompat.h;h=b442718e2af19a7e611aa36d03f04118834f6ab8;hb=c1dea0b3d1312d0e3747da93eb949145c487eeba;hp=e322bdbaad8c504e7e679e09afaf6a0432adb914;hpb=ba6459ba344b54a4f7775e431447be79fd7790f8;p=ust.git diff --git a/share/kernelcompat.h b/share/kernelcompat.h index e322bdb..b442718 100644 --- a/share/kernelcompat.h +++ b/share/kernelcompat.h @@ -186,37 +186,44 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, return old; } -#define local_cmpxchg cmpxchg +//#define local_cmpxchg cmpxchg +#define local_cmpxchg(l, o, n) (cmpxchg(&((l)->a.counter), (o), (n))) + #define atomic_long_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new))) /* LOCAL OPS */ -typedef int local_t; +//typedef int local_t; +typedef struct +{ + atomic_long_t a; +} local_t; + -static inline void local_inc(local_t *a) +static inline void local_inc(local_t *l) { - (*a)++; + (l->a.counter)++; } -static inline void local_set(local_t *a, int v) +static inline void local_set(local_t *l, int v) { - *a = v; + l->a.counter = v; } -static inline void local_add(int v, local_t *a) +static inline void local_add(int v, local_t *l) { - *a += v; + l->a.counter += v; } -static int local_add_return(int v, local_t *a) +static int local_add_return(int v, local_t *l) { - return *a += v; + return l->a.counter += v; } -static inline int local_read(local_t *a) +static inline int local_read(local_t *l) { - return *a; + return l->a.counter; }