Skip to content

Commit 23e2b7a

Browse files
smpetersAbhijit Menon-Sen
authored and
Abhijit Menon-Sen
committed
Re: [PATCH] reentr.h changes so threaded Perl's compile on OpenBSD 3.7
Message-Id: <[email protected]> p4raw-id: //depot/perl@24441
1 parent 66610fd commit 23e2b7a

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

MANIFEST

+1
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,7 @@ README.micro Notes about microperl
24532453
README.mint Perl notes for MiNT
24542454
README.mpeix Perl notes for MPE/iX
24552455
README.netware Perl notes for NetWare
2456+
README.openbsd Perl notes for OpenBSD
24562457
README.os2 Perl notes for OS/2
24572458
README.os390 Perl notes for OS/390
24582459
README.os400 Perl notes for OS/400

README.openbsd

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
If you read this file _as_is_, just ignore the funny characters you
2+
see. It is written in the POD format (see pod/perlpod.pod) which is
3+
specifically designed to be readable as is.
4+
5+
=head1 NAME
6+
7+
README.openbsd - Perl version 5 on OpenBSD systems
8+
9+
=head1 DESCRIPTION
10+
11+
This document describes various features of OpenBSD that will affect how Perl
12+
version 5 (hereafter just Perl) is compiled and/or runs.
13+
14+
=head2 OpenBSD core dumps from getprotobyname_r and getservbyname_r with ithreads
15+
16+
When Perl is configured to use ithreads, it will use re-entrant library calls
17+
in preference to non-re-entrant versions. There is an incompatability in
18+
OpenBSD's C<getprotobyname_r> and C<getservbyname_r> function in versions 3.7
19+
and later that will cause a SEGV when called without doing a C<bzero> on
20+
their return structs prior to calling these functions. Current Perl's
21+
should handle this problem correctly. Older threaded Perls (5.8.6 or earlier)
22+
will run into this problem. If you want to run a threaded Perl on OpenBSD
23+
3.7 or higher, you will need to upgrade to at least Perl 5.8.7.
24+
25+
=head1 AUTHOR
26+
27+
Steve Peters <[email protected]>
28+
29+
Please report any errors, updates, or suggestions to F<[email protected]>.
30+

reentr.pl

+20-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
/*
4242
* reentr.h
4343
*
44-
* Copyright (C) 2002, 2003, by Larry Wall and others
44+
* Copyright (C) 2002, 2003, 2005 by Larry Wall and others
4545
*
4646
* You may distribute under the terms of either the GNU General Public
4747
* License or the Artistic License, as specified in the README file.
@@ -80,6 +80,17 @@
8080
# define NETDB_R_OBSOLETE
8181
#endif
8282
83+
/*
84+
* As of OpenBSD 3.7, reentrant functions are now working, they just are
85+
* incompatible with everyone else. To make OpenBSD happy, we have to
86+
* memzero out certain structures before calling the functions.
87+
*/
88+
#if defined(__OpenBSD__)
89+
# define REENTR_MEMZERO(a,b) memzero(a,b),
90+
#else
91+
# define REENTR_MEMZERO(a,b)
92+
#endif
93+
8394
#ifdef NETDB_R_OBSOLETE
8495
# undef HAS_ENDHOSTENT_R
8596
# undef HAS_ENDNETENT_R
@@ -679,6 +690,13 @@ sub define {
679690
$w = ", $w" if length $v;
680691
}
681692
my $call = "${func}_r($v$w)";
693+
694+
# Must make OpenBSD happy
695+
my $memzero = '';
696+
if($p =~ /D$/ &&
697+
($genfunc eq 'protoent' || $genfunc eq 'servent')) {
698+
$memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data))';
699+
}
682700
push @wrap, <<EOF;
683701
# if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
684702
EOF
@@ -691,7 +709,7 @@ sub define {
691709
my $rv = $v ? ", $v" : "";
692710
if ($r eq 'I') {
693711
push @wrap, <<EOF;
694-
# define $func($v) ((PL_reentrant_retint = $call)$test ? $true : (((PL_reentrant_retint == ERANGE) || (errno == ERANGE)) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
712+
# define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : (((PL_reentrant_retint == ERANGE) || (errno == ERANGE)) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
695713
EOF
696714
} else {
697715
push @wrap, <<EOF;

0 commit comments

Comments
 (0)