This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / reentr.pl
CommitLineData
10bc17b6
JH
1#!/usr/bin/perl -w
2
3#
4# Generate the reentr.c and reentr.h,
5# and optionally also the relevant metaconfig units (-U option).
6#
7
e06c4d37
NC
8BEGIN {
9 # Get function prototypes
10 require 'regen_lib.pl';
11}
12
10bc17b6
JH
13use strict;
14use Getopt::Std;
15my %opts;
16getopts('U', \%opts);
17
18my %map = (
19 V => "void",
20 A => "char*", # as an input argument
21 B => "char*", # as an output argument
22 C => "const char*", # as a read-only input argument
23 I => "int",
24 L => "long",
25 W => "size_t",
26 H => "FILE**",
27 E => "int*",
28 );
29
30# (See the definitions after __DATA__.)
31# In func|inc|type|... a "S" means "type*", and a "R" means "type**".
32# (The "types" are often structs, such as "struct passwd".)
33#
34# After the prototypes one can have |X=...|Y=... to define more types.
35# A commonly used extra type is to define D to be equal to "type_data",
36# for example "struct_hostent_data to" go with "struct hostent".
37#
38# Example #1: I_XSBWR means int func_r(X, type, char*, size_t, type**)
39# Example #2: S_SBIE means type func_r(type, char*, int, int*)
40# Example #3: S_CBI means type func_r(const char*, char*, int)
41
42
e06c4d37 43safer_unlink 'reentr.h';
10bc17b6 44die "reentr.h: $!" unless open(H, ">reentr.h");
0eb6355a 45binmode H;
10bc17b6
JH
46select H;
47print <<EOF;
37442d52
RGS
48/* -*- buffer-read-only: t -*-
49 *
10bc17b6
JH
50 * reentr.h
51 *
38f14693 52 * Copyright (C) 2002, 2003, 2005, 2006, 2007 by Larry Wall and others
10bc17b6
JH
53 *
54 * You may distribute under the terms of either the GNU General Public
55 * License or the Artistic License, as specified in the README file.
56 *
57 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
61296642 58 * This file is built by reentr.pl from data in reentr.pl.
10bc17b6
JH
59 */
60
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
JH
204 select U;
205 }
aa418cf1 206
d63eadf0 207 if ($opts{U}) {
aa418cf1
JH
208 # The metaconfig units needs prerequisite dependencies.
209 my $prereqs = '';
210 my $prereqh = '';
211 my $prereqsh = '';
212 if ($hdr ne 'stdio') { # There's no i_stdio.
213 $prereqs = "i_$hdr";
214 $prereqh = "$hdr.h";
215 $prereqsh = "\$$prereqs $prereqh";
216 }
1fdb6f84
JH
217 my @prereq = qw(Inlibc Protochk Hasproto i_systypes usethreads);
218 push @prereq, $prereqs;
219 my $hdrs = "\$i_systypes sys/types.h define stdio.h $prereqsh";
aa418cf1 220 if ($hdr eq 'time') {
1fdb6f84
JH
221 $hdrs .= " \$i_systime sys/time.h";
222 push @prereq, 'i_systime';
223 }
aa418cf1 224 # Output the metaconfig unit header.
d63eadf0 225 print <<EOF;
aa418cf1 226?RCS: \$Id: d_${func}_r.U,v $
10bc17b6 227?RCS:
a845a0d4 228?RCS: Copyright (c) 2002,2003 Jarkko Hietaniemi
10bc17b6
JH
229?RCS:
230?RCS: You may distribute under the terms of either the GNU General Public
231?RCS: License or the Artistic License, as specified in the README file.
232?RCS:
233?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
234?RCS:
aa418cf1 235?MAKE:d_${func}_r ${func}_r_proto: @prereq
10bc17b6 236?MAKE: -pick add \$@ %<
aa418cf1
JH
237?S:d_${func}_r:
238?S: This variable conditionally defines the HAS_${FUNC}_R symbol,
239?S: which indicates to the C program that the ${func}_r()
10bc17b6
JH
240?S: routine is available.
241?S:.
aa418cf1
JH
242?S:${func}_r_proto:
243?S: This variable encodes the prototype of ${func}_r.
39183afa
JH
244?S: It is zero if d_${func}_r is undef, and one of the
245?S: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
246?S: is defined.
10bc17b6 247?S:.
aa418cf1
JH
248?C:HAS_${FUNC}_R:
249?C: This symbol, if defined, indicates that the ${func}_r routine
250?C: is available to ${func} re-entrantly.
10bc17b6 251?C:.
aa418cf1
JH
252?C:${FUNC}_R_PROTO:
253?C: This symbol encodes the prototype of ${func}_r.
39183afa
JH
254?C: It is zero if d_${func}_r is undef, and one of the
255?C: REENTRANT_PROTO_T_ABC macros of reentr.h if d_${func}_r
256?C: is defined.
10bc17b6 257?C:.
aa418cf1
JH
258?H:#\$d_${func}_r HAS_${FUNC}_R /**/
259?H:#define ${FUNC}_R_PROTO \$${func}_r_proto /**/
10bc17b6 260?H:.
aa418cf1
JH
261?T:try hdrs d_${func}_r_proto
262?LINT:set d_${func}_r
263?LINT:set ${func}_r_proto
264: see if ${func}_r exists
265set ${func}_r d_${func}_r
10bc17b6 266eval \$inlibc
aa418cf1 267case "\$d_${func}_r" in
10bc17b6 268"\$define")
d63eadf0 269EOF
d63eadf0
JH
270 print <<EOF;
271 hdrs="$hdrs"
aa418cf1
JH
272 case "\$d_${func}_r_proto:\$usethreads" in
273 ":define") d_${func}_r_proto=define
274 set d_${func}_r_proto ${func}_r \$hdrs
a48ec845
JH
275 eval \$hasproto ;;
276 *) ;;
277 esac
aa418cf1 278 case "\$d_${func}_r_proto" in
a48ec845 279 define)
10bc17b6 280EOF
d63eadf0
JH
281 }
282 for my $p (@p) {
283 my ($r, $a) = ($p =~ /^(.)_(.+)/);
284 my $v = join(", ", map { $m{$_} } split '', $a);
285 if ($opts{U}) {
286 print <<EOF ;
aa418cf1
JH
287 case "\$${func}_r_proto" in
288 ''|0) try='$m{$r} ${func}_r($v);'
289 ./protochk "extern \$try" \$hdrs && ${func}_r_proto=$p ;;
10bc17b6
JH
290 esac
291EOF
d63eadf0 292 }
aa418cf1
JH
293 $seenh{$func}->{$p}++;
294 push @{$seena{$func}}, $p;
d63eadf0 295 $seenp{$p}++;
aa418cf1
JH
296 $seent{$func} = $type;
297 $seens{$func} = $m{S};
298 $seend{$func} = $m{D};
a845a0d4 299 $seenm{$func} = \%m;
d63eadf0
JH
300 }
301 if ($opts{U}) {
302 print <<EOF;
aa418cf1
JH
303 case "\$${func}_r_proto" in
304 ''|0) d_${func}_r=undef
305 ${func}_r_proto=0
306 echo "Disabling ${func}_r, cannot determine prototype." >&4 ;;
307 * ) case "\$${func}_r_proto" in
10bc17b6 308 REENTRANT_PROTO*) ;;
aa418cf1 309 *) ${func}_r_proto="REENTRANT_PROTO_\$${func}_r_proto" ;;
10bc17b6
JH
310 esac
311 echo "Prototype: \$try" ;;
312 esac
313 ;;
c18e646a 314 *) case "\$usethreads" in
aa418cf1 315 define) echo "${func}_r has no prototype, not using it." >&4 ;;
c18e646a 316 esac
aa418cf1
JH
317 d_${func}_r=undef
318 ${func}_r_proto=0
c18e646a 319 ;;
a48ec845
JH
320 esac
321 ;;
aa418cf1 322*) ${func}_r_proto=0
10bc17b6
JH
323 ;;
324esac
325
326EOF
327 close(U);
328 }
329}
330
331close DATA;
332
aa418cf1
JH
333# Prepare to continue writing the reentr.h.
334
10bc17b6
JH
335select H;
336
337{
aa418cf1 338 # Write out all the known prototype signatures.
10bc17b6
JH
339 my $i = 1;
340 for my $p (sort keys %seenp) {
341 print "#define REENTRANT_PROTO_${p} ${i}\n";
342 $i++;
343 }
344}
345
aa418cf1
JH
346my @struct; # REENTR struct members
347my @size; # struct member buffer size initialization code
348my @init; # struct member buffer initialization (malloc) code
349my @free; # struct member buffer release (free) code
350my @wrap; # the wrapper (foo(a) -> foo_r(a,...)) cpp code
351my @define; # defines for optional features
352
10bc17b6 353sub ifprotomatch {
aa418cf1
JH
354 my $FUNC = shift;
355 join " || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @_;
10bc17b6
JH
356}
357
10bc17b6
JH
358sub pushssif {
359 push @struct, @_;
360 push @size, @_;
361 push @init, @_;
362 push @free, @_;
363}
364
365sub pushinitfree {
aa418cf1 366 my $func = shift;
10bc17b6 367 push @init, <<EOF;
a02a5408 368 Newx(PL_reentrant_buffer->_${func}_buffer, PL_reentrant_buffer->_${func}_size, char);
10bc17b6
JH
369EOF
370 push @free, <<EOF;
aa418cf1 371 Safefree(PL_reentrant_buffer->_${func}_buffer);
10bc17b6
JH
372EOF
373}
374
375sub define {
376 my ($n, $p, @F) = @_;
377 my @H;
378 my $H = uc $F[0];
379 push @define, <<EOF;
380/* The @F using \L$n? */
381
382EOF
aa418cf1
JH
383 my $GENFUNC;
384 for my $func (@F) {
385 my $FUNC = uc $func;
386 my $HAS = "${FUNC}_R_HAS_$n";
387 push @H, $HAS;
388 my @h = grep { /$p/ } @{$seena{$func}};
389 unless (defined $GENFUNC) {
390 $GENFUNC = $FUNC;
391 $GENFUNC =~ s/^GET//;
f7937171 392 }
10bc17b6 393 if (@h) {
aa418cf1 394 push @define, "#if defined(HAS_${FUNC}_R) && (" . join(" || ", map { "${FUNC}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
10bc17b6
JH
395
396 push @define, <<EOF;
aa418cf1 397# define $HAS
10bc17b6 398#else
aa418cf1 399# undef $HAS
10bc17b6
JH
400#endif
401EOF
402 }
403 }
0891a229 404 return if @F == 1;
10bc17b6
JH
405 push @define, <<EOF;
406
407/* Any of the @F using \L$n? */
408
409EOF
410 push @define, "#if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
411 push @define, <<EOF;
aa418cf1 412# define USE_${GENFUNC}_$n
10bc17b6 413#else
aa418cf1 414# undef USE_${GENFUNC}_$n
10bc17b6
JH
415#endif
416
417EOF
418}
419
edd309b7
JH
420define('BUFFER', 'B',
421 qw(getgrent getgrgid getgrnam));
422
10bc17b6
JH
423define('PTR', 'R',
424 qw(getgrent getgrgid getgrnam));
425define('PTR', 'R',
426 qw(getpwent getpwnam getpwuid));
427define('PTR', 'R',
428 qw(getspent getspnam));
429
430define('FPTR', 'H',
f7937171 431 qw(getgrent getgrgid getgrnam setgrent endgrent));
10bc17b6 432define('FPTR', 'H',
f7937171 433 qw(getpwent getpwnam getpwuid setpwent endpwent));
10bc17b6 434
edd309b7
JH
435define('BUFFER', 'B',
436 qw(getpwent getpwgid getpwnam));
437
10bc17b6
JH
438define('PTR', 'R',
439 qw(gethostent gethostbyaddr gethostbyname));
440define('PTR', 'R',
441 qw(getnetent getnetbyaddr getnetbyname));
442define('PTR', 'R',
443 qw(getprotoent getprotobyname getprotobynumber));
444define('PTR', 'R',
445 qw(getservent getservbyname getservbyport));
446
edd309b7
JH
447define('BUFFER', 'B',
448 qw(gethostent gethostbyaddr gethostbyname));
449define('BUFFER', 'B',
450 qw(getnetent getnetbyaddr getnetbyname));
451define('BUFFER', 'B',
452 qw(getprotoent getprotobyname getprotobynumber));
453define('BUFFER', 'B',
454 qw(getservent getservbyname getservbyport));
455
10bc17b6
JH
456define('ERRNO', 'E',
457 qw(gethostent gethostbyaddr gethostbyname));
458define('ERRNO', 'E',
459 qw(getnetent getnetbyaddr getnetbyname));
460
aa418cf1
JH
461# The following loop accumulates the "ssif" (struct, size, init, free)
462# sections that declare the struct members (in reentr.h), and the buffer
463# size initialization, buffer initialization (malloc), and buffer
464# release (free) code (in reentr.c).
465#
466# The loop also contains a lot of intrinsic logic about groups of
467# functions (since functions of certain kind operate the same way).
468
469for my $func (@seenf) {
470 my $FUNC = uc $func;
471 my $ifdef = "#ifdef HAS_${FUNC}_R\n";
472 my $endif = "#endif /* HAS_${FUNC}_R */\n";
473 if (exists $seena{$func}) {
474 my @p = @{$seena{$func}};
475 if ($func =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
10bc17b6
JH
476 pushssif $ifdef;
477 push @struct, <<EOF;
aa418cf1
JH
478 char* _${func}_buffer;
479 size_t _${func}_size;
10bc17b6
JH
480EOF
481 push @size, <<EOF;
aa418cf1 482 PL_reentrant_buffer->_${func}_size = REENTRANTSMALLSIZE;
10bc17b6 483EOF
aa418cf1 484 pushinitfree $func;
10bc17b6
JH
485 pushssif $endif;
486 }
aa418cf1 487 elsif ($func =~ /^(crypt)$/) {
10bc17b6
JH
488 pushssif $ifdef;
489 push @struct, <<EOF;
b430fd04 490#if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
aa418cf1 491 $seend{$func} _${func}_data;
b430fd04 492#else
05404ffe 493 $seent{$func} *_${func}_struct_buffer;
b430fd04 494#endif
10bc17b6 495EOF
b430fd04 496 push @init, <<EOF;
05404ffe
JH
497#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
498 PL_reentrant_buffer->_${func}_struct_buffer = 0;
499#endif
500EOF
501 push @free, <<EOF;
502#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
503 Safefree(PL_reentrant_buffer->_${func}_struct_buffer);
10bc17b6
JH
504#endif
505EOF
b430fd04
JH
506 pushssif $endif;
507 }
5cb13b8d 508 elsif ($func =~ /^(drand48|gmtime|localtime|random|srandom)$/) {
b430fd04
JH
509 pushssif $ifdef;
510 push @struct, <<EOF;
aa418cf1 511 $seent{$func} _${func}_struct;
b430fd04 512EOF
10bc17b6
JH
513 if ($1 eq 'drand48') {
514 push @struct, <<EOF;
aa418cf1 515 double _${func}_double;
10bc17b6 516EOF
a845a0d4
JH
517 } elsif ($1 eq 'random') {
518 push @struct, <<EOF;
b3b3b51f 519# if RANDOM_R_PROTO == REENTRANT_PROTO_I_iS
a845a0d4
JH
520 int _${func}_retval;
521# endif
b3b3b51f 522# if RANDOM_R_PROTO == REENTRANT_PROTO_I_lS
a845a0d4
JH
523 long _${func}_retval;
524# endif
b3b3b51f 525# if RANDOM_R_PROTO == REENTRANT_PROTO_I_St
a845a0d4
JH
526 int32_t _${func}_retval;
527# endif
528EOF
10bc17b6
JH
529 }
530 pushssif $endif;
531 }
aa418cf1 532 elsif ($func =~ /^(getgrnam|getpwnam|getspnam)$/) {
10bc17b6 533 pushssif $ifdef;
aa418cf1
JH
534 # 'genfunc' can be read either as 'generic' or 'genre',
535 # it represents a group of functions.
536 my $genfunc = $func;
537 $genfunc =~ s/nam/ent/g;
538 $genfunc =~ s/^get//;
539 my $GENFUNC = uc $genfunc;
10bc17b6 540 push @struct, <<EOF;
aa418cf1
JH
541 $seent{$func} _${genfunc}_struct;
542 char* _${genfunc}_buffer;
543 size_t _${genfunc}_size;
10bc17b6
JH
544EOF
545 push @struct, <<EOF;
aa418cf1
JH
546# ifdef USE_${GENFUNC}_PTR
547 $seent{$func}* _${genfunc}_ptr;
10bc17b6
JH
548# endif
549EOF
0de8cad8 550 push @struct, <<EOF;
aa418cf1
JH
551# ifdef USE_${GENFUNC}_FPTR
552 FILE* _${genfunc}_fptr;
10bc17b6
JH
553# endif
554EOF
0de8cad8 555 push @init, <<EOF;
aa418cf1
JH
556# ifdef USE_${GENFUNC}_FPTR
557 PL_reentrant_buffer->_${genfunc}_fptr = NULL;
10bc17b6
JH
558# endif
559EOF
0de8cad8 560 my $sc = $genfunc eq 'grent' ?
10bc17b6 561 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
0de8cad8
RGS
562 my $sz = "_${genfunc}_size";
563 push @size, <<EOF;
10bc17b6 564# if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
0de8cad8 565 PL_reentrant_buffer->$sz = sysconf($sc);
832a833b 566 if (PL_reentrant_buffer->$sz == (size_t) -1)
e3410746 567 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
10bc17b6
JH
568# else
569# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
0de8cad8 570 PL_reentrant_buffer->$sz = SIABUFSIZ;
10bc17b6
JH
571# else
572# ifdef __sgi
0de8cad8 573 PL_reentrant_buffer->$sz = BUFSIZ;
10bc17b6 574# else
0de8cad8 575 PL_reentrant_buffer->$sz = REENTRANTUSUALSIZE;
10bc17b6
JH
576# endif
577# endif
578# endif
579EOF
aa418cf1 580 pushinitfree $genfunc;
10bc17b6
JH
581 pushssif $endif;
582 }
aa418cf1 583 elsif ($func =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
10bc17b6 584 pushssif $ifdef;
aa418cf1
JH
585 my $genfunc = $func;
586 $genfunc =~ s/byname/ent/;
587 $genfunc =~ s/^get//;
588 my $GENFUNC = uc $genfunc;
589 my $D = ifprotomatch($FUNC, grep {/D/} @p);
590 my $d = $seend{$func};
31ee0cb7 591 $d =~ s/\*$//; # snip: we need need the base type.
10bc17b6 592 push @struct, <<EOF;
aa418cf1 593 $seent{$func} _${genfunc}_struct;
10bc17b6 594# if $D
aa418cf1 595 $d _${genfunc}_data;
10bc17b6 596# else
aa418cf1
JH
597 char* _${genfunc}_buffer;
598 size_t _${genfunc}_size;
10bc17b6 599# endif
aa418cf1
JH
600# ifdef USE_${GENFUNC}_PTR
601 $seent{$func}* _${genfunc}_ptr;
10bc17b6
JH
602# endif
603EOF
604 push @struct, <<EOF;
aa418cf1
JH
605# ifdef USE_${GENFUNC}_ERRNO
606 int _${genfunc}_errno;
10bc17b6
JH
607# endif
608EOF
609 push @size, <<EOF;
610#if !($D)
aa418cf1 611 PL_reentrant_buffer->_${genfunc}_size = REENTRANTUSUALSIZE;
10bc17b6
JH
612#endif
613EOF
614 push @init, <<EOF;
615#if !($D)
a02a5408 616 Newx(PL_reentrant_buffer->_${genfunc}_buffer, PL_reentrant_buffer->_${genfunc}_size, char);
10bc17b6
JH
617#endif
618EOF
619 push @free, <<EOF;
620#if !($D)
aa418cf1 621 Safefree(PL_reentrant_buffer->_${genfunc}_buffer);
10bc17b6
JH
622#endif
623EOF
624 pushssif $endif;
625 }
aa418cf1 626 elsif ($func =~ /^(readdir|readdir64)$/) {
10bc17b6 627 pushssif $ifdef;
aa418cf1 628 my $R = ifprotomatch($FUNC, grep {/R/} @p);
10bc17b6 629 push @struct, <<EOF;
aa418cf1
JH
630 $seent{$func}* _${func}_struct;
631 size_t _${func}_size;
10bc17b6 632# if $R
aa418cf1 633 $seent{$func}* _${func}_ptr;
10bc17b6
JH
634# endif
635EOF
636 push @size, <<EOF;
637 /* This is the size Solaris recommends.
638 * (though we go static, should use pathconf() instead) */
aa418cf1 639 PL_reentrant_buffer->_${func}_size = sizeof($seent{$func}) + MAXPATHLEN + 1;
10bc17b6
JH
640EOF
641 push @init, <<EOF;
aa418cf1 642 PL_reentrant_buffer->_${func}_struct = ($seent{$func}*)safemalloc(PL_reentrant_buffer->_${func}_size);
10bc17b6
JH
643EOF
644 push @free, <<EOF;
aa418cf1 645 Safefree(PL_reentrant_buffer->_${func}_struct);
10bc17b6
JH
646EOF
647 pushssif $endif;
648 }
649
650 push @wrap, $ifdef;
651
10bc17b6 652 push @wrap, <<EOF;
d896b068 653# if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1)
aa418cf1 654# undef $func
10bc17b6 655EOF
aa418cf1
JH
656
657 # Write out what we have learned.
658
10bc17b6 659 my @v = 'a'..'z';
aa418cf1 660 my $v = join(", ", @v[0..$seenu{$func}-1]);
10bc17b6
JH
661 for my $p (@p) {
662 my ($r, $a) = split '_', $p;
663 my $test = $r eq 'I' ? ' == 0' : '';
664 my $true = 1;
aa418cf1
JH
665 my $genfunc = $func;
666 if ($genfunc =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
667 $genfunc = "${1}ent";
668 } elsif ($genfunc eq 'srand48') {
669 $genfunc = "drand48";
10bc17b6
JH
670 }
671 my $b = $a;
672 my $w = '';
aa418cf1 673 substr($b, 0, $seenu{$func}) = '';
a845a0d4
JH
674 if ($func =~ /^random$/) {
675 $true = "PL_reentrant_buffer->_random_retval";
676 } elsif ($b =~ /R/) {
aa418cf1
JH
677 $true = "PL_reentrant_buffer->_${genfunc}_ptr";
678 } elsif ($b =~ /T/ && $func eq 'drand48') {
679 $true = "PL_reentrant_buffer->_${genfunc}_double";
10bc17b6 680 } elsif ($b =~ /S/) {
aa418cf1
JH
681 if ($func =~ /^readdir/) {
682 $true = "PL_reentrant_buffer->_${genfunc}_struct";
10bc17b6 683 } else {
aa418cf1 684 $true = "&PL_reentrant_buffer->_${genfunc}_struct";
10bc17b6
JH
685 }
686 } elsif ($b =~ /B/) {
aa418cf1 687 $true = "PL_reentrant_buffer->_${genfunc}_buffer";
10bc17b6
JH
688 }
689 if (length $b) {
690 $w = join ", ",
691 map {
692 $_ eq 'R' ?
aa418cf1 693 "&PL_reentrant_buffer->_${genfunc}_ptr" :
10bc17b6 694 $_ eq 'E' ?
aa418cf1 695 "&PL_reentrant_buffer->_${genfunc}_errno" :
10bc17b6 696 $_ eq 'B' ?
aa418cf1 697 "PL_reentrant_buffer->_${genfunc}_buffer" :
10bc17b6 698 $_ =~ /^[WI]$/ ?
aa418cf1 699 "PL_reentrant_buffer->_${genfunc}_size" :
10bc17b6 700 $_ eq 'H' ?
aa418cf1 701 "&PL_reentrant_buffer->_${genfunc}_fptr" :
10bc17b6 702 $_ eq 'D' ?
aa418cf1 703 "&PL_reentrant_buffer->_${genfunc}_data" :
10bc17b6 704 $_ eq 'S' ?
05404ffe 705 ($func =~ /^readdir\d*$/ ?
aa418cf1 706 "PL_reentrant_buffer->_${genfunc}_struct" :
05404ffe
JH
707 $func =~ /^crypt$/ ?
708 "PL_reentrant_buffer->_${genfunc}_struct_buffer" :
709 "&PL_reentrant_buffer->_${genfunc}_struct") :
aa418cf1
JH
710 $_ eq 'T' && $func eq 'drand48' ?
711 "&PL_reentrant_buffer->_${genfunc}_double" :
a845a0d4
JH
712 $_ =~ /^[ilt]$/ && $func eq 'random' ?
713 "&PL_reentrant_buffer->_random_retval" :
10bc17b6
JH
714 $_
715 } split '', $b;
716 $w = ", $w" if length $v;
717 }
832a833b 718
aa418cf1 719 my $call = "${func}_r($v$w)";
64e28687
RGS
720 if ($func eq 'localtime') {
721 $call = "L_R_TZSET $call";
722 }
23e2b7a9
SP
723
724 # Must make OpenBSD happy
725 my $memzero = '';
726 if($p =~ /D$/ &&
727 ($genfunc eq 'protoent' || $genfunc eq 'servent')) {
3fb2f3ac 728 $memzero = 'REENTR_MEMZERO(&PL_reentrant_buffer->_' . $genfunc . '_data, sizeof(PL_reentrant_buffer->_' . $genfunc . '_data)),';
23e2b7a9 729 }
10bc17b6 730 push @wrap, <<EOF;
aa418cf1 731# if !defined($func) && ${FUNC}_R_PROTO == REENTRANT_PROTO_$p
10bc17b6
JH
732EOF
733 if ($r eq 'V' || $r eq 'B') {
734 push @wrap, <<EOF;
aa418cf1 735# define $func($v) $call
10bc17b6
JH
736EOF
737 } else {
aa418cf1 738 if ($func =~ /^get/) {
edd309b7 739 my $rv = $v ? ", $v" : "";
0891a229
JH
740 if ($r eq 'I') {
741 push @wrap, <<EOF;
b8dcbfa5 742# define $func($v) ($memzero(PL_reentrant_retint = $call)$test ? $true : ((PL_reentrant_retint == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
0891a229
JH
743EOF
744 } else {
745 push @wrap, <<EOF;
f6f0b69b 746# define $func($v) ($call$test ? $true : ((errno == ERANGE) ? ($seent{$func} *) Perl_reentrant_retry("$func"$rv) : 0))
10bc17b6 747EOF
0891a229 748 }
edd309b7
JH
749 } else {
750 push @wrap, <<EOF;
aa418cf1 751# define $func($v) ($call$test ? $true : 0)
edd309b7
JH
752EOF
753 }
10bc17b6
JH
754 }
755 push @wrap, <<EOF;
d896b068 756# endif /* if defined(PERL_REENTR_API) && (PERL_REENTR_API+0 == 1) */
10bc17b6
JH
757EOF
758 }
759
832a833b
JH
760 push @wrap, <<EOF;
761# endif /* HAS_\U$func */
762EOF
763
10bc17b6
JH
764 push @wrap, $endif, "\n";
765 }
766}
767
768local $" = '';
769
770print <<EOF;
771
772/* Defines for indicating which special features are supported. */
773
774@define
775typedef struct {
776@struct
aa418cf1 777 int dummy; /* cannot have empty structs */
10bc17b6
JH
778} REENTR;
779
780/* The wrappers. */
781
782@wrap
0891a229 783
10bc17b6
JH
784#endif /* USE_REENTRANT_API */
785
786#endif
787
37442d52 788/* ex: set ro: */
10bc17b6
JH
789EOF
790
791close(H);
792
aa418cf1
JH
793# Prepare to write the reentr.c.
794
e06c4d37 795safer_unlink 'reentr.c';
10bc17b6 796die "reentr.c: $!" unless open(C, ">reentr.c");
0eb6355a 797binmode C;
10bc17b6
JH
798select C;
799print <<EOF;
37442d52
RGS
800/* -*- buffer-read-only: t -*-
801 *
10bc17b6
JH
802 * reentr.c
803 *
38f14693 804 * Copyright (C) 2002, 2003, 2005, 2006, 2007 by Larry Wall and others
10bc17b6
JH
805 *
806 * You may distribute under the terms of either the GNU General Public
807 * License or the Artistic License, as specified in the README file.
808 *
809 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
61296642 810 * This file is built by reentr.pl from data in reentr.pl.
10bc17b6
JH
811 *
812 * "Saruman," I said, standing away from him, "only one hand at a time can
813 * wield the One, and you know that well, so do not trouble to say we!"
814 *
61296642
DM
815 * This file contains a collection of automatically created wrappers
816 * (created by running reentr.pl) for reentrant (thread-safe) versions of
817 * various library calls, such as getpwent_r. The wrapping is done so
818 * that other files like pp_sys.c calling those library functions need not
819 * care about the differences between various platforms' idiosyncrasies
820 * regarding these reentrant interfaces.
10bc17b6
JH
821 */
822
823#include "EXTERN.h"
824#define PERL_IN_REENTR_C
825#include "perl.h"
826#include "reentr.h"
827
828void
829Perl_reentrant_size(pTHX) {
830#ifdef USE_REENTRANT_API
8695fa85
SR
831#define REENTRANTSMALLSIZE 256 /* Make something up. */
832#define REENTRANTUSUALSIZE 4096 /* Make something up. */
10bc17b6
JH
833@size
834#endif /* USE_REENTRANT_API */
835}
836
837void
838Perl_reentrant_init(pTHX) {
839#ifdef USE_REENTRANT_API
a02a5408 840 Newx(PL_reentrant_buffer, 1, REENTR);
10bc17b6
JH
841 Perl_reentrant_size(aTHX);
842@init
843#endif /* USE_REENTRANT_API */
844}
845
846void
847Perl_reentrant_free(pTHX) {
848#ifdef USE_REENTRANT_API
849@free
850 Safefree(PL_reentrant_buffer);
851#endif /* USE_REENTRANT_API */
852}
853
edd309b7
JH
854void*
855Perl_reentrant_retry(const char *f, ...)
856{
abb2c242 857 dTHX;
edd309b7
JH
858 void *retptr = NULL;
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
JH
872 va_list ap;
873
874 va_start(ap, f);
875
edd309b7 876 switch (PL_op->op_type) {
f7937171 877#ifdef USE_HOSTENT_BUFFER
edd309b7
JH
878 case OP_GHBYADDR:
879 case OP_GHBYNAME:
880 case OP_GHOSTENT:
881 {
af685957
JH
882#ifdef PERL_REENTRANT_MAXSIZE
883 if (PL_reentrant_buffer->_hostent_size <=
884 PERL_REENTRANT_MAXSIZE / 2)
885#endif
886 {
f7937171
JH
887 PL_reentrant_buffer->_hostent_size *= 2;
888 Renew(PL_reentrant_buffer->_hostent_buffer,
889 PL_reentrant_buffer->_hostent_size, char);
edd309b7
JH
890 switch (PL_op->op_type) {
891 case OP_GHBYADDR:
892 p0 = va_arg(ap, void *);
893 asize = va_arg(ap, size_t);
894 anint = va_arg(ap, int);
895 retptr = gethostbyaddr(p0, asize, anint); break;
896 case OP_GHBYNAME:
897 p0 = va_arg(ap, void *);
f6f0b69b 898 retptr = gethostbyname((char *)p0); break;
edd309b7
JH
899 case OP_GHOSTENT:
900 retptr = gethostent(); break;
901 default:
0de8cad8 902 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
903 break;
904 }
905 }
906 }
907 break;
908#endif
f7937171 909#ifdef USE_GRENT_BUFFER
edd309b7
JH
910 case OP_GGRNAM:
911 case OP_GGRGID:
912 case OP_GGRENT:
913 {
af685957
JH
914#ifdef PERL_REENTRANT_MAXSIZE
915 if (PL_reentrant_buffer->_grent_size <=
916 PERL_REENTRANT_MAXSIZE / 2)
917#endif
918 {
edd309b7 919 Gid_t gid;
f7937171
JH
920 PL_reentrant_buffer->_grent_size *= 2;
921 Renew(PL_reentrant_buffer->_grent_buffer,
922 PL_reentrant_buffer->_grent_size, char);
edd309b7
JH
923 switch (PL_op->op_type) {
924 case OP_GGRNAM:
925 p0 = va_arg(ap, void *);
f6f0b69b 926 retptr = getgrnam((char *)p0); break;
edd309b7 927 case OP_GGRGID:
ab2b559b
JH
928#if Gid_t_size < INTSIZE
929 gid = (Gid_t)va_arg(ap, int);
930#else
edd309b7 931 gid = va_arg(ap, Gid_t);
ab2b559b 932#endif
edd309b7
JH
933 retptr = getgrgid(gid); break;
934 case OP_GGRENT:
935 retptr = getgrent(); break;
936 default:
0de8cad8 937 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
938 break;
939 }
940 }
941 }
942 break;
943#endif
f7937171 944#ifdef USE_NETENT_BUFFER
edd309b7
JH
945 case OP_GNBYADDR:
946 case OP_GNBYNAME:
947 case OP_GNETENT:
948 {
af685957
JH
949#ifdef PERL_REENTRANT_MAXSIZE
950 if (PL_reentrant_buffer->_netent_size <=
951 PERL_REENTRANT_MAXSIZE / 2)
952#endif
953 {
edd309b7 954 Netdb_net_t net;
f7937171
JH
955 PL_reentrant_buffer->_netent_size *= 2;
956 Renew(PL_reentrant_buffer->_netent_buffer,
957 PL_reentrant_buffer->_netent_size, char);
edd309b7
JH
958 switch (PL_op->op_type) {
959 case OP_GNBYADDR:
960 net = va_arg(ap, Netdb_net_t);
961 anint = va_arg(ap, int);
962 retptr = getnetbyaddr(net, anint); break;
963 case OP_GNBYNAME:
964 p0 = va_arg(ap, void *);
f6f0b69b 965 retptr = getnetbyname((char *)p0); break;
edd309b7
JH
966 case OP_GNETENT:
967 retptr = getnetent(); break;
968 default:
0de8cad8 969 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
970 break;
971 }
972 }
973 }
974 break;
975#endif
f7937171 976#ifdef USE_PWENT_BUFFER
edd309b7
JH
977 case OP_GPWNAM:
978 case OP_GPWUID:
979 case OP_GPWENT:
980 {
af685957
JH
981#ifdef PERL_REENTRANT_MAXSIZE
982 if (PL_reentrant_buffer->_pwent_size <=
983 PERL_REENTRANT_MAXSIZE / 2)
984#endif
985 {
edd309b7 986 Uid_t uid;
f7937171
JH
987 PL_reentrant_buffer->_pwent_size *= 2;
988 Renew(PL_reentrant_buffer->_pwent_buffer,
989 PL_reentrant_buffer->_pwent_size, char);
edd309b7
JH
990 switch (PL_op->op_type) {
991 case OP_GPWNAM:
992 p0 = va_arg(ap, void *);
f6f0b69b 993 retptr = getpwnam((char *)p0); break;
edd309b7 994 case OP_GPWUID:
ab2b559b
JH
995#if Uid_t_size < INTSIZE
996 uid = (Uid_t)va_arg(ap, int);
997#else
edd309b7 998 uid = va_arg(ap, Uid_t);
ab2b559b 999#endif
edd309b7
JH
1000 retptr = getpwuid(uid); break;
1001 case OP_GPWENT:
1002 retptr = getpwent(); break;
1003 default:
0de8cad8 1004 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1005 break;
1006 }
1007 }
1008 }
1009 break;
1010#endif
f7937171 1011#ifdef USE_PROTOENT_BUFFER
edd309b7
JH
1012 case OP_GPBYNAME:
1013 case OP_GPBYNUMBER:
1014 case OP_GPROTOENT:
1015 {
af685957
JH
1016#ifdef PERL_REENTRANT_MAXSIZE
1017 if (PL_reentrant_buffer->_protoent_size <=
1018 PERL_REENTRANT_MAXSIZE / 2)
1019#endif
1020 {
f7937171
JH
1021 PL_reentrant_buffer->_protoent_size *= 2;
1022 Renew(PL_reentrant_buffer->_protoent_buffer,
1023 PL_reentrant_buffer->_protoent_size, char);
edd309b7
JH
1024 switch (PL_op->op_type) {
1025 case OP_GPBYNAME:
1026 p0 = va_arg(ap, void *);
f6f0b69b 1027 retptr = getprotobyname((char *)p0); break;
edd309b7
JH
1028 case OP_GPBYNUMBER:
1029 anint = va_arg(ap, int);
1030 retptr = getprotobynumber(anint); break;
1031 case OP_GPROTOENT:
1032 retptr = getprotoent(); break;
1033 default:
0de8cad8 1034 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1035 break;
1036 }
1037 }
1038 }
1039 break;
1040#endif
f7937171 1041#ifdef USE_SERVENT_BUFFER
edd309b7
JH
1042 case OP_GSBYNAME:
1043 case OP_GSBYPORT:
1044 case OP_GSERVENT:
1045 {
af685957
JH
1046#ifdef PERL_REENTRANT_MAXSIZE
1047 if (PL_reentrant_buffer->_servent_size <=
1048 PERL_REENTRANT_MAXSIZE / 2)
1049#endif
1050 {
f7937171
JH
1051 PL_reentrant_buffer->_servent_size *= 2;
1052 Renew(PL_reentrant_buffer->_servent_buffer,
1053 PL_reentrant_buffer->_servent_size, char);
edd309b7
JH
1054 switch (PL_op->op_type) {
1055 case OP_GSBYNAME:
1056 p0 = va_arg(ap, void *);
1057 p1 = va_arg(ap, void *);
f6f0b69b 1058 retptr = getservbyname((char *)p0, (char *)p1); break;
edd309b7
JH
1059 case OP_GSBYPORT:
1060 anint = va_arg(ap, int);
1061 p0 = va_arg(ap, void *);
f6f0b69b 1062 retptr = getservbyport(anint, (char *)p0); break;
edd309b7
JH
1063 case OP_GSERVENT:
1064 retptr = getservent(); break;
1065 default:
0de8cad8 1066 SETERRNO(ERANGE, LIB_INVARG);
edd309b7
JH
1067 break;
1068 }
1069 }
1070 }
1071 break;
1072#endif
1073 default:
1074 /* Not known how to retry, so just fail. */
1075 break;
1076 }
1077
1078 va_end(ap);
6148ee25
SP
1079#else
1080 PERL_UNUSED_ARG(f);
edd309b7
JH
1081#endif
1082 return retptr;
1083}
1084
37442d52 1085/* ex: set ro: */
10bc17b6
JH
1086EOF
1087
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
1120gmtime T |time |struct tm |S_TS|I_TS|T=const time_t*
1121localtime T |time |struct tm |S_TS|I_TS|T=const time_t*
a845a0d4 1122random |stdlib |struct random_data|I_iS|I_lS|I_St|i=int*|l=long*|t=int32_t*
10bc17b6
JH
1123readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
1124readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
1125setgrent |grp | |I_H|V_H
1126sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
1127setlocale IC |locale | |I_ICBI
1128setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
1129setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
1130setpwent |pwd | |I_H|V_H
1131setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
1132srand48 L |stdlib |struct drand48_data |I_LS
1133srandom T |stdlib |struct random_data|I_TS|T=unsigned int
1134strerror I |string | |I_IBW|I_IBI|B_IBW
1135tmpnam B |stdio | |B_B
1136ttyname I |unistd | |I_IBW|I_IBI|B_IBI