diff options
-rw-r--r-- | otherlibs/graph/Makefile | 6 | ||||
-rw-r--r-- | otherlibs/graph/Makefile.nt | 5 | ||||
-rw-r--r-- | otherlibs/graph/graphics.ml (renamed from otherlibs/graph/graphics.mlp) | 28 | ||||
-rw-r--r-- | otherlibs/num/Makefile | 12 | ||||
-rw-r--r-- | otherlibs/num/Makefile.nt | 8 | ||||
-rw-r--r-- | otherlibs/num/int_misc.ml (renamed from otherlibs/num/int_misc.mlp) | 11 | ||||
-rw-r--r-- | otherlibs/num/nat.ml (renamed from otherlibs/num/nat.mlp) | 59 |
7 files changed, 55 insertions, 74 deletions
diff --git a/otherlibs/graph/Makefile b/otherlibs/graph/Makefile index ef707a497..1e1520560 100644 --- a/otherlibs/graph/Makefile +++ b/otherlibs/graph/Makefile @@ -23,12 +23,8 @@ libgraphics.a: $(OBJS) graphics.cma: graphics.cmo $(CAMLC) -a -o graphics.cma graphics.cmo -graphics.ml: graphics.mlp - $(CPP) -DUSE_ASYNC_IO graphics.mlp > graphics.ml - clean: rm -f *.cm* - rm -f graphics.ml realclean: clean rm -f *.a *.o @@ -49,7 +45,7 @@ installopt: .ml.cmx: $(CAMLOPT) -c $(COMPFLAGS) $< -depend: graphics.ml +depend: gcc -MM $(CFLAGS) *.c > .depend ../../tools/ocamldep *.mli *.ml >> .depend diff --git a/otherlibs/graph/Makefile.nt b/otherlibs/graph/Makefile.nt index e797470cd..5d011e794 100644 --- a/otherlibs/graph/Makefile.nt +++ b/otherlibs/graph/Makefile.nt @@ -9,9 +9,6 @@ all: graphics.cmi graphics.cmo allopt: -graphics.ml: graphics.mlp - $(CPP) graphics.mlp > graphics.ml - clean: rm -f *.cm* rm -f graphics.ml @@ -33,7 +30,7 @@ installopt: .ml.cmx: $(CAMLOPT) -c $(COMPFLAGS) $< -depend: graphics.ml +depend: ..\..\tools\ocamldep *.mli *.ml >> .depend !include .depend diff --git a/otherlibs/graph/graphics.mlp b/otherlibs/graph/graphics.ml index eafbd1f05..fa0a03463 100644 --- a/otherlibs/graph/graphics.mlp +++ b/otherlibs/graph/graphics.ml @@ -18,27 +18,33 @@ exception Graphic_failure of string external register_graphic_failure: exn -> unit = "gr_register_graphic_failure" let _ = register_graphic_failure(Graphic_failure "") -#ifdef USE_ASYNC_IO +let os_type = (Sys.get_config ()).Sys.os_type;; external raw_open_graph: string -> unit = "gr_open_graph" external raw_close_graph: unit -> unit = "gr_close_graph" external sigio_signal: unit -> int = "gr_sigio_signal" external sigio_handler: int -> unit = "gr_sigio_handler" -let open_graph arg = +let unix_open_graph arg = Sys.signal (sigio_signal()) (Sys.Signal_handle sigio_handler); raw_open_graph arg - -let close_graph () = +;; +let unix_close_graph () = Sys.signal (sigio_signal()) Sys.Signal_ignore; raw_close_graph () - -#else - -external open_graph: string -> unit = "gr_open_graph" -external close_graph: unit -> unit = "gr_close_graph" - -#endif +;; +let open_graph = + match os_type with + | "Unix" -> unix_open_graph + | "Win32" -> raw_open_graph + | "MacOS" -> raw_open_graph +;; +let close_graph = + match os_type with + | "Unix" -> unix_close_graph + | "Win32" -> raw_close_graph + | "MacOS" -> raw_close_graph +;; external clear_graph : unit -> unit = "gr_clear_graph" external size_x : unit -> int = "gr_size_x" diff --git a/otherlibs/num/Makefile b/otherlibs/num/Makefile index 00d34d102..7a8b123f4 100644 --- a/otherlibs/num/Makefile +++ b/otherlibs/num/Makefile @@ -49,11 +49,10 @@ clean: realclean: clean rm -f *.a *.o - rm -f nat.ml int_misc.ml cd bignum; $(MAKE) scratch cd test; $(MAKE) clean -.SUFFIXES: .ml .mli .mlp .cmi .cmo .cmx +.SUFFIXES: .ml .mli .cmi .cmo .cmx .mli.cmi: $(CAMLC) -c $(COMPFLAGS) $< @@ -64,16 +63,9 @@ realclean: clean .ml.cmx: $(CAMLOPT) -c $(COMPFLAGS) $< -.mlp.ml: - @rm -f $@ - $(CPP) $< > $@ - @chmod a-w $@ - -int_misc.ml: int_misc.mlp -nat.ml: nat.mlp nat_stubs.o: nat.h -depend: nat.ml int_misc.ml +depend: gcc -MM $(CFLAGS) *.c > .depend ../../tools/ocamldep *.mli *.ml >> .depend diff --git a/otherlibs/num/Makefile.nt b/otherlibs/num/Makefile.nt index 883d1598f..41ff6949f 100644 --- a/otherlibs/num/Makefile.nt +++ b/otherlibs/num/Makefile.nt @@ -45,11 +45,10 @@ clean: realclean: clean rm -f *.lib *.obj - rm -f nat.ml int_misc.ml cd bignum & $(MAKEREC) clean cd test & $(MAKEREC) clean -.SUFFIXES: .ml .mli .mlp .cmi .cmo .cmx +.SUFFIXES: .ml .mli .cmi .cmo .cmx .mli.cmi: $(CAMLC) -c $(COMPFLAGS) $< @@ -60,11 +59,6 @@ realclean: clean .ml.cmx: $(CAMLOPT) -c $(COMPFLAGS) $< -.mlp.ml: - $(CPP) $< > $@ - -int_misc.ml: int_misc.mlp -nat.ml: nat.mlp nat_stubs.obj: nat.h depend: diff --git a/otherlibs/num/int_misc.mlp b/otherlibs/num/int_misc.ml index de525800c..15b3a279e 100644 --- a/otherlibs/num/int_misc.mlp +++ b/otherlibs/num/int_misc.ml @@ -13,10 +13,6 @@ (* Some extra operations on integers *) -(* -#include "../../config/m.h" -*) - let rec gcd_int i1 i2 = if i2 = 0 then abs i1 else gcd_int i2 (i1 mod i2) ;; @@ -28,11 +24,8 @@ let num_bits_int n = num_bits_int_aux (abs n);; let sign_int i = if i = 0 then 0 else if i > 0 then 1 else -1;; -#ifdef SIXTYFOUR -let length_of_int = 62;; -#else -let length_of_int = 30;; -#endif +let length_of_int = (Sys.get_config()).Sys.word_size - 2;; + let monster_int = 1 lsl length_of_int;; let biggest_int = monster_int - 1;; let least_int = - biggest_int;; diff --git a/otherlibs/num/nat.mlp b/otherlibs/num/nat.ml index 12fc5c4af..43e6a03d8 100644 --- a/otherlibs/num/nat.mlp +++ b/otherlibs/num/nat.ml @@ -11,10 +11,6 @@ (* $Id$ *) -(* -#include "../../config/m.h" -*) - open Int_misc type nat;; @@ -48,11 +44,7 @@ external land_digit_nat: nat -> int -> nat -> int -> unit = "land_digit_nat" external lor_digit_nat: nat -> int -> nat -> int -> unit = "lor_digit_nat" external lxor_digit_nat: nat -> int -> nat -> int -> unit = "lxor_digit_nat" -#ifdef SIXTYFOUR -let length_of_digit = 64 -#else -let length_of_digit = 32 -#endif +let length_of_digit = (Sys.get_config ()).Sys.word_size;; let make_nat len = if len < 0 then invalid_arg "make_nat" else @@ -206,31 +198,42 @@ let sqrt_nat nat off len = done; candidate -let power_base_max = make_nat 2 - -#ifdef SIXTYFOUR -let _ = - set_digit_nat power_base_max 0 1000000000000000000; - mult_digit_nat power_base_max 0 2 - power_base_max 0 1 (nat_of_int 9) 0 -let pmax = 19 -#else -let _ = set_digit_nat power_base_max 0 1000000000 -let pmax = 9 -#endif +let power_base_max = make_nat 2;; + +match length_of_digit with + | 64 -> + set_digit_nat power_base_max 0 1000000000000000000; + mult_digit_nat power_base_max 0 2 + power_base_max 0 1 (nat_of_int 9) 0; + () + | 32 -> set_digit_nat power_base_max 0 1000000000 + | _ -> failwith "Nat.power_base_max: unknown word size" +;; + +let pmax = + match length_of_digit with + | 64 -> 19 + | 32 -> 9 + | _ -> failwith "Nat.pmax: unknown word size" +;; (* Nat temporaries *) let a_2 = make_nat 2 and a_1 = make_nat 1 and b_2 = make_nat 2 -#ifdef SIXTYFOUR -let max_superscript_10_power_in_int = 18 -let max_power_10_power_in_int = nat_of_int 1000000000000000000 -#else -let max_superscript_10_power_in_int = 9 -let max_power_10_power_in_int = nat_of_int 1000000000 -#endif +let max_superscript_10_power_in_int = + match length_of_digit with + | 64 -> 18 + | 32 -> 9 + | _ -> failwith "Nat.max_superscript_10_power_in_int: unknown word size" +;; +let max_power_10_power_in_int = + match length_of_digit with + | 64 -> nat_of_int 1000000000000000000 + | 32 -> nat_of_int 1000000000 + | _ -> failwith "Nat.max_power_10_power_in_int: unknown word size" +;; let raw_string_of_digit nat off = if is_nat_int nat off 1 |