From: rich Date: Sat, 11 Dec 2004 15:40:08 +0000 (+0000) Subject: Fix compiler flags so it compiles OK on all architectures. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=a2a35bac77bdc65f10538a31cc5bb105d3dcb533;p=perl4caml.git Fix compiler flags so it compiles OK on all architectures. --- diff --git a/Makefile b/Makefile index 9be234b..a92c178 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Interface to Perl from OCaml. # Copyright (C) 2003 Merjis Ltd. -# $Id: Makefile,v 1.27 2004-12-11 13:38:32 rich Exp $ +# $Id: Makefile,v 1.28 2004-12-11 15:40:08 rich Exp $ include Makefile.config @@ -16,8 +16,10 @@ OCAMLOPTINCS := $(OCAMLCINCS) OCAMLCFLAGS := -w s -g $(OCAMLCINCS) OCAMLOPTFLAGS := -w s $(OCAMLOPTINCS) +PERLCFLAGS := $(shell perl -e 'use Config; print $$Config{ccflags};') + CC := gcc -CFLAGS := -fPIC -Wall -Wno-unused -I$(PERLINCDIR) $(EXTRA_CFLAGS) +CFLAGS := -fPIC -Wall -Wno-unused -I$(PERLINCDIR) $(PERLCFLAGS) $(EXTRA_CFLAGS) LIBPERL := $(shell perl -MExtUtils::Embed -e ldopts) diff --git a/Makefile.config b/Makefile.config index bfb49d6..13e36ee 100644 --- a/Makefile.config +++ b/Makefile.config @@ -1,5 +1,5 @@ # perl4caml configuration -*- Makefile -*- -# $Id: Makefile.config,v 1.19 2004-12-11 13:38:32 rich Exp $ +# $Id: Makefile.config,v 1.20 2004-12-11 15:40:09 rich Exp $ # PERLINCDIR # Directory containing the Perl include files, eg. . @@ -28,8 +28,8 @@ OCAMLLIBDIR := $(shell ocamlc -where) EXTRA_CFLAGS := #EXTRA_CFLAGS := -DPERL4CAML_REFCOUNTING_EXPERIMENTAL=1 -#EXTRA_CFLAGS := -I/Users/rich/OCaml/lib/ocaml/std-lib -DPERL4CAML_NO_CRYPT_H \ - -DPERL4CAML_NO_OFF64_T +#EXTRA_CFLAGS := -I/Users/rich/OCaml/lib/ocaml/std-lib +#EXTRA_CFLAGS := -g # DYNALOADER_HACK # XXX Hack required by ocamlopt, and sometimes ocamlc. @@ -42,4 +42,4 @@ DYNALOADER_HACK := /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a # PACKAGE and VERSION PACKAGE := perl4caml -VERSION := 0.3.14 +VERSION := 0.3.15 diff --git a/perl_c.c b/perl_c.c index 3dea747..948de42 100644 --- a/perl_c.c +++ b/perl_c.c @@ -1,6 +1,6 @@ /* Interface to Perl from OCaml. * Copyright (C) 2003 Merjis Ltd. - * $Id: perl_c.c,v 1.18 2004-12-11 13:38:32 rich Exp $ + * $Id: perl_c.c,v 1.19 2004-12-11 15:40:09 rich Exp $ */ #include @@ -9,6 +9,8 @@ #include #include +#define CAML_NAME_SPACE 1 + #include #include #include @@ -16,19 +18,6 @@ #include #include -#ifndef PERL4CAML_NO_OFF64_T -/* XXX This was required to avoid an error on my machine when loading the Perl - * headers. Not clear why this is missing. - */ -#define off64_t __off64_t -#endif - -#ifndef PERL4CAML_NO_CRYPT_H -/* XXX This is required by Perl >= 5.8.2. */ -#define __USE_GNU -#include -#endif - #include #include @@ -85,13 +74,13 @@ perl4caml_init (value unit) { CAMLparam1 (unit); int argc = 4; - static char *argv[] = { "", "-w", "-e", "0" }; + static char *argv[] = { "", "-w", "-e", "0", NULL }; - PERL_SYS_INIT3 (NULL, NULL, NULL); + PERL_SYS_INIT (&argc, &argv); my_perl = perl_alloc (); perl_construct (my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; - perl_parse (my_perl, xs_init, argc, argv, NULL); + perl_parse (my_perl, xs_init, argc, argv, (char **) NULL); /*perl_run (my_perl);*/ CAMLreturn (Val_unit); @@ -118,7 +107,7 @@ perl4caml_float_of_sv (value svv) CAMLparam1 (svv); SV *sv = Sv_val (svv); CAMLlocal1 (f); - f = copy_double (SvNV (sv)); + f = caml_copy_double (SvNV (sv)); CAMLreturn (f); } @@ -139,7 +128,7 @@ perl4caml_string_of_sv (value svv) CAMLlocal1 (strv); str = SvPV (sv, len); /* XXX This won't work if the string contains NUL. */ - strv = copy_string (str); + strv = caml_copy_string (str); CAMLreturn (strv); } @@ -147,7 +136,7 @@ CAMLprim value perl4caml_sv_of_string (value strv) { CAMLparam1 (strv); - CAMLreturn (Val_sv (newSVpv (String_val (strv), string_length (strv)))); + CAMLreturn (Val_sv (newSVpv (String_val (strv), caml_string_length (strv)))); } CAMLprim value @@ -248,7 +237,7 @@ perl4caml_deref (value svv) SV *sv = Sv_val (svv); if (!SvROK (sv)) - invalid_argument ("deref: SV is not a reference"); + caml_invalid_argument ("deref: SV is not a reference"); switch (SvTYPE (SvRV (sv))) { case SVt_IV: case SVt_NV: @@ -257,7 +246,7 @@ perl4caml_deref (value svv) case SVt_PVMG: break; default: - invalid_argument ("deref: SV is not a reference to a scalar"); + caml_invalid_argument ("deref: SV is not a reference to a scalar"); } rsvv = Val_sv (SvRV (sv)); CAMLreturn (rsvv); @@ -271,12 +260,12 @@ perl4caml_deref_array (value svv) SV *sv = Sv_val (svv); if (!SvROK (sv)) - invalid_argument ("deref_array: SV is not a reference"); + caml_invalid_argument ("deref_array: SV is not a reference"); switch (SvTYPE (SvRV (sv))) { case SVt_PVAV: break; default: - invalid_argument ("deref_array: SV is not a reference to an array"); + caml_invalid_argument ("deref_array: SV is not a reference to an array"); } ravv = Val_av ((AV *) SvRV (sv)); CAMLreturn (ravv); @@ -290,12 +279,12 @@ perl4caml_deref_hash (value svv) SV *sv = Sv_val (svv); if (!SvROK (sv)) - invalid_argument ("deref_hash: SV is not a reference"); + caml_invalid_argument ("deref_hash: SV is not a reference"); switch (SvTYPE (SvRV (sv))) { case SVt_PVHV: break; default: - invalid_argument ("deref_hash: SV is not a reference to a hash"); + caml_invalid_argument ("deref_hash: SV is not a reference to a hash"); } rhvv = Val_hv ((HV *) SvRV (sv)); CAMLreturn (rhvv); @@ -408,7 +397,7 @@ perl4caml_av_get (value avv, value i) CAMLparam2 (avv, i); AV *av = Av_val (avv); SV **svp = av_fetch (av, Int_val (i), 0); - if (svp == 0) invalid_argument ("av_get: index out of bounds"); + if (svp == 0) caml_invalid_argument ("av_get: index out of bounds"); CAMLreturn (Val_sv (*svp)); } @@ -454,7 +443,7 @@ perl4caml_hv_set (value hvv, value key, value svv) HV *hv = Hv_val (hvv); SV *sv = Sv_val (svv); SvREFCNT_inc (sv); - if (hv_store (hv, String_val (key), string_length (key), sv, 0) == 0) + if (hv_store (hv, String_val (key), caml_string_length (key), sv, 0) == 0) SvREFCNT_dec (sv); CAMLreturn (Val_unit); } @@ -464,8 +453,8 @@ perl4caml_hv_get (value hvv, value key) { CAMLparam2 (hvv, key); HV *hv = Hv_val (hvv); - SV **svp = hv_fetch (hv, String_val (key), string_length (key), 0); - if (svp == 0) raise_not_found (); + SV **svp = hv_fetch (hv, String_val (key), caml_string_length (key), 0); + if (svp == 0) caml_raise_not_found (); CAMLreturn (Val_sv (*svp)); } @@ -474,7 +463,7 @@ perl4caml_hv_exists (value hvv, value key) { CAMLparam2 (hvv, key); HV *hv = Hv_val (hvv); - bool r = hv_exists (hv, String_val (key), string_length (key)); + bool r = hv_exists (hv, String_val (key), caml_string_length (key)); CAMLreturn (r ? Val_true : Val_false); } @@ -483,7 +472,7 @@ perl4caml_hv_delete (value hvv, value key) { CAMLparam2 (hvv, key); HV *hv = Hv_val (hvv); - hv_delete (hv, String_val (key), string_length (key), G_DISCARD); + hv_delete (hv, String_val (key), caml_string_length (key), G_DISCARD); CAMLreturn (Val_unit); } @@ -514,7 +503,7 @@ perl4caml_get_sv (value optcreate, value name) create = unoption (optcreate, Val_false); sv = get_sv (String_val (name), create == Val_true ? TRUE : FALSE); - if (sv == NULL) raise_not_found (); + if (sv == NULL) caml_raise_not_found (); CAMLreturn (Val_sv (sv)); } @@ -528,7 +517,7 @@ perl4caml_get_av (value optcreate, value name) create = unoption (optcreate, Val_false); av = get_av (String_val (name), create == Val_true ? TRUE : FALSE); - if (av == NULL) raise_not_found (); + if (av == NULL) caml_raise_not_found (); CAMLreturn (Val_av (av)); } @@ -542,7 +531,7 @@ perl4caml_get_hv (value optcreate, value name) create = unoption (optcreate, Val_false); hv = get_hv (String_val (name), create == Val_true ? TRUE : FALSE); - if (hv == NULL) raise_not_found (); + if (hv == NULL) caml_raise_not_found (); CAMLreturn (Val_hv (hv)); } @@ -558,9 +547,9 @@ check_perl_failure () STRLEN n_a; const char *err = SvPV (errsv, n_a); - errv = copy_string (err); + errv = caml_copy_string (err); - raise_with_arg (*caml_named_value ("perl4caml_perl_failure"), errv); + caml_raise_with_arg (*caml_named_value ("perl4caml_perl_failure"), errv); } } @@ -677,7 +666,7 @@ perl4caml_call_array (value optsv, value optfnname, value arglist) for (i = 0; i < count; ++i) { SV *sv; - cons = alloc (2, 0); + cons = caml_alloc (2, 0); Field (cons, 1) = list; list = cons; sv = newSVsv (POPs); @@ -854,7 +843,7 @@ perl4caml_call_method_array (value ref, value name, value arglist) for (i = 0; i < count; ++i) { SV *sv; - cons = alloc (2, 0); + cons = caml_alloc (2, 0); Field (cons, 1) = list; list = cons; sv = newSVsv (POPs); @@ -998,7 +987,7 @@ perl4caml_call_class_method_array (value classname, value name, value arglist) */ list = Val_int (0); for (i = 0; i < count; ++i) { - cons = alloc (2, 0); + cons = caml_alloc (2, 0); Field (cons, 1) = list; list = cons; Field (cons, 0) = Val_sv (newSVsv (POPs)); @@ -1062,7 +1051,7 @@ Val_voidptr (void *ptr) { CAMLparam0 (); CAMLlocal1 (rv); - rv = alloc (1, Abstract_tag); + rv = caml_alloc (1, Abstract_tag); Field(rv, 0) = (value) ptr; CAMLreturn (rv); } @@ -1089,7 +1078,7 @@ Val_xv (SV *sv) { CAMLparam0 (); CAMLlocal1 (rv); - rv = alloc_custom (&xv_custom_operations, sizeof (void *), 0, 1); + rv = caml_alloc_custom (&xv_custom_operations, sizeof (void *), 0, 1); Xv_val (rv) = sv; CAMLreturn (rv); }