f141bc54e88555534cb2786665a51dbdd3191e97
11 #define container_of(ptr, type, member) ({ \
12 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
13 (type *)( (char *)__mptr - offsetof(type,member) );})
16 #define KERN_NOTICE ""
20 #define KERN_WARNING ""
24 #define MAX_ERRNO 4095
26 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
28 static inline void *ERR_PTR(long error
)
30 return (void *) error
;
33 static inline long PTR_ERR(const void *ptr
)
38 static inline long IS_ERR(const void *ptr
)
40 return IS_ERR_VALUE((unsigned long)ptr
);
44 /* FIXED SIZE INTEGERS */
49 //typedef uint16_t u16;
50 //typedef uint32_t u32;
51 //typedef uint64_t u64;
53 #define min_t(type, x, y) ({ \
56 __min1 < __min2 ? __min1: __min2; })
58 #define max_t(type, x, y) ({ \
61 __max1 > __max2 ? __max1: __max2; })
68 #define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
69 #define DECLARE_MUTEX(m) extern pthread_mutex_t (m);
71 #define mutex_lock(m) pthread_mutex_lock(m)
73 #define mutex_unlock(m) pthread_mutex_unlock(m)
80 #define kmalloc(s, t) malloc(s)
81 #define kzalloc(s, t) zmalloc(s)
82 #define kfree(p) free((void *)p)
83 #define kstrdup(s, t) strdup(s)
85 #define zmalloc(s) calloc(1, s)
92 #define printk(fmt, args...) printf(fmt, ## args)
96 #define smp_mb__after_atomic_inc() do {} while(0)
101 //#define call_rcu_sched(a,b) b(a); synchronize_rcu()
102 //#define rcu_barrier_sched() do {} while(0) /* this nop is ok if call_rcu_sched does a synchronize_rcu() */
103 //#define rcu_read_lock_sched_notrace() rcu_read_lock()
104 //#define rcu_read_unlock_sched_notrace() rcu_read_unlock()
110 static inline int atomic_dec_and_test(atomic_t
*p
)
116 static inline void atomic_set(atomic_t
*p
, int v
)
121 static inline void atomic_inc(atomic_t
*p
)
126 static int atomic_read(atomic_t
*p
)
131 #define atomic_long_t atomic_t
132 #define atomic_long_set atomic_set
133 #define atomic_long_read atomic_read
135 //#define __xg(x) ((volatile long *)(x))
137 #define cmpxchg(ptr, o, n) \
138 ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \
139 (unsigned long)(n), sizeof(*(ptr))))
141 //#define local_cmpxchg cmpxchg
142 #define local_cmpxchg(l, o, n) (cmpxchg(&((l)->a.counter), (o), (n)))
144 #define atomic_long_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
149 //typedef int local_t;
156 static inline void local_inc(local_t
*l
)
161 static inline void local_set(local_t
*l
, int v
)
166 static inline void local_add(int v
, local_t
*l
)
171 static int local_add_return(int v
, local_t
*l
)
173 return l
->a
.counter
+= v
;
176 static inline int local_read(local_t
*l
)
184 #define ____cacheline_aligned
190 static inline unsigned int hweight32(unsigned int w
)
192 unsigned int res
= w
- ((w
>> 1) & 0x55555555);
193 res
= (res
& 0x33333333) + ((res
>> 2) & 0x33333333);
194 res
= (res
+ (res
>> 4)) & 0x0F0F0F0F;
195 res
= res
+ (res
>> 8);
196 return (res
+ (res
>> 16)) & 0x000000FF;
199 static inline int fls(int x
)
202 //ust// #ifdef CONFIG_X86_CMOV
205 : "=&r" (r
) : "rm" (x
), "rm" (-1));
207 //ust// asm("bsrl %1,%0\n\t"
209 //ust// "movl $-1,%0\n"
210 //ust// "1:" : "=r" (r) : "rm" (x));
215 static __inline__
int get_count_order(unsigned int count
)
219 order
= fls(count
) - 1;
220 if (count
& (count
- 1))
230 #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
231 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
232 #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
233 #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
234 #define PAGE_MASK (PAGE_SIZE-1)
241 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
245 //ust// static inline u64 trace_clock_read64(void)
247 //ust// uint32_t low;
248 //ust// uint32_t high;
249 //ust// uint64_t retval;
250 //ust// __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));
252 //ust// retval = high;
253 //ust// retval <<= 32;
254 //ust// return retval | low;
257 static inline u64
trace_clock_read64(void)
262 gettimeofday(&tv
, NULL
);
265 retval
+= tv
.tv_usec
;
270 static inline u64
trace_clock_frequency(void)
275 static inline u32
trace_clock_freq_scale(void)
283 #define list_add_rcu list_add
284 #define list_for_each_entry_rcu list_for_each_entry
287 #define EXPORT_SYMBOL_GPL(a) /*nothing*/
289 #define smp_processor_id() (-1)
291 #endif /* KERNELCOMPAT_H */
This page took 0.040288 seconds and 3 git commands to generate.