]> matita.cs.unibo.it Git - pkg-cerco/acc-trusted.git/blob - cparser/uint64.c
Control and copyright added.
[pkg-cerco/acc-trusted.git] / cparser / uint64.c
1 /* *********************************************************************/
2 /*                                                                     */
3 /*              The Compcert verified compiler                         */
4 /*                                                                     */
5 /*          Xavier Leroy, INRIA Paris-Rocquencourt                     */
6 /*                                                                     */
7 /*  Copyright Institut National de Recherche en Informatique et en     */
8 /*  Automatique.  All rights reserved.  This file is distributed       */
9 /*  under the terms of the GNU General Public License as published by  */
10 /*  the Free Software Foundation, either version 2 of the License, or  */
11 /*  (at your option) any later version.  This file is also distributed */
12 /*  under the terms of the INRIA Non-Commercial License Agreement.     */
13 /*                                                                     */
14 /* *********************************************************************/
15
16 #include <caml/mlvalues.h>
17 #include <caml/alloc.h>
18
19 value cparser_int64_unsigned_to_float(value v)
20 {
21   return caml_copy_double((double)((uint64) Int64_val(v)));
22 }
23
24 value cparser_int64_unsigned_div(value v1, value v2)
25 {
26   return caml_copy_int64((uint64) Int64_val(v1) / (uint64) Int64_val(v2));
27 }
28
29 value cparser_int64_unsigned_mod(value v1, value v2)
30 {
31   return caml_copy_int64((uint64) Int64_val(v1) % (uint64) Int64_val(v2));
32 }
33
34 value cparser_int64_unsigned_compare(value v1, value v2)
35 {
36   uint64 n1 = (uint64) Int64_val(v1);
37   uint64 n2 = (uint64) Int64_val(v2);
38   if (n1 < n2) return Val_int(-1);
39   if (n1 > n2) return Val_int(1);
40   return Val_int(0);
41 }
42