2
0
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:
Michael Brown 2007-09-16 17:36:40 +01:00
parent b21d4ca21e
commit 6d15a193aa
2 changed files with 11 additions and 5 deletions

10
src/core/bitops.c Normal file
View File

@ -0,0 +1,10 @@
#include <strings.h>
int __flsl ( long x ) {
int r = 0;
for ( r = 0 ; x ; r++ ) {
x >>= 1;
}
return r;
}

View File

@ -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 );