xen/libxc-bitmap-long.patch
Charles Arnold f9b3d85b1e - Update to Xen 4.20.0 RC2 release
* xen/arm: Fully initialise struct membanks_hdr fields
  * build: Set DATE to SOURCE_DATE_EPOCH if available (for 
    reproducible builds)
  * x86: Add Support for Paging-Write Feature
  * x86/time: introduce command line option to select wallclock
  * x86/time: prefer CMOS over EFI_GET_TIME
  * xentrace: free CPU mask string before overwriting pointer
  * xl: properly dispose of vTPM struct instance
  * xl: properly dispose of libxl_dominfo struct instances
  * Various documentation fixes and adjustments
  * Various MISRA compliance improvements.

OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=871
2025-01-20 13:29:19 +00:00

65 lines
1.7 KiB
Diff

From: Olaf Hering <olaf@aepfle.de>
Date: Wed, 9 Dec 2020 16:40:00 +0100
Subject: libxc sr bitmap long
tools: add API to work with sevaral bits at once
Introduce new API to test if a fixed number of bits is clear or set,
and clear or set them all at once.
The caller has to make sure the input bitnumber is a multiple of BITS_PER_LONG.
This API avoids the loop over each bit in a known range just to see
if all of them are either clear or set.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
v02:
- change return type from int to bool (jgross)
---
tools/libs/ctrl/xc_bitops.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
--- a/tools/libs/ctrl/xc_bitops.h
+++ b/tools/libs/ctrl/xc_bitops.h
@@ -3,6 +3,7 @@
/* bitmap operations for single threaded access */
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@@ -81,4 +82,31 @@ static inline void bitmap_or(void *_dst,
dst[i] |= other[i];
}
+static inline bool test_bit_long_set(unsigned long nr_base, const void *_addr)
+{
+ const unsigned long *addr = _addr;
+ unsigned long val = addr[nr_base / BITS_PER_LONG];
+
+ return val == ~0;
+}
+
+static inline bool test_bit_long_clear(unsigned long nr_base, const void *_addr)
+{
+ const unsigned long *addr = _addr;
+ unsigned long val = addr[nr_base / BITS_PER_LONG];
+
+ return val == 0;
+}
+
+static inline void clear_bit_long(unsigned long nr_base, void *_addr)
+{
+ unsigned long *addr = _addr;
+ addr[nr_base / BITS_PER_LONG] = 0;
+}
+
+static inline void set_bit_long(unsigned long nr_base, void *_addr)
+{
+ unsigned long *addr = _addr;
+ addr[nr_base / BITS_PER_LONG] = ~0;
+}
#endif /* XC_BITOPS_H */