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