From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Subject:To:From:Date:in-reply-to: references; bh=I8E3UDjzVUyDr6WGu9cLUhYPOUFqIfg8v/cHt0JFhec=; b=a5Tok+hFdVqnaS vIWGGXywyS+GWn/gThluqc/NViBjspvPaUyr3UzuzQR/W2hirfODLT/x+u9TS7HmR/9Oh1ffcHJzf gGHc3b/UFb3+tB7uyAhmX+XEXilrt6j4PhitKUKSVqdG8N4roUVaLH3lyrB+fOclIUxPaQi3zkeH0 KpcMKzZIcfq87G4dqH2OpNql0kXZCWVfzyrChdon6Qwbw705By+xVBr4XOLhclJegtnoOi41TO9f0 SdjMD3+tRN5PttIzYdpg/Wks57uLgn4rbltgObn5pVR0z78nXVOwP790AaotRCkbahg5Vq+2e5G6j 1wyi/kUyW94BpIG9Q7dw==; 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 From: Samuel Thibault To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org, Jonathan Wakely Cc: bug-hurd@gnu.org 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-Type: text/plain; charset=us-ascii 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 List-Id: 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