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: 64158 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 9EC903857838 for ; Thu, 2 Feb 2023 18:06:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EC903857838 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675361162; bh=tV1W2kJ7/xsnRfnJlOxs9e23t2Gcxe9H89Vkd2HuEX0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ussclVQVi+vME8pRXyhVpj67fseckisO3EVPFS/w9KJYSwSr591TLS2Xl8sBKKwyI h1Akx/xxMJI0lfeUsg3ekzuD4wNiLZK9QwurnwKoVyLtdj5LNQR7nt5cnW7hw5Hcp1 X3HbXN1qZuKFe2ruuND/LbKwJrMLMJwq2hxyMXfU= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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