Added support for mlx4_en on RHEL7.6
[compat-rdma/compat.git] / include / linux / bitmap.h
1 #ifndef _COMPAT_LINUX_BITMAP_H
2 #define _COMPAT_LINUX_BITMAP_H
3
4 #include "../../compat/config.h"
5
6 #include_next <linux/bitmap.h>
7
8
9 #ifndef HAVE_BITMAP_KZALLOC
10 extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags);
11 extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
12 #endif
13
14 #ifndef HAVE_BITMAP_FREE
15 #define bitmap_free LINUX_BACKPORT(bitmap_free)
16 extern void bitmap_free(const unsigned long *bitmap);
17 #endif
18
19 #ifndef HAVE_BITMAP_FROM_ARR32
20 #if BITS_PER_LONG == 64
21 extern void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf,
22                               unsigned int nbits);
23 #else
24
25 static inline void bitmap_copy_clear_tail(unsigned long *dst,
26                 const unsigned long *src, unsigned int nbits)
27 {
28         bitmap_copy(dst, src, nbits);
29         if (nbits % BITS_PER_LONG)
30                 dst[nbits / BITS_PER_LONG] &= BITMAP_LAST_WORD_MASK(nbits);
31 }
32
33 #define bitmap_from_arr32(bitmap, buf, nbits)                   \
34         bitmap_copy_clear_tail((unsigned long *) (bitmap),      \
35                         (const unsigned long *) (buf), (nbits))
36 #endif
37 #endif
38
39 #endif /* _COMPAT_LINUX_BITMAP_H */