63964888e6de5f93850e230ea899d047d0c75d6b
11 /* FIXME: libkcompat must not define arch-specific local ops, as ust *must*
12 * fallback to the normal atomic ops. Fix things so we don't add them and
13 * break things accidentally.
16 #define container_of(ptr, type, member) ({ \
17 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
18 (type *)( (char *)__mptr - offsetof(type,member) );})
21 #define KERN_NOTICE ""
25 #define KERN_WARNING ""
29 #define MAX_ERRNO 4095
31 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
33 static inline void *ERR_PTR(long error
)
35 return (void *) error
;
38 static inline long PTR_ERR(const void *ptr
)
43 static inline long IS_ERR(const void *ptr
)
45 return IS_ERR_VALUE((unsigned long)ptr
);
51 #define min_t(type, x, y) ({ \
54 __min1 < __min2 ? __min1: __min2; })
56 #define max_t(type, x, y) ({ \
59 __max1 > __max2 ? __max1: __max2; })
66 #define DEFINE_MUTEX(m) pthread_mutex_t (m) = PTHREAD_MUTEX_INITIALIZER;
67 #define DECLARE_MUTEX(m) extern pthread_mutex_t (m);
69 #define mutex_lock(m) pthread_mutex_lock(m)
71 #define mutex_unlock(m) pthread_mutex_unlock(m)
78 #define kmalloc(s, t) malloc(s)
79 #define kzalloc(s, t) zmalloc(s)
80 #define kfree(p) free((void *)p)
81 #define kstrdup(s, t) strdup(s)
83 #define zmalloc(s) calloc(1, s)
90 #define printk(fmt, args...) printf(fmt, ## args)
95 #define ____cacheline_aligned
101 static inline unsigned int hweight32(unsigned int w
)
103 unsigned int res
= w
- ((w
>> 1) & 0x55555555);
104 res
= (res
& 0x33333333) + ((res
>> 2) & 0x33333333);
105 res
= (res
+ (res
>> 4)) & 0x0F0F0F0F;
106 res
= res
+ (res
>> 8);
107 return (res
+ (res
>> 16)) & 0x000000FF;
110 static inline int fls(int x
)
113 //ust// #ifdef CONFIG_X86_CMOV
116 : "=&r" (r
) : "rm" (x
), "rm" (-1));
118 //ust// asm("bsrl %1,%0\n\t"
120 //ust// "movl $-1,%0\n"
121 //ust// "1:" : "=r" (r) : "rm" (x));
126 static __inline__
int get_count_order(unsigned int count
)
130 order
= fls(count
) - 1;
131 if (count
& (count
- 1))
141 #define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
142 #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
143 #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
144 #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
145 #define PAGE_MASK (PAGE_SIZE-1)
152 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
156 //ust// static inline u64 trace_clock_read64(void)
158 //ust// uint32_t low;
159 //ust// uint32_t high;
160 //ust// uint64_t retval;
161 //ust// __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));
163 //ust// retval = high;
164 //ust// retval <<= 32;
165 //ust// return retval | low;
168 static inline u64
trace_clock_read64(void)
173 gettimeofday(&tv
, NULL
);
176 retval
+= tv
.tv_usec
;
181 static inline u64
trace_clock_frequency(void)
186 static inline u32
trace_clock_freq_scale(void)
194 #define list_add_rcu list_add
195 #define list_for_each_entry_rcu list_for_each_entry
198 #define EXPORT_SYMBOL_GPL(a) /*nothing*/
200 #define smp_processor_id() (-1)
202 #endif /* KERNELCOMPAT_H */
This page took 0.074113 seconds and 3 git commands to generate.