9 #ifndef __DynamicBitset__bitwise_ops__
10 #define __DynamicBitset__bitwise_ops__
24 #define SIZE_MAX ((size_t)-1)
29 size_t msb(uint32_t val);
32 uint32_t
maskLeft(uint32_t val,uint8_t pos);
33 uint32_t
maskRight(uint32_t val, uint8_t pos);
35 uint32_t
rol(uint32_t& val, uint8_t shift_register);
36 uint32_t
ror(uint32_t& val, uint8_t shift_register);
40 T
rol(T val, uint8_t shift_register) {
41 return (val << shift_register) | (val >> ((
sizeof(T)*
CHAR_BIT) - shift_register));
47 T
ror(T val, uint8_t shift_register) {
48 return (val >> shift_register) | (val << ((
sizeof(T)*
CHAR_BIT) - shift_register));
55 T
lso(T& val, uint8_t n) {
64 return temp >> ((
sizeof(T)*CHAR_BIT) - n);
71 T
rso(T& val, uint8_t n) {
80 return temp << ((
sizeof(T)*CHAR_BIT) - n);
91 T
lsoso(T& val, T& old_val, uint8_t n) {
93 val = (val << n) | old_val;
94 return temp >> ((
sizeof(T)*
CHAR_BIT) - n);
102 template <
typename T>
103 T
rsoso(T& val, T& old_val, uint8_t n) {
105 val = (val>>n) | old_val;
106 return temp << ((
sizeof(T)*
CHAR_BIT) - n);