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