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