X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=reentr.pl;h=049b06eed1d0dd1a8c0f882e360287b18230a681;hb=df44d732c379359119ddcbb4645f9d1a2c1ffec2;hp=ee94c8d64115db520e9c77bd14750b6b3a231d1e;hpb=a845a0d454e0f00755bd9ac955d4d658c0af2872;p=p5sagit%2Fp5-mst-13.2.git diff --git a/reentr.pl b/reentr.pl index ee94c8d..049b06e 100644 --- a/reentr.pl +++ b/reentr.pl @@ -5,6 +5,11 @@ # and optionally also the relevant metaconfig units (-U option). # +BEGIN { + # Get function prototypes + require 'regen_lib.pl'; +} + use strict; use Getopt::Std; my %opts; @@ -35,23 +40,41 @@ my %map = ( # Example #3: S_CBI means type func_r(const char*, char*, int) +safer_unlink 'reentr.h'; die "reentr.h: $!" unless open(H, ">reentr.h"); +binmode H; select H; print <. + */ + +#ifndef PERL_REENTR_API +# if defined(PERL_CORE) || defined(PERL_EXT) +# define PERL_REENTR_API 1 +# else +# define PERL_REENTR_API 0 +# endif +#endif #ifdef USE_REENTRANT_API @@ -59,7 +82,8 @@ print <) { # 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")) { + binmode U; select U; } @@ -329,7 +365,7 @@ sub pushssif { sub pushinitfree { my $func = shift; push @init, <_${func}_buffer, PL_reentrant_buffer->_${func}_size, char); + Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char); EOF push @free, <_${func}_buffer); @@ -365,6 +401,7 @@ EOF EOF } } + return if @F == 1; push @define, <_${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, <_${func}_struct_buffer); #endif EOF pushssif $endif; } - elsif ($func =~ /^(drand48|gmtime|localtime|random)$/) { + elsif ($func =~ /^(drand48|gmtime|localtime|random|srandom)$/) { pushssif $ifdef; push @struct, <$sz = sysconf($sc); - if (PL_reentrant_buffer->$sz == -1) + if (PL_reentrant_buffer->$sz == (size_t) -1) PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE; # else # if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ) @@ -573,7 +613,7 @@ EOF EOF push @init, <_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char); + Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char); #endif EOF push @free, <_${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' ? @@ -672,8 +715,18 @@ EOF } split '', $b; $w = ", $w" if length $v; } + my $call = "${func}_r($v$w)"; - $call = "((errno = $call))" if $r eq 'I' && $func ne 'random'; + if ($func eq 'localtime') { + $call = "L_R_TZSET $call"; + } + + # Must make OpenBSD happy + my $memzero = ''; + if($p =~ /D$/ && + ($genfunc eq 'protoent' || $genfunc eq 'servent')) { + $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),'; + } push @wrap, <reentr.c"); +binmode C; select C; print <op_type) { case OP_GGRNAM: p0 = va_arg(ap, void *); - retptr = getgrnam(p0); break; + retptr = getgrnam((char *)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; @@ -884,7 +962,7 @@ Perl_reentrant_retry(const char *f, ...) retptr = getnetbyaddr(net, anint); break; case OP_GNBYNAME: p0 = va_arg(ap, void *); - retptr = getnetbyname(p0); break; + retptr = getnetbyname((char *)p0); break; case OP_GNETENT: retptr = getnetent(); break; default: @@ -912,9 +990,13 @@ Perl_reentrant_retry(const char *f, ...) switch (PL_op->op_type) { case OP_GPWNAM: p0 = va_arg(ap, void *); - retptr = getpwnam(p0); break; + retptr = getpwnam((char *)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; @@ -942,7 +1024,7 @@ Perl_reentrant_retry(const char *f, ...) switch (PL_op->op_type) { case OP_GPBYNAME: p0 = va_arg(ap, void *); - retptr = getprotobyname(p0); break; + retptr = getprotobyname((char *)p0); break; case OP_GPBYNUMBER: anint = va_arg(ap, int); retptr = getprotobynumber(anint); break; @@ -973,11 +1055,11 @@ Perl_reentrant_retry(const char *f, ...) case OP_GSBYNAME: p0 = va_arg(ap, void *); p1 = va_arg(ap, void *); - retptr = getservbyname(p0, p1); break; + retptr = getservbyname((char *)p0, (char *)p1); break; case OP_GSBYPORT: anint = va_arg(ap, int); p0 = va_arg(ap, void *); - retptr = getservbyport(anint, p0); break; + retptr = getservbyport(anint, (char *)p0); break; case OP_GSERVENT: retptr = getservent(); break; default: @@ -994,10 +1076,13 @@ Perl_reentrant_retry(const char *f, ...) } va_end(ap); +#else + PERL_UNUSED_ARG(f); #endif return retptr; } +/* ex: set ro: */ EOF __DATA__ @@ -1018,7 +1103,7 @@ 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|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 +getlogin |unistd |char |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|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*