X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=share%2Fkernelcompat.h;h=aa3d0facba17f8333148d409e1500eb99ac0eaf6;hb=59b161cdfcaad93fee295add37090a3d991e7aa8;hp=b6615eeaf1edfbd7d95090d0d4658dfedaf9da2c;hpb=183646e613012a150edf2aa814e9bc44fd67e089;p=ust.git diff --git a/share/kernelcompat.h b/share/kernelcompat.h index b6615ee..aa3d0fa 100644 --- a/share/kernelcompat.h +++ b/share/kernelcompat.h @@ -1,6 +1,8 @@ #ifndef KERNELCOMPAT_H #define KERNELCOMPAT_H +#include "compiler.h" + #include #define container_of(ptr, type, member) ({ \ @@ -10,16 +12,36 @@ #define KERN_DEBUG #define KERN_NOTICE +/* ERROR OPS */ + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) + static inline void *ERR_PTR(long error) { - return (void *) error; + return (void *) error; } +static inline long PTR_ERR(const void *ptr) +{ + return (long) ptr; +} + +static inline long IS_ERR(const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + + +/* FIXED SIZE INTEGERS */ #include +typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; +typedef uint64_t u64; #include @@ -43,14 +65,47 @@ typedef uint32_t u32; #define printk(fmt, args...) printf(fmt, ## args) +/* MEMORY BARRIERS */ + +#define smp_rmb() do {} while(0) +#define smp_wmb() do {} while(0) +#define smp_mb() do {} while(0) +#define smp_mb__after_atomic_inc() do {} while(0) + +#define read_barrier_depends() do {} while(0) +#define smp_read_barrier_depends() do {} while(0) -#define smp_rmb() -#define smp_wmb() +/* RCU */ +#define rcu_assign_pointer(a, b) do {} while(0) -#define read_barrier_depends() -#define smp_read_barrier_depends() +/* ATOMICITY */ +#include + +typedef struct { sig_atomic_t counter; } atomic_t; + +static inline int atomic_dec_and_test(atomic_t *p) +{ + (p->counter)--; + return !p->counter; +} + +static inline void atomic_set(atomic_t *p, int v) +{ + p->counter=v; +} + +static inline void atomic_inc(atomic_t *p) +{ + p->counter++; +} + +static int atomic_read(atomic_t *p) +{ + return p->counter; +} +/* CACHE */ +#define ____cacheline_aligned -#define rcu_assign_pointer(a, b) #endif /* KERNELCOMPAT_H */