From: rich Date: Tue, 31 Oct 2006 14:39:50 +0000 (+0000) Subject: Fix to work against OCaml 3.08.3. X-Git-Tag: 0.9.0~8 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=d636bf12b0e8a8d6c7f9ad96d24984c24a145930;p=ocaml-ancient.git Fix to work against OCaml 3.08.3. --- diff --git a/MANIFEST b/MANIFEST index d5b0530..d8abd7a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -35,6 +35,7 @@ mmalloc/mrealloc.c mmalloc/mvalloc.c mmalloc/sbrk-sup.c mmalloc/TODO +ocaml_version.ml README.txt test_ancient_dict_read.ml test_ancient_dict_verify.ml diff --git a/Makefile b/Makefile index e51ff2f..41c3cee 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ # Mark objects as 'ancient' so they are taken out of the OCaml heap. -# $Id: Makefile,v 1.8 2006-10-06 15:03:47 rich Exp $ +# $Id: Makefile,v 1.9 2006-10-31 14:39:50 rich Exp $ include Makefile.config CC := gcc -CFLAGS := -g -fPIC -Wall -Werror +CFLAGS := -g -fPIC -Wall -Werror \ + -DOCAML_VERSION_MAJOR=$(OCAML_VERSION_MAJOR) \ + -DOCAML_VERSION_MINOR=$(OCAML_VERSION_MINOR) OCAMLCFLAGS := -g OCAMLCPACKAGES := -package unix diff --git a/Makefile.config b/Makefile.config index 7940423..4188bfb 100644 --- a/Makefile.config +++ b/Makefile.config @@ -1,5 +1,8 @@ # Mark objects as 'ancient' so they are taken out of the OCaml heap. -# $Id: Makefile.config,v 1.7 2006-10-13 15:12:41 rich Exp $ +# $Id: Makefile.config,v 1.8 2006-10-31 14:39:50 rich Exp $ PACKAGE := ancient VERSION := 0.8.0 + +OCAML_VERSION_MAJOR := $(shell ocaml ocaml_version.ml major) +OCAML_VERSION_MINOR := $(shell ocaml ocaml_version.ml minor) diff --git a/ancient_c.c b/ancient_c.c index ea2ca55..8a4e914 100644 --- a/ancient_c.c +++ b/ancient_c.c @@ -1,5 +1,5 @@ /* Mark objects as 'ancient' so they are taken out of the OCaml heap. - * $Id: ancient_c.c,v 1.10 2006-10-13 12:28:20 rich Exp $ + * $Id: ancient_c.c,v 1.11 2006-10-31 14:39:50 rich Exp $ */ #include @@ -13,10 +13,16 @@ #include "mmalloc/mmalloc.h" +// uintnat, intnat only appeared in Caml 3.09.x. +#if OCAML_VERSION_MAJOR == 3 && OCAML_VERSION_MINOR < 9 +typedef unsigned long uintnat; +typedef long intnat; +#endif + // From byterun/misc.h: typedef char * addr; -// From byterun/minor_gc.c: +// From byterun/minor_gc.h: CAMLextern char *caml_young_start; CAMLextern char *caml_young_end; #define Is_young(val) \ diff --git a/ocaml_version.ml b/ocaml_version.ml new file mode 100644 index 0000000..3367f93 --- /dev/null +++ b/ocaml_version.ml @@ -0,0 +1,25 @@ +(* Get the major or minor part of the OCaml version string. + * This doesn't seem t be present in header files (at least not in 3.08.x). + * $Id: ocaml_version.ml,v 1.1 2006-10-31 14:39:50 rich Exp $ + *) +type t = Major | Minor +let usage () = failwith "ocaml_version major|minor" +let t = + if Array.length Sys.argv < 2 then + usage () + else match Sys.argv.(1) with + | "major" -> Major + | "minor" -> Minor + | _ -> usage () +let ocaml_version = Sys.ocaml_version +let i = String.index ocaml_version '.' +let s = + match t with + | Major -> String.sub ocaml_version 0 i + | Minor -> + let j = + try String.index_from ocaml_version (i+1) '.' + with Not_found -> String.length ocaml_version in + String.sub ocaml_version (i+1) (j-i-1) +let s = string_of_int (int_of_string s) ;; +print_endline s