summaryrefslogtreecommitdiff
path: root/os2/os2ish.h
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>1997-12-13 13:09:15 -0500
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-12-17 12:02:03 +0000
commitdd96f567babd77c258fd51112ff376f11f0b32ac (patch)
tree25be9a2f30132eaa9bf9f5a5a2cafb22b3630ea3 /os2/os2ish.h
parent414017bba678bf057e68f59bd92234bf578ec54e (diff)
downloadperl-dd96f567babd77c258fd51112ff376f11f0b32ac.tar.gz
Threading patches for OS/2 (missing files taken from previous patch):
Subject: Re: 5.004_55: OS/2 patches again p4raw-id: //depot/perl@371
Diffstat (limited to 'os2/os2ish.h')
-rw-r--r--os2/os2ish.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/os2/os2ish.h b/os2/os2ish.h
index 9a3d267ae5..4895538d6e 100644
--- a/os2/os2ish.h
+++ b/os2/os2ish.h
@@ -64,6 +64,98 @@
/* 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(char **);