summaryrefslogtreecommitdiffstats
path: root/src/include/strings.h
diff options
context:
space:
mode:
authorMichael Brown2014-04-27 17:11:44 +0200
committerMichael Brown2014-04-27 17:56:09 +0200
commitd36e814b8aad0dc15386180245efb3f5cb8b8386 (patch)
tree9c3c633f01a1703a8c85524a4393f8f45539f459 /src/include/strings.h
parent[libc] Add isqrt() function to find integer square roots (diff)
downloadipxe-d36e814b8aad0dc15386180245efb3f5cb8b8386.tar.gz
ipxe-d36e814b8aad0dc15386180245efb3f5cb8b8386.tar.xz
ipxe-d36e814b8aad0dc15386180245efb3f5cb8b8386.zip
[libc] Add flsll()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/strings.h')
-rw-r--r--src/include/strings.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/include/strings.h b/src/include/strings.h
index 924a084f..6912a1e4 100644
--- a/src/include/strings.h
+++ b/src/include/strings.h
@@ -8,15 +8,13 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <bits/strings.h>
static inline __attribute__ (( always_inline )) int
-__constant_flsl ( unsigned long x ) {
+__constant_flsll ( unsigned long long x ) {
int r = 0;
-#if ULONG_MAX > 0xffffffff
- if ( x & 0xffffffff00000000UL ) {
+ if ( x & 0xffffffff00000000ULL ) {
x >>= 32;
r += 32;
}
-#endif
if ( x & 0xffff0000UL ) {
x >>= 16;
r += 16;
@@ -43,8 +41,17 @@ __constant_flsl ( unsigned long x ) {
return r;
}
+static inline __attribute__ (( always_inline )) int
+__constant_flsl ( unsigned long x ) {
+ return __constant_flsll ( x );
+}
+
+int __flsll ( long long x );
int __flsl ( long x );
+#define flsll( x ) \
+ ( __builtin_constant_p ( x ) ? __constant_flsll ( x ) : __flsll ( x ) )
+
#define flsl( x ) \
( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )