summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--README.openbsd30
-rw-r--r--reentr.pl22
3 files changed, 51 insertions, 2 deletions
diff --git a/MANIFEST b/MANIFEST
index 213e945f78..250c4c13ec 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2453,6 +2453,7 @@ README.micro Notes about microperl
README.mint Perl notes for MiNT
README.mpeix Perl notes for MPE/iX
README.netware Perl notes for NetWare
+README.openbsd Perl notes for OpenBSD
README.os2 Perl notes for OS/2
README.os390 Perl notes for OS/390
README.os400 Perl notes for OS/400
diff --git a/README.openbsd b/README.openbsd
new file mode 100644
index 0000000000..b1d5eea14f
--- /dev/null
+++ b/README.openbsd
@@ -0,0 +1,30 @@
+If you read this file _as_is_, just ignore the funny characters you
+see. It is written in the POD format (see pod/perlpod.pod) which is
+specifically designed to be readable as is.
+
+=head1 NAME
+
+README.openbsd - Perl version 5 on OpenBSD systems
+
+=head1 DESCRIPTION
+
+This document describes various features of OpenBSD that will affect how Perl
+version 5 (hereafter just Perl) is compiled and/or runs.
+
+=head2 OpenBSD core dumps from getprotobyname_r and getservbyname_r with ithreads
+
+When Perl is configured to use ithreads, it will use re-entrant library calls
+in preference to non-re-entrant versions. There is an incompatability in
+OpenBSD's C<getprotobyname_r> and C<getservbyname_r> function in versions 3.7
+and later that will cause a SEGV when called without doing a C<bzero> on
+their return structs prior to calling these functions. Current Perl's
+should handle this problem correctly. Older threaded Perls (5.8.6 or earlier)
+will run into this problem. If you want to run a threaded Perl on OpenBSD
+3.7 or higher, you will need to upgrade to at least Perl 5.8.7.
+
+=head1 AUTHOR
+
+Steve Peters <steve@fisharerojo.org>
+
+Please report any errors, updates, or suggestions to F<perlbug@perl.org>.
+
diff --git a/reentr.pl b/reentr.pl
index 53a76e2d57..cd6998990c 100644
--- a/reentr.pl
+++ b/reentr.pl
@@ -41,7 +41,7 @@ print <<EOF;
/*
* reentr.h
*
- * Copyright (C) 2002, 2003, by Larry Wall and others
+ * Copyright (C) 2002, 2003, 2005 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.
@@ -80,6 +80,17 @@ print <<EOF;
# 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
@@ -679,6 +690,13 @@ EOF
$w = ", $w" if length $v;
}
my $call = "${func}_r($v$w)";
+
+ # Must make OpenBSD happy
+ my $memzero = '';
+ if($p =~ /D$/ &&
+ ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
+ $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data))';
+ }
push @wrap, <<EOF;
# if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
EOF
@@ -691,7 +709,7 @@ EOF
my $rv = $v ? ", $v" : "";
if ($r eq 'I') {
push @wrap, <<EOF;
-# define $func($v) ((PL_reentrant_retint = $call)$test ? $true : (((PL_reentrant_retint == ERANGE) || (errno == ERANGE)) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
+# define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : (((PL_reentrant_retint == ERANGE) || (errno == ERANGE)) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
EOF
} else {
push @wrap, <<EOF;