From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675361134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tV1W2kJ7/xsnRfnJlOxs9e23t2Gcxe9H89Vkd2HuEX0=; b=Wf0JxQsBHQoRYxQRVE5WqICm31wVMaGcYovG0eqcR3GsWLyZWuVuT9MunOQtN5SMTIE0iP Qk/5zfTisigOzLV7ILPb8Yzm/tEPt0RUg/2zYhzhyi/AtvypabEA4lWpWWdMDVVItT/FVj eCHJ8dz71ujabwsDzyJeRsp2TZO+pbo= 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) From: Jonathan Wakely 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 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.39.1