misc: add clz wrapper for builtin
* spot/bricks/brick-bitlevel, spot/misc/Makefile.am, spot/misc/bitset.hh, spot/misc/clz.cc, spot/misc/clz.hh, spot/misc/fixpool.hh: here.
This commit is contained in:
parent
01cceef29a
commit
69457e957b
6 changed files with 158 additions and 8 deletions
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <spot/misc/clz.hh>
|
||||
|
||||
#ifndef BRICK_BITLEVEL_H
|
||||
#define BRICK_BITLEVEL_H
|
||||
|
|
@ -182,19 +183,19 @@ static inline unsigned MSB( T x ) {
|
|||
template<>
|
||||
inline unsigned MSB< unsigned int >( unsigned int x ) {
|
||||
static const unsigned long bits = sizeof( unsigned int ) * 8 - 1;
|
||||
return bits - __builtin_clz( x );
|
||||
return bits - spot::clz( x );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned MSB< unsigned long >( unsigned long x ) {
|
||||
static const unsigned bits = sizeof( unsigned long ) * 8 - 1;
|
||||
return bits - __builtin_clzl( x );
|
||||
return bits - spot::clz( x );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline unsigned MSB< unsigned long long >( unsigned long long x ) {
|
||||
static const unsigned bits = sizeof( unsigned long long ) * 8 - 1;
|
||||
return bits - __builtin_clzll( x );
|
||||
return bits - spot::clz( x );
|
||||
}
|
||||
|
||||
// gets only Most Significant Bit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue