for beter make distclean (was Re: [PATCH] Re: [ID 20020305.026] Not OK: perl v5.7...
[p5sagit/p5-mst-13.2.git] / reentr.pl
index a92f42d..5c566f1 100644 (file)
--- a/reentr.pl
+++ b/reentr.pl
@@ -161,7 +161,14 @@ while (<DATA>) {
     if ($opts{U} && open(U, ">d_${f}_r.U"))  {
        select U;
     }
-    my $prereqh = $h eq 'stdio' ? '' : "i_$h"; # There's no i_stdio.
+    my $prereqs  = '';
+    my $prereqh  = '';
+    my $prereqsh = '';
+    if ($h ne 'stdio') { # There's no i_stdio.
+       $prereqs  = "i_$h";
+       $prereqh  = "$h.h";
+       $prereqsh = "\$$prereqs $prereqh";
+    }
     print <<EOF if $opts{U};
 ?RCS: \$Id: d_${f}_r.U,v $
 ?RCS:
@@ -172,7 +179,7 @@ while (<DATA>) {
 ?RCS:
 ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
 ?RCS:
-?MAKE:d_${f}_r ${f}_r_proto: Inlibc Protochk Hasproto i_systypes $prereqh usethreads
+?MAKE:d_${f}_r ${f}_r_proto: Inlibc Protochk Hasproto i_systypes i_systime $prereqs usethreads
 ?MAKE: -pick add \$@ %<
 ?S:d_${f}_r:
 ?S:    This variable conditionally defines the HAS_${F}_R symbol,
@@ -200,7 +207,7 @@ set ${f}_r d_${f}_r
 eval \$inlibc
 case "\$d_${f}_r" in
 "\$define")
-       hdrs="\$i_systypes sys/types.h define stdio.h \$i_${h} $h.h"
+       hdrs="\$i_systypes sys/types.h define stdio.h $prereqsh"
        case "$h" in
        time)
                hdrs="\$hdrs \$i_systime sys/time.h"
@@ -397,7 +404,7 @@ for my $f (@seenf) {
        size_t  _${f}_size;
 EOF
            push @size, <<EOF;
-       PL_reentrant_buffer->_${f}_size = 256; /* Make something up. */
+       PL_reentrant_buffer->_${f}_size = REENTRANTSMALLSIZE;
 EOF
            pushinitfree $f;
            pushssif $endif;
@@ -462,9 +469,13 @@ EOF
 EOF
                my $sc = $g eq 'getgrent' ?
                    '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
+               my $sz = $g eq 'getgrent' ?
+                    '_getgrent_size' : '_getpwent_size';
                push @size, <<EOF;
 #   if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
        PL_reentrant_buffer->_${g}_size = sysconf($sc);
+       if (PL_reentrant_buffer->$sz == -1)
+               PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
 #   else
 #       if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
        PL_reentrant_buffer->_${g}_size = SIABUFSIZ;
@@ -472,7 +483,7 @@ EOF
 #           ifdef __sgi
        PL_reentrant_buffer->_${g}_size = BUFSIZ;
 #           else
-       PL_reentrant_buffer->_${g}_size = 256;
+       PL_reentrant_buffer->_${g}_size = REENTRANTUSUALSIZE;
 #           endif
 #       endif
 #   endif 
@@ -488,6 +499,7 @@ EOF
            my $G = uc $g;
            my $D = ifprotomatch($F, grep {/D/} @p);
            my $d = $seend{$f};
+           $d =~ s/\*$//; # snip: we need need the base type.
            push @struct, <<EOF;
        $seent{$f}      _${g}_struct;
 #   if $D
@@ -507,7 +519,7 @@ EOF
 EOF
            push @size, <<EOF;
 #if   !($D)
-       PL_reentrant_buffer->_${g}_size = 2048; /* Any better ideas? */
+       PL_reentrant_buffer->_${g}_size = REENTRANTUSUALSIZE;
 #endif
 EOF
            push @init, <<EOF;
@@ -548,7 +560,6 @@ EOF
 
        push @wrap, $ifdef;
 
-# Doesn't implement the buffer growth loop for glibc gethostby*().
        push @wrap, <<EOF;
 #   undef $f
 EOF
@@ -684,6 +695,8 @@ print <<EOF;
 void
 Perl_reentrant_size(pTHX) {
 #ifdef USE_REENTRANT_API
+#define REENTRANTSMALLSIZE      256    /* Make something up. */
+#define REENTRANTUSUALSIZE     4096    /* Make something up. */
 @size
 #endif /* USE_REENTRANT_API */
 }
@@ -711,9 +724,18 @@ Perl_reentrant_retry(const char *f, ...)
     dTHX;
     void *retptr = NULL;
 #ifdef USE_REENTRANT_API
-    void *p0, *p1;
+#  if defined(USE_GETHOSTENT_BUFFER) || defined(USE_GETGRENT_BUFFER) || defined(USE_GETNETENT_BUFFER) || defined(USE_GETPWENT_BUFFER) || defined(USE_GETPROTOENT_BUFFER) || defined(USE_GETSERVENT_BUFFER)
+    void *p0;
+#  endif
+#  if defined(USE_GETSERVENT_BUFFER)
+    void *p1;
+#  endif
+#  if defined(USE_GETHOSTENT_BUFFER)
     size_t asize;
+#  endif
+#  if defined(USE_GETHOSTENT_BUFFER) || defined(USE_GETNETENT_BUFFER) || defined(USE_GETPROTOENT_BUFFER) || defined(USE_GETSERVENT_BUFFER)
     int anint;
+#  endif
     va_list ap;
 
     va_start(ap, f);
@@ -898,11 +920,11 @@ ctermid   B       |stdio  |               |B_B
 ctime S                |time   |const time_t   |B_SB|B_SBI|I_SB|I_SBI
 drand48                |stdlib |struct drand48_data    |I_ST|T=double*
 endgrent       |grp    |               |I_H|V_H
-endhostent     |netdb  |struct hostent_data    |I_S|V_S
-endnetent      |netdb  |struct netent_data     |I_S|V_S
-endprotoent    |netdb  |struct protoent_data   |I_S|V_S
+endhostent     |netdb  |               |I_D|V_D|D=struct hostent_data*
+endnetent      |netdb  |               |I_D|V_D|D=struct netent_data*
+endprotoent    |netdb  |               |I_D|V_D|D=struct protoent_data*
 endpwent       |pwd    |               |I_H|V_H
-endservent     |netdb  |struct servent_data    |I_S|V_S
+endservent     |netdb  |               |I_D|V_D|D=struct servent_data*
 getgrent       |grp    |struct group   |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
 getgrgid T     |grp    |struct group   |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
 getgrnam C     |grp    |struct group   |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI