summaryrefslogtreecommitdiffstats
path: root/lib/librthread
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librthread')
-rw-r--r--lib/librthread/rthread.c8
-rw-r--r--lib/librthread/rthread_sync.c6
-rw-r--r--lib/librthread/rthread_tls.c4
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c
index c1916bc0937..e611b2fdd93 100644
--- a/lib/librthread/rthread.c
+++ b/lib/librthread/rthread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread.c,v 1.7 2005/12/14 06:07:54 tedu Exp $ */
+/* $OpenBSD: rthread.c,v 1.8 2005/12/18 01:35:06 tedu Exp $ */
/*
* Copyright (c) 2004 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -39,7 +39,7 @@
static int threads_ready;
static pthread_t thread_list;
-static _spinlock_lock_t thread_lock;
+static _spinlock_lock_t thread_lock = _SPINLOCK_UNLOCKED;
int getthrid();
void threxit(int);
@@ -103,6 +103,7 @@ thread_init(void)
thread = malloc(sizeof(*thread));
memset(thread, 0, sizeof(*thread));
thread->tid = getthrid();
+ thread->donesem.lock = _SPINLOCK_UNLOCKED;
thread->flags |= THREAD_CANCEL_ENABLE|THREAD_CANCEL_DEFERRED;
snprintf(thread->name, sizeof(thread->name), "Main process");
thread_list = thread;
@@ -200,6 +201,7 @@ pthread_create(pthread_t *threadp, const pthread_attr_t *attr,
thread = malloc(sizeof(*thread));
memset(thread, 0, sizeof(*thread));
+ thread->donesem.lock = _SPINLOCK_UNLOCKED;
thread->fn = start_routine;
thread->arg = arg;
@@ -352,7 +354,7 @@ _thread_dump_info(void)
/*
* the malloc lock
*/
-static _spinlock_lock_t malloc_lock;
+static _spinlock_lock_t malloc_lock = _SPINLOCK_UNLOCKED;
void
_thread_malloc_lock()
diff --git a/lib/librthread/rthread_sync.c b/lib/librthread/rthread_sync.c
index 616be71ad55..c57ffdedc0f 100644
--- a/lib/librthread/rthread_sync.c
+++ b/lib/librthread/rthread_sync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_sync.c,v 1.9 2005/12/14 07:02:47 tedu Exp $ */
+/* $OpenBSD: rthread_sync.c,v 1.10 2005/12/18 01:35:06 tedu Exp $ */
/*
* Copyright (c) 2004 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -229,6 +229,7 @@ pthread_mutex_init(pthread_mutex_t *mutexp, const pthread_mutexattr_t *attr)
if (!mutex)
return (errno);
memset((void *)mutex, 0, sizeof(*mutex));
+ mutex->sem.lock = _SPINLOCK_UNLOCKED;
mutex->sem.value = 1; /* unlocked */
mutex->type = attr ? (*attr)->type : PTHREAD_MUTEX_ERRORCHECK;
*mutexp = mutex;
@@ -353,6 +354,7 @@ pthread_cond_init(pthread_cond_t *condp, const pthread_condattr_t *attrp)
if (!cond)
return (errno);
memset(cond, 0, sizeof(*cond));
+ cond->sem.lock = _SPINLOCK_UNLOCKED;
*condp = cond;
@@ -472,6 +474,8 @@ pthread_rwlock_init(pthread_rwlock_t *lockp, const pthread_rwlockattr_t *attrp)
if (!lock)
return (errno);
memset(lock, 0, sizeof(*lock));
+ lock->lock = _SPINLOCK_UNLOCKED;
+ lock->sem.lock = _SPINLOCK_UNLOCKED;
*lockp = lock;
return (0);
diff --git a/lib/librthread/rthread_tls.c b/lib/librthread/rthread_tls.c
index 05311c11d7e..4adbbcb6c54 100644
--- a/lib/librthread/rthread_tls.c
+++ b/lib/librthread/rthread_tls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_tls.c,v 1.5 2005/12/14 05:42:07 tedu Exp $ */
+/* $OpenBSD: rthread_tls.c,v 1.6 2005/12/18 01:35:06 tedu Exp $ */
/*
* Copyright (c) 2004 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
@@ -37,7 +37,7 @@
#include "rthread.h"
static struct rthread_key rkeys[PTHREAD_KEYS_MAX];
-static _spinlock_lock_t rkeyslock;
+static _spinlock_lock_t rkeyslock = _SPINLOCK_UNLOCKED;
int
pthread_key_create(pthread_key_t *key, void (*destructor)(void*))