From patchwork Sat Jan 19 17:22:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 213878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id DBEA52C0079 for ; Sun, 20 Jan 2013 04:22:54 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1359220976; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=tLM1nSn WIx7JBlUeXwvxB6Z29iY=; b=wLw2ptECPo/db2eF1X9HFkFE32MBseFOCjrjBa5 nTZr/0PBSyvO330Z18vmdGivodYT4R7D8E4Q1R0oRH1A6RF4HPhKl1Tf+dMYK+bH 3Gqh7n9GQ/J2CgIBVwT2ejNoP1DtqqDGnO0Bc/MqQSsSylCpKpUiWZkBnkvFCk1f zAhE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=nWfQlHHNOx0PN4f9Ti5sc/cCHCjFi2W5eNTyelEppCrsbTiftDDN5rYznI1X+m iTK0xBJqtspikw6gZGKtZcRM+X8nk3IHjocYsgS9guRPdJC+r1vDHHy0JNwjKnBy HMbcjJMiOC7MO6l5rrZhvpm6RVVtgZtOOqUCwD5wBLnq0=; Received: (qmail 17433 invoked by alias); 19 Jan 2013 17:22:36 -0000 Received: (qmail 17410 invoked by uid 22791); 19 Jan 2013 17:22:34 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Jan 2013 17:22:25 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0JHMOpP031155 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 19 Jan 2013 12:22:25 -0500 Received: from [10.3.112.2] ([10.3.112.2]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0JHMNuu010173; Sat, 19 Jan 2013 12:22:23 -0500 Message-ID: <50FAD64F.4040604@redhat.com> Date: Sat, 19 Jan 2013 12:22:23 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List , libstdc++ CC: Siddhesh Poyarekar , Jakub Jelinek Subject: PATCH to libstdc++ to use __cxa_thread_atexit_impl if available Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Siddhesh has a patch to implement the thread atexit functionality in glibc in order to integrate better with the dynamic loader and run the cleanups in the correct order. Once it's available there, this patch will make the copy in libsupc++ use it. The main __cxa_thread_atexit function will always live in libsupc++, however, in order to maintain ABI compatibility between releases of libstdc++. Does this configure change look right, or should it go in linkage.m4 somewhere? I think I'll hold off checking this in until Siddhesh's patch goes into glibc. commit cba5e8c2535f5950d1c78a6c35a2f83d549f37dc Author: Jason Merrill Date: Sat Jan 19 12:08:25 2013 -0500 * configure.ac: Check for __cxa_thread_atexit_impl. * libsupc++/atexit_thread.cc (__cxa_thread_atexit): Just forward to it if available. * config.h.in, configure: Regenerate. diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index dd14b91..c14862d 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -652,6 +652,9 @@ /* Define to 1 if you have the `_tanl' function. */ #undef HAVE__TANL +/* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ +#undef HAVE___CXA_THREAD_ATEXIT_IMPL + /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index a4cf5c9..f53b9cf 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -26584,6 +26584,18 @@ $as_echo "#define HAVE_TLS 1" >>confdefs.h fi + for ac_func in __cxa_thread_atexit_impl +do : + ac_fn_c_check_func "$LINENO" "__cxa_thread_atexit_impl" "ac_cv_func___cxa_thread_atexit_impl" +if test "x$ac_cv_func___cxa_thread_atexit_impl" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE___CXA_THREAD_ATEXIT_IMPL 1 +_ACEOF + +fi +done + + # For iconv support. if test "X$prefix" = "XNONE"; then diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 66164a2..a64fee2 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -235,6 +235,8 @@ if $GLIBCXX_IS_NATIVE; then # For TLS support. GCC_CHECK_TLS + AC_CHECK_FUNCS(__cxa_thread_atexit_impl) + # For iconv support. AM_ICONV diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc index 95bdcf0..ce26717 100644 --- a/libstdc++-v3/libsupc++/atexit_thread.cc +++ b/libstdc++-v3/libsupc++/atexit_thread.cc @@ -26,6 +26,20 @@ #include #include "bits/gthr.h" +#if HAVE___CXA_THREAD_ATEXIT_IMPL + +extern "C" int __cxa_thread_atexit_impl (void (*func) (void *), + void *arg, void *d); +extern "C" int +__cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), + void *obj, void *dso_handle) + _GLIBCXX_NOTHROW +{ + return __cxa_thread_atexit_impl (dtor, obj, dso_handle); +} + +#else /* HAVE___CXA_THREAD_ATEXIT_IMPL */ + namespace { // One element in a singly-linked stack of cleanups. struct elt @@ -116,3 +130,5 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void *obj, void */*dso_ha return 0; } + +#endif /* HAVE___CXA_THREAD_ATEXIT_IMPL */