X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/aa418cf14f5423600e2de800942ca69bd80882ac..be92ff21b1b31bf647f96c308fe1a246f1974bde:/reentr.pl diff --git a/reentr.pl b/reentr.pl index 19b9852..0622a80 100644 --- a/reentr.pl +++ b/reentr.pl @@ -41,7 +41,7 @@ print <) { # Read in the protypes. @@ -188,7 +189,7 @@ while () { # Read in the protypes. print <) { # Read in the protypes. ?S:. ?S:${func}_r_proto: ?S: This variable encodes the prototype of ${func}_r. +?S: It is zero if d_${func}_r is undef, and one of the +?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r +?S: is defined. ?S:. ?C:HAS_${FUNC}_R: ?C: This symbol, if defined, indicates that the ${func}_r routine @@ -211,6 +215,9 @@ while () { # Read in the protypes. ?C:. ?C:${FUNC}_R_PROTO: ?C: This symbol encodes the prototype of ${func}_r. +?C: It is zero if d_${func}_r is undef, and one of the +?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r +?C: is defined. ?C:. ?H:#\$d_${func}_r HAS_${FUNC}_R /**/ ?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/ @@ -253,6 +260,7 @@ EOF $seent{$func} = $type; $seens{$func} = $m{S}; $seend{$func} = $m{D}; + $seenm{$func} = \%m; } if ($opts{U}) { print <_${func}_struct.initialized = 0; +#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD + PL_reentrant_buffer->_${func}_struct_buffer = 0; +#endif +EOF + push @free, <_${func}_struct_buffer); #endif EOF pushssif $endif; } - elsif ($func =~ /^(drand48|gmtime|localtime|random)$/) { + elsif ($func =~ /^(drand48|gmtime|localtime|random|srandom)$/) { pushssif $ifdef; push @struct, <_${genfunc}_size = 1024; -EOF - } else { - push @struct, <_${genfunc}_fptr = NULL; # endif EOF - my $sc = $genfunc eq 'getgrent' ? + my $sc = $genfunc eq 'grent' ? '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX'; - my $sz = $genfunc eq 'getgrent' ? - '_grent_size' : '_pwent_size'; - push @size, <_${genfunc}_size = sysconf($sc); + PL_reentrant_buffer->$sz = sysconf($sc); if (PL_reentrant_buffer->$sz == -1) PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; # else # if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ) - PL_reentrant_buffer->_${genfunc}_size = SIABUFSIZ; + PL_reentrant_buffer->$sz = SIABUFSIZ; # else # ifdef __sgi - PL_reentrant_buffer->_${genfunc}_size = BUFSIZ; + PL_reentrant_buffer->$sz = BUFSIZ; # else - PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE; + PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; # endif # endif # endif EOF - } pushinitfree $genfunc; pushssif $endif; } @@ -615,7 +634,9 @@ EOF my $b = $a; my $w = ''; substr($b, 0, $seenu{$func}) = ''; - if ($b =~ /R/) { + if ($func =~ /^random$/) { + $true = "PL_reentrant_buffer->_random_retval"; + } elsif ($b =~ /R/) { $true = "PL_reentrant_buffer->_${genfunc}_ptr"; } elsif ($b =~ /T/ && $func eq 'drand48') { $true = "PL_reentrant_buffer->_${genfunc}_double"; @@ -644,17 +665,20 @@ 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' ? + "&PL_reentrant_buffer->_random_retval" : $_ } split '', $b; $w = ", $w" if length $v; } my $call = "${func}_r($v$w)"; - $call = "((errno = $call))" if $r eq 'I'; push @wrap, <op_type) { #ifdef USE_HOSTENT_BUFFER case OP_GHBYADDR: case OP_GHBYNAME: case OP_GHOSTENT: { - if (PL_reentrant_buffer->_hostent_size <= REENTRANTHALFMAXSIZE) { +#ifdef PERL_REENTRANT_MAXSIZE + if (PL_reentrant_buffer->_hostent_size <= + PERL_REENTRANT_MAXSIZE / 2) +#endif + { PL_reentrant_buffer->_hostent_size *= 2; Renew(PL_reentrant_buffer->_hostent_buffer, PL_reentrant_buffer->_hostent_size, char); @@ -804,6 +837,7 @@ Perl_reentrant_retry(const char *f, ...) case OP_GHOSTENT: retptr = gethostent(); break; default: + SETERRNO(ERANGE, LIB_INVARG); break; } } @@ -815,7 +849,11 @@ Perl_reentrant_retry(const char *f, ...) case OP_GGRGID: case OP_GGRENT: { - if (PL_reentrant_buffer->_grent_size <= REENTRANTHALFMAXSIZE) { +#ifdef PERL_REENTRANT_MAXSIZE + if (PL_reentrant_buffer->_grent_size <= + PERL_REENTRANT_MAXSIZE / 2) +#endif + { Gid_t gid; PL_reentrant_buffer->_grent_size *= 2; Renew(PL_reentrant_buffer->_grent_buffer, @@ -825,11 +863,16 @@ 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; default: + SETERRNO(ERANGE, LIB_INVARG); break; } } @@ -841,7 +884,11 @@ Perl_reentrant_retry(const char *f, ...) case OP_GNBYNAME: case OP_GNETENT: { - if (PL_reentrant_buffer->_netent_size <= REENTRANTHALFMAXSIZE) { +#ifdef PERL_REENTRANT_MAXSIZE + if (PL_reentrant_buffer->_netent_size <= + PERL_REENTRANT_MAXSIZE / 2) +#endif + { Netdb_net_t net; PL_reentrant_buffer->_netent_size *= 2; Renew(PL_reentrant_buffer->_netent_buffer, @@ -857,6 +904,7 @@ Perl_reentrant_retry(const char *f, ...) case OP_GNETENT: retptr = getnetent(); break; default: + SETERRNO(ERANGE, LIB_INVARG); break; } } @@ -868,7 +916,11 @@ Perl_reentrant_retry(const char *f, ...) case OP_GPWUID: case OP_GPWENT: { - if (PL_reentrant_buffer->_pwent_size <= REENTRANTHALFMAXSIZE) { +#ifdef PERL_REENTRANT_MAXSIZE + if (PL_reentrant_buffer->_pwent_size <= + PERL_REENTRANT_MAXSIZE / 2) +#endif + { Uid_t uid; PL_reentrant_buffer->_pwent_size *= 2; Renew(PL_reentrant_buffer->_pwent_buffer, @@ -878,11 +930,16 @@ 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; default: + SETERRNO(ERANGE, LIB_INVARG); break; } } @@ -894,7 +951,11 @@ Perl_reentrant_retry(const char *f, ...) case OP_GPBYNUMBER: case OP_GPROTOENT: { - if (PL_reentrant_buffer->_protoent_size <= REENTRANTHALFMAXSIZE) { +#ifdef PERL_REENTRANT_MAXSIZE + if (PL_reentrant_buffer->_protoent_size <= + PERL_REENTRANT_MAXSIZE / 2) +#endif + { PL_reentrant_buffer->_protoent_size *= 2; Renew(PL_reentrant_buffer->_protoent_buffer, PL_reentrant_buffer->_protoent_size, char); @@ -908,6 +969,7 @@ Perl_reentrant_retry(const char *f, ...) case OP_GPROTOENT: retptr = getprotoent(); break; default: + SETERRNO(ERANGE, LIB_INVARG); break; } } @@ -919,7 +981,11 @@ Perl_reentrant_retry(const char *f, ...) case OP_GSBYPORT: case OP_GSERVENT: { - if (PL_reentrant_buffer->_servent_size <= REENTRANTHALFMAXSIZE) { +#ifdef PERL_REENTRANT_MAXSIZE + if (PL_reentrant_buffer->_servent_size <= + PERL_REENTRANT_MAXSIZE / 2) +#endif + { PL_reentrant_buffer->_servent_size *= 2; Renew(PL_reentrant_buffer->_servent_buffer, PL_reentrant_buffer->_servent_size, char); @@ -935,6 +1001,7 @@ Perl_reentrant_retry(const char *f, ...) case OP_GSERVENT: retptr = getservent(); break; default: + SETERRNO(ERANGE, LIB_INVARG); break; } } @@ -968,11 +1035,11 @@ 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 -gethostbyaddr CWI |netdb |struct hostent |I_CWISBWRE|S_CWISBWIE|S_CWISBIE|S_TWISBIE|S_CIISBIE|S_CSBIE|S_TSBIE|I_CWISD|I_CIISD|I_CII|D=struct hostent_data*|T=const void* +gethostbyaddr CWI |netdb |struct hostent |I_CWISBWRE|S_CWISBWIE|S_CWISBIE|S_TWISBIE|S_CIISBIE|S_CSBIE|S_TSBIE|I_CWISD|I_CIISD|I_CII|I_TsISBWRE|D=struct hostent_data*|T=const void*|s=socklen_t gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data* gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data* getlogin |unistd | |I_BW|I_BI|B_BW|B_BI -getnetbyaddr LI |netdb |struct netent |I_UISBWRE|I_LISBI|S_TISBI|S_LISBI|I_TISD|I_LISD|I_IISD|D=struct netent_data*|T=in_addr_t|U=unsigned long +getnetbyaddr LI |netdb |struct netent |I_UISBWRE|I_LISBI|S_TISBI|S_LISBI|I_TISD|I_LISD|I_IISD|I_uISBWRE|D=struct netent_data*|T=in_addr_t|U=unsigned long|u=uint32_t getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data* getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data* getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data* @@ -987,7 +1054,7 @@ 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 gmtime T |time |struct tm |S_TS|I_TS|T=const time_t* localtime T |time |struct tm |S_TS|I_TS|T=const time_t* -random |stdlib |struct random_data|I_TS|T=int* +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