@@ -1366,6 +1366,15 @@ ftms = {
};
};
+ftms = {
+ name = freestanding_cstring;
+ values = {
+ v = 202311;
+ // This is a C++26 feature, but we support it in C++23.
+ cxxmin = 23;
+ };
+};
+
ftms = {
name = freestanding_expected;
values = {
@@ -1653,6 +1653,17 @@
#undef __glibcxx_want_freestanding_array
// from version.def line 1370
+#if !defined(__cpp_lib_freestanding_cstring)
+# if (__cplusplus >= 202100L)
+# define __glibcxx_freestanding_cstring 202311L
+# if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_cstring)
+# define __cpp_lib_freestanding_cstring 202311L
+# endif
+# endif
+#endif /* !defined(__cpp_lib_freestanding_cstring) && defined(__glibcxx_want_freestanding_cstring) */
+#undef __glibcxx_want_freestanding_cstring
+
+// from version.def line 1379
#if !defined(__cpp_lib_freestanding_expected)
# if (__cplusplus >= 202100L) && (__cpp_lib_expected)
# define __glibcxx_freestanding_expected 202311L
@@ -50,7 +50,9 @@ using std::strpbrk;
using std::strrchr;
using std::strspn;
using std::strstr;
+#if _GLIBCXX_HOSTED || __cplusplus <= 202302L
using std::strtok;
+#endif
using std::memset;
using std::strerror;
using std::strlen;
@@ -38,7 +38,8 @@
#pragma GCC system_header
-#include <bits/c++config.h>
+#define __glibcxx_want_freestanding_cstring
+#include <bits/version.h>
#include <string.h>
#ifndef _GLIBCXX_CSTRING
@@ -90,7 +91,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using ::strncmp;
using ::strncpy;
using ::strspn;
+#if _GLIBCXX_HOSTED || __cplusplus <= 202302L
using ::strtok;
+#endif
using ::strxfrm;
using ::strchr;
using ::strpbrk;
new file mode 100644
@@ -0,0 +1,19 @@
+// { dg-do compile { target c++26 } }
+// { dg-add-options no_pch }
+
+#include <cstring>
+
+#ifndef __cpp_lib_freestanding_cstring
+# error "Feature test macro for freestanding <cstring> is missing in <cstring>"
+#elif __cpp_lib_freestanding_cstring < 202311L
+# error "Feature test macro for freestanding <cstring> has wrong value in <cstring>"
+#endif
+
+#undef __cpp_lib_freestanding_cstring
+#include <version>
+
+#ifndef __cpp_lib_freestanding_cstring
+# error "Feature test macro for freestanding <cstring> is missing in <version>"
+#elif __cpp_lib_freestanding_cstring < 202311L
+# error "Feature test macro for freestanding <cstring> has wrong value in <version>"
+#endif