]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not use dirent::d_type unconditionally
authorJonathan Wakely <jwakely@redhat.com>
Tue, 1 Feb 2022 23:58:08 +0000 (23:58 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 4 Apr 2022 11:45:30 +0000 (12:45 +0100)
These new tests should not use the d_type member unless it's actually
present on the OS.

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
autoconf macro to check whether d_type is present.
* testsuite/experimental/filesystem/iterators/error_reporting.cc:
Likewise.

(cherry picked from commit d98668eb06f532b2dbe0c721fa1b9ed6e643df27)

libstdc++-v3/testsuite/27_io/filesystem/iterators/error_reporting.cc
libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc

index 81ef10693675bda2751b019eeee1837316ba5c6f..1f297a731a374692cacbbdf2ea788f61e4b8f996 100644 (file)
@@ -36,14 +36,18 @@ extern "C" struct dirent* readdir(DIR*)
   {
   case 1:
     global_dirent.d_ino = 999;
+#if defined _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE && defined DT_REG
     global_dirent.d_type = DT_REG;
+#endif
     global_dirent.d_reclen = 0;
     std::char_traits<char>::copy(global_dirent.d_name, "file", 5);
     choice = 0;
     return &global_dirent;
   case 2:
     global_dirent.d_ino = 111;
+#if defined _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE && defined DT_DIR
     global_dirent.d_type = DT_DIR;
+#endif
     global_dirent.d_reclen = 60;
     std::char_traits<char>::copy(global_dirent.d_name, "subdir", 7);
     choice = 1;
index ade62732028d32ea3e40e39a56f181548e148186..806c511ebefc8e2ccdab6ac058452a3c5690a248 100644 (file)
@@ -37,14 +37,18 @@ extern "C" struct dirent* readdir(DIR*)
   {
   case 1:
     global_dirent.d_ino = 999;
+#if defined _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE && defined DT_REG
     global_dirent.d_type = DT_REG;
+#endif
     global_dirent.d_reclen = 0;
     std::char_traits<char>::copy(global_dirent.d_name, "file", 5);
     choice = 0;
     return &global_dirent;
   case 2:
     global_dirent.d_ino = 111;
+#if defined _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE && defined DT_DIR
     global_dirent.d_type = DT_DIR;
+#endif
     global_dirent.d_reclen = 60;
     std::char_traits<char>::copy(global_dirent.d_name, "subdir", 7);
     choice = 1;