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