This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Ensure that constant folding runs with IN_PERL_RUNTIME true, by copying
[perl5.git] / iperlsys.h
CommitLineData
0f4eea8f
DL
1/*
2 * iperlsys.h - Perl's interface to the system
3 *
4 * This file defines the system level functionality that perl needs.
5 *
6 * When using C, this definition is in the form of a set of macros
7 * that can be #defined to the system-level function (or a wrapper
8 * provided elsewhere).
9 *
0f4eea8f
DL
10 * GSAR 21-JUN-98
11 */
12
13#ifndef __Inc__IPerl___
14#define __Inc__IPerl___
15
16/*
17 * PerlXXX_YYY explained - DickH and DougL @ ActiveState.com
18 *
19 * XXX := functional group
20 * YYY := stdlib/OS function name
21 *
22 * Continuing with the theme of PerlIO, all OS functionality was
23 * encapsulated into one of several interfaces.
24 *
25 * PerlIO - stdio
26 * PerlLIO - low level I/O
27 * PerlMem - malloc, realloc, free
28 * PerlDir - directory related
29 * PerlEnv - process environment handling
30 * PerlProc - process control
31 * PerlSock - socket functions
32 *
33 *
34 * The features of this are:
35 * 1. All OS dependant code is in the Perl Host and not the Perl Core.
36 * (At least this is the holy grail goal of this work)
37 * 2. The Perl Host (see perl.h for description) can provide a new and
38 * improved interface to OS functionality if required.
39 * 3. Developers can easily hook into the OS calls for instrumentation
40 * or diagnostic purposes.
41 *
42 * What was changed to do this:
43 * 1. All calls to OS functions were replaced with PerlXXX_YYY
44 *
45 */
46
0f4eea8f 47/*
76ced9ad
NIS
48 Interface for perl stdio functions, or whatever we are Configure-d
49 to use.
0f4eea8f 50*/
76ced9ad 51#include "perlio.h"
0f4eea8f 52
d543acb6 53#ifndef Sighandler_t
8aad04aa 54# if defined(HAS_SIGACTION) && defined(SA_SIGINFO)
80626cf1 55typedef Signal_t (*Sighandler_t) (int, siginfo_t*, void*);
8aad04aa 56# else
d543acb6 57typedef Signal_t (*Sighandler_t) (int);
8aad04aa 58# endif
d543acb6
GS
59#endif
60
c5be433b 61#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 62
0cb96387
GS
63/* IPerlStdIO */
64struct IPerlStdIO;
7766f137 65struct IPerlStdIOInfo;
eaf8b698
NIS
66typedef FILE* (*LPStdin)(struct IPerlStdIO*);
67typedef FILE* (*LPStdout)(struct IPerlStdIO*);
68typedef FILE* (*LPStderr)(struct IPerlStdIO*);
69typedef FILE* (*LPOpen)(struct IPerlStdIO*, const char*,
0cb96387 70 const char*);
eaf8b698
NIS
71typedef int (*LPClose)(struct IPerlStdIO*, FILE*);
72typedef int (*LPEof)(struct IPerlStdIO*, FILE*);
73typedef int (*LPError)(struct IPerlStdIO*, FILE*);
74typedef void (*LPClearerr)(struct IPerlStdIO*, FILE*);
75typedef int (*LPGetc)(struct IPerlStdIO*, FILE*);
76typedef char* (*LPGetBase)(struct IPerlStdIO*, FILE*);
77typedef int (*LPGetBufsiz)(struct IPerlStdIO*, FILE*);
78typedef int (*LPGetCnt)(struct IPerlStdIO*, FILE*);
79typedef char* (*LPGetPtr)(struct IPerlStdIO*, FILE*);
80typedef char* (*LPGets)(struct IPerlStdIO*, FILE*, char*, int);
81typedef int (*LPPutc)(struct IPerlStdIO*, FILE*, int);
82typedef int (*LPPuts)(struct IPerlStdIO*, FILE*, const char*);
83typedef int (*LPFlush)(struct IPerlStdIO*, FILE*);
adb71456 84typedef int (*LPUngetc)(struct IPerlStdIO*, int,FILE*);
eaf8b698
NIS
85typedef int (*LPFileno)(struct IPerlStdIO*, FILE*);
86typedef FILE* (*LPFdopen)(struct IPerlStdIO*, int, const char*);
87typedef FILE* (*LPReopen)(struct IPerlStdIO*, const char*,
88 const char*, FILE*);
adb71456
NIS
89typedef SSize_t (*LPRead)(struct IPerlStdIO*, void*, Size_t, Size_t, FILE *);
90typedef SSize_t (*LPWrite)(struct IPerlStdIO*, const void*, Size_t, Size_t, FILE *);
eaf8b698
NIS
91typedef void (*LPSetBuf)(struct IPerlStdIO*, FILE*, char*);
92typedef int (*LPSetVBuf)(struct IPerlStdIO*, FILE*, char*, int,
0cb96387 93 Size_t);
eaf8b698 94typedef void (*LPSetCnt)(struct IPerlStdIO*, FILE*, int);
011f1a1a
JH
95
96#ifndef NETWARE
adb71456 97typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*);
011f1a1a
JH
98#elif defined(NETWARE)
99typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*, int);
100#endif
101
eaf8b698
NIS
102typedef void (*LPSetlinebuf)(struct IPerlStdIO*, FILE*);
103typedef int (*LPPrintf)(struct IPerlStdIO*, FILE*, const char*,
0cb96387 104 ...);
eaf8b698 105typedef int (*LPVprintf)(struct IPerlStdIO*, FILE*, const char*,
0cb96387 106 va_list);
c623ac67 107typedef Off_t (*LPTell)(struct IPerlStdIO*, FILE*);
eaf8b698
NIS
108typedef int (*LPSeek)(struct IPerlStdIO*, FILE*, Off_t, int);
109typedef void (*LPRewind)(struct IPerlStdIO*, FILE*);
110typedef FILE* (*LPTmpfile)(struct IPerlStdIO*);
111typedef int (*LPGetpos)(struct IPerlStdIO*, FILE*, Fpos_t*);
112typedef int (*LPSetpos)(struct IPerlStdIO*, FILE*,
0cb96387
GS
113 const Fpos_t*);
114typedef void (*LPInit)(struct IPerlStdIO*);
115typedef void (*LPInitOSExtras)(struct IPerlStdIO*);
eaf8b698 116typedef FILE* (*LPFdupopen)(struct IPerlStdIO*, FILE*);
0cb96387
GS
117
118struct IPerlStdIO
0f4eea8f 119{
0cb96387
GS
120 LPStdin pStdin;
121 LPStdout pStdout;
122 LPStderr pStderr;
123 LPOpen pOpen;
124 LPClose pClose;
125 LPEof pEof;
126 LPError pError;
127 LPClearerr pClearerr;
128 LPGetc pGetc;
129 LPGetBase pGetBase;
130 LPGetBufsiz pGetBufsiz;
131 LPGetCnt pGetCnt;
132 LPGetPtr pGetPtr;
133 LPGets pGets;
134 LPPutc pPutc;
135 LPPuts pPuts;
136 LPFlush pFlush;
137 LPUngetc pUngetc;
138 LPFileno pFileno;
139 LPFdopen pFdopen;
140 LPReopen pReopen;
141 LPRead pRead;
142 LPWrite pWrite;
143 LPSetBuf pSetBuf;
144 LPSetVBuf pSetVBuf;
145 LPSetCnt pSetCnt;
adb71456 146 LPSetPtr pSetPtr;
0cb96387
GS
147 LPSetlinebuf pSetlinebuf;
148 LPPrintf pPrintf;
149 LPVprintf pVprintf;
150 LPTell pTell;
151 LPSeek pSeek;
152 LPRewind pRewind;
153 LPTmpfile pTmpfile;
154 LPGetpos pGetpos;
155 LPSetpos pSetpos;
156 LPInit pInit;
157 LPInitOSExtras pInitOSExtras;
7766f137 158 LPFdupopen pFdupopen;
0f4eea8f
DL
159};
160
0cb96387
GS
161struct IPerlStdIOInfo
162{
163 unsigned long nCount; /* number of entries expected */
164 struct IPerlStdIO perlStdIOList;
165};
2bd2b9e0 166
76ced9ad
NIS
167/* These do not belong here ... NI-S, 14 Nov 2000 */
168
2bd2b9e0 169#ifdef USE_STDIO_PTR
eaf8b698 170# define PerlSIO_has_cntptr(f) 1
a7ffa9b9
NC
171# ifdef STDIO_PTR_LVALUE
172# ifdef STDIO_CNT_LVALUE
eaf8b698 173# define PerlSIO_canset_cnt(f) 1
a7ffa9b9 174# ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
eaf8b698 175# define PerlSIO_fast_gets(f) 1
a7ffa9b9
NC
176# endif
177# else /* STDIO_CNT_LVALUE */
eaf8b698 178# define PerlSIO_canset_cnt(f) 0
a7ffa9b9
NC
179# endif
180# else /* STDIO_PTR_LVALUE */
181# ifdef STDIO_PTR_LVAL_SETS_CNT
eaf8b698 182# define PerlSIO_fast_gets(f) 1
2bd2b9e0 183# endif
2bd2b9e0
GS
184# endif
185#else /* USE_STDIO_PTR */
eaf8b698
NIS
186# define PerlSIO_has_cntptr(f) 0
187# define PerlSIO_canset_cnt(f) 0
2bd2b9e0
GS
188#endif /* USE_STDIO_PTR */
189
eaf8b698
NIS
190#ifndef PerlSIO_fast_gets
191#define PerlSIO_fast_gets(f) 0
2bd2b9e0
GS
192#endif
193
194#ifdef FILE_base
eaf8b698 195#define PerlSIO_has_base(f) 1
2bd2b9e0 196#else
eaf8b698 197#define PerlSIO_has_base(f) 0
2bd2b9e0 198#endif
0f4eea8f 199
eaf8b698 200/* Now take FILE * via function table */
76ced9ad 201
eaf8b698 202#define PerlSIO_stdin \
51371543 203 (*PL_StdIO->pStdin)(PL_StdIO)
eaf8b698 204#define PerlSIO_stdout \
51371543 205 (*PL_StdIO->pStdout)(PL_StdIO)
eaf8b698 206#define PerlSIO_stderr \
51371543 207 (*PL_StdIO->pStderr)(PL_StdIO)
eaf8b698 208#define PerlSIO_fopen(x,y) \
51371543 209 (*PL_StdIO->pOpen)(PL_StdIO, (x),(y))
eaf8b698 210#define PerlSIO_fclose(f) \
51371543 211 (*PL_StdIO->pClose)(PL_StdIO, (f))
eaf8b698 212#define PerlSIO_feof(f) \
51371543 213 (*PL_StdIO->pEof)(PL_StdIO, (f))
eaf8b698 214#define PerlSIO_ferror(f) \
51371543 215 (*PL_StdIO->pError)(PL_StdIO, (f))
eaf8b698 216#define PerlSIO_clearerr(f) \
51371543 217 (*PL_StdIO->pClearerr)(PL_StdIO, (f))
eaf8b698 218#define PerlSIO_fgetc(f) \
51371543 219 (*PL_StdIO->pGetc)(PL_StdIO, (f))
eaf8b698 220#define PerlSIO_get_base(f) \
51371543 221 (*PL_StdIO->pGetBase)(PL_StdIO, (f))
eaf8b698 222#define PerlSIO_get_bufsiz(f) \
51371543 223 (*PL_StdIO->pGetBufsiz)(PL_StdIO, (f))
eaf8b698 224#define PerlSIO_get_cnt(f) \
51371543 225 (*PL_StdIO->pGetCnt)(PL_StdIO, (f))
eaf8b698 226#define PerlSIO_get_ptr(f) \
51371543 227 (*PL_StdIO->pGetPtr)(PL_StdIO, (f))
eaf8b698 228#define PerlSIO_fputc(f,c) \
51371543 229 (*PL_StdIO->pPutc)(PL_StdIO, (f),(c))
eaf8b698 230#define PerlSIO_fputs(f,s) \
51371543 231 (*PL_StdIO->pPuts)(PL_StdIO, (f),(s))
eaf8b698 232#define PerlSIO_fflush(f) \
51371543 233 (*PL_StdIO->pFlush)(PL_StdIO, (f))
eaf8b698 234#define PerlSIO_fgets(s, n, fp) \
51371543 235 (*PL_StdIO->pGets)(PL_StdIO, (fp), s, n)
adb71456
NIS
236#define PerlSIO_ungetc(c,f) \
237 (*PL_StdIO->pUngetc)(PL_StdIO, (c),(f))
eaf8b698 238#define PerlSIO_fileno(f) \
51371543 239 (*PL_StdIO->pFileno)(PL_StdIO, (f))
eaf8b698 240#define PerlSIO_fdopen(f, s) \
51371543 241 (*PL_StdIO->pFdopen)(PL_StdIO, (f),(s))
eaf8b698 242#define PerlSIO_freopen(p, m, f) \
51371543 243 (*PL_StdIO->pReopen)(PL_StdIO, (p), (m), (f))
eaf8b698 244#define PerlSIO_fread(buf,sz,count,f) \
adb71456
NIS
245 (*PL_StdIO->pRead)(PL_StdIO, (buf), (sz), (count), (f))
246#define PerlSIO_fwrite(buf,sz,count,f) \
247 (*PL_StdIO->pWrite)(PL_StdIO, (buf), (sz), (count), (f))
eaf8b698 248#define PerlSIO_setbuf(f,b) \
51371543 249 (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b))
eaf8b698 250#define PerlSIO_setvbuf(f,b,t,s) \
51371543 251 (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s))
eaf8b698 252#define PerlSIO_set_cnt(f,c) \
51371543 253 (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c))
adb71456
NIS
254#define PerlSIO_set_ptr(f,p) \
255 (*PL_StdIO->pSetPtr)(PL_StdIO, (f), (p))
eaf8b698 256#define PerlSIO_setlinebuf(f) \
51371543 257 (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f))
eaf8b698 258#define PerlSIO_printf Perl_fprintf_nocontext
b0316773
JH
259#define PerlSIO_stdoutf Perl_printf_nocontext
260#define PerlSIO_vprintf(f,fmt,a) \
4a7d1889 261 (*PL_StdIO->pVprintf)(PL_StdIO, (f),(fmt),a)
eaf8b698 262#define PerlSIO_ftell(f) \
51371543 263 (*PL_StdIO->pTell)(PL_StdIO, (f))
eaf8b698 264#define PerlSIO_fseek(f,o,w) \
51371543 265 (*PL_StdIO->pSeek)(PL_StdIO, (f),(o),(w))
eaf8b698 266#define PerlSIO_fgetpos(f,p) \
51371543 267 (*PL_StdIO->pGetpos)(PL_StdIO, (f),(p))
eaf8b698 268#define PerlSIO_fsetpos(f,p) \
51371543 269 (*PL_StdIO->pSetpos)(PL_StdIO, (f),(p))
eaf8b698 270#define PerlSIO_rewind(f) \
51371543 271 (*PL_StdIO->pRewind)(PL_StdIO, (f))
eaf8b698 272#define PerlSIO_tmpfile() \
51371543 273 (*PL_StdIO->pTmpfile)(PL_StdIO)
eaf8b698 274#define PerlSIO_init() \
51371543 275 (*PL_StdIO->pInit)(PL_StdIO)
0f4eea8f 276#undef init_os_extras
c5be433b 277#define init_os_extras() \
51371543 278 (*PL_StdIO->pInitOSExtras)(PL_StdIO)
eaf8b698 279#define PerlSIO_fdupopen(f) \
7766f137 280 (*PL_StdIO->pFdupopen)(PL_StdIO, (f))
eaf8b698
NIS
281
282#else /* PERL_IMPLICIT_SYS */
283
284#define PerlSIO_stdin stdin
285#define PerlSIO_stdout stdout
286#define PerlSIO_stderr stderr
287#define PerlSIO_fopen(x,y) fopen(x,y)
75e258e9
PG
288#ifdef __VOS__
289/* Work around VOS bug posix-979, wrongly setting errno when at end of file. */
290#define PerlSIO_fclose(f) (((errno==1025)?errno=0:0),fclose(f))
291#define PerlSIO_feof(f) (((errno==1025)?errno=0:0),feof(f))
292#define PerlSIO_ferror(f) (((errno==1025)?errno=0:0),ferror(f))
293#else
eaf8b698
NIS
294#define PerlSIO_fclose(f) fclose(f)
295#define PerlSIO_feof(f) feof(f)
296#define PerlSIO_ferror(f) ferror(f)
75e258e9 297#endif
eaf8b698
NIS
298#define PerlSIO_clearerr(f) clearerr(f)
299#define PerlSIO_fgetc(f) fgetc(f)
f7c20d1e 300#ifdef FILE_base
eaf8b698
NIS
301#define PerlSIO_get_base(f) FILE_base(f)
302#define PerlSIO_get_bufsiz(f) FILE_bufsiz(f)
303#else
304#define PerlSIO_get_base(f) NULL
305#define PerlSIO_get_bufsiz(f) 0
306#endif
307#ifdef USE_STDIO_PTR
308#define PerlSIO_get_cnt(f) FILE_cnt(f)
309#define PerlSIO_get_ptr(f) FILE_ptr(f)
310#else
311#define PerlSIO_get_cnt(f) 0
312#define PerlSIO_get_ptr(f) NULL
313#endif
314#define PerlSIO_fputc(f,c) fputc(c,f)
315#define PerlSIO_fputs(f,s) fputs(s,f)
316#define PerlSIO_fflush(f) Fflush(f)
317#define PerlSIO_fgets(s, n, fp) fgets(s,n,fp)
a15cef0c
CB
318#if defined(VMS) && defined(__DECC)
319 /* Unusual definition of ungetc() here to accomodate fast_sv_gets()'
320 * belief that it can mix getc/ungetc with reads from stdio buffer */
321 int decc$ungetc(int __c, FILE *__stream);
322# define PerlSIO_ungetc(c,f) ((c) == EOF ? EOF : \
323 ((*(f) && !((*(f))->_flag & _IONBF) && \
324 ((*(f))->_ptr > (*(f))->_base)) ? \
325 ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f)))
326#else
327# define PerlSIO_ungetc(c,f) ungetc(c,f)
328#endif
eaf8b698
NIS
329#define PerlSIO_fileno(f) fileno(f)
330#define PerlSIO_fdopen(f, s) fdopen(f,s)
331#define PerlSIO_freopen(p, m, f) freopen(p,m,f)
332#define PerlSIO_fread(buf,sz,count,f) fread(buf,sz,count,f)
333#define PerlSIO_fwrite(buf,sz,count,f) fwrite(buf,sz,count,f)
334#define PerlSIO_setbuf(f,b) setbuf(f,b)
335#define PerlSIO_setvbuf(f,b,t,s) setvbuf(f,b,t,s)
336#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
337#define PerlSIO_set_cnt(f,c) FILE_cnt(f) = (c)
338#else
339#define PerlSIO_set_cnt(f,c) PerlIOProc_abort()
340#endif
341#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE)
714c8e96 342#define PerlSIO_set_ptr(f,p) (FILE_ptr(f) = (p))
eaf8b698
NIS
343#else
344#define PerlSIO_set_ptr(f,p) PerlIOProc_abort()
345#endif
346#define PerlSIO_setlinebuf(f) setlinebuf(f)
079b94bc
NIS
347#define PerlSIO_printf fprintf
348#define PerlSIO_stdoutf printf
362d0d44 349#define PerlSIO_vprintf(f,fmt,a) vfprintf(f,fmt,a)
eaf8b698
NIS
350#define PerlSIO_ftell(f) ftell(f)
351#define PerlSIO_fseek(f,o,w) fseek(f,o,w)
352#define PerlSIO_fgetpos(f,p) fgetpos(f,p)
353#define PerlSIO_fsetpos(f,p) fsetpos(f,p)
354#define PerlSIO_rewind(f) rewind(f)
355#define PerlSIO_tmpfile() tmpfile()
eaf8b698 356#define PerlSIO_fdupopen(f) (f)
0f4eea8f 357
c5be433b 358#endif /* PERL_IMPLICIT_SYS */
0f4eea8f 359
0f4eea8f
DL
360/*
361 * Interface for directory functions
362 */
363
c5be433b 364#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 365
0cb96387
GS
366/* IPerlDir */
367struct IPerlDir;
7766f137 368struct IPerlDirInfo;
0cb96387
GS
369typedef int (*LPMakedir)(struct IPerlDir*, const char*, int);
370typedef int (*LPChdir)(struct IPerlDir*, const char*);
371typedef int (*LPRmdir)(struct IPerlDir*, const char*);
372typedef int (*LPDirClose)(struct IPerlDir*, DIR*);
0e06f75d 373typedef DIR* (*LPDirOpen)(struct IPerlDir*, const char*);
0cb96387
GS
374typedef struct direct* (*LPDirRead)(struct IPerlDir*, DIR*);
375typedef void (*LPDirRewind)(struct IPerlDir*, DIR*);
376typedef void (*LPDirSeek)(struct IPerlDir*, DIR*, long);
377typedef long (*LPDirTell)(struct IPerlDir*, DIR*);
7766f137
GS
378#ifdef WIN32
379typedef char* (*LPDirMapPathA)(struct IPerlDir*, const char*);
380typedef WCHAR* (*LPDirMapPathW)(struct IPerlDir*, const WCHAR*);
381#endif
0cb96387
GS
382
383struct IPerlDir
0f4eea8f 384{
0cb96387
GS
385 LPMakedir pMakedir;
386 LPChdir pChdir;
387 LPRmdir pRmdir;
388 LPDirClose pClose;
389 LPDirOpen pOpen;
390 LPDirRead pRead;
391 LPDirRewind pRewind;
392 LPDirSeek pSeek;
393 LPDirTell pTell;
7766f137
GS
394#ifdef WIN32
395 LPDirMapPathA pMapPathA;
396 LPDirMapPathW pMapPathW;
397#endif
0cb96387
GS
398};
399
400struct IPerlDirInfo
401{
402 unsigned long nCount; /* number of entries expected */
403 struct IPerlDir perlDirList;
0f4eea8f
DL
404};
405
406#define PerlDir_mkdir(name, mode) \
51371543 407 (*PL_Dir->pMakedir)(PL_Dir, (name), (mode))
0f4eea8f 408#define PerlDir_chdir(name) \
51371543 409 (*PL_Dir->pChdir)(PL_Dir, (name))
0f4eea8f 410#define PerlDir_rmdir(name) \
51371543 411 (*PL_Dir->pRmdir)(PL_Dir, (name))
0f4eea8f 412#define PerlDir_close(dir) \
51371543 413 (*PL_Dir->pClose)(PL_Dir, (dir))
0f4eea8f 414#define PerlDir_open(name) \
51371543 415 (*PL_Dir->pOpen)(PL_Dir, (name))
0f4eea8f 416#define PerlDir_read(dir) \
51371543 417 (*PL_Dir->pRead)(PL_Dir, (dir))
0f4eea8f 418#define PerlDir_rewind(dir) \
51371543 419 (*PL_Dir->pRewind)(PL_Dir, (dir))
0f4eea8f 420#define PerlDir_seek(dir, loc) \
51371543 421 (*PL_Dir->pSeek)(PL_Dir, (dir), (loc))
0f4eea8f 422#define PerlDir_tell(dir) \
51371543 423 (*PL_Dir->pTell)(PL_Dir, (dir))
7766f137
GS
424#ifdef WIN32
425#define PerlDir_mapA(dir) \
426 (*PL_Dir->pMapPathA)(PL_Dir, (dir))
427#define PerlDir_mapW(dir) \
428 (*PL_Dir->pMapPathW)(PL_Dir, (dir))
429#endif
0f4eea8f 430
c5be433b 431#else /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
432
433#define PerlDir_mkdir(name, mode) Mkdir((name), (mode))
434#ifdef VMS
9d4c144b 435# define PerlDir_chdir(n) Chdir((n))
6f9d8c32 436#else
0f4eea8f
DL
437# define PerlDir_chdir(name) chdir((name))
438#endif
439#define PerlDir_rmdir(name) rmdir((name))
440#define PerlDir_close(dir) closedir((dir))
441#define PerlDir_open(name) opendir((name))
442#define PerlDir_read(dir) readdir((dir))
443#define PerlDir_rewind(dir) rewinddir((dir))
444#define PerlDir_seek(dir, loc) seekdir((dir), (loc))
445#define PerlDir_tell(dir) telldir((dir))
7766f137
GS
446#ifdef WIN32
447#define PerlDir_mapA(dir) dir
448#define PerlDir_mapW(dir) dir
449#endif
0f4eea8f 450
c5be433b 451#endif /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
452
453/*
454 Interface for perl environment functions
455*/
456
c5be433b 457#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 458
0cb96387
GS
459/* IPerlEnv */
460struct IPerlEnv;
7766f137 461struct IPerlEnvInfo;
0cb96387
GS
462typedef char* (*LPEnvGetenv)(struct IPerlEnv*, const char*);
463typedef int (*LPEnvPutenv)(struct IPerlEnv*, const char*);
3075ddba 464typedef char* (*LPEnvGetenv_len)(struct IPerlEnv*,
0cb96387
GS
465 const char *varname, unsigned long *len);
466typedef int (*LPEnvUname)(struct IPerlEnv*, struct utsname *name);
467typedef void (*LPEnvClearenv)(struct IPerlEnv*);
3075ddba
GS
468typedef void* (*LPEnvGetChildenv)(struct IPerlEnv*);
469typedef void (*LPEnvFreeChildenv)(struct IPerlEnv*, void* env);
470typedef char* (*LPEnvGetChilddir)(struct IPerlEnv*);
471typedef void (*LPEnvFreeChilddir)(struct IPerlEnv*, char* dir);
0cb96387 472#ifdef HAS_ENVGETENV
3075ddba
GS
473typedef char* (*LPENVGetenv)(struct IPerlEnv*, const char *varname);
474typedef char* (*LPENVGetenv_len)(struct IPerlEnv*,
0cb96387
GS
475 const char *varname, unsigned long *len);
476#endif
477#ifdef WIN32
3075ddba 478typedef unsigned long (*LPEnvOsID)(struct IPerlEnv*);
4ea817c6
GS
479typedef char* (*LPEnvLibPath)(struct IPerlEnv*, const char*);
480typedef char* (*LPEnvSiteLibPath)(struct IPerlEnv*, const char*);
481typedef char* (*LPEnvVendorLibPath)(struct IPerlEnv*, const char*);
635bbe87 482typedef void (*LPEnvGetChildIO)(struct IPerlEnv*, child_IO_table*);
0cb96387
GS
483#endif
484
485struct IPerlEnv
0f4eea8f 486{
0cb96387
GS
487 LPEnvGetenv pGetenv;
488 LPEnvPutenv pPutenv;
489 LPEnvGetenv_len pGetenv_len;
490 LPEnvUname pEnvUname;
491 LPEnvClearenv pClearenv;
3075ddba
GS
492 LPEnvGetChildenv pGetChildenv;
493 LPEnvFreeChildenv pFreeChildenv;
494 LPEnvGetChilddir pGetChilddir;
495 LPEnvFreeChilddir pFreeChilddir;
a6c40364 496#ifdef HAS_ENVGETENV
0cb96387
GS
497 LPENVGetenv pENVGetenv;
498 LPENVGetenv_len pENVGetenv_len;
499#endif
500#ifdef WIN32
501 LPEnvOsID pEnvOsID;
502 LPEnvLibPath pLibPath;
503 LPEnvSiteLibPath pSiteLibPath;
4ea817c6 504 LPEnvVendorLibPath pVendorLibPath;
635bbe87 505 LPEnvGetChildIO pGetChildIO;
a6c40364 506#endif
0f4eea8f
DL
507};
508
0cb96387
GS
509struct IPerlEnvInfo
510{
511 unsigned long nCount; /* number of entries expected */
512 struct IPerlEnv perlEnvList;
513};
514
515#define PerlEnv_putenv(str) \
51371543 516 (*PL_Env->pPutenv)(PL_Env,(str))
0cb96387 517#define PerlEnv_getenv(str) \
51371543 518 (*PL_Env->pGetenv)(PL_Env,(str))
0cb96387 519#define PerlEnv_getenv_len(str,l) \
51371543 520 (*PL_Env->pGetenv_len)(PL_Env,(str), (l))
3075ddba 521#define PerlEnv_clearenv() \
51371543 522 (*PL_Env->pClearenv)(PL_Env)
3075ddba
GS
523#define PerlEnv_get_childenv() \
524 (*PL_Env->pGetChildenv)(PL_Env)
525#define PerlEnv_free_childenv(e) \
526 (*PL_Env->pFreeChildenv)(PL_Env, (e))
527#define PerlEnv_get_childdir() \
528 (*PL_Env->pGetChilddir)(PL_Env)
529#define PerlEnv_free_childdir(d) \
530 (*PL_Env->pFreeChilddir)(PL_Env, (d))
f675dbe5 531#ifdef HAS_ENVGETENV
0cb96387 532# define PerlEnv_ENVgetenv(str) \
51371543 533 (*PL_Env->pENVGetenv)(PL_Env,(str))
0cb96387 534# define PerlEnv_ENVgetenv_len(str,l) \
51371543 535 (*PL_Env->pENVGetenv_len)(PL_Env,(str), (l))
f675dbe5 536#else
0cb96387
GS
537# define PerlEnv_ENVgetenv(str) \
538 PerlEnv_getenv((str))
539# define PerlEnv_ENVgetenv_len(str,l) \
540 PerlEnv_getenv_len((str),(l))
f675dbe5 541#endif
0cb96387 542#define PerlEnv_uname(name) \
51371543 543 (*PL_Env->pEnvUname)(PL_Env,(name))
0f4eea8f 544#ifdef WIN32
0cb96387 545#define PerlEnv_os_id() \
51371543 546 (*PL_Env->pEnvOsID)(PL_Env)
0cb96387 547#define PerlEnv_lib_path(str) \
51371543 548 (*PL_Env->pLibPath)(PL_Env,(str))
0cb96387 549#define PerlEnv_sitelib_path(str) \
51371543 550 (*PL_Env->pSiteLibPath)(PL_Env,(str))
4ea817c6
GS
551#define PerlEnv_vendorlib_path(str) \
552 (*PL_Env->pVendorLibPath)(PL_Env,(str))
635bbe87
GS
553#define PerlEnv_get_child_IO(ptr) \
554 (*PL_Env->pGetChildIO)(PL_Env, ptr)
0f4eea8f
DL
555#endif
556
c5be433b 557#else /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
558
559#define PerlEnv_putenv(str) putenv((str))
560#define PerlEnv_getenv(str) getenv((str))
a6c40364 561#define PerlEnv_getenv_len(str,l) getenv_len((str), (l))
f675dbe5
CB
562#ifdef HAS_ENVGETENV
563# define PerlEnv_ENVgetenv(str) ENVgetenv((str))
a6c40364 564# define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l))
f675dbe5
CB
565#else
566# define PerlEnv_ENVgetenv(str) PerlEnv_getenv((str))
a6c40364 567# define PerlEnv_ENVgetenv_len(str,l) PerlEnv_getenv_len((str), (l))
f675dbe5 568#endif
b2af26b1 569#define PerlEnv_uname(name) uname((name))
0f4eea8f 570
0cb96387
GS
571#ifdef WIN32
572#define PerlEnv_os_id() win32_os_id()
4ea817c6
GS
573#define PerlEnv_lib_path(str) win32_get_privlib(str)
574#define PerlEnv_sitelib_path(str) win32_get_sitelib(str)
575#define PerlEnv_vendorlib_path(str) win32_get_vendorlib(str)
635bbe87 576#define PerlEnv_get_child_IO(ptr) win32_get_child_IO(ptr)
df3728a2
JH
577#define PerlEnv_clearenv() win32_clearenv()
578#define PerlEnv_get_childenv() win32_get_childenv()
579#define PerlEnv_free_childenv(e) win32_free_childenv((e))
580#define PerlEnv_get_childdir() win32_get_childdir()
581#define PerlEnv_free_childdir(d) win32_free_childdir((d))
582#else
583#define PerlEnv_clearenv() clearenv()
584#define PerlEnv_get_childenv() get_childenv()
585#define PerlEnv_free_childenv(e) free_childenv((e))
586#define PerlEnv_get_childdir() get_childdir()
587#define PerlEnv_free_childdir(d) free_childdir((d))
0cb96387
GS
588#endif
589
c5be433b 590#endif /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
591
592/*
593 Interface for perl low-level IO functions
594*/
595
c5be433b 596#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 597
0cb96387
GS
598/* IPerlLIO */
599struct IPerlLIO;
7766f137 600struct IPerlLIOInfo;
0cb96387
GS
601typedef int (*LPLIOAccess)(struct IPerlLIO*, const char*, int);
602typedef int (*LPLIOChmod)(struct IPerlLIO*, const char*, int);
603typedef int (*LPLIOChown)(struct IPerlLIO*, const char*, uid_t,
604 gid_t);
4a9d6100 605typedef int (*LPLIOChsize)(struct IPerlLIO*, int, Off_t);
0cb96387
GS
606typedef int (*LPLIOClose)(struct IPerlLIO*, int);
607typedef int (*LPLIODup)(struct IPerlLIO*, int);
608typedef int (*LPLIODup2)(struct IPerlLIO*, int, int);
609typedef int (*LPLIOFlock)(struct IPerlLIO*, int, int);
c623ac67 610typedef int (*LPLIOFileStat)(struct IPerlLIO*, int, Stat_t*);
0cb96387
GS
611typedef int (*LPLIOIOCtl)(struct IPerlLIO*, int, unsigned int,
612 char*);
613typedef int (*LPLIOIsatty)(struct IPerlLIO*, int);
6b980173
JD
614typedef int (*LPLIOLink)(struct IPerlLIO*, const char*,
615 const char *);
c623ac67 616typedef Off_t (*LPLIOLseek)(struct IPerlLIO*, int, Off_t, int);
0cb96387 617typedef int (*LPLIOLstat)(struct IPerlLIO*, const char*,
c623ac67 618 Stat_t*);
0cb96387
GS
619typedef char* (*LPLIOMktemp)(struct IPerlLIO*, char*);
620typedef int (*LPLIOOpen)(struct IPerlLIO*, const char*, int);
621typedef int (*LPLIOOpen3)(struct IPerlLIO*, const char*, int, int);
622typedef int (*LPLIORead)(struct IPerlLIO*, int, void*, unsigned int);
623typedef int (*LPLIORename)(struct IPerlLIO*, const char*,
624 const char*);
2986a63f
JH
625#ifdef NETWARE
626typedef int (*LPLIOSetmode)(struct IPerlLIO*, FILE*, int);
627#else
0cb96387 628typedef int (*LPLIOSetmode)(struct IPerlLIO*, int, int);
2986a63f 629#endif /* NETWARE */
0cb96387 630typedef int (*LPLIONameStat)(struct IPerlLIO*, const char*,
c623ac67 631 Stat_t*);
0cb96387
GS
632typedef char* (*LPLIOTmpnam)(struct IPerlLIO*, char*);
633typedef int (*LPLIOUmask)(struct IPerlLIO*, int);
634typedef int (*LPLIOUnlink)(struct IPerlLIO*, const char*);
c3ff6b30 635typedef int (*LPLIOUtime)(struct IPerlLIO*, const char*, struct utimbuf*);
0cb96387
GS
636typedef int (*LPLIOWrite)(struct IPerlLIO*, int, const void*,
637 unsigned int);
638
639struct IPerlLIO
640{
641 LPLIOAccess pAccess;
642 LPLIOChmod pChmod;
643 LPLIOChown pChown;
644 LPLIOChsize pChsize;
645 LPLIOClose pClose;
646 LPLIODup pDup;
647 LPLIODup2 pDup2;
648 LPLIOFlock pFlock;
649 LPLIOFileStat pFileStat;
650 LPLIOIOCtl pIOCtl;
651 LPLIOIsatty pIsatty;
6b980173 652 LPLIOLink pLink;
0cb96387
GS
653 LPLIOLseek pLseek;
654 LPLIOLstat pLstat;
655 LPLIOMktemp pMktemp;
656 LPLIOOpen pOpen;
657 LPLIOOpen3 pOpen3;
658 LPLIORead pRead;
659 LPLIORename pRename;
660 LPLIOSetmode pSetmode;
661 LPLIONameStat pNameStat;
662 LPLIOTmpnam pTmpnam;
663 LPLIOUmask pUmask;
664 LPLIOUnlink pUnlink;
665 LPLIOUtime pUtime;
666 LPLIOWrite pWrite;
667};
668
669struct IPerlLIOInfo
0f4eea8f 670{
0cb96387
GS
671 unsigned long nCount; /* number of entries expected */
672 struct IPerlLIO perlLIOList;
0f4eea8f
DL
673};
674
675#define PerlLIO_access(file, mode) \
51371543 676 (*PL_LIO->pAccess)(PL_LIO, (file), (mode))
0f4eea8f 677#define PerlLIO_chmod(file, mode) \
51371543 678 (*PL_LIO->pChmod)(PL_LIO, (file), (mode))
0f4eea8f 679#define PerlLIO_chown(file, owner, group) \
51371543 680 (*PL_LIO->pChown)(PL_LIO, (file), (owner), (group))
0f4eea8f 681#define PerlLIO_chsize(fd, size) \
51371543 682 (*PL_LIO->pChsize)(PL_LIO, (fd), (size))
0f4eea8f 683#define PerlLIO_close(fd) \
51371543 684 (*PL_LIO->pClose)(PL_LIO, (fd))
0f4eea8f 685#define PerlLIO_dup(fd) \
51371543 686 (*PL_LIO->pDup)(PL_LIO, (fd))
0f4eea8f 687#define PerlLIO_dup2(fd1, fd2) \
51371543 688 (*PL_LIO->pDup2)(PL_LIO, (fd1), (fd2))
0f4eea8f 689#define PerlLIO_flock(fd, op) \
51371543 690 (*PL_LIO->pFlock)(PL_LIO, (fd), (op))
0f4eea8f 691#define PerlLIO_fstat(fd, buf) \
51371543 692 (*PL_LIO->pFileStat)(PL_LIO, (fd), (buf))
0f4eea8f 693#define PerlLIO_ioctl(fd, u, buf) \
51371543 694 (*PL_LIO->pIOCtl)(PL_LIO, (fd), (u), (buf))
0f4eea8f 695#define PerlLIO_isatty(fd) \
51371543 696 (*PL_LIO->pIsatty)(PL_LIO, (fd))
6b980173
JD
697#define PerlLIO_link(oldname, newname) \
698 (*PL_LIO->pLink)(PL_LIO, (oldname), (newname))
0f4eea8f 699#define PerlLIO_lseek(fd, offset, mode) \
51371543 700 (*PL_LIO->pLseek)(PL_LIO, (fd), (offset), (mode))
0f4eea8f 701#define PerlLIO_lstat(name, buf) \
51371543 702 (*PL_LIO->pLstat)(PL_LIO, (name), (buf))
0f4eea8f 703#define PerlLIO_mktemp(file) \
51371543 704 (*PL_LIO->pMktemp)(PL_LIO, (file))
0f4eea8f 705#define PerlLIO_open(file, flag) \
51371543 706 (*PL_LIO->pOpen)(PL_LIO, (file), (flag))
0f4eea8f 707#define PerlLIO_open3(file, flag, perm) \
51371543 708 (*PL_LIO->pOpen3)(PL_LIO, (file), (flag), (perm))
0f4eea8f 709#define PerlLIO_read(fd, buf, count) \
51371543 710 (*PL_LIO->pRead)(PL_LIO, (fd), (buf), (count))
8d9b2e3c 711#define PerlLIO_rename(oname, newname) \
51371543 712 (*PL_LIO->pRename)(PL_LIO, (oname), (newname))
0f4eea8f 713#define PerlLIO_setmode(fd, mode) \
51371543 714 (*PL_LIO->pSetmode)(PL_LIO, (fd), (mode))
0f4eea8f 715#define PerlLIO_stat(name, buf) \
51371543 716 (*PL_LIO->pNameStat)(PL_LIO, (name), (buf))
0f4eea8f 717#define PerlLIO_tmpnam(str) \
51371543 718 (*PL_LIO->pTmpnam)(PL_LIO, (str))
0f4eea8f 719#define PerlLIO_umask(mode) \
51371543 720 (*PL_LIO->pUmask)(PL_LIO, (mode))
0f4eea8f 721#define PerlLIO_unlink(file) \
51371543 722 (*PL_LIO->pUnlink)(PL_LIO, (file))
0f4eea8f 723#define PerlLIO_utime(file, time) \
51371543 724 (*PL_LIO->pUtime)(PL_LIO, (file), (time))
0f4eea8f 725#define PerlLIO_write(fd, buf, count) \
51371543 726 (*PL_LIO->pWrite)(PL_LIO, (fd), (buf), (count))
0f4eea8f 727
c5be433b 728#else /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
729
730#define PerlLIO_access(file, mode) access((file), (mode))
731#define PerlLIO_chmod(file, mode) chmod((file), (mode))
732#define PerlLIO_chown(file, owner, grp) chown((file), (owner), (grp))
58e24eff
SH
733#if defined(HAS_TRUNCATE)
734# define PerlLIO_chsize(fd, size) ftruncate((fd), (size))
735#elif defined(HAS_CHSIZE)
736# define PerlLIO_chsize(fd, size) chsize((fd), (size))
737#else
738# define PerlLIO_chsize(fd, size) my_chsize((fd), (size))
739#endif
0f4eea8f
DL
740#define PerlLIO_close(fd) close((fd))
741#define PerlLIO_dup(fd) dup((fd))
742#define PerlLIO_dup2(fd1, fd2) dup2((fd1), (fd2))
743#define PerlLIO_flock(fd, op) FLOCK((fd), (op))
744#define PerlLIO_fstat(fd, buf) Fstat((fd), (buf))
745#define PerlLIO_ioctl(fd, u, buf) ioctl((fd), (u), (buf))
746#define PerlLIO_isatty(fd) isatty((fd))
6b980173 747#define PerlLIO_link(oldname, newname) link((oldname), (newname))
0f4eea8f 748#define PerlLIO_lseek(fd, offset, mode) lseek((fd), (offset), (mode))
1f47e8e2 749#define PerlLIO_stat(name, buf) Stat((name), (buf))
9423c6fc 750#ifdef HAS_LSTAT
1f47e8e2 751# define PerlLIO_lstat(name, buf) lstat((name), (buf))
9423c6fc 752#else
1f47e8e2 753# define PerlLIO_lstat(name, buf) PerlLIO_stat((name), (buf))
9423c6fc 754#endif
0f4eea8f
DL
755#define PerlLIO_mktemp(file) mktemp((file))
756#define PerlLIO_mkstemp(file) mkstemp((file))
757#define PerlLIO_open(file, flag) open((file), (flag))
758#define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm))
759#define PerlLIO_read(fd, buf, count) read((fd), (buf), (count))
760#define PerlLIO_rename(old, new) rename((old), (new))
761#define PerlLIO_setmode(fd, mode) setmode((fd), (mode))
0f4eea8f
DL
762#define PerlLIO_tmpnam(str) tmpnam((str))
763#define PerlLIO_umask(mode) umask((mode))
764#define PerlLIO_unlink(file) unlink((file))
765#define PerlLIO_utime(file, time) utime((file), (time))
766#define PerlLIO_write(fd, buf, count) write((fd), (buf), (count))
767
c5be433b 768#endif /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
769
770/*
771 Interface for perl memory allocation
772*/
773
c5be433b 774#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 775
0cb96387
GS
776/* IPerlMem */
777struct IPerlMem;
7766f137 778struct IPerlMemInfo;
0cb96387
GS
779typedef void* (*LPMemMalloc)(struct IPerlMem*, size_t);
780typedef void* (*LPMemRealloc)(struct IPerlMem*, void*, size_t);
781typedef void (*LPMemFree)(struct IPerlMem*, void*);
7766f137
GS
782typedef void* (*LPMemCalloc)(struct IPerlMem*, size_t, size_t);
783typedef void (*LPMemGetLock)(struct IPerlMem*);
784typedef void (*LPMemFreeLock)(struct IPerlMem*);
785typedef int (*LPMemIsLocked)(struct IPerlMem*);
0cb96387
GS
786
787struct IPerlMem
0f4eea8f 788{
0cb96387
GS
789 LPMemMalloc pMalloc;
790 LPMemRealloc pRealloc;
791 LPMemFree pFree;
7766f137
GS
792 LPMemCalloc pCalloc;
793 LPMemGetLock pGetLock;
794 LPMemFreeLock pFreeLock;
795 LPMemIsLocked pIsLocked;
0f4eea8f
DL
796};
797
0cb96387
GS
798struct IPerlMemInfo
799{
800 unsigned long nCount; /* number of entries expected */
801 struct IPerlMem perlMemList;
802};
803
7766f137 804/* Interpreter specific memory macros */
0cb96387 805#define PerlMem_malloc(size) \
51371543 806 (*PL_Mem->pMalloc)(PL_Mem, (size))
0cb96387 807#define PerlMem_realloc(buf, size) \
51371543 808 (*PL_Mem->pRealloc)(PL_Mem, (buf), (size))
0cb96387 809#define PerlMem_free(buf) \
51371543 810 (*PL_Mem->pFree)(PL_Mem, (buf))
7766f137
GS
811#define PerlMem_calloc(num, size) \
812 (*PL_Mem->pCalloc)(PL_Mem, (num), (size))
813#define PerlMem_get_lock() \
814 (*PL_Mem->pGetLock)(PL_Mem)
815#define PerlMem_free_lock() \
816 (*PL_Mem->pFreeLock)(PL_Mem)
817#define PerlMem_is_locked() \
818 (*PL_Mem->pIsLocked)(PL_Mem)
819
820/* Shared memory macros */
083fcd59 821#ifdef NETWARE
362d0d44 822
7e4e8c89 823#define PerlMemShared_malloc(size) \
083fcd59
JH
824 (*PL_Mem->pMalloc)(PL_Mem, (size))
825#define PerlMemShared_realloc(buf, size) \
826 (*PL_Mem->pRealloc)(PL_Mem, (buf), (size))
827#define PerlMemShared_free(buf) \
828 (*PL_Mem->pFree)(PL_Mem, (buf))
829#define PerlMemShared_calloc(num, size) \
830 (*PL_Mem->pCalloc)(PL_Mem, (num), (size))
831#define PerlMemShared_get_lock() \
832 (*PL_Mem->pGetLock)(PL_Mem)
833#define PerlMemShared_free_lock() \
834 (*PL_Mem->pFreeLock)(PL_Mem)
835#define PerlMemShared_is_locked() \
836 (*PL_Mem->pIsLocked)(PL_Mem)
837
838#else
839
7766f137 840#define PerlMemShared_malloc(size) \
0a77e2d7 841 (*PL_MemShared->pMalloc)(PL_MemShared, (size))
7766f137 842#define PerlMemShared_realloc(buf, size) \
0a77e2d7 843 (*PL_MemShared->pRealloc)(PL_MemShared, (buf), (size))
7766f137 844#define PerlMemShared_free(buf) \
0a77e2d7 845 (*PL_MemShared->pFree)(PL_MemShared, (buf))
7766f137 846#define PerlMemShared_calloc(num, size) \
0a77e2d7 847 (*PL_MemShared->pCalloc)(PL_MemShared, (num), (size))
7766f137 848#define PerlMemShared_get_lock() \
0a77e2d7 849 (*PL_MemShared->pGetLock)(PL_MemShared)
7766f137 850#define PerlMemShared_free_lock() \
0a77e2d7 851 (*PL_MemShared->pFreeLock)(PL_MemShared)
7766f137 852#define PerlMemShared_is_locked() \
0a77e2d7 853 (*PL_MemShared->pIsLocked)(PL_MemShared)
7766f137 854
083fcd59 855#endif
7766f137
GS
856
857/* Parse tree memory macros */
858#define PerlMemParse_malloc(size) \
0a77e2d7 859 (*PL_MemParse->pMalloc)(PL_MemParse, (size))
7766f137 860#define PerlMemParse_realloc(buf, size) \
0a77e2d7 861 (*PL_MemParse->pRealloc)(PL_MemParse, (buf), (size))
7766f137 862#define PerlMemParse_free(buf) \
0a77e2d7 863 (*PL_MemParse->pFree)(PL_MemParse, (buf))
7766f137 864#define PerlMemParse_calloc(num, size) \
0a77e2d7 865 (*PL_MemParse->pCalloc)(PL_MemParse, (num), (size))
7766f137 866#define PerlMemParse_get_lock() \
0a77e2d7 867 (*PL_MemParse->pGetLock)(PL_MemParse)
7766f137 868#define PerlMemParse_free_lock() \
0a77e2d7 869 (*PL_MemParse->pFreeLock)(PL_MemParse)
7766f137 870#define PerlMemParse_is_locked() \
0a77e2d7 871 (*PL_MemParse->pIsLocked)(PL_MemParse)
7766f137 872
0f4eea8f 873
c5be433b 874#else /* PERL_IMPLICIT_SYS */
0f4eea8f 875
7766f137 876/* Interpreter specific memory macros */
0f4eea8f
DL
877#define PerlMem_malloc(size) malloc((size))
878#define PerlMem_realloc(buf, size) realloc((buf), (size))
879#define PerlMem_free(buf) free((buf))
7766f137
GS
880#define PerlMem_calloc(num, size) calloc((num), (size))
881#define PerlMem_get_lock()
882#define PerlMem_free_lock()
883#define PerlMem_is_locked() 0
884
885/* Shared memory macros */
886#define PerlMemShared_malloc(size) malloc((size))
887#define PerlMemShared_realloc(buf, size) realloc((buf), (size))
888#define PerlMemShared_free(buf) free((buf))
889#define PerlMemShared_calloc(num, size) calloc((num), (size))
890#define PerlMemShared_get_lock()
891#define PerlMemShared_free_lock()
892#define PerlMemShared_is_locked() 0
893
894/* Parse tree memory macros */
895#define PerlMemParse_malloc(size) malloc((size))
896#define PerlMemParse_realloc(buf, size) realloc((buf), (size))
897#define PerlMemParse_free(buf) free((buf))
898#define PerlMemParse_calloc(num, size) calloc((num), (size))
899#define PerlMemParse_get_lock()
900#define PerlMemParse_free_lock()
901#define PerlMemParse_is_locked() 0
0f4eea8f 902
c5be433b 903#endif /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
904
905/*
906 Interface for perl process functions
907*/
908
909
c5be433b 910#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 911
0f4eea8f
DL
912#ifndef jmp_buf
913#include <setjmp.h>
914#endif
915
0cb96387
GS
916/* IPerlProc */
917struct IPerlProc;
7766f137 918struct IPerlProcInfo;
0cb96387
GS
919typedef void (*LPProcAbort)(struct IPerlProc*);
920typedef char* (*LPProcCrypt)(struct IPerlProc*, const char*,
921 const char*);
d951c358
SH
922typedef void (*LPProcExit)(struct IPerlProc*, int)
923 __attribute__noreturn__;
924typedef void (*LPProc_Exit)(struct IPerlProc*, int)
925 __attribute__noreturn__;
0cb96387
GS
926typedef int (*LPProcExecl)(struct IPerlProc*, const char*,
927 const char*, const char*, const char*,
928 const char*);
929typedef int (*LPProcExecv)(struct IPerlProc*, const char*,
930 const char*const*);
931typedef int (*LPProcExecvp)(struct IPerlProc*, const char*,
932 const char*const*);
933typedef uid_t (*LPProcGetuid)(struct IPerlProc*);
934typedef uid_t (*LPProcGeteuid)(struct IPerlProc*);
935typedef gid_t (*LPProcGetgid)(struct IPerlProc*);
936typedef gid_t (*LPProcGetegid)(struct IPerlProc*);
937typedef char* (*LPProcGetlogin)(struct IPerlProc*);
938typedef int (*LPProcKill)(struct IPerlProc*, int, int);
939typedef int (*LPProcKillpg)(struct IPerlProc*, int, int);
940typedef int (*LPProcPauseProc)(struct IPerlProc*);
941typedef PerlIO* (*LPProcPopen)(struct IPerlProc*, const char*,
942 const char*);
8c0134a8
NIS
943typedef PerlIO* (*LPProcPopenList)(struct IPerlProc*, const char*,
944 IV narg, SV **args);
0cb96387
GS
945typedef int (*LPProcPclose)(struct IPerlProc*, PerlIO*);
946typedef int (*LPProcPipe)(struct IPerlProc*, int*);
947typedef int (*LPProcSetuid)(struct IPerlProc*, uid_t);
948typedef int (*LPProcSetgid)(struct IPerlProc*, gid_t);
949typedef int (*LPProcSleep)(struct IPerlProc*, unsigned int);
950typedef int (*LPProcTimes)(struct IPerlProc*, struct tms*);
951typedef int (*LPProcWait)(struct IPerlProc*, int*);
952typedef int (*LPProcWaitpid)(struct IPerlProc*, int, int*, int);
953typedef Sighandler_t (*LPProcSignal)(struct IPerlProc*, int, Sighandler_t);
7766f137
GS
954typedef int (*LPProcFork)(struct IPerlProc*);
955typedef int (*LPProcGetpid)(struct IPerlProc*);
0cb96387 956#ifdef WIN32
7766f137 957typedef void* (*LPProcDynaLoader)(struct IPerlProc*, const char*);
0cb96387
GS
958typedef void (*LPProcGetOSError)(struct IPerlProc*,
959 SV* sv, DWORD dwErr);
0cb96387
GS
960typedef int (*LPProcSpawnvp)(struct IPerlProc*, int, const char*,
961 const char*const*);
0cb96387 962#endif
5f1a76d0 963typedef int (*LPProcLastHost)(struct IPerlProc*);
57ab3dfe
GS
964typedef int (*LPProcGetTimeOfDay)(struct IPerlProc*,
965 struct timeval*, void*);
0cb96387
GS
966
967struct IPerlProc
0f4eea8f 968{
0cb96387
GS
969 LPProcAbort pAbort;
970 LPProcCrypt pCrypt;
971 LPProcExit pExit;
972 LPProc_Exit p_Exit;
973 LPProcExecl pExecl;
974 LPProcExecv pExecv;
975 LPProcExecvp pExecvp;
976 LPProcGetuid pGetuid;
977 LPProcGeteuid pGeteuid;
978 LPProcGetgid pGetgid;
979 LPProcGetegid pGetegid;
980 LPProcGetlogin pGetlogin;
981 LPProcKill pKill;
982 LPProcKillpg pKillpg;
983 LPProcPauseProc pPauseProc;
984 LPProcPopen pPopen;
985 LPProcPclose pPclose;
986 LPProcPipe pPipe;
987 LPProcSetuid pSetuid;
988 LPProcSetgid pSetgid;
989 LPProcSleep pSleep;
990 LPProcTimes pTimes;
991 LPProcWait pWait;
992 LPProcWaitpid pWaitpid;
993 LPProcSignal pSignal;
7766f137
GS
994 LPProcFork pFork;
995 LPProcGetpid pGetpid;
0f4eea8f 996#ifdef WIN32
0cb96387
GS
997 LPProcDynaLoader pDynaLoader;
998 LPProcGetOSError pGetOSError;
0cb96387 999 LPProcSpawnvp pSpawnvp;
0f4eea8f 1000#endif
5f1a76d0 1001 LPProcLastHost pLastHost;
8c0134a8 1002 LPProcPopenList pPopenList;
57ab3dfe 1003 LPProcGetTimeOfDay pGetTimeOfDay;
0f4eea8f
DL
1004};
1005
0cb96387
GS
1006struct IPerlProcInfo
1007{
1008 unsigned long nCount; /* number of entries expected */
1009 struct IPerlProc perlProcList;
1010};
1011
1012#define PerlProc_abort() \
51371543 1013 (*PL_Proc->pAbort)(PL_Proc)
0cb96387 1014#define PerlProc_crypt(c,s) \
51371543 1015 (*PL_Proc->pCrypt)(PL_Proc, (c), (s))
0cb96387 1016#define PerlProc_exit(s) \
51371543 1017 (*PL_Proc->pExit)(PL_Proc, (s))
0cb96387 1018#define PerlProc__exit(s) \
51371543 1019 (*PL_Proc->p_Exit)(PL_Proc, (s))
0f4eea8f 1020#define PerlProc_execl(c, w, x, y, z) \
51371543 1021 (*PL_Proc->pExecl)(PL_Proc, (c), (w), (x), (y), (z))
0cb96387 1022#define PerlProc_execv(c, a) \
51371543 1023 (*PL_Proc->pExecv)(PL_Proc, (c), (a))
0cb96387 1024#define PerlProc_execvp(c, a) \
51371543 1025 (*PL_Proc->pExecvp)(PL_Proc, (c), (a))
0cb96387 1026#define PerlProc_getuid() \
51371543 1027 (*PL_Proc->pGetuid)(PL_Proc)
0cb96387 1028#define PerlProc_geteuid() \
51371543 1029 (*PL_Proc->pGeteuid)(PL_Proc)
0cb96387 1030#define PerlProc_getgid() \
51371543 1031 (*PL_Proc->pGetgid)(PL_Proc)
0cb96387 1032#define PerlProc_getegid() \
51371543 1033 (*PL_Proc->pGetegid)(PL_Proc)
0cb96387 1034#define PerlProc_getlogin() \
51371543 1035 (*PL_Proc->pGetlogin)(PL_Proc)
0cb96387 1036#define PerlProc_kill(i, a) \
51371543 1037 (*PL_Proc->pKill)(PL_Proc, (i), (a))
0cb96387 1038#define PerlProc_killpg(i, a) \
51371543 1039 (*PL_Proc->pKillpg)(PL_Proc, (i), (a))
0cb96387 1040#define PerlProc_pause() \
51371543 1041 (*PL_Proc->pPauseProc)(PL_Proc)
0cb96387 1042#define PerlProc_popen(c, m) \
51371543 1043 (*PL_Proc->pPopen)(PL_Proc, (c), (m))
4a7d1889
NIS
1044#define PerlProc_popen_list(m, n, a) \
1045 (*PL_Proc->pPopenList)(PL_Proc, (m), (n), (a))
0cb96387 1046#define PerlProc_pclose(f) \
51371543 1047 (*PL_Proc->pPclose)(PL_Proc, (f))
0cb96387 1048#define PerlProc_pipe(fd) \
51371543 1049 (*PL_Proc->pPipe)(PL_Proc, (fd))
0cb96387 1050#define PerlProc_setuid(u) \
51371543 1051 (*PL_Proc->pSetuid)(PL_Proc, (u))
0cb96387 1052#define PerlProc_setgid(g) \
51371543 1053 (*PL_Proc->pSetgid)(PL_Proc, (g))
0cb96387 1054#define PerlProc_sleep(t) \
51371543 1055 (*PL_Proc->pSleep)(PL_Proc, (t))
0cb96387 1056#define PerlProc_times(t) \
51371543 1057 (*PL_Proc->pTimes)(PL_Proc, (t))
0cb96387 1058#define PerlProc_wait(t) \
51371543 1059 (*PL_Proc->pWait)(PL_Proc, (t))
0cb96387 1060#define PerlProc_waitpid(p,s,f) \
51371543 1061 (*PL_Proc->pWaitpid)(PL_Proc, (p), (s), (f))
0cb96387 1062#define PerlProc_signal(n, h) \
51371543 1063 (*PL_Proc->pSignal)(PL_Proc, (n), (h))
7766f137
GS
1064#define PerlProc_fork() \
1065 (*PL_Proc->pFork)(PL_Proc)
1066#define PerlProc_getpid() \
1067 (*PL_Proc->pGetpid)(PL_Proc)
0cb96387
GS
1068#define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
1069#define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
0f4eea8f
DL
1070
1071#ifdef WIN32
0cb96387 1072#define PerlProc_DynaLoad(f) \
51371543 1073 (*PL_Proc->pDynaLoader)(PL_Proc, (f))
0cb96387 1074#define PerlProc_GetOSError(s,e) \
51371543 1075 (*PL_Proc->pGetOSError)(PL_Proc, (s), (e))
54725af6 1076#define PerlProc_spawnvp(m, c, a) \
51371543 1077 (*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a))
0f4eea8f 1078#endif
5f1a76d0
NIS
1079#define PerlProc_lasthost() \
1080 (*PL_Proc->pLastHost)(PL_Proc)
57ab3dfe
GS
1081#define PerlProc_gettimeofday(t,z) \
1082 (*PL_Proc->pGetTimeOfDay)(PL_Proc,(t),(z))
0f4eea8f 1083
c5be433b 1084#else /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
1085
1086#define PerlProc_abort() abort()
ff95b63e 1087#define PerlProc_crypt(c,s) crypt((c), (s))
0f4eea8f
DL
1088#define PerlProc_exit(s) exit((s))
1089#define PerlProc__exit(s) _exit((s))
1090#define PerlProc_execl(c,w,x,y,z) \
1091 execl((c), (w), (x), (y), (z))
1092#define PerlProc_execv(c, a) execv((c), (a))
1093#define PerlProc_execvp(c, a) execvp((c), (a))
1094#define PerlProc_getuid() getuid()
1095#define PerlProc_geteuid() geteuid()
1096#define PerlProc_getgid() getgid()
1097#define PerlProc_getegid() getegid()
1098#define PerlProc_getlogin() getlogin()
1099#define PerlProc_kill(i, a) kill((i), (a))
1100#define PerlProc_killpg(i, a) killpg((i), (a))
1101#define PerlProc_pause() Pause()
1102#define PerlProc_popen(c, m) my_popen((c), (m))
4a7d1889 1103#define PerlProc_popen_list(m,n,a) my_popen_list((m),(n),(a))
0f4eea8f
DL
1104#define PerlProc_pclose(f) my_pclose((f))
1105#define PerlProc_pipe(fd) pipe((fd))
1106#define PerlProc_setuid(u) setuid((u))
1107#define PerlProc_setgid(g) setgid((g))
1108#define PerlProc_sleep(t) sleep((t))
1109#define PerlProc_times(t) times((t))
1110#define PerlProc_wait(t) wait((t))
1111#define PerlProc_waitpid(p,s,f) waitpid((p), (s), (f))
1112#define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
1113#define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
1114#define PerlProc_signal(n, h) signal((n), (h))
52e18b1f 1115#define PerlProc_fork() my_fork()
7766f137 1116#define PerlProc_getpid() getpid()
57ab3dfe 1117#define PerlProc_gettimeofday(t,z) gettimeofday((t),(z))
0f4eea8f 1118
0cb96387
GS
1119#ifdef WIN32
1120#define PerlProc_DynaLoad(f) \
c5be433b 1121 win32_dynaload((f))
0cb96387 1122#define PerlProc_GetOSError(s,e) \
c5be433b 1123 win32_str_os_error((s), (e))
54725af6
GS
1124#define PerlProc_spawnvp(m, c, a) \
1125 win32_spawnvp((m), (c), (a))
b410b86c
MB
1126#undef PerlProc_signal
1127#define PerlProc_signal(n, h) win32_signal((n), (h))
0cb96387 1128#endif
c5be433b 1129#endif /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
1130
1131/*
1132 Interface for perl socket functions
1133*/
1134
c5be433b 1135#if defined(PERL_IMPLICIT_SYS)
0f4eea8f 1136
0cb96387
GS
1137/* PerlSock */
1138struct IPerlSock;
7766f137 1139struct IPerlSockInfo;
0cb96387
GS
1140typedef u_long (*LPHtonl)(struct IPerlSock*, u_long);
1141typedef u_short (*LPHtons)(struct IPerlSock*, u_short);
1142typedef u_long (*LPNtohl)(struct IPerlSock*, u_long);
1143typedef u_short (*LPNtohs)(struct IPerlSock*, u_short);
1144typedef SOCKET (*LPAccept)(struct IPerlSock*, SOCKET,
1145 struct sockaddr*, int*);
1146typedef int (*LPBind)(struct IPerlSock*, SOCKET,
1147 const struct sockaddr*, int);
1148typedef int (*LPConnect)(struct IPerlSock*, SOCKET,
1149 const struct sockaddr*, int);
1150typedef void (*LPEndhostent)(struct IPerlSock*);
1151typedef void (*LPEndnetent)(struct IPerlSock*);
1152typedef void (*LPEndprotoent)(struct IPerlSock*);
1153typedef void (*LPEndservent)(struct IPerlSock*);
1154typedef int (*LPGethostname)(struct IPerlSock*, char*, int);
1155typedef int (*LPGetpeername)(struct IPerlSock*, SOCKET,
1156 struct sockaddr*, int*);
1157typedef struct hostent* (*LPGethostbyaddr)(struct IPerlSock*, const char*,
1158 int, int);
1159typedef struct hostent* (*LPGethostbyname)(struct IPerlSock*, const char*);
1160typedef struct hostent* (*LPGethostent)(struct IPerlSock*);
1161typedef struct netent* (*LPGetnetbyaddr)(struct IPerlSock*, long, int);
1162typedef struct netent* (*LPGetnetbyname)(struct IPerlSock*, const char*);
1163typedef struct netent* (*LPGetnetent)(struct IPerlSock*);
1164typedef struct protoent*(*LPGetprotobyname)(struct IPerlSock*, const char*);
1165typedef struct protoent*(*LPGetprotobynumber)(struct IPerlSock*, int);
1166typedef struct protoent*(*LPGetprotoent)(struct IPerlSock*);
1167typedef struct servent* (*LPGetservbyname)(struct IPerlSock*, const char*,
1168 const char*);
1169typedef struct servent* (*LPGetservbyport)(struct IPerlSock*, int,
1170 const char*);
1171typedef struct servent* (*LPGetservent)(struct IPerlSock*);
1172typedef int (*LPGetsockname)(struct IPerlSock*, SOCKET,
1173 struct sockaddr*, int*);
1174typedef int (*LPGetsockopt)(struct IPerlSock*, SOCKET, int, int,
1175 char*, int*);
1176typedef unsigned long (*LPInetAddr)(struct IPerlSock*, const char*);
1177typedef char* (*LPInetNtoa)(struct IPerlSock*, struct in_addr);
1178typedef int (*LPListen)(struct IPerlSock*, SOCKET, int);
1179typedef int (*LPRecv)(struct IPerlSock*, SOCKET, char*, int, int);
1180typedef int (*LPRecvfrom)(struct IPerlSock*, SOCKET, char*, int,
1181 int, struct sockaddr*, int*);
1182typedef int (*LPSelect)(struct IPerlSock*, int, char*, char*,
1183 char*, const struct timeval*);
1184typedef int (*LPSend)(struct IPerlSock*, SOCKET, const char*, int,
6f9d8c32 1185 int);
0cb96387
GS
1186typedef int (*LPSendto)(struct IPerlSock*, SOCKET, const char*,
1187 int, int, const struct sockaddr*, int);
1188typedef void (*LPSethostent)(struct IPerlSock*, int);
1189typedef void (*LPSetnetent)(struct IPerlSock*, int);
1190typedef void (*LPSetprotoent)(struct IPerlSock*, int);
1191typedef void (*LPSetservent)(struct IPerlSock*, int);
1192typedef int (*LPSetsockopt)(struct IPerlSock*, SOCKET, int, int,
1193 const char*, int);
1194typedef int (*LPShutdown)(struct IPerlSock*, SOCKET, int);
1195typedef SOCKET (*LPSocket)(struct IPerlSock*, int, int, int);
1196typedef int (*LPSocketpair)(struct IPerlSock*, int, int, int,
1197 int*);
1198#ifdef WIN32
1199typedef int (*LPClosesocket)(struct IPerlSock*, SOCKET s);
1200#endif
1201
1202struct IPerlSock
0f4eea8f 1203{
0cb96387
GS
1204 LPHtonl pHtonl;
1205 LPHtons pHtons;
1206 LPNtohl pNtohl;
1207 LPNtohs pNtohs;
1208 LPAccept pAccept;
1209 LPBind pBind;
1210 LPConnect pConnect;
1211 LPEndhostent pEndhostent;
1212 LPEndnetent pEndnetent;
1213 LPEndprotoent pEndprotoent;
1214 LPEndservent pEndservent;
1215 LPGethostname pGethostname;
1216 LPGetpeername pGetpeername;
1217 LPGethostbyaddr pGethostbyaddr;
1218 LPGethostbyname pGethostbyname;
1219 LPGethostent pGethostent;
1220 LPGetnetbyaddr pGetnetbyaddr;
1221 LPGetnetbyname pGetnetbyname;
1222 LPGetnetent pGetnetent;
1223 LPGetprotobyname pGetprotobyname;
1224 LPGetprotobynumber pGetprotobynumber;
1225 LPGetprotoent pGetprotoent;
1226 LPGetservbyname pGetservbyname;
1227 LPGetservbyport pGetservbyport;
1228 LPGetservent pGetservent;
1229 LPGetsockname pGetsockname;
1230 LPGetsockopt pGetsockopt;
1231 LPInetAddr pInetAddr;
1232 LPInetNtoa pInetNtoa;
1233 LPListen pListen;
1234 LPRecv pRecv;
1235 LPRecvfrom pRecvfrom;
1236 LPSelect pSelect;
1237 LPSend pSend;
1238 LPSendto pSendto;
1239 LPSethostent pSethostent;
1240 LPSetnetent pSetnetent;
1241 LPSetprotoent pSetprotoent;
1242 LPSetservent pSetservent;
1243 LPSetsockopt pSetsockopt;
1244 LPShutdown pShutdown;
1245 LPSocket pSocket;
1246 LPSocketpair pSocketpair;
0f4eea8f 1247#ifdef WIN32
0cb96387 1248 LPClosesocket pClosesocket;
0f4eea8f
DL
1249#endif
1250};
1251
0cb96387
GS
1252struct IPerlSockInfo
1253{
1254 unsigned long nCount; /* number of entries expected */
1255 struct IPerlSock perlSockList;
1256};
1257
1258#define PerlSock_htonl(x) \
51371543 1259 (*PL_Sock->pHtonl)(PL_Sock, x)
0cb96387 1260#define PerlSock_htons(x) \
51371543 1261 (*PL_Sock->pHtons)(PL_Sock, x)
0cb96387 1262#define PerlSock_ntohl(x) \
51371543 1263 (*PL_Sock->pNtohl)(PL_Sock, x)
0cb96387 1264#define PerlSock_ntohs(x) \
51371543 1265 (*PL_Sock->pNtohs)(PL_Sock, x)
0cb96387 1266#define PerlSock_accept(s, a, l) \
51371543 1267 (*PL_Sock->pAccept)(PL_Sock, s, a, l)
0cb96387 1268#define PerlSock_bind(s, n, l) \
51371543 1269 (*PL_Sock->pBind)(PL_Sock, s, n, l)
0cb96387 1270#define PerlSock_connect(s, n, l) \
51371543 1271 (*PL_Sock->pConnect)(PL_Sock, s, n, l)
0cb96387 1272#define PerlSock_endhostent() \
51371543 1273 (*PL_Sock->pEndhostent)(PL_Sock)
0cb96387 1274#define PerlSock_endnetent() \
51371543 1275 (*PL_Sock->pEndnetent)(PL_Sock)
0cb96387 1276#define PerlSock_endprotoent() \
51371543 1277 (*PL_Sock->pEndprotoent)(PL_Sock)
0cb96387 1278#define PerlSock_endservent() \
51371543 1279 (*PL_Sock->pEndservent)(PL_Sock)
0cb96387 1280#define PerlSock_gethostbyaddr(a, l, t) \
51371543 1281 (*PL_Sock->pGethostbyaddr)(PL_Sock, a, l, t)
0cb96387 1282#define PerlSock_gethostbyname(n) \
51371543 1283 (*PL_Sock->pGethostbyname)(PL_Sock, n)
0cb96387 1284#define PerlSock_gethostent() \
51371543 1285 (*PL_Sock->pGethostent)(PL_Sock)
0cb96387 1286#define PerlSock_gethostname(n, l) \
51371543 1287 (*PL_Sock->pGethostname)(PL_Sock, n, l)
0cb96387 1288#define PerlSock_getnetbyaddr(n, t) \
51371543 1289 (*PL_Sock->pGetnetbyaddr)(PL_Sock, n, t)
0cb96387 1290#define PerlSock_getnetbyname(c) \
51371543 1291 (*PL_Sock->pGetnetbyname)(PL_Sock, c)
0cb96387 1292#define PerlSock_getnetent() \
51371543 1293 (*PL_Sock->pGetnetent)(PL_Sock)
0cb96387 1294#define PerlSock_getpeername(s, n, l) \
51371543 1295 (*PL_Sock->pGetpeername)(PL_Sock, s, n, l)
0cb96387 1296#define PerlSock_getprotobyname(n) \
51371543 1297 (*PL_Sock->pGetprotobyname)(PL_Sock, n)
0cb96387 1298#define PerlSock_getprotobynumber(n) \
51371543 1299 (*PL_Sock->pGetprotobynumber)(PL_Sock, n)
0cb96387 1300#define PerlSock_getprotoent() \
51371543 1301 (*PL_Sock->pGetprotoent)(PL_Sock)
0cb96387 1302#define PerlSock_getservbyname(n, p) \
51371543 1303 (*PL_Sock->pGetservbyname)(PL_Sock, n, p)
0cb96387 1304#define PerlSock_getservbyport(port, p) \
51371543 1305 (*PL_Sock->pGetservbyport)(PL_Sock, port, p)
0cb96387 1306#define PerlSock_getservent() \
51371543 1307 (*PL_Sock->pGetservent)(PL_Sock)
0cb96387 1308#define PerlSock_getsockname(s, n, l) \
51371543 1309 (*PL_Sock->pGetsockname)(PL_Sock, s, n, l)
0cb96387 1310#define PerlSock_getsockopt(s,l,n,v,i) \
51371543 1311 (*PL_Sock->pGetsockopt)(PL_Sock, s, l, n, v, i)
0cb96387 1312#define PerlSock_inet_addr(c) \
51371543 1313 (*PL_Sock->pInetAddr)(PL_Sock, c)
0cb96387 1314#define PerlSock_inet_ntoa(i) \
51371543 1315 (*PL_Sock->pInetNtoa)(PL_Sock, i)
0cb96387 1316#define PerlSock_listen(s, b) \
51371543 1317 (*PL_Sock->pListen)(PL_Sock, s, b)
0cb96387 1318#define PerlSock_recv(s, b, l, f) \
51371543 1319 (*PL_Sock->pRecv)(PL_Sock, s, b, l, f)
0f4eea8f 1320#define PerlSock_recvfrom(s,b,l,f,from,fromlen) \
51371543 1321 (*PL_Sock->pRecvfrom)(PL_Sock, s, b, l, f, from, fromlen)
0f4eea8f 1322#define PerlSock_select(n, r, w, e, t) \
51371543 1323 (*PL_Sock->pSelect)(PL_Sock, n, (char*)r, (char*)w, (char*)e, t)
0cb96387 1324#define PerlSock_send(s, b, l, f) \
51371543 1325 (*PL_Sock->pSend)(PL_Sock, s, b, l, f)
0f4eea8f 1326#define PerlSock_sendto(s, b, l, f, t, tlen) \
51371543 1327 (*PL_Sock->pSendto)(PL_Sock, s, b, l, f, t, tlen)
0cb96387 1328#define PerlSock_sethostent(f) \
51371543 1329 (*PL_Sock->pSethostent)(PL_Sock, f)
0cb96387 1330#define PerlSock_setnetent(f) \
51371543 1331 (*PL_Sock->pSetnetent)(PL_Sock, f)
0cb96387 1332#define PerlSock_setprotoent(f) \
51371543 1333 (*PL_Sock->pSetprotoent)(PL_Sock, f)
0cb96387 1334#define PerlSock_setservent(f) \
51371543 1335 (*PL_Sock->pSetservent)(PL_Sock, f)
0f4eea8f 1336#define PerlSock_setsockopt(s, l, n, v, len) \
51371543 1337 (*PL_Sock->pSetsockopt)(PL_Sock, s, l, n, v, len)
0cb96387 1338#define PerlSock_shutdown(s, h) \
51371543 1339 (*PL_Sock->pShutdown)(PL_Sock, s, h)
0cb96387 1340#define PerlSock_socket(a, t, p) \
51371543 1341 (*PL_Sock->pSocket)(PL_Sock, a, t, p)
0cb96387 1342#define PerlSock_socketpair(a, t, p, f) \
51371543 1343 (*PL_Sock->pSocketpair)(PL_Sock, a, t, p, f)
0cb96387
GS
1344
1345#ifdef WIN32
1346#define PerlSock_closesocket(s) \
51371543 1347 (*PL_Sock->pClosesocket)(PL_Sock, s)
0cb96387 1348#endif
0f4eea8f 1349
c5be433b 1350#else /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
1351
1352#define PerlSock_htonl(x) htonl(x)
1353#define PerlSock_htons(x) htons(x)
1354#define PerlSock_ntohl(x) ntohl(x)
1355#define PerlSock_ntohs(x) ntohs(x)
1356#define PerlSock_accept(s, a, l) accept(s, a, l)
1357#define PerlSock_bind(s, n, l) bind(s, n, l)
1358#define PerlSock_connect(s, n, l) connect(s, n, l)
1359
1360#define PerlSock_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
1361#define PerlSock_gethostbyname(n) gethostbyname(n)
1362#define PerlSock_gethostent gethostent
1363#define PerlSock_endhostent endhostent
1364#define PerlSock_gethostname(n, l) gethostname(n, l)
1365
1366#define PerlSock_getnetbyaddr(n, t) getnetbyaddr(n, t)
1367#define PerlSock_getnetbyname(n) getnetbyname(n)
1368#define PerlSock_getnetent getnetent
1369#define PerlSock_endnetent endnetent
1370#define PerlSock_getpeername(s, n, l) getpeername(s, n, l)
1371
1372#define PerlSock_getprotobyname(n) getprotobyname(n)
1373#define PerlSock_getprotobynumber(n) getprotobynumber(n)
1374#define PerlSock_getprotoent getprotoent
1375#define PerlSock_endprotoent endprotoent
1376
1377#define PerlSock_getservbyname(n, p) getservbyname(n, p)
1378#define PerlSock_getservbyport(port, p) getservbyport(port, p)
1379#define PerlSock_getservent getservent
1380#define PerlSock_endservent endservent
1381
1382#define PerlSock_getsockname(s, n, l) getsockname(s, n, l)
1383#define PerlSock_getsockopt(s,l,n,v,i) getsockopt(s, l, n, v, i)
1384#define PerlSock_inet_addr(c) inet_addr(c)
1385#define PerlSock_inet_ntoa(i) inet_ntoa(i)
1386#define PerlSock_listen(s, b) listen(s, b)
c6af7a1a 1387#define PerlSock_recv(s, b, l, f) recv(s, b, l, f)
0f4eea8f
DL
1388#define PerlSock_recvfrom(s, b, l, f, from, fromlen) \
1389 recvfrom(s, b, l, f, from, fromlen)
1390#define PerlSock_select(n, r, w, e, t) select(n, r, w, e, t)
1391#define PerlSock_send(s, b, l, f) send(s, b, l, f)
1392#define PerlSock_sendto(s, b, l, f, t, tlen) \
1393 sendto(s, b, l, f, t, tlen)
1394#define PerlSock_sethostent(f) sethostent(f)
1395#define PerlSock_setnetent(f) setnetent(f)
1396#define PerlSock_setprotoent(f) setprotoent(f)
1397#define PerlSock_setservent(f) setservent(f)
1398#define PerlSock_setsockopt(s, l, n, v, len) \
1399 setsockopt(s, l, n, v, len)
1400#define PerlSock_shutdown(s, h) shutdown(s, h)
1401#define PerlSock_socket(a, t, p) socket(a, t, p)
1402#define PerlSock_socketpair(a, t, p, f) socketpair(a, t, p, f)
1403
0cb96387
GS
1404#ifdef WIN32
1405#define PerlSock_closesocket(s) closesocket(s)
1406#endif
0f4eea8f 1407
c5be433b 1408#endif /* PERL_IMPLICIT_SYS */
0f4eea8f
DL
1409
1410#endif /* __Inc__IPerl___ */
1411
e9a8c099
MHM
1412/*
1413 * Local variables:
1414 * c-indentation-style: bsd
1415 * c-basic-offset: 4
1416 * indent-tabs-mode: t
1417 * End:
1418 *
1419 * ex: set ts=8 sts=4 sw=4 noet:
1420 */