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