41
41
/*
42
42
* reentr.h
43
43
*
44
- * Copyright (C) 2002, 2003, by Larry Wall and others
44
+ * Copyright (C) 2002, 2003, 2005 by Larry Wall and others
45
45
*
46
46
* You may distribute under the terms of either the GNU General Public
47
47
* License or the Artistic License, as specified in the README file.
80
80
# define NETDB_R_OBSOLETE
81
81
#endif
82
82
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
+
83
94
#ifdef NETDB_R_OBSOLETE
84
95
# undef HAS_ENDHOSTENT_R
85
96
# undef HAS_ENDNETENT_R
@@ -679,6 +690,13 @@ sub define {
679
690
$w = " , $w " if length $v ;
680
691
}
681
692
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
+ }
682
700
push @wrap , <<EOF ;
683
701
# if !defined($func ) && ${FUNC} _R_PROTO == REENTRANT_PROTO_$p
684
702
EOF
@@ -691,7 +709,7 @@ sub define {
691
709
my $rv = $v ? " , $v " : " " ;
692
710
if ($r eq ' I' ) {
693
711
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))
695
713
EOF
696
714
} else {
697
715
push @wrap , <<EOF ;
0 commit comments