0cb9688b419ae2d3a33b797ee33855d90c8e9438
[tatoo.git] / src / utils / uid.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Universit√© Paris-Sud & CNRS                       *)
7 (*                                                                     *)
8 (*  Copyright 2010-2012 Universit√© Paris-Sud and Centre National de la *)
9 (*  Recherche Scientifique. All rights reserved.  This file is         *)
10 (*  distributed under the terms of the GNU Lesser General Public       *)
11 (*  License, with the special exception on linking described in file   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16 (*
17   Time-stamp: <Last modified on 2013-01-30 19:06:39 CET by Kim Nguyen>
18 *)
19
20 type t = int
21
22 exception Overflow
23 let make_maker () =
24   let _id = ref ~-1 in
25     fun () ->
26       incr _id;
27       let i = !_id in
28       if i < 0 then raise Overflow else i
29
30 let dummy = -1
31
32 external to_int : t -> int = "%identity"
33 external of_int : int -> t= "%identity"