From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 0B9A93857807; Wed, 7 Jul 2021 07:33:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B9A93857807 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] nptl: Use internal low-level lock type for !IS_IN (libc) X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: 83e55c982ffcf42185254cff5ac16377672ae32e X-Git-Newrev: 1f9c804fbd699104adefbce9e56d2c8aa711b6b9 Message-Id: <20210707073337.0B9A93857807@sourceware.org> Date: Wed, 7 Jul 2021 07:33:37 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2021 07:33:37 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1f9c804fbd699104adefbce9e56d2c8aa711b6b9 commit 1f9c804fbd699104adefbce9e56d2c8aa711b6b9 Author: Florian Weimer Date: Wed Jul 7 08:40:41 2021 +0200 nptl: Use internal low-level lock type for !IS_IN (libc) This avoids an ABI hazard (types changing between different modules of glibc) without introducing linknamespace issues. In particular, NSS modules now call __lll_lock_wait_private@@GLIBC_PRIVATE to wait on internal locks (the unlock path is inlined and performs a direct system call). Reviewed-by: Adhemerval Zanella Diff: --- sysdeps/nptl/libc-lockP.h | 51 +++++------------------------------------------ 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h index ef88a3e533..b66c938e44 100644 --- a/sysdeps/nptl/libc-lockP.h +++ b/sysdeps/nptl/libc-lockP.h @@ -33,18 +33,8 @@ #include #include -#if IS_IN (libpthread) -/* This gets us the declarations of the __pthread_* internal names, - and hidden_proto for them. */ -# include -#endif - /* Mutex type. */ -#if !IS_IN (libc) && !IS_IN (libpthread) -typedef pthread_mutex_t __libc_lock_t; -#else typedef int __libc_lock_t; -#endif typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t; typedef pthread_rwlock_t __libc_rwlock_t; @@ -108,56 +98,25 @@ _Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0"); /* Initialize the named lock variable, leaving it in a consistent, unlocked state. */ -#if IS_IN (libc) || IS_IN (libpthread) -# define __libc_lock_init(NAME) \ - ((void) ((NAME) = LLL_LOCK_INITIALIZER)) -#else -# define __libc_lock_init(NAME) __pthread_mutex_init (&(NAME)) -#endif +#define __libc_lock_init(NAME) ((void) ((NAME) = LLL_LOCK_INITIALIZER)) #define __libc_rwlock_init(NAME) __pthread_rwlock_init (&(NAME), NULL) /* Finalize the named lock variable, which must be locked. It cannot be used again until __libc_lock_init is called again on it. This must be called on a lock variable before the containing storage is reused. */ -#if IS_IN (libc) || IS_IN (libpthread) -# define __libc_lock_fini(NAME) ((void) 0) -#else -# define __libc_lock_fini(NAME) __pthread_mutex_destroy (&(NAME)) -#endif +#define __libc_lock_fini(NAME) ((void) 0) #define __libc_rwlock_fini(NAME) ((void) 0) /* Lock the named lock variable. */ -#if IS_IN (libc) || IS_IN (libpthread) -# ifndef __libc_lock_lock -# define __libc_lock_lock(NAME) \ - ({ lll_lock (NAME, LLL_PRIVATE); 0; }) -# endif -#else -# undef __libc_lock_lock -# define __libc_lock_lock(NAME) __pthread_mutex_lock (&(NAME)) -#endif +#define __libc_lock_lock(NAME) ({ lll_lock (NAME, LLL_PRIVATE); 0; }) #define __libc_rwlock_rdlock(NAME) __pthread_rwlock_rdlock (&(NAME)) #define __libc_rwlock_wrlock(NAME) __pthread_rwlock_wrlock (&(NAME)) /* Try to lock the named lock variable. */ -#if IS_IN (libc) || IS_IN (libpthread) -# ifndef __libc_lock_trylock -# define __libc_lock_trylock(NAME) \ - lll_trylock (NAME) -# endif -#else -# undef __libc_lock_trylock -# define __libc_lock_trylock(NAME) \ - __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0) -#endif +#define __libc_lock_trylock(NAME) lll_trylock (NAME) /* Unlock the named lock variable. */ -#if IS_IN (libc) || IS_IN (libpthread) -# define __libc_lock_unlock(NAME) \ - lll_unlock (NAME, LLL_PRIVATE) -#else -# define __libc_lock_unlock(NAME) __pthread_mutex_unlock (&(NAME)) -#endif +#define __libc_lock_unlock(NAME) lll_unlock (NAME, LLL_PRIVATE) #define __libc_rwlock_unlock(NAME) __pthread_rwlock_unlock (&(NAME)) #if IS_IN (rtld)