Improve and restructure t/op/pat.t and split out some unicode related tests into...
[p5sagit/p5-mst-13.2.git] / reentr.c
CommitLineData
37442d52 1/* -*- buffer-read-only: t -*-
2 *
10bc17b6 3 * reentr.c
4 *
922adc66 5 * Copyright (C) 2002, 2003, 2005, 2006, 2007 by Larry Wall and others
10bc17b6 6 *
7 * You may distribute under the terms of either the GNU General Public
8 * License or the Artistic License, as specified in the README file.
9 *
10 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
61296642 11 * This file is built by reentr.pl from data in reentr.pl.
10bc17b6 12 *
13 * "Saruman," I said, standing away from him, "only one hand at a time can
14 * wield the One, and you know that well, so do not trouble to say we!"
15 *
61296642 16 * This file contains a collection of automatically created wrappers
17 * (created by running reentr.pl) for reentrant (thread-safe) versions of
18 * various library calls, such as getpwent_r. The wrapping is done so
19 * that other files like pp_sys.c calling those library functions need not
20 * care about the differences between various platforms' idiosyncrasies
21 * regarding these reentrant interfaces.
10bc17b6 22 */
23
24#include "EXTERN.h"
25#define PERL_IN_REENTR_C
26#include "perl.h"
27#include "reentr.h"
28
29void
30Perl_reentrant_size(pTHX) {
31#ifdef USE_REENTRANT_API
8695fa85 32#define REENTRANTSMALLSIZE 256 /* Make something up. */
33#define REENTRANTUSUALSIZE 4096 /* Make something up. */
10bc17b6 34#ifdef HAS_ASCTIME_R
8695fa85 35 PL_reentrant_buffer->_asctime_size = REENTRANTSMALLSIZE;
10bc17b6 36#endif /* HAS_ASCTIME_R */
37#ifdef HAS_CRYPT_R
38#endif /* HAS_CRYPT_R */
39#ifdef HAS_CTIME_R
8695fa85 40 PL_reentrant_buffer->_ctime_size = REENTRANTSMALLSIZE;
10bc17b6 41#endif /* HAS_CTIME_R */
42#ifdef HAS_DRAND48_R
43#endif /* HAS_DRAND48_R */
44#ifdef HAS_GETGRNAM_R
0de8cad8 45# if defined(HAS_SYSCONF) && defined(_SC_GETGR_R_SIZE_MAX) && !defined(__GLIBC__)
46 PL_reentrant_buffer->_grent_size = sysconf(_SC_GETGR_R_SIZE_MAX);
a3dd3f83 47 if (PL_reentrant_buffer->_grent_size == (size_t) -1)
0de8cad8 48 PL_reentrant_buffer->_grent_size = REENTRANTUSUALSIZE;
10bc17b6 49# else
50# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
f7937171 51 PL_reentrant_buffer->_grent_size = SIABUFSIZ;
10bc17b6 52# else
53# ifdef __sgi
f7937171 54 PL_reentrant_buffer->_grent_size = BUFSIZ;
10bc17b6 55# else
f7937171 56 PL_reentrant_buffer->_grent_size = REENTRANTUSUALSIZE;
10bc17b6 57# endif
58# endif
59# endif
60#endif /* HAS_GETGRNAM_R */
61#ifdef HAS_GETHOSTBYNAME_R
62#if !(GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
f7937171 63 PL_reentrant_buffer->_hostent_size = REENTRANTUSUALSIZE;
10bc17b6 64#endif
65#endif /* HAS_GETHOSTBYNAME_R */
66#ifdef HAS_GETLOGIN_R
8695fa85 67 PL_reentrant_buffer->_getlogin_size = REENTRANTSMALLSIZE;
10bc17b6 68#endif /* HAS_GETLOGIN_R */
69#ifdef HAS_GETNETBYNAME_R
70#if !(GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
f7937171 71 PL_reentrant_buffer->_netent_size = REENTRANTUSUALSIZE;
10bc17b6 72#endif
73#endif /* HAS_GETNETBYNAME_R */
74#ifdef HAS_GETPROTOBYNAME_R
75#if !(GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
f7937171 76 PL_reentrant_buffer->_protoent_size = REENTRANTUSUALSIZE;
10bc17b6 77#endif
78#endif /* HAS_GETPROTOBYNAME_R */
79#ifdef HAS_GETPWNAM_R
80# if defined(HAS_SYSCONF) && defined(_SC_GETPW_R_SIZE_MAX) && !defined(__GLIBC__)
f7937171 81 PL_reentrant_buffer->_pwent_size = sysconf(_SC_GETPW_R_SIZE_MAX);
a3dd3f83 82 if (PL_reentrant_buffer->_pwent_size == (size_t) -1)
f7937171 83 PL_reentrant_buffer->_pwent_size = REENTRANTUSUALSIZE;
10bc17b6 84# else
85# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
f7937171 86 PL_reentrant_buffer->_pwent_size = SIABUFSIZ;
10bc17b6 87# else
88# ifdef __sgi
f7937171 89 PL_reentrant_buffer->_pwent_size = BUFSIZ;
10bc17b6 90# else
f7937171 91 PL_reentrant_buffer->_pwent_size = REENTRANTUSUALSIZE;
10bc17b6 92# endif
93# endif
94# endif
95#endif /* HAS_GETPWNAM_R */
96#ifdef HAS_GETSERVBYNAME_R
97#if !(GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD)
f7937171 98 PL_reentrant_buffer->_servent_size = REENTRANTUSUALSIZE;
10bc17b6 99#endif
100#endif /* HAS_GETSERVBYNAME_R */
101#ifdef HAS_GETSPNAM_R
f7937171 102# if defined(HAS_SYSCONF) && defined(_SC_GETPW_R_SIZE_MAX) && !defined(__GLIBC__)
103 PL_reentrant_buffer->_spent_size = sysconf(_SC_GETPW_R_SIZE_MAX);
a3dd3f83 104 if (PL_reentrant_buffer->_spent_size == (size_t) -1)
0de8cad8 105 PL_reentrant_buffer->_spent_size = REENTRANTUSUALSIZE;
f7937171 106# else
107# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
108 PL_reentrant_buffer->_spent_size = SIABUFSIZ;
109# else
110# ifdef __sgi
111 PL_reentrant_buffer->_spent_size = BUFSIZ;
112# else
113 PL_reentrant_buffer->_spent_size = REENTRANTUSUALSIZE;
114# endif
115# endif
116# endif
10bc17b6 117#endif /* HAS_GETSPNAM_R */
118#ifdef HAS_GMTIME_R
119#endif /* HAS_GMTIME_R */
120#ifdef HAS_LOCALTIME_R
121#endif /* HAS_LOCALTIME_R */
122#ifdef HAS_RANDOM_R
123#endif /* HAS_RANDOM_R */
124#ifdef HAS_READDIR_R
125 /* This is the size Solaris recommends.
126 * (though we go static, should use pathconf() instead) */
127 PL_reentrant_buffer->_readdir_size = sizeof(struct dirent) + MAXPATHLEN + 1;
128#endif /* HAS_READDIR_R */
129#ifdef HAS_READDIR64_R
130 /* This is the size Solaris recommends.
131 * (though we go static, should use pathconf() instead) */
132 PL_reentrant_buffer->_readdir64_size = sizeof(struct dirent64) + MAXPATHLEN + 1;
133#endif /* HAS_READDIR64_R */
134#ifdef HAS_SETLOCALE_R
8695fa85 135 PL_reentrant_buffer->_setlocale_size = REENTRANTSMALLSIZE;
10bc17b6 136#endif /* HAS_SETLOCALE_R */
5cb13b8d 137#ifdef HAS_SRANDOM_R
138#endif /* HAS_SRANDOM_R */
10bc17b6 139#ifdef HAS_STRERROR_R
8695fa85 140 PL_reentrant_buffer->_strerror_size = REENTRANTSMALLSIZE;
10bc17b6 141#endif /* HAS_STRERROR_R */
142#ifdef HAS_TTYNAME_R
8695fa85 143 PL_reentrant_buffer->_ttyname_size = REENTRANTSMALLSIZE;
10bc17b6 144#endif /* HAS_TTYNAME_R */
145
146#endif /* USE_REENTRANT_API */
147}
148
149void
150Perl_reentrant_init(pTHX) {
151#ifdef USE_REENTRANT_API
a02a5408 152 Newx(PL_reentrant_buffer, 1, REENTR);
10bc17b6 153 Perl_reentrant_size(aTHX);
154#ifdef HAS_ASCTIME_R
a02a5408 155 Newx(PL_reentrant_buffer->_asctime_buffer, PL_reentrant_buffer->_asctime_size, char);
10bc17b6 156#endif /* HAS_ASCTIME_R */
157#ifdef HAS_CRYPT_R
05404ffe 158#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
159 PL_reentrant_buffer->_crypt_struct_buffer = 0;
10bc17b6 160#endif
161#endif /* HAS_CRYPT_R */
162#ifdef HAS_CTIME_R
a02a5408 163 Newx(PL_reentrant_buffer->_ctime_buffer, PL_reentrant_buffer->_ctime_size, char);
10bc17b6 164#endif /* HAS_CTIME_R */
165#ifdef HAS_DRAND48_R
166#endif /* HAS_DRAND48_R */
167#ifdef HAS_GETGRNAM_R
f7937171 168# ifdef USE_GRENT_FPTR
169 PL_reentrant_buffer->_grent_fptr = NULL;
10bc17b6 170# endif
a02a5408 171 Newx(PL_reentrant_buffer->_grent_buffer, PL_reentrant_buffer->_grent_size, char);
10bc17b6 172#endif /* HAS_GETGRNAM_R */
173#ifdef HAS_GETHOSTBYNAME_R
174#if !(GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
a02a5408 175 Newx(PL_reentrant_buffer->_hostent_buffer, PL_reentrant_buffer->_hostent_size, char);
10bc17b6 176#endif
177#endif /* HAS_GETHOSTBYNAME_R */
178#ifdef HAS_GETLOGIN_R
a02a5408 179 Newx(PL_reentrant_buffer->_getlogin_buffer, PL_reentrant_buffer->_getlogin_size, char);
10bc17b6 180#endif /* HAS_GETLOGIN_R */
181#ifdef HAS_GETNETBYNAME_R
182#if !(GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
a02a5408 183 Newx(PL_reentrant_buffer->_netent_buffer, PL_reentrant_buffer->_netent_size, char);
10bc17b6 184#endif
185#endif /* HAS_GETNETBYNAME_R */
186#ifdef HAS_GETPROTOBYNAME_R
187#if !(GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
a02a5408 188 Newx(PL_reentrant_buffer->_protoent_buffer, PL_reentrant_buffer->_protoent_size, char);
10bc17b6 189#endif
190#endif /* HAS_GETPROTOBYNAME_R */
191#ifdef HAS_GETPWNAM_R
f7937171 192# ifdef USE_PWENT_FPTR
193 PL_reentrant_buffer->_pwent_fptr = NULL;
10bc17b6 194# endif
a02a5408 195 Newx(PL_reentrant_buffer->_pwent_buffer, PL_reentrant_buffer->_pwent_size, char);
10bc17b6 196#endif /* HAS_GETPWNAM_R */
197#ifdef HAS_GETSERVBYNAME_R
198#if !(GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD)
a02a5408 199 Newx(PL_reentrant_buffer->_servent_buffer, PL_reentrant_buffer->_servent_size, char);
10bc17b6 200#endif
201#endif /* HAS_GETSERVBYNAME_R */
202#ifdef HAS_GETSPNAM_R
f7937171 203# ifdef USE_SPENT_FPTR
204 PL_reentrant_buffer->_spent_fptr = NULL;
205# endif
a02a5408 206 Newx(PL_reentrant_buffer->_spent_buffer, PL_reentrant_buffer->_spent_size, char);
10bc17b6 207#endif /* HAS_GETSPNAM_R */
208#ifdef HAS_GMTIME_R
209#endif /* HAS_GMTIME_R */
210#ifdef HAS_LOCALTIME_R
211#endif /* HAS_LOCALTIME_R */
212#ifdef HAS_RANDOM_R
213#endif /* HAS_RANDOM_R */
214#ifdef HAS_READDIR_R
215 PL_reentrant_buffer->_readdir_struct = (struct dirent*)safemalloc(PL_reentrant_buffer->_readdir_size);
216#endif /* HAS_READDIR_R */
217#ifdef HAS_READDIR64_R
218 PL_reentrant_buffer->_readdir64_struct = (struct dirent64*)safemalloc(PL_reentrant_buffer->_readdir64_size);
219#endif /* HAS_READDIR64_R */
220#ifdef HAS_SETLOCALE_R
a02a5408 221 Newx(PL_reentrant_buffer->_setlocale_buffer, PL_reentrant_buffer->_setlocale_size, char);
10bc17b6 222#endif /* HAS_SETLOCALE_R */
5cb13b8d 223#ifdef HAS_SRANDOM_R
224#endif /* HAS_SRANDOM_R */
10bc17b6 225#ifdef HAS_STRERROR_R
a02a5408 226 Newx(PL_reentrant_buffer->_strerror_buffer, PL_reentrant_buffer->_strerror_size, char);
10bc17b6 227#endif /* HAS_STRERROR_R */
228#ifdef HAS_TTYNAME_R
a02a5408 229 Newx(PL_reentrant_buffer->_ttyname_buffer, PL_reentrant_buffer->_ttyname_size, char);
10bc17b6 230#endif /* HAS_TTYNAME_R */
231
232#endif /* USE_REENTRANT_API */
233}
234
235void
236Perl_reentrant_free(pTHX) {
237#ifdef USE_REENTRANT_API
238#ifdef HAS_ASCTIME_R
239 Safefree(PL_reentrant_buffer->_asctime_buffer);
240#endif /* HAS_ASCTIME_R */
241#ifdef HAS_CRYPT_R
05404ffe 242#if CRYPT_R_PROTO != REENTRANT_PROTO_B_CCD
243 Safefree(PL_reentrant_buffer->_crypt_struct_buffer);
244#endif
10bc17b6 245#endif /* HAS_CRYPT_R */
246#ifdef HAS_CTIME_R
247 Safefree(PL_reentrant_buffer->_ctime_buffer);
248#endif /* HAS_CTIME_R */
249#ifdef HAS_DRAND48_R
250#endif /* HAS_DRAND48_R */
251#ifdef HAS_GETGRNAM_R
f7937171 252 Safefree(PL_reentrant_buffer->_grent_buffer);
10bc17b6 253#endif /* HAS_GETGRNAM_R */
254#ifdef HAS_GETHOSTBYNAME_R
255#if !(GETHOSTBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
f7937171 256 Safefree(PL_reentrant_buffer->_hostent_buffer);
10bc17b6 257#endif
258#endif /* HAS_GETHOSTBYNAME_R */
259#ifdef HAS_GETLOGIN_R
260 Safefree(PL_reentrant_buffer->_getlogin_buffer);
261#endif /* HAS_GETLOGIN_R */
262#ifdef HAS_GETNETBYNAME_R
263#if !(GETNETBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
f7937171 264 Safefree(PL_reentrant_buffer->_netent_buffer);
10bc17b6 265#endif
266#endif /* HAS_GETNETBYNAME_R */
267#ifdef HAS_GETPROTOBYNAME_R
268#if !(GETPROTOBYNAME_R_PROTO == REENTRANT_PROTO_I_CSD)
f7937171 269 Safefree(PL_reentrant_buffer->_protoent_buffer);
10bc17b6 270#endif
271#endif /* HAS_GETPROTOBYNAME_R */
272#ifdef HAS_GETPWNAM_R
f7937171 273 Safefree(PL_reentrant_buffer->_pwent_buffer);
10bc17b6 274#endif /* HAS_GETPWNAM_R */
275#ifdef HAS_GETSERVBYNAME_R
276#if !(GETSERVBYNAME_R_PROTO == REENTRANT_PROTO_I_CCSD)
f7937171 277 Safefree(PL_reentrant_buffer->_servent_buffer);
10bc17b6 278#endif
279#endif /* HAS_GETSERVBYNAME_R */
280#ifdef HAS_GETSPNAM_R
f7937171 281 Safefree(PL_reentrant_buffer->_spent_buffer);
10bc17b6 282#endif /* HAS_GETSPNAM_R */
283#ifdef HAS_GMTIME_R
284#endif /* HAS_GMTIME_R */
285#ifdef HAS_LOCALTIME_R
286#endif /* HAS_LOCALTIME_R */
287#ifdef HAS_RANDOM_R
288#endif /* HAS_RANDOM_R */
289#ifdef HAS_READDIR_R
290 Safefree(PL_reentrant_buffer->_readdir_struct);
291#endif /* HAS_READDIR_R */
292#ifdef HAS_READDIR64_R
293 Safefree(PL_reentrant_buffer->_readdir64_struct);
294#endif /* HAS_READDIR64_R */
295#ifdef HAS_SETLOCALE_R
296 Safefree(PL_reentrant_buffer->_setlocale_buffer);
297#endif /* HAS_SETLOCALE_R */
5cb13b8d 298#ifdef HAS_SRANDOM_R
299#endif /* HAS_SRANDOM_R */
10bc17b6 300#ifdef HAS_STRERROR_R
301 Safefree(PL_reentrant_buffer->_strerror_buffer);
302#endif /* HAS_STRERROR_R */
303#ifdef HAS_TTYNAME_R
304 Safefree(PL_reentrant_buffer->_ttyname_buffer);
305#endif /* HAS_TTYNAME_R */
306
307 Safefree(PL_reentrant_buffer);
308#endif /* USE_REENTRANT_API */
309}
310
edd309b7 311void*
312Perl_reentrant_retry(const char *f, ...)
313{
abb2c242 314 dTHX;
edd309b7 315 void *retptr = NULL;
fe5bfecd 316 va_list ap;
7918f24d 317#ifdef USE_REENTRANT_API
318 /* Easier to special case this here than in embed.pl. (Look at what it
319 generates for proto.h) */
320 PERL_ARGS_ASSERT_REENTRANT_RETRY;
321#endif
fe5bfecd 322 va_start(ap, f);
369ec4b2 323 {
edd309b7 324#ifdef USE_REENTRANT_API
0891a229 325# 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 326 void *p0;
327# endif
f7937171 328# if defined(USE_SERVENT_BUFFER)
e3410746 329 void *p1;
330# endif
f7937171 331# if defined(USE_HOSTENT_BUFFER)
edd309b7 332 size_t asize;
e3410746 333# endif
f7937171 334# if defined(USE_HOSTENT_BUFFER) || defined(USE_NETENT_BUFFER) || defined(USE_PROTOENT_BUFFER) || defined(USE_SERVENT_BUFFER)
edd309b7 335 int anint;
e3410746 336# endif
edd309b7 337
edd309b7 338 switch (PL_op->op_type) {
f7937171 339#ifdef USE_HOSTENT_BUFFER
edd309b7 340 case OP_GHBYADDR:
341 case OP_GHBYNAME:
342 case OP_GHOSTENT:
343 {
af685957 344#ifdef PERL_REENTRANT_MAXSIZE
345 if (PL_reentrant_buffer->_hostent_size <=
346 PERL_REENTRANT_MAXSIZE / 2)
347#endif
348 {
f7937171 349 PL_reentrant_buffer->_hostent_size *= 2;
350 Renew(PL_reentrant_buffer->_hostent_buffer,
351 PL_reentrant_buffer->_hostent_size, char);
edd309b7 352 switch (PL_op->op_type) {
353 case OP_GHBYADDR:
354 p0 = va_arg(ap, void *);
355 asize = va_arg(ap, size_t);
356 anint = va_arg(ap, int);
357 retptr = gethostbyaddr(p0, asize, anint); break;
358 case OP_GHBYNAME:
359 p0 = va_arg(ap, void *);
f6f0b69b 360 retptr = gethostbyname((char *)p0); break;
edd309b7 361 case OP_GHOSTENT:
362 retptr = gethostent(); break;
363 default:
0de8cad8 364 SETERRNO(ERANGE, LIB_INVARG);
edd309b7 365 break;
366 }
367 }
368 }
369 break;
370#endif
f7937171 371#ifdef USE_GRENT_BUFFER
edd309b7 372 case OP_GGRNAM:
373 case OP_GGRGID:
374 case OP_GGRENT:
375 {
af685957 376#ifdef PERL_REENTRANT_MAXSIZE
377 if (PL_reentrant_buffer->_grent_size <=
378 PERL_REENTRANT_MAXSIZE / 2)
379#endif
380 {
edd309b7 381 Gid_t gid;
f7937171 382 PL_reentrant_buffer->_grent_size *= 2;
383 Renew(PL_reentrant_buffer->_grent_buffer,
384 PL_reentrant_buffer->_grent_size, char);
edd309b7 385 switch (PL_op->op_type) {
386 case OP_GGRNAM:
387 p0 = va_arg(ap, void *);
f6f0b69b 388 retptr = getgrnam((char *)p0); break;
edd309b7 389 case OP_GGRGID:
ab2b559b 390#if Gid_t_size < INTSIZE
391 gid = (Gid_t)va_arg(ap, int);
392#else
edd309b7 393 gid = va_arg(ap, Gid_t);
ab2b559b 394#endif
edd309b7 395 retptr = getgrgid(gid); break;
396 case OP_GGRENT:
397 retptr = getgrent(); break;
398 default:
0de8cad8 399 SETERRNO(ERANGE, LIB_INVARG);
edd309b7 400 break;
401 }
402 }
403 }
404 break;
405#endif
f7937171 406#ifdef USE_NETENT_BUFFER
edd309b7 407 case OP_GNBYADDR:
408 case OP_GNBYNAME:
409 case OP_GNETENT:
410 {
af685957 411#ifdef PERL_REENTRANT_MAXSIZE
412 if (PL_reentrant_buffer->_netent_size <=
413 PERL_REENTRANT_MAXSIZE / 2)
414#endif
415 {
edd309b7 416 Netdb_net_t net;
f7937171 417 PL_reentrant_buffer->_netent_size *= 2;
418 Renew(PL_reentrant_buffer->_netent_buffer,
419 PL_reentrant_buffer->_netent_size, char);
edd309b7 420 switch (PL_op->op_type) {
421 case OP_GNBYADDR:
422 net = va_arg(ap, Netdb_net_t);
423 anint = va_arg(ap, int);
424 retptr = getnetbyaddr(net, anint); break;
425 case OP_GNBYNAME:
426 p0 = va_arg(ap, void *);
f6f0b69b 427 retptr = getnetbyname((char *)p0); break;
edd309b7 428 case OP_GNETENT:
429 retptr = getnetent(); break;
430 default:
0de8cad8 431 SETERRNO(ERANGE, LIB_INVARG);
edd309b7 432 break;
433 }
434 }
435 }
436 break;
437#endif
f7937171 438#ifdef USE_PWENT_BUFFER
edd309b7 439 case OP_GPWNAM:
440 case OP_GPWUID:
441 case OP_GPWENT:
442 {
af685957 443#ifdef PERL_REENTRANT_MAXSIZE
444 if (PL_reentrant_buffer->_pwent_size <=
445 PERL_REENTRANT_MAXSIZE / 2)
446#endif
447 {
edd309b7 448 Uid_t uid;
f7937171 449 PL_reentrant_buffer->_pwent_size *= 2;
450 Renew(PL_reentrant_buffer->_pwent_buffer,
451 PL_reentrant_buffer->_pwent_size, char);
edd309b7 452 switch (PL_op->op_type) {
453 case OP_GPWNAM:
454 p0 = va_arg(ap, void *);
f6f0b69b 455 retptr = getpwnam((char *)p0); break;
edd309b7 456 case OP_GPWUID:
ab2b559b 457#if Uid_t_size < INTSIZE
458 uid = (Uid_t)va_arg(ap, int);
459#else
edd309b7 460 uid = va_arg(ap, Uid_t);
ab2b559b 461#endif
edd309b7 462 retptr = getpwuid(uid); break;
463 case OP_GPWENT:
464 retptr = getpwent(); break;
465 default:
0de8cad8 466 SETERRNO(ERANGE, LIB_INVARG);
edd309b7 467 break;
468 }
469 }
470 }
471 break;
472#endif
f7937171 473#ifdef USE_PROTOENT_BUFFER
edd309b7 474 case OP_GPBYNAME:
475 case OP_GPBYNUMBER:
476 case OP_GPROTOENT:
477 {
af685957 478#ifdef PERL_REENTRANT_MAXSIZE
479 if (PL_reentrant_buffer->_protoent_size <=
480 PERL_REENTRANT_MAXSIZE / 2)
481#endif
482 {
f7937171 483 PL_reentrant_buffer->_protoent_size *= 2;
484 Renew(PL_reentrant_buffer->_protoent_buffer,
485 PL_reentrant_buffer->_protoent_size, char);
edd309b7 486 switch (PL_op->op_type) {
487 case OP_GPBYNAME:
488 p0 = va_arg(ap, void *);
f6f0b69b 489 retptr = getprotobyname((char *)p0); break;
edd309b7 490 case OP_GPBYNUMBER:
491 anint = va_arg(ap, int);
492 retptr = getprotobynumber(anint); break;
493 case OP_GPROTOENT:
494 retptr = getprotoent(); break;
495 default:
0de8cad8 496 SETERRNO(ERANGE, LIB_INVARG);
edd309b7 497 break;
498 }
499 }
500 }
501 break;
502#endif
f7937171 503#ifdef USE_SERVENT_BUFFER
edd309b7 504 case OP_GSBYNAME:
505 case OP_GSBYPORT:
506 case OP_GSERVENT:
507 {
af685957 508#ifdef PERL_REENTRANT_MAXSIZE
509 if (PL_reentrant_buffer->_servent_size <=
510 PERL_REENTRANT_MAXSIZE / 2)
511#endif
512 {
f7937171 513 PL_reentrant_buffer->_servent_size *= 2;
514 Renew(PL_reentrant_buffer->_servent_buffer,
515 PL_reentrant_buffer->_servent_size, char);
edd309b7 516 switch (PL_op->op_type) {
517 case OP_GSBYNAME:
518 p0 = va_arg(ap, void *);
519 p1 = va_arg(ap, void *);
f6f0b69b 520 retptr = getservbyname((char *)p0, (char *)p1); break;
edd309b7 521 case OP_GSBYPORT:
522 anint = va_arg(ap, int);
523 p0 = va_arg(ap, void *);
f6f0b69b 524 retptr = getservbyport(anint, (char *)p0); break;
edd309b7 525 case OP_GSERVENT:
526 retptr = getservent(); break;
527 default:
0de8cad8 528 SETERRNO(ERANGE, LIB_INVARG);
edd309b7 529 break;
530 }
531 }
532 }
533 break;
534#endif
535 default:
536 /* Not known how to retry, so just fail. */
537 break;
538 }
6148ee25 539#else
540 PERL_UNUSED_ARG(f);
edd309b7 541#endif
369ec4b2 542 }
fe5bfecd 543 va_end(ap);
edd309b7 544 return retptr;
545}
546
37442d52 547/* ex: set ro: */