summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog25
-rw-r--r--global.c18
-rw-r--r--implement.h14
-rw-r--r--misc.c8
-rw-r--r--mutex.c2
-rw-r--r--private.c8
6 files changed, 59 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a84251..051a348 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+Tue Aug 4 16:57:58 1998 Ross Johnson <rpj@swan.canberra.edu.au>
+
+ * private.c (_pthread_delete_thread): Fix typo. Add missing ';'.
+
+ * global.c (_pthread_virgins): Change types from pointer to
+ array pointer.
+ (_pthread_reuse): Ditto.
+ (_pthread_win32handle_map): Ditto.
+ (_pthread_threads_mutex_table): Ditto.
+
+ * implement.h(_pthread_virgins): Change types from pointer to
+ array pointer.
+ (_pthread_reuse): Ditto.
+ (_pthread_win32handle_map): Ditto.
+ (_pthread_threads_mutex_table): Ditto.
+
+ * private.c (_pthread_delete_thread): Fix "entry" should be "thread".
+
+ * misc.c (pthread_self): Add extern for _pthread_threadID_TlsIndex.
+
+ * global.c: Add comment.
+
+ * misc.c (pthread_once): Fix member -> dereferences.
+ Change _pthread_once_flag to once_control->flag in "if" test.
+
Tue Aug 4 00:09:30 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* implement.h(_pthread_virgins): Add extern.
diff --git a/global.c b/global.c
index 01f6a40..2914fb7 100644
--- a/global.c
+++ b/global.c
@@ -30,6 +30,9 @@ const int _pthread_cancel_disable = 1;
const int _pthread_cancel_asynchronous = 0;
const int _pthread_cancel_deferred = 1;
+
+/* Declare variables which are global to all threads in the process. */
+
/* FIXME: This is temporary. */
#define PTHREAD_MUTEX_INITIALIZER {0}
@@ -38,15 +41,22 @@ pthread_mutex_t _pthread_table_mutex = PTHREAD_MUTEX_INITIALIZER;
DWORD _pthread_threads_count = 0;
/* Per thread management storage. See comments in private.c */
-_pthread_t * _pthread_virgins;
+/* An array of struct _pthread */
+_pthread_t _pthread_virgins[];
+/* Index to the next available previously unused struct _pthread */
int _pthread_virgin_next = 0;
-pthread_t * _pthread_reuse;
+/* An array of pointers to struct _pthread */
+pthread_t _pthread_reuse[];
+/* Index to the first available reusable pthread_t. */
int _pthread_reuse_top = -1;
-pthread_t * _pthread_win32handle_map;
+/* An array of pointers to struct _pthread indexed by hashing
+ the Win32 handle. */
+pthread_t _pthread_win32handle_map[];
/* Per thread mutex locks. */
-pthread_mutex_t * _pthread_threads_mutex_table;
+pthread_mutex_t _pthread_threads_mutex_table[];
+
diff --git a/implement.h b/implement.h
index f132674..4a616ec 100644
--- a/implement.h
+++ b/implement.h
@@ -137,18 +137,24 @@ extern pthread_mutex_t _pthread_table_mutex;
extern DWORD _pthread_threads_count;
-extern _pthread_t * _pthread_virgins;
+/* An array of struct _pthread */
+extern _pthread_t _pthread_virgins[];
+/* Index to the next available previously unused struct _pthread */
extern int _pthread_virgin_next;
-extern pthread_t * _pthread_reuse;
+/* An array of pointers to struct _pthread */
+extern pthread_t _pthread_reuse[];
+/* Index to the first available reusable pthread_t. */
extern int _pthread_reuse_top;
-extern pthread_t * _pthread_win32handle_map;
+/* An array of pointers to struct _pthread indexed by hashing
+ the Win32 handle. */
+extern pthread_t _pthread_win32handle_map[];
/* Per thread mutex locks. */
-extern pthread_mutex_t * _pthread_threads_mutex_table;
+extern pthread_mutex_t _pthread_threads_mutex_table[];
#endif /* _IMPLEMENT_H */
diff --git a/misc.c b/misc.c
index ca39513..7905488 100644
--- a/misc.c
+++ b/misc.c
@@ -25,12 +25,12 @@ pthread_once(pthread_once_t *once_control,
the DLL is unloaded. */
/* An atomic test-and-set of the "once" flag. */
- EnterCriticalSection(once_control.lock);
- if (_pthread_once_flag == 0)
+ EnterCriticalSection(once_control->lock);
+ if (once_control->flag == 0)
{
flag = once_control->flag = 1;
}
- LeaveCriticalSection(once_control.lock);
+ LeaveCriticalSection(once_control->lock);
if (flag)
{
@@ -45,6 +45,8 @@ pthread_t
pthread_self(void)
{
pthread_t ret;
+ /* This TLS index is allocated on DLL load by dll.c */
+ extern DWORD _pthread_threadID_TlsIndex;
ret = (pthread_t) TlsGetValue(_pthread_threadID_TlsIndex);
diff --git a/mutex.c b/mutex.c
index e779729..2f51144 100644
--- a/mutex.c
+++ b/mutex.c
@@ -9,7 +9,7 @@
#include "implement.h"
int
-pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutex_attr_t *attr)
+pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)
{
if (mutex == NULL)
{
diff --git a/private.c b/private.c
index 454695d..d4d94f0 100644
--- a/private.c
+++ b/private.c
@@ -126,7 +126,7 @@ _pthread_new_thread(pthread_t * thread)
{
if (_pthread_virgin_next < PTHREAD_THREADS_MAX)
{
- new_thread = _pthread_virgin[_pthread_virgin_next++];
+ new_thread = (pthread_t) &_pthread_virgins[_pthread_virgin_next++];
}
else
{
@@ -163,15 +163,15 @@ _pthread_delete_thread(_pthread_t * thread)
if (thread != NULL
&& thread->ptstatus == _PTHREAD_EXITED)
{
- pthread_attr_destroy(&(entry->attr));
+ pthread_attr_destroy(&(thread->attr));
thread->win32handle = NULL;
- thread_ptstatus = _PTHREAD_REUSE;
+ thread->ptstatus = _PTHREAD_REUSE;
_pthread_reuse[++_pthread_reuse_top] = thread;
}
else
{
- return EINVAL
+ return EINVAL;
}
return 0;
}