# and optionally also the relevant metaconfig units (-U option).
#
+BEGIN {
+ # Get function prototypes
+ require 'regen_lib.pl';
+}
+
use strict;
use Getopt::Std;
my %opts;
# Example #3: S_CBI means type func_r(const char*, char*, int)
+safer_unlink 'reentr.h';
die "reentr.h: $!" unless open(H, ">reentr.h");
+binmode H;
select H;
print <<EOF;
-/*
+/* -*- buffer-read-only: t -*-
+ *
* reentr.h
*
- * Copyright (C) 2002, 2003, 2005 by Larry Wall and others
+ * Copyright (C) 2002, 2003, 2005, 2006 by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*/
#ifndef REENTR_H
-#define REENTR_H
+#define REENTR_H
#ifdef USE_REENTRANT_API
# define NETDB_R_OBSOLETE
#endif
-/*
- * As of OpenBSD 3.7, reentrant functions are now working, they just are
- * incompatible with everyone else. To make OpenBSD happy, we have to
- * memzero out certain structures before calling the functions.
- */
-#if defined(__OpenBSD__)
-# define REENTR_MEMZERO(a,b) memzero(a,b);
-#else
-# define REENTR_MEMZERO(a,b)
-#endif
-
#ifdef NETDB_R_OBSOLETE
# undef HAS_ENDHOSTENT_R
# undef HAS_ENDNETENT_R
# If given the -U option open up the metaconfig unit for this function.
if ($opts{U} && open(U, ">d_${func}_r.U")) {
+ binmode U;
select U;
}
sub pushinitfree {
my $func = shift;
push @init, <<EOF;
- New(31338, PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
+ Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
EOF
push @free, <<EOF;
Safefree(PL_reentrant_buffer->_${func}_buffer);
EOF
push @init, <<EOF;
#if !($D)
- New(31338, PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
+ Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
#endif
EOF
push @free, <<EOF;
$call = qq[((PL_REENTRANT_RETINT = $call)$test ? $true : (((PL_REENTRANT_RETINT == ERANGE) || (errno == ERANGE)) ? ($seenm{$func}{$seenr{$func}})Perl_reentrant_retry("$func"$rv) : 0))];
my $arg = join(", ", map { $seenm{$func}{substr($a,$_,1)}." ".$v[$_] } 0..$seenu{$func}-1);
my $ret = $seenr{$func} eq 'V' ? "" : "return ";
+ my $memzero_ = $memzero ? "$memzero, " : "";
push @wrap, <<EOF;
# ifdef PERL_CORE
-# define $func($v) $call
+# define $func($v) ($memzero_$call)
# else
# if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC)
# define $func($v) ({int PL_REENTRANT_RETINT; $memzero; $call;})
#ifdef USE_REENTRANT_API
+/*
+ * As of OpenBSD 3.7, reentrant functions are now working, they just are
+ * incompatible with everyone else. To make OpenBSD happy, we have to
+ * memzero out certain structures before calling the functions.
+ */
+#if defined(__OpenBSD__)
+# define REENTR_MEMZERO(a,b) memzero(a,b)
+#else
+# define REENTR_MEMZERO(a,b) 0
+#endif
+
/* The reentrant wrappers. */
@wrap
#endif
+/* ex: set ro: */
EOF
close(H);
# Prepare to write the reentr.c.
+safer_unlink 'reentr.c';
die "reentr.c: $!" unless open(C, ">reentr.c");
+binmode C;
select C;
print <<EOF;
-/*
+/* -*- buffer-read-only: t -*-
+ *
* reentr.c
*
- * Copyright (C) 2002, 2003, by Larry Wall and others
+ * Copyright (C) 2002, 2003, 2005, 2006 by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
void
Perl_reentrant_init(pTHX) {
#ifdef USE_REENTRANT_API
- New(31337, PL_reentrant_buffer, 1, REENTR);
+ Newx(PL_reentrant_buffer, 1, REENTR);
Perl_reentrant_size(aTHX);
@init
#endif /* USE_REENTRANT_API */
return retptr;
}
+/* ex: set ro: */
EOF
__DATA__