From owner-svn-src-head@FreeBSD.ORG Sun Nov 16 05:13:11 2014 Return-Path: Delivered-To: svn-src-head@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 C12173CA; Sun, 16 Nov 2014 05:13:11 +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 94F718B3; Sun, 16 Nov 2014 05:13:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAG5DBXU059780; Sun, 16 Nov 2014 05:13:11 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAG5DB13059779; Sun, 16 Nov 2014 05:13:11 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201411160513.sAG5DB13059779@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 16 Nov 2014 05:13:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274576 - head/contrib/netbsd-tests/lib/libpthread X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2014 05:13:11 -0000 Author: ngie Date: Sun Nov 16 05:13:10 2014 New Revision: 274576 URL: https://svnweb.freebsd.org/changeset/base/274576 Log: Port helper program to FreeBSD, similar to ../../lib/libc/stdlib/h_atexit.c Submitted by: pho In collaboration with: kib Modified: head/contrib/netbsd-tests/lib/libpthread/h_atexit.c Modified: head/contrib/netbsd-tests/lib/libpthread/h_atexit.c ============================================================================== --- head/contrib/netbsd-tests/lib/libpthread/h_atexit.c Sun Nov 16 05:11:07 2014 (r274575) +++ head/contrib/netbsd-tests/lib/libpthread/h_atexit.c Sun Nov 16 05:13:10 2014 (r274576) @@ -47,9 +47,19 @@ __RCSID("$NetBSD: h_atexit.c,v 1.1 2010/ extern int __cxa_atexit(void (*func)(void *), void *, void *); extern void __cxa_finalize(void *); +#ifdef __FreeBSD__ +/* + * See comments in ../../lib/libc/stdlib/h_atexit.c about the deviation + * between FreeBSD and NetBSD with this helper program + */ +static void *dso_handle_1 = (void *)1; +static void *dso_handle_2 = (void *)2; +static void *dso_handle_3 = (void *)3; +#else static int dso_handle_1; static int dso_handle_2; static int dso_handle_3; +#endif static int arg_1; static int arg_2; @@ -170,8 +180,17 @@ main(int argc, char *argv[]) exiting_state = 5; +#if defined(__FreeBSD__) ASSERT(0 == atexit(normal_handler_0)); ASSERT(0 == atexit(normal_handler_1)); + ASSERT(0 == __cxa_atexit(cxa_handler_4, &arg_1, dso_handle_1)); + ASSERT(0 == __cxa_atexit(cxa_handler_5, &arg_1, dso_handle_1)); + ASSERT(0 == __cxa_atexit(cxa_handler_3, &arg_2, dso_handle_2)); + ASSERT(0 == __cxa_atexit(cxa_handler_2, &arg_3, dso_handle_3)); + + __cxa_finalize(dso_handle_1); + __cxa_finalize(dso_handle_2); +#else ASSERT(0 == __cxa_atexit(cxa_handler_4, &arg_1, &dso_handle_1)); ASSERT(0 == __cxa_atexit(cxa_handler_5, &arg_1, &dso_handle_1)); ASSERT(0 == __cxa_atexit(cxa_handler_3, &arg_2, &dso_handle_2)); @@ -179,5 +198,6 @@ main(int argc, char *argv[]) __cxa_finalize(&dso_handle_1); __cxa_finalize(&dso_handle_2); +#endif exit(0); }