mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-14 07:11:32 +00:00
Add fls() for non-constant values.
This commit is contained in:
parent
b21d4ca21e
commit
6d15a193aa
10
src/core/bitops.c
Normal file
10
src/core/bitops.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <strings.h>
|
||||
|
||||
int __flsl ( long x ) {
|
||||
int r = 0;
|
||||
|
||||
for ( r = 0 ; x ; r++ ) {
|
||||
x >>= 1;
|
||||
}
|
||||
return r;
|
||||
}
|
@ -40,17 +40,13 @@ __constant_flsl ( unsigned long x ) {
|
||||
return r;
|
||||
}
|
||||
|
||||
#define __constant_fls(x) __constant_flsl(x)
|
||||
|
||||
/* We don't actually have these functions yet */
|
||||
extern int __fls ( int x );
|
||||
extern int __flsl ( long x );
|
||||
|
||||
#define flsl( x ) \
|
||||
( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
|
||||
|
||||
#define fls( x ) \
|
||||
( __builtin_constant_p ( x ) ? __constant_fls ( x ) : __fls ( x ) )
|
||||
#define fls( x ) flsl ( x )
|
||||
|
||||
extern int strcasecmp ( const char *s1, const char *s2 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user