diff options
| author | Alexander Wirt <formorer@debian.org> | 2012-06-03 08:49:55 +0200 |
|---|---|---|
| committer | Alexander Wirt <formorer@debian.org> | 2012-06-03 08:49:55 +0200 |
| commit | ceecc8855af313c14e8a164f1cd0399716174398 (patch) | |
| tree | 0d58f5cf7075dea5ff7ddeff6f9a3c89d9eb6352 /include/bitops.h | |
| parent | 10f2c00aa6ef875e7998838c200681c6ea5eeebe (diff) | |
| parent | ea27bb406e3d8fe9466ba274af38e6f540ff5bfc (diff) | |
| download | conntrack-tools-ceecc8855af313c14e8a164f1cd0399716174398.tar.gz conntrack-tools-ceecc8855af313c14e8a164f1cd0399716174398.zip | |
Merge tag 'upstream/1.2.1'
Upstream version 1.2.1
Diffstat (limited to 'include/bitops.h')
| -rw-r--r-- | include/bitops.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/bitops.h b/include/bitops.h new file mode 100644 index 0000000..51f4289 --- /dev/null +++ b/include/bitops.h @@ -0,0 +1,36 @@ +#ifndef _BITOPS_H_ +#define _BITOPS_H_ + +#include <stdlib.h> + +static inline void set_bit_u32(int nr, u_int32_t *addr) +{ + addr[nr >> 5] |= (1UL << (nr & 31)); +} + +static inline void unset_bit_u32(int nr, u_int32_t *addr) +{ + addr[nr >> 5] &= ~(1UL << (nr & 31)); +} + +static inline int test_bit_u32(int nr, const u_int32_t *addr) +{ + return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0; +} + +static inline void set_bit_u16(int nr, u_int16_t *addr) +{ + addr[nr >> 4] |= (1UL << (nr & 15)); +} + +static inline void unset_bit_u16(int nr, u_int16_t *addr) +{ + addr[nr >> 4] &= ~(1UL << (nr & 15)); +} + +static inline int test_bit_u16(int nr, const u_int16_t *addr) +{ + return ((1UL << (nr & 15)) & (addr[nr >> 4])) != 0; +} + +#endif |
