From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5E0D61F466 for ; Mon, 20 Jan 2020 17:31:48 +0000 (UTC) Received: from localhost ([::1]:40692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itatu-00077m-SG for normalperson@yhbt.net; Mon, 20 Jan 2020 12:31:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40050) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itatk-00075I-VY for bug-gnulib@gnu.org; Mon, 20 Jan 2020 12:31:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itatj-0006Ir-OB for bug-gnulib@gnu.org; Mon, 20 Jan 2020 12:31:36 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::6]:19440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1itatj-0006Hv-1H for bug-gnulib@gnu.org; Mon, 20 Jan 2020 12:31:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1579541492; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=Vlm2OVdKY3iU0NkKCW7xlA2t7B4+knaW/Az2U1zKnD4=; b=M7UTrgJ43B4Se70QBQHmMnY4pnVfGvy5viXSvgtw2P/tUaty2dx+3L56ESrl5+qd6Q /FlsCrNyqxHhe/GXgbwGitpi6C7MBz1+d8xsU2litGWfihwtz4HTzGQh09GMrw0++0Wx F59DT4vhSe6HXfIhaEtxSxYJoJRLOSwYJELuISJ0eDtiCdBJNHttZm8HR3iIH+Xkfvc5 pm7bLFoWeBSK6V6oMEcjc0LQS9ja1qiOEct1aZoSLG9jY3QbnL+DF10EVU9KJl9nxy71 vS8MwSDTvU3WTqoxguPyecNXCYZcdMhu3MqrEHKGHn6iQtqhpeYcl18Xzkg/POPE9SGt uc/A== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.1.5 DYNA|AUTH) with ESMTPSA id 506e28w0KHVV2Vm (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Mon, 20 Jan 2020 18:31:31 +0100 (CET) From: Bruno Haible To: Tim =?ISO-8859-1?Q?R=FChsen?= Subject: Re: FreeBSD 11.2: glthread build failure Date: Mon, 20 Jan 2020 18:31:31 +0100 Message-ID: <2216289.3qrW4xaBTv@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <928aec54-9ccb-7464-20ff-22e1f91e7be7@gmx.de> <1770813.AsgGKQxQiM@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::6 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" > I can confirm that your patch fixes the issue here. Great. Thanks. Testing showed a regression: glthread_once is no longer working on FreeBSD 11, because in this code # define glthread_once(ONCE_CONTROL, INITFUNCTION) \ (pthread_in_use () \ ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) pthread_in_use () now evaluates to 1, and pthread_once from libc returns ENOSYS. Thus glthread_once returns ENOSYS, and gl_once calls abort(). This patch fixes it. 2020-01-20 Bruno Haible lock: Fix test-once1 failure on FreeBSD 11 (regression from 2020-01-19). * lib/glthread/lock.c (glthread_once_multithreaded): New function. * lib/glthread/lock.h (glthread_once_multithreaded): New declaration. (glthread_once): Use it. diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c index 6336591..1f6f713 100644 --- a/lib/glthread/lock.c +++ b/lib/glthread/lock.c @@ -718,6 +718,26 @@ glthread_once_singlethreaded (pthread_once_t *once_control) return 0; } +# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK) + +int +glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)) +{ + int err = pthread_once (once_control, init_function); + if (err == ENOSYS) + { + /* This happens on FreeBSD 11: The pthread_once function in libc returns + ENOSYS. */ + if (glthread_once_singlethreaded (once_control)) + init_function (); + return 0; + } + return err; +} + +# endif + #endif /* ========================================================================= */ diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h index 9c70f4e..1de86fe 100644 --- a/lib/glthread/lock.h +++ b/lib/glthread/lock.h @@ -505,10 +505,19 @@ extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *l typedef pthread_once_t gl_once_t; # define gl_once_define(STORAGECLASS, NAME) \ STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pthread_in_use () \ - ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +# else +# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ + (pthread_in_use () \ + ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ + : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) +extern int glthread_once_multithreaded (pthread_once_t *once_control, + void (*init_function) (void)); +# endif extern int glthread_once_singlethreaded (pthread_once_t *once_control); # ifdef __cplusplus