Explorar el Código

Add fls() for non-constant values.

tags/v0.9.3
Michael Brown hace 17 años
padre
commit
db124b1255
Se han modificado 2 ficheros con 11 adiciones y 5 borrados
  1. 10
    0
      src/core/bitops.c
  2. 1
    5
      src/include/strings.h

+ 10
- 0
src/core/bitops.c Ver fichero

@@ -0,0 +1,10 @@
1
+#include <strings.h>
2
+
3
+int __flsl ( long x ) {
4
+	int r = 0;
5
+
6
+	for ( r = 0 ; x ; r++ ) {
7
+		x >>= 1;
8
+	}
9
+	return r;
10
+}

+ 1
- 5
src/include/strings.h Ver fichero

@@ -40,17 +40,13 @@ __constant_flsl ( unsigned long x ) {
40 40
 	return r;
41 41
 }
42 42
 
43
-#define __constant_fls(x) __constant_flsl(x)
44
-
45 43
 /* We don't actually have these functions yet */
46
-extern int __fls ( int x );
47 44
 extern int __flsl ( long x );
48 45
 
49 46
 #define flsl( x ) \
50 47
 	( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
51 48
 
52
-#define fls( x ) \
53
-	( __builtin_constant_p ( x ) ? __constant_fls ( x ) : __fls ( x ) )
49
+#define fls( x ) flsl ( x )
54 50
 
55 51
 extern int strcasecmp ( const char *s1, const char *s2 );
56 52
 

Loading…
Cancelar
Guardar