* that can be #defined to the system-level function (or a wrapper
* provided elsewhere).
*
- * When using C++ with -DPERL_OBJECT, this definition is in the
- * form of a set of virtual base classes which must be subclassed to
- * provide a real implementation. The Perl Object will use instances
- * of this implementation to use the system-level functionality.
- *
* GSAR 21-JUN-98
*/
#include "perlio.h"
#ifndef Sighandler_t
+# if defined(HAS_SIGACTION) && defined(SA_SIGINFO)
+typedef Signal_t (*Sighandler_t) (int, ...);
+# else
typedef Signal_t (*Sighandler_t) (int);
+# endif
#endif
#if defined(PERL_IMPLICIT_SYS)
typedef int (*LPSetVBuf)(struct IPerlStdIO*, FILE*, char*, int,
Size_t);
typedef void (*LPSetCnt)(struct IPerlStdIO*, FILE*, int);
+
+#ifndef NETWARE
typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*);
+#elif defined(NETWARE)
+typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*, int);
+#endif
+
typedef void (*LPSetlinebuf)(struct IPerlStdIO*, FILE*);
typedef int (*LPPrintf)(struct IPerlStdIO*, FILE*, const char*,
...);
typedef int (*LPVprintf)(struct IPerlStdIO*, FILE*, const char*,
va_list);
-typedef long (*LPTell)(struct IPerlStdIO*, FILE*);
+typedef Off_t (*LPTell)(struct IPerlStdIO*, FILE*);
typedef int (*LPSeek)(struct IPerlStdIO*, FILE*, Off_t, int);
typedef void (*LPRewind)(struct IPerlStdIO*, FILE*);
typedef FILE* (*LPTmpfile)(struct IPerlStdIO*);
#define PerlSIO_setlinebuf(f) \
(*PL_StdIO->pSetlinebuf)(PL_StdIO, (f))
#define PerlSIO_printf Perl_fprintf_nocontext
-#define PerlSIO_stdoutf *PL_StdIO->pPrintf
-#define PerlSIO_vprintf(f,fmt,a) \
+#define PerlSIO_stdoutf Perl_printf_nocontext
+#define PerlSIO_vprintf(f,fmt,a) \
(*PL_StdIO->pVprintf)(PL_StdIO, (f),(fmt),a)
#define PerlSIO_ftell(f) \
(*PL_StdIO->pTell)(PL_StdIO, (f))
#define PerlSIO_stdout stdout
#define PerlSIO_stderr stderr
#define PerlSIO_fopen(x,y) fopen(x,y)
+#ifdef __VOS__
+/* Work around VOS bug posix-979, wrongly setting errno when at end of file. */
+#define PerlSIO_fclose(f) (((errno==1025)?errno=0:0),fclose(f))
+#define PerlSIO_feof(f) (((errno==1025)?errno=0:0),feof(f))
+#define PerlSIO_ferror(f) (((errno==1025)?errno=0:0),ferror(f))
+#else
#define PerlSIO_fclose(f) fclose(f)
#define PerlSIO_feof(f) feof(f)
#define PerlSIO_ferror(f) ferror(f)
+#endif
#define PerlSIO_clearerr(f) clearerr(f)
#define PerlSIO_fgetc(f) fgetc(f)
-#if PerlSIO_has_base
+#ifdef FILE_base
#define PerlSIO_get_base(f) FILE_base(f)
#define PerlSIO_get_bufsiz(f) FILE_bufsiz(f)
#else
#define PerlSIO_fputs(f,s) fputs(s,f)
#define PerlSIO_fflush(f) Fflush(f)
#define PerlSIO_fgets(s, n, fp) fgets(s,n,fp)
-#define PerlSIO_ungetc(c,f) ungetc(c,f)
+#if defined(VMS) && defined(__DECC)
+ /* Unusual definition of ungetc() here to accomodate fast_sv_gets()'
+ * belief that it can mix getc/ungetc with reads from stdio buffer */
+ int decc$ungetc(int __c, FILE *__stream);
+# define PerlSIO_ungetc(c,f) ((c) == EOF ? EOF : \
+ ((*(f) && !((*(f))->_flag & _IONBF) && \
+ ((*(f))->_ptr > (*(f))->_base)) ? \
+ ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f)))
+#else
+# define PerlSIO_ungetc(c,f) ungetc(c,f)
+#endif
#define PerlSIO_fileno(f) fileno(f)
#define PerlSIO_fdopen(f, s) fdopen(f,s)
#define PerlSIO_freopen(p, m, f) freopen(p,m,f)
#define PerlSIO_set_cnt(f,c) PerlIOProc_abort()
#endif
#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE)
-#define PerlSIO_set_ptr(f,p) FILE_ptr(f) = (p)
+#define PerlSIO_set_ptr(f,p) FILE_ptr(f) = ((STDCHAR*)(p))
#else
#define PerlSIO_set_ptr(f,p) PerlIOProc_abort()
#endif
#define PerlSIO_setlinebuf(f) setlinebuf(f)
-#define PerlSIO_printf Perl_fprintf_nocontext
-#define PerlSIO_stdoutf *PL_StdIO->pPrintf
-#define PerlSIO_vprintf(f,fmt,a)
+#define PerlSIO_printf fprintf
+#define PerlSIO_stdoutf printf
+#define PerlSIO_vprintf(f,fmt,a) vfprintf(f,fmt,a)
#define PerlSIO_ftell(f) ftell(f)
#define PerlSIO_fseek(f,o,w) fseek(f,o,w)
#define PerlSIO_fgetpos(f,p) fgetpos(f,p)
typedef int (*LPChdir)(struct IPerlDir*, const char*);
typedef int (*LPRmdir)(struct IPerlDir*, const char*);
typedef int (*LPDirClose)(struct IPerlDir*, DIR*);
-typedef DIR* (*LPDirOpen)(struct IPerlDir*, char*);
+typedef DIR* (*LPDirOpen)(struct IPerlDir*, const char*);
typedef struct direct* (*LPDirRead)(struct IPerlDir*, DIR*);
typedef void (*LPDirRewind)(struct IPerlDir*, DIR*);
typedef void (*LPDirSeek)(struct IPerlDir*, DIR*, long);
#define PerlDir_mkdir(name, mode) Mkdir((name), (mode))
#ifdef VMS
-# define PerlDir_chdir(n) Chdir(((n) && *(n)) ? (n) : "SYS$LOGIN")
+# define PerlDir_chdir(n) Chdir((n))
#else
# define PerlDir_chdir(name) chdir((name))
#endif
#define PerlEnv_putenv(str) putenv((str))
#define PerlEnv_getenv(str) getenv((str))
#define PerlEnv_getenv_len(str,l) getenv_len((str), (l))
-#define PerlEnv_clearenv() clearenv()
-#define PerlEnv_get_childenv() get_childenv()
-#define PerlEnv_free_childenv(e) free_childenv((e))
-#define PerlEnv_get_childdir() get_childdir()
-#define PerlEnv_free_childdir(d) free_childdir((d))
#ifdef HAS_ENVGETENV
# define PerlEnv_ENVgetenv(str) ENVgetenv((str))
# define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l))
#define PerlEnv_sitelib_path(str) win32_get_sitelib(str)
#define PerlEnv_vendorlib_path(str) win32_get_vendorlib(str)
#define PerlEnv_get_child_IO(ptr) win32_get_child_IO(ptr)
+#define PerlEnv_clearenv() win32_clearenv()
+#define PerlEnv_get_childenv() win32_get_childenv()
+#define PerlEnv_free_childenv(e) win32_free_childenv((e))
+#define PerlEnv_get_childdir() win32_get_childdir()
+#define PerlEnv_free_childdir(d) win32_free_childdir((d))
+#else
+#define PerlEnv_clearenv() clearenv()
+#define PerlEnv_get_childenv() get_childenv()
+#define PerlEnv_free_childenv(e) free_childenv((e))
+#define PerlEnv_get_childdir() get_childdir()
+#define PerlEnv_free_childdir(d) free_childdir((d))
#endif
#endif /* PERL_IMPLICIT_SYS */
typedef int (*LPLIOChmod)(struct IPerlLIO*, const char*, int);
typedef int (*LPLIOChown)(struct IPerlLIO*, const char*, uid_t,
gid_t);
-typedef int (*LPLIOChsize)(struct IPerlLIO*, int, long);
+typedef int (*LPLIOChsize)(struct IPerlLIO*, int, Off_t);
typedef int (*LPLIOClose)(struct IPerlLIO*, int);
typedef int (*LPLIODup)(struct IPerlLIO*, int);
typedef int (*LPLIODup2)(struct IPerlLIO*, int, int);
typedef int (*LPLIOFlock)(struct IPerlLIO*, int, int);
-typedef int (*LPLIOFileStat)(struct IPerlLIO*, int, struct stat*);
+typedef int (*LPLIOFileStat)(struct IPerlLIO*, int, Stat_t*);
typedef int (*LPLIOIOCtl)(struct IPerlLIO*, int, unsigned int,
char*);
typedef int (*LPLIOIsatty)(struct IPerlLIO*, int);
typedef int (*LPLIOLink)(struct IPerlLIO*, const char*,
const char *);
-typedef long (*LPLIOLseek)(struct IPerlLIO*, int, long, int);
+typedef Off_t (*LPLIOLseek)(struct IPerlLIO*, int, Off_t, int);
typedef int (*LPLIOLstat)(struct IPerlLIO*, const char*,
- struct stat*);
+ Stat_t*);
typedef char* (*LPLIOMktemp)(struct IPerlLIO*, char*);
typedef int (*LPLIOOpen)(struct IPerlLIO*, const char*, int);
typedef int (*LPLIOOpen3)(struct IPerlLIO*, const char*, int, int);
typedef int (*LPLIORead)(struct IPerlLIO*, int, void*, unsigned int);
typedef int (*LPLIORename)(struct IPerlLIO*, const char*,
const char*);
+#ifdef NETWARE
+typedef int (*LPLIOSetmode)(struct IPerlLIO*, FILE*, int);
+#else
typedef int (*LPLIOSetmode)(struct IPerlLIO*, int, int);
+#endif /* NETWARE */
typedef int (*LPLIONameStat)(struct IPerlLIO*, const char*,
- struct stat*);
+ Stat_t*);
typedef char* (*LPLIOTmpnam)(struct IPerlLIO*, char*);
typedef int (*LPLIOUmask)(struct IPerlLIO*, int);
typedef int (*LPLIOUnlink)(struct IPerlLIO*, const char*);
-typedef int (*LPLIOUtime)(struct IPerlLIO*, char*, struct utimbuf*);
+typedef int (*LPLIOUtime)(struct IPerlLIO*, const char*, struct utimbuf*);
typedef int (*LPLIOWrite)(struct IPerlLIO*, int, const void*,
unsigned int);
#define PerlLIO_access(file, mode) access((file), (mode))
#define PerlLIO_chmod(file, mode) chmod((file), (mode))
#define PerlLIO_chown(file, owner, grp) chown((file), (owner), (grp))
-#define PerlLIO_chsize(fd, size) chsize((fd), (size))
+#if defined(HAS_TRUNCATE)
+# define PerlLIO_chsize(fd, size) ftruncate((fd), (size))
+#elif defined(HAS_CHSIZE)
+# define PerlLIO_chsize(fd, size) chsize((fd), (size))
+#else
+# define PerlLIO_chsize(fd, size) my_chsize((fd), (size))
+#endif
#define PerlLIO_close(fd) close((fd))
#define PerlLIO_dup(fd) dup((fd))
#define PerlLIO_dup2(fd1, fd2) dup2((fd1), (fd2))
(*PL_Mem->pIsLocked)(PL_Mem)
/* Shared memory macros */
+#ifdef NETWARE
+
#define PerlMemShared_malloc(size) \
- (*PL_MemShared->pMalloc)(PL_Mem, (size))
+ (*PL_Mem->pMalloc)(PL_Mem, (size))
#define PerlMemShared_realloc(buf, size) \
- (*PL_MemShared->pRealloc)(PL_Mem, (buf), (size))
+ (*PL_Mem->pRealloc)(PL_Mem, (buf), (size))
#define PerlMemShared_free(buf) \
- (*PL_MemShared->pFree)(PL_Mem, (buf))
+ (*PL_Mem->pFree)(PL_Mem, (buf))
#define PerlMemShared_calloc(num, size) \
- (*PL_MemShared->pCalloc)(PL_Mem, (num), (size))
+ (*PL_Mem->pCalloc)(PL_Mem, (num), (size))
#define PerlMemShared_get_lock() \
- (*PL_MemShared->pGetLock)(PL_Mem)
+ (*PL_Mem->pGetLock)(PL_Mem)
#define PerlMemShared_free_lock() \
- (*PL_MemShared->pFreeLock)(PL_Mem)
+ (*PL_Mem->pFreeLock)(PL_Mem)
#define PerlMemShared_is_locked() \
- (*PL_MemShared->pIsLocked)(PL_Mem)
+ (*PL_Mem->pIsLocked)(PL_Mem)
+#else
+
+#define PerlMemShared_malloc(size) \
+ (*PL_MemShared->pMalloc)(PL_MemShared, (size))
+#define PerlMemShared_realloc(buf, size) \
+ (*PL_MemShared->pRealloc)(PL_MemShared, (buf), (size))
+#define PerlMemShared_free(buf) \
+ (*PL_MemShared->pFree)(PL_MemShared, (buf))
+#define PerlMemShared_calloc(num, size) \
+ (*PL_MemShared->pCalloc)(PL_MemShared, (num), (size))
+#define PerlMemShared_get_lock() \
+ (*PL_MemShared->pGetLock)(PL_MemShared)
+#define PerlMemShared_free_lock() \
+ (*PL_MemShared->pFreeLock)(PL_MemShared)
+#define PerlMemShared_is_locked() \
+ (*PL_MemShared->pIsLocked)(PL_MemShared)
+
+#endif
/* Parse tree memory macros */
#define PerlMemParse_malloc(size) \
- (*PL_MemParse->pMalloc)(PL_Mem, (size))
+ (*PL_MemParse->pMalloc)(PL_MemParse, (size))
#define PerlMemParse_realloc(buf, size) \
- (*PL_MemParse->pRealloc)(PL_Mem, (buf), (size))
+ (*PL_MemParse->pRealloc)(PL_MemParse, (buf), (size))
#define PerlMemParse_free(buf) \
- (*PL_MemParse->pFree)(PL_Mem, (buf))
+ (*PL_MemParse->pFree)(PL_MemParse, (buf))
#define PerlMemParse_calloc(num, size) \
- (*PL_MemParse->pCalloc)(PL_Mem, (num), (size))
+ (*PL_MemParse->pCalloc)(PL_MemParse, (num), (size))
#define PerlMemParse_get_lock() \
- (*PL_MemParse->pGetLock)(PL_Mem)
+ (*PL_MemParse->pGetLock)(PL_MemParse)
#define PerlMemParse_free_lock() \
- (*PL_MemParse->pFreeLock)(PL_Mem)
+ (*PL_MemParse->pFreeLock)(PL_MemParse)
#define PerlMemParse_is_locked() \
- (*PL_MemParse->pIsLocked)(PL_Mem)
+ (*PL_MemParse->pIsLocked)(PL_MemParse)
#else /* PERL_IMPLICIT_SYS */
typedef void (*LPProcAbort)(struct IPerlProc*);
typedef char* (*LPProcCrypt)(struct IPerlProc*, const char*,
const char*);
-typedef void (*LPProcExit)(struct IPerlProc*, int);
-typedef void (*LPProc_Exit)(struct IPerlProc*, int);
+typedef void (*LPProcExit)(struct IPerlProc*, int)
+ __attribute__noreturn__;
+typedef void (*LPProc_Exit)(struct IPerlProc*, int)
+ __attribute__noreturn__;
typedef int (*LPProcExecl)(struct IPerlProc*, const char*,
const char*, const char*, const char*,
const char*);
typedef int (*LPProcPauseProc)(struct IPerlProc*);
typedef PerlIO* (*LPProcPopen)(struct IPerlProc*, const char*,
const char*);
+typedef PerlIO* (*LPProcPopenList)(struct IPerlProc*, const char*,
+ IV narg, SV **args);
typedef int (*LPProcPclose)(struct IPerlProc*, PerlIO*);
typedef int (*LPProcPipe)(struct IPerlProc*, int*);
typedef int (*LPProcSetuid)(struct IPerlProc*, uid_t);
typedef void* (*LPProcDynaLoader)(struct IPerlProc*, const char*);
typedef void (*LPProcGetOSError)(struct IPerlProc*,
SV* sv, DWORD dwErr);
-typedef void (*LPProcFreeBuf)(struct IPerlProc*, char*);
-typedef BOOL (*LPProcDoCmd)(struct IPerlProc*, char*);
-typedef int (*LPProcSpawn)(struct IPerlProc*, char*);
typedef int (*LPProcSpawnvp)(struct IPerlProc*, int, const char*,
const char*const*);
-typedef int (*LPProcASpawn)(struct IPerlProc*, void*, void**, void**);
#endif
typedef int (*LPProcLastHost)(struct IPerlProc*);
+typedef int (*LPProcGetTimeOfDay)(struct IPerlProc*,
+ struct timeval*, void*);
struct IPerlProc
{
#ifdef WIN32
LPProcDynaLoader pDynaLoader;
LPProcGetOSError pGetOSError;
- LPProcDoCmd pDoCmd;
- LPProcSpawn pSpawn;
LPProcSpawnvp pSpawnvp;
- LPProcASpawn pASpawn;
#endif
LPProcLastHost pLastHost;
+ LPProcPopenList pPopenList;
+ LPProcGetTimeOfDay pGetTimeOfDay;
};
struct IPerlProcInfo
(*PL_Proc->pPauseProc)(PL_Proc)
#define PerlProc_popen(c, m) \
(*PL_Proc->pPopen)(PL_Proc, (c), (m))
+#define PerlProc_popen_list(m, n, a) \
+ (*PL_Proc->pPopenList)(PL_Proc, (m), (n), (a))
#define PerlProc_pclose(f) \
(*PL_Proc->pPclose)(PL_Proc, (f))
#define PerlProc_pipe(fd) \
(*PL_Proc->pDynaLoader)(PL_Proc, (f))
#define PerlProc_GetOSError(s,e) \
(*PL_Proc->pGetOSError)(PL_Proc, (s), (e))
-#define PerlProc_Cmd(s) \
- (*PL_Proc->pDoCmd)(PL_Proc, (s))
-#define do_spawn(s) \
- (*PL_Proc->pSpawn)(PL_Proc, (s))
-#define do_spawnvp(m, c, a) \
+#define PerlProc_spawnvp(m, c, a) \
(*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a))
-#define PerlProc_aspawn(m,c,a) \
- (*PL_Proc->pASpawn)(PL_Proc, (m), (c), (a))
#endif
#define PerlProc_lasthost() \
(*PL_Proc->pLastHost)(PL_Proc)
+#define PerlProc_gettimeofday(t,z) \
+ (*PL_Proc->pGetTimeOfDay)(PL_Proc,(t),(z))
#else /* PERL_IMPLICIT_SYS */
#define PerlProc_killpg(i, a) killpg((i), (a))
#define PerlProc_pause() Pause()
#define PerlProc_popen(c, m) my_popen((c), (m))
+#define PerlProc_popen_list(m,n,a) my_popen_list((m),(n),(a))
#define PerlProc_pclose(f) my_pclose((f))
#define PerlProc_pipe(fd) pipe((fd))
#define PerlProc_setuid(u) setuid((u))
#define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
#define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
#define PerlProc_signal(n, h) signal((n), (h))
-#define PerlProc_fork() fork()
+#define PerlProc_fork() my_fork()
#define PerlProc_getpid() getpid()
+#define PerlProc_gettimeofday(t,z) gettimeofday((t),(z))
#ifdef WIN32
#define PerlProc_DynaLoad(f) \
win32_dynaload((f))
#define PerlProc_GetOSError(s,e) \
win32_str_os_error((s), (e))
+#define PerlProc_spawnvp(m, c, a) \
+ win32_spawnvp((m), (c), (a))
+#undef PerlProc_signal
+#define PerlProc_signal(n, h) win32_signal((n), (h))
#endif
#endif /* PERL_IMPLICIT_SYS */