Browse Source

do {} while (0); the macros; jarle@runit.sintef.no

OPENBSD_2_2
deraadt 27 years ago
parent
commit
4bca9c33f9
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      src/include/bitstring.h

+ 8
- 8
src/include/bitstring.h View File

@ -69,27 +69,27 @@ typedef unsigned char bitstr_t;
(name)[_bit_byte(bit)] &= ~_bit_mask(bit)
/* clear bits start ... stop in bitstring */
#define bit_nclear(name, start, stop) { \
#define bit_nclear(name, start, stop) do { \
register bitstr_t *_name = name; \
register int _start = start, _stop = stop; \
while (_start <= _stop) { \
bit_clear(_name, _start); \
_start++; \
} \
}
} while (0)
/* set bits start ... stop in bitstring */
#define bit_nset(name, start, stop) { \
#define bit_nset(name, start, stop) do { \
register bitstr_t *_name = name; \
register int _start = start, _stop = stop; \
while (_start <= _stop) { \
bit_set(_name, _start); \
_start++; \
} \
}
} while (0)
/* find first bit clear in name */
#define bit_ffc(name, nbits, value) { \
#define bit_ffc(name, nbits, value) do { \
register bitstr_t *_name = name; \
register int _bit, _nbits = nbits, _value = -1; \
for (_bit = 0; _bit < _nbits; ++_bit) \
@ -98,10 +98,10 @@ typedef unsigned char bitstr_t;
break; \
} \
*(value) = _value; \
}
} while (0)
/* find first bit set in name */
#define bit_ffs(name, nbits, value) { \
#define bit_ffs(name, nbits, value) do { \
register bitstr_t *_name = name; \
register int _bit, _nbits = nbits, _value = -1; \
for (_bit = 0; _bit < _nbits; ++_bit) \
@ -110,6 +110,6 @@ typedef unsigned char bitstr_t;
break; \
} \
*(value) = _value; \
}
} while (0)
#endif /* !_BITSTRING_H_ */

Loading…
Cancel
Save