david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Add fls() for non-constant values.

This commit is contained in:
Michael Brown 2007-09-16 17:36:40 +01:00
parent f09173326c
commit db124b1255
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 );