The compilation of PerlIO::via may hang on AIX when
[p5sagit/p5-mst-13.2.git] / reentr.pl
index ee94c8d..339529f 100644 (file)
--- a/reentr.pl
+++ b/reentr.pl
@@ -41,7 +41,7 @@ print <<EOF;
 /*
  *    reentr.h
  *
- *    Copyright (c) 1997-2003, Larry Wall
+ *    Copyright (C) 2002, 2003, 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.
@@ -365,6 +365,7 @@ EOF
 EOF
         }
     }
+    return if @F == 1;
     push @define, <<EOF;
 
 /* Any of the @F using \L$n? */
@@ -453,14 +454,17 @@ EOF
 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
        $seend{$func} _${func}_data;
 #else
-       $seent{$func} _${func}_struct;
+       $seent{$func} *_${func}_struct_buffer;
 #endif
 EOF
            push @init, <<EOF;
-#ifdef __GLIBC__
-       PL_reentrant_buffer->_${func}_struct.initialized = 0;
-       /* work around glibc-2.2.5 bug */
-       PL_reentrant_buffer->_${func}_struct.current_saltbits = 0;
+#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
+       PL_reentrant_buffer->_${func}_struct_buffer = 0;
+#endif
+EOF
+           push @free, <<EOF;
+#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
+       Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
 #endif
 EOF
            pushssif $endif;
@@ -661,9 +665,11 @@ EOF
                             $_ eq 'D' ?
                                 "&PL_reentrant_buffer->_${genfunc}_data" :
                             $_ eq 'S' ?
-                                ($func =~ /^readdir/ ?
+                                ($func =~ /^readdir\d*$/ ?
                                  "PL_reentrant_buffer->_${genfunc}_struct" :
-                                 "&PL_reentrant_buffer->_${genfunc}_struct" ) :
+                                 $func =~ /^crypt$/ ?
+                                 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
+                                 "&PL_reentrant_buffer->_${genfunc}_struct") :
                             $_ eq 'T' && $func eq 'drand48' ?
                                 "&PL_reentrant_buffer->_${genfunc}_double" :
                             $_ =~ /^[ilt]$/ && $func eq 'random' ?
@@ -673,7 +679,7 @@ EOF
                $w = ", $w" if length $v;
            }
            my $call = "${func}_r($v$w)";
-           $call = "((errno = $call))" if $r eq 'I' && $func ne 'random';
+           $call = "((PL_reentrant_retint = $call))" if $r eq 'I' && $func ne 'random';
            push @wrap, <<EOF;
 #   if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
 EOF
@@ -684,9 +690,15 @@ EOF
            } else {
                if ($func =~ /^get/) {
                    my $rv = $v ? ", $v" : "";
-                   push @wrap, <<EOF;
-#       define $func($v) ($call$test ? $true : (errno == ERANGE ? Perl_reentrant_retry("$func"$rv) : 0))
+                   if ($r eq 'I') {
+                       push @wrap, <<EOF;
+#       define $func($v) ($call$test ? $true : (((PL_reentrant_retint > 0 && PL_reentrant_retint == ERANGE) || (errno == ERANGE)) ? Perl_reentrant_retry("$func"$rv) : 0))
+EOF
+                   } else {
+                       push @wrap, <<EOF;
+#       define $func($v) ($call$test ? $true : ((errno == ERANGE) ? Perl_reentrant_retry("$func"$rv) : 0))
 EOF
+                    }
                } else {
                    push @wrap, <<EOF;
 #       define $func($v) ($call$test ? $true : 0)
@@ -717,6 +729,7 @@ typedef struct {
 /* The wrappers. */
 
 @wrap
+
 #endif /* USE_REENTRANT_API */
  
 #endif
@@ -733,7 +746,7 @@ print <<EOF;
 /*
  *    reentr.c
  *
- *    Copyright (c) 1997-2003, Larry Wall
+ *    Copyright (C) 2002, 2003, 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.
@@ -783,7 +796,7 @@ Perl_reentrant_retry(const char *f, ...)
     dTHX;
     void *retptr = NULL;
 #ifdef USE_REENTRANT_API
-#  if defined(USE_HOSTENT_BUFFER) || defined(USE_GRENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PWENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SRVENT_BUFFER)
+#  if defined(USE_HOSTENT_BUFFER) || defined(USE_GRENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PWENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
     void *p0;
 #  endif
 #  if defined(USE_SERVENT_BUFFER)
@@ -851,7 +864,11 @@ Perl_reentrant_retry(const char *f, ...)
                    p0 = va_arg(ap, void *);
                    retptr = getgrnam(p0); break;
                case OP_GGRGID:
+#if Gid_t_size < INTSIZE
+                   gid = (Gid_t)va_arg(ap, int);
+#else
                    gid = va_arg(ap, Gid_t);
+#endif
                    retptr = getgrgid(gid); break;
                case OP_GGRENT:
                    retptr = getgrent(); break;
@@ -914,7 +931,11 @@ Perl_reentrant_retry(const char *f, ...)
                    p0 = va_arg(ap, void *);
                    retptr = getpwnam(p0); break;
                case OP_GPWUID:
+#if Uid_t_size < INTSIZE
+                   uid = (Uid_t)va_arg(ap, int);
+#else
                    uid = va_arg(ap, Uid_t);
+#endif
                    retptr = getpwuid(uid); break;
                case OP_GPWENT:
                    retptr = getpwent(); break;