8 #define container_of(ptr, type, member) ({ \
9 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
10 (type *)( (char *)__mptr - offsetof(type,member) );})
13 #define KERN_NOTICE ""
20 #define MAX_ERRNO 4095
22 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
24 static inline void *ERR_PTR(long error
)
26 return (void *) error
;
29 static inline long PTR_ERR(const void *ptr
)
34 static inline long IS_ERR(const void *ptr
)
36 return IS_ERR_VALUE((unsigned long)ptr
);
40 /* FIXED SIZE INTEGERS */
49 #define min_t(type, x, y) ({ \
52 __min1 < __min2 ? __min1: __min2; })
54 #define max_t(type, x, y) ({ \
57 __max1 > __max2 ? __max1: __max2; })
64 #define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
66 #define mutex_lock(m) pthread_mutex_lock(m)
68 #define mutex_unlock(m) pthread_mutex_unlock(m)
74 #define kmalloc(s, t) malloc(s)
75 #define kzalloc(s, t) malloc(s)
76 #define kfree(p) free((void *)p)
77 #define kstrdup(s, t) strdup(s)
82 #define printk(fmt, args...) printf(fmt, ## args)
86 #define smp_rmb() do {} while(0)
87 #define smp_wmb() do {} while(0)
88 #define smp_mb() do {} while(0)
89 #define smp_mb__after_atomic_inc() do {} while(0)
91 #define read_barrier_depends() do {} while(0)
92 #define smp_read_barrier_depends() do {} while(0)
96 #define rcu_assign_pointer(a, b) do {} while(0)
97 #define call_rcu_sched(a,b) do {} while(0)
98 #define rcu_barrier_sched() do {} while(0)
104 typedef struct { sig_atomic_t counter
; } atomic_t
;
106 static inline int atomic_dec_and_test(atomic_t
*p
)
112 static inline void atomic_set(atomic_t
*p
, int v
)
117 static inline void atomic_inc(atomic_t
*p
)
122 static int atomic_read(atomic_t
*p
)
129 #define ____cacheline_aligned
133 static inline unsigned int hweight32(unsigned int w
)
135 unsigned int res
= w
- ((w
>> 1) & 0x55555555);
136 res
= (res
& 0x33333333) + ((res
>> 2) & 0x33333333);
137 res
= (res
+ (res
>> 4)) & 0x0F0F0F0F;
138 res
= res
+ (res
>> 8);
139 return (res
+ (res
>> 16)) & 0x000000FF;
142 static inline int fls(int x
)
145 //ust// #ifdef CONFIG_X86_CMOV
148 : "=&r" (r
) : "rm" (x
), "rm" (-1));
150 //ust// asm("bsrl %1,%0\n\t"
152 //ust// "movl $-1,%0\n"
153 //ust// "1:" : "=r" (r) : "rm" (x));
158 static __inline__
int get_count_order(unsigned int count
)
162 order
= fls(count
) - 1;
163 if (count
& (count
- 1))
171 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
175 static inline u64
trace_clock_read64(void)
180 static inline unsigned int trace_clock_frequency(void)
185 static inline u32
trace_clock_freq_scale(void)
190 #endif /* KERNELCOMPAT_H */
This page took 0.036783 seconds and 4 git commands to generate.