Commits

Anonymous committed 79327ae

Ajout de qques fonctions sur entiers pour le compilateur natif.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@25f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

Comments (0)

Files changed (2)

       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)
         (* [copy_file_chunk ic oc n] reads [n] bytes from [ic] and copies
            them to [oc]. It raises [End_of_file] when encountering
            EOF on [ic]. *)
+
+val log2: int -> int
+        (* [log2 n] returns [s] such that [n = 1 lsl s] 
+           if [n] is a power of 2*)
+val align: int -> int -> int
+        (* [align n a] rounds [n] upwards to a multiple of [a]
+           (a power of 2). *)
+
+