diff options
Diffstat (limited to 'lib/libpthread/uthread/uthread_fd.c')
-rw-r--r-- | lib/libpthread/uthread/uthread_fd.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/lib/libpthread/uthread/uthread_fd.c b/lib/libpthread/uthread/uthread_fd.c index 51aacd35841..4875cd10fb1 100644 --- a/lib/libpthread/uthread/uthread_fd.c +++ b/lib/libpthread/uthread/uthread_fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_fd.c,v 1.12 2002/11/03 20:36:43 marc Exp $ */ +/* $OpenBSD: uthread_fd.c,v 1.13 2002/11/03 23:58:39 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, - const char *fname, int lineno) + 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, (char *)fname, lineno); + _spinlock_debug(&entry->lock, 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(int fd, int lock_type, const char *fname, int lineno) +_thread_fd_unlock_debug(int fd, int lock_type, char *fname, int lineno) { struct pthread *curthread = _get_curthread(); return (_thread_fd_unlock_thread(curthread, fd, lock_type, @@ -274,6 +274,17 @@ _thread_fd_unlock(int fd, int lock_type, const 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 @@ -312,8 +323,8 @@ _thread_fd_unlock_owned(pthread_t pthread) * null when called by the non-debug version of the function. */ int -_thread_fd_lock(int fd, int lock_type, struct timespec * timeout, - const char *fname, int lineno) +_thread_fd_lock_debug(int fd, int lock_type, struct timespec * timeout, + char *fname, int lineno) { struct pthread *curthread = _get_curthread(); struct fd_table_entry *entry; @@ -333,7 +344,7 @@ _thread_fd_lock(int fd, int lock_type, struct timespec * timeout, * thread's accesses: */ if (fname) - _spinlock_debug(&entry->lock, (char *)fname, lineno); + _spinlock_debug(&entry->lock, fname, lineno); else _SPINLOCK(&entry->lock); @@ -365,8 +376,7 @@ _thread_fd_lock(int fd, int lock_type, struct timespec * timeout, */ curthread->data.fd.fd = fd; curthread->data.fd.branch = lineno; - curthread->data.fd.fname = - (char *)fname; + curthread->data.fd.fname = fname; /* Set the timeout: */ _thread_kern_set_timeout(timeout); @@ -445,8 +455,7 @@ _thread_fd_lock(int fd, int lock_type, struct timespec * timeout, */ curthread->data.fd.fd = fd; curthread->data.fd.branch = lineno; - curthread->data.fd.fname = - (char *)fname; + curthread->data.fd.fname = fname; /* Set the timeout: */ _thread_kern_set_timeout(timeout); @@ -503,4 +512,14 @@ _thread_fd_lock(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 |