Eliminate unused dummy variable
[p5sagit/p5-mst-13.2.git] / vms / vmsish.h
index b2814ad..fd4434e 100644 (file)
@@ -2,8 +2,8 @@
  *
  * VMS-specific C header file for perl5.
  *
- * Last revised: 01-Oct-1995 by Charles Bailey  bailey@genetics.upenn.edu
- * Version: 5.1.6
+ * Last revised: 18-Feb-1997 by Charles Bailey  bailey@genetics.upenn.edu
+ * Version: 5.3.28
  */
 
 #ifndef __vmsish_h_included
@@ -13,6 +13,7 @@
 #include <libdef.h>  /* status codes for various places */
 #include <rmsdef.h>  /* at which errno and vaxc$errno are */
 #include <ssdef.h>   /* explicitly set in the perl source code */
+#include <stsdef.h>  /* bitmasks for exit status testing */
 
 /* Suppress compiler warnings from DECC for VMS-specific extensions:
  * GLOBALEXT, NOSHAREEXT, READONLYEXT: global[dr]ef declarations
 #include <unixio.h>
 #include <unixlib.h>
 #include <file.h>  /* it's not <sys/file.h>, so don't use I_SYS_FILE */
-#ifdef __DECC
+#if defined(__DECC) && defined(__DECC_VER) && __DECC_VER > 20000000
 #  include <unistd.h> /* DECC has this; VAXC and gcc don't */
 #endif
 
+#ifdef NO_PERL_TYPEDEFS /* a2p; we don't want Perl's special routines */
+#  define DONT_MASK_RTL_CALLS
+#endif
+
+    /* defined for vms.c so we can see CRTL |  defined for a2p */
+#ifndef DONT_MASK_RTL_CALLS
+#  ifdef getenv
+#    undef getenv
+#  endif
+#  define getenv(v) my_getenv(v)  /* getenv used for regular logical names */
+#endif
+
+/* DECC introduces this routine in the RTL as of VMS 7.0; for now,
+ * we'll use ours, since it gives us the full VMS exit status. */
+#ifdef __PID_T
+#  define Pid_t pid_t
+#else
+#  define Pid_t unsigned int
+#endif
+#define waitpid my_waitpid
+
 /* Our own contribution to PerlShr's global symbols . . . */
 #ifdef EMBED
 #  define my_trnlnm            Perl_my_trnlnm
@@ -62,7 +84,7 @@
 #  define prime_env_iter       Perl_prime_env_iter
 #  define my_setenv            Perl_my_setenv
 #  define my_crypt             Perl_my_crypt
-#  define waitpid              Perl_waitpid
+#  define my_waitpid           Perl_my_waitpid
 #  define my_gconvert          Perl_my_gconvert
 #  define do_rmdir             Perl_do_rmdir
 #  define kill_file            Perl_kill_file
 #  define vmsreaddirversions   Perl_vmsreaddirversions
 #  define getredirection       Perl_getredirection
 #  define my_gmtime            Perl_my_gmtime
+#  define my_localtime         Perl_my_localtime
+#  define my_time              Perl_my_time
 #  define cando_by_name                Perl_cando_by_name
 #  define flex_fstat           Perl_flex_fstat
 #  define flex_stat            Perl_flex_stat
  * exec should be handled in VMSish or Unixish style.
  */
 #define fork my_vfork
-#ifndef __DONT_MASK_VFORK  /* #defined in vms.c so we see real vfork */
+#ifndef DONT_MASK_RTL_CALLS     /* #defined in vms.c so we see real vfork */
 #  ifdef vfork
 #    undef vfork
 #  endif
  */
 #undef ACME_MESS       /**/
 
+/* ALTERNATE_SHEBANG:
+ *     This symbol, if defined, contains a "magic" string which may be used
+ *     as the first line of a Perl program designed to be executed directly
+ *     by name, instead of the standard Unix #!.  If ALTERNATE_SHEBANG
+ *     begins with a character other then #, then Perl will only treat
+ *     it as a command line if if finds the string "perl" in the first
+ *     word; otherwise it's treated as the first line of code in the script.
+ *     (IOW, Perl won't hand off to another interpreter via an alternate
+ *     shebang sequence that might be legal Perl code.)
+ */
+#define ALTERNATE_SHEBANG "$"
+
 /* Macros to set errno using the VAX thread-safe calls, if present */
 #if (defined(__DECC) || defined(__DECCXX)) && !defined(__ALPHA)
 #  define set_errno(v)      (cma$tis_errno_set_value(v))
+   void cma$tis_errno_set_value(int __value);  /* missing in some errno.h */
 #  define set_vaxc_errno(v) (vaxc$errno = (v))
 #else
 #  define set_errno(v)      (errno = (v))
 #  define set_vaxc_errno(v) (vaxc$errno = (v))
 #endif
 
+/* Support for 'vmsish' behaviors enabled with C<use vmsish> pragma */
+
+#define COMPLEX_STATUS 1       /* We track both "POSIX" and VMS values */
+
+#define HINT_V_VMSISH          24
+#define HINT_M_VMSISH_STATUS   0x01000000 /* system, $? return VMS status */
+#define HINT_M_VMSISH_EXIT     0x02000000 /* exit(1) ==> SS$_NORMAL */
+#define HINT_M_VMSISH_TIME     0x04000000 /* times are local, not UTC */
+#define NATIVE_HINTS           (hints >> HINT_V_VMSISH)  /* used in op.c */
+
+#define TEST_VMSISH(h) (curcop->op_private & ((h) >> HINT_V_VMSISH))
+#define VMSISH_STATUS  TEST_VMSISH(HINT_M_VMSISH_STATUS)
+#define VMSISH_EXIT    TEST_VMSISH(HINT_M_VMSISH_EXIT)
+#define VMSISH_TIME    TEST_VMSISH(HINT_M_VMSISH_TIME)
+
 /* Handy way to vet calls to VMS system services and RTL routines. */
 #define _ckvmssts(call) STMT_START { register unsigned long int __ckvms_sts; \
   if (!((__ckvms_sts=(call))&1)) { \
@@ -271,9 +323,12 @@ struct utimbuf {
 /* Prior to VMS 7.0, the CRTL gmtime() routine was a stub which always
  * returned NULL.  Substitute our own routine, which uses the logical
  * SYS$TIMEZONE_DIFFERENTIAL, whcih the native UTC support routines
- * in VMS 6.0 or later use.*
+ * in VMS 6.0 or later use.  We also add shims for time() and localtime()
+ * so we can run on UTC by default.
  */
 #define gmtime(t) my_gmtime(t)
+#define localtime(t) my_localtime(t)
+#define time(t) my_time(t)
 
 /* VMS doesn't use a real sys_nerr, but we need this when scanning for error
  * messages in text strings . . .
@@ -284,6 +339,9 @@ struct utimbuf {
 /* Look up new %ENV values on the fly */
 #define DYNAMIC_ENV_FETCH 1
 #define ENV_HV_NAME "%EnV%VmS%"
+  /* Special getenv function for retrieving %ENV elements. */
+#define ENV_getenv(v) my_getenv(v)
+
 
 /* Thin jacket around cuserid() tomatch Unix' calling sequence */
 #define getlogin my_getlogin
@@ -302,7 +360,6 @@ struct utimbuf {
  * opendir(), closedir(), readdir(), seekdir(), telldir(), and
  * vmsreaddirversions(), and preprocessor stuff on which these depend:
  *    Written by Rich $alz, <rsalz@bbn.com> in August, 1990.
- *    This code has no copyright.
  */
     /* Data structure returned by READDIR(). */
 struct dirent {
@@ -387,11 +444,16 @@ struct mystat
         char   st_fab_fsz;     /* fixed header size */
         unsigned st_dev;       /* encoded device name */
 };
-#define stat mystat
 typedef unsigned mydev_t;
-#define dev_t mydev_t
 typedef unsigned myino_t;
-#define ino_t myino_t
+#ifndef DONT_MASK_RTL_CALLS  /* defined for vms.c so we can see RTL calls */
+#  ifdef stat
+#    undef stat
+#  endif
+#  define stat mystat
+#  define dev_t mydev_t
+#  define ino_t myino_t
+#endif
 #if defined(__DECC) || defined(__DECCXX)
 #  pragma __member_alignment __restore
 #endif
@@ -413,6 +475,25 @@ typedef unsigned myino_t;
  *    <data type><TAB>name<WHITESPACE>_((<prototype args>));
  */
 
+#ifdef NO_PERL_TYPEDEFS
+  /* We don't have Perl typedefs available (e.g. when building a2p), so
+     we fake them here.  N.B.  There is *no* guarantee that the faked
+     prototypes will actually match the real routines.  If you want to
+     call Perl routines, include perl.h to get the real typedefs.  */
+#  ifndef bool
+#    define bool int
+#    define __MY_BOOL_TYPE_FAKE
+#  endif
+#  ifndef I32
+#    define I32  int
+#    define __MY_I32_TYPE_FAKE
+#  endif
+#  ifndef SV
+#    define SV   void   /* Since we only see SV * in prototypes */
+#    define __MY_SV_TYPE_FAKE
+#  endif
+#endif
+
 void   prime_env_iter _((void));
 void   getredirection _((int *, char ***));
 void   init_os_extras _(());
@@ -421,7 +502,7 @@ typedef char  __VMS_PROTOTYPES__;
 int    my_trnlnm _((char *, char *, unsigned long int));
 char * my_getenv _((char *));
 char * my_crypt _((const char *, const char *));
-unsigned long int      waitpid _((unsigned long int, int *, int));
+Pid_t  my_waitpid _((Pid_t, int *, int));
 char * my_gconvert _((double, int, int, char *));
 int    do_rmdir _((char *));
 int    kill_file _((char *));
@@ -447,11 +528,13 @@ long      telldir _((DIR *));
 void   seekdir _((DIR *, long));
 void   closedir _((DIR *));
 void   vmsreaddirversions _((DIR *, int));
-struct tm *my_gmtime _((const time_t *));
+struct tm *    my_gmtime _((const time_t *));
+struct tm *    my_localtime _((const time_t *));
+time_t my_time _((time_t *));
 I32    cando_by_name _((I32, I32, char *));
-int    flex_fstat _((int, struct stat *));
-int    flex_stat _((char *, struct stat *));
-int    trim_unixpath _((char *, char*));
+int    flex_fstat _((int, struct mystat *));
+int    flex_stat _((char *, struct mystat *));
+int    trim_unixpath _((char *, char*, int));
 int    my_vfork _(());
 bool   vms_do_aexec _((SV *, SV **, SV **));
 bool   vms_do_exec _((char *));
@@ -468,6 +551,21 @@ int        rmscopy _((char *, char *, int));
 typedef char __VMS_SEPYTOTORP__;
 /* prototype section end marker; `typedef' passes through cpp */
 
+#ifdef NO_PERL_TYPEDEFS  /* We'll try not to scramble later files */
+#  ifdef __MY_BOOL_TYPE_FAKE
+#    undef bool
+#    undef __MY_BOOL_TYPE_FAKE
+#  endif
+#  ifdef __MY_I32_TYPE_FAKE
+#    undef I32
+#    undef __MY_I32_TYPE_FAKE
+#  endif
+#  ifdef __MY_SV_TYPE_FAKE
+#    undef SV
+#    undef __MY_SV_TYPE_FAKE
+#  endif
+#endif
+
 #ifndef VMS_DO_SOCKETS
 /* This relies on tricks in perl.h to pick up that these manifest constants
  * are undefined and set up conversion routines.  It will then redefine