3 # Regenerate (overwriting only if changed):
8 # from information stored in the DATA section of this file.
10 # With the -U option, it also unconditionally regenerates the relevant
15 # Also accepts the standard regen_lib -q and -v args.
17 # This script is normally invoked from regen.pl.
20 # Get function prototypes
21 require './regen/regen_lib.pl';
27 getopts('Uv', \%opts);
31 A => "char*", # as an input argument
32 B => "char*", # as an output argument
33 C => "const char*", # as a read-only input argument
41 # (See the definitions after __DATA__.)
42 # In func|inc|type|... a "S" means "type*", and a "R" means "type**".
43 # (The "types" are often structs, such as "struct passwd".)
45 # After the prototypes one can have |X=...|Y=... to define more types.
46 # A commonly used extra type is to define D to be equal to "type_data",
47 # for example "struct_hostent_data to" go with "struct hostent".
49 # Example #1: I_XSBWR means int func_r(X, type, char*, size_t, type**)
50 # Example #2: S_SBIE means type func_r(type, char*, int, int*)
51 # Example #3: S_CBI means type func_r(const char*, char*, int)
53 sub open_print_header {
54 my ($file, $quote) = @_;
55 return open_new($file, '>',
56 { by => 'regen/reentr.pl',
57 from => 'data in regen/reentr.pl',
58 file => $file, style => '*',
59 copyright => [2002, 2003, 2005 .. 2007],
63 my $h = open_print_header('reentr.h');
65 #ifndef PERL_REENTR_H_
66 #define PERL_REENTR_H_
68 /* If compiling for a threaded perl, we will macro-wrap the system/library
69 * interfaces (e.g. getpwent()) which have threaded versions
70 * (e.g. getpwent_r()), which will handle things correctly for
71 * the Perl interpreter. This is done automatically for the perl core and
72 * extensions, but not generally for XS modules unless they
73 * #define PERL_REENTRANT
74 * See L<perlxs/Thread-aware system interfaces>.
76 * For a function 'foo', use the compile-time directive
77 * #ifdef PERL_REENTR_USING_FOO_R
78 * to test if the function actually did get replaced by the reentrant version.
79 * (If it isn't getting replaced, it might mean it uses a different prototype
80 * on the given platform than any we are expecting. To fix that, add the
81 * prototype to the __DATA__ section of regen/reentr.pl.)
84 #ifndef PERL_REENTR_API
85 # if defined(PERL_CORE) || defined(PERL_EXT) || defined(PERL_REENTRANT)
86 # define PERL_REENTR_API 1
88 # define PERL_REENTR_API 0
92 #ifdef USE_REENTRANT_API
94 /* For thread-safe builds, alternative methods are used to make calls to this
96 #ifdef USE_THREAD_SAFE_LOCALE
97 # undef HAS_SETLOCALE_R
100 /* Deprecations: some platforms have the said reentrant interfaces
101 * but they are declared obsolete and are not to be used. Often this
102 * means that the platform has threadsafed the interfaces (hopefully).
103 * All this is OS version dependent, so we are of course fooling ourselves.
104 * If you know of more deprecations on some platforms, please add your own
105 * (by editing reentr.pl, mind!) */
109 # undef HAS_ENDGRENT_R
110 # undef HAS_ENDPWENT_R
111 # undef HAS_GETGRENT_R
112 # undef HAS_GETPWENT_R
113 # undef HAS_SETLOCALE_R
114 # undef HAS_STRERROR_R
115 # define NETDB_R_OBSOLETE
118 # if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
120 # undef HAS_STRERROR_R
121 # define NETDB_R_OBSOLETE
124 # if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 24))
125 # undef HAS_READDIR_R
126 # undef HAS_READDIR64_R
130 * As of OpenBSD 3.7, reentrant functions are now working, they just are
131 * incompatible with everyone else. To make OpenBSD happy, we have to
132 * memzero out certain structures before calling the functions.
134 # if defined(__OpenBSD__)
135 # define REENTR_MEMZERO(a,b) memzero(a,b)
137 # define REENTR_MEMZERO(a,b) 0
140 # ifdef NETDB_R_OBSOLETE
141 # undef HAS_ENDHOSTENT_R
142 # undef HAS_ENDNETENT_R
143 # undef HAS_ENDPROTOENT_R
144 # undef HAS_ENDSERVENT_R
145 # undef HAS_GETHOSTBYADDR_R
146 # undef HAS_GETHOSTBYNAME_R
147 # undef HAS_GETHOSTENT_R
148 # undef HAS_GETNETBYADDR_R
149 # undef HAS_GETNETBYNAME_R
150 # undef HAS_GETNETENT_R
151 # undef HAS_GETPROTOBYNAME_R
152 # undef HAS_GETPROTOBYNUMBER_R
153 # undef HAS_GETPROTOENT_R
154 # undef HAS_GETSERVBYNAME_R
155 # undef HAS_GETSERVBYPORT_R
156 # undef HAS_GETSERVENT_R
157 # undef HAS_SETHOSTENT_R
158 # undef HAS_SETNETENT_R
159 # undef HAS_SETPROTOENT_R
160 # undef HAS_SETSERVENT_R
177 # ifdef HAS_GETSPNAM_R
185 my %seenh; # the different prototypes signatures for this function
186 my %seena; # the different prototypes signatures for this function in order
187 my @seenf; # all the seen functions
188 my %seenp; # the different prototype signatures for all functions
189 my %seent; # the return type of this function
190 my %seens; # the type of this function's "S"
191 my %seend; # the type of this function's "D"
192 my %seenm; # all the types
193 my %seenu; # the length of the argument list of this function
195 while (<DATA>) { # Read in the protoypes.
198 my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1);
200 # Split off the real function name and the argument list.
201 ($func, $u) = split(' ', $func);
202 $seenu{$func} = defined $u ? length $u : 0;
203 my $FUNC = uc $func; # for output.
211 # Set any special mapping variables (like X=x_t)
213 while ($p[-1] =~ /=/) {
214 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
220 # If given the -U option open up the metaconfig unit for this function.
221 if ($opts{U} && open(U, ">", "d_${func}_r.U")) {
226 # The metaconfig units needs prerequisite dependencies.
230 if ($hdr ne 'stdio') { # There's no i_stdio.
233 $prereqsh = "\$$prereqs $prereqh";
235 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
236 push @prereq, $prereqs;
237 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
238 if ($hdr eq 'time') {
239 $hdrs .= " \$i_systime sys/time.h";
240 push @prereq, 'i_systime';
242 # Output the metaconfig unit header.
244 ?RCS: \$Id: d_${func}_r.U,v $
246 ?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
248 ?RCS: You may distribute under the terms of either the GNU General Public
249 ?RCS: License or the Artistic License, as specified in the README file.
251 ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
253 ?MAKE:d_${func}_r ${func}_r_proto: @prereq
254 ?MAKE: -pick add \$@ %<
256 ?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
257 ?S: which indicates to the C program that the ${func}_r()
258 ?S: routine is available.
261 ?S: This variable encodes the prototype of ${func}_r.
262 ?S: It is zero if d_${func}_r is undef, and one of the
263 ?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
267 ?C: This symbol, if defined, indicates that the ${func}_r routine
268 ?C: is available to ${func} re-entrantly.
271 ?C: This symbol encodes the prototype of ${func}_r.
272 ?C: It is zero if d_${func}_r is undef, and one of the
273 ?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
276 ?H:#\$d_${func}_r HAS_${FUNC}_R /**/
277 ?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
279 ?T:try hdrs d_${func}_r_proto
280 ?LINT:set d_${func}_r
281 ?LINT:set ${func}_r_proto
282 : see if ${func}_r exists
283 set ${func}_r d_${func}_r
285 case "\$d_${func}_r" in
290 case "\$d_${func}_r_proto:\$usethreads" in
291 ":define") d_${func}_r_proto=define
292 set d_${func}_r_proto ${func}_r \$hdrs
296 case "\$d_${func}_r_proto" in
301 my ($r, $a) = ($p =~ /^(.)_(.+)/);
302 my $v = join(", ", map { $m{$_} } split '', $a);
305 case "\$${func}_r_proto" in
306 ''|0) try='$m{$r} ${func}_r($v);'
307 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
311 $seenh{$func}->{$p}++;
312 push @{$seena{$func}}, $p;
314 $seent{$func} = $type;
315 $seens{$func} = $m{S};
316 $seend{$func} = $m{D};
321 case "\$${func}_r_proto" in
322 ''|0) d_${func}_r=undef
324 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
325 * ) case "\$${func}_r_proto" in
327 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
329 echo "Prototype: \$try" ;;
332 *) case "\$usethreads" in
333 define) echo "${func}_r has no prototype, not using it." >&4 ;;
352 # Write out all the known prototype signatures.
354 for my $p (sort keys %seenp) {
355 print $h "# define REENTRANT_PROTO_${p} ${i}\n";
360 my @struct; # REENTR struct members
361 my @size; # struct member buffer size initialization code
362 my @init; # struct member buffer initialization (malloc) code
363 my @free; # struct member buffer release (free) code
364 my @wrap; # the wrapper (foo(a) -> foo_r(a,...)) cpp code
365 my @define; # defines for optional features
369 join " || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @_;
382 Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
385 Safefree(PL_reentrant_buffer->_${func}_buffer);
390 my ($n, $p, @F) = @_;
394 /* The @F using \L$n? */
400 my $HAS = "${FUNC}_R_HAS_$n";
402 my @h = grep { /$p/ } @{$seena{$func}};
403 unless (defined $GENFUNC) {
405 $GENFUNC =~ s/^GET//;
408 push @define, "# if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
421 /* Any of the @F using \L$n? */
424 push @define, "# if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
426 # define USE_${GENFUNC}_$n
428 # undef USE_${GENFUNC}_$n
434 define('BUFFER', 'B',
435 qw(getgrent getgrgid getgrnam));
438 qw(getgrent getgrgid getgrnam));
440 qw(getpwent getpwnam getpwuid));
442 qw(getspent getspnam));
445 qw(getgrent getgrgid getgrnam setgrent endgrent));
447 qw(getpwent getpwnam getpwuid setpwent endpwent));
449 define('BUFFER', 'B',
450 qw(getpwent getpwgid getpwnam));
452 define('BUFFER', 'B',
453 qw(getspent getspnam));
456 qw(gethostent gethostbyaddr gethostbyname));
458 qw(getnetent getnetbyaddr getnetbyname));
460 qw(getprotoent getprotobyname getprotobynumber));
462 qw(getservent getservbyname getservbyport));
464 define('BUFFER', 'B',
465 qw(gethostent gethostbyaddr gethostbyname));
466 define('BUFFER', 'B',
467 qw(getnetent getnetbyaddr getnetbyname));
468 define('BUFFER', 'B',
469 qw(getprotoent getprotobyname getprotobynumber));
470 define('BUFFER', 'B',
471 qw(getservent getservbyname getservbyport));
474 qw(gethostent gethostbyaddr gethostbyname));
476 qw(getnetent getnetbyaddr getnetbyname));
478 # The following loop accumulates the "ssif" (struct, size, init, free)
479 # sections that declare the struct members (in reentr.h), and the buffer
480 # size initialization, buffer initialization (malloc), and buffer
481 # release (free) code (in reentr.c).
483 # The loop also contains a lot of intrinsic logic about groups of
484 # functions (since functions of certain kind operate the same way).
486 for my $func (@seenf) {
488 my $ifdef = "# ifdef HAS_${FUNC}_R\n";
489 my $endif = "# endif /* HAS_${FUNC}_R */\n\n";
490 if (exists $seena{$func}) {
491 my @p = @{$seena{$func}};
492 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
495 char* _${func}_buffer;
496 size_t _${func}_size;
498 my $size = ($func =~ /^(asctime|ctime)$/)
500 : "REENTRANTSMALLSIZE";
502 PL_reentrant_buffer->_${func}_size = $size;
507 elsif ($func =~ /^(gm|local)time$/) {
509 push @struct, <<EOF; # Fixed size
510 $seent{$func} _${func}_struct;
514 elsif ($func =~ /^(crypt)$/) {
517 # if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
518 $seend{$func} _${func}_data;
520 $seent{$func} *_${func}_struct_buffer;
524 # if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
525 PL_reentrant_buffer->_${func}_struct_buffer = 0;
529 # if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
530 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
535 elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) {
537 # 'genfunc' can be read either as 'generic' or 'genre',
538 # it represents a group of functions.
540 $genfunc =~ s/nam/ent/g;
541 $genfunc =~ s/^get//;
542 my $GENFUNC = uc $genfunc;
544 $seent{$func} _${genfunc}_struct;
545 char* _${genfunc}_buffer;
546 size_t _${genfunc}_size;
549 # ifdef USE_${GENFUNC}_PTR
550 $seent{$func}* _${genfunc}_ptr;
554 # ifdef USE_${GENFUNC}_FPTR
555 FILE* _${genfunc}_fptr;
559 # ifdef USE_${GENFUNC}_FPTR
560 PL_reentrant_buffer->_${genfunc}_fptr = NULL;
563 my $sc = $genfunc eq 'grent' ?
564 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
565 my $sz = "_${genfunc}_size";
567 # if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
568 PL_reentrant_buffer->$sz = sysconf($sc);
569 if (PL_reentrant_buffer->$sz == (size_t) -1)
570 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
571 # elif defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
572 PL_reentrant_buffer->$sz = SIABUFSIZ;
573 # elif defined(__sgi)
574 PL_reentrant_buffer->$sz = BUFSIZ;
576 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 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";
670 substr($b, 0, $seenu{$func}) = '';
672 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
673 } elsif ($b =~ /S/) {
674 if ($func =~ /^readdir/) {
675 $true = "PL_reentrant_buffer->_${genfunc}_struct";
677 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
679 } elsif ($b =~ /B/) {
680 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
685 ? "&PL_reentrant_buffer->_${genfunc}_ptr"
687 ? "&PL_reentrant_buffer->_${genfunc}_errno"
689 ? "PL_reentrant_buffer->_${genfunc}_buffer"
691 ? "PL_reentrant_buffer->_${genfunc}_size"
693 ? "&PL_reentrant_buffer->_${genfunc}_fptr"
695 ? "&PL_reentrant_buffer->_${genfunc}_data"
697 ? ($func =~ /^readdir\d*$/
698 ? "PL_reentrant_buffer->_${genfunc}_struct"
700 ? "PL_reentrant_buffer->_${genfunc}_struct_buffer"
701 : "&PL_reentrant_buffer->_${genfunc}_struct")
704 $w = ", $w" if length $v;
707 # This needs a special case, see its definition in config.h
708 my $setup = ($func eq 'localtime') ? "L_R_TZSET " : "";
710 my $call = "$setup${func}_r($v$w)";
712 # Must make OpenBSD happy
715 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
716 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),';
719 # if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
721 if ($r eq 'V' || $r eq 'B') {
723 # define $func($v) $call
726 if ($func =~ /^get/) {
727 my $rv = $v ? ", $v" : "";
730 # define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : ((PL_reentrant_retint == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
734 # define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
739 # define $func($v) ($call$test ? $true : 0)
743 push @wrap, <<EOF; # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS
749 # define PERL_REENTR_USING_${FUNC}_R
753 push @wrap, <<EOF; # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
757 push @wrap, $endif, "\n";
765 /* Defines for indicating which special features are supported. */
771 int dummy; /* cannot have empty structs */
778 /* Special case this; if others came along, could automate it */
779 # ifdef HAS_GETSPNAM_R
780 # define KEY_getspnam -1
783 #endif /* USE_REENTRANT_API */
788 read_only_bottom_close_and_rename($h);
790 # Prepare to write the reentr.c.
792 my $c = open_print_header('reentr.c', <<'EOQ');
796 * "Saruman," I said, standing away from him, "only one hand at a time can
797 * wield the One, and you know that well, so do not trouble to say we!"
799 * [p.260 of _The Lord of the Rings_, II/ii: "The Council of Elrond"]
803 * This file contains a collection of automatically created wrappers
804 * (created by running reentr.pl) for reentrant (thread-safe) versions of
805 * various library calls, such as getpwent_r. The wrapping is done so
806 * that other files like pp_sys.c calling those library functions need not
807 * care about the differences between various platforms' idiosyncrasies
808 * regarding these reentrant interfaces.
814 #define PERL_IN_REENTR_C
817 #include "keywords.h"
819 #define RenewDouble(data_pointer, size_pointer, type) \\
821 const size_t size = MAX(*(size_pointer), 1) * 2; \\
822 Renew((data_pointer), (size), type); \\
823 *(size_pointer) = size; \\
827 Perl_reentrant_size(pTHX) {
830 /* Set the sizes of the reentrant buffers */
832 #ifdef USE_REENTRANT_API
833 # define REENTRANTSMALLSIZE 256 /* Make something up. */
834 # define REENTRANTUSUALSIZE 4096 /* Make something up. */
837 #endif /* USE_REENTRANT_API */
842 Perl_reentrant_init(pTHX) {
845 /* Initialize the whole thing */
847 #ifdef USE_REENTRANT_API
849 Newx(PL_reentrant_buffer, 1, REENTR);
850 Perl_reentrant_size(aTHX);
853 #endif /* USE_REENTRANT_API */
858 Perl_reentrant_free(pTHX) {
863 #ifdef USE_REENTRANT_API
866 Safefree(PL_reentrant_buffer);
868 #endif /* USE_REENTRANT_API */
872 Perl_reentrant_retry(const char *f, ...)
874 /* This function is set up to be called if the normal function returns
875 * failure with errno ERANGE, which indicates the buffer is too small.
876 * This function calls the failing one again with a larger buffer.
878 * What has happened is that, due to the magic of C preprocessor macro
879 * expansion, when the original code called function 'foo(args)', it was
880 * instead compiled into something like a call of 'foo_r(args, buffer)'
881 * Below we retry with 'foo', but the preprocessor has changed that into
882 * 'foo_r', so this function will end up calling itself recursively, each
883 * time with a larger buffer. If PERL_REENTRANT_MAXSIZE is defined, it
884 * won't increase beyond that, instead failing. */
891 #ifdef USE_REENTRANT_API
895 key = Perl_keyword (aTHX_ f, strlen(f), FALSE /* not feature enabled */);
897 /* Easier to special case this here than in embed.pl. (Look at what it
898 generates for proto.h) */
899 PERL_ARGS_ASSERT_REENTRANT_RETRY;
905 #ifdef HAS_GETSPNAM_R
907 /* This is a #define as has no corresponding keyword */
908 if (strEQ(f, "getspnam")) {
921 #ifdef USE_REENTRANT_API
925 # ifdef USE_HOSTENT_BUFFER
927 case KEY_gethostbyaddr:
928 case KEY_gethostbyname:
936 # ifdef PERL_REENTRANT_MAXSIZE
937 if (PL_reentrant_buffer->_hostent_size <=
938 PERL_REENTRANT_MAXSIZE / 2)
940 RenewDouble(PL_reentrant_buffer->_hostent_buffer,
941 &PL_reentrant_buffer->_hostent_size, char);
943 case KEY_gethostbyaddr:
944 host_addr = va_arg(ap, char *);
945 asize = va_arg(ap, Size_t);
946 anint = va_arg(ap, int);
947 /* socklen_t is what Posix 2001 says this should be */
948 retptr = gethostbyaddr(host_addr, (socklen_t) asize, anint); break;
949 case KEY_gethostbyname:
950 host_name = va_arg(ap, char *);
951 retptr = gethostbyname(host_name); break;
953 retptr = gethostent(); break;
955 SETERRNO(ERANGE, LIB_INVARG);
962 # ifdef USE_GRENT_BUFFER
971 # ifdef PERL_REENTRANT_MAXSIZE
972 if (PL_reentrant_buffer->_grent_size <=
973 PERL_REENTRANT_MAXSIZE / 2)
975 RenewDouble(PL_reentrant_buffer->_grent_buffer,
976 &PL_reentrant_buffer->_grent_size, char);
979 name = va_arg(ap, char *);
980 retptr = getgrnam(name); break;
982 # if Gid_t_size < INTSIZE
983 gid = (Gid_t)va_arg(ap, int);
985 gid = va_arg(ap, Gid_t);
987 retptr = getgrgid(gid); break;
989 retptr = getgrent(); break;
991 SETERRNO(ERANGE, LIB_INVARG);
998 # ifdef USE_NETENT_BUFFER
1000 case KEY_getnetbyaddr:
1001 case KEY_getnetbyname:
1008 # ifdef PERL_REENTRANT_MAXSIZE
1009 if (PL_reentrant_buffer->_netent_size <=
1010 PERL_REENTRANT_MAXSIZE / 2)
1012 RenewDouble(PL_reentrant_buffer->_netent_buffer,
1013 &PL_reentrant_buffer->_netent_size, char);
1015 case KEY_getnetbyaddr:
1016 net = va_arg(ap, Netdb_net_t);
1017 anint = va_arg(ap, int);
1018 retptr = getnetbyaddr(net, anint); break;
1019 case KEY_getnetbyname:
1020 name = va_arg(ap, char *);
1021 retptr = getnetbyname(name); break;
1023 retptr = getnetent(); break;
1025 SETERRNO(ERANGE, LIB_INVARG);
1032 # ifdef USE_PWENT_BUFFER
1041 # ifdef PERL_REENTRANT_MAXSIZE
1042 if (PL_reentrant_buffer->_pwent_size <=
1043 PERL_REENTRANT_MAXSIZE / 2)
1046 RenewDouble(PL_reentrant_buffer->_pwent_buffer,
1047 &PL_reentrant_buffer->_pwent_size, char);
1050 name = va_arg(ap, char *);
1051 retptr = getpwnam(name); break;
1054 # if Uid_t_size < INTSIZE
1055 uid = (Uid_t)va_arg(ap, int);
1057 uid = va_arg(ap, Uid_t);
1059 retptr = getpwuid(uid); break;
1061 # if defined(HAS_GETPWENT) || defined(HAS_GETPWENT_R)
1064 retptr = getpwent(); break;
1067 SETERRNO(ERANGE, LIB_INVARG);
1074 # ifdef USE_SPENT_BUFFER
1080 # ifdef PERL_REENTRANT_MAXSIZE
1081 if (PL_reentrant_buffer->_spent_size <=
1082 PERL_REENTRANT_MAXSIZE / 2)
1085 RenewDouble(PL_reentrant_buffer->_spent_buffer,
1086 &PL_reentrant_buffer->_spent_size, char);
1089 name = va_arg(ap, char *);
1090 retptr = getspnam(name); break;
1092 SETERRNO(ERANGE, LIB_INVARG);
1099 # ifdef USE_PROTOENT_BUFFER
1101 case KEY_getprotobyname:
1102 case KEY_getprotobynumber:
1103 case KEY_getprotoent:
1108 # ifdef PERL_REENTRANT_MAXSIZE
1109 if (PL_reentrant_buffer->_protoent_size <=
1110 PERL_REENTRANT_MAXSIZE / 2)
1112 RenewDouble(PL_reentrant_buffer->_protoent_buffer,
1113 &PL_reentrant_buffer->_protoent_size, char);
1115 case KEY_getprotobyname:
1116 name = va_arg(ap, char *);
1117 retptr = getprotobyname(name); break;
1118 case KEY_getprotobynumber:
1119 anint = va_arg(ap, int);
1120 retptr = getprotobynumber(anint); break;
1121 case KEY_getprotoent:
1122 retptr = getprotoent(); break;
1124 SETERRNO(ERANGE, LIB_INVARG);
1131 # ifdef USE_SERVENT_BUFFER
1133 case KEY_getservbyname:
1134 case KEY_getservbyport:
1135 case KEY_getservent:
1141 # ifdef PERL_REENTRANT_MAXSIZE
1142 if (PL_reentrant_buffer->_servent_size <=
1143 PERL_REENTRANT_MAXSIZE / 2)
1145 RenewDouble(PL_reentrant_buffer->_servent_buffer,
1146 &PL_reentrant_buffer->_servent_size, char);
1148 case KEY_getservbyname:
1149 name = va_arg(ap, char *);
1150 proto = va_arg(ap, char *);
1151 retptr = getservbyname(name, proto); break;
1152 case KEY_getservbyport:
1153 anint = va_arg(ap, int);
1154 name = va_arg(ap, char *);
1155 retptr = getservbyport(anint, name); break;
1156 case KEY_getservent:
1157 retptr = getservent(); break;
1159 SETERRNO(ERANGE, LIB_INVARG);
1168 /* Not known how to retry, so just fail. */
1183 read_only_bottom_close_and_rename($c);
1185 # As of March 2020, the config.h entries that have reentrant prototypes that
1186 # aren't in this file are:
1192 # The meanings of the flags are derivable from %map above
1193 # Fnc, arg flags| hdr | ? struct type | prototypes...
1195 asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
1196 crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
1197 ctermid B |stdio | |B_B
1198 ctime S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
1199 endgrent |grp | |I_H|V_H
1200 endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1201 endnetent |netdb | |I_D|V_D|D=struct netent_data*
1202 endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
1203 endpwent |pwd | |I_H|V_H
1204 endservent |netdb | |I_D|V_D|D=struct servent_data*
1205 getgrent |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1206 getgrgid T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1207 getgrnam C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
1208 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
1209 gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1210 gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
1211 getlogin |unistd |char |I_BW|I_BI|B_BW|B_BI
1212 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
1213 getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1214 getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1215 getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1216 getprotobynumber I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1217 getprotoent |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1218 getpwent |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1219 getpwnam C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1220 getpwuid T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1221 getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1222 getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1223 getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1224 getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
1225 gmtime T |time |struct tm |S_TS|T=time_t*
1226 localtime T |time |struct tm |S_TS|T=time_t*
1227 readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1228 readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1229 setgrent |grp | |I_H|V_H
1230 sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
1231 setlocale IC |locale | |I_ICBI
1232 setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
1233 setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
1234 setpwent |pwd | |I_H|V_H
1235 setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
1236 strerror I |string | |I_IBW|I_IBI|B_IBW
1237 tmpnam B |stdio | |B_B
1238 ttyname I |unistd | |I_IBW|I_IBI|B_IBI