diff options
author | Vladimir Kondratyev <wulf@FreeBSD.org> | 2023-04-22 08:29:29 +0000 |
---|---|---|
committer | Vladimir Kondratyev <wulf@FreeBSD.org> | 2023-04-22 08:29:29 +0000 |
commit | e5cf9deb61fdc52c7647f4669a64d3fae126db94 (patch) | |
tree | 1d799044ad1eb7ea589a7f9a53865650d057eb81 | |
parent | b14c03f808c415248ae7ec0f0476176ad521d67b (diff) | |
download | src-e5cf9deb61fdc52c7647f4669a64d3fae126db94.tar.gz src-e5cf9deb61fdc52c7647f4669a64d3fae126db94.zip |
LinuxKPI: Add bitmap_to_arr32() to <linux/bitmap.h>
bitmap_to_arr32() copies contents of bitmap to a uint32_t array of bits
Required by: drm-kmod 5.15-lts
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D39552
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/bitmap.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/bitmap.h b/sys/compat/linuxkpi/common/include/linux/bitmap.h index 1ae6078966a4..4e156377cdaf 100644 --- a/sys/compat/linuxkpi/common/include/linux/bitmap.h +++ b/sys/compat/linuxkpi/common/include/linux/bitmap.h @@ -289,6 +289,26 @@ bitmap_copy(unsigned long *dst, const unsigned long *src, } static inline void +bitmap_to_arr32(uint32_t *dst, const unsigned long *src, unsigned int size) +{ + const unsigned int end = howmany(size, 32); + +#ifdef __LP64__ + unsigned int i = 0; + while (i < end) { + dst[i++] = (uint32_t)(*src & UINT_MAX); + if (i < end) + dst[i++] = (uint32_t)(*src >> 32); + src++; + } +#else + bitmap_copy(dst, src, size); +#endif + if ((size % 32) != 0) /* Linux uses BITS_PER_LONG. Seems to be a bug */ + dst[end - 1] &= (uint32_t)(UINT_MAX >> (32 - (size % 32))); +} + +static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, const unsigned long *src2, const unsigned int size) { |