summaryrefslogtreecommitdiff
path: root/lib/libc_r
diff options
context:
space:
mode:
authorMarco S Hyman <marc@cvs.openbsd.org>2002-11-03 20:36:44 +0000
committerMarco S Hyman <marc@cvs.openbsd.org>2002-11-03 20:36:44 +0000
commit664e44eac173bd00d9757c4d15084393436fcbdc (patch)
treed0df53493c5ae4d4dceb1c350e7bfa2b9d4770a8 /lib/libc_r
parenta7bb9a3fe7041afd8e1153c8c5b97c0952ec0e2c (diff)
libc changes for thread safety. Tested on:
alpha (millert@), i386 (marc@), m68k (millert@ and miod@), powerpc (drahn@ and dhartmei@), sparc (millert@ and marc@), sparc64 (marc@), and vax (millert@ and miod@). Thanks to millert@, miod@, and mickey@ for fixes along the way.
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/thread/Makefile.inc4
-rw-r--r--lib/libc_r/thread/thread_malloc_lock.c10
-rw-r--r--lib/libc_r/thread/thread_storage.c6
-rw-r--r--lib/libc_r/uthread/uthread_fd.c41
4 files changed, 26 insertions, 35 deletions
diff --git a/lib/libc_r/thread/Makefile.inc b/lib/libc_r/thread/Makefile.inc
index 919300d08ae..a235b563ae8 100644
--- a/lib/libc_r/thread/Makefile.inc
+++ b/lib/libc_r/thread/Makefile.inc
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile.inc,v 1.1 2000/01/06 07:25:15 d Exp $
+# $OpenBSD: Makefile.inc,v 1.2 2002/11/03 20:36:43 marc Exp $
.PATH: ${LIBC_RSRCDIR}/thread
-SRCS+= thread_storage.c
+SRCS+= thread_storage.c thread_malloc_lock.c
diff --git a/lib/libc_r/thread/thread_malloc_lock.c b/lib/libc_r/thread/thread_malloc_lock.c
index 68f899983cb..229973d7e89 100644
--- a/lib/libc_r/thread/thread_malloc_lock.c
+++ b/lib/libc_r/thread/thread_malloc_lock.c
@@ -1,7 +1,8 @@
+/* $OpenBSD: thread_malloc_lock.c,v 1.2 2002/11/03 20:36:43 marc Exp $ */
+/* Public Domain <marc@snafu.org> */
+
#include <pthread.h>
#include "pthread_private.h"
-#include "thread_private.h"
-#include "spinlock.h"
static spinlock_t malloc_lock = _SPINLOCK_INITIALIZER;
@@ -16,3 +17,8 @@ _thread_malloc_unlock()
{
_SPINUNLOCK(&malloc_lock);
}
+
+void
+_thread_malloc_init()
+{
+}
diff --git a/lib/libc_r/thread/thread_storage.c b/lib/libc_r/thread/thread_storage.c
index fa8357c85ec..5872003a09f 100644
--- a/lib/libc_r/thread/thread_storage.c
+++ b/lib/libc_r/thread/thread_storage.c
@@ -1,5 +1,9 @@
+/* $OpenBSD: thread_storage.c,v 1.4 2002/11/03 20:36:43 marc Exp $ */
+/* Public Domain */
-/* libpthread's stronger functions */
+/*
+ * libpthread's stronger functions
+ */
#include <stdlib.h>
#include <pthread.h>
diff --git a/lib/libc_r/uthread/uthread_fd.c b/lib/libc_r/uthread/uthread_fd.c
index d824a4c49d3..51aacd35841 100644
--- a/lib/libc_r/uthread/uthread_fd.c
+++ b/lib/libc_r/uthread/uthread_fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_fd.c,v 1.11 2002/10/30 20:05:11 marc Exp $ */
+/* $OpenBSD: uthread_fd.c,v 1.12 2002/11/03 20:36:43 marc Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -145,7 +145,7 @@ _thread_fd_table_init(int fd)
*/
void
_thread_fd_unlock_thread(struct pthread *thread, int fd, int lock_type,
- char *fname, int lineno)
+ const char *fname, int lineno)
{
struct fd_table_entry *entry;
int ret;
@@ -170,7 +170,7 @@ _thread_fd_unlock_thread(struct pthread *thread, int fd, int lock_type,
* thread's accesses:
*/
if (fname)
- _spinlock_debug(&entry->lock, fname, lineno);
+ _spinlock_debug(&entry->lock, (char *)fname, lineno);
else
_SPINLOCK(&entry->lock);
@@ -266,7 +266,7 @@ _thread_fd_unlock_thread(struct pthread *thread, int fd, int lock_type,
* fname and lineno (debug variables).
*/
void
-_thread_fd_unlock_debug(int fd, int lock_type, char *fname, int lineno)
+_thread_fd_unlock(int fd, int lock_type, const char *fname, int lineno)
{
struct pthread *curthread = _get_curthread();
return (_thread_fd_unlock_thread(curthread, fd, lock_type,
@@ -274,17 +274,6 @@ _thread_fd_unlock_debug(int fd, int lock_type, char *fname, int lineno)
}
/*
- * Unlock an fd table entry for the given fd and lock type (read,
- * write, or read-write).
- */
-void
-_thread_fd_unlock(int fd, int lock_type)
-{
- struct pthread *curthread = _get_curthread();
- return (_thread_fd_unlock_thread(curthread, fd, lock_type, NULL, 0));
-}
-
-/*
* Unlock all fd table entries owned by the given thread
*/
void
@@ -323,8 +312,8 @@ _thread_fd_unlock_owned(pthread_t pthread)
* null when called by the non-debug version of the function.
*/
int
-_thread_fd_lock_debug(int fd, int lock_type, struct timespec * timeout,
- char *fname, int lineno)
+_thread_fd_lock(int fd, int lock_type, struct timespec * timeout,
+ const char *fname, int lineno)
{
struct pthread *curthread = _get_curthread();
struct fd_table_entry *entry;
@@ -344,7 +333,7 @@ _thread_fd_lock_debug(int fd, int lock_type, struct timespec * timeout,
* thread's accesses:
*/
if (fname)
- _spinlock_debug(&entry->lock, fname, lineno);
+ _spinlock_debug(&entry->lock, (char *)fname, lineno);
else
_SPINLOCK(&entry->lock);
@@ -376,7 +365,8 @@ _thread_fd_lock_debug(int fd, int lock_type, struct timespec * timeout,
*/
curthread->data.fd.fd = fd;
curthread->data.fd.branch = lineno;
- curthread->data.fd.fname = fname;
+ curthread->data.fd.fname =
+ (char *)fname;
/* Set the timeout: */
_thread_kern_set_timeout(timeout);
@@ -455,7 +445,8 @@ _thread_fd_lock_debug(int fd, int lock_type, struct timespec * timeout,
*/
curthread->data.fd.fd = fd;
curthread->data.fd.branch = lineno;
- curthread->data.fd.fname = fname;
+ curthread->data.fd.fname =
+ (char *)fname;
/* Set the timeout: */
_thread_kern_set_timeout(timeout);
@@ -512,14 +503,4 @@ _thread_fd_lock_debug(int fd, int lock_type, struct timespec * timeout,
return (ret);
}
-/*
- * Non-debug version of fd locking. Just call the debug version
- * passing a null file and line
- */
-int
-_thread_fd_lock(int fd, int lock_type, struct timespec * timeout)
-{
- return (_thread_fd_lock_debug(fd, lock_type, timeout, NULL, 0));
-}
-
#endif