Shim layer updates

This commit is contained in:
Kent Overstreet 2017-12-13 16:00:44 -05:00
parent fa36882a73
commit f2feceddae
4 changed files with 42 additions and 1 deletions

View File

@ -25,6 +25,17 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
#define small_const_nbits(nbits) \
(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
static inline void bitmap_complement(unsigned long *dst, const unsigned long *src,
unsigned int bits)
{
unsigned int k, lim = bits/BITS_PER_LONG;
for (k = 0; k < lim; ++k)
dst[k] = ~src[k];
if (bits % BITS_PER_LONG)
dst[k] = ~src[k];
}
static inline void bitmap_zero(unsigned long *dst, int nbits)
{
memset(dst, 0, BITS_TO_LONGS(nbits) * sizeof(unsigned long));

View File

@ -15,7 +15,7 @@
#define BUG_ON(cond) assert(!(cond))
#define WARN_ON_ONCE(cond) assert(!(cond))
#define WARN_ONCE(cond, msg) assert(!(cond))
#define WARN_ONCE(cond, msg) ({ bool _r = (cond); if (_r) assert(0); _r; })
#define __WARN() assert(0)
#define __WARN_printf(arg...) assert(0)

View File

@ -382,4 +382,26 @@ static inline void closure_call(struct closure *cl, closure_fn fn,
continue_at_nobarrier(cl, fn, wq);
}
#define __closure_wait_event(waitlist, _cond) \
do { \
struct closure cl; \
\
closure_init_stack(&cl); \
\
while (1) { \
closure_wait(waitlist, &cl); \
if (_cond) \
break; \
closure_sync(&cl); \
} \
closure_wake_up(waitlist); \
closure_sync(&cl); \
} while (0)
#define closure_wait_event(waitlist, _cond) \
do { \
if (!(_cond)) \
__closure_wait_event(waitlist, _cond); \
} while (0)
#endif /* _LINUX_CLOSURE_H */

View File

@ -37,4 +37,12 @@ static inline int get_random_int(void)
return v;
}
static inline long get_random_long(void)
{
long v;
get_random_bytes(&v, sizeof(v));
return v;
}
#endif /* _LINUX_RANDOM_H */