From 971c80ef07735ea5fdaa9a2fa1dae4b34f2084d9 Mon Sep 17 00:00:00 2001 From: alihanozturk Date: Thu, 2 Feb 2017 17:03:52 +0300 Subject: [PATCH] ocaml:fix --- ... 0001-Don-t-add-rpaths-to-libraries.patch} | 15 +- ...ore-.-configure-it-s-a-real-git-file.patch | 24 - ...pilerlibs-directory-is-created-by-gi.patch | 18 - ...mlplugininfo-Useful-utilities-from-.patch} | 7 +- ...Allow-user-defined-C-compiler-flags.patch} | 15 +- .../fedora/0004-Don-t-rewrite-Werror.patch | 27 + ...x-address-of-caml_raise_exn-in-nativ.patch | 28 + .../0006-Adapt-config.guess-for-RISC-V.patch | 34 + .../0007-Add-RISC-V-backend-runtime.patch | 1716 ++++++++++++++ ...y-fix-for-andi-ori-xori-immediates-1.patch | 42 + ...tes-range-when-adjusting-indexing-sp.patch | 155 ++ ...-no_arg-and-get_arg-helper-functions.patch | 118 - .../0010-Another-immediate-range-fix.patch | 130 ++ ...such-as-flag-arg-as-well-as-flag-arg.patch | 84 - ...C99-types-u-int-32-64-_t-in-preferen.patch | 1963 ----------------- programming/language/ocaml/ocaml/pspec.xml | 18 +- 16 files changed, 2159 insertions(+), 2235 deletions(-) rename programming/language/ocaml/ocaml/files/fedora/{0003-Don-t-add-rpaths-to-libraries.patch => 0001-Don-t-add-rpaths-to-libraries.patch} (71%) delete mode 100644 programming/language/ocaml/ocaml/files/fedora/0001-Don-t-ignore-.-configure-it-s-a-real-git-file.patch delete mode 100644 programming/language/ocaml/ocaml/files/fedora/0002-Ensure-empty-compilerlibs-directory-is-created-by-gi.patch rename programming/language/ocaml/ocaml/files/fedora/{0004-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch => 0002-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch} (98%) rename programming/language/ocaml/ocaml/files/fedora/{0005-configure-Allow-user-defined-C-compiler-flags.patch => 0003-configure-Allow-user-defined-C-compiler-flags.patch} (59%) create mode 100644 programming/language/ocaml/ocaml/files/fedora/0004-Don-t-rewrite-Werror.patch create mode 100644 programming/language/ocaml/ocaml/files/fedora/0005-PR-7405-s390x-Fix-address-of-caml_raise_exn-in-nativ.patch create mode 100644 programming/language/ocaml/ocaml/files/fedora/0006-Adapt-config.guess-for-RISC-V.patch create mode 100644 programming/language/ocaml/ocaml/files/fedora/0007-Add-RISC-V-backend-runtime.patch create mode 100644 programming/language/ocaml/ocaml/files/fedora/0008-Try-fix-for-andi-ori-xori-immediates-1.patch create mode 100644 programming/language/ocaml/ocaml/files/fedora/0009-Fix-immediates-range-when-adjusting-indexing-sp.patch delete mode 100644 programming/language/ocaml/ocaml/files/fedora/0009-arg-Add-no_arg-and-get_arg-helper-functions.patch create mode 100644 programming/language/ocaml/ocaml/files/fedora/0010-Another-immediate-range-fix.patch delete mode 100644 programming/language/ocaml/ocaml/files/fedora/0010-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch delete mode 100644 programming/language/ocaml/ocaml/files/fedora/0011-PR-6517-use-ISO-C99-types-u-int-32-64-_t-in-preferen.patch diff --git a/programming/language/ocaml/ocaml/files/fedora/0003-Don-t-add-rpaths-to-libraries.patch b/programming/language/ocaml/ocaml/files/fedora/0001-Don-t-add-rpaths-to-libraries.patch similarity index 71% rename from programming/language/ocaml/ocaml/files/fedora/0003-Don-t-add-rpaths-to-libraries.patch rename to programming/language/ocaml/ocaml/files/fedora/0001-Don-t-add-rpaths-to-libraries.patch index 1d36cccb11..02d4e85c6c 100644 --- a/programming/language/ocaml/ocaml/files/fedora/0003-Don-t-add-rpaths-to-libraries.patch +++ b/programming/language/ocaml/ocaml/files/fedora/0001-Don-t-add-rpaths-to-libraries.patch @@ -1,20 +1,20 @@ -From 79f0f91e3e4abbfbd3564c11ea72e53310236afc Mon Sep 17 00:00:00 2001 +From fc5ac0d955afce294fe58a20cab8e9dda572de78 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 24 Jun 2014 10:00:15 +0100 -Subject: [PATCH 03/12] Don't add rpaths to libraries. +Subject: [PATCH 01/10] Don't add rpaths to libraries. --- tools/Makefile.shared | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/Makefile.shared b/tools/Makefile.shared -index 2517434..75a75b4 100644 +index 2803d78..d6c42bb 100644 --- a/tools/Makefile.shared +++ b/tools/Makefile.shared -@@ -112,9 +112,9 @@ ocamlmklibconfig.ml: ../config/Makefile - echo 'let ext_dll = "$(EXT_DLL)"'; \ +@@ -154,9 +154,9 @@ $(call byte_and_opt,ocamlmklib,ocamlmklibconfig.cmo config.cmo \ + ocamlmklibconfig.ml: ../config/Makefile Makefile + (echo 'let bindir = "$(BINDIR)"'; \ echo 'let supports_shared_libraries = $(SUPPORTS_SHARED_LIBRARIES)';\ - echo 'let mkdll = "$(MKDLL)"'; \ - echo 'let byteccrpath = "$(BYTECCRPATH)"'; \ - echo 'let nativeccrpath = "$(NATIVECCRPATH)"'; \ - echo 'let mksharedlibrpath = "$(MKSHAREDLIBRPATH)"'; \ @@ -25,5 +25,4 @@ index 2517434..75a75b4 100644 sed -n -e 's/^#ml //p' ../config/Makefile) \ > ocamlmklibconfig.ml -- -2.0.4 - +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0001-Don-t-ignore-.-configure-it-s-a-real-git-file.patch b/programming/language/ocaml/ocaml/files/fedora/0001-Don-t-ignore-.-configure-it-s-a-real-git-file.patch deleted file mode 100644 index 6561c038fe..0000000000 --- a/programming/language/ocaml/ocaml/files/fedora/0001-Don-t-ignore-.-configure-it-s-a-real-git-file.patch +++ /dev/null @@ -1,24 +0,0 @@ -From ccc1bf226619608230dc94b26377756719cf7b20 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 24 Jun 2014 22:29:38 +0100 -Subject: [PATCH 01/12] Don't ignore ./configure, it's a real git file. - ---- - .gitignore | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/.gitignore b/.gitignore -index d36195a..dbb0e3e 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -19,7 +19,6 @@ - /.depend - /.depend.nt - /.DS_Store --/configure - /ocamlc - /ocamlc.opt - /expunge --- -2.0.4 - diff --git a/programming/language/ocaml/ocaml/files/fedora/0002-Ensure-empty-compilerlibs-directory-is-created-by-gi.patch b/programming/language/ocaml/ocaml/files/fedora/0002-Ensure-empty-compilerlibs-directory-is-created-by-gi.patch deleted file mode 100644 index 6560bd343d..0000000000 --- a/programming/language/ocaml/ocaml/files/fedora/0002-Ensure-empty-compilerlibs-directory-is-created-by-gi.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0e3b6450f6ab803442a809b6da41d5d5c5da650f Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Thu, 7 Jun 2012 15:36:16 +0100 -Subject: [PATCH 02/12] Ensure empty compilerlibs/ directory is created by git. - -This directory exists in the OCaml tarball, but is empty. As a -result, git ignores it unless we put a dummy file in it. ---- - compilerlibs/.exists | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) - create mode 100644 compilerlibs/.exists - -diff --git a/compilerlibs/.exists b/compilerlibs/.exists -new file mode 100644 -index 0000000..e69de29 --- -2.0.4 - diff --git a/programming/language/ocaml/ocaml/files/fedora/0004-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch b/programming/language/ocaml/ocaml/files/fedora/0002-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch similarity index 98% rename from programming/language/ocaml/ocaml/files/fedora/0004-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch rename to programming/language/ocaml/ocaml/files/fedora/0002-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch index 5e117b7dc4..023085ebca 100644 --- a/programming/language/ocaml/ocaml/files/fedora/0004-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch +++ b/programming/language/ocaml/ocaml/files/fedora/0002-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch @@ -1,7 +1,7 @@ -From 11b377aee2811891635982a5590fef62f12645b6 Mon Sep 17 00:00:00 2001 +From 61bdb02cedd1be6ecdc37bc4a80ffe3f19aa5521 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:40:36 +0100 -Subject: [PATCH 04/12] ocamlbyteinfo, ocamlplugininfo: Useful utilities from +Subject: [PATCH 02/10] ocamlbyteinfo, ocamlplugininfo: Useful utilities from Debian, sent upstream. See: @@ -236,5 +236,4 @@ index 0000000..e28800f + header.units + end -- -2.0.4 - +2.9.3 diff --git a/programming/language/ocaml/ocaml/files/fedora/0005-configure-Allow-user-defined-C-compiler-flags.patch b/programming/language/ocaml/ocaml/files/fedora/0003-configure-Allow-user-defined-C-compiler-flags.patch similarity index 59% rename from programming/language/ocaml/ocaml/files/fedora/0005-configure-Allow-user-defined-C-compiler-flags.patch rename to programming/language/ocaml/ocaml/files/fedora/0003-configure-Allow-user-defined-C-compiler-flags.patch index c66d1fbaf2..58205019a3 100644 --- a/programming/language/ocaml/ocaml/files/fedora/0005-configure-Allow-user-defined-C-compiler-flags.patch +++ b/programming/language/ocaml/ocaml/files/fedora/0003-configure-Allow-user-defined-C-compiler-flags.patch @@ -1,19 +1,19 @@ -From 5308c47681201ef3beef3e543ab877f81aa08784 Mon Sep 17 00:00:00 2001 +From 2f93494aea56c9216bb561800a6861b653f409ce Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 29 May 2012 20:44:18 +0100 -Subject: [PATCH 05/12] configure: Allow user defined C compiler flags. +Subject: [PATCH 03/10] configure: Allow user defined C compiler flags. --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure -index dbc6178..c1133ee 100755 +index f43893a..41c9315 100755 --- a/configure +++ b/configure -@@ -1633,6 +1633,10 @@ case "$buggycc" in - nativecccompopts="$nativecccompopts -fomit-frame-pointer";; - esac +@@ -1901,6 +1901,10 @@ if $with_fpic; then + echo "#define CAML_WITH_FPIC" >> m.h + fi +# Allow user defined C Compiler flags +bytecccompopts="$bytecccompopts $CFLAGS" @@ -23,5 +23,4 @@ index dbc6178..c1133ee 100755 cclibs="$cclibs $mathlib" -- -2.0.4 - +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0004-Don-t-rewrite-Werror.patch b/programming/language/ocaml/ocaml/files/fedora/0004-Don-t-rewrite-Werror.patch new file mode 100644 index 0000000000..429b040f9d --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0004-Don-t-rewrite-Werror.patch @@ -0,0 +1,27 @@ +From cdd42ba82210bfaa97cfa010eaac3d805b80cb49 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 3 Nov 2016 19:50:20 +0000 +Subject: [PATCH 04/10] Don't rewrite -Werror. + +In Fedora our CFLAGS contains -Wall -Werror=format-security. + +As written, the sed phrase substitutes this with -Wall=format-security +which is bogus. Remove this rewriting completely. +--- + Makefile | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 85be2db..1764d0e 100644 +--- a/Makefile ++++ b/Makefile +@@ -409,7 +409,6 @@ utils/config.ml: utils/config.mlp config/Makefile + -e 's|%%CCOMPTYPE%%|cc|' \ + -e 's|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS)|' \ + -e 's|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|' \ +- -e '/c_compiler =/s| -Werror||' \ + -e 's|%%PACKLD%%|$(PACKLD)|' \ + -e 's|%%BYTECCLIBS%%|$(BYTECCLIBS)|' \ + -e 's|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|' \ +-- +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0005-PR-7405-s390x-Fix-address-of-caml_raise_exn-in-nativ.patch b/programming/language/ocaml/ocaml/files/fedora/0005-PR-7405-s390x-Fix-address-of-caml_raise_exn-in-nativ.patch new file mode 100644 index 0000000000..4b0ebe5b82 --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0005-PR-7405-s390x-Fix-address-of-caml_raise_exn-in-nativ.patch @@ -0,0 +1,28 @@ +From d4a20446fc8d00223b0c23726618407e451472e8 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 9 Nov 2016 11:01:15 -0500 +Subject: [PATCH 05/10] PR#7405: s390x: Fix address of caml_raise_exn in native + dynlink modules. + +This commit started as Fedora patch e732c39340e86939530a087744caa8d8f1247878. + +(cherry picked from commit d6f24c5f4ee9408ac9a00e3de84f417450b41215) +--- + asmcomp/s390x/emit.mlp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/asmcomp/s390x/emit.mlp b/asmcomp/s390x/emit.mlp +index 5d233a3..f99380a 100644 +--- a/asmcomp/s390x/emit.mlp ++++ b/asmcomp/s390x/emit.mlp +@@ -611,7 +611,7 @@ let emit_instr i = + | Lraise k -> + begin match k with + | Cmm.Raise_withtrace -> +- ` brasl %r14, {emit_symbol "caml_raise_exn"}\n`; ++ ` {emit_call "caml_raise_exn"}\n`; + let lbl = record_frame Reg.Set.empty true i.dbg in + `{emit_label lbl}:\n` + | Cmm.Raise_notrace -> +-- +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0006-Adapt-config.guess-for-RISC-V.patch b/programming/language/ocaml/ocaml/files/fedora/0006-Adapt-config.guess-for-RISC-V.patch new file mode 100644 index 0000000000..a5f44b2950 --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0006-Adapt-config.guess-for-RISC-V.patch @@ -0,0 +1,34 @@ +From 427232f0f36bfcaafcb1ec2f8da3d1daad0b1121 Mon Sep 17 00:00:00 2001 +From: Nicolas Ojeda Bar +Date: Tue, 8 Nov 2016 23:56:50 +0100 +Subject: [PATCH 06/10] Adapt config.guess for RISC-V + +--- + config/gnu/config.guess | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/config/gnu/config.guess b/config/gnu/config.guess +index b79252d..8335398 100755 +--- a/config/gnu/config.guess ++++ b/config/gnu/config.guess +@@ -2,7 +2,7 @@ + # Attempt to guess a canonical system name. + # Copyright 1992-2013 Free Software Foundation, Inc. + +-timestamp='2013-06-10' ++timestamp='2016-10-23' + + # This file is free software; you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by +@@ -1001,6 +1001,9 @@ EOF + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; ++ riscv*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux ++ exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; +-- +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0007-Add-RISC-V-backend-runtime.patch b/programming/language/ocaml/ocaml/files/fedora/0007-Add-RISC-V-backend-runtime.patch new file mode 100644 index 0000000000..d456ea1258 --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0007-Add-RISC-V-backend-runtime.patch @@ -0,0 +1,1716 @@ +From cc3aa63c6892479851786af89b956004491dc84c Mon Sep 17 00:00:00 2001 +From: Nicolas Ojeda Bar +Date: Fri, 4 Nov 2016 20:39:09 +0100 +Subject: [PATCH 07/10] Add RISC-V backend & runtime + +--- + README.adoc | 1 + + asmcomp/riscv/CSE.ml | 36 +++ + asmcomp/riscv/arch.ml | 84 ++++++ + asmcomp/riscv/emit.mlp | 616 ++++++++++++++++++++++++++++++++++++++++++++ + asmcomp/riscv/proc.ml | 301 ++++++++++++++++++++++ + asmcomp/riscv/reload.ml | 16 ++ + asmcomp/riscv/scheduling.ml | 19 ++ + asmcomp/riscv/selection.ml | 85 ++++++ + asmrun/riscv.S | 424 ++++++++++++++++++++++++++++++ + byterun/caml/stack.h | 5 + + configure | 5 +- + 11 files changed, 1591 insertions(+), 1 deletion(-) + create mode 100644 asmcomp/riscv/CSE.ml + create mode 100644 asmcomp/riscv/arch.ml + create mode 100644 asmcomp/riscv/emit.mlp + create mode 100644 asmcomp/riscv/proc.ml + create mode 100644 asmcomp/riscv/reload.ml + create mode 100644 asmcomp/riscv/scheduling.ml + create mode 100644 asmcomp/riscv/selection.ml + create mode 100644 asmrun/riscv.S + +diff --git a/README.adoc b/README.adoc +index 480b025..cb6eebf 100644 +--- a/README.adoc ++++ b/README.adoc +@@ -34,6 +34,7 @@ IA32 (Pentium):: NetBSD, OpenBSD, Solaris 9 + PowerPC:: NetBSD + ARM:: NetBSD + SPARC:: Solaris, Linux, NetBSD ++RISC-V:: Linux + + Other operating systems for the processors above have not been tested, but + the compiler may work under other operating systems with little work. +diff --git a/asmcomp/riscv/CSE.ml b/asmcomp/riscv/CSE.ml +new file mode 100644 +index 0000000..302811a +--- /dev/null ++++ b/asmcomp/riscv/CSE.ml +@@ -0,0 +1,36 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2106 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* CSE for the RISC-V *) ++ ++open Arch ++open Mach ++open CSEgen ++ ++class cse = object (_self) ++ ++inherit cse_generic as super ++ ++method! class_of_operation op = ++ match op with ++ | Ispecific(Imultaddf _ | Imultsubf _) -> Op_pure ++ | _ -> super#class_of_operation op ++ ++method! is_cheap_operation op = ++ match op with ++ | Iconst_int n -> n <= 0x7FFn && n >= -0x800n ++ | _ -> false ++ ++end ++ ++let fundecl f = ++ (new cse)#fundecl f +diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml +new file mode 100644 +index 0000000..61a38b1 +--- /dev/null ++++ b/asmcomp/riscv/arch.ml +@@ -0,0 +1,84 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Specific operations for the RISC-V processor *) ++ ++open Format ++ ++(* Machine-specific command-line options *) ++ ++let command_line_options = [] ++ ++(* Specific operations *) ++ ++type specific_operation = ++ | Imultaddf of bool (* multiply, optionally negate, and add *) ++ | Imultsubf of bool (* multiply, optionally negate, and subtract *) ++ ++let spacetime_node_hole_pointer_is_live_before = function ++ | Imultaddf _ | Imultsubf _ -> false ++ ++(* Addressing modes *) ++ ++type addressing_mode = ++ | Iindexed of int (* reg + displ *) ++ ++(* Sizes, endianness *) ++ ++let big_endian = false ++ ++let rv64 = ++ match Config.model with "riscv64" -> true | "riscv32" -> false | _ -> assert false ++ ++let size_addr = if rv64 then 8 else 4 ++let size_int = size_addr ++let size_float = 8 ++ ++let allow_unaligned_access = false ++ ++(* Behavior of division *) ++ ++let division_crashes_on_overflow = false ++ ++(* Operations on addressing modes *) ++ ++let identity_addressing = Iindexed 0 ++ ++let offset_addressing addr delta = ++ match addr with ++ | Iindexed n -> Iindexed(n + delta) ++ ++let num_args_addressing = function ++ | Iindexed _ -> 1 ++ ++(* Printing operations and addressing modes *) ++ ++let print_addressing printreg addr ppf arg = ++ match addr with ++ | Iindexed n -> ++ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in ++ fprintf ppf "%a%s" printreg arg.(0) idx ++ ++let print_specific_operation printreg op ppf arg = ++ match op with ++ | Imultaddf false -> ++ fprintf ppf "%a *f %a +f %a" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultaddf true -> ++ fprintf ppf "-f (%a *f %a +f %a)" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultsubf false -> ++ fprintf ppf "%a *f %a -f %a" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) ++ | Imultsubf true -> ++ fprintf ppf "-f (%a *f %a -f %a)" ++ printreg arg.(0) printreg arg.(1) printreg arg.(2) +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +new file mode 100644 +index 0000000..6d0e3ae +--- /dev/null ++++ b/asmcomp/riscv/emit.mlp +@@ -0,0 +1,616 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Emission of RISC-V assembly code *) ++ ++open Misc ++open Cmm ++open Arch ++open Proc ++open Reg ++open Mach ++open Linearize ++open Emitaux ++ ++(* Layout of the stack. The stack is kept 16-aligned. *) ++ ++let stack_offset = ref 0 ++ ++let frame_size () = ++ let size = ++ !stack_offset + (* Trap frame, outgoing parameters *) ++ size_int * num_stack_slots.(0) + (* Local int variables *) ++ size_float * num_stack_slots.(1) + (* Local float variables *) ++ (if !contains_calls then size_addr else 0) in (* The return address *) ++ Misc.align size 16 ++ ++let slot_offset loc cls = ++ match loc with ++ | Local n -> ++ if cls = 0 ++ then !stack_offset + num_stack_slots.(1) * size_float + n * size_int ++ else !stack_offset + n * size_float ++ | Incoming n -> frame_size() + n ++ | Outgoing n -> n ++ ++(* Output a symbol *) ++ ++let emit_symbol s = ++ Emitaux.emit_symbol '.' s ++ ++(* Output a label *) ++ ++let label_prefix = "L" ++ ++let emit_label lbl = ++ emit_string label_prefix; emit_int lbl ++ ++(* Section switching *) ++ ++let data_space = ++ ".section .data" ++ ++let code_space = ++ ".section .text" ++ ++let rodata_space = ++ ".section .rodata" ++ ++let reg_tmp1 = phys_reg 21 (* used by the assembler *) ++let reg_tmp2 = phys_reg 22 ++let reg_t2 = phys_reg 16 ++(* let reg_fp = phys_reg 23 *) ++let reg_trap = phys_reg 24 ++let reg_alloc_ptr = phys_reg 25 ++let reg_alloc_lim = phys_reg 26 ++ ++(* Names of instructions that differ in 32 and 64-bit modes *) ++ ++let lg = if rv64 then "ld" else "lw" ++let stg = if rv64 then "sd" else "sw" ++let datag = if rv64 then ".quad" else ".long" ++ ++(* Output a pseudo-register *) ++ ++let emit_reg = function ++ | {loc = Reg r} -> emit_string (register_name r) ++ | _ -> fatal_error "Emit.emit_reg" ++ ++(* Output a stack reference *) ++ ++let emit_stack r = ++ match r.loc with ++ Stack s -> ++ let ofs = slot_offset s (register_class r) in `{emit_int ofs}(sp)` ++ | _ -> fatal_error "Emit.emit_stack" ++ ++(* Record live pointers at call points *) ++ ++let record_frame_label ?label live raise_ dbg = ++ let lbl = ++ match label with ++ | None -> new_label() ++ | Some label -> label ++ in ++ let live_offset = ref [] in ++ Reg.Set.iter ++ (function ++ {typ = Val; loc = Reg r} -> ++ live_offset := (r lsl 1) + 1 :: !live_offset ++ | {typ = Val; loc = Stack s} as reg -> ++ live_offset := slot_offset s (register_class reg) :: !live_offset ++ | {typ = Addr} as r -> ++ Misc.fatal_error ("bad GC root " ^ Reg.name r) ++ | _ -> () ++ ) ++ live; ++ frame_descriptors := ++ { fd_lbl = lbl; ++ fd_frame_size = frame_size(); ++ fd_live_offset = !live_offset; ++ fd_raise = raise_; ++ fd_debuginfo = dbg } :: !frame_descriptors; ++ lbl ++ ++let record_frame ?label live raise_ dbg = ++ let lbl = record_frame_label ?label live raise_ dbg in ++ `{emit_label lbl}:\n` ++ ++(* Record calls to the GC -- we've moved them out of the way *) ++ ++type gc_call = ++ { gc_lbl: label; (* Entry label *) ++ gc_return_lbl: label; (* Where to branch after GC *) ++ gc_frame_lbl: label } (* Label of frame descriptor *) ++ ++let call_gc_sites = ref ([] : gc_call list) ++ ++let emit_call_gc gc = ++ `{emit_label gc.gc_lbl}:\n`; ++ ` call {emit_symbol "caml_call_gc"}\n`; ++ `{emit_label gc.gc_frame_lbl}:\n`; ++ ` j {emit_label gc.gc_return_lbl}\n` ++ ++(* Record calls to caml_ml_array_bound_error. ++ In debug mode, we maintain one call to caml_ml_array_bound_error ++ per bound check site. Otherwise, we can share a single call. *) ++ ++type bound_error_call = ++ { bd_lbl: label; (* Entry label *) ++ bd_frame_lbl: label } (* Label of frame descriptor *) ++ ++let bound_error_sites = ref ([] : bound_error_call list) ++ ++let bound_error_label ?label dbg = ++ if !Clflags.debug || !bound_error_sites = [] then begin ++ let lbl_bound_error = new_label() in ++ let lbl_frame = record_frame_label ?label Reg.Set.empty false dbg in ++ bound_error_sites := ++ { bd_lbl = lbl_bound_error; ++ bd_frame_lbl = lbl_frame } :: !bound_error_sites; ++ lbl_bound_error ++ end else ++ let bd = List.hd !bound_error_sites in ++ bd.bd_lbl ++ ++let emit_call_bound_error bd = ++ `{emit_label bd.bd_lbl}:\n`; ++ ` call {emit_symbol "caml_ml_array_bound_error"}\n`; ++ `{emit_label bd.bd_frame_lbl}:\n` ++ ++(* Record floating-point literals *) ++ ++let float_literals = ref ([] : (int64 * int) list) ++ ++(* Names for various instructions *) ++ ++let name_for_intop = function ++ | Iadd -> "add" ++ | Isub -> "sub" ++ | Imul -> "mul" ++ | Imulh -> "mulh" ++ | Idiv -> "div" ++ | Iand -> "and" ++ | Ior -> "or" ++ | Ixor -> "xor" ++ | Ilsl -> "sll" ++ | Ilsr -> "srl" ++ | Iasr -> "sra" ++ | Imod -> "rem" ++ | _ -> fatal_error "Emit.Intop" ++ ++let name_for_intop_imm = function ++ | Iadd -> "addi" ++ | Iand -> "andi" ++ | Ior -> "ori" ++ | Ixor -> "xori" ++ | Ilsl -> "slli" ++ | Ilsr -> "srli" ++ | Iasr -> "srai" ++ | _ -> fatal_error "Emit.Intop_imm" ++ ++let name_for_floatop1 = function ++ | Inegf -> "fneg.d" ++ | Iabsf -> "fabs.d" ++ | _ -> fatal_error "Emit.Iopf1" ++ ++let name_for_floatop2 = function ++ | Iaddf -> "fadd.d" ++ | Isubf -> "fsub.d" ++ | Imulf -> "fmul.d" ++ | Idivf -> "fdiv.d" ++ | _ -> fatal_error "Emit.Iopf2" ++ ++let name_for_specific = function ++ | Imultaddf false -> "fmadd.d" ++ | Imultaddf true -> "fnmadd.d" ++ | Imultsubf false -> "fmsub.d" ++ | Imultsubf true -> "fnmsub.d" ++ ++(* Name of current function *) ++let function_name = ref "" ++(* Entry point for tail recursive calls *) ++let tailrec_entry_point = ref 0 ++ ++(* Output the assembly code for an instruction *) ++ ++let emit_instr i = ++ match i.desc with ++ Lend -> () ++ | Lop(Imove | Ispill | Ireload) -> ++ let src = i.arg.(0) and dst = i.res.(0) in ++ if src.loc <> dst.loc then begin ++ match (src, dst) with ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} -> ++ ` mv {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> ++ ` fmv.d {emit_reg dst}, {emit_reg src}\n` ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack _} -> ++ ` {emit_string stg} {emit_reg src}, {emit_stack dst}\n` ++ | {loc = Reg _; typ = Float}, {loc = Stack _} -> ++ ` fsd {emit_reg src}, {emit_stack dst}\n` ++ | {loc = Stack _; typ = (Val | Int | Addr)}, {loc = Reg _ } -> ++ ` {emit_string lg} {emit_reg dst}, {emit_stack src}\n` ++ | {loc = Stack _; typ = Float}, {loc = Reg _} -> ++ ` fld {emit_reg dst}, {emit_stack src}\n` ++ | _ -> ++ fatal_error "Emit: Imove" ++ end ++ | Lop(Iconst_int n) -> ++ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` ++ | Lop(Iconst_float f) -> ++ let lbl = new_label() in ++ float_literals := (f, lbl) :: !float_literals; ++ ` fld {emit_reg i.res.(0)}, {emit_label lbl}, {emit_reg reg_tmp1}\n` ++ | Lop(Iconst_symbol s) -> ++ ` la {emit_reg i.res.(0)}, {emit_symbol s}\n` ++ | Lop(Icall_ind {label_after = label}) -> ++ ` jalr {emit_reg i.arg.(0)}\n`; ++ record_frame ~label i.live false i.dbg ++ | Lop(Icall_imm {func; label_after = label}) -> ++ ` call {emit_symbol func}\n`; ++ record_frame ~label i.live false i.dbg ++ | Lop(Itailcall_ind {label_after = _}) -> ++ let n = frame_size() in ++ if !contains_calls then ++ ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n`; ++ if n > 0 then ++ ` addi sp, sp, {emit_int n}\n`; ++ ` jr {emit_reg i.arg.(0)}\n` ++ | Lop(Itailcall_imm {func; label_after = _}) -> ++ if func = !function_name then begin ++ ` j {emit_label !tailrec_entry_point}\n` ++ end else begin ++ let n = frame_size() in ++ if !contains_calls then ++ ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n`; ++ if n > 0 then ++ ` addi sp, sp, {emit_int n}\n`; ++ ` tail {emit_symbol func}\n` ++ end ++ | Lop(Iextcall{func; alloc = true; label_after = label}) -> ++ ` la {emit_reg reg_t2}, {emit_symbol func}\n`; ++ ` call {emit_symbol "caml_c_call"}\n`; ++ record_frame ~label i.live false i.dbg ++ | Lop(Iextcall{func; alloc = false; label_after = _}) -> ++ ` call {emit_symbol func}\n` ++ | Lop(Istackoffset n) -> ++ assert (n mod 16 = 0); ++ ` addi sp, sp, {emit_int (-n)}\n`; ++ stack_offset := !stack_offset + n ++ | Lop(Iload(Single, Iindexed ofs)) -> ++ ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; ++ ` fcvt.d.s {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Lop(Iload(chunk, Iindexed ofs)) -> ++ let instr = ++ match chunk with ++ | Byte_unsigned -> "lbu" ++ | Byte_signed -> "lb" ++ | Sixteen_unsigned -> "lhu" ++ | Sixteen_signed -> "lh" ++ | Thirtytwo_unsigned -> if rv64 then "lwu" else "lw" ++ | Thirtytwo_signed -> "lw" ++ | Word_int | Word_val -> lg ++ | Single -> assert false ++ | Double | Double_u -> "fld" ++ in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n` ++ | Lop(Istore(Single, Iindexed ofs, _)) -> ++ ` fmv.x.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}\n`; ++ ` fcvt.s.d {emit_reg i.arg.(0)}, {emit_reg i.arg.(0)}\n`; ++ ` fsw {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n`; ++ ` fmv.d.x {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}\n` ++ | Lop(Istore(chunk, Iindexed ofs, _)) -> ++ let instr = ++ match chunk with ++ | Byte_unsigned | Byte_signed -> "sb" ++ | Sixteen_unsigned | Sixteen_signed -> "sh" ++ | Thirtytwo_unsigned | Thirtytwo_signed -> "sw" ++ | Word_int | Word_val -> stg ++ | Single -> assert false ++ | Double | Double_u -> "fsd" ++ in ++ ` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n` ++ | Lop(Ialloc {words = n; label_after_call_gc = label; _}) -> ++ let lbl_frame_lbl = record_frame_label ?label i.live false i.dbg in ++ let lbl_redo = new_label () in ++ let lbl_call_gc = new_label () in ++ `{emit_label lbl_redo}:\n`; ++ ` addi {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_ptr}, -{emit_int n}\n`; ++ ` addi {emit_reg i.res.(0)}, {emit_reg reg_alloc_ptr}, {emit_int size_addr}\n`; ++ ` bltu {emit_reg reg_alloc_ptr}, {emit_reg reg_alloc_lim}, {emit_label lbl_call_gc}\n`; ++ call_gc_sites := ++ { gc_lbl = lbl_call_gc; ++ gc_return_lbl = lbl_redo; ++ gc_frame_lbl = lbl_frame_lbl } :: !call_gc_sites ++ | Lop(Iintop(Icomp cmp)) -> ++ begin match cmp with ++ | Isigned Clt -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Isigned Cge -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Isigned Cgt -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | Isigned Cle -> ++ ` slt {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Isigned Ceq | Iunsigned Ceq -> ++ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` seqz {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Isigned Cne | Iunsigned Cne -> ++ ` sub {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` snez {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` ++ | Iunsigned Clt -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Iunsigned Cge -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ | Iunsigned Cgt -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` ++ | Iunsigned Cle -> ++ ` sltu {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; ++ ` xori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, 1\n`; ++ end ++ | Lop(Iintop (Icheckbound {label_after_error = label; _})) -> ++ let lbl = bound_error_label ?label i.dbg in ++ ` bleu {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` ++ | Lop(Iintop op) -> ++ let instr = name_for_intop op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Lop(Iintop_imm(Isub, n)) -> ++ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` ++ | Lop(Iintop_imm(Icomp _, _)) -> ++ fatal_error "Emit.emit_instr (Iintop_imm (Icomp _, _))" ++ | Lop(Iintop_imm(Icheckbound {label_after_error = label; _}, n)) -> ++ let lbl = bound_error_label ?label i.dbg in ++ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; ++ ` bleu {emit_reg i.arg.(0)}, {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ | Lop(Iintop_imm(op, n)) -> ++ let instr = name_for_intop_imm op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` ++ | Lop(Inegf | Iabsf as op) -> ++ let instr = name_for_floatop1 op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> ++ let instr = name_for_floatop2 op in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` ++ | Lop(Ifloatofint) -> ++ let name = if rv64 then "fcvt.d.l" else "fcvt.d.w" in ++ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Iintoffloat) -> ++ let name = if rv64 then "fcvt.l.d" else "fcvt.w.d" in ++ ` {emit_string name} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` ++ | Lop(Ispecific sop) -> ++ let instr = name_for_specific sop in ++ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` ++ | Lreloadretaddr -> ++ let n = frame_size () in ++ ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n` ++ | Lreturn -> ++ let n = frame_size() in ++ if n > 0 then ++ ` addi sp, sp, {emit_int n}\n`; ++ ` ret\n` ++ | Llabel lbl -> ++ `{emit_label lbl}:\n` ++ | Lbranch lbl -> ++ ` j {emit_label lbl}\n` ++ | Lcondbranch(tst, lbl) -> ++ begin match tst with ++ | Itruetest -> ++ ` bnez {emit_reg i.arg.(0)}, {emit_label lbl}\n` ++ | Ifalsetest -> ++ ` beqz {emit_reg i.arg.(0)}, {emit_label lbl}\n` ++ | Iinttest cmp -> ++ let name = match cmp with ++ | Iunsigned Ceq | Isigned Ceq -> "beq" ++ | Iunsigned Cne | Isigned Cne -> "bne" ++ | Iunsigned Cle -> "bleu" | Isigned Cle -> "ble" ++ | Iunsigned Cge -> "bgeu" | Isigned Cge -> "bge" ++ | Iunsigned Clt -> "bltu" | Isigned Clt -> "blt" ++ | Iunsigned Cgt -> "bgtu" | Isigned Cgt -> "bgt" ++ in ++ ` {emit_string name} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_label lbl}\n` ++ | Iinttest_imm _ -> ++ fatal_error "Emit.emit_instr (Iinttest_imm _)" ++ | Ifloattest(cmp, neg) -> ++ let neg = match cmp with ++ | Ceq -> ` feq.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; neg ++ | Cne -> ` feq.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; not neg ++ | Clt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; neg ++ | Cgt -> ` flt.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; neg ++ | Cle -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; neg ++ | Cge -> ` fle.d {emit_reg reg_tmp1}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n`; neg ++ in ++ if neg then ++ ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ else ++ ` bnez {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ | Ioddtest -> ++ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; ++ ` bnez {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ | Ieventest -> ++ ` andi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, 1\n`; ++ ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end ++ | Lcondbranch3(lbl0, lbl1, lbl2) -> ++ ` addi {emit_reg reg_tmp1}, {emit_reg i.arg.(0)}, -1\n`; ++ begin match lbl0 with ++ | None -> () ++ | Some lbl -> ` bltz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end; ++ begin match lbl1 with ++ | None -> () ++ | Some lbl -> ` beqz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end; ++ begin match lbl2 with ++ | None -> () ++ | Some lbl -> ` bgtz {emit_reg reg_tmp1}, {emit_label lbl}\n` ++ end ++ | Lswitch jumptbl -> (* FIXME FIXME ? *) ++ let lbl = new_label() in ++ ` la {emit_reg reg_tmp1}, {emit_label lbl}\n`; ++ ` slli {emit_reg reg_tmp2}, {emit_reg i.arg.(0)}, 2\n`; ++ ` add {emit_reg reg_tmp1}, {emit_reg reg_tmp1}, {emit_reg reg_tmp2}\n`; ++ ` jr {emit_reg reg_tmp1}\n`; ++ `{emit_label lbl}:\n`; ++ for i = 0 to Array.length jumptbl - 1 do ++ ` j {emit_label jumptbl.(i)}\n` ++ done ++ | Lsetuptrap lbl -> ++ ` addi sp, sp, -16\n`; ++ ` jal {emit_label lbl}\n` ++ | Lpushtrap -> ++ stack_offset := !stack_offset + 16; ++ ` {emit_string stg} ra, {emit_int size_addr}(sp)\n`; ++ ` {emit_string stg} {emit_reg reg_trap}, 0(sp)\n`; ++ ` mv {emit_reg reg_trap}, sp\n` ++ | Lpoptrap -> ++ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; ++ ` addi sp, sp, 16\n`; ++ stack_offset := !stack_offset - 16 ++ | Lraise k -> ++ begin match !Clflags.debug, k with ++ | true, Cmm.Raise_withtrace -> ++ ` call {emit_symbol "caml_raise_exn"}\n`; ++ record_frame Reg.Set.empty true i.dbg ++ | false, _ ++ | true, Cmm.Raise_notrace -> ++ ` mv sp, {emit_reg reg_trap}\n`; ++ ` {emit_string lg} {emit_reg reg_tmp1}, {emit_int size_addr}(sp)\n`; ++ ` {emit_string lg} {emit_reg reg_trap}, 0(sp)\n`; ++ ` addi sp, sp, 16\n`; ++ ` jalr {emit_reg reg_tmp1}\n` ++ end ++ ++(* Emit a sequence of instructions *) ++ ++let rec emit_all = function ++ | {desc = Lend} -> () | i -> emit_instr i; emit_all i.next ++ ++(* Emission of a function declaration *) ++ ++let fundecl fundecl = ++ function_name := fundecl.fun_name; ++ tailrec_entry_point := new_label(); ++ stack_offset := 0; ++ call_gc_sites := []; ++ bound_error_sites := []; ++ float_literals := []; ++ ` .globl {emit_symbol fundecl.fun_name}\n`; ++ ` .type {emit_symbol fundecl.fun_name}, @function\n`; ++ ` {emit_string code_space}\n`; ++ ` .align 2\n`; ++ `{emit_symbol fundecl.fun_name}:\n`; ++ let n = frame_size() in ++ if n > 0 then ++ ` addi sp, sp, {emit_int(-n)}\n`; ++ if !contains_calls then ++ ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n`; ++ `{emit_label !tailrec_entry_point}:\n`; ++ emit_all fundecl.fun_body; ++ List.iter emit_call_gc !call_gc_sites; ++ List.iter emit_call_bound_error !bound_error_sites; ++ ` .size {emit_symbol fundecl.fun_name}, .-{emit_symbol fundecl.fun_name}\n`; ++ (* Emit the float literals *) ++ if !float_literals <> [] then begin ++ ` {emit_string rodata_space}\n`; ++ ` .align 3\n`; ++ List.iter ++ (fun (f, lbl) -> ++ `{emit_label lbl}:\n`; ++ if rv64 ++ then emit_float64_directive ".quad" f ++ else emit_float64_split_directive ".long" f) ++ !float_literals; ++ end ++ ++(* Emission of data *) ++ ++let declare_global_data s = ++ ` .globl {emit_symbol s}\n`; ++ ` .type {emit_symbol s}, @object\n` ++ ++let emit_item = function ++ | Cglobal_symbol s -> ++ declare_global_data s ++ | Cdefine_symbol s -> ++ `{emit_symbol s}:\n`; ++ | Cint8 n -> ++ ` .byte {emit_int n}\n` ++ | Cint16 n -> ++ ` .short {emit_int n}\n` ++ | Cint32 n -> ++ ` .long {emit_nativeint n}\n` ++ | Cint n -> ++ ` {emit_string datag} {emit_nativeint n}\n` ++ | Csingle f -> ++ emit_float32_directive ".long" (Int32.bits_of_float f) ++ | Cdouble f -> ++ if rv64 ++ then emit_float64_directive ".quad" (Int64.bits_of_float f) ++ else emit_float64_split_directive ".long" (Int64.bits_of_float f) ++ | Csymbol_address s -> ++ ` {emit_string datag} {emit_symbol s}\n` ++ | Cstring s -> ++ emit_bytes_directive " .byte " s ++ | Cskip n -> ++ if n > 0 then ` .space {emit_int n}\n` ++ | Calign n -> ++ ` .align {emit_int (Misc.log2 n)}\n` ++ ++let data l = ++ ` {emit_string data_space}\n`; ++ List.iter emit_item l ++ ++(* Beginning / end of an assembly file *) ++ ++let begin_assembly() = ++ (* Emit the beginning of the segments *) ++ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in ++ ` {emit_string data_space}\n`; ++ declare_global_data lbl_begin; ++ `{emit_symbol lbl_begin}:\n`; ++ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in ++ ` {emit_string code_space}\n`; ++ declare_global_data lbl_begin; ++ `{emit_symbol lbl_begin}:\n` ++ ++let end_assembly() = ++ ` {emit_string code_space}\n`; ++ let lbl_end = Compilenv.make_symbol (Some "code_end") in ++ declare_global_data lbl_end; ++ `{emit_symbol lbl_end}:\n`; ++ ` .long 0\n`; ++ ` {emit_string data_space}\n`; ++ let lbl_end = Compilenv.make_symbol (Some "data_end") in ++ declare_global_data lbl_end; ++ `{emit_symbol lbl_end}:\n`; ++ ` {emit_string datag} 0\n`; ++ (* Emit the frame descriptors *) ++ ` {emit_string rodata_space}\n`; ++ let lbl = Compilenv.make_symbol (Some "frametable") in ++ declare_global_data lbl; ++ `{emit_symbol lbl}:\n`; ++ emit_frames ++ { efa_code_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); ++ efa_data_label = (fun l -> ` {emit_string datag} {emit_label l}\n`); ++ efa_16 = (fun n -> ` .short {emit_int n}\n`); ++ efa_32 = (fun n -> ` .long {emit_int32 n}\n`); ++ efa_word = (fun n -> ` {emit_string datag} {emit_int n}\n`); ++ efa_align = (fun n -> ` .align {emit_int (Misc.log2 n)}\n`); ++ efa_label_rel = (fun lbl ofs -> ++ ` .long ({emit_label lbl} - .) + {emit_int32 ofs}\n`); ++ efa_def_label = (fun l -> `{emit_label l}:\n`); ++ efa_string = (fun s -> emit_bytes_directive " .byte " (s ^ "\000")) ++ } +diff --git a/asmcomp/riscv/proc.ml b/asmcomp/riscv/proc.ml +new file mode 100644 +index 0000000..c0b0dcd +--- /dev/null ++++ b/asmcomp/riscv/proc.ml +@@ -0,0 +1,301 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Description of the RISC-V *) ++ ++open Misc ++open Cmm ++open Reg ++open Arch ++open Mach ++ ++(* Instruction selection *) ++ ++let word_addressed = false ++ ++(* Registers available for register allocation *) ++ ++(* Integer register map: ++ zero always zero ++ ra return address ++ sp, gp, tp stack pointer, global pointer, thread pointer (preserved by C) ++ a0 - a7 0 - 7 arguments/results ++ s2 - s9 8 - 15 arguments/results (preserved by C) ++ t2 - t6 16 - 20 temporary ++ t0 21 temporary (used by assembler) ++ t1 22 temporary (reserved for code gen) ++ s0 23 frame pointer (preserved by C) ++ s1 24 trap pointer (preserved by C) ++ s10 25 allocation pointer (preserved by C) ++ s11 26 allocation limit (preserved by C) ++ Floating-point register map: ++ ft0 - ft7 100 - 107 temporary ++ fs0 - fs1 108 - 109 general purpose (preserved by C) ++ fa0 - fa7 110 - 117 arguments/results ++ fs2 - fs9 118 - 125 arguments/results (preserved by C) ++ fs10 - fs11 126 - 127 general purpose (preserved by C) ++ ft8 - ft11 128 - 131 temporary ++*) ++ ++let int_reg_name = ++ [| "a0"; "a1"; "a2"; "a3"; "a4"; "a5"; "a6"; "a7"; ++ "s2"; "s3"; "s4"; "s5"; "s6"; "s7"; "s8"; "s9"; ++ "t2"; "t3"; "t4"; "t5"; "t6"; ++ "t0"; "t1"; ++ "s0"; "s1"; "s10"; "s11" |] ++ ++let float_reg_name = ++ [| "ft0"; "ft1"; "ft2"; "ft3"; "ft4"; "ft5"; "ft6"; "ft7"; ++ "fs0"; "fs1"; ++ "fa0"; "fa1"; "fa2"; "fa3"; "fa4"; "fa5"; "fa6"; "fa7"; ++ "fs2"; "fs3"; "fs4"; "fs5"; "fs6"; "fs7"; "fs8"; "fs9"; "fs10"; "fs11"; ++ "ft8"; "ft9"; "ft10"; "ft11" |] ++ ++let num_register_classes = 2 ++ ++let register_class r = ++ match r.typ with ++ | Val | Int | Addr -> 0 ++ | Float -> 1 ++ ++let num_available_registers = [| 21; 32 |] ++ ++let first_available_register = [| 0; 100 |] ++ ++let register_name r = ++ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) ++ ++let rotate_registers = true ++ ++(* Representation of hard registers by pseudo-registers *) ++ ++let hard_int_reg = ++ let v = Array.make 27 Reg.dummy in ++ for i = 0 to 26 do ++ v.(i) <- Reg.at_location Int (Reg i) ++ done; ++ v ++ ++let hard_float_reg = ++ let v = Array.make 32 Reg.dummy in ++ for i = 0 to 31 do ++ v.(i) <- Reg.at_location Float (Reg(100 + i)) ++ done; ++ v ++ ++let all_phys_regs = ++ Array.append hard_int_reg hard_float_reg ++ ++let phys_reg n = ++ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) ++ ++let stack_slot slot ty = ++ Reg.at_location ty (Stack slot) ++ ++(* Calling conventions *) ++ ++let calling_conventions ++ first_int last_int first_float last_float make_stack arg = ++ let loc = Array.make (Array.length arg) Reg.dummy in ++ let int = ref first_int in ++ let float = ref first_float in ++ let ofs = ref 0 in ++ for i = 0 to Array.length arg - 1 do ++ match arg.(i).typ with ++ | Val | Int | Addr as ty -> ++ if !int <= last_int then begin ++ loc.(i) <- phys_reg !int; ++ incr int ++ end else begin ++ loc.(i) <- stack_slot (make_stack !ofs) ty; ++ ofs := !ofs + size_int ++ end ++ | Float -> ++ if !float <= last_float then begin ++ loc.(i) <- phys_reg !float; ++ incr float ++ end else begin ++ loc.(i) <- stack_slot (make_stack !ofs) Float; ++ ofs := !ofs + size_float ++ end ++ done; ++ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) ++ ++let incoming ofs = Incoming ofs ++let outgoing ofs = Outgoing ofs ++let not_supported _ = fatal_error "Proc.loc_results: cannot call" ++ ++let max_arguments_for_tailcalls = 16 ++ ++let loc_spacetime_node_hole = Reg.dummy (* Spacetime unsupported *) ++ ++(* OCaml calling convention: ++ first integer args in a0 .. a7, s2 .. s9 ++ first float args in fa0 .. fa7, fs2 .. fs9 ++ remaining args on stack. ++ Return values in a0 .. a7, s2 .. s9 or fa0 .. fa7, fs2 .. fs9. *) ++ ++let single_regs arg = Array.map (fun arg -> [| arg |]) arg ++let ensure_single_regs res = ++ Array.map (function ++ | [| res |] -> res ++ | _ -> failwith "proc.ensure_single_regs" ++ ) res ++ ++let loc_arguments arg = ++ calling_conventions 0 15 110 125 outgoing arg ++ ++let loc_parameters arg = ++ let (loc, _ofs) = ++ calling_conventions 0 15 110 125 incoming arg ++ in ++ loc ++ ++let loc_results res = ++ let (loc, _ofs) = ++ calling_conventions 0 15 110 125 not_supported res ++ in ++ loc ++ ++(* C calling convention: ++ first integer args in a0 .. a7 ++ first float args in fa0 .. fa7 ++ remaining args on stack. ++ Return values in a0 .. a1 or fa0 .. fa1. *) ++ ++let external_calling_conventions ++ first_int last_int first_float last_float make_stack arg = ++ let loc = Array.make (Array.length arg) [| Reg.dummy |] in ++ let int = ref first_int in ++ let float = ref first_float in ++ let ofs = ref 0 in ++ for i = 0 to Array.length arg - 1 do ++ match arg.(i) with ++ | [| arg |] -> ++ begin match arg.typ with ++ | Val | Int | Addr as ty -> ++ if !int <= last_int then begin ++ loc.(i) <- [| phys_reg !int |]; ++ incr int; ++ incr float; ++ end else begin ++ loc.(i) <- [| stack_slot (make_stack !ofs) ty |]; ++ ofs := !ofs + size_int ++ end ++ | Float -> ++ if !float <= last_float then begin ++ loc.(i) <- [| phys_reg !float |]; ++ incr float; ++ incr int; ++ end else begin ++ loc.(i) <- [| stack_slot (make_stack !ofs) Float |]; ++ ofs := !ofs + size_float ++ end ++ end ++ | [| arg1; arg2 |] -> ++ (* Passing of 64-bit quantities to external functions on 32-bit ++ platform. *) ++ assert (size_int = 4); ++ begin match arg1.typ, arg2.typ with ++ | Int, Int -> ++ int := Misc.align !int 2; ++ if !int <= last_int - 1 then begin ++ let reg_lower = phys_reg !int in ++ let reg_upper = phys_reg (!int + 1) in ++ loc.(i) <- [| reg_lower; reg_upper |]; ++ int := !int + 2 ++ end else begin ++ let size_int64 = 8 in ++ ofs := Misc.align !ofs size_int64; ++ let ofs_lower = !ofs in ++ let ofs_upper = !ofs + size_int in ++ let stack_lower = stack_slot (make_stack ofs_lower) Int in ++ let stack_upper = stack_slot (make_stack ofs_upper) Int in ++ loc.(i) <- [| stack_lower; stack_upper |]; ++ ofs := !ofs + size_int64 ++ end ++ | _ -> ++ let f = function Int -> "I" | Addr -> "A" | Val -> "V" | Float -> "F" in ++ fatal_error (Printf.sprintf "Proc.calling_conventions: bad register \ ++ type(s) for multi-register argument: %s, %s" ++ (f arg1.typ) (f arg2.typ)) ++ end ++ | _ -> ++ fatal_error "Proc.calling_conventions: bad number of register for \ ++ multi-register argument" ++ done; ++ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned. *) ++ ++let loc_external_arguments arg = ++ external_calling_conventions 0 7 110 117 outgoing arg ++ ++let loc_external_results res = ++ let (loc, _ofs) = ++ external_calling_conventions 0 1 110 111 not_supported (single_regs res) ++ in ++ ensure_single_regs loc ++ ++(* Exceptions are in GPR 3 *) ++ ++let loc_exn_bucket = phys_reg 0 ++ ++(* Volatile registers: none *) ++ ++let regs_are_volatile _ = false ++ ++(* Registers destroyed by operations *) ++ ++let destroyed_at_c_call = ++ Array.of_list(List.map phys_reg ++ [0; 1; 2; 3; 4; 5; 6; 7; 16; 17; 18; 19; 20; (* 21; 22; *) ++ 100; 101; 102; 103; 104; 105; 106; 107; 110; 111; 112; 113; 114; 115; 116; ++ 117; 128; 129; 130; 131]) ++ ++let destroyed_at_oper = function ++ | Iop(Icall_ind _ | Icall_imm _ | Iextcall{alloc = true; _}) -> all_phys_regs ++ | Iop(Iextcall{alloc = false; _}) -> destroyed_at_c_call ++ | _ -> [||] ++ ++let destroyed_at_raise = all_phys_regs ++ ++(* Maximal register pressure *) ++ ++let safe_register_pressure = function ++ | Iextcall _ -> 15 ++ | _ -> 21 ++ ++let max_register_pressure = function ++ | Iextcall _ -> [| 15; 18 |] ++ | _ -> [| 21; 30 |] ++ ++(* Pure operations (without any side effect besides updating their result ++ registers). *) ++ ++let op_is_pure = function ++ | Icall_ind _ | Icall_imm _ | Itailcall_ind _ | Itailcall_imm _ ++ | Iextcall _ | Istackoffset _ | Istore _ | Ialloc _ ++ | Iintop(Icheckbound _) | Iintop_imm(Icheckbound _, _) -> false ++ | Ispecific(Imultaddf _ | Imultsubf _) -> true ++ | _ -> true ++ ++(* Layout of the stack *) ++ ++let num_stack_slots = [| 0; 0 |] ++let contains_calls = ref false ++ ++(* Calling the assembler *) ++ ++let assemble_file infile outfile = ++ Ccomp.command ++ (Config.asm ^ " -o " ^ Filename.quote outfile ^ " " ^ Filename.quote infile) ++ ++let init () = () +diff --git a/asmcomp/riscv/reload.ml b/asmcomp/riscv/reload.ml +new file mode 100644 +index 0000000..85b9703 +--- /dev/null ++++ b/asmcomp/riscv/reload.ml +@@ -0,0 +1,16 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Reloading for the RISC-V *) ++ ++let fundecl f = ++ (new Reloadgen.reload_generic)#fundecl f +diff --git a/asmcomp/riscv/scheduling.ml b/asmcomp/riscv/scheduling.ml +new file mode 100644 +index 0000000..e436be1 +--- /dev/null ++++ b/asmcomp/riscv/scheduling.ml +@@ -0,0 +1,19 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Instruction scheduling for the RISC-V *) ++ ++let _ = let module M = Schedgen in () (* to create a dependency *) ++ ++(* Scheduling is turned off. *) ++ ++let fundecl f = f +diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml +new file mode 100644 +index 0000000..60ec5cb +--- /dev/null ++++ b/asmcomp/riscv/selection.ml +@@ -0,0 +1,85 @@ ++(***********************************************************************) ++(* *) ++(* OCaml *) ++(* *) ++(* Nicolas Ojeda Bar *) ++(* *) ++(* Copyright 2016 Institut National de Recherche en Informatique et *) ++(* en Automatique. All rights reserved. This file is distributed *) ++(* under the terms of the Q Public License version 1.0. *) ++(* *) ++(***********************************************************************) ++ ++(* Instruction selection for the RISC-V processor *) ++ ++open Cmm ++open Arch ++open Mach ++ ++(* Instruction selection *) ++ ++class selector = object (self) ++ ++inherit Selectgen.selector_generic as super ++ ++method is_immediate n = (n <= 0x7FF) && (n >= -0x800) ++ ++method select_addressing _ = function ++ | Cop(Cadda, [arg; Cconst_int n]) when self#is_immediate n -> ++ (Iindexed n, arg) ++ | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int n])]) when self#is_immediate n -> ++ (Iindexed n, Cop(Caddi, [arg1; arg2])) ++ | arg -> ++ (Iindexed 0, arg) ++ ++method! select_operation op args = ++ match (op, args) with ++ (* RISC-V does not support immediate operands for multiply high *) ++ | (Cmulhi, _) -> (Iintop Imulh, args) ++ (* The and, or and xor instructions have a different range of immediate ++ operands than the other instructions *) ++ | (Cand, _) -> self#select_logical Iand args ++ | (Cor, _) -> self#select_logical Ior args ++ | (Cxor, _) -> self#select_logical Ixor args ++ (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) ++ | (Caddf, [Cop(Cmulf, [arg1; arg2]); arg3]) ++ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2])]) -> ++ (Ispecific (Imultaddf false), [arg1; arg2; arg3]) ++ | (Csubf, [Cop(Cmulf, [arg1; arg2]); arg3]) -> ++ (Ispecific (Imultsubf false), [arg1; arg2; arg3]) ++ | (Cnegf, [Cop(Csubf, [Cop(Cmulf, [arg1; arg2]); arg3])]) -> ++ (Ispecific (Imultsubf true), [arg1; arg2; arg3]) ++ | (Cnegf, [Cop(Caddf, [Cop(Cmulf, [arg1; arg2]); arg3])]) -> ++ (Ispecific (Imultaddf true), [arg1; arg2; arg3]) ++ (* RISC-V does not support immediate operands for comparison operators *) ++ | (Ccmpi comp, args) -> (Iintop(Icomp (Isigned comp)), args) ++ | (Ccmpa comp, args) -> (Iintop(Icomp (Iunsigned comp)), args) ++ | (Cmuli, _) -> (Iintop Imul, args) ++ | _ -> ++ super#select_operation op args ++ ++method select_logical op = function ++ | [arg; Cconst_int n] when n >= 0 && n <= 0xFFF -> ++ (Iintop_imm(op, n), [arg]) ++ | [Cconst_int n; arg] when n >= 0 && n <= 0xFFF -> ++ (Iintop_imm(op, n), [arg]) ++ | args -> ++ (Iintop op, args) ++ ++(* Instruction selection for conditionals *) ++ ++method! select_condition = function ++ | Cop(Ccmpi cmp, args) -> ++ (Iinttest(Isigned cmp), Ctuple args) ++ | Cop(Ccmpa cmp, args) -> ++ (Iinttest(Iunsigned cmp), Ctuple args) ++ | Cop(Ccmpf cmp, args) -> ++ (Ifloattest(cmp, false), Ctuple args) ++ | Cop(Cand, [arg; Cconst_int 1]) -> ++ (Ioddtest, arg) ++ | arg -> ++ (Itruetest, arg) ++ ++end ++ ++let fundecl f = (new selector)#emit_fundecl f +diff --git a/asmrun/riscv.S b/asmrun/riscv.S +new file mode 100644 +index 0000000..a82048e +--- /dev/null ++++ b/asmrun/riscv.S +@@ -0,0 +1,424 @@ ++/***********************************************************************/ ++/* */ ++/* OCaml */ ++/* */ ++/* Nicolas Ojeda Bar */ ++/* */ ++/* 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, with */ ++/* the special exception on linking described in file ../LICENSE. */ ++/* */ ++/***********************************************************************/ ++ ++/* Asm part of the runtime system, RISC-V processor, 64-bit mode */ ++/* Must be preprocessed by cpp */ ++ ++#define TRAP_PTR s1 ++#define ALLOC_PTR s10 ++#define ALLOC_LIMIT s11 ++#define TMP0 t0 ++#define TMP1 t1 ++#define ARG t2 ++ ++#if defined(MODEL_riscv64) ++#define store sd ++#define load ld ++#define WSZ 8 ++#else ++#define store sw ++#define load lw ++#define WSZ 4 ++#endif ++ ++#if defined(__PIC__) ++ .option pic ++#else ++ .option nopic ++#endif ++ ++ .section .text ++/* Invoke the garbage collector. */ ++ ++ .globl caml_system__code_begin ++caml_system__code_begin: ++ ++ .align 2 ++ .globl caml_call_gc ++ .type caml_call_gc, @function ++caml_call_gc: ++ /* Record return address */ ++ store ra, caml_last_return_address, TMP0 ++ /* Record lowest stack address */ ++ mv TMP1, sp ++ store sp, caml_bottom_of_stack, TMP0 ++.Lcaml_call_gc: ++ /* Set up stack space, saving return address */ ++ /* (1 reg for RA, 1 reg for FP, 21 allocatable int regs, 20 caller-save float regs) * 8 */ ++ /* + 1 for alignment */ ++ addi sp, sp, -0x160 ++ mv s0, sp ++ store ra, 0x8(sp) ++ store s0, 0x0(sp) ++ /* Save allocatable integer registers on the stack, ++ in the order given in proc.ml */ ++ store a0, 0x10(sp) ++ store a1, 0x18(sp) ++ store a2, 0x20(sp) ++ store a3, 0x28(sp) ++ store a4, 0x30(sp) ++ store a5, 0x38(sp) ++ store a6, 0x40(sp) ++ store a7, 0x48(sp) ++ store s2, 0x50(sp) ++ store s3, 0x58(sp) ++ store s4, 0x60(sp) ++ store s5, 0x68(sp) ++ store s6, 0x70(sp) ++ store s7, 0x78(sp) ++ store s8, 0x80(sp) ++ store s9, 0x88(sp) ++ store t2, 0x90(sp) ++ store t3, 0x98(sp) ++ store t4, 0xa0(sp) ++ store t5, 0xa8(sp) ++ store t6, 0xb0(sp) ++ /* Save caller-save floating-point registers on the stack ++ (callee-saves are preserved by caml_garbage_collection) */ ++ fsd ft0, 0xb8(sp) ++ fsd ft1, 0xc0(sp) ++ fsd ft2, 0xc8(sp) ++ fsd ft3, 0xd0(sp) ++ fsd ft4, 0xd8(sp) ++ fsd ft5, 0xe0(sp) ++ fsd ft6, 0xe8(sp) ++ fsd ft7, 0xf0(sp) ++ fsd fa0, 0xf8(sp) ++ fsd fa1, 0x100(sp) ++ fsd fa2, 0x108(sp) ++ fsd fa3, 0x110(sp) ++ fsd fa4, 0x118(sp) ++ fsd fa5, 0x120(sp) ++ fsd fa6, 0x128(sp) ++ fsd fa7, 0x130(sp) ++ fsd ft8, 0x138(sp) ++ fsd ft9, 0x140(sp) ++ fsd ft9, 0x148(sp) ++ fsd ft10, 0x150(sp) ++ fsd ft11, 0x158(sp) ++ /* Store pointer to saved integer registers in caml_gc_regs */ ++ addi TMP1, sp, 16 ++ store TMP1, caml_gc_regs, TMP0 ++ /* Save current allocation pointer for debugging purposes */ ++ store ALLOC_PTR, caml_young_ptr, TMP0 ++ /* Save trap pointer in case an exception is raised during GC */ ++ store TRAP_PTR, caml_exception_pointer, TMP0 ++ /* Call the garbage collector */ ++ call caml_garbage_collection ++ /* Restore registers */ ++ load a0, 0x10(sp) ++ load a1, 0x18(sp) ++ load a2, 0x20(sp) ++ load a3, 0x28(sp) ++ load a4, 0x30(sp) ++ load a5, 0x38(sp) ++ load a6, 0x40(sp) ++ load a7, 0x48(sp) ++ load s2, 0x50(sp) ++ load s3, 0x58(sp) ++ load s4, 0x60(sp) ++ load s5, 0x68(sp) ++ load s6, 0x70(sp) ++ load s7, 0x78(sp) ++ load s8, 0x80(sp) ++ load s9, 0x88(sp) ++ load t2, 0x90(sp) ++ load t3, 0x98(sp) ++ load t4, 0xa0(sp) ++ load t5, 0xa8(sp) ++ load t6, 0xb0(sp) ++ fld ft0, 0xb8(sp) ++ fld ft1, 0xc0(sp) ++ fld ft2, 0xc8(sp) ++ fld ft3, 0xd0(sp) ++ fld ft4, 0xd8(sp) ++ fld ft5, 0xe0(sp) ++ fld ft6, 0xe8(sp) ++ fld ft7, 0xf0(sp) ++ fld fa0, 0xf8(sp) ++ fld fa1, 0x100(sp) ++ fld fa2, 0x108(sp) ++ fld fa3, 0x110(sp) ++ fld fa4, 0x118(sp) ++ fld fa5, 0x120(sp) ++ fld fa6, 0x128(sp) ++ fld fa7, 0x130(sp) ++ fld ft8, 0x138(sp) ++ fld ft9, 0x140(sp) ++ fld ft9, 0x148(sp) ++ fld ft10, 0x150(sp) ++ fld ft11, 0x158(sp) ++ /* Reload new allocation pointer and allocation limit */ ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ /* Free stack space and return to caller */ ++ load ra, 0x8(sp) ++ load s0, 0x0(sp) ++ addi sp, sp, 0x160 ++ ret ++ .size caml_call_gc, .-caml_call_gc ++ ++/* Call a C function from OCaml */ ++/* Function to call is in ARG */ ++ ++ .align 2 ++ .globl caml_c_call ++ .type caml_c_call, @function ++caml_c_call: ++ /* Preserve return address in callee-save register s2 */ ++ mv s2, ra ++ /* Record lowest stack address and return address */ ++ store ra, caml_last_return_address, TMP0 ++ store sp, caml_bottom_of_stack, TMP0 ++ /* Make the exception handler alloc ptr available to the C code */ ++ store ALLOC_PTR, caml_young_ptr, TMP0 ++ store TRAP_PTR, caml_exception_pointer, TMP0 ++ /* Call the function */ ++ jalr ARG ++ /* Reload alloc ptr and alloc limit */ ++ load ALLOC_PTR, caml_young_ptr ++ load TRAP_PTR, caml_exception_pointer ++ /* Return */ ++ jr s2 ++ .size caml_c_call, .-caml_c_call ++ ++/* Raise an exception from OCaml */ ++ .align 2 ++ .globl caml_raise_exn ++ .type caml_raise_exn, @function ++caml_raise_exn: ++ /* Test if backtrace is active */ ++ load TMP1, caml_backtrace_active ++ bnez TMP1, 2f ++1: /* Cut stack at current trap handler */ ++ mv sp, TRAP_PTR ++ /* Pop previous handler and jump to it */ ++ load TMP1, 8(sp) ++ load TRAP_PTR, 0(sp) ++ addi sp, sp, 16 ++ jr TMP1 ++2: /* Preserve exception bucket in callee-save register s2 */ ++ mv s2, a0 ++ /* Stash the backtrace */ ++ mv a1, ra ++ mv a2, sp ++ mv a3, TRAP_PTR ++ call caml_stash_backtrace ++ /* Restore exception bucket and raise */ ++ mv a0, s2 ++ j 1b ++ .size caml_raise_exn, .-caml_raise_exn ++ ++ .globl caml_reraise_exn ++ .type caml_reraise_exn, @function ++ ++/* Raise an exception from C */ ++ ++ .align 2 ++ .globl caml_raise_exception ++ .type caml_raise_exception, @function ++caml_raise_exception: ++ load TRAP_PTR, caml_exception_pointer ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ load TMP1, caml_backtrace_active ++ bnez TMP1, 2f ++1: /* Cut stack at current trap handler */ ++ mv sp, TRAP_PTR ++ load TMP1, 8(sp) ++ load TRAP_PTR, 0(sp) ++ addi sp, sp, 16 ++ jr TMP1 ++2: /* Preserve exception bucket in callee-save register s2 */ ++ mv s2, a0 ++ load a1, caml_last_return_address ++ load a2, caml_bottom_of_stack ++ mv a3, TRAP_PTR ++ call caml_stash_backtrace ++ mv a0, s2 ++ j 1b ++ .size caml_raise_exception, .-caml_raise_exception ++ ++/* Start the OCaml program */ ++ ++ .align 2 ++ .globl caml_start_program ++ .type caml_start_program, @function ++caml_start_program: ++ ++ la ARG, caml_program ++ /* Code shared with caml_callback* */ ++ /* Address of OCaml code to call is in ARG */ ++ /* Arguments to the OCaml code are in a0 ... a7 */ ++.Ljump_to_caml: ++ /* Set up stack frame and save callee-save registers */ ++ addi sp, sp, -0xd0 ++ store ra, 0xc0(sp) ++ store s0, 0x0(sp) ++ store s1, 0x8(sp) ++ store s2, 0x10(sp) ++ store s3, 0x18(sp) ++ store s4, 0x20(sp) ++ store s5, 0x28(sp) ++ store s6, 0x30(sp) ++ store s7, 0x38(sp) ++ store s8, 0x40(sp) ++ store s9, 0x48(sp) ++ store s10, 0x50(sp) ++ store s11, 0x58(sp) ++ fsd fs0, 0x60(sp) ++ fsd fs1, 0x68(sp) ++ fsd fs2, 0x70(sp) ++ fsd fs3, 0x78(sp) ++ fsd fs4, 0x80(sp) ++ fsd fs5, 0x88(sp) ++ fsd fs6, 0x90(sp) ++ fsd fs7, 0x98(sp) ++ fsd fs8, 0xa0(sp) ++ fsd fs9, 0xa8(sp) ++ fsd fs10, 0xb0(sp) ++ fsd fs11, 0xb8(sp) ++ addi sp, sp, -32 ++ /* Setup a callback link on the stack */ ++ load TMP1, caml_bottom_of_stack ++ store TMP1, 0(sp) ++ load TMP1, caml_last_return_address ++ store TMP1, 8(sp) ++ load TMP1, caml_gc_regs ++ store TMP1, 16(sp) ++ /* set up a trap frame */ ++ addi sp, sp, -16 ++ load TMP1, caml_exception_pointer ++ store TMP1, 0(sp) ++ lla TMP0, .Ltrap_handler ++ store TMP0, 8(sp) ++ mv TRAP_PTR, sp ++ load ALLOC_PTR, caml_young_ptr ++ load ALLOC_LIMIT, caml_young_limit ++ store x0, caml_last_return_address, TMP0 ++ jalr ARG ++.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ ++ load TMP1, 0(sp) ++ store TMP1, caml_exception_pointer, TMP0 ++ addi sp, sp, 16 ++.Lreturn_result: /* pop callback link, restoring global variables */ ++ load TMP1, 0(sp) ++ store TMP1, caml_bottom_of_stack, TMP0 ++ load TMP1, 8(sp) ++ store TMP1, caml_last_return_address, TMP0 ++ load TMP1, 16(sp) ++ store TMP1, caml_gc_regs, TMP0 ++ addi sp, sp, 32 ++ /* Update allocation pointer */ ++ store ALLOC_PTR, caml_young_ptr, TMP0 ++ /* reload callee-save registers and return */ ++ load ra, 0xc0(sp) ++ load s0, 0x0(sp) ++ load s1, 0x8(sp) ++ load s2, 0x10(sp) ++ load s3, 0x18(sp) ++ load s4, 0x20(sp) ++ load s5, 0x28(sp) ++ load s6, 0x30(sp) ++ load s7, 0x38(sp) ++ load s8, 0x40(sp) ++ load s9, 0x48(sp) ++ load s10, 0x50(sp) ++ load s11, 0x58(sp) ++ fld fs0, 0x60(sp) ++ fld fs1, 0x68(sp) ++ fld fs2, 0x70(sp) ++ fld fs3, 0x78(sp) ++ fld fs4, 0x80(sp) ++ fld fs5, 0x88(sp) ++ fld fs6, 0x90(sp) ++ fld fs7, 0x98(sp) ++ fld fs8, 0xa0(sp) ++ fld fs9, 0xa8(sp) ++ fld fs10, 0xb0(sp) ++ fld fs11, 0xb8(sp) ++ addi sp, sp, 0xd0 ++ ret ++.Ltrap_handler: ++ store TRAP_PTR, caml_exception_pointer, TMP0 ++ ori a0, a0, 2 ++ j .Lreturn_result ++ .size caml_start_program, .-caml_start_program ++ ++/* Callback from C to OCaml */ ++ ++ .align 2 ++ .globl caml_callback_exn ++ .type caml_callback_exn, @function ++caml_callback_exn: ++ /* Initial shuffling of arguments (a0 = closure, a1 = first arg) */ ++ mv TMP1, a0 ++ mv a0, a1 /* a0 = first arg */ ++ mv a1, TMP1 /* a1 = closure environment */ ++ load ARG, 0(TMP1) /* code pointer */ ++ j .Ljump_to_caml ++ .size caml_callback_exn, .-caml_callback_exn ++ ++ .align 2 ++ .globl caml_callback2_exn ++ .type caml_callback2_exn, @function ++caml_callback2_exn: ++ /* Initial shuffling of arguments (a0 = closure, a1 = arg1, a2 = arg2) */ ++ mv TMP1, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, TMP1 ++ la ARG, caml_apply2 ++ j .Ljump_to_caml ++ .size caml_callback2_exn, .-caml_callback2_exn ++ ++ .align 2 ++ .globl caml_callback3_exn ++ .type caml_callback3_exn, @function ++caml_callback3_exn: ++ /* Initial shuffling of argumnets */ ++ /* (a0 = closure, a1 = arg1, a2 = arg2, a3 = arg3) */ ++ mv TMP1, a0 ++ mv a0, a1 ++ mv a1, a2 ++ mv a2, a3 ++ mv a3, TMP1 ++ la ARG, caml_apply3 ++ j .Ljump_to_caml ++ .size caml_callback3_exn, .-caml_callback3_exn ++ ++ .align 2 ++ .globl caml_ml_array_bound_error ++ .type caml_ml_array_bound_error, @function ++caml_ml_array_bound_error: ++ /* Load address of [caml_array_bound_error] in ARG */ ++ la ARG, caml_array_bound_error ++ /* Call that function */ ++ j caml_c_call ++ ++ .globl caml_system__code_end ++caml_system__code_end: ++ ++/* GC roots for callback */ ++ ++ .section .data ++ .align 3 ++ .globl caml_system__frametable ++ .type caml_system__frametable, @object ++caml_system__frametable: ++ .quad 1 /* one descriptor */ ++ .quad .Lcaml_retaddr /* return address into callback */ ++ .short -1 /* negative frame size => use callback link */ ++ .short 0 /* no roots */ ++ .align 3 ++ .size caml_system__frametable, .-caml_system__frametable +diff --git a/byterun/caml/stack.h b/byterun/caml/stack.h +index fd9d528..781c251 100644 +--- a/byterun/caml/stack.h ++++ b/byterun/caml/stack.h +@@ -75,6 +75,11 @@ + #define Callback_link(sp) ((struct caml_context *)((sp) + 16)) + #endif + ++#ifdef TARGET_riscv /* FIXME FIXME */ ++#define Saved_return_address(sp) *((intnat *)((sp) - 8)) ++#define Callback_link(sp) ((struct caml_context *)((sp) + 16)) ++#endif ++ + /* Structure of OCaml callback contexts */ + + struct caml_context { +diff --git a/configure b/configure +index 41c9315..eb3e1f3 100755 +--- a/configure ++++ b/configure +@@ -819,6 +819,7 @@ if test $with_sharedlibs = "yes"; then + arm*-*-freebsd*) natdynlink=true;; + earm*-*-netbsd*) natdynlink=true;; + aarch64-*-linux*) natdynlink=true;; ++ riscv*-*-linux*) natdynlink=true;; + esac + fi + +@@ -888,6 +889,8 @@ case "$target" in + x86_64-*-mingw*) arch=amd64; system=mingw;; + aarch64-*-linux*) arch=arm64; system=linux;; + x86_64-*-cygwin*) arch=amd64; system=cygwin;; ++ riscv32-*-linux*) arch=riscv; model=riscv32; system=linux;; ++ riscv64-*-linux*) arch=riscv; model=riscv64; system=linux;; + esac + + # Some platforms exist both in 32-bit and 64-bit variants, not distinguished +@@ -963,7 +966,7 @@ case "$arch,$system" in + aspp="${TOOLPREF}cc -c";; + *,freebsd) as="${TOOLPREF}as" + aspp="${TOOLPREF}cc -c";; +- amd64,*|arm,*|arm64,*|i386,*|power,bsd*|sparc,*) ++ amd64,*|arm,*|arm64,*|i386,*|power,bsd*|sparc,*|riscv,*) + as="${TOOLPREF}as" + aspp="${TOOLPREF}gcc -c";; + esac +-- +2.9.3 diff --git a/programming/language/ocaml/ocaml/files/fedora/0008-Try-fix-for-andi-ori-xori-immediates-1.patch b/programming/language/ocaml/ocaml/files/fedora/0008-Try-fix-for-andi-ori-xori-immediates-1.patch new file mode 100644 index 0000000000..459c8efa96 --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0008-Try-fix-for-andi-ori-xori-immediates-1.patch @@ -0,0 +1,42 @@ +From f1be77d69e28ad3bd128c6c757d966e90bbf73d3 Mon Sep 17 00:00:00 2001 +From: Nicolas Ojeda Bar +Date: Thu, 10 Nov 2016 14:12:53 +0100 +Subject: [PATCH 08/10] Try fix for andi/ori/xori immediates (#1) + +--- + asmcomp/riscv/selection.ml | 13 ------------- + 1 file changed, 13 deletions(-) + +diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml +index 60ec5cb..ad2b26e 100644 +--- a/asmcomp/riscv/selection.ml ++++ b/asmcomp/riscv/selection.ml +@@ -36,11 +36,6 @@ method! select_operation op args = + match (op, args) with + (* RISC-V does not support immediate operands for multiply high *) + | (Cmulhi, _) -> (Iintop Imulh, args) +- (* The and, or and xor instructions have a different range of immediate +- operands than the other instructions *) +- | (Cand, _) -> self#select_logical Iand args +- | (Cor, _) -> self#select_logical Ior args +- | (Cxor, _) -> self#select_logical Ixor args + (* Recognize (neg-)mult-add and (neg-)mult-sub instructions *) + | (Caddf, [Cop(Cmulf, [arg1; arg2]); arg3]) + | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2])]) -> +@@ -58,14 +53,6 @@ method! select_operation op args = + | _ -> + super#select_operation op args + +-method select_logical op = function +- | [arg; Cconst_int n] when n >= 0 && n <= 0xFFF -> +- (Iintop_imm(op, n), [arg]) +- | [Cconst_int n; arg] when n >= 0 && n <= 0xFFF -> +- (Iintop_imm(op, n), [arg]) +- | args -> +- (Iintop op, args) +- + (* Instruction selection for conditionals *) + + method! select_condition = function +-- +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0009-Fix-immediates-range-when-adjusting-indexing-sp.patch b/programming/language/ocaml/ocaml/files/fedora/0009-Fix-immediates-range-when-adjusting-indexing-sp.patch new file mode 100644 index 0000000000..c328abf09d --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0009-Fix-immediates-range-when-adjusting-indexing-sp.patch @@ -0,0 +1,155 @@ +From b81417ea168c3cf9454eeb41f1f723b66b3210aa Mon Sep 17 00:00:00 2001 +From: Nicolas Ojeda Bar +Date: Tue, 22 Nov 2016 22:30:35 +0100 +Subject: [PATCH 09/10] Fix immediates' range when adjusting/indexing sp + +--- + asmcomp/riscv/arch.ml | 3 +++ + asmcomp/riscv/emit.mlp | 53 ++++++++++++++++++++++++++++++++++------------ + asmcomp/riscv/selection.ml | 2 +- + 3 files changed, 44 insertions(+), 14 deletions(-) + +diff --git a/asmcomp/riscv/arch.ml b/asmcomp/riscv/arch.ml +index 61a38b1..22c807c 100644 +--- a/asmcomp/riscv/arch.ml ++++ b/asmcomp/riscv/arch.ml +@@ -32,6 +32,9 @@ let spacetime_node_hole_pointer_is_live_before = function + type addressing_mode = + | Iindexed of int (* reg + displ *) + ++let is_immediate n = ++ (n <= 2047) && (n >= -2048) ++ + (* Sizes, endianness *) + + let big_endian = false +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +index 6d0e3ae..97c49ce 100644 +--- a/asmcomp/riscv/emit.mlp ++++ b/asmcomp/riscv/emit.mlp +@@ -93,6 +93,34 @@ let emit_stack r = + let ofs = slot_offset s (register_class r) in `{emit_int ofs}(sp)` + | _ -> fatal_error "Emit.emit_stack" + ++(* Adjust sp by the given byte amount *) ++ ++let emit_stack_adjustment = function ++ | 0 -> () ++ | n when is_immediate n -> ++ ` addi sp, sp, {emit_int n}\n` ++ | n -> ++ ` li {emit_reg reg_tmp1}, {emit_int n}\n`; ++ ` add sp, sp, {emit_reg reg_tmp1}\n` ++ ++let emit_store src ofs = ++ if is_immediate ofs then ++ ` {emit_string stg} {emit_reg src}, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string stg} {emit_reg src}, 0({emit_reg reg_tmp1})\n` ++ end ++ ++let emit_load dst ofs = ++ if is_immediate ofs then ++ ` {emit_string lg} {emit_reg dst}, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string lg} {emit_reg dst}, 0({emit_reg reg_tmp1})\n` ++ end ++ + (* Record live pointers at call points *) + + let record_frame_label ?label live raise_ dbg = +@@ -218,6 +246,7 @@ let name_for_specific = function + + (* Name of current function *) + let function_name = ref "" ++ + (* Entry point for tail recursive calls *) + let tailrec_entry_point = ref 0 + +@@ -234,12 +263,14 @@ let emit_instr i = + ` mv {emit_reg dst}, {emit_reg src}\n` + | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} -> + ` fmv.d {emit_reg dst}, {emit_reg src}\n` +- | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack _} -> +- ` {emit_string stg} {emit_reg src}, {emit_stack dst}\n` ++ | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> ++ let ofs = slot_offset s (register_class dst) in ++ emit_store src ofs + | {loc = Reg _; typ = Float}, {loc = Stack _} -> + ` fsd {emit_reg src}, {emit_stack dst}\n` +- | {loc = Stack _; typ = (Val | Int | Addr)}, {loc = Reg _ } -> +- ` {emit_string lg} {emit_reg dst}, {emit_stack src}\n` ++ | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> ++ let ofs = slot_offset s (register_class src) in ++ emit_load dst ofs + | {loc = Stack _; typ = Float}, {loc = Reg _} -> + ` fld {emit_reg dst}, {emit_stack src}\n` + | _ -> +@@ -263,8 +294,7 @@ let emit_instr i = + let n = frame_size() in + if !contains_calls then + ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n`; +- if n > 0 then +- ` addi sp, sp, {emit_int n}\n`; ++ emit_stack_adjustment n; + ` jr {emit_reg i.arg.(0)}\n` + | Lop(Itailcall_imm {func; label_after = _}) -> + if func = !function_name then begin +@@ -273,8 +303,7 @@ let emit_instr i = + let n = frame_size() in + if !contains_calls then + ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n`; +- if n > 0 then +- ` addi sp, sp, {emit_int n}\n`; ++ emit_stack_adjustment n; + ` tail {emit_symbol func}\n` + end + | Lop(Iextcall{func; alloc = true; label_after = label}) -> +@@ -285,7 +314,7 @@ let emit_instr i = + ` call {emit_symbol func}\n` + | Lop(Istackoffset n) -> + assert (n mod 16 = 0); +- ` addi sp, sp, {emit_int (-n)}\n`; ++ emit_stack_adjustment (-n); + stack_offset := !stack_offset + n + | Lop(Iload(Single, Iindexed ofs)) -> + ` flw {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`; +@@ -398,8 +427,7 @@ let emit_instr i = + ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n` + | Lreturn -> + let n = frame_size() in +- if n > 0 then +- ` addi sp, sp, {emit_int n}\n`; ++ emit_stack_adjustment n; + ` ret\n` + | Llabel lbl -> + `{emit_label lbl}:\n` +@@ -513,8 +541,7 @@ let fundecl fundecl = + ` .align 2\n`; + `{emit_symbol fundecl.fun_name}:\n`; + let n = frame_size() in +- if n > 0 then +- ` addi sp, sp, {emit_int(-n)}\n`; ++ emit_stack_adjustment (-n); + if !contains_calls then + ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n`; + `{emit_label !tailrec_entry_point}:\n`; +diff --git a/asmcomp/riscv/selection.ml b/asmcomp/riscv/selection.ml +index ad2b26e..2832336 100644 +--- a/asmcomp/riscv/selection.ml ++++ b/asmcomp/riscv/selection.ml +@@ -22,7 +22,7 @@ class selector = object (self) + + inherit Selectgen.selector_generic as super + +-method is_immediate n = (n <= 0x7FF) && (n >= -0x800) ++method is_immediate n = is_immediate n + + method select_addressing _ = function + | Cop(Cadda, [arg; Cconst_int n]) when self#is_immediate n -> +-- +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0009-arg-Add-no_arg-and-get_arg-helper-functions.patch b/programming/language/ocaml/ocaml/files/fedora/0009-arg-Add-no_arg-and-get_arg-helper-functions.patch deleted file mode 100644 index 3dbebc987d..0000000000 --- a/programming/language/ocaml/ocaml/files/fedora/0009-arg-Add-no_arg-and-get_arg-helper-functions.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 0641f11626be99c8bde349520ac28a8d93106856 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 1 Apr 2014 11:17:07 +0100 -Subject: [PATCH 09/12] arg: Add no_arg and get_arg helper functions. - -The no_arg function in this patch is a no-op. It will do something -useful in the followups. - -The get_arg function simply checks the next position on the command -line exists and returns that argument or raises a Arg.Missing. - -This patch should introduce no functional change, it is simply code -refactoring. - -In particular, this should not change the treatment of Arg.current -(see: http://caml.inria.fr/mantis/view.php?id=5197#c11147) ---- - stdlib/arg.ml | 47 ++++++++++++++++++++++++++--------------------- - 1 file changed, 26 insertions(+), 21 deletions(-) - -diff --git a/stdlib/arg.ml b/stdlib/arg.ml -index 0f6480b..a41e0a2 100644 ---- a/stdlib/arg.ml -+++ b/stdlib/arg.ml -@@ -134,56 +134,62 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg = - try assoc3 s !speclist - with Not_found -> stop (Unknown s) - in -+ let no_arg () = () in -+ let get_arg () = -+ if !current + 1 < l then argv.(!current + 1) -+ else stop (Missing s) -+ in - begin try - let rec treat_action = function -- | Unit f -> f (); -- | Bool f when !current + 1 < l -> -- let arg = argv.(!current + 1) in -+ | Unit f -> no_arg (); f (); -+ | Bool f -> -+ let arg = get_arg () in - begin try f (bool_of_string arg) - with Invalid_argument "bool_of_string" -> - raise (Stop (Wrong (s, arg, "a boolean"))) - end; - incr current; -- | Set r -> r := true; -- | Clear r -> r := false; -- | String f when !current + 1 < l -> -- f argv.(!current + 1); -+ | Set r -> no_arg (); r := true; -+ | Clear r -> no_arg (); r := false; -+ | String f -> -+ let arg = get_arg () in -+ f arg; - incr current; -- | Symbol (symb, f) when !current + 1 < l -> -- let arg = argv.(!current + 1) in -+ | Symbol (symb, f) -> -+ let arg = get_arg () in - if List.mem arg symb then begin -- f argv.(!current + 1); -+ f arg; - incr current; - end else begin - raise (Stop (Wrong (s, arg, "one of: " - ^ (make_symlist "" " " "" symb)))) - end -- | Set_string r when !current + 1 < l -> -- r := argv.(!current + 1); -+ | Set_string r -> -+ r := get_arg (); - incr current; -- | Int f when !current + 1 < l -> -- let arg = argv.(!current + 1) in -+ | Int f -> -+ let arg = get_arg () in - begin try f (int_of_string arg) - with Failure "int_of_string" -> - raise (Stop (Wrong (s, arg, "an integer"))) - end; - incr current; -- | Set_int r when !current + 1 < l -> -- let arg = argv.(!current + 1) in -+ | Set_int r -> -+ let arg = get_arg () in - begin try r := (int_of_string arg) - with Failure "int_of_string" -> - raise (Stop (Wrong (s, arg, "an integer"))) - end; - incr current; -- | Float f when !current + 1 < l -> -- let arg = argv.(!current + 1) in -+ | Float f -> -+ let arg = get_arg () in - begin try f (float_of_string arg); - with Failure "float_of_string" -> - raise (Stop (Wrong (s, arg, "a float"))) - end; - incr current; -- | Set_float r when !current + 1 < l -> -- let arg = argv.(!current + 1) in -+ | Set_float r -> -+ let arg = get_arg () in - begin try r := (float_of_string arg); - with Failure "float_of_string" -> - raise (Stop (Wrong (s, arg, "a float"))) -@@ -196,7 +202,6 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg = - f argv.(!current + 1); - incr current; - done; -- | _ -> raise (Stop (Missing s)) - in - treat_action action - with Bad m -> stop (Message m); --- -2.0.4 - diff --git a/programming/language/ocaml/ocaml/files/fedora/0010-Another-immediate-range-fix.patch b/programming/language/ocaml/ocaml/files/fedora/0010-Another-immediate-range-fix.patch new file mode 100644 index 0000000000..4930a5ab66 --- /dev/null +++ b/programming/language/ocaml/ocaml/files/fedora/0010-Another-immediate-range-fix.patch @@ -0,0 +1,130 @@ +From ab30529b723d451fd0ea8ac64d24fc417af55541 Mon Sep 17 00:00:00 2001 +From: Nicolas Ojeda Bar +Date: Wed, 23 Nov 2016 12:38:28 +0100 +Subject: [PATCH 10/10] Another immediate range fix + +--- + asmcomp/riscv/emit.mlp | 57 ++++++++++++++++++++++++++++++-------------------- + 1 file changed, 34 insertions(+), 23 deletions(-) + +diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp +index 97c49ce..6cc1908 100644 +--- a/asmcomp/riscv/emit.mlp ++++ b/asmcomp/riscv/emit.mlp +@@ -85,14 +85,6 @@ let emit_reg = function + | {loc = Reg r} -> emit_string (register_name r) + | _ -> fatal_error "Emit.emit_reg" + +-(* Output a stack reference *) +- +-let emit_stack r = +- match r.loc with +- Stack s -> +- let ofs = slot_offset s (register_class r) in `{emit_int ofs}(sp)` +- | _ -> fatal_error "Emit.emit_stack" +- + (* Adjust sp by the given byte amount *) + + let emit_stack_adjustment = function +@@ -103,7 +95,27 @@ let emit_stack_adjustment = function + ` li {emit_reg reg_tmp1}, {emit_int n}\n`; + ` add sp, sp, {emit_reg reg_tmp1}\n` + +-let emit_store src ofs = ++let reload_ra n = ++ let ofs = n - size_addr in ++ if is_immediate ofs then ++ ` {emit_string lg} ra, {emit_int ofs}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string lg} ra, 0({emit_reg reg_tmp1})\n` ++ end ++ ++let store_ra n = ++ let ofs = n - size_addr in ++ if is_immediate ofs then ++ ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n` ++ else begin ++ ` li {emit_reg reg_tmp1}, {emit_int ofs}\n`; ++ ` add {emit_reg reg_tmp1}, sp, {emit_reg reg_tmp1}\n`; ++ ` {emit_string stg} ra, 0({emit_reg reg_tmp1})\n` ++ end ++ ++let emit_store stg src ofs = + if is_immediate ofs then + ` {emit_string stg} {emit_reg src}, {emit_int ofs}(sp)\n` + else begin +@@ -112,7 +124,7 @@ let emit_store src ofs = + ` {emit_string stg} {emit_reg src}, 0({emit_reg reg_tmp1})\n` + end + +-let emit_load dst ofs = ++let emit_load lg dst ofs = + if is_immediate ofs then + ` {emit_string lg} {emit_reg dst}, {emit_int ofs}(sp)\n` + else begin +@@ -265,14 +277,16 @@ let emit_instr i = + ` fmv.d {emit_reg dst}, {emit_reg src}\n` + | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} -> + let ofs = slot_offset s (register_class dst) in +- emit_store src ofs +- | {loc = Reg _; typ = Float}, {loc = Stack _} -> +- ` fsd {emit_reg src}, {emit_stack dst}\n` ++ emit_store stg src ofs ++ | {loc = Reg _; typ = Float}, {loc = Stack s} -> ++ let ofs = slot_offset s (register_class dst) in ++ emit_store "fsd" src ofs + | {loc = Stack s; typ = (Val | Int | Addr)}, {loc = Reg _} -> + let ofs = slot_offset s (register_class src) in +- emit_load dst ofs +- | {loc = Stack _; typ = Float}, {loc = Reg _} -> +- ` fld {emit_reg dst}, {emit_stack src}\n` ++ emit_load lg dst ofs ++ | {loc = Stack s; typ = Float}, {loc = Reg _} -> ++ let ofs = slot_offset s (register_class src) in ++ emit_load "fld" dst ofs + | _ -> + fatal_error "Emit: Imove" + end +@@ -292,8 +306,7 @@ let emit_instr i = + record_frame ~label i.live false i.dbg + | Lop(Itailcall_ind {label_after = _}) -> + let n = frame_size() in +- if !contains_calls then +- ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n`; ++ if !contains_calls then reload_ra n; + emit_stack_adjustment n; + ` jr {emit_reg i.arg.(0)}\n` + | Lop(Itailcall_imm {func; label_after = _}) -> +@@ -301,8 +314,7 @@ let emit_instr i = + ` j {emit_label !tailrec_entry_point}\n` + end else begin + let n = frame_size() in +- if !contains_calls then +- ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n`; ++ if !contains_calls then reload_ra n; + emit_stack_adjustment n; + ` tail {emit_symbol func}\n` + end +@@ -424,7 +436,7 @@ let emit_instr i = + ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` + | Lreloadretaddr -> + let n = frame_size () in +- ` {emit_string lg} ra, {emit_int(n - size_addr)}(sp)\n` ++ reload_ra n + | Lreturn -> + let n = frame_size() in + emit_stack_adjustment n; +@@ -542,8 +554,7 @@ let fundecl fundecl = + `{emit_symbol fundecl.fun_name}:\n`; + let n = frame_size() in + emit_stack_adjustment (-n); +- if !contains_calls then +- ` {emit_string stg} ra, {emit_int(n - size_addr)}(sp)\n`; ++ if !contains_calls then store_ra n; + `{emit_label !tailrec_entry_point}:\n`; + emit_all fundecl.fun_body; + List.iter emit_call_gc !call_gc_sites; +-- +2.9.3 \ No newline at end of file diff --git a/programming/language/ocaml/ocaml/files/fedora/0010-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch b/programming/language/ocaml/ocaml/files/fedora/0010-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch deleted file mode 100644 index d9f7fc9bc1..0000000000 --- a/programming/language/ocaml/ocaml/files/fedora/0010-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 4d1defe6f017b86b0766fd02005a468bedd9aa88 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 1 Apr 2014 11:21:40 +0100 -Subject: [PATCH 10/12] arg: Allow flags such as --flag=arg as well as --flag - arg. - -Allow flags to be followed directly by their argument, separated by an '=' -sign. This is consistent with what GNU getopt_long and many other -command line parsing libraries allow. - -Fix for the following issue: -http://caml.inria.fr/mantis/view.php?id=5197 ---- - stdlib/arg.ml | 30 ++++++++++++++++++++++++------ - stdlib/arg.mli | 3 ++- - 2 files changed, 26 insertions(+), 7 deletions(-) - -diff --git a/stdlib/arg.ml b/stdlib/arg.ml -index a41e0a2..5ffdabc 100644 ---- a/stdlib/arg.ml -+++ b/stdlib/arg.ml -@@ -55,6 +55,12 @@ let rec assoc3 x l = - | _ :: t -> assoc3 x t - ;; - -+let split s = -+ let i = String.index s '=' in -+ let len = String.length s in -+ String.sub s 0 i, String.sub s (i+1) (len-(i+1)) -+;; -+ - let make_symlist prefix sep suffix l = - match l with - | [] -> "" -@@ -130,14 +136,26 @@ let parse_argv_dynamic ?(current=current) argv speclist anonfun errmsg = - while !current < l do - let s = argv.(!current) in - if String.length s >= 1 && s.[0] = '-' then begin -- let action = -- try assoc3 s !speclist -- with Not_found -> stop (Unknown s) -+ let action, follow = -+ try assoc3 s !speclist, None -+ with Not_found -> -+ try -+ let keyword, arg = split s in -+ assoc3 keyword !speclist, Some arg -+ with Not_found -> stop (Unknown s) - in -- let no_arg () = () in -+ let no_arg () = -+ match follow with -+ | None -> () -+ | Some arg -> stop (Wrong (s, arg, "no argument")) in - let get_arg () = -- if !current + 1 < l then argv.(!current + 1) -- else stop (Missing s) -+ match follow with -+ | None -> -+ if !current + 1 < l then argv.(!current + 1) -+ else stop (Missing s) -+ | Some arg -> -+ decr current; -+ arg - in - begin try - let rec treat_action = function -diff --git a/stdlib/arg.mli b/stdlib/arg.mli -index 22eda40..7078071 100644 ---- a/stdlib/arg.mli -+++ b/stdlib/arg.mli -@@ -25,7 +25,8 @@ - [Unit], [Set] and [Clear] keywords take no argument. A [Rest] - keyword takes the remaining of the command line as arguments. - Every other keyword takes the following word on the command line -- as argument. -+ as argument. For compatibility with GNU getopt_long, [keyword=arg] -+ is also allowed. - Arguments not preceded by a keyword are called anonymous arguments. - - Examples ([cmd] is assumed to be the command name): --- -2.0.4 - diff --git a/programming/language/ocaml/ocaml/files/fedora/0011-PR-6517-use-ISO-C99-types-u-int-32-64-_t-in-preferen.patch b/programming/language/ocaml/ocaml/files/fedora/0011-PR-6517-use-ISO-C99-types-u-int-32-64-_t-in-preferen.patch deleted file mode 100644 index cf8f07ab8d..0000000000 --- a/programming/language/ocaml/ocaml/files/fedora/0011-PR-6517-use-ISO-C99-types-u-int-32-64-_t-in-preferen.patch +++ /dev/null @@ -1,1963 +0,0 @@ -From 6156d208e6cc6e28a964be5dd34585bd54f6eadf Mon Sep 17 00:00:00 2001 -From: Xavier Leroy -Date: Wed, 27 Aug 2014 09:58:33 +0000 -Subject: [PATCH 11/12] PR#6517: use ISO C99 types {,u}int{32,64}_t in - preference to our homegrown types {,u}int{32,64}. - -git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15131 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 - ----------------------------------------------------------------------- -For Fedora: - -This commit was cherry picked from upstream -commit b868c05ec91a7ee193010a421de768a3b1a80952 (SVN 15131). - -See also: - -http://caml.inria.fr/mantis/view.php?id=6517 ---- - asmrun/backtrace.c | 6 +- - byterun/alloc.h | 4 +- - byterun/backtrace.c | 2 +- - byterun/config.h | 35 +++++++---- - byterun/debugger.h | 28 ++++----- - byterun/exec.h | 4 +- - byterun/extern.c | 4 +- - byterun/fix_code.c | 8 +-- - byterun/floats.c | 6 +- - byterun/globroots.c | 4 +- - byterun/hash.c | 44 +++++++------- - byterun/hash.h | 12 ++-- - byterun/int64_emul.h | 114 ++++++++++++++++++------------------ - byterun/int64_format.h | 4 +- - byterun/int64_native.h | 20 +++---- - byterun/intern.c | 20 +++---- - byterun/interp.c | 2 +- - byterun/intext.h | 12 ++-- - byterun/ints.c | 112 +++++++++++++++++------------------ - byterun/io.c | 6 +- - byterun/io.h | 6 +- - byterun/md5.c | 26 ++++---- - byterun/md5.h | 6 +- - byterun/mlvalues.h | 12 ++-- - byterun/startup.c | 10 ++-- - byterun/startup.h | 4 +- - byterun/str.c | 20 +++---- - config/auto-aux/int64align.c | 14 ++--- - config/s-nt.h | 3 + - configure | 25 ++------ - otherlibs/bigarray/bigarray_stubs.c | 48 +++++++-------- - otherlibs/num/nat_stubs.c | 14 ++--- - otherlibs/unix/addrofstr.c | 2 +- - stdlib/header.c | 2 +- - 34 files changed, 319 insertions(+), 320 deletions(-) - -diff --git a/asmrun/backtrace.c b/asmrun/backtrace.c -index c72a237..773e22c 100644 ---- a/asmrun/backtrace.c -+++ b/asmrun/backtrace.c -@@ -217,7 +217,7 @@ static void extract_location_info(frame_descr * d, - /*out*/ struct loc_info * li) - { - uintnat infoptr; -- uint32 info1, info2; -+ uint32_t info1, info2; - - /* If no debugging information available, print nothing. - When everything is compiled with -g, this corresponds to -@@ -232,8 +232,8 @@ static void extract_location_info(frame_descr * d, - sizeof(char *) + sizeof(short) + sizeof(short) + - sizeof(short) * d->num_live + sizeof(frame_descr *) - 1) - & -sizeof(frame_descr *); -- info1 = ((uint32 *)infoptr)[0]; -- info2 = ((uint32 *)infoptr)[1]; -+ info1 = ((uint32_t *)infoptr)[0]; -+ info2 = ((uint32_t *)infoptr)[1]; - /* Format of the two info words: - llllllllllllllllllll aaaaaaaa bbbbbbbbbb nnnnnnnnnnnnnnnnnnnnnnnn kk - 44 36 26 2 0 -diff --git a/byterun/alloc.h b/byterun/alloc.h -index f00a7ef..2a640eb 100644 ---- a/byterun/alloc.h -+++ b/byterun/alloc.h -@@ -32,8 +32,8 @@ CAMLextern value caml_alloc_string (mlsize_t); /* size in bytes */ - CAMLextern value caml_copy_string (char const *); - CAMLextern value caml_copy_string_array (char const **); - CAMLextern value caml_copy_double (double); --CAMLextern value caml_copy_int32 (int32); /* defined in [ints.c] */ --CAMLextern value caml_copy_int64 (int64); /* defined in [ints.c] */ -+CAMLextern value caml_copy_int32 (int32_t); /* defined in [ints.c] */ -+CAMLextern value caml_copy_int64 (int64_t); /* defined in [ints.c] */ - CAMLextern value caml_copy_nativeint (intnat); /* defined in [ints.c] */ - CAMLextern value caml_alloc_array (value (*funct) (char const *), - char const ** array); -diff --git a/byterun/backtrace.c b/byterun/backtrace.c -index 76e3ddf..6ed56c8 100644 ---- a/byterun/backtrace.c -+++ b/byterun/backtrace.c -@@ -229,7 +229,7 @@ static void read_debug_info(void) - int fd; - struct exec_trailer trail; - struct channel * chan; -- uint32 num_events, orig, i; -+ uint32_t num_events, orig, i; - intnat j; - value evl, l, ev_start; - -diff --git a/byterun/config.h b/byterun/config.h -index f775988..6c86d16 100644 ---- a/byterun/config.h -+++ b/byterun/config.h -@@ -25,24 +25,30 @@ - #include "compatibility.h" - #endif - --/* Types for 32-bit integers, 64-bit integers, -+#ifdef HAS_STDINT_H -+#include -+#endif -+ -+/* Types for 32-bit integers, 64-bit integers, and - native integers (as wide as a pointer type) */ - -+#ifndef ARCH_INT32_TYPE - #if SIZEOF_INT == 4 --typedef int int32; --typedef unsigned int uint32; -+#define ARCH_INT32_TYPE int -+#define ARCH_UINT32_TYPE unsigned int - #define ARCH_INT32_PRINTF_FORMAT "" - #elif SIZEOF_LONG == 4 --typedef long int32; --typedef unsigned long uint32; -+#define ARCH_INT32_TYPE long -+#define ARCH_UINT32_TYPE unsigned long - #define ARCH_INT32_PRINTF_FORMAT "l" - #elif SIZEOF_SHORT == 4 --typedef short int32; --typedef unsigned short uint32; -+#define ARCH_INT32_TYPE short -+#define ARCH_UINT32_TYPE unsigned short - #define ARCH_INT32_PRINTF_FORMAT "" - #else - #error "No 32-bit integer type available" - #endif -+#endif - - #ifndef ARCH_INT64_TYPE - #if SIZEOF_LONGLONG == 8 -@@ -58,8 +64,13 @@ typedef unsigned short uint32; - #endif - #endif - --typedef ARCH_INT64_TYPE int64; --typedef ARCH_UINT64_TYPE uint64; -+#ifndef HAS_STDINT_H -+/* Not a C99 compiler, typically MSVC. Define the C99 types we use. */ -+typedef ARCH_INT32_TYPE int32_t; -+typedef ARCH_UINT32_TYPE uint32_t; -+typedef ARCH_INT64_TYPE int64_t; -+typedef ARCH_UINT64_TYPE uint64_t; -+#endif - - #if SIZEOF_PTR == SIZEOF_LONG - /* Standard models: ILP32 or I32LP64 */ -@@ -72,9 +83,9 @@ typedef int intnat; - typedef unsigned int uintnat; - #define ARCH_INTNAT_PRINTF_FORMAT "" - #elif SIZEOF_PTR == 8 --/* Win64 model: IL32LLP64 */ --typedef int64 intnat; --typedef uint64 uintnat; -+/* Win64 model: IL32P64 */ -+typedef int64_t intnat; -+typedef uint64_t uintnat; - #define ARCH_INTNAT_PRINTF_FORMAT ARCH_INT64_PRINTF_FORMAT - #else - #error "No integer type available to represent pointers" -diff --git a/byterun/debugger.h b/byterun/debugger.h -index b5079eb..e68ef75 100644 ---- a/byterun/debugger.h -+++ b/byterun/debugger.h -@@ -37,17 +37,17 @@ void caml_debugger_cleanup_fork (void); - /* Requests from the debugger to the runtime system */ - - enum debugger_request { -- REQ_SET_EVENT = 'e', /* uint32 pos */ -+ REQ_SET_EVENT = 'e', /* uint32_t pos */ - /* Set an event on the instruction at position pos */ -- REQ_SET_BREAKPOINT = 'B', /* uint32 pos, (char k) */ -+ REQ_SET_BREAKPOINT = 'B', /* uint32_t pos, (char k) */ - /* Set a breakpoint at position pos */ - /* In profiling mode, the breakpoint kind is set to k */ -- REQ_RESET_INSTR = 'i', /* uint32 pos */ -+ REQ_RESET_INSTR = 'i', /* uint32_t pos */ - /* Clear an event or breapoint at position pos, restores initial instr. */ - REQ_CHECKPOINT = 'c', /* no args */ - /* Checkpoint the runtime system by forking a child process. - Reply is pid of child process or -1 if checkpoint failed. */ -- REQ_GO = 'g', /* uint32 n */ -+ REQ_GO = 'g', /* uint32_t n */ - /* Run the program for n events. - Reply is one of debugger_reply described below. */ - REQ_STOP = 's', /* no args */ -@@ -59,38 +59,38 @@ enum debugger_request { - Reply is stack offset and current pc. */ - REQ_GET_FRAME = 'f', /* no args */ - /* Return current frame location (stack offset + current pc). */ -- REQ_SET_FRAME = 'S', /* uint32 stack_offset */ -+ REQ_SET_FRAME = 'S', /* uint32_t stack_offset */ - /* Set current frame to given stack offset. No reply. */ -- REQ_UP_FRAME = 'U', /* uint32 n */ -+ REQ_UP_FRAME = 'U', /* uint32_t n */ - /* Move one frame up. Argument n is size of current frame (in words). - Reply is stack offset and current pc, or -1 if top of stack reached. */ -- REQ_SET_TRAP_BARRIER = 'b', /* uint32 offset */ -+ REQ_SET_TRAP_BARRIER = 'b', /* uint32_t offset */ - /* Set the trap barrier at the given offset. */ -- REQ_GET_LOCAL = 'L', /* uint32 slot_number */ -+ REQ_GET_LOCAL = 'L', /* uint32_t slot_number */ - /* Return the local variable at the given slot in the current frame. - Reply is one value. */ -- REQ_GET_ENVIRONMENT = 'E', /* uint32 slot_number */ -+ REQ_GET_ENVIRONMENT = 'E', /* uint32_t slot_number */ - /* Return the local variable at the given slot in the heap environment - of the current frame. Reply is one value. */ -- REQ_GET_GLOBAL = 'G', /* uint32 global_number */ -+ REQ_GET_GLOBAL = 'G', /* uint32_t global_number */ - /* Return the specified global variable. Reply is one value. */ - REQ_GET_ACCU = 'A', /* no args */ - /* Return the current contents of the accumulator. Reply is one value. */ - REQ_GET_HEADER = 'H', /* mlvalue v */ - /* As REQ_GET_OBJ, but sends only the header. */ -- REQ_GET_FIELD = 'F', /* mlvalue v, uint32 fieldnum */ -+ REQ_GET_FIELD = 'F', /* mlvalue v, uint32_t fieldnum */ - /* As REQ_GET_OBJ, but sends only one field. */ - REQ_MARSHAL_OBJ = 'M', /* mlvalue v */ - /* Send a copy of the data structure rooted at v, using the same - format as [caml_output_value]. */ - REQ_GET_CLOSURE_CODE = 'C', /* mlvalue v */ - /* Send the code address of the given closure. -- Reply is one uint32. */ -- REQ_SET_FORK_MODE = 'K' /* uint32 m */ -+ Reply is one uint32_t. */ -+ REQ_SET_FORK_MODE = 'K' /* uint32_t m */ - /* Set whether to follow the child (m=0) or the parent on fork. */ - }; - --/* Replies to a REQ_GO request. All replies are followed by three uint32: -+/* Replies to a REQ_GO request. All replies are followed by three uint32_t: - - the value of the event counter - - the position of the stack - - the current pc. */ -diff --git a/byterun/exec.h b/byterun/exec.h -index a58bcf8..7e084ac 100644 ---- a/byterun/exec.h -+++ b/byterun/exec.h -@@ -39,13 +39,13 @@ - - struct section_descriptor { - char name[4]; /* Section name */ -- uint32 len; /* Length of data in bytes */ -+ uint32_t len; /* Length of data in bytes */ - }; - - /* Structure of the trailer. */ - - struct exec_trailer { -- uint32 num_sections; /* Number of sections */ -+ uint32_t num_sections; /* Number of sections */ - char magic[12]; /* The magic number */ - struct section_descriptor * section; /* Not part of file */ - }; -diff --git a/byterun/extern.c b/byterun/extern.c -index 33fa89a..e67d7a3 100644 ---- a/byterun/extern.c -+++ b/byterun/extern.c -@@ -720,7 +720,7 @@ CAMLexport void caml_serialize_int_2(int i) - extern_ptr += 2; - } - --CAMLexport void caml_serialize_int_4(int32 i) -+CAMLexport void caml_serialize_int_4(int32_t i) - { - if (extern_ptr + 4 > extern_limit) grow_extern_output(4); - extern_ptr[0] = i >> 24; -@@ -730,7 +730,7 @@ CAMLexport void caml_serialize_int_4(int32 i) - extern_ptr += 4; - } - --CAMLexport void caml_serialize_int_8(int64 i) -+CAMLexport void caml_serialize_int_8(int64_t i) - { - caml_serialize_block_8(&i, 1); - } -diff --git a/byterun/fix_code.c b/byterun/fix_code.c -index 3380dc9..4fa0275 100644 ---- a/byterun/fix_code.c -+++ b/byterun/fix_code.c -@@ -134,12 +134,12 @@ void caml_thread_code (code_t code, asize_t len) - } - *p++ = (opcode_t)(caml_instr_table[instr] - caml_instr_base); - if (instr == SWITCH) { -- uint32 sizes = *p++; -- uint32 const_size = sizes & 0xFFFF; -- uint32 block_size = sizes >> 16; -+ uint32_t sizes = *p++; -+ uint32_t const_size = sizes & 0xFFFF; -+ uint32_t block_size = sizes >> 16; - p += const_size + block_size; - } else if (instr == CLOSUREREC) { -- uint32 nfuncs = *p++; -+ uint32_t nfuncs = *p++; - p++; /* skip nvars */ - p += nfuncs; - } else { -diff --git a/byterun/floats.c b/byterun/floats.c -index 7ff6d89..d8fdd05 100644 ---- a/byterun/floats.c -+++ b/byterun/floats.c -@@ -378,9 +378,9 @@ CAMLprim value caml_log1p_float(value f) - union double_as_two_int32 { - double d; - #if defined(ARCH_BIG_ENDIAN) || (defined(__arm__) && !defined(__ARM_EABI__)) -- struct { uint32 h; uint32 l; } i; -+ struct { uint32_t h; uint32_t l; } i; - #else -- struct { uint32 l; uint32 h; } i; -+ struct { uint32_t l; uint32_t h; } i; - #endif - }; - -@@ -467,7 +467,7 @@ CAMLprim value caml_classify_float(value vd) - } - #else - union double_as_two_int32 u; -- uint32 h, l; -+ uint32_t h, l; - - u.d = Double_val(vd); - h = u.i.h; l = u.i.l; -diff --git a/byterun/globroots.c b/byterun/globroots.c -index ded393e..d9111ee 100644 ---- a/byterun/globroots.c -+++ b/byterun/globroots.c -@@ -43,11 +43,11 @@ struct global_root_list { - (i.e. 2 * (NUM_LEVELS - 1)). Moreover, the congruential PRNG - is faster and guaranteed to be deterministic (to reproduce bugs). */ - --static uint32 random_seed = 0; -+static uint32_t random_seed = 0; - - static int random_level(void) - { -- uint32 r; -+ uint32_t r; - int level = 0; - - /* Linear congruence with modulus = 2^32, multiplier = 69069 -diff --git a/byterun/hash.c b/byterun/hash.c -index f896426..12912d3 100644 ---- a/byterun/hash.c -+++ b/byterun/hash.c -@@ -41,7 +41,7 @@ - h *= 0xc2b2ae35; \ - h ^= h >> 16; - --CAMLexport uint32 caml_hash_mix_uint32(uint32 h, uint32 d) -+CAMLexport uint32_t caml_hash_mix_uint32(uint32_t h, uint32_t d) - { - MIX(h, d); - return h; -@@ -49,17 +49,17 @@ CAMLexport uint32 caml_hash_mix_uint32(uint32 h, uint32 d) - - /* Mix a platform-native integer. */ - --CAMLexport uint32 caml_hash_mix_intnat(uint32 h, intnat d) -+CAMLexport uint32_t caml_hash_mix_intnat(uint32_t h, intnat d) - { -- uint32 n; -+ uint32_t n; - #ifdef ARCH_SIXTYFOUR - /* Mix the low 32 bits and the high 32 bits, in a way that preserves -- 32/64 compatibility: we want n = (uint32) d -+ 32/64 compatibility: we want n = (uint32_t) d - if d is in the range [-2^31, 2^31-1]. */ - n = (d >> 32) ^ (d >> 63) ^ d; - /* If 0 <= d < 2^31: d >> 32 = 0 d >> 63 = 0 - If -2^31 <= d < 0: d >> 32 = -1 d >> 63 = -1 -- In both cases, n = (uint32) d. */ -+ In both cases, n = (uint32_t) d. */ - #else - n = d; - #endif -@@ -69,9 +69,9 @@ CAMLexport uint32 caml_hash_mix_intnat(uint32 h, intnat d) - - /* Mix a 64-bit integer. */ - --CAMLexport uint32 caml_hash_mix_int64(uint32 h, int64 d) -+CAMLexport uint32_t caml_hash_mix_int64(uint32_t h, int64_t d) - { -- uint32 hi = (uint32) (d >> 32), lo = (uint32) d; -+ uint32_t hi = (uint32_t) (d >> 32), lo = (uint32_t) d; - MIX(h, lo); - MIX(h, hi); - return h; -@@ -82,17 +82,17 @@ CAMLexport uint32 caml_hash_mix_int64(uint32 h, int64 d) - Treats all NaNs identically. - */ - --CAMLexport uint32 caml_hash_mix_double(uint32 hash, double d) -+CAMLexport uint32_t caml_hash_mix_double(uint32_t hash, double d) - { - union { - double d; - #if defined(ARCH_BIG_ENDIAN) || (defined(__arm__) && !defined(__ARM_EABI__)) -- struct { uint32 h; uint32 l; } i; -+ struct { uint32_t h; uint32_t l; } i; - #else -- struct { uint32 l; uint32 h; } i; -+ struct { uint32_t l; uint32_t h; } i; - #endif - } u; -- uint32 h, l; -+ uint32_t h, l; - /* Convert to two 32-bit halves */ - u.d = d; - h = u.i.h; l = u.i.l; -@@ -115,14 +115,14 @@ CAMLexport uint32 caml_hash_mix_double(uint32 hash, double d) - Treats all NaNs identically. - */ - --CAMLexport uint32 caml_hash_mix_float(uint32 hash, float d) -+CAMLexport uint32_t caml_hash_mix_float(uint32_t hash, float d) - { - union { - float f; -- uint32 i; -+ uint32_t i; - } u; -- uint32 n; -- /* Convert to int32 */ -+ uint32_t n; -+ /* Convert to int32_t */ - u.f = d; n = u.i; - /* Normalize NaNs */ - if ((n & 0x7F800000) == 0x7F800000 && (n & 0x007FFFFF) != 0) { -@@ -138,11 +138,11 @@ CAMLexport uint32 caml_hash_mix_float(uint32 hash, float d) - - /* Mix an OCaml string */ - --CAMLexport uint32 caml_hash_mix_string(uint32 h, value s) -+CAMLexport uint32_t caml_hash_mix_string(uint32_t h, value s) - { - mlsize_t len = caml_string_length(s); - mlsize_t i; -- uint32 w; -+ uint32_t w; - - /* Mix by 32-bit blocks (little-endian) */ - for (i = 0; i + 4 <= len; i += 4) { -@@ -152,7 +152,7 @@ CAMLexport uint32 caml_hash_mix_string(uint32 h, value s) - | (Byte_u(s, i+2) << 16) - | (Byte_u(s, i+3) << 24); - #else -- w = *((uint32 *) &Byte_u(s, i)); -+ w = *((uint32_t *) &Byte_u(s, i)); - #endif - MIX(h, w); - } -@@ -166,7 +166,7 @@ CAMLexport uint32 caml_hash_mix_string(uint32 h, value s) - default: /*skip*/; /* len & 3 == 0, no extra bytes, do nothing */ - } - /* Finally, mix in the length. Ignore the upper 32 bits, generally 0. */ -- h ^= (uint32) len; -+ h ^= (uint32_t) len; - return h; - } - -@@ -184,7 +184,7 @@ CAMLprim value caml_hash(value count, value limit, value seed, value obj) - intnat wr; /* One past position of last value in queue */ - intnat sz; /* Max number of values to put in queue */ - intnat num; /* Max number of meaningful values to see */ -- uint32 h; /* Rolling hash */ -+ uint32_t h; /* Rolling hash */ - value v; - mlsize_t i, len; - -@@ -245,7 +245,7 @@ CAMLprim value caml_hash(value count, value limit, value seed, value obj) - /* If no hashing function provided, do nothing. */ - /* Only use low 32 bits of custom hash, for 32/64 compatibility */ - if (Custom_ops_val(v)->hash != NULL) { -- uint32 n = (uint32) Custom_ops_val(v)->hash(v); -+ uint32_t n = (uint32_t) Custom_ops_val(v)->hash(v); - h = caml_hash_mix_uint32(h, n); - num--; - } -@@ -408,5 +408,5 @@ CAMLexport value caml_hash_variant(char const * tag) - #endif - /* Force sign extension of bit 31 for compatibility between 32 and 64-bit - platforms */ -- return (int32) accu; -+ return (int32_t) accu; - } -diff --git a/byterun/hash.h b/byterun/hash.h -index 436a8bb..6561397 100644 ---- a/byterun/hash.h -+++ b/byterun/hash.h -@@ -18,12 +18,12 @@ - - #include "mlvalues.h" - --CAMLextern uint32 caml_hash_mix_uint32(uint32 h, uint32 d); --CAMLextern uint32 caml_hash_mix_intnat(uint32 h, intnat d); --CAMLextern uint32 caml_hash_mix_int64(uint32 h, int64 d); --CAMLextern uint32 caml_hash_mix_double(uint32 h, double d); --CAMLextern uint32 caml_hash_mix_float(uint32 h, float d); --CAMLextern uint32 caml_hash_mix_string(uint32 h, value s); -+CAMLextern uint32_t caml_hash_mix_uint32(uint32_t h, uint32_t d); -+CAMLextern uint32_t caml_hash_mix_intnat(uint32_t h, intnat d); -+CAMLextern uint32_t caml_hash_mix_int64(uint32_t h, int64_t d); -+CAMLextern uint32_t caml_hash_mix_double(uint32_t h, double d); -+CAMLextern uint32_t caml_hash_mix_float(uint32_t h, float d); -+CAMLextern uint32_t caml_hash_mix_string(uint32_t h, value s); - - - #endif -diff --git a/byterun/int64_emul.h b/byterun/int64_emul.h -index ba7904a..2554df1 100644 ---- a/byterun/int64_emul.h -+++ b/byterun/int64_emul.h -@@ -28,7 +28,7 @@ - #define I64_split(x,hi,lo) (hi = (x).h, lo = (x).l) - - /* Unsigned comparison */ --static int I64_ucompare(uint64 x, uint64 y) -+static int I64_ucompare(uint64_t x, uint64_t y) - { - if (x.h > y.h) return 1; - if (x.h < y.h) return -1; -@@ -40,19 +40,19 @@ static int I64_ucompare(uint64 x, uint64 y) - #define I64_ult(x, y) (I64_ucompare(x, y) < 0) - - /* Signed comparison */ --static int I64_compare(int64 x, int64 y) -+static int I64_compare(int64_t x, int64_t y) - { -- if ((int32)x.h > (int32)y.h) return 1; -- if ((int32)x.h < (int32)y.h) return -1; -+ if ((int32_t)x.h > (int32_t)y.h) return 1; -+ if ((int32_t)x.h < (int32_t)y.h) return -1; - if (x.l > y.l) return 1; - if (x.l < y.l) return -1; - return 0; - } - - /* Negation */ --static int64 I64_neg(int64 x) -+static int64_t I64_neg(int64_t x) - { -- int64 res; -+ int64_t res; - res.l = -x.l; - res.h = ~x.h; - if (res.l == 0) res.h++; -@@ -60,9 +60,9 @@ static int64 I64_neg(int64 x) - } - - /* Addition */ --static int64 I64_add(int64 x, int64 y) -+static int64_t I64_add(int64_t x, int64_t y) - { -- int64 res; -+ int64_t res; - res.l = x.l + y.l; - res.h = x.h + y.h; - if (res.l < x.l) res.h++; -@@ -70,9 +70,9 @@ static int64 I64_add(int64 x, int64 y) - } - - /* Subtraction */ --static int64 I64_sub(int64 x, int64 y) -+static int64_t I64_sub(int64_t x, int64_t y) - { -- int64 res; -+ int64_t res; - res.l = x.l - y.l; - res.h = x.h - y.h; - if (x.l < y.l) res.h--; -@@ -80,13 +80,13 @@ static int64 I64_sub(int64 x, int64 y) - } - - /* Multiplication */ --static int64 I64_mul(int64 x, int64 y) -+static int64_t I64_mul(int64_t x, int64_t y) - { -- int64 res; -- uint32 prod00 = (x.l & 0xFFFF) * (y.l & 0xFFFF); -- uint32 prod10 = (x.l >> 16) * (y.l & 0xFFFF); -- uint32 prod01 = (x.l & 0xFFFF) * (y.l >> 16); -- uint32 prod11 = (x.l >> 16) * (y.l >> 16); -+ int64_t res; -+ uint32_t prod00 = (x.l & 0xFFFF) * (y.l & 0xFFFF); -+ uint32_t prod10 = (x.l >> 16) * (y.l & 0xFFFF); -+ uint32_t prod01 = (x.l & 0xFFFF) * (y.l >> 16); -+ uint32_t prod11 = (x.l >> 16) * (y.l >> 16); - res.l = prod00; - res.h = prod11 + (prod01 >> 16) + (prod10 >> 16); - prod01 = prod01 << 16; res.l += prod01; if (res.l < prod01) res.h++; -@@ -96,39 +96,39 @@ static int64 I64_mul(int64 x, int64 y) - } - - #define I64_is_zero(x) (((x).l | (x).h) == 0) --#define I64_is_negative(x) ((int32) (x).h < 0) -+#define I64_is_negative(x) ((int32_t) (x).h < 0) - #define I64_is_min_int(x) ((x).l == 0 && (x).h == 0x80000000U) - #define I64_is_minus_one(x) (((x).l & (x).h) == 0xFFFFFFFFU) - - /* Bitwise operations */ --static int64 I64_and(int64 x, int64 y) -+static int64_t I64_and(int64_t x, int64_t y) - { -- int64 res; -+ int64_t res; - res.l = x.l & y.l; - res.h = x.h & y.h; - return res; - } - --static int64 I64_or(int64 x, int64 y) -+static int64_t I64_or(int64_t x, int64_t y) - { -- int64 res; -+ int64_t res; - res.l = x.l | y.l; - res.h = x.h | y.h; - return res; - } - --static int64 I64_xor(int64 x, int64 y) -+static int64_t I64_xor(int64_t x, int64_t y) - { -- int64 res; -+ int64_t res; - res.l = x.l ^ y.l; - res.h = x.h ^ y.h; - return res; - } - - /* Shifts */ --static int64 I64_lsl(int64 x, int s) -+static int64_t I64_lsl(int64_t x, int s) - { -- int64 res; -+ int64_t res; - s = s & 63; - if (s == 0) return x; - if (s < 32) { -@@ -141,9 +141,9 @@ static int64 I64_lsl(int64 x, int s) - return res; - } - --static int64 I64_lsr(int64 x, int s) -+static int64_t I64_lsr(int64_t x, int s) - { -- int64 res; -+ int64_t res; - s = s & 63; - if (s == 0) return x; - if (s < 32) { -@@ -156,17 +156,17 @@ static int64 I64_lsr(int64 x, int s) - return res; - } - --static int64 I64_asr(int64 x, int s) -+static int64_t I64_asr(int64_t x, int s) - { -- int64 res; -+ int64_t res; - s = s & 63; - if (s == 0) return x; - if (s < 32) { - res.l = (x.l >> s) | (x.h << (32 - s)); -- res.h = (int32) x.h >> s; -+ res.h = (int32_t) x.h >> s; - } else { -- res.l = (int32) x.h >> (s - 32); -- res.h = (int32) x.h >> 31; -+ res.l = (int32_t) x.h >> (s - 32); -+ res.h = (int32_t) x.h >> 31; - } - return res; - } -@@ -176,15 +176,15 @@ static int64 I64_asr(int64 x, int s) - #define I64_SHL1(x) x.h = (x.h << 1) | (x.l >> 31); x.l <<= 1 - #define I64_SHR1(x) x.l = (x.l >> 1) | (x.h << 31); x.h >>= 1 - --static void I64_udivmod(uint64 modulus, uint64 divisor, -- uint64 * quo, uint64 * mod) -+static void I64_udivmod(uint64_t modulus, uint64_t divisor, -+ uint64_t * quo, uint64_t * mod) - { -- int64 quotient, mask; -+ int64_t quotient, mask; - int cmp; - - quotient.h = 0; quotient.l = 0; - mask.h = 0; mask.l = 1; -- while ((int32) divisor.h >= 0) { -+ while ((int32_t) divisor.h >= 0) { - cmp = I64_ucompare(divisor, modulus); - I64_SHL1(divisor); - I64_SHL1(mask); -@@ -202,27 +202,27 @@ static void I64_udivmod(uint64 modulus, uint64 divisor, - *mod = modulus; - } - --static int64 I64_div(int64 x, int64 y) -+static int64_t I64_div(int64_t x, int64_t y) - { -- int64 q, r; -- int32 sign; -+ int64_t q, r; -+ int32_t sign; - - sign = x.h ^ y.h; -- if ((int32) x.h < 0) x = I64_neg(x); -- if ((int32) y.h < 0) y = I64_neg(y); -+ if ((int32_t) x.h < 0) x = I64_neg(x); -+ if ((int32_t) y.h < 0) y = I64_neg(y); - I64_udivmod(x, y, &q, &r); - if (sign < 0) q = I64_neg(q); - return q; - } - --static int64 I64_mod(int64 x, int64 y) -+static int64_t I64_mod(int64_t x, int64_t y) - { -- int64 q, r; -- int32 sign; -+ int64_t q, r; -+ int32_t sign; - - sign = x.h; -- if ((int32) x.h < 0) x = I64_neg(x); -- if ((int32) y.h < 0) y = I64_neg(y); -+ if ((int32_t) x.h < 0) x = I64_neg(x); -+ if ((int32_t) y.h < 0) y = I64_neg(y); - I64_udivmod(x, y, &q, &r); - if (sign < 0) r = I64_neg(r); - return r; -@@ -230,49 +230,49 @@ static int64 I64_mod(int64 x, int64 y) - - /* Coercions */ - --static int64 I64_of_int32(int32 x) -+static int64_t I64_of_int32(int32_t x) - { -- int64 res; -+ int64_t res; - res.l = x; - res.h = x >> 31; - return res; - } - --#define I64_to_int32(x) ((int32) (x).l) -+#define I64_to_int32(x) ((int32_t) (x).l) - - /* Note: we assume sizeof(intnat) = 4 here, which is true otherwise - autoconfiguration would have selected native 64-bit integers */ - #define I64_of_intnat I64_of_int32 - #define I64_to_intnat I64_to_int32 - --static double I64_to_double(int64 x) -+static double I64_to_double(int64_t x) - { - double res; -- int32 sign = x.h; -+ int32_t sign = x.h; - if (sign < 0) x = I64_neg(x); - res = ldexp((double) x.h, 32) + x.l; - if (sign < 0) res = -res; - return res; - } - --static int64 I64_of_double(double f) -+static int64_t I64_of_double(double f) - { -- int64 res; -+ int64_t res; - double frac, integ; - int neg; - - neg = (f < 0); - f = fabs(f); - frac = modf(ldexp(f, -32), &integ); -- res.h = (uint32) integ; -- res.l = (uint32) ldexp(frac, 32); -+ res.h = (uint32_t) integ; -+ res.l = (uint32_t) ldexp(frac, 32); - if (neg) res = I64_neg(res); - return res; - } - --static int64 I64_bswap(int64 x) -+static int64_t I64_bswap(int64_t x) - { -- int64 res; -+ int64_t res; - res.h = (((x.l & 0x000000FF) << 24) | - ((x.l & 0x0000FF00) << 8) | - ((x.l & 0x00FF0000) >> 8) | -diff --git a/byterun/int64_format.h b/byterun/int64_format.h -index b0de527..aa8f1ab 100644 ---- a/byterun/int64_format.h -+++ b/byterun/int64_format.h -@@ -17,7 +17,7 @@ - #ifndef CAML_INT64_FORMAT_H - #define CAML_INT64_FORMAT_H - --static void I64_format(char * buffer, char * fmt, int64 x) -+static void I64_format(char * buffer, char * fmt, int64_t x) - { - static char conv_lower[] = "0123456789abcdef"; - static char conv_upper[] = "0123456789ABCDEF"; -@@ -26,7 +26,7 @@ static void I64_format(char * buffer, char * fmt, int64 x) - int base, width, sign, i, rawlen; - char * cvtbl; - char * p, * r; -- int64 wbase, digit; -+ int64_t wbase, digit; - - /* Parsing of format */ - justify = '+'; -diff --git a/byterun/int64_native.h b/byterun/int64_native.h -index e9ffe67..b6716ad 100644 ---- a/byterun/int64_native.h -+++ b/byterun/int64_native.h -@@ -18,36 +18,36 @@ - #ifndef CAML_INT64_NATIVE_H - #define CAML_INT64_NATIVE_H - --#define I64_literal(hi,lo) ((int64)(hi) << 32 | (lo)) --#define I64_split(x,hi,lo) (hi = (uint32)((x)>>32), lo = (uint32)(x)) -+#define I64_literal(hi,lo) ((int64_t)(hi) << 32 | (lo)) -+#define I64_split(x,hi,lo) (hi = (uint32_t)((x)>>32), lo = (uint32_t)(x)) - #define I64_compare(x,y) (((x) > (y)) - ((x) < (y))) --#define I64_ult(x,y) ((uint64)(x) < (uint64)(y)) -+#define I64_ult(x,y) ((uint64_t)(x) < (uint64_t)(y)) - #define I64_neg(x) (-(x)) - #define I64_add(x,y) ((x) + (y)) - #define I64_sub(x,y) ((x) - (y)) - #define I64_mul(x,y) ((x) * (y)) - #define I64_is_zero(x) ((x) == 0) - #define I64_is_negative(x) ((x) < 0) --#define I64_is_min_int(x) ((x) == ((int64)1 << 63)) -+#define I64_is_min_int(x) ((x) == ((int64_t)1 << 63)) - #define I64_is_minus_one(x) ((x) == -1) - - #define I64_div(x,y) ((x) / (y)) - #define I64_mod(x,y) ((x) % (y)) - #define I64_udivmod(x,y,quo,rem) \ -- (*(rem) = (uint64)(x) % (uint64)(y), \ -- *(quo) = (uint64)(x) / (uint64)(y)) -+ (*(rem) = (uint64_t)(x) % (uint64_t)(y), \ -+ *(quo) = (uint64_t)(x) / (uint64_t)(y)) - #define I64_and(x,y) ((x) & (y)) - #define I64_or(x,y) ((x) | (y)) - #define I64_xor(x,y) ((x) ^ (y)) - #define I64_lsl(x,y) ((x) << (y)) - #define I64_asr(x,y) ((x) >> (y)) --#define I64_lsr(x,y) ((uint64)(x) >> (y)) -+#define I64_lsr(x,y) ((uint64_t)(x) >> (y)) - #define I64_to_intnat(x) ((intnat) (x)) - #define I64_of_intnat(x) ((intnat) (x)) --#define I64_to_int32(x) ((int32) (x)) --#define I64_of_int32(x) ((int64) (x)) -+#define I64_to_int32(x) ((int32_t) (x)) -+#define I64_of_int32(x) ((int64_t) (x)) - #define I64_to_double(x) ((double)(x)) --#define I64_of_double(x) ((int64)(x)) -+#define I64_of_double(x) ((int64_t)(x)) - - #define I64_bswap(x) ((((x) & 0x00000000000000FFULL) << 56) | \ - (((x) & 0x000000000000FF00ULL) << 40) | \ -diff --git a/byterun/intern.c b/byterun/intern.c -index e0fcc5d..638ff72 100644 ---- a/byterun/intern.c -+++ b/byterun/intern.c -@@ -553,7 +553,7 @@ static void intern_add_to_heap(mlsize_t whsize) - - value caml_input_val(struct channel *chan) - { -- uint32 magic; -+ uint32_t magic; - mlsize_t block_len, num_objects, whsize; - char * block; - value res; -@@ -663,7 +663,7 @@ static value input_val_from_block(void) - - CAMLexport value caml_input_value_from_malloc(char * data, intnat ofs) - { -- uint32 magic; -+ uint32_t magic; - value obj; - - intern_input = (unsigned char *) data; -@@ -681,7 +681,7 @@ CAMLexport value caml_input_value_from_malloc(char * data, intnat ofs) - - CAMLexport value caml_input_value_from_block(char * data, intnat len) - { -- uint32 magic; -+ uint32_t magic; - mlsize_t block_len; - value obj; - -@@ -700,7 +700,7 @@ CAMLexport value caml_input_value_from_block(char * data, intnat len) - - CAMLprim value caml_marshal_data_size(value buff, value ofs) - { -- uint32 magic; -+ uint32_t magic; - mlsize_t block_len; - - intern_src = &Byte_u(buff, Long_val(ofs)); -@@ -771,26 +771,26 @@ CAMLexport int caml_deserialize_sint_2(void) - return read16s(); - } - --CAMLexport uint32 caml_deserialize_uint_4(void) -+CAMLexport uint32_t caml_deserialize_uint_4(void) - { - return read32u(); - } - --CAMLexport int32 caml_deserialize_sint_4(void) -+CAMLexport int32_t caml_deserialize_sint_4(void) - { - return read32s(); - } - --CAMLexport uint64 caml_deserialize_uint_8(void) -+CAMLexport uint64_t caml_deserialize_uint_8(void) - { -- uint64 i; -+ uint64_t i; - caml_deserialize_block_8(&i, 1); - return i; - } - --CAMLexport int64 caml_deserialize_sint_8(void) -+CAMLexport int64_t caml_deserialize_sint_8(void) - { -- int64 i; -+ int64_t i; - caml_deserialize_block_8(&i, 1); - return i; - } -diff --git a/byterun/interp.c b/byterun/interp.c -index 9b682ba..e22b28b 100644 ---- a/byterun/interp.c -+++ b/byterun/interp.c -@@ -793,7 +793,7 @@ value caml_interprete(code_t prog, asize_t prog_size) - if (accu == Val_false) pc += *pc; else pc++; - Next; - Instruct(SWITCH): { -- uint32 sizes = *pc++; -+ uint32_t sizes = *pc++; - if (Is_block(accu)) { - intnat index = Tag_val(accu); - Assert ((uintnat) index < (sizes >> 16)); -diff --git a/byterun/intext.h b/byterun/intext.h -index f7aa655..2c108a4 100644 ---- a/byterun/intext.h -+++ b/byterun/intext.h -@@ -119,8 +119,8 @@ CAMLextern value caml_input_value_from_block(char * data, intnat len); - - CAMLextern void caml_serialize_int_1(int i); - CAMLextern void caml_serialize_int_2(int i); --CAMLextern void caml_serialize_int_4(int32 i); --CAMLextern void caml_serialize_int_8(int64 i); -+CAMLextern void caml_serialize_int_4(int32_t i); -+CAMLextern void caml_serialize_int_8(int64_t i); - CAMLextern void caml_serialize_float_4(float f); - CAMLextern void caml_serialize_float_8(double f); - CAMLextern void caml_serialize_block_1(void * data, intnat len); -@@ -133,10 +133,10 @@ CAMLextern int caml_deserialize_uint_1(void); - CAMLextern int caml_deserialize_sint_1(void); - CAMLextern int caml_deserialize_uint_2(void); - CAMLextern int caml_deserialize_sint_2(void); --CAMLextern uint32 caml_deserialize_uint_4(void); --CAMLextern int32 caml_deserialize_sint_4(void); --CAMLextern uint64 caml_deserialize_uint_8(void); --CAMLextern int64 caml_deserialize_sint_8(void); -+CAMLextern uint32_t caml_deserialize_uint_4(void); -+CAMLextern int32_t caml_deserialize_sint_4(void); -+CAMLextern uint64_t caml_deserialize_uint_8(void); -+CAMLextern int64_t caml_deserialize_sint_8(void); - CAMLextern float caml_deserialize_float_4(void); - CAMLextern double caml_deserialize_float_8(void); - CAMLextern void caml_deserialize_block_1(void * data, intnat len); -diff --git a/byterun/ints.c b/byterun/ints.c -index d762c76..056e82a 100644 ---- a/byterun/ints.c -+++ b/byterun/ints.c -@@ -172,8 +172,8 @@ CAMLprim value caml_format_int(value fmt, value arg) - - static int int32_cmp(value v1, value v2) - { -- int32 i1 = Int32_val(v1); -- int32 i2 = Int32_val(v2); -+ int32_t i1 = Int32_val(v1); -+ int32_t i2 = Int32_val(v2); - return (i1 > i2) - (i1 < i2); - } - -@@ -191,7 +191,7 @@ static void int32_serialize(value v, uintnat * wsize_32, - - static uintnat int32_deserialize(void * dst) - { -- *((int32 *) dst) = caml_deserialize_sint_4(); -+ *((int32_t *) dst) = caml_deserialize_sint_4(); - return 4; - } - -@@ -205,7 +205,7 @@ CAMLexport struct custom_operations caml_int32_ops = { - custom_compare_ext_default - }; - --CAMLexport value caml_copy_int32(int32 i) -+CAMLexport value caml_copy_int32(int32_t i) - { - value res = caml_alloc_custom(&caml_int32_ops, 4, 0, 1); - Int32_val(res) = i; -@@ -226,8 +226,8 @@ CAMLprim value caml_int32_mul(value v1, value v2) - - CAMLprim value caml_int32_div(value v1, value v2) - { -- int32 dividend = Int32_val(v1); -- int32 divisor = Int32_val(v2); -+ int32_t dividend = Int32_val(v1); -+ int32_t divisor = Int32_val(v2); - if (divisor == 0) caml_raise_zero_divide(); - /* PR#4740: on some processors, division crashes on overflow. - Implement the same behavior as for type "int". */ -@@ -237,8 +237,8 @@ CAMLprim value caml_int32_div(value v1, value v2) - - CAMLprim value caml_int32_mod(value v1, value v2) - { -- int32 dividend = Int32_val(v1); -- int32 divisor = Int32_val(v2); -+ int32_t dividend = Int32_val(v1); -+ int32_t divisor = Int32_val(v2); - if (divisor == 0) caml_raise_zero_divide(); - /* PR#4740: on some processors, modulus crashes if division overflows. - Implement the same behavior as for type "int". */ -@@ -262,9 +262,9 @@ CAMLprim value caml_int32_shift_right(value v1, value v2) - { return caml_copy_int32(Int32_val(v1) >> Int_val(v2)); } - - CAMLprim value caml_int32_shift_right_unsigned(value v1, value v2) --{ return caml_copy_int32((uint32)Int32_val(v1) >> Int_val(v2)); } -+{ return caml_copy_int32((uint32_t)Int32_val(v1) >> Int_val(v2)); } - --static int32 caml_swap32(int32 x) -+static int32_t caml_swap32(int32_t x) - { - return (((x & 0x000000FF) << 24) | - ((x & 0x0000FF00) << 8) | -@@ -285,15 +285,15 @@ CAMLprim value caml_int32_to_int(value v) - { return Val_long(Int32_val(v)); } - - CAMLprim value caml_int32_of_float(value v) --{ return caml_copy_int32((int32)(Double_val(v))); } -+{ return caml_copy_int32((int32_t)(Double_val(v))); } - - CAMLprim value caml_int32_to_float(value v) - { return caml_copy_double((double)(Int32_val(v))); } - - CAMLprim value caml_int32_compare(value v1, value v2) - { -- int32 i1 = Int32_val(v1); -- int32 i2 = Int32_val(v2); -+ int32_t i1 = Int32_val(v1); -+ int32_t i2 = Int32_val(v2); - int res = (i1 > i2) - (i1 < i2); - return Val_int(res); - } -@@ -313,14 +313,14 @@ CAMLprim value caml_int32_of_string(value s) - - CAMLprim value caml_int32_bits_of_float(value vd) - { -- union { float d; int32 i; } u; -+ union { float d; int32_t i; } u; - u.d = Double_val(vd); - return caml_copy_int32(u.i); - } - - CAMLprim value caml_int32_float_of_bits(value vi) - { -- union { float d; int32 i; } u; -+ union { float d; int32_t i; } u; - u.i = Int32_val(vi); - return caml_copy_double(u.d); - } -@@ -329,11 +329,11 @@ CAMLprim value caml_int32_float_of_bits(value vi) - - #ifdef ARCH_ALIGN_INT64 - --CAMLexport int64 caml_Int64_val(value v) -+CAMLexport int64_t caml_Int64_val(value v) - { -- union { int32 i[2]; int64 j; } buffer; -- buffer.i[0] = ((int32 *) Data_custom_val(v))[0]; -- buffer.i[1] = ((int32 *) Data_custom_val(v))[1]; -+ union { int32_t i[2]; int64_t j; } buffer; -+ buffer.i[0] = ((int32_t *) Data_custom_val(v))[0]; -+ buffer.i[1] = ((int32_t *) Data_custom_val(v))[1]; - return buffer.j; - } - -@@ -341,15 +341,15 @@ CAMLexport int64 caml_Int64_val(value v) - - static int int64_cmp(value v1, value v2) - { -- int64 i1 = Int64_val(v1); -- int64 i2 = Int64_val(v2); -+ int64_t i1 = Int64_val(v1); -+ int64_t i2 = Int64_val(v2); - return (i1 > i2) - (i1 < i2); - } - - static intnat int64_hash(value v) - { -- int64 x = Int64_val(v); -- uint32 lo = (uint32) x, hi = (uint32) (x >> 32); -+ int64_t x = Int64_val(v); -+ uint32_t lo = (uint32_t) x, hi = (uint32_t) (x >> 32); - return hi ^ lo; - } - -@@ -363,12 +363,12 @@ static void int64_serialize(value v, uintnat * wsize_32, - static uintnat int64_deserialize(void * dst) - { - #ifndef ARCH_ALIGN_INT64 -- *((int64 *) dst) = caml_deserialize_sint_8(); -+ *((int64_t *) dst) = caml_deserialize_sint_8(); - #else -- union { int32 i[2]; int64 j; } buffer; -+ union { int32_t i[2]; int64_t j; } buffer; - buffer.j = caml_deserialize_sint_8(); -- ((int32 *) dst)[0] = buffer.i[0]; -- ((int32 *) dst)[1] = buffer.i[1]; -+ ((int32_t *) dst)[0] = buffer.i[0]; -+ ((int32_t *) dst)[1] = buffer.i[1]; - #endif - return 8; - } -@@ -383,16 +383,16 @@ CAMLexport struct custom_operations caml_int64_ops = { - custom_compare_ext_default - }; - --CAMLexport value caml_copy_int64(int64 i) -+CAMLexport value caml_copy_int64(int64_t i) - { - value res = caml_alloc_custom(&caml_int64_ops, 8, 0, 1); - #ifndef ARCH_ALIGN_INT64 - Int64_val(res) = i; - #else -- union { int32 i[2]; int64 j; } buffer; -+ union { int32_t i[2]; int64_t j; } buffer; - buffer.j = i; -- ((int32 *) Data_custom_val(res))[0] = buffer.i[0]; -- ((int32 *) Data_custom_val(res))[1] = buffer.i[1]; -+ ((int32_t *) Data_custom_val(res))[0] = buffer.i[0]; -+ ((int32_t *) Data_custom_val(res))[1] = buffer.i[1]; - #endif - return res; - } -@@ -413,23 +413,23 @@ CAMLprim value caml_int64_mul(value v1, value v2) - - CAMLprim value caml_int64_div(value v1, value v2) - { -- int64 dividend = Int64_val(v1); -- int64 divisor = Int64_val(v2); -+ int64_t dividend = Int64_val(v1); -+ int64_t divisor = Int64_val(v2); - if (divisor == 0) caml_raise_zero_divide(); - /* PR#4740: on some processors, division crashes on overflow. - Implement the same behavior as for type "int". */ -- if (dividend == ((int64)1 << 63) && divisor == -1) return v1; -+ if (dividend == ((int64_t)1 << 63) && divisor == -1) return v1; - return caml_copy_int64(Int64_val(v1) / divisor); - } - - CAMLprim value caml_int64_mod(value v1, value v2) - { -- int64 dividend = Int64_val(v1); -- int64 divisor = Int64_val(v2); -+ int64_t dividend = Int64_val(v1); -+ int64_t divisor = Int64_val(v2); - if (divisor == 0) caml_raise_zero_divide(); - /* PR#4740: on some processors, division crashes on overflow. - Implement the same behavior as for type "int". */ -- if (dividend == ((int64)1 << 63) && divisor == -1) return caml_copy_int64(0); -+ if (dividend == ((int64_t)1 << 63) && divisor == -1) return caml_copy_int64(0); - return caml_copy_int64(Int64_val(v1) % divisor); - } - -@@ -449,7 +449,7 @@ CAMLprim value caml_int64_shift_right(value v1, value v2) - { return caml_copy_int64(Int64_val(v1) >> Int_val(v2)); } - - CAMLprim value caml_int64_shift_right_unsigned(value v1, value v2) --{ return caml_copy_int64((uint64) (Int64_val(v1)) >> Int_val(v2)); } -+{ return caml_copy_int64((uint64_t) (Int64_val(v1)) >> Int_val(v2)); } - - #ifdef ARCH_SIXTYFOUR - static value caml_swap64(value x) -@@ -470,7 +470,7 @@ value caml_int64_direct_bswap(value v) - - CAMLprim value caml_int64_bswap(value v) - { -- int64 x = Int64_val(v); -+ int64_t x = Int64_val(v); - return caml_copy_int64 - (((x & 0x00000000000000FFULL) << 56) | - ((x & 0x000000000000FF00ULL) << 40) | -@@ -483,33 +483,33 @@ CAMLprim value caml_int64_bswap(value v) - } - - CAMLprim value caml_int64_of_int(value v) --{ return caml_copy_int64((int64) (Long_val(v))); } -+{ return caml_copy_int64((int64_t) (Long_val(v))); } - - CAMLprim value caml_int64_to_int(value v) - { return Val_long((intnat) (Int64_val(v))); } - - CAMLprim value caml_int64_of_float(value v) --{ return caml_copy_int64((int64) (Double_val(v))); } -+{ return caml_copy_int64((int64_t) (Double_val(v))); } - - CAMLprim value caml_int64_to_float(value v) - { return caml_copy_double((double) (Int64_val(v))); } - - CAMLprim value caml_int64_of_int32(value v) --{ return caml_copy_int64((int64) (Int32_val(v))); } -+{ return caml_copy_int64((int64_t) (Int32_val(v))); } - - CAMLprim value caml_int64_to_int32(value v) --{ return caml_copy_int32((int32) (Int64_val(v))); } -+{ return caml_copy_int32((int32_t) (Int64_val(v))); } - - CAMLprim value caml_int64_of_nativeint(value v) --{ return caml_copy_int64((int64) (Nativeint_val(v))); } -+{ return caml_copy_int64((int64_t) (Nativeint_val(v))); } - - CAMLprim value caml_int64_to_nativeint(value v) - { return caml_copy_nativeint((intnat) (Int64_val(v))); } - - CAMLprim value caml_int64_compare(value v1, value v2) - { -- int64 i1 = Int64_val(v1); -- int64 i2 = Int64_val(v2); -+ int64_t i1 = Int64_val(v1); -+ int64_t i2 = Int64_val(v2); - return Val_int((i1 > i2) - (i1 < i2)); - } - -@@ -524,11 +524,11 @@ CAMLprim value caml_int64_format(value fmt, value arg) - CAMLprim value caml_int64_of_string(value s) - { - char * p; -- uint64 res, threshold; -+ uint64_t res, threshold; - int sign, base, d; - - p = parse_sign_and_base(String_val(s), &base, &sign); -- threshold = ((uint64) -1) / base; -+ threshold = ((uint64_t) -1) / base; - d = parse_digit(*p); - if (d < 0 || d >= base) caml_failwith("int_of_string"); - res = d; -@@ -541,7 +541,7 @@ CAMLprim value caml_int64_of_string(value s) - if (res > threshold) caml_failwith("int_of_string"); - res = base * res + d; - /* Detect overflow in addition (base * res) + d */ -- if (res < (uint64) d) caml_failwith("int_of_string"); -+ if (res < (uint64_t) d) caml_failwith("int_of_string"); - } - if (p != String_val(s) + caml_string_length(s)){ - caml_failwith("int_of_string"); -@@ -549,9 +549,9 @@ CAMLprim value caml_int64_of_string(value s) - if (base == 10) { - /* Signed representation expected, allow -2^63 to 2^63 - 1 only */ - if (sign >= 0) { -- if (res >= (uint64)1 << 63) caml_failwith("int_of_string"); -+ if (res >= (uint64_t)1 << 63) caml_failwith("int_of_string"); - } else { -- if (res > (uint64)1 << 63) caml_failwith("int_of_string"); -+ if (res > (uint64_t)1 << 63) caml_failwith("int_of_string"); - } - } - if (sign < 0) res = - res; -@@ -560,20 +560,20 @@ CAMLprim value caml_int64_of_string(value s) - - CAMLprim value caml_int64_bits_of_float(value vd) - { -- union { double d; int64 i; int32 h[2]; } u; -+ union { double d; int64_t i; int32_t h[2]; } u; - u.d = Double_val(vd); - #if defined(__arm__) && !defined(__ARM_EABI__) -- { int32 t = u.h[0]; u.h[0] = u.h[1]; u.h[1] = t; } -+ { int32_t t = u.h[0]; u.h[0] = u.h[1]; u.h[1] = t; } - #endif - return caml_copy_int64(u.i); - } - - CAMLprim value caml_int64_float_of_bits(value vi) - { -- union { double d; int64 i; int32 h[2]; } u; -+ union { double d; int64_t i; int32_t h[2]; } u; - u.i = Int64_val(vi); - #if defined(__arm__) && !defined(__ARM_EABI__) -- { int32 t = u.h[0]; u.h[0] = u.h[1]; u.h[1] = t; } -+ { int32_t t = u.h[0]; u.h[0] = u.h[1]; u.h[1] = t; } - #endif - return caml_copy_double(u.d); - } -@@ -606,7 +606,7 @@ static void nativeint_serialize(value v, uintnat * wsize_32, - #ifdef ARCH_SIXTYFOUR - if (l >= -((intnat)1 << 31) && l < ((intnat)1 << 31)) { - caml_serialize_int_1(1); -- caml_serialize_int_4((int32) l); -+ caml_serialize_int_4((int32_t) l); - } else { - caml_serialize_int_1(2); - caml_serialize_int_8(l); -diff --git a/byterun/io.c b/byterun/io.c -index 5f04a96..bedc0f0 100644 ---- a/byterun/io.c -+++ b/byterun/io.c -@@ -207,7 +207,7 @@ CAMLexport void caml_flush(struct channel *channel) - - /* Output data */ - --CAMLexport void caml_putword(struct channel *channel, uint32 w) -+CAMLexport void caml_putword(struct channel *channel, uint32_t w) - { - if (! caml_channel_binary_mode(channel)) - caml_failwith("output_binary_int: not a binary channel"); -@@ -303,10 +303,10 @@ CAMLexport unsigned char caml_refill(struct channel *channel) - return (unsigned char)(channel->buff[0]); - } - --CAMLexport uint32 caml_getword(struct channel *channel) -+CAMLexport uint32_t caml_getword(struct channel *channel) - { - int i; -- uint32 res; -+ uint32_t res; - - if (! caml_channel_binary_mode(channel)) - caml_failwith("input_binary_int: not a binary channel"); -diff --git a/byterun/io.h b/byterun/io.h -index 64a8bf5..5a9c037 100644 ---- a/byterun/io.h -+++ b/byterun/io.h -@@ -78,12 +78,12 @@ CAMLextern value caml_alloc_channel(struct channel *chan); - - CAMLextern int caml_flush_partial (struct channel *); - CAMLextern void caml_flush (struct channel *); --CAMLextern void caml_putword (struct channel *, uint32); -+CAMLextern void caml_putword (struct channel *, uint32_t); - CAMLextern int caml_putblock (struct channel *, char *, intnat); - CAMLextern void caml_really_putblock (struct channel *, char *, intnat); - - CAMLextern unsigned char caml_refill (struct channel *); --CAMLextern uint32 caml_getword (struct channel *); -+CAMLextern uint32_t caml_getword (struct channel *); - CAMLextern int caml_getblock (struct channel *, char *, intnat); - CAMLextern int caml_really_getblock (struct channel *, char *, intnat); - -@@ -107,7 +107,7 @@ CAMLextern struct channel * caml_all_opened_channels; - #define Unlock_exn() \ - if (caml_channel_mutex_unlock_exn != NULL) (*caml_channel_mutex_unlock_exn)() - --/* Conversion between file_offset and int64 */ -+/* Conversion between file_offset and int64_t */ - - #define Val_file_offset(fofs) caml_copy_int64(fofs) - #define File_offset_val(v) ((file_offset) Int64_val(v)) -diff --git a/byterun/md5.c b/byterun/md5.c -index 10ac76a..2dc90a2 100644 ---- a/byterun/md5.c -+++ b/byterun/md5.c -@@ -97,11 +97,11 @@ CAMLexport void caml_md5_block(unsigned char digest[16], - #else - static void byteReverse(unsigned char * buf, unsigned longs) - { -- uint32 t; -+ uint32_t t; - do { -- t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | -+ t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); -- *(uint32 *) buf = t; -+ *(uint32_t *) buf = t; - buf += 4; - } while (--longs); - } -@@ -129,12 +129,12 @@ CAMLexport void caml_MD5Init(struct MD5Context *ctx) - CAMLexport void caml_MD5Update(struct MD5Context *ctx, unsigned char *buf, - uintnat len) - { -- uint32 t; -+ uint32_t t; - - /* Update bitcount */ - - t = ctx->bits[0]; -- if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) -+ if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - -@@ -152,7 +152,7 @@ CAMLexport void caml_MD5Update(struct MD5Context *ctx, unsigned char *buf, - } - memcpy(p, buf, t); - byteReverse(ctx->in, 16); -- caml_MD5Transform(ctx->buf, (uint32 *) ctx->in); -+ caml_MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += t; - len -= t; - } -@@ -161,7 +161,7 @@ CAMLexport void caml_MD5Update(struct MD5Context *ctx, unsigned char *buf, - while (len >= 64) { - memcpy(ctx->in, buf, 64); - byteReverse(ctx->in, 16); -- caml_MD5Transform(ctx->buf, (uint32 *) ctx->in); -+ caml_MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += 64; - len -= 64; - } -@@ -196,7 +196,7 @@ CAMLexport void caml_MD5Final(unsigned char *digest, struct MD5Context *ctx) - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); -- caml_MD5Transform(ctx->buf, (uint32 *) ctx->in); -+ caml_MD5Transform(ctx->buf, (uint32_t *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); -@@ -207,10 +207,10 @@ CAMLexport void caml_MD5Final(unsigned char *digest, struct MD5Context *ctx) - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ -- ((uint32 *) ctx->in)[14] = ctx->bits[0]; -- ((uint32 *) ctx->in)[15] = ctx->bits[1]; -+ ((uint32_t *) ctx->in)[14] = ctx->bits[0]; -+ ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - -- caml_MD5Transform(ctx->buf, (uint32 *) ctx->in); -+ caml_MD5Transform(ctx->buf, (uint32_t *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ -@@ -233,9 +233,9 @@ CAMLexport void caml_MD5Final(unsigned char *digest, struct MD5Context *ctx) - * reflect the addition of 16 longwords of new data. caml_MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ --CAMLexport void caml_MD5Transform(uint32 *buf, uint32 *in) -+CAMLexport void caml_MD5Transform(uint32_t *buf, uint32_t *in) - { -- register uint32 a, b, c, d; -+ register uint32_t a, b, c, d; - - a = buf[0]; - b = buf[1]; -diff --git a/byterun/md5.h b/byterun/md5.h -index d8aff09..f63667d 100644 ---- a/byterun/md5.h -+++ b/byterun/md5.h -@@ -26,8 +26,8 @@ CAMLextern void caml_md5_block(unsigned char digest[16], - void * data, uintnat len); - - struct MD5Context { -- uint32 buf[4]; -- uint32 bits[2]; -+ uint32_t buf[4]; -+ uint32_t bits[2]; - unsigned char in[64]; - }; - -@@ -35,7 +35,7 @@ CAMLextern void caml_MD5Init (struct MD5Context *context); - CAMLextern void caml_MD5Update (struct MD5Context *context, unsigned char *buf, - uintnat len); - CAMLextern void caml_MD5Final (unsigned char *digest, struct MD5Context *ctx); --CAMLextern void caml_MD5Transform (uint32 *buf, uint32 *in); -+CAMLextern void caml_MD5Transform (uint32_t *buf, uint32_t *in); - - - #endif /* CAML_MD5_H */ -diff --git a/byterun/mlvalues.h b/byterun/mlvalues.h -index 268bcfe..a08948e 100644 ---- a/byterun/mlvalues.h -+++ b/byterun/mlvalues.h -@@ -38,8 +38,8 @@ extern "C" { - bp: Pointer to the first byte of a block. (a char *) - op: Pointer to the first field of a block. (a value *) - hp: Pointer to the header of a block. (a char *) -- int32: Four bytes on all architectures. -- int64: Eight bytes on all architectures. -+ int32_t: Four bytes on all architectures. -+ int64_t: Eight bytes on all architectures. - - Remark: A block size is always a multiple of the word size, and at least - one word plus the header. -@@ -161,7 +161,7 @@ bits 63 10 9 8 7 0 - /* Fields are numbered from 0. */ - #define Field(x, i) (((value *)(x)) [i]) /* Also an l-value. */ - --typedef int32 opcode_t; -+typedef int32_t opcode_t; - typedef opcode_t * code_t; - - /* NOTE: [Forward_tag] and [Infix_tag] must be just under -@@ -262,12 +262,12 @@ struct custom_operations; /* defined in [custom.h] */ - - /* Int32.t, Int64.t and Nativeint.t are represented as custom blocks. */ - --#define Int32_val(v) (*((int32 *) Data_custom_val(v))) -+#define Int32_val(v) (*((int32_t *) Data_custom_val(v))) - #define Nativeint_val(v) (*((intnat *) Data_custom_val(v))) - #ifndef ARCH_ALIGN_INT64 --#define Int64_val(v) (*((int64 *) Data_custom_val(v))) -+#define Int64_val(v) (*((int64_t *) Data_custom_val(v))) - #else --CAMLextern int64 caml_Int64_val(value v); -+CAMLextern int64_t caml_Int64_val(value v); - #define Int64_val(v) caml_Int64_val(v) - #endif - -diff --git a/byterun/startup.c b/byterun/startup.c -index 3697220..ab926ef 100644 ---- a/byterun/startup.c -+++ b/byterun/startup.c -@@ -79,7 +79,7 @@ static void init_atoms(void) - - /* Read the trailer of a bytecode file */ - --static void fixup_endianness_trailer(uint32 * p) -+static void fixup_endianness_trailer(uint32_t * p) - { - #ifndef ARCH_BIG_ENDIAN - Reverse_32(p, p); -@@ -153,7 +153,7 @@ void caml_read_section_descriptors(int fd, struct exec_trailer *trail) - Return the length of the section data in bytes, or -1 if no section - found with that name. */ - --int32 caml_seek_optional_section(int fd, struct exec_trailer *trail, char *name) -+int32_t caml_seek_optional_section(int fd, struct exec_trailer *trail, char *name) - { - long ofs; - int i; -@@ -172,9 +172,9 @@ int32 caml_seek_optional_section(int fd, struct exec_trailer *trail, char *name) - /* Position fd at the beginning of the section having the given name. - Return the length of the section data in bytes. */ - --int32 caml_seek_section(int fd, struct exec_trailer *trail, char *name) -+int32_t caml_seek_section(int fd, struct exec_trailer *trail, char *name) - { -- int32 len = caml_seek_optional_section(fd, trail, name); -+ int32_t len = caml_seek_optional_section(fd, trail, name); - if (len == -1) - caml_fatal_error_arg("Fatal_error: section `%s' is missing\n", name); - return len; -@@ -185,7 +185,7 @@ int32 caml_seek_section(int fd, struct exec_trailer *trail, char *name) - - static char * read_section(int fd, struct exec_trailer *trail, char *name) - { -- int32 len; -+ int32_t len; - char * data; - - len = caml_seek_optional_section(fd, trail, name); -diff --git a/byterun/startup.h b/byterun/startup.h -index 3dda64b..3268d88 100644 ---- a/byterun/startup.h -+++ b/byterun/startup.h -@@ -30,9 +30,9 @@ enum { FILE_NOT_FOUND = -1, BAD_BYTECODE = -2 }; - extern int caml_attempt_open(char **name, struct exec_trailer *trail, - int do_open_script); - extern void caml_read_section_descriptors(int fd, struct exec_trailer *trail); --extern int32 caml_seek_optional_section(int fd, struct exec_trailer *trail, -+extern int32_t caml_seek_optional_section(int fd, struct exec_trailer *trail, - char *name); --extern int32 caml_seek_section(int fd, struct exec_trailer *trail, char *name); -+extern int32_t caml_seek_section(int fd, struct exec_trailer *trail, char *name); - - - #endif /* CAML_STARTUP_H */ -diff --git a/byterun/str.c b/byterun/str.c -index 6effa91..9c7baa1 100644 ---- a/byterun/str.c -+++ b/byterun/str.c -@@ -101,7 +101,7 @@ CAMLprim value caml_string_get32(value str, value index) - - CAMLprim value caml_string_get64(value str, value index) - { -- uint64 res; -+ uint64_t res; - unsigned char b1, b2, b3, b4, b5, b6, b7, b8; - intnat idx = Long_val(index); - if (idx < 0 || idx + 7 >= caml_string_length(str)) caml_array_bound_error(); -@@ -114,15 +114,15 @@ CAMLprim value caml_string_get64(value str, value index) - b7 = Byte_u(str, idx + 6); - b8 = Byte_u(str, idx + 7); - #ifdef ARCH_BIG_ENDIAN -- res = (uint64) b1 << 56 | (uint64) b2 << 48 -- | (uint64) b3 << 40 | (uint64) b4 << 32 -- | (uint64) b5 << 24 | (uint64) b6 << 16 -- | (uint64) b7 << 8 | (uint64) b8; -+ res = (uint64_t) b1 << 56 | (uint64_t) b2 << 48 -+ | (uint64_t) b3 << 40 | (uint64_t) b4 << 32 -+ | (uint64_t) b5 << 24 | (uint64_t) b6 << 16 -+ | (uint64_t) b7 << 8 | (uint64_t) b8; - #else -- res = (uint64) b8 << 56 | (uint64) b7 << 48 -- | (uint64) b6 << 40 | (uint64) b5 << 32 -- | (uint64) b4 << 24 | (uint64) b3 << 16 -- | (uint64) b2 << 8 | (uint64) b1; -+ res = (uint64_t) b8 << 56 | (uint64_t) b7 << 48 -+ | (uint64_t) b6 << 40 | (uint64_t) b5 << 32 -+ | (uint64_t) b4 << 24 | (uint64_t) b3 << 16 -+ | (uint64_t) b2 << 8 | (uint64_t) b1; - #endif - return caml_copy_int64(res); - } -@@ -174,7 +174,7 @@ CAMLprim value caml_string_set32(value str, value index, value newval) - CAMLprim value caml_string_set64(value str, value index, value newval) - { - unsigned char b1, b2, b3, b4, b5, b6, b7, b8; -- int64 val; -+ int64_t val; - intnat idx = Long_val(index); - if (idx < 0 || idx + 7 >= caml_string_length(str)) caml_array_bound_error(); - val = Int64_val(newval); -diff --git a/config/auto-aux/int64align.c b/config/auto-aux/int64align.c -index 5795e48..c143986 100644 ---- a/config/auto-aux/int64align.c -+++ b/config/auto-aux/int64align.c -@@ -17,18 +17,18 @@ - #include "m.h" - - #if defined(ARCH_INT64_TYPE) --typedef ARCH_INT64_TYPE int64; -+typedef ARCH_INT64_TYPE int64_t; - #elif SIZEOF_LONG == 8 --typedef long int64; -+typedef long int64_t; - #elif SIZEOF_LONGLONG == 8 --typedef long long int64; -+typedef long long int64_t; - #else - #error "No 64-bit integer type available" - #endif - --int64 foo; -+int64_t foo; - --void access_int64(int64 *p) -+void access_int64(int64_t *p) - { - foo = *p; - } -@@ -49,8 +49,8 @@ int main(void) - signal(SIGBUS, sig_handler); - #endif - if(setjmp(failure) == 0) { -- access_int64((int64 *) n); -- access_int64((int64 *) (n+1)); -+ access_int64((int64_t *) n); -+ access_int64((int64_t *) (n+1)); - res = 0; - } else { - res = 1; -diff --git a/config/s-nt.h b/config/s-nt.h -index 6df440b..603b050 100644 ---- a/config/s-nt.h -+++ b/config/s-nt.h -@@ -15,6 +15,9 @@ - - #define OCAML_OS_TYPE "Win32" - -+#ifdef __MINGW32__ -+#define HAS_STDINT_H -+#endif - #undef BSD_SIGNALS - #define HAS_STRERROR - #define HAS_SOCKETS -diff --git a/configure b/configure -index 0bf4ebd..8a9be78 100755 ---- a/configure -+++ b/configure -@@ -615,26 +615,6 @@ case "$target" in - esac - esac - --# Check semantics of division and modulus -- --sh ./runtest divmod.c --case $? in -- 0) inf "Native division and modulus have round-towards-zero semantics," \ -- "will use them." -- echo "#undef NONSTANDARD_DIV_MOD" >> m.h;; -- 1) inf "Native division and modulus do not have round-towards-zero" -- "semantics, will use software emulation." -- echo "#define NONSTANDARD_DIV_MOD" >> m.h;; -- *) case $target in -- *-*-mingw*) inf "Native division and modulus have round-towards-zero" \ -- "semantics, will use them." -- echo "#undef NONSTANDARD_DIV_MOD" >> m.h;; -- *) wrn "Something went wrong while checking native division and modulus"\ -- "please report it at http://http://caml.inria.fr/mantis/" -- echo "#define NONSTANDARD_DIV_MOD" >> m.h;; -- esac;; --esac -- - # Shared library support - - shared_libraries_supported=false -@@ -1085,6 +1065,11 @@ if sh ./hasgot -i sys/types.h -i sys/socket.h -i netinet/in.h \ - echo "#define HAS_IPV6" >> s.h - fi - -+if sh ./hasgot -i stdint.h; then -+ inf "stdint.h found." -+ echo "#define HAS_STDINT_H" >> s.h -+fi -+ - if sh ./hasgot -i unistd.h; then - inf "unistd.h found." - echo "#define HAS_UNISTD" >> s.h -diff --git a/otherlibs/bigarray/bigarray_stubs.c b/otherlibs/bigarray/bigarray_stubs.c -index 7e63cbf..f2ccb92 100644 ---- a/otherlibs/bigarray/bigarray_stubs.c -+++ b/otherlibs/bigarray/bigarray_stubs.c -@@ -279,9 +279,9 @@ value caml_ba_get_N(value vb, value * vind, int nind) - case CAML_BA_UINT16: - return Val_int(((uint16 *) b->data)[offset]); - case CAML_BA_INT32: -- return caml_copy_int32(((int32 *) b->data)[offset]); -+ return caml_copy_int32(((int32_t *) b->data)[offset]); - case CAML_BA_INT64: -- return caml_copy_int64(((int64 *) b->data)[offset]); -+ return caml_copy_int64(((int64_t *) b->data)[offset]); - case CAML_BA_NATIVE_INT: - return caml_copy_nativeint(((intnat *) b->data)[offset]); - case CAML_BA_CAML_INT: -@@ -388,7 +388,7 @@ CAMLprim value caml_ba_uint8_get32(value vb, value vind) - - CAMLprim value caml_ba_uint8_get64(value vb, value vind) - { -- uint64 res; -+ uint64_t res; - unsigned char b1, b2, b3, b4, b5, b6, b7, b8; - intnat idx = Long_val(vind); - struct caml_ba_array * b = Caml_ba_array_val(vb); -@@ -402,15 +402,15 @@ CAMLprim value caml_ba_uint8_get64(value vb, value vind) - b7 = ((unsigned char*) b->data)[idx+6]; - b8 = ((unsigned char*) b->data)[idx+7]; - #ifdef ARCH_BIG_ENDIAN -- res = (uint64) b1 << 56 | (uint64) b2 << 48 -- | (uint64) b3 << 40 | (uint64) b4 << 32 -- | (uint64) b5 << 24 | (uint64) b6 << 16 -- | (uint64) b7 << 8 | (uint64) b8; -+ res = (uint64_t) b1 << 56 | (uint64_t) b2 << 48 -+ | (uint64_t) b3 << 40 | (uint64_t) b4 << 32 -+ | (uint64_t) b5 << 24 | (uint64_t) b6 << 16 -+ | (uint64_t) b7 << 8 | (uint64_t) b8; - #else -- res = (uint64) b8 << 56 | (uint64) b7 << 48 -- | (uint64) b6 << 40 | (uint64) b5 << 32 -- | (uint64) b4 << 24 | (uint64) b3 << 16 -- | (uint64) b2 << 8 | (uint64) b1; -+ res = (uint64_t) b8 << 56 | (uint64_t) b7 << 48 -+ | (uint64_t) b6 << 40 | (uint64_t) b5 << 32 -+ | (uint64_t) b4 << 24 | (uint64_t) b3 << 16 -+ | (uint64_t) b2 << 8 | (uint64_t) b1; - #endif - return caml_copy_int64(res); - } -@@ -447,9 +447,9 @@ static value caml_ba_set_aux(value vb, value * vind, intnat nind, value newval) - case CAML_BA_UINT16: - ((int16 *) b->data)[offset] = Int_val(newval); break; - case CAML_BA_INT32: -- ((int32 *) b->data)[offset] = Int32_val(newval); break; -+ ((int32_t *) b->data)[offset] = Int32_val(newval); break; - case CAML_BA_INT64: -- ((int64 *) b->data)[offset] = Int64_val(newval); break; -+ ((int64_t *) b->data)[offset] = Int64_val(newval); break; - case CAML_BA_NATIVE_INT: - ((intnat *) b->data)[offset] = Nativeint_val(newval); break; - case CAML_BA_CAML_INT: -@@ -577,7 +577,7 @@ CAMLprim value caml_ba_uint8_set64(value vb, value vind, value newval) - { - unsigned char b1, b2, b3, b4, b5, b6, b7, b8; - intnat idx = Long_val(vind); -- int64 val; -+ int64_t val; - struct caml_ba_array * b = Caml_ba_array_val(vb); - if (idx < 0 || idx >= b->dim[0] - 7) caml_array_bound_error(); - val = Int64_val(newval); -@@ -760,9 +760,9 @@ static int caml_ba_compare(value v1, value v2) - case CAML_BA_UINT16: - DO_INTEGER_COMPARISON(uint16); - case CAML_BA_INT32: -- DO_INTEGER_COMPARISON(int32); -+ DO_INTEGER_COMPARISON(int32_t); - case CAML_BA_INT64: -- DO_INTEGER_COMPARISON(int64); -+ DO_INTEGER_COMPARISON(int64_t); - case CAML_BA_CAML_INT: - case CAML_BA_NATIVE_INT: - DO_INTEGER_COMPARISON(intnat); -@@ -780,7 +780,7 @@ static intnat caml_ba_hash(value v) - { - struct caml_ba_array * b = Caml_ba_array_val(v); - intnat num_elts, n; -- uint32 h, w; -+ uint32_t h, w; - int i; - - num_elts = 1; -@@ -820,7 +820,7 @@ static intnat caml_ba_hash(value v) - } - case CAML_BA_INT32: - { -- uint32 * p = b->data; -+ uint32_t * p = b->data; - if (num_elts > 64) num_elts = 64; - for (n = 0; n < num_elts; n++, p++) h = caml_hash_mix_uint32(h, *p); - break; -@@ -835,7 +835,7 @@ static intnat caml_ba_hash(value v) - } - case CAML_BA_INT64: - { -- int64 * p = b->data; -+ int64_t * p = b->data; - if (num_elts > 32) num_elts = 32; - for (n = 0; n < num_elts; n++, p++) h = caml_hash_mix_int64(h, *p); - break; -@@ -878,7 +878,7 @@ static void caml_ba_serialize_longarray(void * data, - } else { - caml_serialize_int_1(0); - for (n = 0, p = data; n < num_elts; n++, p++) -- caml_serialize_int_4((int32) *p); -+ caml_serialize_int_4((int32_t) *p); - } - #else - caml_serialize_int_1(0); -@@ -1181,14 +1181,14 @@ CAMLprim value caml_ba_fill(value vb, value vinit) - break; - } - case CAML_BA_INT32: { -- int32 init = Int32_val(vinit); -- int32 * p; -+ int32_t init = Int32_val(vinit); -+ int32_t * p; - for (p = b->data; num_elts > 0; p++, num_elts--) *p = init; - break; - } - case CAML_BA_INT64: { -- int64 init = Int64_val(vinit); -- int64 * p; -+ int64_t init = Int64_val(vinit); -+ int64_t * p; - for (p = b->data; num_elts > 0; p++, num_elts--) *p = init; - break; - } -diff --git a/otherlibs/num/nat_stubs.c b/otherlibs/num/nat_stubs.c -index 9a62759..d718a05 100644 ---- a/otherlibs/num/nat_stubs.c -+++ b/otherlibs/num/nat_stubs.c -@@ -347,9 +347,9 @@ static void serialize_nat(value nat, - if (len >= ((mlsize_t)1 << 32)) - failwith("output_value: nat too big"); - #endif -- serialize_int_4((int32) len); -+ serialize_int_4((int32_t) len); - #if defined(ARCH_SIXTYFOUR) && defined(ARCH_BIG_ENDIAN) -- { int32 * p; -+ { int32_t * p; - mlsize_t i; - for (i = len, p = Data_custom_val(nat); i > 0; i -= 2, p += 2) { - serialize_int_4(p[1]); /* low 32 bits of 64-bit digit */ -@@ -369,7 +369,7 @@ static uintnat deserialize_nat(void * dst) - - len = deserialize_uint_4(); - #if defined(ARCH_SIXTYFOUR) && defined(ARCH_BIG_ENDIAN) -- { uint32 * p; -+ { uint32_t * p; - mlsize_t i; - for (i = len, p = dst; i > 1; i -= 2, p += 2) { - p[1] = deserialize_uint_4(); /* low 32 bits of 64-bit digit */ -@@ -385,7 +385,7 @@ static uintnat deserialize_nat(void * dst) - deserialize_block_4(dst, len); - #if defined(ARCH_SIXTYFOUR) - if (len & 1){ -- ((uint32 *) dst)[len] = 0; -+ ((uint32_t *) dst)[len] = 0; - ++ len; - } - #endif -@@ -396,7 +396,7 @@ static uintnat deserialize_nat(void * dst) - static intnat hash_nat(value v) - { - bngsize len, i; -- uint32 h; -+ uint32_t h; - - len = bng_num_digits(&Digit_val(v,0), Wosize_val(v) - 1); - h = 0; -@@ -406,10 +406,10 @@ static intnat hash_nat(value v) - /* Mix the two 32-bit halves as if we were on a 32-bit platform, - namely low 32 bits first, then high 32 bits. - Also, ignore final 32 bits if they are zero. */ -- h = caml_hash_mix_uint32(h, (uint32) d); -+ h = caml_hash_mix_uint32(h, (uint32_t) d); - d = d >> 32; - if (d == 0 && i + 1 == len) break; -- h = caml_hash_mix_uint32(h, (uint32) d); -+ h = caml_hash_mix_uint32(h, (uint32_t) d); - #else - h = caml_hash_mix_uint32(h, d); - #endif -diff --git a/otherlibs/unix/addrofstr.c b/otherlibs/unix/addrofstr.c -index e17841f..a2830ba 100644 ---- a/otherlibs/unix/addrofstr.c -+++ b/otherlibs/unix/addrofstr.c -@@ -73,7 +73,7 @@ CAMLprim value unix_inet_addr_of_string(value s) - #else - struct in_addr address; - address.s_addr = inet_addr(String_val(s)); -- if (address.s_addr == (uint32) -1) failwith("inet_addr_of_string"); -+ if (address.s_addr == (uint32_t) -1) failwith("inet_addr_of_string"); - return alloc_inet_addr(&address); - #endif - } -diff --git a/stdlib/header.c b/stdlib/header.c -index cb3d995..93cdfeb 100644 ---- a/stdlib/header.c -+++ b/stdlib/header.c -@@ -133,7 +133,7 @@ static char * read_runtime_path(int fd) - char buffer[TRAILER_SIZE]; - static char runtime_path[MAXPATHLEN]; - int num_sections, i; -- uint32 path_size; -+ uint32_t path_size; - long ofs; - - lseek(fd, (long) -TRAILER_SIZE, SEEK_END); --- -2.0.4 - diff --git a/programming/language/ocaml/ocaml/pspec.xml b/programming/language/ocaml/ocaml/pspec.xml index d90fbeca8c..77ac321be5 100644 --- a/programming/language/ocaml/ocaml/pspec.xml +++ b/programming/language/ocaml/ocaml/pspec.xml @@ -26,14 +26,16 @@ chrpath - fedora/0001-Don-t-ignore-.-configure-it-s-a-real-git-file.patch - fedora/0002-Ensure-empty-compilerlibs-directory-is-created-by-gi.patch - fedora/0003-Don-t-add-rpaths-to-libraries.patch - fedora/0004-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch - fedora/0005-configure-Allow-user-defined-C-compiler-flags.patch - fedora/0009-arg-Add-no_arg-and-get_arg-helper-functions.patch - fedora/0010-arg-Allow-flags-such-as-flag-arg-as-well-as-flag-arg.patch - fedora/0011-PR-6517-use-ISO-C99-types-u-int-32-64-_t-in-preferen.patch + fedora/0001-Don-t-add-rpaths-to-libraries.patch + fedora/0002-ocamlbyteinfo-ocamlplugininfo-Useful-utilities-from-.patch + fedora/0003-configure-Allow-user-defined-C-compiler-flags.patch + fedora/0004-Don-t-rewrite-Werror.patch + fedora/0005-PR-7405-s390x-Fix-address-of-caml_raise_exn-in-nativ.patch + fedora/0006-Adapt-config.guess-for-RISC-V.patch + fedora/0007-Add-RISC-V-backend-runtime.patch + fedora/0008-Try-fix-for-andi-ori-xori-immediates-1.patch + fedora/0009-Fix-immediates-range-when-adjusting-indexing-sp.patch + fedora/0010-Another-immediate-range-fix.patch