source: Deliverables/D2.2/8051/cparser/uint64.c @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

File size: 1.7 KB
Line 
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
19value cparser_int64_unsigned_to_float(value v)
20{
21  return caml_copy_double((double)((uint64) Int64_val(v)));
22}
23
24value cparser_int64_unsigned_div(value v1, value v2)
25{
26  return caml_copy_int64((uint64) Int64_val(v1) / (uint64) Int64_val(v2));
27}
28
29value cparser_int64_unsigned_mod(value v1, value v2)
30{
31  return caml_copy_int64((uint64) Int64_val(v1) % (uint64) Int64_val(v2));
32}
33
34value 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
Note: See TracBrowser for help on using the repository browser.