This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix si_names context debugging names
[perl5.git] / regen / reentr.pl
CommitLineData
10bc17b6 1#!/usr/bin/perl -w
10bc17b6 2#
6294c161
DM
3# Regenerate (overwriting only if changed):
4#
5# reentr.h
6# reentr.c
7#
8# from information stored in the DATA section of this file.
9#
10# With the -U option, it also unconditionally regenerates the relevant
11# metaconfig units:
12#
13# d_${func}_r.U
14#
15# Also accepts the standard regen_lib -q and -v args.
16#
17# This script is normally invoked from regen.pl.
10bc17b6 18
e06c4d37
NC
19BEGIN {
20 # Get function prototypes
af001346 21 require 'regen/regen_lib.pl';
e06c4d37
NC
22}
23
10bc17b6
JH
24use strict;
25use Getopt::Std;
26my %opts;
b6b9a099 27getopts('Uv', \%opts);
10bc17b6
JH
28
29my %map = (
30 V => "void",
31 A => "char*", # as an input argument
32 B => "char*", # as an output argument
33 C => "const char*", # as a read-only input argument
34 I => "int",
35 L => "long",
36 W => "size_t",
37 H => "FILE**",
38 E => "int*",
39 );
40
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".)
44#
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".
48#
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)
52
d91994bb
NC
53sub 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],
60 quote => $quote });
61}
10bc17b6 62
d91994bb 63my $h = open_print_header('reentr.h');
2d6469fe 64print $h <<EOF;
10bc17b6 65#ifndef REENTR_H
37442d52 66#define REENTR_H
10bc17b6 67
832a833b
JH
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>.
73 */
74
75#ifndef PERL_REENTR_API
76# if defined(PERL_CORE) || defined(PERL_EXT)
77# define PERL_REENTR_API 1
78# else
79# define PERL_REENTR_API 0
80# endif
81#endif
82
10bc17b6
JH
83#ifdef USE_REENTRANT_API
84
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.
832a833b
JH
89 * If you know of more deprecations on some platforms, please add your own
90 * (by editing reentr.pl, mind!) */
10bc17b6
JH
91
92#ifdef __hpux
93# undef HAS_CRYPT_R
efa45b01
JH
94# undef HAS_ENDGRENT_R
95# undef HAS_ENDPWENT_R
10bc17b6
JH
96# undef HAS_GETGRENT_R
97# undef HAS_GETPWENT_R
98# undef HAS_SETLOCALE_R
10bc17b6
JH
99# undef HAS_STRERROR_R
100# define NETDB_R_OBSOLETE
101#endif
102
103#if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
104# undef HAS_CRYPT_R
105# undef HAS_STRERROR_R
106# define NETDB_R_OBSOLETE
107#endif
108
23e2b7a9
SP
109/*
110 * As of OpenBSD 3.7, reentrant functions are now working, they just are
111 * incompatible with everyone else. To make OpenBSD happy, we have to
112 * memzero out certain structures before calling the functions.
113 */
114#if defined(__OpenBSD__)
3fb2f3ac 115# define REENTR_MEMZERO(a,b) memzero(a,b)
23e2b7a9 116#else
3fb2f3ac 117# define REENTR_MEMZERO(a,b) 0
23e2b7a9
SP
118#endif
119
10bc17b6
JH
120#ifdef NETDB_R_OBSOLETE
121# undef HAS_ENDHOSTENT_R
122# undef HAS_ENDNETENT_R
123# undef HAS_ENDPROTOENT_R
124# undef HAS_ENDSERVENT_R
125# undef HAS_GETHOSTBYADDR_R
126# undef HAS_GETHOSTBYNAME_R
127# undef HAS_GETHOSTENT_R
128# undef HAS_GETNETBYADDR_R
129# undef HAS_GETNETBYNAME_R
130# undef HAS_GETNETENT_R
131# undef HAS_GETPROTOBYNAME_R
132# undef HAS_GETPROTOBYNUMBER_R
133# undef HAS_GETPROTOENT_R
134# undef HAS_GETSERVBYNAME_R
135# undef HAS_GETSERVBYPORT_R
136# undef HAS_GETSERVENT_R
137# undef HAS_SETHOSTENT_R
138# undef HAS_SETNETENT_R
139# undef HAS_SETPROTOENT_R
140# undef HAS_SETSERVENT_R
141#endif
142
143#ifdef I_PWD
144# include <pwd.h>
145#endif
146#ifdef I_GRP
147# include <grp.h>
148#endif
149#ifdef I_NETDB
150# include <netdb.h>
151#endif
10bc17b6
JH
152#ifdef I_CRYPT
153# ifdef I_CRYPT
154# include <crypt.h>
155# endif
156#endif
157#ifdef HAS_GETSPNAM_R
158# ifdef I_SHADOW
159# include <shadow.h>
160# endif
161#endif
162
163EOF
164
aa418cf1
JH
165my %seenh; # the different prototypes signatures for this function
166my %seena; # the different prototypes signatures for this function in order
167my @seenf; # all the seen functions
168my %seenp; # the different prototype signatures for all functions
169my %seent; # the return type of this function
170my %seens; # the type of this function's "S"
171my %seend; # the type of this function's "D"
a845a0d4 172my %seenm; # all the types
aa418cf1
JH
173my %seenu; # the length of the argument list of this function
174
b6a6e956 175while (<DATA>) { # Read in the protoypes.
10bc17b6
JH
176 next if /^\s+$/;
177 chomp;
aa418cf1 178 my ($func, $hdr, $type, @p) = split(/\s*\|\s*/, $_, -1);
10bc17b6 179 my $u;
aa418cf1
JH
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.
184 push @seenf, $func;
10bc17b6 185 my %m = %map;
aa418cf1
JH
186 if ($type) {
187 $m{S} = "$type*";
188 $m{R} = "$type**";
10bc17b6 189 }
aa418cf1
JH
190
191 # Set any special mapping variables (like X=x_t)
10bc17b6
JH
192 if (@p) {
193 while ($p[-1] =~ /=/) {
194 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
195 $m{$k} = $v;
196 pop @p;
197 }
198 }
aa418cf1
JH
199
200 # If given the -U option open up the metaconfig unit for this function.
201 if ($opts{U} && open(U, ">d_${func}_r.U")) {
0eb6355a 202 binmode U;
10bc17b6 203 }
aa418cf1 204
d63eadf0 205 if ($opts{U}) {
aa418cf1
JH
206 # The metaconfig units needs prerequisite dependencies.
207 my $prereqs = '';
208 my $prereqh = '';
209 my $prereqsh = '';
210 if ($hdr ne 'stdio') { # There's no i_stdio.
211 $prereqs = "i_$hdr";
212 $prereqh = "$hdr.h";
213 $prereqsh = "\$$prereqs $prereqh";
214 }
1fdb6f84
JH
215 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
216 push @prereq, $prereqs;
217 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
aa418cf1 218 if ($hdr eq 'time') {
1fdb6f84
JH
219 $hdrs .= " \$i_systime sys/time.h";
220 push @prereq, 'i_systime';
221 }
aa418cf1 222 # Output the metaconfig unit header.
2d6469fe 223 print U <<"EOF";
aa418cf1 224?RCS: \$Id: d_${func}_r.U,v $
10bc17b6 225?RCS:
a845a0d4 226?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
10bc17b6
JH
227?RCS:
228?RCS: You may distribute under the terms of either the GNU General Public
229?RCS: License or the Artistic License, as specified in the README file.
230?RCS:
231?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
232?RCS:
aa418cf1 233?MAKE:d_${func}_r ${func}_r_proto: @prereq
10bc17b6 234?MAKE: -pick add \$@ %<
aa418cf1
JH
235?S:d_${func}_r:
236?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
237?S: which indicates to the C program that the ${func}_r()
10bc17b6
JH
238?S: routine is available.
239?S:.
aa418cf1
JH
240?S:${func}_r_proto:
241?S: This variable encodes the prototype of ${func}_r.
39183afa
JH
242?S: It is zero if d_${func}_r is undef, and one of the
243?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
244?S: is defined.
10bc17b6 245?S:.
aa418cf1
JH
246?C:HAS_${FUNC}_R:
247?C: This symbol, if defined, indicates that the ${func}_r routine
248?C: is available to ${func} re-entrantly.
10bc17b6 249?C:.
aa418cf1
JH
250?C:${FUNC}_R_PROTO:
251?C: This symbol encodes the prototype of ${func}_r.
39183afa
JH
252?C: It is zero if d_${func}_r is undef, and one of the
253?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
254?C: is defined.
10bc17b6 255?C:.
aa418cf1
JH
256?H:#\$d_${func}_r HAS_${FUNC}_R /**/
257?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
10bc17b6 258?H:.
aa418cf1
JH
259?T:try hdrs d_${func}_r_proto
260?LINT:set d_${func}_r
261?LINT:set ${func}_r_proto
262: see if ${func}_r exists
263set ${func}_r d_${func}_r
10bc17b6 264eval \$inlibc
aa418cf1 265case "\$d_${func}_r" in
10bc17b6 266"\$define")
d63eadf0 267EOF
2d6469fe 268 print U <<"EOF";
d63eadf0 269 hdrs="$hdrs"
aa418cf1
JH
270 case "\$d_${func}_r_proto:\$usethreads" in
271 ":define") d_${func}_r_proto=define
272 set d_${func}_r_proto ${func}_r \$hdrs
a48ec845
JH
273 eval \$hasproto ;;
274 *) ;;
275 esac
aa418cf1 276 case "\$d_${func}_r_proto" in
a48ec845 277 define)
10bc17b6 278EOF
d63eadf0
JH
279 }
280 for my $p (@p) {
281 my ($r, $a) = ($p =~ /^(.)_(.+)/);
282 my $v = join(", ", map { $m{$_} } split '', $a);
283 if ($opts{U}) {
2d6469fe 284 print U <<"EOF";
aa418cf1
JH
285 case "\$${func}_r_proto" in
286 ''|0) try='$m{$r} ${func}_r($v);'
287 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
10bc17b6
JH
288 esac
289EOF
d63eadf0 290 }
aa418cf1
JH
291 $seenh{$func}->{$p}++;
292 push @{$seena{$func}}, $p;
d63eadf0 293 $seenp{$p}++;
aa418cf1
JH
294 $seent{$func} = $type;
295 $seens{$func} = $m{S};
296 $seend{$func} = $m{D};
a845a0d4 297 $seenm{$func} = \%m;
d63eadf0
JH
298 }
299 if ($opts{U}) {
2d6469fe 300 print U <<"EOF";
aa418cf1
JH
301 case "\$${func}_r_proto" in
302 ''|0) d_${func}_r=undef
303 ${func}_r_proto=0
304 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
305 * ) case "\$${func}_r_proto" in
10bc17b6 306 REENTRANT_PROTO*) ;;
aa418cf1 307 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
10bc17b6
JH
308 esac
309 echo "Prototype: \$try" ;;
310 esac
311 ;;
c18e646a 312 *) case "\$usethreads" in
aa418cf1 313 define) echo "${func}_r has no prototype, not using it." >&4 ;;
c18e646a 314 esac
aa418cf1
JH
315 d_${func}_r=undef
316 ${func}_r_proto=0
c18e646a 317 ;;
a48ec845
JH
318 esac
319 ;;
aa418cf1 320*) ${func}_r_proto=0
10bc17b6
JH
321 ;;
322esac
323
324EOF
325 close(U);
326 }
327}
328
329close DATA;
330
10bc17b6 331{
aa418cf1 332 # Write out all the known prototype signatures.
10bc17b6
JH
333 my $i = 1;
334 for my $p (sort keys %seenp) {
2d6469fe 335 print $h "#define REENTRANT_PROTO_${p} ${i}\n";
10bc17b6
JH
336 $i++;
337 }
338}
339
aa418cf1
JH
340my @struct; # REENTR struct members
341my @size; # struct member buffer size initialization code
342my @init; # struct member buffer initialization (malloc) code
343my @free; # struct member buffer release (free) code
344my @wrap; # the wrapper (foo(a) -> foo_r(a,...)) cpp code
345my @define; # defines for optional features
346
10bc17b6 347sub ifprotomatch {
aa418cf1
JH
348 my $FUNC = shift;
349 join " || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @_;
10bc17b6
JH
350}
351
10bc17b6
JH
352sub pushssif {
353 push @struct, @_;
354 push @size, @_;
355 push @init, @_;
356 push @free, @_;
357}
358
359sub pushinitfree {
aa418cf1 360 my $func = shift;
10bc17b6 361 push @init, <<EOF;
a02a5408 362 Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
10bc17b6
JH
363EOF
364 push @free, <<EOF;
aa418cf1 365 Safefree(PL_reentrant_buffer->_${func}_buffer);
10bc17b6
JH
366EOF
367}
368
369sub define {
370 my ($n, $p, @F) = @_;
371 my @H;
372 my $H = uc $F[0];
373 push @define, <<EOF;
374/* The @F using \L$n? */
375
376EOF
aa418cf1
JH
377 my $GENFUNC;
378 for my $func (@F) {
379 my $FUNC = uc $func;
380 my $HAS = "${FUNC}_R_HAS_$n";
381 push @H, $HAS;
382 my @h = grep { /$p/ } @{$seena{$func}};
383 unless (defined $GENFUNC) {
384 $GENFUNC = $FUNC;
385 $GENFUNC =~ s/^GET//;
f7937171 386 }
10bc17b6 387 if (@h) {
aa418cf1 388 push @define, "#if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
10bc17b6
JH
389
390 push @define, <<EOF;
aa418cf1 391# define $HAS
10bc17b6 392#else
aa418cf1 393# undef $HAS
10bc17b6
JH
394#endif
395EOF
396 }
397 }
0891a229 398 return if @F == 1;
10bc17b6
JH
399 push @define, <<EOF;
400
401/* Any of the @F using \L$n? */
402
403EOF
404 push @define, "#if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
405 push @define, <<EOF;
aa418cf1 406# define USE_${GENFUNC}_$n
10bc17b6 407#else
aa418cf1 408# undef USE_${GENFUNC}_$n
10bc17b6
JH
409#endif
410
411EOF
412}
413
edd309b7
JH
414define('BUFFER', 'B',
415 qw(getgrent getgrgid getgrnam));
416
10bc17b6
JH
417define('PTR', 'R',
418 qw(getgrent getgrgid getgrnam));
419define('PTR', 'R',
420 qw(getpwent getpwnam getpwuid));
421define('PTR', 'R',
422 qw(getspent getspnam));
423
424define('FPTR', 'H',
f7937171 425 qw(getgrent getgrgid getgrnam setgrent endgrent));
10bc17b6 426define('FPTR', 'H',
f7937171 427 qw(getpwent getpwnam getpwuid setpwent endpwent));
10bc17b6 428
edd309b7
JH
429define('BUFFER', 'B',
430 qw(getpwent getpwgid getpwnam));
431
10bc17b6
JH
432define('PTR', 'R',
433 qw(gethostent gethostbyaddr gethostbyname));
434define('PTR', 'R',
435 qw(getnetent getnetbyaddr getnetbyname));
436define('PTR', 'R',
437 qw(getprotoent getprotobyname getprotobynumber));
438define('PTR', 'R',
439 qw(getservent getservbyname getservbyport));
440
edd309b7
JH
441define('BUFFER', 'B',
442 qw(gethostent gethostbyaddr gethostbyname));
443define('BUFFER', 'B',
444 qw(getnetent getnetbyaddr getnetbyname));
445define('BUFFER', 'B',
446 qw(getprotoent getprotobyname getprotobynumber));
447define('BUFFER', 'B',
448 qw(getservent getservbyname getservbyport));
449
10bc17b6
JH
450define('ERRNO', 'E',
451 qw(gethostent gethostbyaddr gethostbyname));
452define('ERRNO', 'E',
453 qw(getnetent getnetbyaddr getnetbyname));
454
aa418cf1
JH
455# The following loop accumulates the "ssif" (struct, size, init, free)
456# sections that declare the struct members (in reentr.h), and the buffer
457# size initialization, buffer initialization (malloc), and buffer
458# release (free) code (in reentr.c).
459#
460# The loop also contains a lot of intrinsic logic about groups of
461# functions (since functions of certain kind operate the same way).
462
463for my $func (@seenf) {
464 my $FUNC = uc $func;
465 my $ifdef = "#ifdef HAS_${FUNC}_R\n";
466 my $endif = "#endif /* HAS_${FUNC}_R */\n";
467 if (exists $seena{$func}) {
468 my @p = @{$seena{$func}};
469 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
10bc17b6
JH
470 pushssif $ifdef;
471 push @struct, <<EOF;
aa418cf1
JH
472 char* _${func}_buffer;
473 size_t _${func}_size;
10bc17b6
JH
474EOF
475 push @size, <<EOF;
aa418cf1 476 PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
10bc17b6 477EOF
aa418cf1 478 pushinitfree $func;
10bc17b6
JH
479 pushssif $endif;
480 }
aa418cf1 481 elsif ($func =~ /^(crypt)$/) {
10bc17b6
JH
482 pushssif $ifdef;
483 push @struct, <<EOF;
b430fd04 484#if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
aa418cf1 485 $seend{$func} _${func}_data;
b430fd04 486#else
05404ffe 487 $seent{$func} *_${func}_struct_buffer;
b430fd04 488#endif
10bc17b6 489EOF
b430fd04 490 push @init, <<EOF;
05404ffe
JH
491#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
492 PL_reentrant_buffer->_${func}_struct_buffer = 0;
493#endif
494EOF
495 push @free, <<EOF;
496#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
497 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
10bc17b6
JH
498#endif
499EOF
b430fd04
JH
500 pushssif $endif;
501 }
aa418cf1 502 elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) {
10bc17b6 503 pushssif $ifdef;
aa418cf1
JH
504 # 'genfunc' can be read either as 'generic' or 'genre',
505 # it represents a group of functions.
506 my $genfunc = $func;
507 $genfunc =~ s/nam/ent/g;
508 $genfunc =~ s/^get//;
509 my $GENFUNC = uc $genfunc;
10bc17b6 510 push @struct, <<EOF;
aa418cf1
JH
511 $seent{$func} _${genfunc}_struct;
512 char* _${genfunc}_buffer;
513 size_t _${genfunc}_size;
10bc17b6
JH
514EOF
515 push @struct, <<EOF;
aa418cf1
JH
516# ifdef USE_${GENFUNC}_PTR
517 $seent{$func}* _${genfunc}_ptr;
10bc17b6
JH
518# endif
519EOF
0de8cad8 520 push @struct, <<EOF;
aa418cf1
JH
521# ifdef USE_${GENFUNC}_FPTR
522 FILE* _${genfunc}_fptr;
10bc17b6
JH
523# endif
524EOF
0de8cad8 525 push @init, <<EOF;
aa418cf1
JH
526# ifdef USE_${GENFUNC}_FPTR
527 PL_reentrant_buffer->_${genfunc}_fptr = NULL;
10bc17b6
JH
528# endif
529EOF
0de8cad8 530 my $sc = $genfunc eq 'grent' ?
10bc17b6 531 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
0de8cad8
RGS
532 my $sz = "_${genfunc}_size";
533 push @size, <<EOF;
10bc17b6 534# if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
0de8cad8 535 PL_reentrant_buffer->$sz = sysconf($sc);
832a833b 536 if (PL_reentrant_buffer->$sz == (size_t) -1)
e3410746 537 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
10bc17b6
JH
538# else
539# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
0de8cad8 540 PL_reentrant_buffer->$sz = SIABUFSIZ;
10bc17b6
JH
541# else
542# ifdef __sgi
0de8cad8 543 PL_reentrant_buffer->$sz = BUFSIZ;
10bc17b6 544# else
0de8cad8 545 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
10bc17b6
JH
546# endif
547# endif
548# endif
549EOF
aa418cf1 550 pushinitfree $genfunc;
10bc17b6
JH
551 pushssif $endif;
552 }
aa418cf1 553 elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
10bc17b6 554 pushssif $ifdef;
aa418cf1
JH
555 my $genfunc = $func;
556 $genfunc =~ s/byname/ent/;
557 $genfunc =~ s/^get//;
558 my $GENFUNC = uc $genfunc;
559 my $D = ifprotomatch($FUNC, grep {/D/} @p);
560 my $d = $seend{$func};
b6a6e956 561 $d =~ s/\*$//; # snip: we need the base type.
10bc17b6 562 push @struct, <<EOF;
aa418cf1 563 $seent{$func} _${genfunc}_struct;
10bc17b6 564# if $D
aa418cf1 565 $d _${genfunc}_data;
10bc17b6 566# else
aa418cf1
JH
567 char* _${genfunc}_buffer;
568 size_t _${genfunc}_size;
10bc17b6 569# endif
aa418cf1
JH
570# ifdef USE_${GENFUNC}_PTR
571 $seent{$func}* _${genfunc}_ptr;
10bc17b6
JH
572# endif
573EOF
574 push @struct, <<EOF;
aa418cf1
JH
575# ifdef USE_${GENFUNC}_ERRNO
576 int _${genfunc}_errno;
10bc17b6
JH
577# endif
578EOF
579 push @size, <<EOF;
580#if !($D)
aa418cf1 581 PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE;
10bc17b6
JH
582#endif
583EOF
584 push @init, <<EOF;
585#if !($D)
a02a5408 586 Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
10bc17b6
JH
587#endif
588EOF
589 push @free, <<EOF;
590#if !($D)
aa418cf1 591 Safefree(PL_reentrant_buffer->_${genfunc}_buffer);
10bc17b6
JH
592#endif
593EOF
594 pushssif $endif;
595 }
aa418cf1 596 elsif ($func =~ /^(readdir|readdir64)$/) {
10bc17b6 597 pushssif $ifdef;
aa418cf1 598 my $R = ifprotomatch($FUNC, grep {/R/} @p);
10bc17b6 599 push @struct, <<EOF;
aa418cf1
JH
600 $seent{$func}* _${func}_struct;
601 size_t _${func}_size;
10bc17b6 602# if $R
aa418cf1 603 $seent{$func}* _${func}_ptr;
10bc17b6
JH
604# endif
605EOF
606 push @size, <<EOF;
607 /* This is the size Solaris recommends.
608 * (though we go static, should use pathconf() instead) */
aa418cf1 609 PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1;
10bc17b6
JH
610EOF
611 push @init, <<EOF;
aa418cf1 612 PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size);
10bc17b6
JH
613EOF
614 push @free, <<EOF;
aa418cf1 615 Safefree(PL_reentrant_buffer->_${func}_struct);
10bc17b6
JH
616EOF
617 pushssif $endif;
618 }
619
620 push @wrap, $ifdef;
621
10bc17b6 622 push @wrap, <<EOF;
d896b068 623# if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
aa418cf1 624# undef $func
10bc17b6 625EOF
aa418cf1
JH
626
627 # Write out what we have learned.
628
10bc17b6 629 my @v = 'a'..'z';
aa418cf1 630 my $v = join(", ", @v[0..$seenu{$func}-1]);
10bc17b6
JH
631 for my $p (@p) {
632 my ($r, $a) = split '_', $p;
633 my $test = $r eq 'I' ? ' == 0' : '';
634 my $true = 1;
aa418cf1
JH
635 my $genfunc = $func;
636 if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
637 $genfunc = "${1}ent";
10bc17b6
JH
638 }
639 my $b = $a;
640 my $w = '';
aa418cf1 641 substr($b, 0, $seenu{$func}) = '';
a7f3e46a 642 if ($b =~ /R/) {
aa418cf1 643 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
10bc17b6 644 } elsif ($b =~ /S/) {
aa418cf1
JH
645 if ($func =~ /^readdir/) {
646 $true = "PL_reentrant_buffer->_${genfunc}_struct";
10bc17b6 647 } else {
aa418cf1 648 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
10bc17b6
JH
649 }
650 } elsif ($b =~ /B/) {
aa418cf1 651 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
10bc17b6
JH
652 }
653 if (length $b) {
654 $w = join ", ",
655 map {
656 $_ eq 'R' ?
aa418cf1 657 "&PL_reentrant_buffer->_${genfunc}_ptr" :
10bc17b6 658 $_ eq 'E' ?
aa418cf1 659 "&PL_reentrant_buffer->_${genfunc}_errno" :
10bc17b6 660 $_ eq 'B' ?
aa418cf1 661 "PL_reentrant_buffer->_${genfunc}_buffer" :
10bc17b6 662 $_ =~ /^[WI]$/ ?
aa418cf1 663 "PL_reentrant_buffer->_${genfunc}_size" :
10bc17b6 664 $_ eq 'H' ?
aa418cf1 665 "&PL_reentrant_buffer->_${genfunc}_fptr" :
10bc17b6 666 $_ eq 'D' ?
aa418cf1 667 "&PL_reentrant_buffer->_${genfunc}_data" :
10bc17b6 668 $_ eq 'S' ?
05404ffe 669 ($func =~ /^readdir\d*$/ ?
aa418cf1 670 "PL_reentrant_buffer->_${genfunc}_struct" :
05404ffe
JH
671 $func =~ /^crypt$/ ?
672 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
673 "&PL_reentrant_buffer->_${genfunc}_struct") :
10bc17b6
JH
674 $_
675 } split '', $b;
676 $w = ", $w" if length $v;
677 }
832a833b 678
aa418cf1 679 my $call = "${func}_r($v$w)";
23e2b7a9
SP
680
681 # Must make OpenBSD happy
682 my $memzero = '';
683 if($p =~ /D$/ &&
684 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
3fb2f3ac 685 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),';
23e2b7a9 686 }
10bc17b6 687 push @wrap, <<EOF;
aa418cf1 688# if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
10bc17b6
JH
689EOF
690 if ($r eq 'V' || $r eq 'B') {
691 push @wrap, <<EOF;
aa418cf1 692# define $func($v) $call
10bc17b6
JH
693EOF
694 } else {
aa418cf1 695 if ($func =~ /^get/) {
edd309b7 696 my $rv = $v ? ", $v" : "";
0891a229
JH
697 if ($r eq 'I') {
698 push @wrap, <<EOF;
b8dcbfa5 699# define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : ((PL_reentrant_retint == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
0891a229
JH
700EOF
701 } else {
702 push @wrap, <<EOF;
f6f0b69b 703# define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
10bc17b6 704EOF
0891a229 705 }
edd309b7
JH
706 } else {
707 push @wrap, <<EOF;
aa418cf1 708# define $func($v) ($call$test ? $true : 0)
edd309b7
JH
709EOF
710 }
10bc17b6 711 }
d4222de0
RGS
712 push @wrap, <<EOF; # !defined(xxx) && XXX_R_PROTO == REENTRANT_PROTO_Y_TS
713# endif
10bc17b6
JH
714EOF
715 }
716
d4222de0
RGS
717 push @wrap, <<EOF; # defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
718# endif
832a833b
JH
719EOF
720
10bc17b6
JH
721 push @wrap, $endif, "\n";
722 }
723}
724
725local $" = '';
726
2d6469fe 727print $h <<EOF;
10bc17b6
JH
728
729/* Defines for indicating which special features are supported. */
730
731@define
732typedef struct {
733@struct
aa418cf1 734 int dummy; /* cannot have empty structs */
10bc17b6
JH
735} REENTR;
736
737/* The wrappers. */
738
739@wrap
0891a229 740
10bc17b6
JH
741#endif /* USE_REENTRANT_API */
742
743#endif
10bc17b6
JH
744EOF
745
ce716c52 746read_only_bottom_close_and_rename($h);
10bc17b6 747
aa418cf1
JH
748# Prepare to write the reentr.c.
749
d91994bb 750my $c = open_print_header('reentr.c', <<'EOQ');
56fd1190 751 *
10bc17b6 752 * "Saruman," I said, standing away from him, "only one hand at a time can
56fd1190 753 * wield the One, and you know that well, so do not trouble to say we!"
10bc17b6 754 *
61296642
DM
755 * This file contains a collection of automatically created wrappers
756 * (created by running reentr.pl) for reentrant (thread-safe) versions of
757 * various library calls, such as getpwent_r. The wrapping is done so
758 * that other files like pp_sys.c calling those library functions need not
759 * care about the differences between various platforms' idiosyncrasies
760 * regarding these reentrant interfaces.
10bc17b6 761 */
56fd1190 762EOQ
10bc17b6 763
56fd1190 764print $c <<"EOF";
10bc17b6
JH
765#include "EXTERN.h"
766#define PERL_IN_REENTR_C
767#include "perl.h"
768#include "reentr.h"
769
770void
771Perl_reentrant_size(pTHX) {
23491f1d 772 PERL_UNUSED_CONTEXT;
10bc17b6 773#ifdef USE_REENTRANT_API
8695fa85
SR
774#define REENTRANTSMALLSIZE 256 /* Make something up. */
775#define REENTRANTUSUALSIZE 4096 /* Make something up. */
10bc17b6
JH
776@size
777#endif /* USE_REENTRANT_API */
778}
779
780void
781Perl_reentrant_init(pTHX) {
23491f1d 782 PERL_UNUSED_CONTEXT;
10bc17b6 783#ifdef USE_REENTRANT_API
a02a5408 784 Newx(PL_reentrant_buffer, 1, REENTR);
10bc17b6
JH
785 Perl_reentrant_size(aTHX);
786@init
787#endif /* USE_REENTRANT_API */
788}
789
790void
791Perl_reentrant_free(pTHX) {
23491f1d 792 PERL_UNUSED_CONTEXT;
10bc17b6
JH
793#ifdef USE_REENTRANT_API
794@free
795 Safefree(PL_reentrant_buffer);
796#endif /* USE_REENTRANT_API */
797}
798
edd309b7
JH
799void*
800Perl_reentrant_retry(const char *f, ...)
801{
edd309b7 802 void *retptr = NULL;
fe5bfecd 803 va_list ap;
7918f24d 804#ifdef USE_REENTRANT_API
dbf7dff6 805 dTHX;
7918f24d
NC
806 /* Easier to special case this here than in embed.pl. (Look at what it
807 generates for proto.h) */
808 PERL_ARGS_ASSERT_REENTRANT_RETRY;
809#endif
fe5bfecd 810 va_start(ap, f);
369ec4b2 811 {
edd309b7 812#ifdef USE_REENTRANT_API
0891a229 813# 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)
e3410746
SR
814 void *p0;
815# endif
f7937171 816# if defined(USE_SERVENT_BUFFER)
e3410746
SR
817 void *p1;
818# endif
f7937171 819# if defined(USE_HOSTENT_BUFFER)
edd309b7 820 size_t asize;
e3410746 821# endif
f7937171 822# if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
edd309b7 823 int anint;
e3410746 824# endif
edd309b7 825
edd309b7 826 switch (PL_op->op_type) {
f7937171 827#ifdef USE_HOSTENT_BUFFER
edd309b7
JH
828 case OP_GHBYADDR:
829 case OP_GHBYNAME:
830 case OP_GHOSTENT:
831 {
af685957
JH
832#ifdef PERL_REENTRANT_MAXSIZE
833 if (PL_reentrant_buffer->_hostent_size <=
834 PERL_REENTRANT_MAXSIZE / 2)
835#endif
836 {
f7937171
JH
837 PL_reentrant_buffer->_hostent_size *= 2;
838 Renew(PL_reentrant_buffer->_hostent_buffer,
839 PL_reentrant_buffer->_hostent_size, char);
edd309b7
JH
840 switch (PL_op->op_type) {
841 case OP_GHBYADDR:
842 p0 = va_arg(ap, void *);
843 asize = va_arg(ap, size_t);
844 anint = va_arg(ap, int);
845 retptr = gethostbyaddr(p0, asize, anint); break;
846 case OP_GHBYNAME:
847 p0 = va_arg(ap, void *);
f6f0b69b 848 retptr = gethostbyname((char *)p0); break;
edd309b7
JH
849 case OP_GHOSTENT:
850 retptr = gethostent(); break;
851 default:
0de8cad8 852 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
853 break;
854 }
855 }
856 }
857 break;
858#endif
f7937171 859#ifdef USE_GRENT_BUFFER
edd309b7
JH
860 case OP_GGRNAM:
861 case OP_GGRGID:
862 case OP_GGRENT:
863 {
af685957
JH
864#ifdef PERL_REENTRANT_MAXSIZE
865 if (PL_reentrant_buffer->_grent_size <=
866 PERL_REENTRANT_MAXSIZE / 2)
867#endif
868 {
edd309b7 869 Gid_t gid;
f7937171
JH
870 PL_reentrant_buffer->_grent_size *= 2;
871 Renew(PL_reentrant_buffer->_grent_buffer,
872 PL_reentrant_buffer->_grent_size, char);
edd309b7
JH
873 switch (PL_op->op_type) {
874 case OP_GGRNAM:
875 p0 = va_arg(ap, void *);
f6f0b69b 876 retptr = getgrnam((char *)p0); break;
edd309b7 877 case OP_GGRGID:
ab2b559b
JH
878#if Gid_t_size < INTSIZE
879 gid = (Gid_t)va_arg(ap, int);
880#else
edd309b7 881 gid = va_arg(ap, Gid_t);
ab2b559b 882#endif
edd309b7
JH
883 retptr = getgrgid(gid); break;
884 case OP_GGRENT:
885 retptr = getgrent(); break;
886 default:
0de8cad8 887 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
888 break;
889 }
890 }
891 }
892 break;
893#endif
f7937171 894#ifdef USE_NETENT_BUFFER
edd309b7
JH
895 case OP_GNBYADDR:
896 case OP_GNBYNAME:
897 case OP_GNETENT:
898 {
af685957
JH
899#ifdef PERL_REENTRANT_MAXSIZE
900 if (PL_reentrant_buffer->_netent_size <=
901 PERL_REENTRANT_MAXSIZE / 2)
902#endif
903 {
edd309b7 904 Netdb_net_t net;
f7937171
JH
905 PL_reentrant_buffer->_netent_size *= 2;
906 Renew(PL_reentrant_buffer->_netent_buffer,
907 PL_reentrant_buffer->_netent_size, char);
edd309b7
JH
908 switch (PL_op->op_type) {
909 case OP_GNBYADDR:
910 net = va_arg(ap, Netdb_net_t);
911 anint = va_arg(ap, int);
912 retptr = getnetbyaddr(net, anint); break;
913 case OP_GNBYNAME:
914 p0 = va_arg(ap, void *);
f6f0b69b 915 retptr = getnetbyname((char *)p0); break;
edd309b7
JH
916 case OP_GNETENT:
917 retptr = getnetent(); break;
918 default:
0de8cad8 919 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
920 break;
921 }
922 }
923 }
924 break;
925#endif
f7937171 926#ifdef USE_PWENT_BUFFER
edd309b7
JH
927 case OP_GPWNAM:
928 case OP_GPWUID:
929 case OP_GPWENT:
930 {
af685957
JH
931#ifdef PERL_REENTRANT_MAXSIZE
932 if (PL_reentrant_buffer->_pwent_size <=
933 PERL_REENTRANT_MAXSIZE / 2)
934#endif
935 {
edd309b7 936 Uid_t uid;
f7937171
JH
937 PL_reentrant_buffer->_pwent_size *= 2;
938 Renew(PL_reentrant_buffer->_pwent_buffer,
939 PL_reentrant_buffer->_pwent_size, char);
edd309b7
JH
940 switch (PL_op->op_type) {
941 case OP_GPWNAM:
942 p0 = va_arg(ap, void *);
f6f0b69b 943 retptr = getpwnam((char *)p0); break;
edd309b7 944 case OP_GPWUID:
ab2b559b
JH
945#if Uid_t_size < INTSIZE
946 uid = (Uid_t)va_arg(ap, int);
947#else
edd309b7 948 uid = va_arg(ap, Uid_t);
ab2b559b 949#endif
edd309b7 950 retptr = getpwuid(uid); break;
123829cf 951#if defined(HAS_GETPWENT) || defined(HAS_GETPWENT_R)
edd309b7
JH
952 case OP_GPWENT:
953 retptr = getpwent(); break;
123829cf 954#endif
edd309b7 955 default:
0de8cad8 956 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
957 break;
958 }
959 }
960 }
961 break;
962#endif
f7937171 963#ifdef USE_PROTOENT_BUFFER
edd309b7
JH
964 case OP_GPBYNAME:
965 case OP_GPBYNUMBER:
966 case OP_GPROTOENT:
967 {
af685957
JH
968#ifdef PERL_REENTRANT_MAXSIZE
969 if (PL_reentrant_buffer->_protoent_size <=
970 PERL_REENTRANT_MAXSIZE / 2)
971#endif
972 {
f7937171
JH
973 PL_reentrant_buffer->_protoent_size *= 2;
974 Renew(PL_reentrant_buffer->_protoent_buffer,
975 PL_reentrant_buffer->_protoent_size, char);
edd309b7
JH
976 switch (PL_op->op_type) {
977 case OP_GPBYNAME:
978 p0 = va_arg(ap, void *);
f6f0b69b 979 retptr = getprotobyname((char *)p0); break;
edd309b7
JH
980 case OP_GPBYNUMBER:
981 anint = va_arg(ap, int);
982 retptr = getprotobynumber(anint); break;
983 case OP_GPROTOENT:
984 retptr = getprotoent(); break;
985 default:
0de8cad8 986 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
987 break;
988 }
989 }
990 }
991 break;
992#endif
f7937171 993#ifdef USE_SERVENT_BUFFER
edd309b7
JH
994 case OP_GSBYNAME:
995 case OP_GSBYPORT:
996 case OP_GSERVENT:
997 {
af685957
JH
998#ifdef PERL_REENTRANT_MAXSIZE
999 if (PL_reentrant_buffer->_servent_size <=
1000 PERL_REENTRANT_MAXSIZE / 2)
1001#endif
1002 {
f7937171
JH
1003 PL_reentrant_buffer->_servent_size *= 2;
1004 Renew(PL_reentrant_buffer->_servent_buffer,
1005 PL_reentrant_buffer->_servent_size, char);
edd309b7
JH
1006 switch (PL_op->op_type) {
1007 case OP_GSBYNAME:
1008 p0 = va_arg(ap, void *);
1009 p1 = va_arg(ap, void *);
f6f0b69b 1010 retptr = getservbyname((char *)p0, (char *)p1); break;
edd309b7
JH
1011 case OP_GSBYPORT:
1012 anint = va_arg(ap, int);
1013 p0 = va_arg(ap, void *);
f6f0b69b 1014 retptr = getservbyport(anint, (char *)p0); break;
edd309b7
JH
1015 case OP_GSERVENT:
1016 retptr = getservent(); break;
1017 default:
0de8cad8 1018 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1019 break;
1020 }
1021 }
1022 }
1023 break;
1024#endif
1025 default:
1026 /* Not known how to retry, so just fail. */
1027 break;
1028 }
6148ee25
SP
1029#else
1030 PERL_UNUSED_ARG(f);
edd309b7 1031#endif
369ec4b2 1032 }
fe5bfecd 1033 va_end(ap);
edd309b7
JH
1034 return retptr;
1035}
10bc17b6
JH
1036EOF
1037
ce716c52 1038read_only_bottom_close_and_rename($c);
b6b9a099 1039
10bc17b6
JH
1040__DATA__
1041asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
b430fd04 1042crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
10bc17b6
JH
1043ctermid B |stdio | |B_B
1044ctime S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
10bc17b6 1045endgrent |grp | |I_H|V_H
31ee0cb7
JH
1046endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1047endnetent |netdb | |I_D|V_D|D=struct netent_data*
1048endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
10bc17b6 1049endpwent |pwd | |I_H|V_H
31ee0cb7 1050endservent |netdb | |I_D|V_D|D=struct servent_data*
10bc17b6
JH
1051getgrent |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1052getgrgid T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1053getgrnam C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
a845a0d4 1054gethostbyaddr 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
10bc17b6
JH
1055gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1056gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
f6f0b69b 1057getlogin |unistd |char |I_BW|I_BI|B_BW|B_BI
a845a0d4 1058getnetbyaddr 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
10bc17b6
JH
1059getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1060getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1061getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1062getprotobynumber I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1063getprotoent |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1064getpwent |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1065getpwnam C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1066getpwuid T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1067getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1068getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1069getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1070getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
10bc17b6
JH
1071readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1072readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1073setgrent |grp | |I_H|V_H
1074sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
1075setlocale IC |locale | |I_ICBI
1076setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
1077setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
1078setpwent |pwd | |I_H|V_H
1079setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
10bc17b6
JH
1080strerror I |string | |I_IBW|I_IBI|B_IBW
1081tmpnam B |stdio | |B_B
1082ttyname I |unistd | |I_IBW|I_IBI|B_IBI