From owner-svn-src-all@FreeBSD.ORG Sun Sep 19 05:42:29 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C98E71065672; Sun, 19 Sep 2010 05:42:29 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9F0A68FC1B; Sun, 19 Sep 2010 05:42:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8J5gTbN090590; Sun, 19 Sep 2010 05:42:29 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8J5gTjE090588; Sun, 19 Sep 2010 05:42:29 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201009190542.o8J5gTjE090588@svn.freebsd.org> From: David Xu Date: Sun, 19 Sep 2010 05:42:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212838 - head/lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 19 Sep 2010 05:42:29 -0000 Author: davidxu Date: Sun Sep 19 05:42:29 2010 New Revision: 212838 URL: http://svn.freebsd.org/changeset/base/212838 Log: - _Unwind_Resume function is not used, remove it. - Use a store barrier to make sure uwl_forcedunwind is lastest thing other threads can see. - Add some comments. Modified: head/lib/libthr/thread/thr_exit.c Modified: head/lib/libthr/thread/thr_exit.c ============================================================================== --- head/lib/libthr/thread/thr_exit.c Sun Sep 19 05:19:47 2010 (r212837) +++ head/lib/libthr/thread/thr_exit.c Sun Sep 19 05:42:29 2010 (r212838) @@ -63,7 +63,6 @@ static _Unwind_Reason_Code thread_unwind /* unwind library pointers */ static _Unwind_Reason_Code (*uwl_forcedunwind)(struct _Unwind_Exception *, _Unwind_Stop_Fn, void *); -static void (*uwl_resume)(struct _Unwind_Exception *exc); static _Unwind_Word (*uwl_getcfa)(struct _Unwind_Context *); static void @@ -72,22 +71,24 @@ thread_uw_init(void) static int inited = 0; Dl_info dlinfo; void *handle; - void *forcedunwind, *resume, *getcfa; + void *forcedunwind, *getcfa; if (inited) return; handle = RTLD_DEFAULT; if ((forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind")) != NULL) { if (dladdr(forcedunwind, &dlinfo)) { + /* + * Make sure the address is always valid by holding the library, + * also assume functions are in same library. + */ if ((handle = dlopen(dlinfo.dli_fname, RTLD_LAZY)) != NULL) { forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind"); - resume = dlsym(handle, "_Unwind_Resume"); getcfa = dlsym(handle, "_Unwind_GetCFA"); - if (forcedunwind != NULL && resume != NULL && - getcfa != NULL) { - uwl_forcedunwind = forcedunwind; - uwl_resume = resume; + if (forcedunwind != NULL && getcfa != NULL) { uwl_getcfa = getcfa; + atomic_store_rel_ptr((volatile void *)&uwl_forcedunwind, + (uintptr_t)forcedunwind); } else { dlclose(handle); } @@ -97,12 +98,6 @@ thread_uw_init(void) inited = 1; } -void -_Unwind_Resume(struct _Unwind_Exception *ex) -{ - (*uwl_resume)(ex); -} - _Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *ex, _Unwind_Stop_Fn stop_func, void *stop_arg) @@ -118,7 +113,6 @@ _Unwind_GetCFA(struct _Unwind_Context *c #else #pragma weak _Unwind_GetCFA #pragma weak _Unwind_ForcedUnwind -#pragma weak _Unwind_Resume #endif /* PIC */ static void