@@ -167,6 +167,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef EOVERFLOW
value_too_large = EOVERFLOW,
+#elif defined __AVR__
+ value_too_large = 999,
#endif
wrong_protocol_type = EPROTOTYPE
@@ -251,6 +251,15 @@ namespace
X (WRITE_PROTECT, EROFS);
#undef X
+#elif defined __AVR__
+ // avr-libc only defines a few distinct error numbers. Most <errno.h>
+ // constants are not usable in #if directives and have the same value.
+ case EDOM:
+ case ERANGE:
+ case ENOSYS:
+ case EINTR:
+ case 0:
+ return std::error_condition(ev, generic_category_instance.obj);
#else
// List of errno macros from [cerrno.syn].
// C11 only defines EDOM, EILSEQ and ERANGE, the rest are from POSIX.
@@ -736,7 +736,7 @@ fs::path
fs::current_path(error_code& ec)
{
path p;
-#ifdef _GLIBCXX_HAVE_UNISTD_H
+#if defined _GLIBCXX_HAVE_UNISTD_H && ! defined __AVR__
#if defined __GLIBC__ || defined _GLIBCXX_FILESYSTEM_IS_WINDOWS
if (char_ptr cwd = char_ptr{posix::getcwd(nullptr, 0)})
{
@@ -1302,6 +1302,7 @@ fs::remove_all(const path& p)
}
// Directory is empty now, will remove it below.
break;
+#ifndef __AVR__
case ENOENT:
// Our work here is done.
return 0;
@@ -1309,6 +1310,7 @@ fs::remove_all(const path& p)
case ELOOP:
// Not a directory, will remove below.
break;
+#endif
default:
// An error occurred.
_GLIBCXX_THROW_OR_ABORT(filesystem_error("cannot remove all", p, ec));
@@ -1339,6 +1341,7 @@ fs::remove_all(const path& p, error_code& ec)
}
// Directory is empty now, will remove it below.
break;
+#ifndef __AVR__
case ENOENT:
// Our work here is done.
ec.clear();
@@ -1347,6 +1350,7 @@ fs::remove_all(const path& p, error_code& ec)
case ELOOP:
// Not a directory, will remove below.
break;
+#endif
default:
// An error occurred.
return -1;
@@ -167,7 +167,7 @@ namespace __gnu_posix
return ret;
}
using char_type = wchar_t;
-#elif defined _GLIBCXX_HAVE_UNISTD_H
+#elif defined _GLIBCXX_HAVE_UNISTD_H && ! defined __AVR__
using ::open;
using ::close;
# ifdef _GLIBCXX_HAVE_SYS_STAT_H