From owner-svn-src-all@FreeBSD.ORG Tue Feb 17 01:03:09 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 31C5FDB5; Tue, 17 Feb 2015 01:03:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 12277D62; Tue, 17 Feb 2015 01:03:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1H138vg062030; Tue, 17 Feb 2015 01:03:08 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1H1378J062022; Tue, 17 Feb 2015 01:03:07 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502170103.t1H1378J062022@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 17 Feb 2015 01:03:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r278875 - in stable/10/lib: libc/gen libc/include libc/sys libthr/thread X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Feb 2015 01:03:09 -0000 Author: kib Date: Tue Feb 17 01:03:06 2015 New Revision: 278875 URL: https://svnweb.freebsd.org/changeset/base/278875 Log: MFC r278751: Properly interpose libc spinlocks, was missed in r276630. Modified: stable/10/lib/libc/gen/_spinlock_stub.c stable/10/lib/libc/include/libc_private.h stable/10/lib/libc/sys/interposing_table.c stable/10/lib/libthr/thread/thr_private.h stable/10/lib/libthr/thread/thr_spinlock.c stable/10/lib/libthr/thread/thr_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/gen/_spinlock_stub.c ============================================================================== --- stable/10/lib/libc/gen/_spinlock_stub.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libc/gen/_spinlock_stub.c Tue Feb 17 01:03:06 2015 (r278875) @@ -33,51 +33,48 @@ __FBSDID("$FreeBSD$"); #include #include "spinlock.h" +#include "libc_private.h" long _atomic_lock_stub(volatile long *); void _spinlock_stub(spinlock_t *); void _spinunlock_stub(spinlock_t *); void _spinlock_debug_stub(spinlock_t *, char *, int); -/* - * Declare weak definitions in case the application is not linked - * with libpthread. - */ __weak_reference(_atomic_lock_stub, _atomic_lock); -__weak_reference(_spinlock_stub, _spinlock); -__weak_reference(_spinunlock_stub, _spinunlock); -__weak_reference(_spinlock_debug_stub, _spinlock_debug); - -/* - * This function is a stub for the _atomic_lock function in libpthread. - */ + long _atomic_lock_stub(volatile long *lck __unused) { return (0L); } +__weak_reference(_spinlock, _spinlock_debug); +#pragma weak _spinlock +void +_spinlock(spinlock_t *lck) +{ + + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinlock]) + (lck); -/* - * This function is a stub for the spinlock function in libpthread. - */ +} + +#pragma weak _spinlock void -_spinlock_stub(spinlock_t *lck __unused) +_spinunlock(spinlock_t *lck) { + + ((void (*)(spinlock_t *lck))__libc_interposing[INTERPOS_spinunlock]) + (lck); + } -/* - * This function is a stub for the spinunlock function in libpthread. - */ void -_spinunlock_stub(spinlock_t *lck __unused) +__libc_spinlock_stub(spinlock_t *lck __unused) { } -/* - * This function is a stub for the debug spinlock function in libpthread. - */ void -_spinlock_debug_stub(spinlock_t *lck __unused, char *fname __unused, int lineno __unused) +__libc_spinunlock_stub(spinlock_t *lck __unused) { } Modified: stable/10/lib/libc/include/libc_private.h ============================================================================== --- stable/10/lib/libc/include/libc_private.h Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libc/include/libc_private.h Tue Feb 17 01:03:06 2015 (r278875) @@ -95,6 +95,9 @@ do { \ _SPINUNLOCK(&__stdio_thread_lock); \ } while (0) +void __libc_spinlock_stub(struct _spinlock *); +void __libc_spinunlock_stub(struct _spinlock *); + /* * Indexes into the pthread jump table. * @@ -216,6 +219,8 @@ enum { INTERPOS_write, INTERPOS_writev, INTERPOS__pthread_mutex_init_calloc_cb, + INTERPOS_spinlock, + INTERPOS_spinunlock, INTERPOS_MAX }; Modified: stable/10/lib/libc/sys/interposing_table.c ============================================================================== --- stable/10/lib/libc/sys/interposing_table.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libc/sys/interposing_table.c Tue Feb 17 01:03:06 2015 (r278875) @@ -73,6 +73,8 @@ interpos_func_t __libc_interposing[INTER SLOT(write, __sys_write), SLOT(writev, __sys_writev), SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub), + SLOT(spinlock, __libc_spinlock_stub), + SLOT(spinunlock, __libc_spinunlock_stub), }; #undef SLOT Modified: stable/10/lib/libthr/thread/thr_private.h ============================================================================== --- stable/10/lib/libthr/thread/thr_private.h Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libthr/thread/thr_private.h Tue Feb 17 01:03:06 2015 (r278875) @@ -928,6 +928,10 @@ int __thr_sigwait(const sigset_t *set, i int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info); int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp); +struct _spinlock; +void __thr_spinunlock(struct _spinlock *lck); +void __thr_spinlock(struct _spinlock *lck); + __END_DECLS #endif /* !_THR_PRIVATE_H */ Modified: stable/10/lib/libthr/thread/thr_spinlock.c ============================================================================== --- stable/10/lib/libthr/thread/thr_spinlock.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libthr/thread/thr_spinlock.c Tue Feb 17 01:03:06 2015 (r278875) @@ -61,7 +61,7 @@ static void init_spinlock(spinlock_t *lc */ void -_spinunlock(spinlock_t *lck) +__thr_spinunlock(spinlock_t *lck) { struct spinlock_extra *_extra; @@ -70,7 +70,7 @@ _spinunlock(spinlock_t *lck) } void -_spinlock(spinlock_t *lck) +__thr_spinlock(spinlock_t *lck) { struct spinlock_extra *_extra; @@ -84,12 +84,6 @@ _spinlock(spinlock_t *lck) THR_UMUTEX_LOCK(_get_curthread(), &_extra->lock); } -void -_spinlock_debug(spinlock_t *lck, char *fname __unused, int lineno __unused) -{ - _spinlock(lck); -} - static void init_spinlock(spinlock_t *lck) { Modified: stable/10/lib/libthr/thread/thr_syscalls.c ============================================================================== --- stable/10/lib/libthr/thread/thr_syscalls.c Mon Feb 16 23:50:53 2015 (r278874) +++ stable/10/lib/libthr/thread/thr_syscalls.c Tue Feb 17 01:03:06 2015 (r278875) @@ -597,6 +597,8 @@ __thr_interpose_libc(void) SLOT(wait4); SLOT(write); SLOT(writev); + SLOT(spinlock); + SLOT(spinunlock); #undef SLOT *(__libc_interposing_slot( INTERPOS__pthread_mutex_init_calloc_cb)) =