Date: Thu, 12 Jan 2017 09:01:14 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311972 - head/lib/libnetbsd/sys Message-ID: <201701120901.v0C91ExE065111@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Thu Jan 12 09:01:14 2017 New Revision: 311972 URL: https://svnweb.freebsd.org/changeset/base/311972 Log: Add __BIT and __BITS macros from NetBSD to help support new testcases MFC after: 1 week Modified: head/lib/libnetbsd/sys/cdefs.h Modified: head/lib/libnetbsd/sys/cdefs.h ============================================================================== --- head/lib/libnetbsd/sys/cdefs.h Thu Jan 12 08:53:10 2017 (r311971) +++ head/lib/libnetbsd/sys/cdefs.h Thu Jan 12 09:01:14 2017 (r311972) @@ -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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701120901.v0C91ExE065111>