aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-05-21 13:11:42 -0500
committerRob Landley <rob@landley.net>2017-05-21 13:11:42 -0500
commitf86f2f4e9a20d235b24ea86e4dddd0485165306f (patch)
tree83e2341019727a29ef59210926e6c83e15ccd146 /lib/lib.c
parent83b3531ec2876fa76817501bf1a38d4438ac39e6 (diff)
downloadtoybox-f86f2f4e9a20d235b24ea86e4dddd0485165306f.tar.gz
Cleaup chrt
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index ceced263..b6277f3b 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -512,6 +512,16 @@ void msleep(long miliseconds)
nanosleep(&ts, &ts);
}
+// return 1<<x of highest bit set
+int highest_bit(unsigned long l)
+{
+ int i;
+
+ for (i = 0; l; i++) l >>= 1;
+
+ return i-1;
+}
+
// Inefficient, but deals with unaligned access
int64_t peek_le(void *ptr, unsigned size)
{