summaryrefslogtreecommitdiff
path: root/utils/misc.ml
diff options
context:
space:
mode:
Diffstat (limited to 'utils/misc.ml')
-rw-r--r--utils/misc.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/utils/misc.ml b/utils/misc.ml
index 1cdb5dcf25..7f8d42aab4 100644
--- a/utils/misc.ml
+++ b/utils/misc.ml
@@ -84,3 +84,11 @@ let copy_file_chunk ic oc len =
if r = 0 then raise End_of_file else (output oc buff 0 r; copy(n-r))
end
in copy len
+
+(* Integer operations *)
+
+let rec log2 n =
+ if n <= 1 then 1 else 1 + log2(n asr 1)
+
+let align n a =
+ (n + a - 1) land (-a)