From patchwork Thu Feb 2 18:05:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 52106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp388964wrn; Thu, 2 Feb 2023 10:06:26 -0800 (PST) X-Google-Smtp-Source: AK7set9k8Ioub6kA9tG7AHtQ8NyGciiIkRyTSP0mmtYh0IBu7e/i5qsgUjzn/IgUDAvwqKqSfHwM X-Received: by 2002:a17:907:1607:b0:87b:6aa1:c87f with SMTP id hb7-20020a170907160700b0087b6aa1c87fmr9007377ejc.26.1675361186775; Thu, 02 Feb 2023 10:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361186; cv=none; d=google.com; s=arc-20160816; b=H2ut/9OZ031Vcin3F/hIm0LSuFlLjzsLo6a6Zh0UzHtpeOTRLfjZXvWy7Ej8bA8cxb FIvDoI2DOo0nIqUNZbMrb0oIV3h/yJYJrxq1kFYzXXbLii4sGwBWnIH+/7BHuuCL/ylM dplOfR927Xb4RywFBnF/AXlN7dc7yOVmz3hwz67SUjk+Q/fTjDSiKQL1wKPgjkV/uIBF KPnmYZHZkYfLG8ga3AnjjM3LblQ9SFPGE36u/4c0X66TgaBMjf6zAV13oCLU8w4i/E6C zUCGaSeedXWQRjU8zi5pcZRg+I67H2OCGq0BOdBb5nIv65hgMto67Cnh7MB42Izv0NSB Vltg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=tV1W2kJ7/xsnRfnJlOxs9e23t2Gcxe9H89Vkd2HuEX0=; b=hi1/+R5mU2lxjxQSsvVHk3vC7OS8XRewo/wcTf48TGDe57TzzvX37AGWXm5V+RGMb/ AHOBoLcpGKfKKGV9SJJSg02zLqF23+AEx4LWmwlUN9c+l+gjQHqINODuNWFzT4gFL+L7 hX6YTuP9BgRZ9AzsDVnvevkqoHHS77TBaly0meNU5CkofT7H583bhu03ka83ESjTS30I z6IF/Wwo4Cv+m54Ap4pcYYg4k9JJp9XdvgQ2nCUtq22PD0kNN7Cn3EGw0sUODMBUw6U/ T0SdrWxIjD0R8PyA92fCrWtmHEMSq7xzHDDtzyy2r19GtZ6DvGPYwT79XbEy7wJrUHC2 c6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pNdqtU7b; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gb39-20020a170907962700b0088f1ecec549si275507ejc.995.2023.02.02.10.06.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:06:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pNdqtU7b; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 53DAE3858023 for ; Thu, 2 Feb 2023 18:06:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53DAE3858023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675361177; bh=tV1W2kJ7/xsnRfnJlOxs9e23t2Gcxe9H89Vkd2HuEX0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pNdqtU7b2P8a/saUSyYCFqLAC2ZA+U5g4sopQwrhBMUq91UQY0UGglgVRNnLY55w8 lgnNmW2KH73dpykFd1HZuOACOcSGe5VsnwXRSZDBYUjaiZhgIggLJnePE/jwsaBX34 CXtNVTAcAZg3i3Z01cQOQXZKZg0kNIy1FjJJJt+Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 590A83858C5F for ; Thu, 2 Feb 2023 18:05:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 590A83858C5F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-eILQdhAoN8q2RGGKC5d60w-1; Thu, 02 Feb 2023 13:05:30 -0500 X-MC-Unique: eILQdhAoN8q2RGGKC5d60w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 551D33C0DDCA; Thu, 2 Feb 2023 18:05:30 +0000 (UTC) Received: from localhost (unknown [10.33.36.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E29B2026D4B; Thu, 2 Feb 2023 18:05:30 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use ENOSYS for unsupported filesystem ops on AVR Date: Thu, 2 Feb 2023 18:05:29 +0000 Message-Id: <20230202180529.2642046-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely 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?1756743531462776498?= X-GMAIL-MSGID: =?utf-8?q?1756743531462776498?= Tested x86_64-linux, built on avr. Pushed to trunk. I might backport this to gcc-12 too, although realistically I doubt anybody is going to try to use the filesystem library on avr anyway, so it doesn't matter. -- >8 -- Because avr-libc defines most error numbers with duplicate values it's not sufficient to check #ifdef ENOTSUP when deciding which std::errc constant to use for the filesystem library's __unsupported() helper. Add a special case for AVR to always use the ENOSYS value. libstdc++-v3/ChangeLog: * src/filesystem/ops-common.h [AVR] (__unsupported): Always use errc::function_not_supported instead of errc::not_supported. --- libstdc++-v3/src/filesystem/ops-common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index 02c75be09d2..abbfca43e5c 100644 --- a/libstdc++-v3/src/filesystem/ops-common.h +++ b/libstdc++-v3/src/filesystem/ops-common.h @@ -84,7 +84,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline error_code __unsupported() noexcept { -#if defined ENOTSUP +#if defined __AVR__ + // avr-libc defines ENOTSUP and EOPNOTSUPP but with nonsense values. + // ENOSYS is defined though, so use an error_code corresponding to that. + // This contradicts the comment above, but we don't have much choice. + return std::make_error_code(std::errc::function_not_supported); +#elif defined ENOTSUP return std::make_error_code(std::errc::not_supported); #elif defined EOPNOTSUPP // This is supposed to be for socket operations