(***********************************************************************) (* *) (* Objective Caml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. All rights reserved. This file is distributed *) (* under the terms of the GNU Library General Public License. *) (* *) (***********************************************************************) (* $Id$ *) (* Module [Nativeint]: processor-native integers *) external neg: nativeint -> nativeint = "%nativeint_neg" external add: nativeint -> nativeint -> nativeint = "%nativeint_add" external sub: nativeint -> nativeint -> nativeint = "%nativeint_sub" external mul: nativeint -> nativeint -> nativeint = "%nativeint_mul" external div: nativeint -> nativeint -> nativeint = "%nativeint_div" external rem: nativeint -> nativeint -> nativeint = "%nativeint_mod" external logand: nativeint -> nativeint -> nativeint = "%nativeint_and" external logor: nativeint -> nativeint -> nativeint = "%nativeint_or" external logxor: nativeint -> nativeint -> nativeint = "%nativeint_xor" external shift_left: nativeint -> int -> nativeint = "%nativeint_lsl" external shift_right: nativeint -> int -> nativeint = "%nativeint_asr" external shift_right_logical: nativeint -> int -> nativeint = "%nativeint_lsr" external of_int: int -> nativeint = "%nativeint_of_int" external to_int: nativeint -> int = "%nativeint_to_int" let zero = of_int 0 let one = of_int 1 let minus_one = of_int (-1) let succ n = add n one let pred n = sub n one let abs n = if n >= zero then n else neg n let min = shift_left one (Sys.word_size - 1) let max = sub min one let lognot n = logxor n minus_one external format : string -> nativeint -> string = "nativeint_format" let to_string n = format "%d" n external of_string: string -> nativeint = "nativeint_of_string"