diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-06-15 07:04:10 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2022-06-15 07:04:10 +0000 |
commit | fbf9e932c5a7ec580f613d3efb507a9003e8a917 (patch) | |
tree | 71e334d819c85ece21db8d8262b081e5335a6aef | |
parent | 24f35c8af4dbb55aa6a8250a0c0677339c02e295 (diff) |
add bitmap_to_arr32() for 5.15.47 drm
discussed with and partly from kettenis@
-rw-r--r-- | sys/dev/pci/drm/include/linux/bitmap.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/dev/pci/drm/include/linux/bitmap.h b/sys/dev/pci/drm/include/linux/bitmap.h index c3160639a75..f02cbd6ef40 100644 --- a/sys/dev/pci/drm/include/linux/bitmap.h +++ b/sys/dev/pci/drm/include/linux/bitmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bitmap.h,v 1.3 2020/06/08 04:48:14 jsg Exp $ */ +/* $OpenBSD: bitmap.h,v 1.4 2022/06/15 07:04:09 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * @@ -97,6 +97,27 @@ bitmap_copy(void *d, void *s, u_int n) dst[b >> 5] = src[b >> 5]; } +static inline void +bitmap_to_arr32(void *d, unsigned long *src, u_int n) +{ + u_int *dst = d; + u_int b; + +#ifdef __LP64__ + for (b = 0; b < n; b += 32) { + dst[b >> 5] = src[b >> 6] & 0xffffffff; + b += 32; + if (b < n) + dst[b >> 5] = src[b >> 6] >> 32; + } +#else + bitmap_copy(d, src, n); +#endif + if ((n % 32) != 0) + dst[n >> 5] &= (0xffffffff >> (32 - (n % 32))); +} + + static inline int bitmap_weight(void *p, u_int n) { |