Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Re: [PATCH] reentr.h changes so threaded Perl's compile on OpenBSD 3.7

Message-Id: <20050510174413.GA19686@mccoy.peters.homeunix.org>

p4raw-id: //depot/perl@24441
  • Loading branch information...
commit 23e2b7a9cd174dbd4e526e1069d671e42c30d954 1 parent 66610fd
Steve Peters authored May 10, 2005 Abhijit Menon-Sen committed May 10, 2005
1  MANIFEST
@@ -2453,6 +2453,7 @@ README.micro			Notes about microperl
2453 2453
 README.mint			Perl notes for MiNT
2454 2454
 README.mpeix			Perl notes for MPE/iX
2455 2455
 README.netware			Perl notes for NetWare
  2456
+README.openbsd			Perl notes for OpenBSD
2456 2457
 README.os2			Perl notes for OS/2
2457 2458
 README.os390			Perl notes for OS/390
2458 2459
 README.os400			Perl notes for OS/400
30  README.openbsd
... ...
@@ -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 <steve@fisharerojo.org>
  28
+
  29
+Please report any errors, updates, or suggestions to F<perlbug@perl.org>.
  30
+
22  reentr.pl
@@ -41,7 +41,7 @@
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,6 +80,17 @@
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 notes on commit 23e2b7a

Please sign in to comment.
Something went wrong with that request. Please try again.