diff options
author | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:03:14 +0200 |
---|---|---|
committer | whitespace / reindent <invalid@invalid.invalid> | 2017-07-17 14:04:07 +0200 |
commit | d62a17aedeb0eebdba98238874bb13d62c48dbf9 (patch) | |
tree | 3b319b1d61c8b85b4d1f06adf8b844bb8a9b5107 /lib/bitfield.h | |
parent | *: add indent control files (diff) | |
download | frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.tar.xz frr-d62a17aedeb0eebdba98238874bb13d62c48dbf9.zip |
*: reindentreindent-master-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/bitfield.h')
-rw-r--r-- | lib/bitfield.h | 109 |
1 files changed, 59 insertions, 50 deletions
diff --git a/lib/bitfield.h b/lib/bitfield.h index 1e0b54731..0e031ccc4 100644 --- a/lib/bitfield.h +++ b/lib/bitfield.h @@ -62,42 +62,41 @@ typedef unsigned int word_t; * @N: number of bits to start with, which equates to how many * IDs can be allocated. */ -#define bf_init(v, N) \ - do { \ - (v).n = 0; \ - (v).m = ((N) / WORD_SIZE + 1); \ - (v).data = calloc(1, ((v).m * sizeof(word_t))); \ - } while (0) +#define bf_init(v, N) \ + do { \ + (v).n = 0; \ + (v).m = ((N) / WORD_SIZE + 1); \ + (v).data = calloc(1, ((v).m * sizeof(word_t))); \ + } while (0) /** * allocate and assign an id from bitfield v. */ -#define bf_assign_index(v, id) \ - do { \ - bf_find_bit(v, id); \ - bf_set_bit(v, id); \ - } while (0) +#define bf_assign_index(v, id) \ + do { \ + bf_find_bit(v, id); \ + bf_set_bit(v, id); \ + } while (0) /* * allocate and assign 0th bit in the bitfiled. */ -#define bf_assign_zero_index(v) \ - do { \ - int id = 0; \ - bf_assign_index(v, id); \ - } while (0) +#define bf_assign_zero_index(v) \ + do { \ + int id = 0; \ + bf_assign_index(v, id); \ + } while (0) /* * return an id to bitfield v */ -#define bf_release_index(v, id) \ - (v).data[bf_index(id)] &= ~(1 << (bf_offset(id))) +#define bf_release_index(v, id) \ + (v).data[bf_index(id)] &= ~(1 << (bf_offset(id))) /* * return 0th index back to bitfield */ -#define bf_release_zero_index(v) \ - bf_release_index(v, 0) +#define bf_release_zero_index(v) bf_release_index(v, 0) #define bf_index(b) ((b) / WORD_SIZE) #define bf_offset(b) ((b) % WORD_SIZE) @@ -106,42 +105,52 @@ typedef unsigned int word_t; * Set a bit in the array. If it fills up that word and we are * out of words, extend it by one more word. */ -#define bf_set_bit(v, b) \ - do { \ - size_t w = bf_index(b); \ - (v).data[w] |= 1 << (bf_offset(b)); \ - (v).n += ((v).data[w] == WORD_MAX); \ - if ((v).n == (v).m) { \ - (v).m = (v).m + 1; \ - (v).data = realloc((v).data, (v).m * sizeof(word_t)); \ - } \ - } while (0) +#define bf_set_bit(v, b) \ + do { \ + size_t w = bf_index(b); \ + (v).data[w] |= 1 << (bf_offset(b)); \ + (v).n += ((v).data[w] == WORD_MAX); \ + if ((v).n == (v).m) { \ + (v).m = (v).m + 1; \ + (v).data = realloc((v).data, (v).m * sizeof(word_t)); \ + } \ + } while (0) /* Find a clear bit in v and assign it to b. */ -#define bf_find_bit(v, b) \ - do { \ - word_t word = 0; \ - unsigned int w, sh; \ - for (w = 0; w <= (v).n; w++) { \ - if ((word = (v).data[w]) != WORD_MAX) break; \ - } \ - (b) = ((word & 0xFFFF) == 0xFFFF) << 4; word >>= (b); \ - sh = ((word & 0xFF) == 0xFF) << 3; word >>= sh; (b) |= sh; \ - sh = ((word & 0xF) == 0xF) << 2; word >>= sh; (b) |= sh; \ - sh = ((word & 0x3) == 0x3) << 1; word >>= sh; (b) |= sh; \ - sh = ((word & 0x1) == 0x1) << 0; word >>= sh; (b) |= sh; \ - (b) += (w * WORD_SIZE); \ - } while (0) +#define bf_find_bit(v, b) \ + do { \ + word_t word = 0; \ + unsigned int w, sh; \ + for (w = 0; w <= (v).n; w++) { \ + if ((word = (v).data[w]) != WORD_MAX) \ + break; \ + } \ + (b) = ((word & 0xFFFF) == 0xFFFF) << 4; \ + word >>= (b); \ + sh = ((word & 0xFF) == 0xFF) << 3; \ + word >>= sh; \ + (b) |= sh; \ + sh = ((word & 0xF) == 0xF) << 2; \ + word >>= sh; \ + (b) |= sh; \ + sh = ((word & 0x3) == 0x3) << 1; \ + word >>= sh; \ + (b) |= sh; \ + sh = ((word & 0x1) == 0x1) << 0; \ + word >>= sh; \ + (b) |= sh; \ + (b) += (w * WORD_SIZE); \ + } while (0) /* * Free the allocated memory for data * @v: an instance of bitfield_t struct. */ -#define bf_free(v) \ - do { \ - if ((v).data) { \ - free((v).data); \ - } \ - } while (0) +#define bf_free(v) \ + do { \ + if ((v).data) { \ + free((v).data); \ + } \ + } while (0) #endif |