Date: Sat, 4 Feb 2017 16:49:50 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r313228 - stable/11/lib/libnetbsd/sys Message-ID: <201702041649.v14GnoHo075246@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Sat Feb 4 16:49:50 2017 New Revision: 313228 URL: https://svnweb.freebsd.org/changeset/base/313228 Log: MFC r311972: Add __BIT and __BITS macros from NetBSD to help support new testcases Modified: stable/11/lib/libnetbsd/sys/cdefs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libnetbsd/sys/cdefs.h ============================================================================== --- stable/11/lib/libnetbsd/sys/cdefs.h Sat Feb 4 16:47:56 2017 (r313227) +++ stable/11/lib/libnetbsd/sys/cdefs.h Sat Feb 4 16:49:50 2017 (r313228) @@ -69,4 +69,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?201702041649.v14GnoHo075246>