diff options
author | Kurt Miller <kurt@cvs.openbsd.org> | 2007-06-05 18:11:50 +0000 |
---|---|---|
committer | Kurt Miller <kurt@cvs.openbsd.org> | 2007-06-05 18:11:50 +0000 |
commit | 5ea227edb4b41ecee104b943846b3df89ceafb8c (patch) | |
tree | 5e3932033b9b169395a0474156a37318fa74db42 /lib/libc/thread | |
parent | 5727900f0e332290d68166eab7d4e4d71eea2264 (diff) |
_FD_LOCK/UNLOCK() is libpthread specific and not needed for librthread, so
isolate its usage to libpthread only and replace with generic non-static
mutex support in the one place it is needed:
- remove _FD_LOCK/UNLOCK from lseek and ftruncate in libc and make the
functions weak so that libpthread can override with its own new
versions that do the locking.
- remove _thread_fd_lock/unlock() weak functions from libc and adjust
libpthread for the change.
- add generic _thread_mutex_lock/unlock/destroy() weak functions in libc
to support non-static mutexes in libc and add libpthread and librthread
implementations for them. libc can utilize non-static mutexes via the
new _MUTEX_LOCK/UNLOCK/DESTROY() macros. Actually these new macros can
support both static and non-static mutexes but currently only using
them for non-static.
- make opendir/closedir/readdir/readdir_r/seekdir/telldir() thread-safe
for both thread libraries by using a non-static mutex in the struct
_dirdesc (typedef DIR), utilizing it in the *dir functions and remove
remaining and incorrect _FD_LOCK/UNLOCK() use in libc.
- add comments to both thread libraries to indicate libc depends on the
current implementation of static mutex initialization. suggested by
marc@
- major bump libc and libpthread due to function removal, structure
change and weak symbol conversions.
okay marc@, tedu@
Diffstat (limited to 'lib/libc/thread')
-rw-r--r-- | lib/libc/thread/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/thread/thread_fd.c | 22 | ||||
-rw-r--r-- | lib/libc/thread/unithread_mutex.c | 49 |
3 files changed, 51 insertions, 24 deletions
diff --git a/lib/libc/thread/Makefile.inc b/lib/libc/thread/Makefile.inc index 9d323879900..6d4c1cacdf6 100644 --- a/lib/libc/thread/Makefile.inc +++ b/lib/libc/thread/Makefile.inc @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile.inc,v 1.6 2004/06/07 21:11:23 marc Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2007/06/05 18:11:48 kurt Exp $ .PATH: ${LIBCSRCDIR}/thread -SRCS+= thread_fd.c unithread_malloc_lock.c unithread_tag.c +SRCS+= unithread_malloc_lock.c unithread_mutex.c unithread_tag.c diff --git a/lib/libc/thread/thread_fd.c b/lib/libc/thread/thread_fd.c index 9f10fedf837..e69de29bb2d 100644 --- a/lib/libc/thread/thread_fd.c +++ b/lib/libc/thread/thread_fd.c @@ -1,22 +0,0 @@ -/* $OpenBSD: thread_fd.c,v 1.8 2004/06/07 21:11:23 marc Exp $ */ - -#include <sys/time.h> -#include "thread_private.h" - -WEAK_PROTOTYPE(_thread_fd_lock); -WEAK_PROTOTYPE(_thread_fd_unlock); - -WEAK_ALIAS(_thread_fd_lock); -WEAK_ALIAS(_thread_fd_unlock); - -int -WEAK_NAME(_thread_fd_lock)(int fd, int lock_type, struct timespec *timeout) -{ - return 0; -} - -void -WEAK_NAME(_thread_fd_unlock)(int fd, int lock_type) -{ -} - diff --git a/lib/libc/thread/unithread_mutex.c b/lib/libc/thread/unithread_mutex.c new file mode 100644 index 00000000000..44009de7c01 --- /dev/null +++ b/lib/libc/thread/unithread_mutex.c @@ -0,0 +1,49 @@ +/* $OpenBSD: unithread_mutex.c,v 1.1 2007/06/05 18:11:48 kurt Exp $ */ + +/* + * Copyright (c) 2007 Kurt Miller <kurt@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/types.h> +#include "thread_private.h" + +WEAK_PROTOTYPE(_thread_mutex_lock); +WEAK_PROTOTYPE(_thread_mutex_unlock); +WEAK_PROTOTYPE(_thread_mutex_destroy); + +WEAK_ALIAS(_thread_mutex_lock); +WEAK_ALIAS(_thread_mutex_unlock); +WEAK_ALIAS(_thread_mutex_destroy); + +/* ARGSUSED */ +void +WEAK_NAME(_thread_mutex_lock)(void **mutex) +{ + return; +} + +/* ARGSUSED */ +void +WEAK_NAME(_thread_mutex_unlock)(void **mutex) +{ + return; +} + +/* ARGSUSED */ +void +WEAK_NAME(_thread_mutex_destroy)(void **mutex) +{ + return; +} |