Add __BIT and __BITS macros from NetBSD to help support new testcases
MFC after: 1 week
This commit is contained in:
parent
dec64e48c6
commit
2b62be0b79
@ -71,4 +71,13 @@
|
||||
*/
|
||||
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
|
||||
|
||||
/* __BIT(n): nth bit, where __BIT(0) == 0x1. */
|
||||
#define __BIT(__n) \
|
||||
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \
|
||||
((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1))))
|
||||
|
||||
/* __BITS(m, n): bits m through n, m < n. */
|
||||
#define __BITS(__m, __n) \
|
||||
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
|
||||
|
||||
#endif /* _LIBNETBSD_SYS_CDEFS_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user