Thomas Watson
1249388f23
AP_Common: use template parameter in bitmask functions
...
Substantially improves code optimization and reduces memory usage.
2024-07-09 11:51:41 +10:00
Thomas Watson
6a4520e8fd
AP_Common: clean up bitmask operators
...
Code already won't compile if there are different numbers of bits as the
template parameter will be different.
2024-07-09 11:51:41 +10:00
Thomas Watson
b030b8e789
AP_Common: correctly bound bitmask datatypes
...
Probably won't work correctly (and of questionable use) if less than 1.
The `first_set()` function might not be able to return a valid value if
greater than INT16_MAX.
unsigned int needs to be >= uint32_t so that the shift ops are in range.
2024-07-09 11:51:41 +10:00
Thomas Watson
0b320fe303
AP_Common: unify bitmask out of bounds checking
...
Ensures out-of-bounds reads and writes are never performed for setting,
clearing, and checking. Fixes test failure when the number of bits
evenly divides the word size.
2024-07-09 11:51:41 +10:00
Thomas Watson
9a89223531
AP_Common: fix bitmask setall()
...
Fixes an issue where the last word was not set to all 1s if the number
of bits evenly divided the word size.
Also fixes UB if there were 31 valid bits.
2024-07-09 11:51:41 +10:00
Andrew Tridgell
9d42f49ac8
AP_Common: added setonoff() method for bitmask
2022-10-11 11:47:04 +11:00
bugobliterator
3c87062f27
AP_Common: add support for comparing BitMasks
2022-07-27 18:18:03 +10:00
Peter Barker
8e82ea2540
AP_Common: create and use INTERNAL_ERROR macro so we get line numbers
2020-04-30 13:21:36 +10:00
Peter Barker
9d4bdbf3d5
AP_Common: add sanity check into bitmask get/set
...
Also return false if we are asked about an out-of-bounds bit
2019-05-28 09:43:17 +10:00
Peter Barker
e51a0a7a52
AP_Common: make Bitmask a template on number of bits
2019-04-16 15:12:07 +10:00
Peter Barker
e198b0c7e6
AP_Common: Bitmask: choose builtin based on type for find_first_set
2018-12-10 12:52:41 +09:00
Peter Barker
db5f933e7a
AP_Common: Bitmask: add assignment operator
2018-12-10 12:52:41 +09:00
Andrew Tridgell
0fcb22afde
AP_Common: added first_set() method to Bitmask
2018-12-10 12:52:41 +09:00
Peter Barker
6b7e04da06
AP_Common: Bitmask: remove copy operator and constructor
2018-11-05 12:17:55 +09:00
squilter
1a9bccaaa7
AP_Common: fix Bitmask out-of-range values
2017-09-09 14:05:41 +09:00
Randy Mackay
963c9c93fe
AP_Common: constify bitmask
2017-09-09 14:05:41 +09:00
Randy Mackay
f187df225a
AP_Common: add setall, count and size methods to Bitmask
2017-09-09 14:05:41 +09:00
Randy Mackay
aaac6b3692
AP_Common: Bitmask formatting fix
2017-08-30 20:07:04 +09:00
Andrew Tridgell
71158e3e74
AP_Common: added #pragma once
2017-05-06 15:21:14 +10:00
Andrew Tridgell
6adad11e2f
AP_Common: added simple bitmask class
2016-12-02 09:49:39 +11:00