From e9359f93b236ed62fa7a555429a1466a5199deea Mon Sep 17 00:00:00 2001 From: kurt <> Date: Tue, 5 Jun 2007 18:11:48 +0000 Subject: [PATCH] _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@ --- src/include/dirent.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/include/dirent.h b/src/include/dirent.h index 7565be1c..20765d01 100644 --- a/src/include/dirent.h +++ b/src/include/dirent.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dirent.h,v 1.17 2007/02/08 16:34:38 millert Exp $ */ +/* $OpenBSD: dirent.h,v 1.18 2007/06/05 18:11:48 kurt Exp $ */ /* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */ /*- @@ -71,6 +71,7 @@ typedef struct _dirdesc { long dd_rewind; /* magic cookie for rewinding */ int dd_flags; /* flags for readdir */ struct _telldir *dd_td; /* telldir position recording */ + void *dd_lock; /* mutex to protect struct */ } DIR; #define dirfd(dirp) ((dirp)->dd_fd)