summaryrefslogtreecommitdiff
path: root/pthread.h
diff options
context:
space:
mode:
authorrpj <rpj>1999-04-03 22:05:39 +0000
committerrpj <rpj>1999-04-03 22:05:39 +0000
commit451bb0670ddd5f5c0606410f2b5f51733119645d (patch)
tree09e56af6c763e0c7874cce25ac700daf9f1e93a0 /pthread.h
parentad0b866780adf56e19114fb67ab2d532b4501425 (diff)
./ChangeLog
Sun Apr 4 11:05:57 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * sched.c (sched.h): Include. * sched.h: New file for POSIX 1b scheduling. * pthread.h: Move opaque structures to implement.h; move sched_* prototypes out and into sched.h. * implement.h: Add opaque structures from pthread.h. * sched.c (sched_yield): New function. * condvar.c (_pthread_sem_*): Rename to sem_*; except for _pthread_sem_timedwait which is an private function. Sat Apr 3 23:28:00 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * Makefile.in (OBJS): Add errno.o. Fri Apr 2 11:08:50 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * implement.h (_pthread_sem_*): Remove prototypes now defined in semaphore.h. * pthread.h (sempahore.h): Include. * semaphore.h: New file for POSIX 1b semaphores. * pthread.h (_pthread_sem_t): Change to sem_t. * semaphore.c (_pthread_sem_*): Change to sem_*; these functions will be exported from the library; set errno on error. - John Bossom <jebossom@cognos.com> (_pthread_sem_timedwait): Moved to private.c. * private.c (_pthread_sem_timedwait): Moved from semaphore.c; set errno on error. * errno.c (_errno): New file. New function. - John Bossom * pthread.h (pthread_t_): Add per-thread errno element. tests/ChangeLog Sun Apr 4 12:04:28 1999 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * tsd1.c (mythread): Change Sleep(0) to sched_yield(). (sched.h): Include. * condvar3.c (mythread): Remove redundant Sleep(). * runtest.bat: Re-organised to make more informative.
Diffstat (limited to 'pthread.h')
-rw-r--r--pthread.h177
1 files changed, 23 insertions, 154 deletions
diff --git a/pthread.h b/pthread.h
index bc11d1b..8995558 100644
--- a/pthread.h
+++ b/pthread.h
@@ -253,9 +253,6 @@ struct timespec {
#define FALSE 0
#endif /* !TRUE */
-
-/* #include <sched.h> */
-
#ifdef __MINGW32__
#define PT_STDCALL
#else
@@ -419,14 +416,14 @@ extern "C"
#define PTHREAD_THREADS_MAX 2019
- typedef struct pthread_t_ *pthread_t;
- typedef struct pthread_attr_t_ *pthread_attr_t;
- typedef struct pthread_once_t_ pthread_once_t;
- typedef struct pthread_key_t_ *pthread_key_t;
- typedef struct pthread_mutex_t_ *pthread_mutex_t;
- typedef struct pthread_mutexattr_t_ *pthread_mutexattr_t;
- typedef struct pthread_cond_t_ *pthread_cond_t;
- typedef struct pthread_condattr_t_ *pthread_condattr_t;
+typedef struct pthread_t_ *pthread_t;
+typedef struct pthread_attr_t_ *pthread_attr_t;
+typedef struct pthread_once_t_ pthread_once_t;
+typedef struct pthread_key_t_ *pthread_key_t;
+typedef struct pthread_mutex_t_ *pthread_mutex_t;
+typedef struct pthread_mutexattr_t_ *pthread_mutexattr_t;
+typedef struct pthread_cond_t_ *pthread_cond_t;
+typedef struct pthread_condattr_t_ *pthread_condattr_t;
/*
@@ -501,141 +498,9 @@ struct pthread_once_t_
};
-/*
- * ====================
- * ====================
- * Structure Definitions
- * ====================
- * ====================
- */
-
-typedef enum {
- /*
- * This enumeration represents the state of the thread;
- * The thread is still "alive" if the numeric value of the
- * state is greater or equal "PThreadStateRunning".
- */
- PThreadStateInitial = 0, /* Thread not running */
- PThreadStateRunning, /* Thread alive & kicking */
- PThreadStateSuspended, /* Thread alive but suspended */
- PThreadStateCanceling, /* Thread alive but and is */
- /* in the process of terminating */
- /* due to a cancellation request */
- PThreadStateException, /* Thread alive but exiting */
- /* due to an exception */
- PThreadStateLast
-}
-PThreadState;
-
-
-typedef enum {
- /*
- * This enumeration represents the reason why a thread has
- * terminated/is terminating.
- */
- PThreadDemisePeaceful = 0, /* Death due natural causes */
- PThreadDemiseCancelled, /* Death due to user cancel */
- PThreadDemiseException, /* Death due to unhandled */
- /* exception */
- PThreadDemiseNotDead /* I'm not dead! */
-}
-PThreadDemise;
-
-
-struct pthread_t_ {
- DWORD thread;
- HANDLE threadH;
- PThreadState state;
- PThreadDemise demise;
- void *exitStatus;
- void *parms;
- int detachState;
- int cancelState;
- int cancelType;
- HANDLE cancelEvent;
-#if HAVE_SIGSET_T
- sigset_t sigmask;
-#endif /* HAVE_SIGSET_T */
- int implicit:1;
- void *keys;
-};
-
+#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) -1)
-/*
- * Special value to mark attribute objects as valid.
- */
-#define _PTHREAD_ATTR_VALID ((unsigned long) 0xC4C0FFEE)
-
-struct pthread_attr_t_ {
- unsigned long valid;
- void *stackaddr;
- size_t stacksize;
- int detachstate;
- int priority;
-#if HAVE_SIGSET_T
- sigset_t sigmask;
-#endif /* HAVE_SIGSET_T */
-};
-
-
-/*
- * ====================
- * ====================
- * Mutexes and Condition Variables
- * ====================
- * ====================
- */
-
-enum {
- _PTHREAD_OBJECT_INVALID = 0, /* NULL */
- _PTHREAD_OBJECT_AUTO_INIT
-};
-
-#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) _PTHREAD_OBJECT_AUTO_INIT)
-
-struct pthread_mutex_t_ {
- HANDLE mutex;
- CRITICAL_SECTION cs;
-};
-
-
-struct pthread_mutexattr_t_ {
- int pshared;
- int forcecs;
-};
-
-
-struct pthread_key_t_ {
- DWORD key;
- void (*destructor) (void *);
- pthread_mutex_t threadsLock;
- void *threads;
-};
-
-
-#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) _PTHREAD_OBJECT_AUTO_INIT)
-
-typedef HANDLE _pthread_sem_t;
-
-struct pthread_cond_t_ {
- long waiters; /* # waiting threads */
- pthread_mutex_t waitersLock; /* Mutex that guards access to
- waiter count */
- _pthread_sem_t sema; /* Queue up threads waiting for the
- condition to become signaled */
- HANDLE waitersDone; /* An auto reset event used by the
- broadcast/signal thread to wait
- for the waiting thread(s) to wake
- up and get a chance at the
- semaphore */
- int wasBroadcast; /* keeps track if we are signaling
- or broadcasting */
-};
-
-
-struct pthread_condattr_t_ {
- int pshared;
-};
+#define PTHREAD_COND_INITIALIZER ((pthread_cond_t) -1)
/*
@@ -655,13 +520,22 @@ struct pthread_condattr_t_ {
#define SCHED_MIN SCHED_OTHER
#define SCHED_MAX SCHED_RR
- struct sched_param {
- int sched_priority;
- };
-
+struct sched_param {
+ int sched_priority;
+};
/* There are three implementations of cancel cleanup.
+ * Note that pthread.h is included in both application
+ * compilation units and also internally for the library.
+ * The code here and within the library aims to work
+ * for all reasonable combinations of environments.
+ * For example, although the library itself can't be
+ * built (yet) in C, an application written in C can
+ * be linked and run against a library built using
+ * either WIN32 SEH or C++ EH.
+ *
+ * The three implementations are:
*
* WIN32 SEH
* C
@@ -963,17 +837,12 @@ int pthread_getschedparam (pthread_t thread,
int *policy,
struct sched_param *param);
-int sched_get_priority_min (int policy);
-
-int sched_get_priority_max (int policy);
-
int pthread_attr_getschedparam (const pthread_attr_t *attr,
struct sched_param *param);
int pthread_attr_setschedparam (pthread_attr_t *attr,
const struct sched_param *param);
-
/*
* Protected Methods
*