X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/ce716c52d393ac84495b7b8f262c39ecc5447cc9..c6709bf9918ed61b4a7a0ad24887085bdf1732c9:/regen/reentr.pl diff --git a/regen/reentr.pl b/regen/reentr.pl index 6c7b5e6..b73193c 100644 --- a/regen/reentr.pl +++ b/regen/reentr.pl @@ -18,7 +18,7 @@ BEGIN { # Get function prototypes - require 'regen/regen_lib.pl'; + require './regen/regen_lib.pl'; } use strict; @@ -50,15 +50,18 @@ my %map = ( # Example #2: S_SBIE means type func_r(type, char*, int, int*) # Example #3: S_CBI means type func_r(const char*, char*, int) +sub open_print_header { + my ($file, $quote) = @_; + return open_new($file, '>', + { by => 'regen/reentr.pl', + from => 'data in regen/reentr.pl', + file => $file, style => '*', + copyright => [2002, 2003, 2005 .. 2007], + quote => $quote }); +} -my $h = safer_open('reentr.h-new', 'reentr.h'); -select $h; -print read_only_top(lang => 'C', by => 'regen/reentr.pl', - from => 'data in regen/reentr.pl', - file => 'reentr.h', style => '*', - copyright => [2002, 2003, 2005 .. 2007]); - -print < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 24)) +# undef HAS_READDIR_R +# undef HAS_READDIR64_R +#endif + /* * As of OpenBSD 3.7, reentrant functions are now working, they just are * incompatible with everyone else. To make OpenBSD happy, we have to @@ -148,9 +154,6 @@ print < #endif -#ifdef I_STDLIB -# include /* drand48_data */ -#endif #ifdef I_CRYPT # ifdef I_CRYPT # include @@ -174,7 +177,7 @@ my %seend; # the type of this function's "D" my %seenm; # all the types my %seenu; # the length of the argument list of this function -while () { # Read in the protypes. +while () { # Read in the protoypes. next if /^\s+$/; chomp; my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1); @@ -200,9 +203,8 @@ while () { # Read in the protypes. } # If given the -U option open up the metaconfig unit for this function. - if ($opts{U} && open(U, ">d_${func}_r.U")) { + if ($opts{U} && open(U, ">", "d_${func}_r.U")) { binmode U; - select U; } if ($opts{U}) { @@ -223,7 +225,7 @@ while () { # Read in the protypes. push @prereq, 'i_systime'; } # Output the metaconfig unit header. - print <_${genfunc}_struct_buffer" : "&PL_reentrant_buffer->_${genfunc}_struct") : - $_ eq 'T' && $func eq 'drand48' ? - "&PL_reentrant_buffer->_${genfunc}_double" : - $_ =~ /^[ilt]$/ && $func eq 'random' ? - "&PL_reentrant_buffer->_random_retval" : $_ } split '', $b; $w = ", $w" if length $v; @@ -765,7 +729,7 @@ EOF local $" = ''; -print < 'C', by => 'regen/reentr.pl', - from => 'data in regen/reentr.pl', - file => 'reentr.c', style => '*', - copyright => [2002, 2003, 2005 .. 2007]); +my $c = open_print_header('reentr.c', <<'EOQ'); + */ -$top =~ s! \*/\n! * +/* * "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\!" + * wield the One, and you know that well, so do not trouble to say we!" * + * [p.260 of _The Lord of the Rings_, II/ii: "The Council of Elrond"] + */ + +/* * 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 @@ -806,16 +770,24 @@ $top =~ s! \*/\n! * * care about the differences between various platforms' idiosyncrasies * regarding these reentrant interfaces. */ -!s; +EOQ -print $top, <_hostent_size *= 2; - Renew(PL_reentrant_buffer->_hostent_buffer, - PL_reentrant_buffer->_hostent_size, char); + RenewDouble(PL_reentrant_buffer->_hostent_buffer, + &PL_reentrant_buffer->_hostent_size, char); switch (PL_op->op_type) { case OP_GHBYADDR: p0 = va_arg(ap, void *); @@ -911,9 +884,8 @@ Perl_reentrant_retry(const char *f, ...) #endif { Gid_t gid; - PL_reentrant_buffer->_grent_size *= 2; - Renew(PL_reentrant_buffer->_grent_buffer, - PL_reentrant_buffer->_grent_size, char); + RenewDouble(PL_reentrant_buffer->_grent_buffer, + &PL_reentrant_buffer->_grent_size, char); switch (PL_op->op_type) { case OP_GGRNAM: p0 = va_arg(ap, void *); @@ -946,9 +918,8 @@ Perl_reentrant_retry(const char *f, ...) #endif { Netdb_net_t net; - PL_reentrant_buffer->_netent_size *= 2; - Renew(PL_reentrant_buffer->_netent_buffer, - PL_reentrant_buffer->_netent_size, char); + RenewDouble(PL_reentrant_buffer->_netent_buffer, + &PL_reentrant_buffer->_netent_size, char); switch (PL_op->op_type) { case OP_GNBYADDR: net = va_arg(ap, Netdb_net_t); @@ -978,9 +949,8 @@ Perl_reentrant_retry(const char *f, ...) #endif { Uid_t uid; - PL_reentrant_buffer->_pwent_size *= 2; - Renew(PL_reentrant_buffer->_pwent_buffer, - PL_reentrant_buffer->_pwent_size, char); + RenewDouble(PL_reentrant_buffer->_pwent_buffer, + &PL_reentrant_buffer->_pwent_size, char); switch (PL_op->op_type) { case OP_GPWNAM: p0 = va_arg(ap, void *); @@ -992,8 +962,10 @@ Perl_reentrant_retry(const char *f, ...) uid = va_arg(ap, Uid_t); #endif retptr = getpwuid(uid); break; +#if defined(HAS_GETPWENT) || defined(HAS_GETPWENT_R) case OP_GPWENT: retptr = getpwent(); break; +#endif default: SETERRNO(ERANGE, LIB_INVARG); break; @@ -1012,9 +984,8 @@ Perl_reentrant_retry(const char *f, ...) PERL_REENTRANT_MAXSIZE / 2) #endif { - PL_reentrant_buffer->_protoent_size *= 2; - Renew(PL_reentrant_buffer->_protoent_buffer, - PL_reentrant_buffer->_protoent_size, char); + RenewDouble(PL_reentrant_buffer->_protoent_buffer, + &PL_reentrant_buffer->_protoent_size, char); switch (PL_op->op_type) { case OP_GPBYNAME: p0 = va_arg(ap, void *); @@ -1042,9 +1013,8 @@ Perl_reentrant_retry(const char *f, ...) PERL_REENTRANT_MAXSIZE / 2) #endif { - PL_reentrant_buffer->_servent_size *= 2; - Renew(PL_reentrant_buffer->_servent_buffer, - PL_reentrant_buffer->_servent_size, char); + RenewDouble(PL_reentrant_buffer->_servent_buffer, + &PL_reentrant_buffer->_servent_size, char); switch (PL_op->op_type) { case OP_GSBYNAME: p0 = va_arg(ap, void *); @@ -1084,7 +1054,6 @@ asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD* 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 | |I_D|V_D|D=struct hostent_data* endnetent |netdb | |I_D|V_D|D=struct netent_data* @@ -1111,7 +1080,6 @@ getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data* getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data* getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI -random |stdlib |struct random_data|I_iS|I_lS|I_St|i=int*|l=long*|t=int32_t* readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR* readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR* setgrent |grp | |I_H|V_H @@ -1121,8 +1089,6 @@ setnetent I |netdb | |I_ID|V_ID|D=struct netent_data* setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data* setpwent |pwd | |I_H|V_H setservent I |netdb | |I_ID|V_ID|D=struct servent_data* -srand48 L |stdlib |struct drand48_data |I_LS -srandom T |stdlib |struct random_data|I_TS|T=unsigned int strerror I |string | |I_IBW|I_IBI|B_IBW tmpnam B |stdio | |B_B ttyname I |unistd | |I_IBW|I_IBI|B_IBI