svn commit: r300539 - in head: . share/man/man3 sys/kern sys/sys tests/sys/sys

Peter Wemm peter at wemm.org
Mon May 23 22:31:29 UTC 2016


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 at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com; KI6FJV
UTF-8: for when a ' or ... just won\342\200\231t do\342\200\246
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20160523/e975d92a/attachment.sig>


More information about the svn-src-head mailing list