X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=os2%2Fos2ish.h;h=4506bb4fb2e40df31df72d4359c3c706a62b9417;hb=55d729e4e15089064cd25ed6dce2c105389f3837;hp=44aee84152e2153b380209b89c8880c3b0d661c4;hpb=9a3e71f668bd84b1cf53dd3ea10f588d59ecfebb;p=p5sagit%2Fp5-mst-13.2.git diff --git a/os2/os2ish.h b/os2/os2ish.h index 44aee84..4506bb4 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -15,6 +15,7 @@ #define HAS_KILL #define HAS_WAIT #define HAS_DLERROR +#define HAS_WAITPID_RUNTIME (_emx_env & 0x200) /* USEMYBINMODE * This symbol, if defined, indicates that the program should @@ -24,6 +25,14 @@ */ #undef USEMYBINMODE +/* Stat_t: + * This symbol holds the type used to declare buffers for information + * returned by stat(). It's usually just struct stat. It may be necessary + * to include and to get any typedef'ed + * information. + */ +#define Stat_t struct stat + /* USE_STAT_RDEV: * This symbol is defined if this system has a stat structure declaring * st_rdev @@ -37,6 +46,18 @@ */ #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 @@ -51,20 +72,114 @@ /* It is not working without TCPIPV4 defined. */ # undef I_SYS_UN #endif + +#ifdef USE_THREADS + +#define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */ + +extern int rc; + +#define MUTEX_INIT(m) \ + STMT_START { \ + int rc; \ + if ((rc = _rmutex_create(m,0))) \ + croak("panic: MUTEX_INIT: rc=%i", rc); \ + } STMT_END +#define MUTEX_LOCK(m) \ + STMT_START { \ + int rc; \ + if ((rc = _rmutex_request(m,_FMR_IGNINT))) \ + croak("panic: MUTEX_LOCK: rc=%i", rc); \ + } STMT_END +#define MUTEX_UNLOCK(m) \ + STMT_START { \ + int rc; \ + if ((rc = _rmutex_release(m))) \ + croak("panic: MUTEX_UNLOCK: rc=%i", rc); \ + } STMT_END +#define MUTEX_DESTROY(m) \ + STMT_START { \ + int rc; \ + if ((rc = _rmutex_close(m))) \ + croak("panic: MUTEX_DESTROY: rc=%i", rc); \ + } STMT_END + +#define COND_INIT(c) \ + STMT_START { \ + int rc; \ + if ((rc = DosCreateEventSem(NULL,c,0,0))) \ + croak("panic: COND_INIT: rc=%i", rc); \ + } STMT_END +#define COND_SIGNAL(c) \ + STMT_START { \ + int rc; \ + if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED) \ + croak("panic: COND_SIGNAL, rc=%ld", rc); \ + } STMT_END +#define COND_BROADCAST(c) \ + STMT_START { \ + int rc; \ + if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\ + croak("panic: COND_BROADCAST, rc=%i", rc); \ + } STMT_END +/* #define COND_WAIT(c, m) \ + STMT_START { \ + if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \ + croak("panic: COND_WAIT"); \ + } STMT_END +*/ +#define COND_WAIT(c, m) os2_cond_wait(c,m) + +#define COND_WAIT_win32(c, m) \ + STMT_START { \ + int rc; \ + if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE)))\ + croak("panic: COND_WAIT"); \ + else \ + MUTEX_LOCK(m); \ + } STMT_END +#define COND_DESTROY(c) \ + STMT_START { \ + int rc; \ + if ((rc = DosCloseEventSem(*(c)))) \ + croak("panic: COND_DESTROY, rc=%i", rc); \ + } STMT_END +/*#define THR ((struct thread *) TlsGetValue(thr_key)) +#define dTHR struct thread *thr = THR +*/ + +#define pthread_getspecific(k) (*_threadstore()) +#define pthread_setspecific(k,v) (*_threadstore()=v,0) +#define pthread_self() _gettid() +#define pthread_key_create(keyp,flag) (*keyp=_gettid(),0) +#define sched_yield() DosSleep(0) + +#ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */ +int pthread_join(pthread_t tid, void **status); +int pthread_detach(pthread_t tid); +int pthread_create(pthread_t *tid, const pthread_attr_t *attr, + void *(*start_routine)(void*), void *arg); +#endif + +#define THREADS_ELSEWHERE + +#endif -void Perl_OS2_init(); +void Perl_OS2_init(char **); + +/* 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() MALLOC_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 HAS_FORK */ @@ -111,6 +226,7 @@ char *my_tmpnam (char *); #define fwrite1 fwrite #define my_getenv(var) getenv(var) +#define flock my_flock void *emx_calloc (size_t, size_t); void emx_free (void *); @@ -128,7 +244,6 @@ void *emx_realloc (void *, size_t); /* 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) \ @@ -143,6 +258,7 @@ void *emx_realloc (void *, size_t); #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 @@ -154,6 +270,7 @@ void *emx_realloc (void *, size_t); #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