From da563c98dbb391c4343bb3749ccd3b47a3cc425f Mon Sep 17 00:00:00 2001 From: rich Date: Tue, 3 Feb 2004 12:38:57 +0000 Subject: [PATCH] Commented out ref counting code for now. Updated Debian version. --- Makefile.config | 14 +++++++++++++- debian/changelog | 2 +- perl_c.c | 27 ++++++++++++++++++++------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Makefile.config b/Makefile.config index 23a7aaf..319b32d 100644 --- a/Makefile.config +++ b/Makefile.config @@ -1,5 +1,5 @@ # perl4caml configuration -*- Makefile -*- -# $Id: Makefile.config,v 1.13 2003-12-11 17:41:52 rich Exp $ +# $Id: Makefile.config,v 1.14 2004-02-03 12:38:57 rich Exp $ # PERLINCDIR # Directory containing the Perl include files, eg. . @@ -14,8 +14,20 @@ OCAMLLIBDIR := $(shell ocamlc -where) # EXTRA_CFLAGS # You can specify extra flags to be passed to gcc here. +# +# One flag you might want to pass here is +# +# -DPERL4CAML_REFCOUNTING_EXPERIMENTAL=1 +# +# which will turn on experimental support for reference counting. +# Without this none of the Perl structures that you allocate will get +# freed. With this we try to map Perl's reference counting onto +# OCaml's garbage collection by using finalizers. There are some +# problems with this code at the moment, hence it is disabled by +# default. EXTRA_CFLAGS := +#EXTRA_CFLAGS := -DPERL4CAML_REFCOUNTING_EXPERIMENTAL=1 # PACKAGE and VERSION diff --git a/debian/changelog b/debian/changelog index 02ff439..1ce967f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -perl4caml (0.3.9-2) unstable; urgency=low +perl4caml (0.3.9-3) unstable; urgency=low * Initial Release. diff --git a/perl_c.c b/perl_c.c index 772bae2..3214e34 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.13 2003-12-11 17:41:52 rich Exp $ + * $Id: perl_c.c,v 1.14 2004-02-03 12:38:57 rich Exp $ */ #include @@ -31,22 +31,31 @@ /* Perl requires the interpreter to be called literally 'my_perl'! */ static PerlInterpreter *my_perl; +/* Get the concrete value from an optional field. */ +static value unoption (value option, value deflt); + /* Wrap up an arbitrary void pointer in an opaque OCaml object. */ static value Val_voidptr (void *ptr); +/* Unwrap an arbitrary void pointer from an opaque OCaml object. */ +#define Voidptr_val(type,rv) ((type *) Field ((rv), 0)) + +#if PERL4CAML_REFCOUNTING_EXPERIMENTAL + +/* Unwrap a custom block. */ +#define Xv_val(rv) (*((void **)Data_custom_val(rv))) + /* Wrap up an SV, AV or HV in a custom OCaml object which will decrement * the reference count on finalization. */ static value Val_xv (SV *sv); -/* Get the concrete value from an optional field. */ -static value unoption (value option, value deflt); +#else -/* Unwrap an arbitrary void pointer from an opaque OCaml object. */ -#define Voidptr_val(type,rv) ((type *) Field ((rv), 0)) +#define Xv_val(rv) Voidptr_val (SV, (rv)) +#define Val_xv(sv) Val_voidptr ((sv)) -/* Unwrap a custom block. */ -#define Xv_val(rv) (*((void **)Data_custom_val(rv))) +#endif /* Hide Perl types in opaque OCaml objects. */ #define Val_perl(pl) (Val_voidptr ((pl))) @@ -1044,6 +1053,8 @@ Val_voidptr (void *ptr) CAMLreturn (rv); } +#if PERL4CAML_REFCOUNTING_EXPERIMENTAL + static void xv_finalize (value v) { @@ -1069,6 +1080,8 @@ Val_xv (SV *sv) CAMLreturn (rv); } +#endif /* PERL4CAML_REFCOUNTING_EXPERIMENTAL */ + static value unoption (value option, value deflt) { -- 1.8.3.1