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';
16 getopts('Uv', \%opts);
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 my $h = safer_open("reentr.h-new");
47 /* -*- buffer-read-only: t -*-
51 * Copyright (C) 2002, 2003, 2005, 2006, 2007 by Larry Wall and others
53 * You may distribute under the terms of either the GNU General Public
54 * License or the Artistic License, as specified in the README file.
56 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
57 * This file is built by reentr.pl from data in reentr.pl.
63 /* If compiling for a threaded perl, we will macro-wrap the system/library
64 * interfaces (e.g. getpwent()) which have threaded versions
65 * (e.g. getpwent_r()), which will handle things correctly for
66 * the Perl interpreter, but otherwise (for XS) the wrapping does
67 * not take place. See L<perlxs/Thread-aware system interfaces>.
70 #ifndef PERL_REENTR_API
71 # if defined(PERL_CORE) || defined(PERL_EXT)
72 # define PERL_REENTR_API 1
74 # define PERL_REENTR_API 0
78 #ifdef USE_REENTRANT_API
80 /* Deprecations: some platforms have the said reentrant interfaces
81 * but they are declared obsolete and are not to be used. Often this
82 * means that the platform has threadsafed the interfaces (hopefully).
83 * All this is OS version dependent, so we are of course fooling ourselves.
84 * If you know of more deprecations on some platforms, please add your own
85 * (by editing reentr.pl, mind!) */
90 # undef HAS_ENDGRENT_R
91 # undef HAS_ENDPWENT_R
92 # undef HAS_GETGRENT_R
93 # undef HAS_GETPWENT_R
94 # undef HAS_SETLOCALE_R
96 # undef HAS_STRERROR_R
97 # define NETDB_R_OBSOLETE
100 #if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
102 # undef HAS_STRERROR_R
103 # define NETDB_R_OBSOLETE
107 * As of OpenBSD 3.7, reentrant functions are now working, they just are
108 * incompatible with everyone else. To make OpenBSD happy, we have to
109 * memzero out certain structures before calling the functions.
111 #if defined(__OpenBSD__)
112 # define REENTR_MEMZERO(a,b) memzero(a,b)
114 # define REENTR_MEMZERO(a,b) 0
117 #ifdef NETDB_R_OBSOLETE
118 # undef HAS_ENDHOSTENT_R
119 # undef HAS_ENDNETENT_R
120 # undef HAS_ENDPROTOENT_R
121 # undef HAS_ENDSERVENT_R
122 # undef HAS_GETHOSTBYADDR_R
123 # undef HAS_GETHOSTBYNAME_R
124 # undef HAS_GETHOSTENT_R
125 # undef HAS_GETNETBYADDR_R
126 # undef HAS_GETNETBYNAME_R
127 # undef HAS_GETNETENT_R
128 # undef HAS_GETPROTOBYNAME_R
129 # undef HAS_GETPROTOBYNUMBER_R
130 # undef HAS_GETPROTOENT_R
131 # undef HAS_GETSERVBYNAME_R
132 # undef HAS_GETSERVBYPORT_R
133 # undef HAS_GETSERVENT_R
134 # undef HAS_SETHOSTENT_R
135 # undef HAS_SETNETENT_R
136 # undef HAS_SETPROTOENT_R
137 # undef HAS_SETSERVENT_R
150 # include <stdlib.h> /* drand48_data */
157 #ifdef HAS_GETSPNAM_R
165 my %seenh; # the different prototypes signatures for this function
166 my %seena; # the different prototypes signatures for this function in order
167 my @seenf; # all the seen functions
168 my %seenp; # the different prototype signatures for all functions
169 my %seent; # the return type of this function
170 my %seens; # the type of this function's "S"
171 my %seend; # the type of this function's "D"
172 my %seenm; # all the types
173 my %seenu; # the length of the argument list of this function
175 while (<DATA>) { # Read in the protypes.
178 my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1);
180 # Split off the real function name and the argument list.
181 ($func, $u) = split(' ', $func);
182 $seenu{$func} = defined $u ? length $u : 0;
183 my $FUNC = uc $func; # for output.
191 # Set any special mapping variables (like X=x_t)
193 while ($p[-1] =~ /=/) {
194 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
200 # If given the -U option open up the metaconfig unit for this function.
201 if ($opts{U} && open(U, ">d_${func}_r.U")) {
207 # The metaconfig units needs prerequisite dependencies.
211 if ($hdr ne 'stdio') { # There's no i_stdio.
214 $prereqsh = "\$$prereqs $prereqh";
216 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
217 push @prereq, $prereqs;
218 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
219 if ($hdr eq 'time') {
220 $hdrs .= " \$i_systime sys/time.h";
221 push @prereq, 'i_systime';
223 # Output the metaconfig unit header.
225 ?RCS: \$Id: d_${func}_r.U,v $
227 ?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
229 ?RCS: You may distribute under the terms of either the GNU General Public
230 ?RCS: License or the Artistic License, as specified in the README file.
232 ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
234 ?MAKE:d_${func}_r ${func}_r_proto: @prereq
235 ?MAKE: -pick add \$@ %<
237 ?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
238 ?S: which indicates to the C program that the ${func}_r()
239 ?S: routine is available.
242 ?S: This variable encodes the prototype of ${func}_r.
243 ?S: It is zero if d_${func}_r is undef, and one of the
244 ?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
248 ?C: This symbol, if defined, indicates that the ${func}_r routine
249 ?C: is available to ${func} re-entrantly.
252 ?C: This symbol encodes the prototype of ${func}_r.
253 ?C: It is zero if d_${func}_r is undef, and one of the
254 ?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
257 ?H:#\$d_${func}_r HAS_${FUNC}_R /**/
258 ?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
260 ?T:try hdrs d_${func}_r_proto
261 ?LINT:set d_${func}_r
262 ?LINT:set ${func}_r_proto
263 : see if ${func}_r exists
264 set ${func}_r d_${func}_r
266 case "\$d_${func}_r" in
271 case "\$d_${func}_r_proto:\$usethreads" in
272 ":define") d_${func}_r_proto=define
273 set d_${func}_r_proto ${func}_r \$hdrs
277 case "\$d_${func}_r_proto" in
282 my ($r, $a) = ($p =~ /^(.)_(.+)/);
283 my $v = join(", ", map { $m{$_} } split '', $a);
286 case "\$${func}_r_proto" in
287 ''|0) try='$m{$r} ${func}_r($v);'
288 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
292 $seenh{$func}->{$p}++;
293 push @{$seena{$func}}, $p;
295 $seent{$func} = $type;
296 $seens{$func} = $m{S};
297 $seend{$func} = $m{D};
302 case "\$${func}_r_proto" in
303 ''|0) d_${func}_r=undef
305 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
306 * ) case "\$${func}_r_proto" in
308 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
310 echo "Prototype: \$try" ;;
313 *) case "\$usethreads" in
314 define) echo "${func}_r has no prototype, not using it." >&4 ;;
332 # Prepare to continue writing the reentr.h.
337 # Write out all the known prototype signatures.
339 for my $p (sort keys %seenp) {
340 print "#define REENTRANT_PROTO_${p} ${i}\n";
345 my @struct; # REENTR struct members
346 my @size; # struct member buffer size initialization code
347 my @init; # struct member buffer initialization (malloc) code
348 my @free; # struct member buffer release (free) code
349 my @wrap; # the wrapper (foo(a) -> foo_r(a,...)) cpp code
350 my @define; # defines for optional features
354 join " || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @_;
367 Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
370 Safefree(PL_reentrant_buffer->_${func}_buffer);
375 my ($n, $p, @F) = @_;
379 /* The @F using \L$n? */
385 my $HAS = "${FUNC}_R_HAS_$n";
387 my @h = grep { /$p/ } @{$seena{$func}};
388 unless (defined $GENFUNC) {
390 $GENFUNC =~ s/^GET//;
393 push @define, "#if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
406 /* Any of the @F using \L$n? */
409 push @define, "#if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
411 # define USE_${GENFUNC}_$n
413 # undef USE_${GENFUNC}_$n
419 define('BUFFER', 'B',
420 qw(getgrent getgrgid getgrnam));
423 qw(getgrent getgrgid getgrnam));
425 qw(getpwent getpwnam getpwuid));
427 qw(getspent getspnam));
430 qw(getgrent getgrgid getgrnam setgrent endgrent));
432 qw(getpwent getpwnam getpwuid setpwent endpwent));
434 define('BUFFER', 'B',
435 qw(getpwent getpwgid getpwnam));
438 qw(gethostent gethostbyaddr gethostbyname));
440 qw(getnetent getnetbyaddr getnetbyname));
442 qw(getprotoent getprotobyname getprotobynumber));
444 qw(getservent getservbyname getservbyport));
446 define('BUFFER', 'B',
447 qw(gethostent gethostbyaddr gethostbyname));
448 define('BUFFER', 'B',
449 qw(getnetent getnetbyaddr getnetbyname));
450 define('BUFFER', 'B',
451 qw(getprotoent getprotobyname getprotobynumber));
452 define('BUFFER', 'B',
453 qw(getservent getservbyname getservbyport));
456 qw(gethostent gethostbyaddr gethostbyname));
458 qw(getnetent getnetbyaddr getnetbyname));
460 # The following loop accumulates the "ssif" (struct, size, init, free)
461 # sections that declare the struct members (in reentr.h), and the buffer
462 # size initialization, buffer initialization (malloc), and buffer
463 # release (free) code (in reentr.c).
465 # The loop also contains a lot of intrinsic logic about groups of
466 # functions (since functions of certain kind operate the same way).
468 for my $func (@seenf) {
470 my $ifdef = "#ifdef HAS_${FUNC}_R\n";
471 my $endif = "#endif /* HAS_${FUNC}_R */\n";
472 if (exists $seena{$func}) {
473 my @p = @{$seena{$func}};
474 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
477 char* _${func}_buffer;
478 size_t _${func}_size;
481 PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
486 elsif ($func =~ /^(crypt)$/) {
489 #if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
490 $seend{$func} _${func}_data;
492 $seent{$func} *_${func}_struct_buffer;
496 #if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
497 PL_reentrant_buffer->_${func}_struct_buffer = 0;
501 #if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
502 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
507 elsif ($func =~ /^(drand48|random|srandom)$/) {
510 $seent{$func} _${func}_struct;
512 if ($1 eq 'drand48') {
514 double _${func}_double;
516 } elsif ($1 eq 'random') {
518 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_iS
521 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_lS
522 long _${func}_retval;
524 # if RANDOM_R_PROTO == REENTRANT_PROTO_I_St
525 int32_t _${func}_retval;
531 elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) {
533 # 'genfunc' can be read either as 'generic' or 'genre',
534 # it represents a group of functions.
536 $genfunc =~ s/nam/ent/g;
537 $genfunc =~ s/^get//;
538 my $GENFUNC = uc $genfunc;
540 $seent{$func} _${genfunc}_struct;
541 char* _${genfunc}_buffer;
542 size_t _${genfunc}_size;
545 # ifdef USE_${GENFUNC}_PTR
546 $seent{$func}* _${genfunc}_ptr;
550 # ifdef USE_${GENFUNC}_FPTR
551 FILE* _${genfunc}_fptr;
555 # ifdef USE_${GENFUNC}_FPTR
556 PL_reentrant_buffer->_${genfunc}_fptr = NULL;
559 my $sc = $genfunc eq 'grent' ?
560 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
561 my $sz = "_${genfunc}_size";
563 # if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
564 PL_reentrant_buffer->$sz = sysconf($sc);
565 if (PL_reentrant_buffer->$sz == (size_t) -1)
566 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
568 # if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
569 PL_reentrant_buffer->$sz = SIABUFSIZ;
572 PL_reentrant_buffer->$sz = BUFSIZ;
574 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
579 pushinitfree $genfunc;
582 elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
585 $genfunc =~ s/byname/ent/;
586 $genfunc =~ s/^get//;
587 my $GENFUNC = uc $genfunc;
588 my $D = ifprotomatch($FUNC, grep {/D/} @p);
589 my $d = $seend{$func};
590 $d =~ s/\*$//; # snip: we need need the base type.
592 $seent{$func} _${genfunc}_struct;
596 char* _${genfunc}_buffer;
597 size_t _${genfunc}_size;
599 # ifdef USE_${GENFUNC}_PTR
600 $seent{$func}* _${genfunc}_ptr;
604 # ifdef USE_${GENFUNC}_ERRNO
605 int _${genfunc}_errno;
610 PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE;
615 Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
620 Safefree(PL_reentrant_buffer->_${genfunc}_buffer);
625 elsif ($func =~ /^(readdir|readdir64)$/) {
627 my $R = ifprotomatch($FUNC, grep {/R/} @p);
629 $seent{$func}* _${func}_struct;
630 size_t _${func}_size;
632 $seent{$func}* _${func}_ptr;
636 /* This is the size Solaris recommends.
637 * (though we go static, should use pathconf() instead) */
638 PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1;
641 PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size);
644 Safefree(PL_reentrant_buffer->_${func}_struct);
652 # if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
656 # Write out what we have learned.
659 my $v = join(", ", @v[0..$seenu{$func}-1]);
661 my ($r, $a) = split '_', $p;
662 my $test = $r eq 'I' ? ' == 0' : '';
665 if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
666 $genfunc = "${1}ent";
667 } elsif ($genfunc eq 'srand48') {
668 $genfunc = "drand48";
672 substr($b, 0, $seenu{$func}) = '';
673 if ($func =~ /^random$/) {
674 $true = "PL_reentrant_buffer->_random_retval";
675 } elsif ($b =~ /R/) {
676 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
677 } elsif ($b =~ /T/ && $func eq 'drand48') {
678 $true = "PL_reentrant_buffer->_${genfunc}_double";
679 } elsif ($b =~ /S/) {
680 if ($func =~ /^readdir/) {
681 $true = "PL_reentrant_buffer->_${genfunc}_struct";
683 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
685 } elsif ($b =~ /B/) {
686 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
692 "&PL_reentrant_buffer->_${genfunc}_ptr" :
694 "&PL_reentrant_buffer->_${genfunc}_errno" :
696 "PL_reentrant_buffer->_${genfunc}_buffer" :
698 "PL_reentrant_buffer->_${genfunc}_size" :
700 "&PL_reentrant_buffer->_${genfunc}_fptr" :
702 "&PL_reentrant_buffer->_${genfunc}_data" :
704 ($func =~ /^readdir\d*$/ ?
705 "PL_reentrant_buffer->_${genfunc}_struct" :
707 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
708 "&PL_reentrant_buffer->_${genfunc}_struct") :
709 $_ eq 'T' && $func eq 'drand48' ?
710 "&PL_reentrant_buffer->_${genfunc}_double" :
711 $_ =~ /^[ilt]$/ && $func eq 'random' ?
712 "&PL_reentrant_buffer->_random_retval" :
715 $w = ", $w" if length $v;
718 my $call = "${func}_r($v$w)";
720 # Must make OpenBSD happy
723 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
724 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),';
727 # if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
729 if ($r eq 'V' || $r eq 'B') {
731 # define $func($v) $call
734 if ($func =~ /^get/) {
735 my $rv = $v ? ", $v" : "";
738 # define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : ((PL_reentrant_retint == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
742 # define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
747 # define $func($v) ($call$test ? $true : 0)
751 push @wrap, <<EOF; # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS
756 push @wrap, <<EOF; # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
760 push @wrap, $endif, "\n";
768 /* Defines for indicating which special features are supported. */
773 int dummy; /* cannot have empty structs */
780 #endif /* USE_REENTRANT_API */
788 rename_if_different('reentr.h-new', 'reentr.h');
790 # Prepare to write the reentr.c.
792 # safer_unlink 'reentr.c';
793 my $c = safer_open("reentr.c-new");
796 /* -*- buffer-read-only: t -*-
800 * Copyright (C) 2002, 2003, 2005, 2006, 2007 by Larry Wall and others
802 * You may distribute under the terms of either the GNU General Public
803 * License or the Artistic License, as specified in the README file.
805 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
806 * This file is built by reentr.pl from data in reentr.pl.
808 * "Saruman," I said, standing away from him, "only one hand at a time can
809 * wield the One, and you know that well, so do not trouble to say we!"
811 * This file contains a collection of automatically created wrappers
812 * (created by running reentr.pl) for reentrant (thread-safe) versions of
813 * various library calls, such as getpwent_r. The wrapping is done so
814 * that other files like pp_sys.c calling those library functions need not
815 * care about the differences between various platforms' idiosyncrasies
816 * regarding these reentrant interfaces.
820 #define PERL_IN_REENTR_C
825 Perl_reentrant_size(pTHX) {
826 #ifdef USE_REENTRANT_API
827 #define REENTRANTSMALLSIZE 256 /* Make something up. */
828 #define REENTRANTUSUALSIZE 4096 /* Make something up. */
830 #endif /* USE_REENTRANT_API */
834 Perl_reentrant_init(pTHX) {
835 #ifdef USE_REENTRANT_API
836 Newx(PL_reentrant_buffer, 1, REENTR);
837 Perl_reentrant_size(aTHX);
839 #endif /* USE_REENTRANT_API */
843 Perl_reentrant_free(pTHX) {
844 #ifdef USE_REENTRANT_API
846 Safefree(PL_reentrant_buffer);
847 #endif /* USE_REENTRANT_API */
851 Perl_reentrant_retry(const char *f, ...)
856 #ifdef USE_REENTRANT_API
857 /* Easier to special case this here than in embed.pl. (Look at what it
858 generates for proto.h) */
859 PERL_ARGS_ASSERT_REENTRANT_RETRY;
863 #ifdef USE_REENTRANT_API
864 # 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)
867 # if defined(USE_SERVENT_BUFFER)
870 # if defined(USE_HOSTENT_BUFFER)
873 # if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
877 switch (PL_op->op_type) {
878 #ifdef USE_HOSTENT_BUFFER
883 #ifdef PERL_REENTRANT_MAXSIZE
884 if (PL_reentrant_buffer->_hostent_size <=
885 PERL_REENTRANT_MAXSIZE / 2)
888 PL_reentrant_buffer->_hostent_size *= 2;
889 Renew(PL_reentrant_buffer->_hostent_buffer,
890 PL_reentrant_buffer->_hostent_size, char);
891 switch (PL_op->op_type) {
893 p0 = va_arg(ap, void *);
894 asize = va_arg(ap, size_t);
895 anint = va_arg(ap, int);
896 retptr = gethostbyaddr(p0, asize, anint); break;
898 p0 = va_arg(ap, void *);
899 retptr = gethostbyname((char *)p0); break;
901 retptr = gethostent(); break;
903 SETERRNO(ERANGE, LIB_INVARG);
910 #ifdef USE_GRENT_BUFFER
915 #ifdef PERL_REENTRANT_MAXSIZE
916 if (PL_reentrant_buffer->_grent_size <=
917 PERL_REENTRANT_MAXSIZE / 2)
921 PL_reentrant_buffer->_grent_size *= 2;
922 Renew(PL_reentrant_buffer->_grent_buffer,
923 PL_reentrant_buffer->_grent_size, char);
924 switch (PL_op->op_type) {
926 p0 = va_arg(ap, void *);
927 retptr = getgrnam((char *)p0); break;
929 #if Gid_t_size < INTSIZE
930 gid = (Gid_t)va_arg(ap, int);
932 gid = va_arg(ap, Gid_t);
934 retptr = getgrgid(gid); break;
936 retptr = getgrent(); break;
938 SETERRNO(ERANGE, LIB_INVARG);
945 #ifdef USE_NETENT_BUFFER
950 #ifdef PERL_REENTRANT_MAXSIZE
951 if (PL_reentrant_buffer->_netent_size <=
952 PERL_REENTRANT_MAXSIZE / 2)
956 PL_reentrant_buffer->_netent_size *= 2;
957 Renew(PL_reentrant_buffer->_netent_buffer,
958 PL_reentrant_buffer->_netent_size, char);
959 switch (PL_op->op_type) {
961 net = va_arg(ap, Netdb_net_t);
962 anint = va_arg(ap, int);
963 retptr = getnetbyaddr(net, anint); break;
965 p0 = va_arg(ap, void *);
966 retptr = getnetbyname((char *)p0); break;
968 retptr = getnetent(); break;
970 SETERRNO(ERANGE, LIB_INVARG);
977 #ifdef USE_PWENT_BUFFER
982 #ifdef PERL_REENTRANT_MAXSIZE
983 if (PL_reentrant_buffer->_pwent_size <=
984 PERL_REENTRANT_MAXSIZE / 2)
988 PL_reentrant_buffer->_pwent_size *= 2;
989 Renew(PL_reentrant_buffer->_pwent_buffer,
990 PL_reentrant_buffer->_pwent_size, char);
991 switch (PL_op->op_type) {
993 p0 = va_arg(ap, void *);
994 retptr = getpwnam((char *)p0); break;
996 #if Uid_t_size < INTSIZE
997 uid = (Uid_t)va_arg(ap, int);
999 uid = va_arg(ap, Uid_t);
1001 retptr = getpwuid(uid); break;
1003 retptr = getpwent(); break;
1005 SETERRNO(ERANGE, LIB_INVARG);
1012 #ifdef USE_PROTOENT_BUFFER
1017 #ifdef PERL_REENTRANT_MAXSIZE
1018 if (PL_reentrant_buffer->_protoent_size <=
1019 PERL_REENTRANT_MAXSIZE / 2)
1022 PL_reentrant_buffer->_protoent_size *= 2;
1023 Renew(PL_reentrant_buffer->_protoent_buffer,
1024 PL_reentrant_buffer->_protoent_size, char);
1025 switch (PL_op->op_type) {
1027 p0 = va_arg(ap, void *);
1028 retptr = getprotobyname((char *)p0); break;
1030 anint = va_arg(ap, int);
1031 retptr = getprotobynumber(anint); break;
1033 retptr = getprotoent(); break;
1035 SETERRNO(ERANGE, LIB_INVARG);
1042 #ifdef USE_SERVENT_BUFFER
1047 #ifdef PERL_REENTRANT_MAXSIZE
1048 if (PL_reentrant_buffer->_servent_size <=
1049 PERL_REENTRANT_MAXSIZE / 2)
1052 PL_reentrant_buffer->_servent_size *= 2;
1053 Renew(PL_reentrant_buffer->_servent_buffer,
1054 PL_reentrant_buffer->_servent_size, char);
1055 switch (PL_op->op_type) {
1057 p0 = va_arg(ap, void *);
1058 p1 = va_arg(ap, void *);
1059 retptr = getservbyname((char *)p0, (char *)p1); break;
1061 anint = va_arg(ap, int);
1062 p0 = va_arg(ap, void *);
1063 retptr = getservbyport(anint, (char *)p0); break;
1065 retptr = getservent(); break;
1067 SETERRNO(ERANGE, LIB_INVARG);
1075 /* Not known how to retry, so just fail. */
1090 rename_if_different('reentr.c-new', 'reentr.c');
1093 asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
1094 crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
1095 ctermid B |stdio | |B_B
1096 ctime S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
1097 drand48 |stdlib |struct drand48_data |I_ST|T=double*
1098 endgrent |grp | |I_H|V_H
1099 endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1100 endnetent |netdb | |I_D|V_D|D=struct netent_data*
1101 endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
1102 endpwent |pwd | |I_H|V_H
1103 endservent |netdb | |I_D|V_D|D=struct servent_data*
1104 getgrent |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1105 getgrgid T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1106 getgrnam C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
1107 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
1108 gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1109 gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
1110 getlogin |unistd |char |I_BW|I_BI|B_BW|B_BI
1111 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
1112 getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1113 getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1114 getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1115 getprotobynumber I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1116 getprotoent |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1117 getpwent |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1118 getpwnam C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1119 getpwuid T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1120 getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1121 getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1122 getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1123 getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
1124 random |stdlib |struct random_data|I_iS|I_lS|I_St|i=int*|l=long*|t=int32_t*
1125 readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1126 readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1127 setgrent |grp | |I_H|V_H
1128 sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
1129 setlocale IC |locale | |I_ICBI
1130 setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
1131 setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
1132 setpwent |pwd | |I_H|V_H
1133 setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
1134 srand48 L |stdlib |struct drand48_data |I_LS
1135 srandom T |stdlib |struct random_data|I_TS|T=unsigned int
1136 strerror I |string | |I_IBW|I_IBI|B_IBW
1137 tmpnam B |stdio | |B_B
1138 ttyname I |unistd | |I_IBW|I_IBI|B_IBI