mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
bitmath.h : Minor improvements.
This is part of a larger patch from lvqcl. Patch-from: lvqcl <lvqcl.mail@gmail.com>
This commit is contained in:
@@ -78,10 +78,10 @@ static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v)
|
|||||||
return _bit_scan_reverse(v) ^ 31U;
|
return _bit_scan_reverse(v) ^ 31U;
|
||||||
#elif defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
#elif defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||||
/* This will translate either to (bsr ^ 31U), clz , ctlz, cntlz, lzcnt depending on
|
/* This will translate either to (bsr ^ 31U), clz , ctlz, cntlz, lzcnt depending on
|
||||||
* -march= setting or to a software rutine in exotic machines. */
|
* -march= setting or to a software routine in exotic machines. */
|
||||||
return __builtin_clz(v);
|
return __builtin_clz(v);
|
||||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
FLAC__uint32 idx;
|
unsigned long idx;
|
||||||
_BitScanReverse(&idx, v);
|
_BitScanReverse(&idx, v);
|
||||||
return idx ^ 31U;
|
return idx ^ 31U;
|
||||||
#else
|
#else
|
||||||
@@ -122,11 +122,19 @@ static inline unsigned int FLAC__clz2_uint32(FLAC__uint32 v)
|
|||||||
|
|
||||||
static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v)
|
static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v)
|
||||||
{
|
{
|
||||||
|
#if defined(__INTEL_COMPILER)
|
||||||
|
return _bit_scan_reverse(v);
|
||||||
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
|
unsigned long idx;
|
||||||
|
_BitScanReverse(&idx, v);
|
||||||
|
return idx;
|
||||||
|
#else
|
||||||
return sizeof(FLAC__uint32) * CHAR_BIT - 1 - FLAC__clz_uint32(v);
|
return sizeof(FLAC__uint32) * CHAR_BIT - 1 - FLAC__clz_uint32(v);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef FLAC__INTEGER_ONLY_LIBRARY /*Unused otherwise */
|
#ifdef FLAC__INTEGER_ONLY_LIBRARY /* Unused otherwise */
|
||||||
|
|
||||||
static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
|
static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user