summaryrefslogtreecommitdiff
path: root/cparser/uint64.c
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-03 10:22:27 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-03 10:22:27 +0000
commit891377ce1962cdb31357d6580d6546ec22df2b4f (patch)
tree4ff7c38749cc7a4c1af411c5aa3eb7225c4ae6a1 /cparser/uint64.c
parent018edf2d81bf94197892cf1df221f7eeac1f96f6 (diff)
Switching to the new C parser/elaborator/simplifier
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1269 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cparser/uint64.c')
-rw-r--r--cparser/uint64.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/cparser/uint64.c b/cparser/uint64.c
new file mode 100644
index 0000000..5396617
--- /dev/null
+++ b/cparser/uint64.c
@@ -0,0 +1,42 @@
+/* *********************************************************************/
+/* */
+/* The Compcert verified compiler */
+/* */
+/* Xavier Leroy, INRIA Paris-Rocquencourt */
+/* */
+/* Copyright Institut National de Recherche en Informatique et en */
+/* Automatique. All rights reserved. This file is distributed */
+/* under the terms of the GNU General Public License as published by */
+/* the Free Software Foundation, either version 2 of the License, or */
+/* (at your option) any later version. This file is also distributed */
+/* under the terms of the INRIA Non-Commercial License Agreement. */
+/* */
+/* *********************************************************************/
+
+#include <caml/mlvalues.h>
+#include <caml/alloc.h>
+
+value cparser_int64_unsigned_to_float(value v)
+{
+ return caml_copy_double((double)((uint64) Int64_val(v)));
+}
+
+value cparser_int64_unsigned_div(value v1, value v2)
+{
+ return caml_copy_int64((uint64) Int64_val(v1) / (uint64) Int64_val(v2));
+}
+
+value cparser_int64_unsigned_mod(value v1, value v2)
+{
+ return caml_copy_int64((uint64) Int64_val(v1) % (uint64) Int64_val(v2));
+}
+
+value cparser_int64_unsigned_compare(value v1, value v2)
+{
+ uint64 n1 = (uint64) Int64_val(v1);
+ uint64 n2 = (uint64) Int64_val(v2);
+ if (n1 < n2) return Val_int(-1);
+ if (n1 > n2) return Val_int(1);
+ return Val_int(0);
+}
+