From: Jonathan Wakely <jwakely@redhat.com>
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 [thread overview]
Message-ID: <20230202180529.2642046-1-jwakely@redhat.com> (raw)
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 <errno.h> 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
reply other threads:[~2023-02-02 18:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230202180529.2642046-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).