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, but otherwise (for XS) the wrapping does
72 * not take place. See L<perlxs/Thread-aware system interfaces>.
75 #ifndef PERL_REENTR_API
76 # if defined(PERL_CORE) || defined(PERL_EXT) || defined(PERL_REENTRANT)
77 # define PERL_REENTR_API 1
79 # define PERL_REENTR_API 0
83 #ifdef USE_REENTRANT_API
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!) */
94 # undef HAS_ENDGRENT_R
95 # undef HAS_ENDPWENT_R
96 # undef HAS_GETGRENT_R
97 # undef HAS_GETPWENT_R
98 # undef HAS_SETLOCALE_R
99 # undef HAS_STRERROR_R
100 # define NETDB_R_OBSOLETE
103 # if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
105 # undef HAS_STRERROR_R
106 # define NETDB_R_OBSOLETE
109 # if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 24))
110 # undef HAS_READDIR_R
111 # undef HAS_READDIR64_R
115 * As of OpenBSD 3.7, reentrant functions are now working, they just are
116 * incompatible with everyone else. To make OpenBSD happy, we have to
117 * memzero out certain structures before calling the functions.
119 # if defined(__OpenBSD__)
120 # define REENTR_MEMZERO(a,b) memzero(a,b)
122 # define REENTR_MEMZERO(a,b) 0
125 # ifdef NETDB_R_OBSOLETE
126 # undef HAS_ENDHOSTENT_R
127 # undef HAS_ENDNETENT_R
128 # undef HAS_ENDPROTOENT_R
129 # undef HAS_ENDSERVENT_R
130 # undef HAS_GETHOSTBYADDR_R
131 # undef HAS_GETHOSTBYNAME_R
132 # undef HAS_GETHOSTENT_R
133 # undef HAS_GETNETBYADDR_R
134 # undef HAS_GETNETBYNAME_R
135 # undef HAS_GETNETENT_R
136 # undef HAS_GETPROTOBYNAME_R
137 # undef HAS_GETPROTOBYNUMBER_R
138 # undef HAS_GETPROTOENT_R
139 # undef HAS_GETSERVBYNAME_R
140 # undef HAS_GETSERVBYPORT_R
141 # undef HAS_GETSERVENT_R
142 # undef HAS_SETHOSTENT_R
143 # undef HAS_SETNETENT_R
144 # undef HAS_SETPROTOENT_R
145 # undef HAS_SETSERVENT_R
162 # ifdef HAS_GETSPNAM_R
170 my %seenh; # the different prototypes signatures for this function
171 my %seena; # the different prototypes signatures for this function in order
172 my @seenf; # all the seen functions
173 my %seenp; # the different prototype signatures for all functions
174 my %seent; # the return type of this function
175 my %seens; # the type of this function's "S"
176 my %seend; # the type of this function's "D"
177 my %seenm; # all the types
178 my %seenu; # the length of the argument list of this function
180 while (<DATA>) { # Read in the protoypes.
183 my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1);
185 # Split off the real function name and the argument list.
186 ($func, $u) = split(' ', $func);
187 $seenu{$func} = defined $u ? length $u : 0;
188 my $FUNC = uc $func; # for output.
196 # Set any special mapping variables (like X=x_t)
198 while ($p[-1] =~ /=/) {
199 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
205 # If given the -U option open up the metaconfig unit for this function.
206 if ($opts{U} && open(U, ">", "d_${func}_r.U")) {
211 # The metaconfig units needs prerequisite dependencies.
215 if ($hdr ne 'stdio') { # There's no i_stdio.
218 $prereqsh = "\$$prereqs $prereqh";
220 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
221 push @prereq, $prereqs;
222 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
223 if ($hdr eq 'time') {
224 $hdrs .= " \$i_systime sys/time.h";
225 push @prereq, 'i_systime';
227 # Output the metaconfig unit header.
229 ?RCS: \$Id: d_${func}_r.U,v $
231 ?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
233 ?RCS: You may distribute under the terms of either the GNU General Public
234 ?RCS: License or the Artistic License, as specified in the README file.
236 ?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
238 ?MAKE:d_${func}_r ${func}_r_proto: @prereq
239 ?MAKE: -pick add \$@ %<
241 ?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
242 ?S: which indicates to the C program that the ${func}_r()
243 ?S: routine is available.
246 ?S: This variable encodes the prototype of ${func}_r.
247 ?S: It is zero if d_${func}_r is undef, and one of the
248 ?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
252 ?C: This symbol, if defined, indicates that the ${func}_r routine
253 ?C: is available to ${func} re-entrantly.
256 ?C: This symbol encodes the prototype of ${func}_r.
257 ?C: It is zero if d_${func}_r is undef, and one of the
258 ?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
261 ?H:#\$d_${func}_r HAS_${FUNC}_R /**/
262 ?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
264 ?T:try hdrs d_${func}_r_proto
265 ?LINT:set d_${func}_r
266 ?LINT:set ${func}_r_proto
267 : see if ${func}_r exists
268 set ${func}_r d_${func}_r
270 case "\$d_${func}_r" in
275 case "\$d_${func}_r_proto:\$usethreads" in
276 ":define") d_${func}_r_proto=define
277 set d_${func}_r_proto ${func}_r \$hdrs
281 case "\$d_${func}_r_proto" in
286 my ($r, $a) = ($p =~ /^(.)_(.+)/);
287 my $v = join(", ", map { $m{$_} } split '', $a);
290 case "\$${func}_r_proto" in
291 ''|0) try='$m{$r} ${func}_r($v);'
292 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
296 $seenh{$func}->{$p}++;
297 push @{$seena{$func}}, $p;
299 $seent{$func} = $type;
300 $seens{$func} = $m{S};
301 $seend{$func} = $m{D};
306 case "\$${func}_r_proto" in
307 ''|0) d_${func}_r=undef
309 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
310 * ) case "\$${func}_r_proto" in
312 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
314 echo "Prototype: \$try" ;;
317 *) case "\$usethreads" in
318 define) echo "${func}_r has no prototype, not using it." >&4 ;;
337 # Write out all the known prototype signatures.
339 for my $p (sort keys %seenp) {
340 print $h "# 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));
437 define('BUFFER', 'B',
438 qw(getspent getspnam));
441 qw(gethostent gethostbyaddr gethostbyname));
443 qw(getnetent getnetbyaddr getnetbyname));
445 qw(getprotoent getprotobyname getprotobynumber));
447 qw(getservent getservbyname getservbyport));
449 define('BUFFER', 'B',
450 qw(gethostent gethostbyaddr gethostbyname));
451 define('BUFFER', 'B',
452 qw(getnetent getnetbyaddr getnetbyname));
453 define('BUFFER', 'B',
454 qw(getprotoent getprotobyname getprotobynumber));
455 define('BUFFER', 'B',
456 qw(getservent getservbyname getservbyport));
459 qw(gethostent gethostbyaddr gethostbyname));
461 qw(getnetent getnetbyaddr getnetbyname));
463 # The following loop accumulates the "ssif" (struct, size, init, free)
464 # sections that declare the struct members (in reentr.h), and the buffer
465 # size initialization, buffer initialization (malloc), and buffer
466 # release (free) code (in reentr.c).
468 # The loop also contains a lot of intrinsic logic about groups of
469 # functions (since functions of certain kind operate the same way).
471 for my $func (@seenf) {
473 my $ifdef = "# ifdef HAS_${FUNC}_R\n";
474 my $endif = "# endif /* HAS_${FUNC}_R */\n\n";
475 if (exists $seena{$func}) {
476 my @p = @{$seena{$func}};
477 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
480 char* _${func}_buffer;
481 size_t _${func}_size;
484 PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
489 elsif ($func =~ /^(crypt)$/) {
492 # if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
493 $seend{$func} _${func}_data;
495 $seent{$func} *_${func}_struct_buffer;
499 # if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
500 PL_reentrant_buffer->_${func}_struct_buffer = 0;
504 # if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
505 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
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 == (size_t) -1)
545 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
546 # elif defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
547 PL_reentrant_buffer->$sz = SIABUFSIZ;
548 # elif defined(__sgi)
549 PL_reentrant_buffer->$sz = BUFSIZ;
551 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
554 pushinitfree $genfunc;
557 elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
560 $genfunc =~ s/byname/ent/;
561 $genfunc =~ s/^get//;
562 my $GENFUNC = uc $genfunc;
563 my $D = ifprotomatch($FUNC, grep {/D/} @p);
564 my $d = $seend{$func};
565 $d =~ s/\*$//; # snip: we need the base type.
567 $seent{$func} _${genfunc}_struct;
571 char* _${genfunc}_buffer;
572 size_t _${genfunc}_size;
574 # ifdef USE_${GENFUNC}_PTR
575 $seent{$func}* _${genfunc}_ptr;
579 # ifdef USE_${GENFUNC}_ERRNO
580 int _${genfunc}_errno;
585 PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE;
590 Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
595 Safefree(PL_reentrant_buffer->_${genfunc}_buffer);
600 elsif ($func =~ /^(readdir|readdir64)$/) {
602 my $R = ifprotomatch($FUNC, grep {/R/} @p);
604 $seent{$func}* _${func}_struct;
605 size_t _${func}_size;
607 $seent{$func}* _${func}_ptr;
611 /* This is the size Solaris recommends.
612 * (though we go static, should use pathconf() instead) */
613 PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1;
616 PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size);
619 Safefree(PL_reentrant_buffer->_${func}_struct);
627 # if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
631 # Write out what we have learned.
634 my $v = join(", ", @v[0..$seenu{$func}-1]);
636 my ($r, $a) = split '_', $p;
637 my $test = $r eq 'I' ? ' == 0' : '';
640 if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
641 $genfunc = "${1}ent";
645 substr($b, 0, $seenu{$func}) = '';
647 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
648 } elsif ($b =~ /S/) {
649 if ($func =~ /^readdir/) {
650 $true = "PL_reentrant_buffer->_${genfunc}_struct";
652 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
654 } elsif ($b =~ /B/) {
655 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
661 "&PL_reentrant_buffer->_${genfunc}_ptr" :
663 "&PL_reentrant_buffer->_${genfunc}_errno" :
665 "PL_reentrant_buffer->_${genfunc}_buffer" :
667 "PL_reentrant_buffer->_${genfunc}_size" :
669 "&PL_reentrant_buffer->_${genfunc}_fptr" :
671 "&PL_reentrant_buffer->_${genfunc}_data" :
673 ($func =~ /^readdir\d*$/ ?
674 "PL_reentrant_buffer->_${genfunc}_struct" :
676 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
677 "&PL_reentrant_buffer->_${genfunc}_struct") :
680 $w = ", $w" if length $v;
683 my $call = "${func}_r($v$w)";
685 # Must make OpenBSD happy
688 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
689 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),';
692 # if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
694 if ($r eq 'V' || $r eq 'B') {
696 # define $func($v) $call
699 if ($func =~ /^get/) {
700 my $rv = $v ? ", $v" : "";
703 # define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : ((PL_reentrant_retint == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
707 # define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
712 # define $func($v) ($call$test ? $true : 0)
716 push @wrap, <<EOF; # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS
721 push @wrap, <<EOF; # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
725 push @wrap, $endif, "\n";
733 /* Defines for indicating which special features are supported. */
739 int dummy; /* cannot have empty structs */
746 /* Special case this; if others came along, could automate it */
747 # ifdef HAS_GETSPNAM_R
748 # define KEY_getspnam -1
751 #endif /* USE_REENTRANT_API */
756 read_only_bottom_close_and_rename($h);
758 # Prepare to write the reentr.c.
760 my $c = open_print_header('reentr.c', <<'EOQ');
764 * "Saruman," I said, standing away from him, "only one hand at a time can
765 * wield the One, and you know that well, so do not trouble to say we!"
767 * [p.260 of _The Lord of the Rings_, II/ii: "The Council of Elrond"]
771 * This file contains a collection of automatically created wrappers
772 * (created by running reentr.pl) for reentrant (thread-safe) versions of
773 * various library calls, such as getpwent_r. The wrapping is done so
774 * that other files like pp_sys.c calling those library functions need not
775 * care about the differences between various platforms' idiosyncrasies
776 * regarding these reentrant interfaces.
782 #define PERL_IN_REENTR_C
785 #include "keywords.h"
787 #define RenewDouble(data_pointer, size_pointer, type) \\
789 const size_t size = *(size_pointer) * 2; \\
790 Renew((data_pointer), (size), type); \\
791 *(size_pointer) = size; \\
795 Perl_reentrant_size(pTHX) {
798 /* Set the sizes of the reentrant buffers */
800 #ifdef USE_REENTRANT_API
801 # define REENTRANTSMALLSIZE 256 /* Make something up. */
802 # define REENTRANTUSUALSIZE 4096 /* Make something up. */
805 #endif /* USE_REENTRANT_API */
810 Perl_reentrant_init(pTHX) {
813 /* Initialize the whole thing */
815 #ifdef USE_REENTRANT_API
817 Newx(PL_reentrant_buffer, 1, REENTR);
818 Perl_reentrant_size(aTHX);
821 #endif /* USE_REENTRANT_API */
826 Perl_reentrant_free(pTHX) {
831 #ifdef USE_REENTRANT_API
834 Safefree(PL_reentrant_buffer);
836 #endif /* USE_REENTRANT_API */
840 Perl_reentrant_retry(const char *f, ...)
842 /* This function is set up to be called if the normal function returns
843 * failure with errno ERANGE, which indicates the buffer is too small.
844 * This function calls the failing one again with a larger buffer.
846 * What has happened is that, due to the magic of C preprocessor macro
847 * expansion, when the original code called function 'foo(args)', it was
848 * instead compiled into something like a call of 'foo_r(args, buffer)'
849 * Below we retry with 'foo', but the preprocessor has changed that into
850 * 'foo_r', so this function will end up calling itself recursively, each
851 * time with a larger buffer. If PERL_REENTRANT_MAXSIZE is defined, it
852 * won't increase beyond that, instead failing. */
859 #ifdef USE_REENTRANT_API
863 key = Perl_keyword (aTHX_ f, strlen(f), FALSE /* not feature enabled */);
865 /* Easier to special case this here than in embed.pl. (Look at what it
866 generates for proto.h) */
867 PERL_ARGS_ASSERT_REENTRANT_RETRY;
873 #ifdef HAS_GETSPNAM_R
875 /* This is a #define as has no corresponding keyword */
876 if (strEQ(f, "getspnam")) {
890 #ifdef USE_REENTRANT_API
891 # 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)
894 # if defined(USE_SERVENT_BUFFER)
897 # if defined(USE_HOSTENT_BUFFER)
900 # if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
906 # ifdef USE_HOSTENT_BUFFER
908 case KEY_gethostbyaddr:
909 case KEY_gethostbyname:
913 # ifdef PERL_REENTRANT_MAXSIZE
914 if (PL_reentrant_buffer->_hostent_size <=
915 PERL_REENTRANT_MAXSIZE / 2)
919 case KEY_gethostbyaddr:
920 p0 = va_arg(ap, void *);
921 asize = va_arg(ap, size_t);
922 anint = va_arg(ap, int);
923 retptr = gethostbyaddr((Netdb_host_t) p0, (Netdb_hlen_t) asize, anint); break;
924 case KEY_gethostbyname:
925 p0 = va_arg(ap, void *);
926 retptr = gethostbyname((Netdb_name_t) p0); break;
928 retptr = gethostent(); break;
930 SETERRNO(ERANGE, LIB_INVARG);
938 # ifdef USE_GRENT_BUFFER
945 # ifdef PERL_REENTRANT_MAXSIZE
946 if (PL_reentrant_buffer->_grent_size <=
947 PERL_REENTRANT_MAXSIZE / 2)
951 RenewDouble(PL_reentrant_buffer->_grent_buffer,
952 &PL_reentrant_buffer->_grent_size, char);
955 p0 = va_arg(ap, void *);
956 retptr = getgrnam((char *)p0); break;
958 # if Gid_t_size < INTSIZE
959 gid = (Gid_t)va_arg(ap, int);
961 gid = va_arg(ap, Gid_t);
963 retptr = getgrgid(gid); break;
965 retptr = getgrent(); break;
967 SETERRNO(ERANGE, LIB_INVARG);
975 # ifdef USE_NETENT_BUFFER
977 case KEY_getnetbyaddr:
978 case KEY_getnetbyname:
982 # ifdef PERL_REENTRANT_MAXSIZE
983 if (PL_reentrant_buffer->_netent_size <=
984 PERL_REENTRANT_MAXSIZE / 2)
988 RenewDouble(PL_reentrant_buffer->_netent_buffer,
989 &PL_reentrant_buffer->_netent_size, char);
991 case KEY_getnetbyaddr:
992 net = va_arg(ap, Netdb_net_t);
993 anint = va_arg(ap, int);
994 retptr = getnetbyaddr(net, anint); break;
995 case KEY_getnetbyname:
996 p0 = va_arg(ap, void *);
997 retptr = getnetbyname((char *)p0); break;
999 retptr = getnetent(); break;
1001 SETERRNO(ERANGE, LIB_INVARG);
1009 # ifdef USE_PWENT_BUFFER
1016 # ifdef PERL_REENTRANT_MAXSIZE
1017 if (PL_reentrant_buffer->_pwent_size <=
1018 PERL_REENTRANT_MAXSIZE / 2)
1023 RenewDouble(PL_reentrant_buffer->_pwent_buffer,
1024 &PL_reentrant_buffer->_pwent_size, char);
1027 p0 = va_arg(ap, void *);
1028 retptr = getpwnam((char *)p0); break;
1031 # if Uid_t_size < INTSIZE
1032 uid = (Uid_t)va_arg(ap, int);
1034 uid = va_arg(ap, Uid_t);
1036 retptr = getpwuid(uid); break;
1038 # if defined(HAS_GETPWENT) || defined(HAS_GETPWENT_R)
1041 retptr = getpwent(); break;
1044 SETERRNO(ERANGE, LIB_INVARG);
1052 # ifdef USE_SPENT_BUFFER
1058 # ifdef PERL_REENTRANT_MAXSIZE
1059 if (PL_reentrant_buffer->_spent_size <=
1060 PERL_REENTRANT_MAXSIZE / 2)
1063 RenewDouble(PL_reentrant_buffer->_spent_buffer,
1064 &PL_reentrant_buffer->_spent_size, char);
1067 name = va_arg(ap, char *);
1068 retptr = getspnam(name); break;
1070 SETERRNO(ERANGE, LIB_INVARG);
1077 # ifdef USE_PROTOENT_BUFFER
1079 case KEY_getprotobyname:
1080 case KEY_getprotobynumber:
1081 case KEY_getprotoent:
1084 # ifdef PERL_REENTRANT_MAXSIZE
1085 if (PL_reentrant_buffer->_protoent_size <=
1086 PERL_REENTRANT_MAXSIZE / 2)
1089 RenewDouble(PL_reentrant_buffer->_protoent_buffer,
1090 &PL_reentrant_buffer->_protoent_size, char);
1092 case KEY_getprotobyname:
1093 p0 = va_arg(ap, void *);
1094 retptr = getprotobyname((char *)p0); break;
1095 case KEY_getprotobynumber:
1096 anint = va_arg(ap, int);
1097 retptr = getprotobynumber(anint); break;
1098 case KEY_getprotoent:
1099 retptr = getprotoent(); break;
1101 SETERRNO(ERANGE, LIB_INVARG);
1109 # ifdef USE_SERVENT_BUFFER
1111 case KEY_getservbyname:
1112 case KEY_getservbyport:
1113 case KEY_getservent:
1116 # ifdef PERL_REENTRANT_MAXSIZE
1117 if (PL_reentrant_buffer->_servent_size <=
1118 PERL_REENTRANT_MAXSIZE / 2)
1121 RenewDouble(PL_reentrant_buffer->_servent_buffer,
1122 &PL_reentrant_buffer->_servent_size, char);
1124 case KEY_getservbyname:
1125 p0 = va_arg(ap, void *);
1126 p1 = va_arg(ap, void *);
1127 retptr = getservbyname((char *)p0, (char *)p1); break;
1128 case KEY_getservbyport:
1129 anint = va_arg(ap, int);
1130 p0 = va_arg(ap, void *);
1131 retptr = getservbyport(anint, (char *)p0); break;
1132 case KEY_getservent:
1133 retptr = getservent(); break;
1135 SETERRNO(ERANGE, LIB_INVARG);
1145 /* Not known how to retry, so just fail. */
1161 read_only_bottom_close_and_rename($c);
1163 # The meanings of the flags are derivable from %map above
1164 # Fnc, arg flags| hdr | ? struct type | prototypes...
1166 asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
1167 crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
1168 ctermid B |stdio | |B_B
1169 ctime S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
1170 endgrent |grp | |I_H|V_H
1171 endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1172 endnetent |netdb | |I_D|V_D|D=struct netent_data*
1173 endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
1174 endpwent |pwd | |I_H|V_H
1175 endservent |netdb | |I_D|V_D|D=struct servent_data*
1176 getgrent |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1177 getgrgid T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1178 getgrnam C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
1179 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
1180 gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1181 gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
1182 getlogin |unistd |char |I_BW|I_BI|B_BW|B_BI
1183 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
1184 getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1185 getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1186 getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1187 getprotobynumber I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1188 getprotoent |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1189 getpwent |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1190 getpwnam C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1191 getpwuid T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1192 getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1193 getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1194 getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1195 getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
1196 readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1197 readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1198 setgrent |grp | |I_H|V_H
1199 sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
1200 setlocale IC |locale | |I_ICBI
1201 setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
1202 setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
1203 setpwent |pwd | |I_H|V_H
1204 setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
1205 strerror I |string | |I_IBW|I_IBI|B_IBW
1206 tmpnam B |stdio | |B_B
1207 ttyname I |unistd | |I_IBW|I_IBI|B_IBI