This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In regen_lib.pl, when opening, first unlink a previous file of that name.
[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
424a4936
NC
54my $h = safer_open("reentr.h-new");
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
785
37442d52 786/* ex: set ro: */
10bc17b6
JH
787EOF
788
08858ed2 789safer_close($h);
424a4936 790rename_if_different('reentr.h-new', 'reentr.h');
10bc17b6 791
aa418cf1
JH
792# Prepare to write the reentr.c.
793
424a4936
NC
794my $c = safer_open("reentr.c-new");
795select $c;
78102347
NC
796my $top = read_only_top(lang => 'C', by => 'regen/reentr.pl',
797 from => 'data in regen/reentr.pl',
798 file => 'reentr.c', style => '*',
799 copyright => [2002, 2003, 2005 .. 2007]);
800
801$top =~ s! \*/\n! *
10bc17b6 802 * "Saruman," I said, standing away from him, "only one hand at a time can
78102347 803 * wield the One, and you know that well, so do not trouble to say we\!"
10bc17b6 804 *
61296642
DM
805 * This file contains a collection of automatically created wrappers
806 * (created by running reentr.pl) for reentrant (thread-safe) versions of
807 * various library calls, such as getpwent_r. The wrapping is done so
808 * that other files like pp_sys.c calling those library functions need not
809 * care about the differences between various platforms' idiosyncrasies
810 * regarding these reentrant interfaces.
10bc17b6 811 */
78102347 812!s;
10bc17b6 813
78102347 814print $top, <<EOF;
10bc17b6
JH
815#include "EXTERN.h"
816#define PERL_IN_REENTR_C
817#include "perl.h"
818#include "reentr.h"
819
820void
821Perl_reentrant_size(pTHX) {
822#ifdef USE_REENTRANT_API
8695fa85
SR
823#define REENTRANTSMALLSIZE 256 /* Make something up. */
824#define REENTRANTUSUALSIZE 4096 /* Make something up. */
10bc17b6
JH
825@size
826#endif /* USE_REENTRANT_API */
827}
828
829void
830Perl_reentrant_init(pTHX) {
831#ifdef USE_REENTRANT_API
a02a5408 832 Newx(PL_reentrant_buffer, 1, REENTR);
10bc17b6
JH
833 Perl_reentrant_size(aTHX);
834@init
835#endif /* USE_REENTRANT_API */
836}
837
838void
839Perl_reentrant_free(pTHX) {
840#ifdef USE_REENTRANT_API
841@free
842 Safefree(PL_reentrant_buffer);
843#endif /* USE_REENTRANT_API */
844}
845
edd309b7
JH
846void*
847Perl_reentrant_retry(const char *f, ...)
848{
abb2c242 849 dTHX;
edd309b7 850 void *retptr = NULL;
fe5bfecd 851 va_list ap;
7918f24d
NC
852#ifdef USE_REENTRANT_API
853 /* Easier to special case this here than in embed.pl. (Look at what it
854 generates for proto.h) */
855 PERL_ARGS_ASSERT_REENTRANT_RETRY;
856#endif
fe5bfecd 857 va_start(ap, f);
369ec4b2 858 {
edd309b7 859#ifdef USE_REENTRANT_API
0891a229 860# 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
861 void *p0;
862# endif
f7937171 863# if defined(USE_SERVENT_BUFFER)
e3410746
SR
864 void *p1;
865# endif
f7937171 866# if defined(USE_HOSTENT_BUFFER)
edd309b7 867 size_t asize;
e3410746 868# endif
f7937171 869# if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
edd309b7 870 int anint;
e3410746 871# endif
edd309b7 872
edd309b7 873 switch (PL_op->op_type) {
f7937171 874#ifdef USE_HOSTENT_BUFFER
edd309b7
JH
875 case OP_GHBYADDR:
876 case OP_GHBYNAME:
877 case OP_GHOSTENT:
878 {
af685957
JH
879#ifdef PERL_REENTRANT_MAXSIZE
880 if (PL_reentrant_buffer->_hostent_size <=
881 PERL_REENTRANT_MAXSIZE / 2)
882#endif
883 {
f7937171
JH
884 PL_reentrant_buffer->_hostent_size *= 2;
885 Renew(PL_reentrant_buffer->_hostent_buffer,
886 PL_reentrant_buffer->_hostent_size, char);
edd309b7
JH
887 switch (PL_op->op_type) {
888 case OP_GHBYADDR:
889 p0 = va_arg(ap, void *);
890 asize = va_arg(ap, size_t);
891 anint = va_arg(ap, int);
892 retptr = gethostbyaddr(p0, asize, anint); break;
893 case OP_GHBYNAME:
894 p0 = va_arg(ap, void *);
f6f0b69b 895 retptr = gethostbyname((char *)p0); break;
edd309b7
JH
896 case OP_GHOSTENT:
897 retptr = gethostent(); break;
898 default:
0de8cad8 899 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
900 break;
901 }
902 }
903 }
904 break;
905#endif
f7937171 906#ifdef USE_GRENT_BUFFER
edd309b7
JH
907 case OP_GGRNAM:
908 case OP_GGRGID:
909 case OP_GGRENT:
910 {
af685957
JH
911#ifdef PERL_REENTRANT_MAXSIZE
912 if (PL_reentrant_buffer->_grent_size <=
913 PERL_REENTRANT_MAXSIZE / 2)
914#endif
915 {
edd309b7 916 Gid_t gid;
f7937171
JH
917 PL_reentrant_buffer->_grent_size *= 2;
918 Renew(PL_reentrant_buffer->_grent_buffer,
919 PL_reentrant_buffer->_grent_size, char);
edd309b7
JH
920 switch (PL_op->op_type) {
921 case OP_GGRNAM:
922 p0 = va_arg(ap, void *);
f6f0b69b 923 retptr = getgrnam((char *)p0); break;
edd309b7 924 case OP_GGRGID:
ab2b559b
JH
925#if Gid_t_size < INTSIZE
926 gid = (Gid_t)va_arg(ap, int);
927#else
edd309b7 928 gid = va_arg(ap, Gid_t);
ab2b559b 929#endif
edd309b7
JH
930 retptr = getgrgid(gid); break;
931 case OP_GGRENT:
932 retptr = getgrent(); break;
933 default:
0de8cad8 934 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
935 break;
936 }
937 }
938 }
939 break;
940#endif
f7937171 941#ifdef USE_NETENT_BUFFER
edd309b7
JH
942 case OP_GNBYADDR:
943 case OP_GNBYNAME:
944 case OP_GNETENT:
945 {
af685957
JH
946#ifdef PERL_REENTRANT_MAXSIZE
947 if (PL_reentrant_buffer->_netent_size <=
948 PERL_REENTRANT_MAXSIZE / 2)
949#endif
950 {
edd309b7 951 Netdb_net_t net;
f7937171
JH
952 PL_reentrant_buffer->_netent_size *= 2;
953 Renew(PL_reentrant_buffer->_netent_buffer,
954 PL_reentrant_buffer->_netent_size, char);
edd309b7
JH
955 switch (PL_op->op_type) {
956 case OP_GNBYADDR:
957 net = va_arg(ap, Netdb_net_t);
958 anint = va_arg(ap, int);
959 retptr = getnetbyaddr(net, anint); break;
960 case OP_GNBYNAME:
961 p0 = va_arg(ap, void *);
f6f0b69b 962 retptr = getnetbyname((char *)p0); break;
edd309b7
JH
963 case OP_GNETENT:
964 retptr = getnetent(); break;
965 default:
0de8cad8 966 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
967 break;
968 }
969 }
970 }
971 break;
972#endif
f7937171 973#ifdef USE_PWENT_BUFFER
edd309b7
JH
974 case OP_GPWNAM:
975 case OP_GPWUID:
976 case OP_GPWENT:
977 {
af685957
JH
978#ifdef PERL_REENTRANT_MAXSIZE
979 if (PL_reentrant_buffer->_pwent_size <=
980 PERL_REENTRANT_MAXSIZE / 2)
981#endif
982 {
edd309b7 983 Uid_t uid;
f7937171
JH
984 PL_reentrant_buffer->_pwent_size *= 2;
985 Renew(PL_reentrant_buffer->_pwent_buffer,
986 PL_reentrant_buffer->_pwent_size, char);
edd309b7
JH
987 switch (PL_op->op_type) {
988 case OP_GPWNAM:
989 p0 = va_arg(ap, void *);
f6f0b69b 990 retptr = getpwnam((char *)p0); break;
edd309b7 991 case OP_GPWUID:
ab2b559b
JH
992#if Uid_t_size < INTSIZE
993 uid = (Uid_t)va_arg(ap, int);
994#else
edd309b7 995 uid = va_arg(ap, Uid_t);
ab2b559b 996#endif
edd309b7
JH
997 retptr = getpwuid(uid); break;
998 case OP_GPWENT:
999 retptr = getpwent(); break;
1000 default:
0de8cad8 1001 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1002 break;
1003 }
1004 }
1005 }
1006 break;
1007#endif
f7937171 1008#ifdef USE_PROTOENT_BUFFER
edd309b7
JH
1009 case OP_GPBYNAME:
1010 case OP_GPBYNUMBER:
1011 case OP_GPROTOENT:
1012 {
af685957
JH
1013#ifdef PERL_REENTRANT_MAXSIZE
1014 if (PL_reentrant_buffer->_protoent_size <=
1015 PERL_REENTRANT_MAXSIZE / 2)
1016#endif
1017 {
f7937171
JH
1018 PL_reentrant_buffer->_protoent_size *= 2;
1019 Renew(PL_reentrant_buffer->_protoent_buffer,
1020 PL_reentrant_buffer->_protoent_size, char);
edd309b7
JH
1021 switch (PL_op->op_type) {
1022 case OP_GPBYNAME:
1023 p0 = va_arg(ap, void *);
f6f0b69b 1024 retptr = getprotobyname((char *)p0); break;
edd309b7
JH
1025 case OP_GPBYNUMBER:
1026 anint = va_arg(ap, int);
1027 retptr = getprotobynumber(anint); break;
1028 case OP_GPROTOENT:
1029 retptr = getprotoent(); break;
1030 default:
0de8cad8 1031 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1032 break;
1033 }
1034 }
1035 }
1036 break;
1037#endif
f7937171 1038#ifdef USE_SERVENT_BUFFER
edd309b7
JH
1039 case OP_GSBYNAME:
1040 case OP_GSBYPORT:
1041 case OP_GSERVENT:
1042 {
af685957
JH
1043#ifdef PERL_REENTRANT_MAXSIZE
1044 if (PL_reentrant_buffer->_servent_size <=
1045 PERL_REENTRANT_MAXSIZE / 2)
1046#endif
1047 {
f7937171
JH
1048 PL_reentrant_buffer->_servent_size *= 2;
1049 Renew(PL_reentrant_buffer->_servent_buffer,
1050 PL_reentrant_buffer->_servent_size, char);
edd309b7
JH
1051 switch (PL_op->op_type) {
1052 case OP_GSBYNAME:
1053 p0 = va_arg(ap, void *);
1054 p1 = va_arg(ap, void *);
f6f0b69b 1055 retptr = getservbyname((char *)p0, (char *)p1); break;
edd309b7
JH
1056 case OP_GSBYPORT:
1057 anint = va_arg(ap, int);
1058 p0 = va_arg(ap, void *);
f6f0b69b 1059 retptr = getservbyport(anint, (char *)p0); break;
edd309b7
JH
1060 case OP_GSERVENT:
1061 retptr = getservent(); break;
1062 default:
0de8cad8 1063 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1064 break;
1065 }
1066 }
1067 }
1068 break;
1069#endif
1070 default:
1071 /* Not known how to retry, so just fail. */
1072 break;
1073 }
6148ee25
SP
1074#else
1075 PERL_UNUSED_ARG(f);
edd309b7 1076#endif
369ec4b2 1077 }
fe5bfecd 1078 va_end(ap);
edd309b7
JH
1079 return retptr;
1080}
1081
37442d52 1082/* ex: set ro: */
10bc17b6
JH
1083EOF
1084
08858ed2 1085safer_close($c);
424a4936 1086rename_if_different('reentr.c-new', 'reentr.c');
b6b9a099 1087
10bc17b6
JH
1088__DATA__
1089asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
b430fd04 1090crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
10bc17b6
JH
1091ctermid B |stdio | |B_B
1092ctime S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
1093drand48 |stdlib |struct drand48_data |I_ST|T=double*
1094endgrent |grp | |I_H|V_H
31ee0cb7
JH
1095endhostent |netdb | |I_D|V_D|D=struct hostent_data*
1096endnetent |netdb | |I_D|V_D|D=struct netent_data*
1097endprotoent |netdb | |I_D|V_D|D=struct protoent_data*
10bc17b6 1098endpwent |pwd | |I_H|V_H
31ee0cb7 1099endservent |netdb | |I_D|V_D|D=struct servent_data*
10bc17b6
JH
1100getgrent |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1101getgrgid T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
1102getgrnam C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
a845a0d4 1103gethostbyaddr 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
1104gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
1105gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
f6f0b69b 1106getlogin |unistd |char |I_BW|I_BI|B_BW|B_BI
a845a0d4 1107getnetbyaddr 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
1108getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
1109getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
1110getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
1111getprotobynumber I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
1112getprotoent |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
1113getpwent |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
1114getpwnam C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
1115getpwuid T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
1116getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
1117getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
1118getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
1119getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
a845a0d4 1120random |stdlib |struct random_data|I_iS|I_lS|I_St|i=int*|l=long*|t=int32_t*
10bc17b6
JH
1121readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1122readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1123setgrent |grp | |I_H|V_H
1124sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
1125setlocale IC |locale | |I_ICBI
1126setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
1127setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
1128setpwent |pwd | |I_H|V_H
1129setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
1130srand48 L |stdlib |struct drand48_data |I_LS
1131srandom T |stdlib |struct random_data|I_TS|T=unsigned int
1132strerror I |string | |I_IBW|I_IBI|B_IBW
1133tmpnam B |stdio | |B_B
1134ttyname I |unistd | |I_IBW|I_IBI|B_IBI