4 # Generate the reentr.c and reentr.h,
5 # and optionally also the relevant metaconfig units (-U option).
9 # Get function prototypes
10 require 'regen_lib.pl';
20 A => "char*", # as an input argument
21 B => "char*", # as an output argument
22 C => "const char*", # as a read-only input argument
30 # (See the definitions after __DATA__.)
31 # In func|inc|type|... a "S" means "type*", and a "R" means "type**".
32 # (The "types" are often structs, such as "struct passwd".)
34 # After the prototypes one can have |X=...|Y=... to define more types.
35 # A commonly used extra type is to define D to be equal to "type_data",
36 # for example "struct_hostent_data to" go with "struct hostent".
38 # Example #1: I_XSBWR means int func_r(X, type, char*, size_t, type**)
39 # Example #2: S_SBIE means type func_r(type, char*, int, int*)
40 # Example #3: S_CBI means type func_r(const char*, char*, int)
43 safer_unlink 'reentr.h';
44 die "reentr.h: $!" unless open(H, ">reentr.h");
48 /* -*- buffer-read-only: t -*-
52 * Copyright (C) 2002, 2003, 2005, 2006 by Larry Wall and others
54 * You may distribute under the terms of either the GNU General Public
55 * License or the Artistic License, as specified in the README file.
57 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
58 * This file is built by reentr.pl from data in reentr.pl.
64 #ifdef USE_REENTRANT_API
67 # define PL_REENTRANT_RETINT PL_reentrant_retint
70 /* Deprecations: some platforms have the said reentrant interfaces
71 * but they are declared obsolete and are not to be used. Often this
72 * means that the platform has threadsafed the interfaces (hopefully).
73 * All this is OS version dependent, so we are of course fooling ourselves.
74 * If you know of more deprecations on some platforms, please add your own. */
79 # undef HAS_ENDGRENT_R
80 # undef HAS_ENDPWENT_R
81 # undef HAS_GETGRENT_R
82 # undef HAS_GETPWENT_R
83 # undef HAS_SETLOCALE_R
85 # undef HAS_STRERROR_R
86 # define NETDB_R_OBSOLETE
89 #if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
91 # undef HAS_STRERROR_R
92 # define NETDB_R_OBSOLETE
95 #ifdef NETDB_R_OBSOLETE
96 # undef HAS_ENDHOSTENT_R
97 # undef HAS_ENDNETENT_R
98 # undef HAS_ENDPROTOENT_R
99 # undef HAS_ENDSERVENT_R
100 # undef HAS_GETHOSTBYADDR_R
101 # undef HAS_GETHOSTBYNAME_R
102 # undef HAS_GETHOSTENT_R
103 # undef HAS_GETNETBYADDR_R
104 # undef HAS_GETNETBYNAME_R
105 # undef HAS_GETNETENT_R
106 # undef HAS_GETPROTOBYNAME_R
107 # undef HAS_GETPROTOBYNUMBER_R
108 # undef HAS_GETPROTOENT_R
109 # undef HAS_GETSERVBYNAME_R
110 # undef HAS_GETSERVBYPORT_R
111 # undef HAS_GETSERVENT_R
112 # undef HAS_SETHOSTENT_R
113 # undef HAS_SETNETENT_R
114 # undef HAS_SETPROTOENT_R
115 # undef HAS_SETSERVENT_R
128 # include <stdlib.h> /* drand48_data */
135 #ifdef HAS_GETSPNAM_R
143 my %seenh; # the different prototypes signatures for this function
144 my %seena; # the different prototypes signatures for this function in order
145 my @seenf; # all the seen functions
146 my %seenp; # the different prototype signatures for all functions
147 my %seent; # the return type of this function
148 my %seens; # the type of this function's "S"
149 my %seend; # the type of this function's "D"
150 my %seenm; # all the types
151 my %seenu; # the length of the argument list of this function
152 my %seenr; # the return type of this function
154 while (<DATA>) { # Read in the protypes.
157 my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1);
159 # Split off the real function name and the argument list.
160 ($func, $u) = split(' ', $func);
161 $u = "V_V" unless $u;
162 ($r, $u) = ($u =~ /^(.)_(.+)/);
163 $seenu{$func} = $u eq 'V' ? 0 : length $u;
165 my $FUNC = uc $func; # for output.
173 # Set any special mapping variables (like X=x_t)
175 while ($p[-1] =~ /=/) {
176 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
182 # If given the -U option open up the metaconfig unit for this function.
183 if ($opts{U} && open(U, ">d_${func}_r.U")) {
189 # The metaconfig units needs prerequisite dependencies.
193 if ($hdr ne 'stdio') { # There's no i_stdio.
196 $prereqsh = "\$$prereqs $prereqh";
198 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
199 push @prereq, $prereqs;
200 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
201 if ($hdr eq 'time') {
202 $hdrs .= " \$i_systime sys/time.h";
203 push @prereq, 'i_systime';
205 # Output the metaconfig unit header.
207 ?RCS: \$Id: d_${func}_r.U,v $
209 ?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
211 ?RCS: You may distribute under the terms of either the GNU General Public
212 ?RCS: License or the Artistic License, as specified in the README file.
214 ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
216 ?MAKE:d_${func}_r ${func}_r_proto: @prereq
217 ?MAKE: -pick add \$@ %<
219 ?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
220 ?S: which indicates to the C program that the ${func}_r()
221 ?S: routine is available.
224 ?S: This variable encodes the prototype of ${func}_r.
225 ?S: It is zero if d_${func}_r is undef, and one of the
226 ?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
230 ?C: This symbol, if defined, indicates that the ${func}_r routine
231 ?C: is available to ${func} re-entrantly.
234 ?C: This symbol encodes the prototype of ${func}_r.
235 ?C: It is zero if d_${func}_r is undef, and one of the
236 ?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
239 ?H:#\$d_${func}_r HAS_${FUNC}_R /**/
240 ?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
242 ?T:try hdrs d_${func}_r_proto
243 ?LINT:set d_${func}_r
244 ?LINT:set ${func}_r_proto
245 : see if ${func}_r exists
246 set ${func}_r d_${func}_r
248 case "\$d_${func}_r" in
253 case "\$d_${func}_r_proto:\$usethreads" in
254 ":define") d_${func}_r_proto=define
255 set d_${func}_r_proto ${func}_r \$hdrs
259 case "\$d_${func}_r_proto" in
264 my ($r, $a) = ($p =~ /^(.)_(.+)/);
265 my $v = join(", ", map { $m{$_} } split '', $a);
268 case "\$${func}_r_proto" in
269 ''|0) try='$m{$r} ${func}_r($v);'
270 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
274 $seenh{$func}->{$p}++;
275 push @{$seena{$func}}, $p;
277 $seent{$func} = $type;
278 $seens{$func} = $m{S};
279 $seend{$func} = $m{D};
284 case "\$${func}_r_proto" in
285 ''|0) d_${func}_r=undef
287 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
288 * ) case "\$${func}_r_proto" in
290 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
292 echo "Prototype: \$try" ;;
295 *) case "\$usethreads" in
296 define) echo "${func}_r has no prototype, not using it." >&4 ;;
314 # Prepare to continue writing the reentr.h.
319 # Write out all the known prototype signatures.
321 for my $p (sort keys %seenp) {
322 print "#define REENTRANT_PROTO_${p} ${i}\n";
327 my @struct; # REENTR struct members
328 my @size; # struct member buffer size initialization code
329 my @init; # struct member buffer initialization (malloc) code
330 my @free; # struct member buffer release (free) code
331 my @wrap; # the wrapper (foo(a) -> foo_r(a,...)) cpp code
332 my @define; # defines for optional features
336 join " || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @_;
349 Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
352 Safefree(PL_reentrant_buffer->_${func}_buffer);
357 my ($n, $p, @F) = @_;
361 /* The @F using \L$n? */
367 my $HAS = "${FUNC}_R_HAS_$n";
369 my @h = grep { /$p/ } @{$seena{$func}};
370 unless (defined $GENFUNC) {
372 $GENFUNC =~ s/^GET//;
375 push @define, "#if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
388 /* Any of the @F using \L$n? */
391 push @define, "#if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
393 # define USE_${GENFUNC}_$n
395 # undef USE_${GENFUNC}_$n
401 define('BUFFER', 'B',
402 qw(getgrent getgrgid getgrnam));
405 qw(getgrent getgrgid getgrnam));
407 qw(getpwent getpwnam getpwuid));
409 qw(getspent getspnam));
412 qw(getgrent getgrgid getgrnam setgrent endgrent));
414 qw(getpwent getpwnam getpwuid setpwent endpwent));
416 define('BUFFER', 'B',
417 qw(getpwent getpwgid getpwnam));
420 qw(gethostent gethostbyaddr gethostbyname));
422 qw(getnetent getnetbyaddr getnetbyname));
424 qw(getprotoent getprotobyname getprotobynumber));
426 qw(getservent getservbyname getservbyport));
428 define('BUFFER', 'B',
429 qw(gethostent gethostbyaddr gethostbyname));
430 define('BUFFER', 'B',
431 qw(getnetent getnetbyaddr getnetbyname));
432 define('BUFFER', 'B',
433 qw(getprotoent getprotobyname getprotobynumber));
434 define('BUFFER', 'B',
435 qw(getservent getservbyname getservbyport));
438 qw(gethostent gethostbyaddr gethostbyname));
440 qw(getnetent getnetbyaddr getnetbyname));
442 # The following loop accumulates the "ssif" (struct, size, init, free)
443 # sections that declare the struct members (in reentr.h), and the buffer
444 # size initialization, buffer initialization (malloc), and buffer
445 # release (free) code (in reentr.c).
447 # The loop also contains a lot of intrinsic logic about groups of
448 # functions (since functions of certain kind operate the same way).
450 for my $func (@seenf) {
452 my $ifdef = "#ifdef HAS_${FUNC}_R\n";
453 my $endif = "#endif /* HAS_${FUNC}_R */\n";
454 if (exists $seena{$func}) {
455 my @p = @{$seena{$func}};
456 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
459 char* _${func}_buffer;
460 size_t _${func}_size;
463 PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
468 elsif ($func =~ /^(crypt)$/) {
471 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
472 $seend{$func} _${func}_data;
474 $seent{$func} _${func}_struct;
478 #if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
479 PL_reentrant_buffer->_${func}_struct_buffer = 0;
483 #if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
484 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
489 elsif ($func =~ /^(drand48|gmtime|localtime)$/) {
492 $seent{$func} _${func}_struct;
494 if ($1 eq 'drand48') {
496 double _${func}_double;
501 elsif ($func =~ /^random$/) {
504 # if RANDOM_R_PROTO != REENTRANT_PROTO_I_St
505 $seent{$func} _${func}_struct;
510 elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) {
512 # 'genfunc' can be read either as 'generic' or 'genre',
513 # it represents a group of functions.
515 $genfunc =~ s/nam/ent/g;
516 $genfunc =~ s/^get//;
517 my $GENFUNC = uc $genfunc;
519 $seent{$func} _${genfunc}_struct;
520 char* _${genfunc}_buffer;
521 size_t _${genfunc}_size;
524 # ifdef USE_${GENFUNC}_PTR
525 $seent{$func}* _${genfunc}_ptr;
529 # ifdef USE_${GENFUNC}_FPTR
530 FILE* _${genfunc}_fptr;
534 # ifdef USE_${GENFUNC}_FPTR
535 PL_reentrant_buffer->_${genfunc}_fptr = NULL;
538 my $sc = $genfunc eq 'grent' ?
539 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
540 my $sz = "_${genfunc}_size";
542 # if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
543 PL_reentrant_buffer->$sz = sysconf($sc);
544 if (PL_reentrant_buffer->$sz == -1)
545 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
547 # if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
548 PL_reentrant_buffer->$sz = SIABUFSIZ;
551 PL_reentrant_buffer->$sz = BUFSIZ;
553 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
558 pushinitfree $genfunc;
561 elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
564 $genfunc =~ s/byname/ent/;
565 $genfunc =~ s/^get//;
566 my $GENFUNC = uc $genfunc;
567 my $D = ifprotomatch($FUNC, grep {/D/} @p);
568 my $d = $seend{$func};
569 $d =~ s/\*$//; # snip: we need need the base type.
571 $seent{$func} _${genfunc}_struct;
575 char* _${genfunc}_buffer;
576 size_t _${genfunc}_size;
578 # ifdef USE_${GENFUNC}_PTR
579 $seent{$func}* _${genfunc}_ptr;
583 # ifdef USE_${GENFUNC}_ERRNO
584 int _${genfunc}_errno;
589 PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE;
594 Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
599 Safefree(PL_reentrant_buffer->_${genfunc}_buffer);
604 elsif ($func =~ /^(readdir|readdir64)$/) {
606 my $R = ifprotomatch($FUNC, grep {/R/} @p);
608 $seent{$func}* _${func}_struct;
609 size_t _${func}_size;
611 $seent{$func}* _${func}_ptr;
615 /* This is the size Solaris recommends.
616 * (though we go static, should use pathconf() instead) */
617 PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1;
620 PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size);
623 Safefree(PL_reentrant_buffer->_${func}_struct);
634 # Write out what we have learned.
637 my $v = join(", ", @v[0..$seenu{$func}-1]);
639 my ($r, $a) = split '_', $p;
640 my $test = $r eq 'I' ? ' == 0' : '';
643 if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
644 $genfunc = "${1}ent";
645 } elsif ($genfunc eq 'srand48') {
646 $genfunc = "drand48";
650 substr($b, 0, $seenu{$func}) = '';
651 if ($func =~ /^random$/) {
652 $true = "PL_reentrant_buffer->_random_retval";
653 } elsif ($b =~ /R/) {
654 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
655 } elsif ($b =~ /T/ && $func eq 'drand48') {
656 $true = "PL_reentrant_buffer->_${genfunc}_double";
657 } elsif ($b =~ /S/) {
658 if ($func =~ /^readdir/) {
659 $true = "PL_reentrant_buffer->_${genfunc}_struct";
661 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
663 } elsif ($b =~ /B/) {
664 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
670 "&PL_reentrant_buffer->_${genfunc}_ptr" :
672 "&PL_reentrant_buffer->_${genfunc}_errno" :
674 "PL_reentrant_buffer->_${genfunc}_buffer" :
676 "PL_reentrant_buffer->_${genfunc}_size" :
678 "&PL_reentrant_buffer->_${genfunc}_fptr" :
680 "&PL_reentrant_buffer->_${genfunc}_data" :
682 ($func =~ /^readdir\d*$/ ?
683 "PL_reentrant_buffer->_${genfunc}_struct" :
685 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
686 "&PL_reentrant_buffer->_${genfunc}_struct") :
687 $_ eq 'T' && $func eq 'drand48' ?
688 "&PL_reentrant_buffer->_${genfunc}_double" :
689 $_ =~ /^[ilt]$/ && $func eq 'random' ?
690 "&PL_reentrant_buffer->_random_retval" :
693 $w = ", $w" if length $v;
695 my $call = "${func}_r($v$w)";
697 # Must make OpenBSD happy
700 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
701 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data))';
704 # if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
706 if ($r eq 'V' || $r eq 'B') {
708 # define $func($v) $call
711 if ($func =~ /^get/) {
712 my $rv = $v ? ", $v" : "";
714 $call = qq[((PL_REENTRANT_RETINT = $call)$test ? $true : (((PL_REENTRANT_RETINT == ERANGE) || (errno == ERANGE)) ? ($seenm{$func}{$seenr{$func}})Perl_reentrant_retry("$func"$rv) : 0))];
715 my $arg = join(", ", map { $seenm{$func}{substr($a,$_,1)}." ".$v[$_] } 0..$seenu{$func}-1);
716 my $ret = $seenr{$func} eq 'V' ? "" : "return ";
717 my $memzero_ = $memzero ? "$memzero, " : "";
720 # define $func($v) ($memzero_$call)
722 # if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC)
723 # define $func($v) ({int PL_REENTRANT_RETINT; $memzero; $call;})
725 # define $func($v) Perl_reentr_$func($v)
726 static $seenm{$func}{$seenr{$func}} Perl_reentr_$func($arg) {
728 int PL_REENTRANT_RETINT;
737 # define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
742 # define $func($v) ($call$test ? $true : 0)
751 push @wrap, $endif, "\n";
755 # New struct members added here to maintain binary compatibility with 5.8.0
757 if (exists $seena{crypt}) {
760 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
762 struct crypt_data *_crypt_struct_buffer;
764 #endif /* HAS_CRYPT_R */
768 if (exists $seena{random}) {
771 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_iS
774 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_lS
777 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_St
778 $seent{random} _random_struct;
779 int32_t _random_retval;
781 #endif /* HAS_RANDOM_R */
785 if (exists $seena{srandom}) {
788 $seent{srandom} _srandom_struct;
789 #endif /* HAS_SRANDOM_R */
798 /* Defines for indicating which special features are supported. */
803 int dummy; /* cannot have empty structs */
806 #endif /* USE_REENTRANT_API */
813 die "reentr.inc: $!" unless open(H, ">reentr.inc");
822 * You may distribute under the terms of either the GNU General Public
823 * License or the Artistic License, as specified in the README file.
825 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
826 * This file is built by reentrl.pl from data in reentr.pl.
832 #ifdef USE_REENTRANT_API
835 * As of OpenBSD 3.7, reentrant functions are now working, they just are
836 * incompatible with everyone else. To make OpenBSD happy, we have to
837 * memzero out certain structures before calling the functions.
839 #if defined(__OpenBSD__)
840 # define REENTR_MEMZERO(a,b) memzero(a,b)
842 # define REENTR_MEMZERO(a,b) 0
845 /* The reentrant wrappers. */
849 #endif /* USE_REENTRANT_API */
858 # Prepare to write the reentr.c.
860 safer_unlink 'reentr.c';
861 die "reentr.c: $!" unless open(C, ">reentr.c");
865 /* -*- buffer-read-only: t -*-
869 * Copyright (C) 2002, 2003, 2005, 2006 by Larry Wall and others
871 * You may distribute under the terms of either the GNU General Public
872 * License or the Artistic License, as specified in the README file.
874 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
875 * This file is built by reentr.pl from data in reentr.pl.
877 * "Saruman," I said, standing away from him, "only one hand at a time can
878 * wield the One, and you know that well, so do not trouble to say we!"
880 * This file contains a collection of automatically created wrappers
881 * (created by running reentr.pl) for reentrant (thread-safe) versions of
882 * various library calls, such as getpwent_r. The wrapping is done so
883 * that other files like pp_sys.c calling those library functions need not
884 * care about the differences between various platforms' idiosyncrasies
885 * regarding these reentrant interfaces.
889 #define PERL_IN_REENTR_C
894 Perl_reentrant_size(pTHX) {
895 #ifdef USE_REENTRANT_API
896 #define REENTRANTSMALLSIZE 256 /* Make something up. */
897 #define REENTRANTUSUALSIZE 4096 /* Make something up. */
899 #endif /* USE_REENTRANT_API */
903 Perl_reentrant_init(pTHX) {
904 #ifdef USE_REENTRANT_API
905 Newx(PL_reentrant_buffer, 1, REENTR);
906 Perl_reentrant_size(aTHX);
908 #endif /* USE_REENTRANT_API */
912 Perl_reentrant_free(pTHX) {
913 #ifdef USE_REENTRANT_API
915 Safefree(PL_reentrant_buffer);
916 #endif /* USE_REENTRANT_API */
920 Perl_reentrant_retry(const char *f, ...)
924 #ifdef USE_REENTRANT_API
925 # 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)
928 # if defined(USE_SERVENT_BUFFER)
931 # if defined(USE_HOSTENT_BUFFER)
934 # if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
941 switch (PL_op->op_type) {
942 #ifdef USE_HOSTENT_BUFFER
947 #ifdef PERL_REENTRANT_MAXSIZE
948 if (PL_reentrant_buffer->_hostent_size <=
949 PERL_REENTRANT_MAXSIZE / 2)
952 PL_reentrant_buffer->_hostent_size *= 2;
953 Renew(PL_reentrant_buffer->_hostent_buffer,
954 PL_reentrant_buffer->_hostent_size, char);
955 switch (PL_op->op_type) {
957 p0 = va_arg(ap, void *);
958 asize = va_arg(ap, size_t);
959 anint = va_arg(ap, int);
960 retptr = gethostbyaddr(p0, asize, anint); break;
962 p0 = va_arg(ap, void *);
963 retptr = gethostbyname((char *)p0); break;
965 retptr = gethostent(); break;
967 SETERRNO(ERANGE, LIB_INVARG);
974 #ifdef USE_GRENT_BUFFER
979 #ifdef PERL_REENTRANT_MAXSIZE
980 if (PL_reentrant_buffer->_grent_size <=
981 PERL_REENTRANT_MAXSIZE / 2)
985 PL_reentrant_buffer->_grent_size *= 2;
986 Renew(PL_reentrant_buffer->_grent_buffer,
987 PL_reentrant_buffer->_grent_size, char);
988 switch (PL_op->op_type) {
990 p0 = va_arg(ap, void *);
991 retptr = getgrnam((char *)p0); break;
993 #if Gid_t_size < INTSIZE
994 gid = (Gid_t)va_arg(ap, int);
996 gid = va_arg(ap, Gid_t);
998 retptr = getgrgid(gid); break;
1000 retptr = getgrent(); break;
1002 SETERRNO(ERANGE, LIB_INVARG);
1009 #ifdef USE_NETENT_BUFFER
1014 #ifdef PERL_REENTRANT_MAXSIZE
1015 if (PL_reentrant_buffer->_netent_size <=
1016 PERL_REENTRANT_MAXSIZE / 2)
1020 PL_reentrant_buffer->_netent_size *= 2;
1021 Renew(PL_reentrant_buffer->_netent_buffer,
1022 PL_reentrant_buffer->_netent_size, char);
1023 switch (PL_op->op_type) {
1025 net = va_arg(ap, Netdb_net_t);
1026 anint = va_arg(ap, int);
1027 retptr = getnetbyaddr(net, anint); break;
1029 p0 = va_arg(ap, void *);
1030 retptr = getnetbyname((char *)p0); break;
1032 retptr = getnetent(); break;
1034 SETERRNO(ERANGE, LIB_INVARG);
1041 #ifdef USE_PWENT_BUFFER
1046 #ifdef PERL_REENTRANT_MAXSIZE
1047 if (PL_reentrant_buffer->_pwent_size <=
1048 PERL_REENTRANT_MAXSIZE / 2)
1052 PL_reentrant_buffer->_pwent_size *= 2;
1053 Renew(PL_reentrant_buffer->_pwent_buffer,
1054 PL_reentrant_buffer->_pwent_size, char);
1055 switch (PL_op->op_type) {
1057 p0 = va_arg(ap, void *);
1058 retptr = getpwnam((char *)p0); break;
1060 #if Uid_t_size < INTSIZE
1061 uid = (Uid_t)va_arg(ap, int);
1063 uid = va_arg(ap, Uid_t);
1065 retptr = getpwuid(uid); break;
1067 retptr = getpwent(); break;
1069 SETERRNO(ERANGE, LIB_INVARG);
1076 #ifdef USE_PROTOENT_BUFFER
1081 #ifdef PERL_REENTRANT_MAXSIZE
1082 if (PL_reentrant_buffer->_protoent_size <=
1083 PERL_REENTRANT_MAXSIZE / 2)
1086 PL_reentrant_buffer->_protoent_size *= 2;
1087 Renew(PL_reentrant_buffer->_protoent_buffer,
1088 PL_reentrant_buffer->_protoent_size, char);
1089 switch (PL_op->op_type) {
1091 p0 = va_arg(ap, void *);
1092 retptr = getprotobyname((char *)p0); break;
1094 anint = va_arg(ap, int);
1095 retptr = getprotobynumber(anint); break;
1097 retptr = getprotoent(); break;
1099 SETERRNO(ERANGE, LIB_INVARG);
1106 #ifdef USE_SERVENT_BUFFER
1111 #ifdef PERL_REENTRANT_MAXSIZE
1112 if (PL_reentrant_buffer->_servent_size <=
1113 PERL_REENTRANT_MAXSIZE / 2)
1116 PL_reentrant_buffer->_servent_size *= 2;
1117 Renew(PL_reentrant_buffer->_servent_buffer,
1118 PL_reentrant_buffer->_servent_size, char);
1119 switch (PL_op->op_type) {
1121 p0 = va_arg(ap, void *);
1122 p1 = va_arg(ap, void *);
1123 retptr = getservbyname((char *)p0, (char *)p1); break;
1125 anint = va_arg(ap, int);
1126 p0 = va_arg(ap, void *);
1127 retptr = getservbyport(anint, (char *)p0); break;
1129 retptr = getservent(); break;
1131 SETERRNO(ERANGE, LIB_INVARG);
1139 /* Not known how to retry, so just fail. */
1152 asctime B_S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
1153 crypt B_CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
1154 ctermid B_B |stdio | |B_B
1155 ctime B_S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
1156 drand48 d_V |stdlib |struct drand48_data |I_ST|T=double*|d=double
1157 endgrent |grp | |I_H|V_H
1158 endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1159 endnetent |netdb | |I_D|V_D|D=struct netent_data*
1160 endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
1161 endpwent |pwd | |I_H|V_H
1162 endservent |netdb | |I_D|V_D|D=struct servent_data*
1163 getgrent S_V |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1164 getgrgid S_T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1165 getgrnam S_C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
1166 gethostbyaddr S_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
1167 gethostbyname S_C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1168 gethostent S_V |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
1169 getlogin B_V |unistd |char |I_BW|I_BI|B_BW|B_BI
1170 getnetbyaddr S_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
1171 getnetbyname S_C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1172 getnetent S_V |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1173 getprotobyname S_C |netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1174 getprotobynumber S_I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1175 getprotoent S_V |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1176 getpwent S_V |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1177 getpwnam S_C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1178 getpwuid S_T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1179 getservbyname S_CC |netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1180 getservbyport S_IC |netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1181 getservent S_V |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1182 getspnam S_C |shadow |struct spwd |I_CSBWR|S_CSBI
1183 gmtime S_T |time |struct tm |S_TS|I_TS|T=const time_t*
1184 localtime S_T |time |struct tm |S_TS|I_TS|T=const time_t*
1185 random L_V |stdlib |struct random_data|I_iS|I_lS|I_St|i=int*|l=long*|t=int32_t*
1186 readdir S_T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1187 readdir64 S_T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1188 setgrent |grp | |I_H|V_H
1189 sethostent V_I |netdb | |I_ID|V_ID|D=struct hostent_data*
1190 setlocale B_IC |locale | |I_ICBI
1191 setnetent V_I |netdb | |I_ID|V_ID|D=struct netent_data*
1192 setprotoent V_I |netdb | |I_ID|V_ID|D=struct protoent_data*
1193 setpwent |pwd | |I_H|V_H
1194 setservent V_I |netdb | |I_ID|V_ID|D=struct servent_data*
1195 srand48 V_L |stdlib |struct drand48_data |I_LS
1196 srandom V_T |stdlib |struct random_data|I_TS|T=unsigned int
1197 strerror B_I |string | |I_IBW|I_IBI|B_IBW
1198 tmpnam B_B |stdio | |B_B
1199 ttyname B_I |unistd | |I_IBW|I_IBI|B_IBI