summaryrefslogtreecommitdiffstats
path: root/src/core/bitops.c
diff options
context:
space:
mode:
authorMichael Brown2007-09-16 18:36:40 +0200
committerMichael Brown2007-09-16 18:36:40 +0200
commit6d15a193aa9e3e4129a885e7010d0d480e723bb8 (patch)
tree67ca53696bf3c4cffd9ea1b11dd7ff3d5a4b51ea /src/core/bitops.c
parentRevert to dev_priv/owner_priv scheme, rather than container_of; it (diff)
downloadipxe-6d15a193aa9e3e4129a885e7010d0d480e723bb8.tar.gz
ipxe-6d15a193aa9e3e4129a885e7010d0d480e723bb8.tar.xz
ipxe-6d15a193aa9e3e4129a885e7010d0d480e723bb8.zip
Add fls() for non-constant values.
Diffstat (limited to 'src/core/bitops.c')
-rw-r--r--src/core/bitops.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/bitops.c b/src/core/bitops.c
new file mode 100644
index 000000000..75d57bf99
--- /dev/null
+++ b/src/core/bitops.c
@@ -0,0 +1,10 @@
+#include <strings.h>
+
+int __flsl ( long x ) {
+ int r = 0;
+
+ for ( r = 0 ; x ; r++ ) {
+ x >>= 1;
+ }
+ return r;
+}