Add comment to top of reentr.c and fix typos in other files
[p5sagit/p5-mst-13.2.git] / reentr.pl
index 4429bc4..f4d754a 100644 (file)
--- a/reentr.pl
+++ b/reentr.pl
@@ -41,13 +41,13 @@ 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.
  *
  *  !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
- *  This file is built by reentrl.pl from data in reentr.pl.
+ *  This file is built by reentr.pl from data in reentr.pl.
  */
 
 #ifndef REENTR_H
@@ -365,6 +365,7 @@ EOF
 EOF
         }
     }
+    return if @F == 1;
     push @define, <<EOF;
 
 /* Any of the @F using \L$n? */
@@ -468,7 +469,7 @@ EOF
 EOF
            pushssif $endif;
        }
-        elsif ($func =~ /^(drand48|gmtime|localtime|random)$/) {
+        elsif ($func =~ /^(drand48|gmtime|localtime|random|srandom)$/) {
            pushssif $ifdef;
            push @struct, <<EOF;
        $seent{$func} _${func}_struct;
@@ -479,13 +480,13 @@ EOF
 EOF
            } elsif ($1 eq 'random') {
            push @struct, <<EOF;
-#   if RANDOM_R_PROTO == REENTRANT_PROTO_iS
+#   if RANDOM_R_PROTO == REENTRANT_PROTO_I_iS
        int     _${func}_retval;
 #   endif
-#   if RANDOM_R_PROTO == REENTRANT_PROTO_lS
+#   if RANDOM_R_PROTO == REENTRANT_PROTO_I_lS
        long    _${func}_retval;
 #   endif
-#   if RANDOM_R_PROTO == REENTRANT_PROTO_tS
+#   if RANDOM_R_PROTO == REENTRANT_PROTO_I_St
        int32_t _${func}_retval;
 #   endif
 EOF
@@ -678,7 +679,6 @@ EOF
                $w = ", $w" if length $v;
            }
            my $call = "${func}_r($v$w)";
-           $call = "((errno = $call))" if $r eq 'I' && $func ne 'random';
            push @wrap, <<EOF;
 #   if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
 EOF
@@ -689,9 +689,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) ((PL_reentrant_retint = $call)$test ? $true : (((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)
@@ -722,6 +728,7 @@ typedef struct {
 /* The wrappers. */
 
 @wrap
+
 #endif /* USE_REENTRANT_API */
  
 #endif
@@ -738,17 +745,23 @@ 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.
  *
  *  !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
- *  This file is built by reentrl.pl from data in reentr.pl.
+ *  This file is built by reentr.pl from data in reentr.pl.
  *
  * "Saruman," I said, standing away from him, "only one hand at a time can
  *  wield the One, and you know that well, so do not trouble to say we!"
  *
+ * This file contains a collection of automatically created wrappers
+ * (created by running reentr.pl) for reentrant (thread-safe) versions of
+ * various library calls, such as getpwent_r.  The wrapping is done so
+ * that other files like pp_sys.c calling those library functions need not
+ * care about the differences between various platforms' idiosyncrasies
+ * regarding these reentrant interfaces.  
  */
 
 #include "EXTERN.h"
@@ -788,7 +801,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)