From patchwork Fri Oct 7 20:45:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 58546 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7CB8E382F9BC for ; Fri, 7 Oct 2022 20:45:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CB8E382F9BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665175540; bh=I8E3UDjzVUyDr6WGu9cLUhYPOUFqIfg8v/cHt0JFhec=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tRxErHW7zR5q2b1aPT5tIZwSr0pZGjgBGuMolVDHnWNV6SAqHX2YC5zrehfzUZCkh 0XgISFAiiMWB3gR+7QFIBQ2QN6aa7BJo1nN41lQINkwxz4P6MBG2ynYUjaDjfBmiud W5iLPW9R/HFKTQ54EpfyB3FtgUHpG4POyUpJk4TU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from fencepost.gnu.org (fencepost.gnu.org [IPv6:2001:470:142:3::e]) by sourceware.org (Postfix) with ESMTPS id 7E0CB3853552; Fri, 7 Oct 2022 20:45:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7E0CB3853552 Received: from 2a01cb008c016e00de41a9fffe47ec49.ipv6.abo.wanadoo.fr ([2a01:cb00:8c01:6e00:de41:a9ff:fe47:ec49]:41608 helo=begin.home) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oguDU-0000iF-3k; Fri, 07 Oct 2022 16:45:09 -0400 Received: from samy by begin.home with local (Exim 4.96) (envelope-from ) id 1oguDT-001loC-01; Fri, 07 Oct 2022 22:45:07 +0200 Date: Fri, 7 Oct 2022 22:45:06 +0200 To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Jonathan Wakely Subject: [PATCHv2] libstdc++: Mark pieces of gnu-linux/os_support.h linux-specific Message-ID: <20221007204506.cokw3lkkn5aequ5h@begin> Mail-Followup-To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Jonathan Wakely , bug-hurd@gnu.org MIME-Version: 1.0 Content-Disposition: inline Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Samuel Thibault via Gcc-patches From: Samuel Thibault Reply-To: Samuel Thibault Cc: bug-hurd@gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This is notably needed because in glibc 2.34, the move of pthread functions into libc.so happened for Linux only, not GNU/Hurd. The pthread_self() function can also always be used fine as it is on GNU/Hurd. libstdc++-v3/ChangeLog: * config/os/gnu-linux/os_defines.h [!__linux__] (_GLIBCXX_NATIVE_THREAD_ID, _GLIBCXX_GTHREAD_USE_WEAK): Do not define. diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h index c0caa21a013..4de93d752e1 100644 --- a/libstdc++-v3/config/os/gnu-linux/os_defines.h +++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h @@ -49,22 +49,24 @@ // version dynamically in case it has changed since libstdc++ was configured. #define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23) -#if __GLIBC_PREREQ(2, 27) -// Since glibc 2.27 pthread_self() is usable without linking to libpthread. -# define _GLIBCXX_NATIVE_THREAD_ID pthread_self() -#else +#ifdef __linux__ +# if __GLIBC_PREREQ(2, 27) +// Since glibc 2.27 Linux' pthread_self() is usable without linking to libpthread. +# define _GLIBCXX_NATIVE_THREAD_ID pthread_self() +# else // Before then it was in libc.so.6 but not libc.a, and always returns 0, // which breaks the invariant this_thread::get_id() != thread::id{}. // So only use it if we know the libpthread version is available. // Otherwise use (__gthread_t)1 as the ID of the main (and only) thread. -# define _GLIBCXX_NATIVE_THREAD_ID \ - (__gthread_active_p() ? __gthread_self() : (__gthread_t)1) -#endif +# define _GLIBCXX_NATIVE_THREAD_ID \ + (__gthread_active_p() ? __gthread_self() : (__gthread_t)1) +# endif -#if __GLIBC_PREREQ(2, 34) -// Since glibc 2.34 all pthreads functions are usable without linking to +# if __GLIBC_PREREQ(2, 34) +// Since glibc 2.34 all Linux pthreads functions are usable without linking to // libpthread. -# define _GLIBCXX_GTHREAD_USE_WEAK 0 +# define _GLIBCXX_GTHREAD_USE_WEAK 0 +# endif #endif #endif