From ea6b4e42adda7e5f78097949539a3d17140e0a81 Mon Sep 17 00:00:00 2001
From: Chris Johns <chrisj@rtems.org>
Date: Sat, 23 Nov 2024 17:06:31 +1100
Subject: [PATCH v2] libstdc++-v3: Enable features for RTEMS

libstdc++-v3/ChangeLog:

	* configure: Regenerate.
	* configure.ac (newlib, *-rtems*): Add HAVE_SYS_IOCTL_H,
	HAVE_SYS_STAT_H, HAVE_SYS_TYPES_H, HAVE_S_ISREG, HAVE_UNISTD_H,
	HAVE_UNLINKAT, _GLIBCXX_USE_CHMOD, _GLIBCXX_USE_MKDIR,
        _GLIBCXX_USE_CHDIR, _GLIBCXX_USE_GETCWD, _GLIBCXX_USE_UTIME,
        _GLIBCXX_USE_LINK, _GLIBCXX_USE_READLINK, _GLIBCXX_USE_SYMLINK,
        _GLIBCXX_USE_TRUNCATE and _GLIBCXX_USE_FDOPENDIR.
---
 libstdc++-v3/configure    | 40 +++++++++++++++++++++++++++++++++++++++
 libstdc++-v3/configure.ac | 20 ++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 81329bba8e5..078fb6abdb6 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -29349,6 +29349,14 @@ else
 
         $as_echo "#define HAVE_LINK 1" >>confdefs.h
 
+        $as_echo "#define HAVE_SYS_IOCT4YL_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_SYS_STAT_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_SYS_TYPES_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_S_ISREG 1" >>confdefs.h
+
         $as_echo "#define HAVE_QUICK_EXIT 1" >>confdefs.h
 
         $as_echo "#define HAVE_READLINK 1" >>confdefs.h
@@ -29363,10 +29371,42 @@ else
 
         $as_echo "#define HAVE_SYMLINK 1" >>confdefs.h
 
+        $as_echo "#define HAVE_SYS_IOCT4YL_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_SYS_STAT_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_SYS_TYPES_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_S_ISREG 1" >>confdefs.h
+
         $as_echo "#define HAVE_TRUNCATE 1" >>confdefs.h
 
+        $as_echo "#define HAVE_UNISTD_H 1" >>confdefs.h
+
+        $as_echo "#define HAVE_UNLINKAT 1" >>confdefs.h
+
         $as_echo "#define HAVE_USLEEP 1" >>confdefs.h
 
+        $as_echo "#define _GLIBCXX_USE_CHMOD 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_MKDIR 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_CHDIR 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_GETCWD 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_UTIME 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_LINK 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_READLINK 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_SYMLINK 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_TRUNCATE 1" >>confdefs.h
+
+        $as_echo "#define _GLIBCXX_USE_FDOPENDIR 1" >>confdefs.h
+
         ;;
     esac
   elif test "x$with_headers" != "xno"; then
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 7b13f37bd5b..dbe25b29a61 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -382,6 +382,10 @@ else
         AC_DEFINE(HAVE_ALIGNED_ALLOC)
         AC_DEFINE(HAVE_AT_QUICK_EXIT)
         AC_DEFINE(HAVE_LINK)
+        AC_DEFINE(HAVE_SYS_IOCT4YL_H)
+        AC_DEFINE(HAVE_SYS_STAT_H)
+        AC_DEFINE(HAVE_SYS_TYPES_H)
+        AC_DEFINE(HAVE_S_ISREG)
         AC_DEFINE(HAVE_QUICK_EXIT)
         AC_DEFINE(HAVE_READLINK)
         AC_DEFINE(HAVE_SETENV)
@@ -389,8 +393,24 @@ else
         AC_DEFINE(HAVE_SOCKATMARK)
         AC_DEFINE(HAVE_STRERROR_L)
         AC_DEFINE(HAVE_SYMLINK)
+        AC_DEFINE(HAVE_SYS_IOCT4YL_H)
+        AC_DEFINE(HAVE_SYS_STAT_H)
+        AC_DEFINE(HAVE_SYS_TYPES_H)
+        AC_DEFINE(HAVE_S_ISREG)
         AC_DEFINE(HAVE_TRUNCATE)
+        AC_DEFINE(HAVE_UNISTD_H)
+        AC_DEFINE(HAVE_UNLINKAT)
         AC_DEFINE(HAVE_USLEEP)
+        AC_DEFINE(_GLIBCXX_USE_CHMOD)
+        AC_DEFINE(_GLIBCXX_USE_MKDIR)
+        AC_DEFINE(_GLIBCXX_USE_CHDIR)
+        AC_DEFINE(_GLIBCXX_USE_GETCWD)
+        AC_DEFINE(_GLIBCXX_USE_UTIME)
+        AC_DEFINE(_GLIBCXX_USE_LINK)
+        AC_DEFINE(_GLIBCXX_USE_READLINK)
+        AC_DEFINE(_GLIBCXX_USE_SYMLINK)
+        AC_DEFINE(_GLIBCXX_USE_TRUNCATE)
+        AC_DEFINE(_GLIBCXX_USE_FDOPENDIR)
         ;;
     esac
   elif test "x$with_headers" != "xno"; then
-- 
2.46.2

