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: 1823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp482035wrs; Fri, 7 Oct 2022 13:46:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Mj4pxcotXpVkh7vbAq7vmogCTI9DS5VFvXrdI8QNAs3yBOt2/w13p5jvd4etd84m+oRcY X-Received: by 2002:aa7:d39a:0:b0:458:a612:f805 with SMTP id x26-20020aa7d39a000000b00458a612f805mr6219033edq.49.1665175564479; Fri, 07 Oct 2022 13:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665175564; cv=none; d=google.com; s=arc-20160816; b=Kmwa/CORh6PELHs3kZDnRiL25Q4OliVIJsXh6L2HuSFVaIkNjOobeH0+YsGE9XUfuZ +NUkTH4i1C1ef8/cOvYdg617Wre4mYsjGOvivYUv1TCKtK0ZaLkCBHczZqiunjSvhCOl HVxPclqm8uh0S/QeLXCq9nYoCmQbFljsXReBnWjRsjP76dHTIGN+mjzN3dV/eV0Bf9Mk 0MsnZIrgc/2YZt3rXlhvP/WzfhV3nkFe1THJWJDtQxaycD2nuRzp3i+OPO/pFC3X/7mP AirKtt/UK6gxVg2geDKUnXtTmoI+nT7tfVFlfdvpq7jL5hqzp3vzV+yDAsWWK0rZNh3Z 9BrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :user-agent:organization:content-disposition:mime-version :mail-followup-to:message-id:subject:to:date:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=I8E3UDjzVUyDr6WGu9cLUhYPOUFqIfg8v/cHt0JFhec=; b=hSpGgguDA0792UN6EplT3G3OIkA7U3DwbltLiOaxJg2DFshtiSrQ+Z75d542/eCsaX mlIl83jWk3Z03oLtz8Plw9xsiCwILHzR7VmB3etEnQByCXqgnA1PKqyWCNXQF+TB6mnK AfGH+iJ97UzwZgh7stl9WKJXJQ5vZCX2rbYYZOdaLErbujPn69mpYtEJ78gsD1GE8MeM PpLR9NAtpegzCy08Rn9vZaCHRooDhTSmkWi4Szr7nBvB4MPrhMUn9T6JdXK4GVckccaX OdssJxcmWd+/1YfTyxTDkG8lLw2H3BR8JEnwm9bsukfuvJ+zFkOyNYkutrRyJGi7LOaE 2MsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TpZe1aoS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hr2-20020a1709073f8200b007307fa2da78si3563544ejc.450.2022.10.07.13.46.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 13:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TpZe1aoS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 787B6389EC52 for ; Fri, 7 Oct 2022 20:45:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 787B6389EC52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665175556; 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=TpZe1aoS6dWsuBQd2bUyRtoFwfwC8fV6Ezaf2OBL8SvtlsyCuoV5aJoBH8Q4jQtTY qcOPwPbxhlCmYPLm2neeeYRWXLXkhoCQ9g8t0L8f1fs+mKF5q/Uxwv8dpaIulLgOIP fgpC6B22RrdB4Yvs4eyemslu3F0rIWQQIn6eypL8= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746063132693485503?= X-GMAIL-MSGID: =?utf-8?q?1746063132693485503?= 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