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 /* If compiling for a threaded perl, we will macro-wrap the system/library
65 * interfaces (e.g. getpwent()) which have threaded versions
66 * (e.g. getpwent_r()), which will handle things correctly for
67 * the Perl interpreter, but otherwise (for XS) the wrapping does
68 * not take place. See L<perlxs/Thread-aware system interfaces>.
71 #ifndef PERL_REENTR_API
72 # if defined(PERL_CORE) || defined(PERL_EXT)
73 # define PERL_REENTR_API 1
75 # define PERL_REENTR_API 0
79 #ifdef USE_REENTRANT_API
82 # define PL_REENTRANT_RETINT PL_reentrant_retint
85 /* Deprecations: some platforms have the said reentrant interfaces
86 * but they are declared obsolete and are not to be used. Often this
87 * means that the platform has threadsafed the interfaces (hopefully).
88 * All this is OS version dependent, so we are of course fooling ourselves.
89 * If you know of more deprecations on some platforms, please add your own
90 * (by editing reentr.pl, mind!) */
95 # undef HAS_ENDGRENT_R
96 # undef HAS_ENDPWENT_R
97 # undef HAS_GETGRENT_R
98 # undef HAS_GETPWENT_R
99 # undef HAS_SETLOCALE_R
100 # undef HAS_SRAND48_R
101 # undef HAS_STRERROR_R
102 # define NETDB_R_OBSOLETE
105 #if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
107 # undef HAS_STRERROR_R
108 # define NETDB_R_OBSOLETE
111 #ifdef NETDB_R_OBSOLETE
112 # undef HAS_ENDHOSTENT_R
113 # undef HAS_ENDNETENT_R
114 # undef HAS_ENDPROTOENT_R
115 # undef HAS_ENDSERVENT_R
116 # undef HAS_GETHOSTBYADDR_R
117 # undef HAS_GETHOSTBYNAME_R
118 # undef HAS_GETHOSTENT_R
119 # undef HAS_GETNETBYADDR_R
120 # undef HAS_GETNETBYNAME_R
121 # undef HAS_GETNETENT_R
122 # undef HAS_GETPROTOBYNAME_R
123 # undef HAS_GETPROTOBYNUMBER_R
124 # undef HAS_GETPROTOENT_R
125 # undef HAS_GETSERVBYNAME_R
126 # undef HAS_GETSERVBYPORT_R
127 # undef HAS_GETSERVENT_R
128 # undef HAS_SETHOSTENT_R
129 # undef HAS_SETNETENT_R
130 # undef HAS_SETPROTOENT_R
131 # undef HAS_SETSERVENT_R
144 # include <stdlib.h> /* drand48_data */
151 #ifdef HAS_GETSPNAM_R
159 my %seenh; # the different prototypes signatures for this function
160 my %seena; # the different prototypes signatures for this function in order
161 my @seenf; # all the seen functions
162 my %seenp; # the different prototype signatures for all functions
163 my %seent; # the return type of this function
164 my %seens; # the type of this function's "S"
165 my %seend; # the type of this function's "D"
166 my %seenm; # all the types
167 my %seenu; # the length of the argument list of this function
168 my %seenr; # the return type of this function
170 while (<DATA>) { # Read in the protypes.
173 my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1);
175 # Split off the real function name and the argument list.
176 ($func, $u) = split(' ', $func);
177 $u = "V_V" unless $u;
178 ($r, $u) = ($u =~ /^(.)_(.+)/);
179 $seenu{$func} = $u eq 'V' ? 0 : length $u;
181 my $FUNC = uc $func; # for output.
189 # Set any special mapping variables (like X=x_t)
191 while ($p[-1] =~ /=/) {
192 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
198 # If given the -U option open up the metaconfig unit for this function.
199 if ($opts{U} && open(U, ">d_${func}_r.U")) {
205 # The metaconfig units needs prerequisite dependencies.
209 if ($hdr ne 'stdio') { # There's no i_stdio.
212 $prereqsh = "\$$prereqs $prereqh";
214 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
215 push @prereq, $prereqs;
216 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
217 if ($hdr eq 'time') {
218 $hdrs .= " \$i_systime sys/time.h";
219 push @prereq, 'i_systime';
221 # Output the metaconfig unit header.
223 ?RCS: \$Id: d_${func}_r.U,v $
225 ?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
227 ?RCS: You may distribute under the terms of either the GNU General Public
228 ?RCS: License or the Artistic License, as specified in the README file.
230 ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
232 ?MAKE:d_${func}_r ${func}_r_proto: @prereq
233 ?MAKE: -pick add \$@ %<
235 ?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
236 ?S: which indicates to the C program that the ${func}_r()
237 ?S: routine is available.
240 ?S: This variable encodes the prototype of ${func}_r.
241 ?S: It is zero if d_${func}_r is undef, and one of the
242 ?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
246 ?C: This symbol, if defined, indicates that the ${func}_r routine
247 ?C: is available to ${func} re-entrantly.
250 ?C: This symbol encodes the prototype of ${func}_r.
251 ?C: It is zero if d_${func}_r is undef, and one of the
252 ?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
255 ?H:#\$d_${func}_r HAS_${FUNC}_R /**/
256 ?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
258 ?T:try hdrs d_${func}_r_proto
259 ?LINT:set d_${func}_r
260 ?LINT:set ${func}_r_proto
261 : see if ${func}_r exists
262 set ${func}_r d_${func}_r
264 case "\$d_${func}_r" in
269 case "\$d_${func}_r_proto:\$usethreads" in
270 ":define") d_${func}_r_proto=define
271 set d_${func}_r_proto ${func}_r \$hdrs
275 case "\$d_${func}_r_proto" in
280 my ($r, $a) = ($p =~ /^(.)_(.+)/);
281 my $v = join(", ", map { $m{$_} } split '', $a);
284 case "\$${func}_r_proto" in
285 ''|0) try='$m{$r} ${func}_r($v);'
286 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
290 $seenh{$func}->{$p}++;
291 push @{$seena{$func}}, $p;
293 $seent{$func} = $type;
294 $seens{$func} = $m{S};
295 $seend{$func} = $m{D};
300 case "\$${func}_r_proto" in
301 ''|0) d_${func}_r=undef
303 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
304 * ) case "\$${func}_r_proto" in
306 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
308 echo "Prototype: \$try" ;;
311 *) case "\$usethreads" in
312 define) echo "${func}_r has no prototype, not using it." >&4 ;;
330 # Prepare to continue writing the reentr.h.
335 # Write out all the known prototype signatures.
337 for my $p (sort keys %seenp) {
338 print "#define REENTRANT_PROTO_${p} ${i}\n";
343 my @struct; # REENTR struct members
344 my @size; # struct member buffer size initialization code
345 my @init; # struct member buffer initialization (malloc) code
346 my @free; # struct member buffer release (free) code
347 my @wrap; # the wrapper (foo(a) -> foo_r(a,...)) cpp code
348 my @define; # defines for optional features
352 join " || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @_;
365 Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
368 Safefree(PL_reentrant_buffer->_${func}_buffer);
373 my ($n, $p, @F) = @_;
377 /* The @F using \L$n? */
383 my $HAS = "${FUNC}_R_HAS_$n";
385 my @h = grep { /$p/ } @{$seena{$func}};
386 unless (defined $GENFUNC) {
388 $GENFUNC =~ s/^GET//;
391 push @define, "#if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
404 /* Any of the @F using \L$n? */
407 push @define, "#if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
409 # define USE_${GENFUNC}_$n
411 # undef USE_${GENFUNC}_$n
417 define('BUFFER', 'B',
418 qw(getgrent getgrgid getgrnam));
421 qw(getgrent getgrgid getgrnam));
423 qw(getpwent getpwnam getpwuid));
425 qw(getspent getspnam));
428 qw(getgrent getgrgid getgrnam setgrent endgrent));
430 qw(getpwent getpwnam getpwuid setpwent endpwent));
432 define('BUFFER', 'B',
433 qw(getpwent getpwgid getpwnam));
436 qw(gethostent gethostbyaddr gethostbyname));
438 qw(getnetent getnetbyaddr getnetbyname));
440 qw(getprotoent getprotobyname getprotobynumber));
442 qw(getservent getservbyname getservbyport));
444 define('BUFFER', 'B',
445 qw(gethostent gethostbyaddr gethostbyname));
446 define('BUFFER', 'B',
447 qw(getnetent getnetbyaddr getnetbyname));
448 define('BUFFER', 'B',
449 qw(getprotoent getprotobyname getprotobynumber));
450 define('BUFFER', 'B',
451 qw(getservent getservbyname getservbyport));
454 qw(gethostent gethostbyaddr gethostbyname));
456 qw(getnetent getnetbyaddr getnetbyname));
458 # The following loop accumulates the "ssif" (struct, size, init, free)
459 # sections that declare the struct members (in reentr.h), and the buffer
460 # size initialization, buffer initialization (malloc), and buffer
461 # release (free) code (in reentr.c).
463 # The loop also contains a lot of intrinsic logic about groups of
464 # functions (since functions of certain kind operate the same way).
466 for my $func (@seenf) {
468 my $ifdef = "#ifdef HAS_${FUNC}_R\n";
469 my $endif = "#endif /* HAS_${FUNC}_R */\n";
470 if (exists $seena{$func}) {
471 my @p = @{$seena{$func}};
472 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
475 char* _${func}_buffer;
476 size_t _${func}_size;
479 PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
484 elsif ($func =~ /^(crypt)$/) {
487 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
488 $seend{$func} _${func}_data;
490 $seent{$func} _${func}_struct;
494 #if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
495 PL_reentrant_buffer->_${func}_struct_buffer = 0;
499 #if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
500 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
505 elsif ($func =~ /^(drand48|gmtime|localtime)$/) {
508 $seent{$func} _${func}_struct;
510 if ($1 eq 'drand48') {
512 double _${func}_double;
517 elsif ($func =~ /^random$/) {
520 # if RANDOM_R_PROTO != REENTRANT_PROTO_I_St
521 $seent{$func} _${func}_struct;
526 elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) {
528 # 'genfunc' can be read either as 'generic' or 'genre',
529 # it represents a group of functions.
531 $genfunc =~ s/nam/ent/g;
532 $genfunc =~ s/^get//;
533 my $GENFUNC = uc $genfunc;
535 $seent{$func} _${genfunc}_struct;
536 char* _${genfunc}_buffer;
537 size_t _${genfunc}_size;
540 # ifdef USE_${GENFUNC}_PTR
541 $seent{$func}* _${genfunc}_ptr;
545 # ifdef USE_${GENFUNC}_FPTR
546 FILE* _${genfunc}_fptr;
550 # ifdef USE_${GENFUNC}_FPTR
551 PL_reentrant_buffer->_${genfunc}_fptr = NULL;
554 my $sc = $genfunc eq 'grent' ?
555 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
556 my $sz = "_${genfunc}_size";
558 # if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
559 PL_reentrant_buffer->$sz = sysconf($sc);
560 if (PL_reentrant_buffer->$sz == (size_t) -1)
561 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
563 # if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
564 PL_reentrant_buffer->$sz = SIABUFSIZ;
567 PL_reentrant_buffer->$sz = BUFSIZ;
569 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
574 pushinitfree $genfunc;
577 elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
580 $genfunc =~ s/byname/ent/;
581 $genfunc =~ s/^get//;
582 my $GENFUNC = uc $genfunc;
583 my $D = ifprotomatch($FUNC, grep {/D/} @p);
584 my $d = $seend{$func};
585 $d =~ s/\*$//; # snip: we need need the base type.
587 $seent{$func} _${genfunc}_struct;
591 char* _${genfunc}_buffer;
592 size_t _${genfunc}_size;
594 # ifdef USE_${GENFUNC}_PTR
595 $seent{$func}* _${genfunc}_ptr;
599 # ifdef USE_${GENFUNC}_ERRNO
600 int _${genfunc}_errno;
605 PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE;
610 Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
615 Safefree(PL_reentrant_buffer->_${genfunc}_buffer);
620 elsif ($func =~ /^(readdir|readdir64)$/) {
622 my $R = ifprotomatch($FUNC, grep {/R/} @p);
624 $seent{$func}* _${func}_struct;
625 size_t _${func}_size;
627 $seent{$func}* _${func}_ptr;
631 /* This is the size Solaris recommends.
632 * (though we go static, should use pathconf() instead) */
633 PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1;
636 PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size);
639 Safefree(PL_reentrant_buffer->_${func}_struct);
647 # if defined(PERL_REENTR_API) && (PERL_REENTR_API == 1)
651 # Write out what we have learned.
654 my $v = join(", ", @v[0..$seenu{$func}-1]);
656 my ($r, $a) = split '_', $p;
657 my $test = $r eq 'I' ? ' == 0' : '';
660 if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
661 $genfunc = "${1}ent";
662 } elsif ($genfunc eq 'srand48') {
663 $genfunc = "drand48";
667 substr($b, 0, $seenu{$func}) = '';
668 if ($func =~ /^random$/) {
669 $true = "PL_reentrant_buffer->_random_retval";
670 } elsif ($b =~ /R/) {
671 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
672 } elsif ($b =~ /T/ && $func eq 'drand48') {
673 $true = "PL_reentrant_buffer->_${genfunc}_double";
674 } elsif ($b =~ /S/) {
675 if ($func =~ /^readdir/) {
676 $true = "PL_reentrant_buffer->_${genfunc}_struct";
678 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
680 } elsif ($b =~ /B/) {
681 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
687 "&PL_reentrant_buffer->_${genfunc}_ptr" :
689 "&PL_reentrant_buffer->_${genfunc}_errno" :
691 "PL_reentrant_buffer->_${genfunc}_buffer" :
693 "PL_reentrant_buffer->_${genfunc}_size" :
695 "&PL_reentrant_buffer->_${genfunc}_fptr" :
697 "&PL_reentrant_buffer->_${genfunc}_data" :
699 ($func =~ /^readdir\d*$/ ?
700 "PL_reentrant_buffer->_${genfunc}_struct" :
702 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
703 "&PL_reentrant_buffer->_${genfunc}_struct") :
704 $_ eq 'T' && $func eq 'drand48' ?
705 "&PL_reentrant_buffer->_${genfunc}_double" :
706 $_ =~ /^[ilt]$/ && $func eq 'random' ?
707 "&PL_reentrant_buffer->_random_retval" :
710 $w = ", $w" if length $v;
713 my $call = "${func}_r($v$w)";
715 # Must make OpenBSD happy
718 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
719 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data))';
722 # if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
724 if ($r eq 'V' || $r eq 'B') {
726 # define $func($v) $call
729 if ($func =~ /^get/) {
730 my $rv = $v ? ", $v" : "";
732 $call = qq[((PL_REENTRANT_RETINT = $call)$test ? $true : (((PL_REENTRANT_RETINT == ERANGE) || (errno == ERANGE)) ? ($seenm{$func}{$seenr{$func}})Perl_reentrant_retry("$func"$rv) : 0))];
733 my $arg = join(", ", map { $seenm{$func}{substr($a,$_,1)}." ".$v[$_] } 0..$seenu{$func}-1);
734 my $ret = $seenr{$func} eq 'V' ? "" : "return ";
735 my $memzero_ = $memzero ? "$memzero, " : "";
738 # define $func($v) ($memzero_$call)
740 # if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC)
741 # define $func($v) ({int PL_REENTRANT_RETINT; $memzero; $call;})
743 # define $func($v) Perl_reentr_$func($v)
744 static $seenm{$func}{$seenr{$func}} Perl_reentr_$func($arg) {
746 int PL_REENTRANT_RETINT;
755 # define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
760 # define $func($v) ($call$test ? $true : 0)
765 # endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API == 1) */
770 # endif /* HAS_\U$func */
773 push @wrap, $endif, "\n";
777 # New struct members added here to maintain binary compatibility with 5.8.0
779 if (exists $seena{crypt}) {
782 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
784 struct crypt_data *_crypt_struct_buffer;
786 #endif /* HAS_CRYPT_R */
790 if (exists $seena{random}) {
793 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_iS
796 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_lS
799 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_St
800 $seent{random} _random_struct;
801 int32_t _random_retval;
803 #endif /* HAS_RANDOM_R */
807 if (exists $seena{srandom}) {
810 $seent{srandom} _srandom_struct;
811 #endif /* HAS_SRANDOM_R */
820 /* Defines for indicating which special features are supported. */
825 int dummy; /* cannot have empty structs */
828 #endif /* USE_REENTRANT_API */
835 die "reentr.inc: $!" unless open(H, ">reentr.inc");
844 * You may distribute under the terms of either the GNU General Public
845 * License or the Artistic License, as specified in the README file.
847 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
848 * This file is built by reentrl.pl from data in reentr.pl.
854 #ifdef USE_REENTRANT_API
857 * As of OpenBSD 3.7, reentrant functions are now working, they just are
858 * incompatible with everyone else. To make OpenBSD happy, we have to
859 * memzero out certain structures before calling the functions.
861 #if defined(__OpenBSD__)
862 # define REENTR_MEMZERO(a,b) memzero(a,b)
864 # define REENTR_MEMZERO(a,b) 0
867 /* The reentrant wrappers. */
871 #endif /* USE_REENTRANT_API */
880 # Prepare to write the reentr.c.
882 safer_unlink 'reentr.c';
883 die "reentr.c: $!" unless open(C, ">reentr.c");
887 /* -*- buffer-read-only: t -*-
891 * Copyright (C) 2002, 2003, 2005, 2006 by Larry Wall and others
893 * You may distribute under the terms of either the GNU General Public
894 * License or the Artistic License, as specified in the README file.
896 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
897 * This file is built by reentr.pl from data in reentr.pl.
899 * "Saruman," I said, standing away from him, "only one hand at a time can
900 * wield the One, and you know that well, so do not trouble to say we!"
902 * This file contains a collection of automatically created wrappers
903 * (created by running reentr.pl) for reentrant (thread-safe) versions of
904 * various library calls, such as getpwent_r. The wrapping is done so
905 * that other files like pp_sys.c calling those library functions need not
906 * care about the differences between various platforms' idiosyncrasies
907 * regarding these reentrant interfaces.
911 #define PERL_IN_REENTR_C
916 Perl_reentrant_size(pTHX) {
917 #ifdef USE_REENTRANT_API
918 #define REENTRANTSMALLSIZE 256 /* Make something up. */
919 #define REENTRANTUSUALSIZE 4096 /* Make something up. */
921 #endif /* USE_REENTRANT_API */
925 Perl_reentrant_init(pTHX) {
926 #ifdef USE_REENTRANT_API
927 Newx(PL_reentrant_buffer, 1, REENTR);
928 Perl_reentrant_size(aTHX);
930 #endif /* USE_REENTRANT_API */
934 Perl_reentrant_free(pTHX) {
935 #ifdef USE_REENTRANT_API
937 Safefree(PL_reentrant_buffer);
938 #endif /* USE_REENTRANT_API */
942 Perl_reentrant_retry(const char *f, ...)
946 #ifdef USE_REENTRANT_API
947 # 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)
950 # if defined(USE_SERVENT_BUFFER)
953 # if defined(USE_HOSTENT_BUFFER)
956 # if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
963 switch (PL_op->op_type) {
964 #ifdef USE_HOSTENT_BUFFER
969 #ifdef PERL_REENTRANT_MAXSIZE
970 if (PL_reentrant_buffer->_hostent_size <=
971 PERL_REENTRANT_MAXSIZE / 2)
974 PL_reentrant_buffer->_hostent_size *= 2;
975 Renew(PL_reentrant_buffer->_hostent_buffer,
976 PL_reentrant_buffer->_hostent_size, char);
977 switch (PL_op->op_type) {
979 p0 = va_arg(ap, void *);
980 asize = va_arg(ap, size_t);
981 anint = va_arg(ap, int);
982 retptr = gethostbyaddr(p0, asize, anint); break;
984 p0 = va_arg(ap, void *);
985 retptr = gethostbyname((char *)p0); break;
987 retptr = gethostent(); break;
989 SETERRNO(ERANGE, LIB_INVARG);
996 #ifdef USE_GRENT_BUFFER
1001 #ifdef PERL_REENTRANT_MAXSIZE
1002 if (PL_reentrant_buffer->_grent_size <=
1003 PERL_REENTRANT_MAXSIZE / 2)
1007 PL_reentrant_buffer->_grent_size *= 2;
1008 Renew(PL_reentrant_buffer->_grent_buffer,
1009 PL_reentrant_buffer->_grent_size, char);
1010 switch (PL_op->op_type) {
1012 p0 = va_arg(ap, void *);
1013 retptr = getgrnam((char *)p0); break;
1015 #if Gid_t_size < INTSIZE
1016 gid = (Gid_t)va_arg(ap, int);
1018 gid = va_arg(ap, Gid_t);
1020 retptr = getgrgid(gid); break;
1022 retptr = getgrent(); break;
1024 SETERRNO(ERANGE, LIB_INVARG);
1031 #ifdef USE_NETENT_BUFFER
1036 #ifdef PERL_REENTRANT_MAXSIZE
1037 if (PL_reentrant_buffer->_netent_size <=
1038 PERL_REENTRANT_MAXSIZE / 2)
1042 PL_reentrant_buffer->_netent_size *= 2;
1043 Renew(PL_reentrant_buffer->_netent_buffer,
1044 PL_reentrant_buffer->_netent_size, char);
1045 switch (PL_op->op_type) {
1047 net = va_arg(ap, Netdb_net_t);
1048 anint = va_arg(ap, int);
1049 retptr = getnetbyaddr(net, anint); break;
1051 p0 = va_arg(ap, void *);
1052 retptr = getnetbyname((char *)p0); break;
1054 retptr = getnetent(); break;
1056 SETERRNO(ERANGE, LIB_INVARG);
1063 #ifdef USE_PWENT_BUFFER
1068 #ifdef PERL_REENTRANT_MAXSIZE
1069 if (PL_reentrant_buffer->_pwent_size <=
1070 PERL_REENTRANT_MAXSIZE / 2)
1074 PL_reentrant_buffer->_pwent_size *= 2;
1075 Renew(PL_reentrant_buffer->_pwent_buffer,
1076 PL_reentrant_buffer->_pwent_size, char);
1077 switch (PL_op->op_type) {
1079 p0 = va_arg(ap, void *);
1080 retptr = getpwnam((char *)p0); break;
1082 #if Uid_t_size < INTSIZE
1083 uid = (Uid_t)va_arg(ap, int);
1085 uid = va_arg(ap, Uid_t);
1087 retptr = getpwuid(uid); break;
1089 retptr = getpwent(); break;
1091 SETERRNO(ERANGE, LIB_INVARG);
1098 #ifdef USE_PROTOENT_BUFFER
1103 #ifdef PERL_REENTRANT_MAXSIZE
1104 if (PL_reentrant_buffer->_protoent_size <=
1105 PERL_REENTRANT_MAXSIZE / 2)
1108 PL_reentrant_buffer->_protoent_size *= 2;
1109 Renew(PL_reentrant_buffer->_protoent_buffer,
1110 PL_reentrant_buffer->_protoent_size, char);
1111 switch (PL_op->op_type) {
1113 p0 = va_arg(ap, void *);
1114 retptr = getprotobyname((char *)p0); break;
1116 anint = va_arg(ap, int);
1117 retptr = getprotobynumber(anint); break;
1119 retptr = getprotoent(); break;
1121 SETERRNO(ERANGE, LIB_INVARG);
1128 #ifdef USE_SERVENT_BUFFER
1133 #ifdef PERL_REENTRANT_MAXSIZE
1134 if (PL_reentrant_buffer->_servent_size <=
1135 PERL_REENTRANT_MAXSIZE / 2)
1138 PL_reentrant_buffer->_servent_size *= 2;
1139 Renew(PL_reentrant_buffer->_servent_buffer,
1140 PL_reentrant_buffer->_servent_size, char);
1141 switch (PL_op->op_type) {
1143 p0 = va_arg(ap, void *);
1144 p1 = va_arg(ap, void *);
1145 retptr = getservbyname((char *)p0, (char *)p1); break;
1147 anint = va_arg(ap, int);
1148 p0 = va_arg(ap, void *);
1149 retptr = getservbyport(anint, (char *)p0); break;
1151 retptr = getservent(); break;
1153 SETERRNO(ERANGE, LIB_INVARG);
1161 /* Not known how to retry, so just fail. */
1176 asctime B_S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
1177 crypt B_CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
1178 ctermid B_B |stdio | |B_B
1179 ctime B_S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
1180 drand48 d_V |stdlib |struct drand48_data |I_ST|T=double*|d=double
1181 endgrent |grp | |I_H|V_H
1182 endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1183 endnetent |netdb | |I_D|V_D|D=struct netent_data*
1184 endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
1185 endpwent |pwd | |I_H|V_H
1186 endservent |netdb | |I_D|V_D|D=struct servent_data*
1187 getgrent S_V |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1188 getgrgid S_T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1189 getgrnam S_C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
1190 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
1191 gethostbyname S_C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1192 gethostent S_V |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
1193 getlogin B_V |unistd |char |I_BW|I_BI|B_BW|B_BI
1194 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
1195 getnetbyname S_C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1196 getnetent S_V |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1197 getprotobyname S_C |netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1198 getprotobynumber S_I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1199 getprotoent S_V |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1200 getpwent S_V |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1201 getpwnam S_C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1202 getpwuid S_T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1203 getservbyname S_CC |netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1204 getservbyport S_IC |netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1205 getservent S_V |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1206 getspnam S_C |shadow |struct spwd |I_CSBWR|S_CSBI
1207 gmtime S_T |time |struct tm |S_TS|I_TS|T=const time_t*
1208 localtime S_T |time |struct tm |S_TS|I_TS|T=const time_t*
1209 random L_V |stdlib |struct random_data|I_iS|I_lS|I_St|i=int*|l=long*|t=int32_t*
1210 readdir S_T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1211 readdir64 S_T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1212 setgrent |grp | |I_H|V_H
1213 sethostent V_I |netdb | |I_ID|V_ID|D=struct hostent_data*
1214 setlocale B_IC |locale | |I_ICBI
1215 setnetent V_I |netdb | |I_ID|V_ID|D=struct netent_data*
1216 setprotoent V_I |netdb | |I_ID|V_ID|D=struct protoent_data*
1217 setpwent |pwd | |I_H|V_H
1218 setservent V_I |netdb | |I_ID|V_ID|D=struct servent_data*
1219 srand48 V_L |stdlib |struct drand48_data |I_LS
1220 srandom V_T |stdlib |struct random_data|I_TS|T=unsigned int
1221 strerror B_I |string | |I_IBW|I_IBI|B_IBW
1222 tmpnam B_B |stdio | |B_B
1223 ttyname B_I |unistd | |I_IBW|I_IBI|B_IBI