Happy chainsaw stories; The removal of the 5005 threads
[p5sagit/p5-mst-13.2.git] / os2 / os2ish.h
index d1c45ad..20e413a 100644 (file)
 # undef I_SYS_UN
 #endif 
 
-#ifdef USE_5005THREADS
-
-#define do_spawn(a)      os2_do_spawn(aTHX_ (a))
-#define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c))
-
-#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)))                         \
-           Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc);       \
-    } STMT_END
-#define MUTEX_LOCK(m) \
-    STMT_START {                                               \
-       int rc;                                                 \
-       if ((rc = _rmutex_request(m,_FMR_IGNINT)))              \
-           Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc);       \
-    } STMT_END
-#define MUTEX_UNLOCK(m) \
-    STMT_START {                                               \
-       int rc;                                                 \
-       if ((rc = _rmutex_release(m)))                          \
-           Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc);     \
-    } STMT_END
-#define MUTEX_DESTROY(m) \
-    STMT_START {                                               \
-       int rc;                                                 \
-       if ((rc = _rmutex_close(m)))                            \
-           Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc);    \
-    } STMT_END
-
-#define COND_INIT(c) \
-    STMT_START {                                               \
-       int rc;                                                 \
-       if ((rc = DosCreateEventSem(NULL,c,0,0)))               \
-           Perl_croak_nocontext("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)\
-           Perl_croak_nocontext("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)\
-           Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc);   \
-    } STMT_END
-/* #define COND_WAIT(c, m) \
-    STMT_START {                                               \
-       if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED)  \
-           Perl_croak_nocontext("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)))       \
-           Perl_croak_nocontext("panic: COND_WAIT");                   \
-       else                                                    \
-           MUTEX_LOCK(m);                                      \
-    } STMT_END
-#define COND_DESTROY(c) \
-    STMT_START {                                               \
-       int rc;                                                 \
-       if ((rc = DosCloseEventSem(*(c))))                      \
-           Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc);     \
-    } STMT_END
-/*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
-*/
-
-#ifdef USE_SLOW_THREAD_SPECIFIC
-#  define pthread_getspecific(k)       (*_threadstore())
-#  define pthread_setspecific(k,v)     (*_threadstore()=v,0)
-#  define pthread_key_create(keyp,flag)        (*keyp=_gettid(),0)
-#else /* USE_SLOW_THREAD_SPECIFIC */
-#  define pthread_getspecific(k)       (*(k))
-#  define pthread_setspecific(k,v)     (*(k)=(v),0)
-#  define pthread_key_create(keyp,flag)                        \
-       ( DosAllocThreadLocalMemory(1,(U32*)keyp)       \
-         ? Perl_croak_nocontext("LocalMemory"),1       \
-         : 0                                           \
-       )
-#endif /* USE_SLOW_THREAD_SPECIFIC */
-#define pthread_key_delete(keyp)
-#define pthread_self()                 _gettid()
-#define 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 /* PTHREAD_INCLUDED */
-
-#define THREADS_ELSEWHERE
-
-#else /* USE_5005THREADS */
-
 #define do_spawn(a)      os2_do_spawn(a)
 #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
-
-#endif /* USE_5005THREADS */
  
 void Perl_OS2_init(char **);
 void Perl_OS2_init3(char **envp, void **excH, int flags);
@@ -357,6 +250,8 @@ void *emx_realloc (void *, size_t);
 
 #include <stdlib.h>    /* before the following definitions */
 #include <unistd.h>    /* before the following definitions */
+#include <fcntl.h>
+#include <sys/stat.h>
 
 #define chdir  _chdir2
 #define getcwd _getcwd2
@@ -370,6 +265,26 @@ void *emx_realloc (void *, size_t);
         ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
 #endif
 
+#define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd)
+
+#ifdef __GNUG__
+# define HAS_BOOL 
+#endif
+#ifndef HAS_BOOL
+# define bool char
+# define HAS_BOOL 1
+#endif
+
+#include <emx/io.h> /* for _fd_flags() prototype */
+
+static inline bool
+_PERLIO_IS_BINMODE_FD(int fd)
+{
+    int *pflags = _fd_flags(fd);
+
+    return pflags && (*pflags) & O_BINARY;
+}
+
 /* ctermid is missing from emx0.9d */
 char *ctermid(char *s);