public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r10-10840] libstdc++: Do not use dirent::d_type unconditionally
Date: Wed, 15 Jun 2022 08:14:54 +0000 (GMT)	[thread overview]
Message-ID: <20220615081454.EE566385C33F@sourceware.org> (raw)

https://gcc.gnu.org/g:401fbbbda29394c70941ec03b9e9f21777c36178

commit r10-10840-g401fbbbda29394c70941ec03b9e9f21777c36178
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Feb 1 23:58:08 2022 +0000

    libstdc++: Do not use dirent::d_type unconditionally
    
    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)

Diff:
---
 libstdc++-v3/testsuite/27_io/filesystem/iterators/error_reporting.cc  | 4 ++++
 .../testsuite/experimental/filesystem/iterators/error_reporting.cc    | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/libstdc++-v3/testsuite/27_io/filesystem/iterators/error_reporting.cc b/libstdc++-v3/testsuite/27_io/filesystem/iterators/error_reporting.cc
index 81ef1069367..1f297a731a3 100644
--- a/libstdc++-v3/testsuite/27_io/filesystem/iterators/error_reporting.cc
+++ b/libstdc++-v3/testsuite/27_io/filesystem/iterators/error_reporting.cc
@@ -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;
diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc
index ade62732028..806c511ebef 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc
@@ -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;


                 reply	other threads:[~2022-06-15  8:14 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=20220615081454.EE566385C33F@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).