The config/os/mingw32-w64/error_constants.h and
config/os/mingw32/error_constants.h headers check `#ifdef EPERM` before
using it, but I think that's completely redundant. Windows and all
versions of MinGW and mingw-w64 define EPERM and always have done as far
as I can tell. And all UNIX-like and POSIX-based targets define it.
We already have other code that uses EPERM without checking if it's
defined, and that would not compile if it wasn't present for the target.
Remove the #ifdef from those headers so that we use it unconditionally,
and remove some other checks and comments that assume it can be absent.
libstdc++-v3/ChangeLog:
* config/os/mingw32-w64/error_constants.h: Use EPERM without
checking if it's defined.
* config/os/mingw32/error_constants.h: Likewise.
* src/c++11/system_error.cc: Likewise.
* src/c++17/fs_dir.cc (fs::recursive_directory_iterator::__erase):
Likewise.
* testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc:
Use errc::operation_not_permitted without checking if EPERM is
defined.
---
Tested x86_64-linux and x86_64-w64-mingw32.
libstdc++-v3/config/os/mingw32-w64/error_constants.h | 2 --
libstdc++-v3/config/os/mingw32/error_constants.h | 2 --
libstdc++-v3/src/c++11/system_error.cc | 4 ----
libstdc++-v3/src/c++17/fs_dir.cc | 6 +-----
.../19_diagnostics/headers/system_error/errc_std_c++0x.cc | 4 ----
5 files changed, 1 insertion(+), 17 deletions(-)
diff --git a/libstdc++-v3/config/os/mingw32-w64/error_constants.h
b/libstdc++-v3/config/os/mingw32-w64/error_constants.h
index f2a4fb579042..eca02eeecc76 100644
--- a/libstdc++-v3/config/os/mingw32-w64/error_constants.h
+++ b/libstdc++-v3/config/os/mingw32-w64/error_constants.h
@@ -118,9 +118,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
operation_canceled = ECANCELED,
operation_in_progress = EINPROGRESS,
-#ifdef EPERM
operation_not_permitted = EPERM,
-#endif
operation_not_supported = EOPNOTSUPP,
#ifdef EWOULDBLOCK
operation_would_block = EWOULDBLOCK,
diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h
b/libstdc++-v3/config/os/mingw32/error_constants.h
index 2586eed5b037..eeeeedc5c611 100644
--- a/libstdc++-v3/config/os/mingw32/error_constants.h
+++ b/libstdc++-v3/config/os/mingw32/error_constants.h
@@ -104,9 +104,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
// operation_canceled = ECANCELED,
// operation_in_progress = EINPROGRESS,
-#ifdef EPERM
operation_not_permitted = EPERM,
-#endif
// operation_not_supported = EOPNOTSUPP,
#ifdef EWOULDBLOCK
operation_would_block = EWOULDBLOCK,
diff --git a/libstdc++-v3/src/c++11/system_error.cc
b/libstdc++-v3/src/c++11/system_error.cc
index 851f51acd404..a251fe6a50e2 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -275,11 +275,7 @@ namespace
X (NONPAGED_SYSTEM_RESOURCES, EAGAIN);
X (NOT_ENOUGH_MEMORY, ENOMEM);
X (NOT_ENOUGH_QUOTA, EIO);
-#ifdef EPERM
X (NOT_OWNER, EPERM);
-#else
- X (NOT_OWNER, EACCES);
-#endif
X (NOT_SAME_DEVICE, EXDEV);
X (NOT_SUPPORTED, ENOSYS);
X (NO_DATA, EPIPE);
diff --git a/libstdc++-v3/src/c++17/fs_dir.cc b/libstdc++-v3/src/c++17/fs_dir.cc
index f6860e264110..f1eca0bbd51c 100644
--- a/libstdc++-v3/src/c++17/fs_dir.cc
+++ b/libstdc++-v3/src/c++17/fs_dir.cc
@@ -514,13 +514,9 @@ fs::recursive_directory_iterator::__erase(error_code*
ecptr)
{
// We did not have a cached type, so it's possible that top.entry
// is actually a directory, and that's why the unlink above failed.
-#ifdef EPERM
// POSIX.1-2017 says unlink on a directory returns EPERM,
- // but LSB allows EISDIR too. Some targets don't even define EPERM.
+ // but LSB allows EISDIR too.
if (ec.value() == EPERM || ec.value() == EISDIR)
-#else
- if (ec.value() == EISDIR)
-#endif
{
// Retry, treating it as a directory.
top.entry._M_type = file_type::directory;
diff --git
a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
index 1b1a950c2b0b..13f4b385e385 100644
---
a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
+++
b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
@@ -121,11 +121,7 @@ void test01()
#endif
TEST_ERRC(operation_in_progress);
-
-#ifdef EPERM
TEST_ERRC(operation_not_permitted);
-#endif
-
TEST_ERRC(operation_not_supported);
#ifdef EWOULDBLOCK
--
2.55.0