Date: Mon, 23 May 2016 15:31:28 -0700 From: Peter Wemm <peter@wemm.org> To: Alan Somers <asomers@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r300539 - in head: . share/man/man3 sys/kern sys/sys tests/sys/sys Message-ID: <1554849.4hxx0PqhhX@overcee.wemm.org> In-Reply-To: <201605232029.u4NKTIjK072941@repo.freebsd.org> References: <201605232029.u4NKTIjK072941@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Monday, May 23, 2016 08:29:18 PM Alan Somers wrote: > Author: asomers > Date: Mon May 23 20:29:18 2016 > New Revision: 300539 > URL: https://svnweb.freebsd.org/changeset/base/300539 > > Log: > Add bit_count to the bitstring(3) api > (My aplogies, I replied to the wrong commit.) This breaks i386: In file included from /usr/src/usr.sbin/apmd/apmd.c:36: In file included from /usr/obj/usr/src/tmp/usr/include/bitstring.h:34: /usr/obj/usr/src/tmp/usr/include/sys/bitstring.h:278:13: error: implicit declaration of function '__bitcountl' is invalid in C99 [-Werror,-Wimplicit- function-declaration] _value += __bitcountl(*_curbitstr & mask); ... This is coming from the inline below: > @@ -256,4 +257,40 @@ bit_ffc(bitstr_t *_bitstr, int _nbits, i > bit_ffc_at(_bitstr, /*start*/0, _nbits, _result); > } > > +/* Count the number of bits set in a bitstr of size _nbits at or after > _start */ +static inline void > +bit_count(bitstr_t *_bitstr, int _start, int _nbits, int *_result) > +{ > + bitstr_t *_curbitstr, mask; > + int _value = 0, curbitstr_len; > + > + if (_start >= _nbits) > + goto out; > + > + _curbitstr = _bitstr + _bit_idx(_start); > + _nbits -= _BITSTR_BITS * _bit_idx(_start); > + _start -= _BITSTR_BITS * _bit_idx(_start); > + > + if (_start > 0) { > + curbitstr_len = (int)_BITSTR_BITS < _nbits ? > + (int)_BITSTR_BITS : _nbits; > + mask = _bit_make_mask(_start, _bit_offset(curbitstr_len - 1)); > + _value += __bitcountl(*_curbitstr & mask); > + _curbitstr++; > + _nbits -= _BITSTR_BITS; > + } > + while (_nbits >= (int)_BITSTR_BITS) { > + _value += __bitcountl(*_curbitstr); > + _curbitstr++; > + _nbits -= _BITSTR_BITS; > + } > + if (_nbits > 0) { > + mask = _bit_make_mask(0, _bit_offset(_nbits - 1)); > + _value += __bitcountl(*_curbitstr & mask); > + } > + > +out: > + *_result = _value; > +} -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV UTF-8: for when a ' or ... just won\342\200\231t do\342\200\246 [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJXQ4TAAAoJEDXWlwnsgJ4E+dwIANI2Tq8KFlSlsAffqN5BIj3N tpNOYrz2TEQ+Ix/30b7CKhOUC0Q+RHEvX2J8UPEYOCIrVvIxlk1sEZfqp2JCfgzt eaU2ynhVypjSIItBaT8ClHypFBgYjTiPclc0Km7e0FV8Ueq4wP5RCC8Yll5aDMMJ vgmnEbszdOG6sNlOqWTthe+5hdSgCt+eAntiLH5I3NroQSjiEy/skLV9gMvqAGZA U1Np7j8+9UQ4FEMhJLqBNH6idOChlZ4iT4EDT7if5SEHuh52RrNeMta/AM5EcfEd QZcrGbJayT9UwcMK6XL1S6bxfIim7EcW2KOGlQMrYnooBNMkS33hhhYOU/dEm8s= =6uJL -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1554849.4hxx0PqhhX>
