2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
16 /* Some elementary bit manipulations
27 /* number of bytes to hold n bits */
28 #define nbytes_for_bits(n) ((((n)-1)>>3)+1)
30 /* test if bit is set */
31 #define bit_is_set(b, var) (((var)[(b)>>3] & (1<<((b)&0x7))) != 0)
34 #define set_bit(b, var) ((var)[(b)>>3] |= (1<<((b)&0x7)))
37 #define clear_bit(b, var) ((var)[(b)>>3] &= ~(1<<((b)&0x7)))
40 #define clear_all_bits(b, var) memset(var, 0, nbytes_for_bits(b))
42 /* set range of bits */
43 #define set_bits(f, l, var) { \
45 for (i=f; i<=l; i++) \
49 /* clear range of bits */
50 #define clear_bits(f, l, var) { \
52 for (i=f; i<=l; i++) \
56 #endif /* __BITS_H_ */