patch to 5.004_01 perltrap.pod
[p5sagit/p5-mst-13.2.git] / os2 / os2ish.h
index 917f515..a1b6db9 100644 (file)
  */
 #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 "extproc "
+
 #ifndef SIGABRT
 #    define SIGABRT SIGILL
 #endif
 #endif
 #define ABORT() kill(getpid(),SIGABRT);
 
-#define BIT_BUCKET "/dev/null"  /* Will this work? */
+#define BIT_BUCKET "/dev/nul"  /* Will this work? */
+
+#if defined(I_SYS_UN) && !defined(TCPIPV4)
+/* It is not working without TCPIPV4 defined. */
+# undef I_SYS_UN
+#endif 
+void Perl_OS2_init(char **);
 
-void Perl_OS2_init();
+/* XXX This code hideously puts env inside: */
 
 #define PERL_SYS_INIT(argcp, argvp) STMT_START {       \
     _response(argcp, argvp);                   \
     _wildcard(argcp, argvp);                   \
-    Perl_OS2_init();   } STMT_END
+    Perl_OS2_init(env);        } STMT_END
 
 #define PERL_SYS_TERM()
 
 /* #define PERL_SYS_TERM() STMT_START {        \
     if (Perl_HAB_set) WinTerminate(Perl_hab);  } STMT_END */
 
-#define dXSUB_SYS int fake = OS2_XS_init()
+#define dXSUB_SYS OS2_XS_init()
 
 #ifdef PERL_IS_AOUT
-#define NO_SYS_ALLOC
+/* #  define HAS_FORK */
+/* #  define HIDEMYMALLOC */
+/* #  define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
+#else /* !PERL_IS_AOUT */
+#  ifndef PERL_FOR_X2P
+#    ifdef EMX_BAD_SBRK
+#      define USE_PERL_SBRK
+#    endif 
+#  else
+#    define PerlIO FILE
+#  endif 
+#  define SYSTEM_ALLOC(a) sys_alloc(a)
+
+void *sys_alloc(int size);
+
+#endif /* !PERL_IS_AOUT */
+#if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
+#  define PerlIO FILE
 #endif 
 
 #define TMPPATH tmppath
 #define TMPPATH1 "plXXXXXX"
 extern char *tmppath;
+PerlIO *my_syspopen(char *cmd, char *mode);
+/* Cannot prototype with I32 at this point. */
+int my_syspclose(PerlIO *f);
+FILE *my_tmpfile (void);
+char *my_tmpnam (char *);
+
+#define tmpfile        my_tmpfile
+#define tmpnam my_tmpnam
+#define isatty _isterm
+#define rand   random
+#define srand  srandom
 
 /*
  * fwrite1() should be a routine with the same calling sequence as fwrite(),
@@ -79,6 +126,11 @@ extern char *tmppath;
 
 #define my_getenv(var) getenv(var)
 
+void *emx_calloc (size_t, size_t);
+void emx_free (void *);
+void *emx_malloc (size_t);
+void *emx_realloc (void *, size_t);
+
 /*****************************************************************************/
 
 #include <stdlib.h>    /* before the following definitions */
@@ -90,7 +142,6 @@ extern char *tmppath;
 /* This guy is needed for quick stdstd  */
 
 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
-#  define _filbuf _fill
        /* Perl uses ungetc only with successful return */
 #  define ungetc(c,fp) \
        (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
@@ -105,6 +156,7 @@ extern char *tmppath;
 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
 #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
 #define Fflush(fp)         fflush(fp)
+#define Mkdir(path,mode)   mkdir((path),(mode))
 
 #undef S_IFBLK
 #undef S_ISBLK
@@ -116,7 +168,13 @@ extern char *tmppath;
 #define Stat(fname,bufptr) stat((fname),(bufptr))
 #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
 #define Fflush(fp)         fflush(fp)
+#define Mkdir(path,mode)   mkdir((path),(mode))
+
+#endif
 
+/* With SD386 it is impossible to debug register variables. */
+#if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
+#  define register
 #endif
 
 /* Our private OS/2 specific data. */
@@ -142,7 +200,7 @@ extern OS2_Perl_data_t OS2_Perl_data;
 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
 #define OS2_XS_init() (*OS2_Perl_data.xs_init)()
 /* The expressions below return true on error. */
-/* INCL_DOSERRORS needed. */
+/* INCL_DOSERRORS needed. rc should be declared outside. */
 #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
 /* INCL_WINERRORS needed. */
 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
@@ -160,8 +218,10 @@ extern OS2_Perl_data_t OS2_Perl_data;
           set_Perl_HAB_f;                                              \
        }
 
-extern char sh_path[33];
-#define SH_PATH sh_path
+#define STATIC_FILE_LENGTH 127
+
+#define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
+char *perllib_mangle(char *, unsigned int);
 
 char *os2error(int rc);
 
@@ -171,8 +231,8 @@ char *os2error(int rc);
        Dos32QuerySysState(flags, 0,  pid, 0, buf, bufsz)
 
 #define QSS_PROCESS    1
-#define QSS_MODULE     2
-#define QSS_SEMAPHORES 4
+#define QSS_MODULE     4
+#define QSS_SEMAPHORES 2
 #define QSS_FILE       8               /* Buggy until fixpack18 */
 #define QSS_SHARED     16
 
@@ -335,3 +395,4 @@ typedef struct {
 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);
 
 #endif /* _OS2EMX_H */
+