string: Declare Issue 8 functions for POSIX.1-2024 [BZ #34466]
Checks
| Context |
Check |
Description |
| redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
| linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
| redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
fail
|
Test failed
|
Commit Message
POSIX.1-2024 requires memmem, strlcpy, and strlcat in <string.h>, and
wcslcpy and wcslcat in <wchar.h>. Expose these declarations and their
fortified wrappers under __USE_XOPEN2K24 as well as __USE_MISC. Keep
mempcpy restricted to __USE_MISC.
Add declaration tests for POSIX and X/Open Issue 8 modes, including
fortified headers.
Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
---
I do not have an FSF copyright assignment on file. This patch is offered
under the Developer Certificate of Origin 1.1, as certified by the
Signed-off-by line above.
string/Makefile | 6 ++++
string/bits/string_fortified.h | 4 +--
string/string.h | 6 ++--
string/tst-string-posix2024-fortify.c | 6 ++++
string/tst-string-posix2024-main.c | 45 +++++++++++++++++++++++++++
string/tst-string-posix2024.c | 5 +++
string/tst-string-xopen2024.c | 5 +++
wcsmbs/Makefile | 5 +++
wcsmbs/bits/wchar2-decl.h | 4 +--
wcsmbs/bits/wchar2.h | 4 +--
wcsmbs/tst-wchar-posix2024-fortify.c | 6 ++++
wcsmbs/tst-wchar-posix2024-main.c | 41 ++++++++++++++++++++++++
wcsmbs/tst-wchar-posix2024.c | 5 +++
wcsmbs/tst-wchar-xopen2024.c | 5 +++
wcsmbs/wchar.h | 2 +-
15 files changed, 140 insertions(+), 9 deletions(-)
create mode 100644 string/tst-string-posix2024-fortify.c
create mode 100644 string/tst-string-posix2024-main.c
create mode 100644 string/tst-string-posix2024.c
create mode 100644 string/tst-string-xopen2024.c
create mode 100644 wcsmbs/tst-wchar-posix2024-fortify.c
create mode 100644 wcsmbs/tst-wchar-posix2024-main.c
create mode 100644 wcsmbs/tst-wchar-posix2024.c
create mode 100644 wcsmbs/tst-wchar-xopen2024.c
Comments
For the record, on the Linaro TCWG precommit result for this patch
(1 regression, 97 fixes on aarch64): the one regression,
nptl/tst-sem_getvalue-affinity, is a CI-environment timeout, not
something this patch can influence. Its log shows the affinity test
being killed at its own timeout after skipping several CPU set sizes,
and sibling affinity tests report UNSUPPORTED because the container
cannot create cgroupv2 groups. The patch only adds declarations under
__USE_XOPEN2K24 plus new tests; the 97 fixes are the existing conform
and header tests that now see the POSIX.1-2024 declarations.
Matthias
LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
Matthias Goergens <matthias.goergens@gmail.com> writes:
> POSIX.1-2024 requires memmem, strlcpy, and strlcat in <string.h>, and
> wcslcpy and wcslcat in <wchar.h>.
Confirmed.
> Expose these declarations and their fortified wrappers under
> __USE_XOPEN2K24 as well as __USE_MISC. Keep mempcpy restricted to
> __USE_MISC.
Sounds reasonable.
> diff --git a/string/Makefile b/string/Makefile
> tst-memmove-overflow \
> tst-strerror-fail \
> tst-strfry \
> + tst-string-posix2024 \
> + tst-string-posix2024-fortify \
> + tst-string-xopen2024 \
> tst-strlcat \
Ok.
> +CPPFLAGS-tst-string-posix2024-fortify.c += \
> + $(no-fortify-source) -D_FORTIFY_SOURCE=2
This looks wierd, I think it needs a comment. I assume you're using
$(no-fortify-source) to undefind _FORTIFY_SOURCE to avoid a redefinition
warning? I see it's a common idiom elsewhere, so I won't complain.
Ok.
> diff --git a/string/bits/string_fortified.h b/string/bits/string_fortified.h
> index f1f597ec..ae97bb55 100644
> --- a/string/bits/string_fortified.h
> +++ b/string/bits/string_fortified.h
> @@ -162,7 +162,7 @@ __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest),
> __glibc_objsize (__dest));
> }
>
> -#ifdef __USE_MISC
> +#if defined __USE_MISC || defined __USE_XOPEN2K24
> extern size_t __strlcpy_chk (char *__dest, const char *__src, size_t __n,
> size_t __destlen) __THROW;
> extern size_t __REDIRECT_NTH (__strlcpy_alias,
> @@ -197,6 +197,6 @@ __NTH (strlcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
> return __strlcat_chk (__dest, __src, __n, __glibc_objsize (__dest));
> return __strlcat_alias (__dest, __src, __n);
> }
> -#endif /* __USE_MISC */
> +#endif /* __USE_MISC || __USE_XOPEN2K24 */
Ok.
> diff --git a/string/string.h b/string/string.h
> -#ifdef __USE_MISC
> +#if defined __USE_MISC || defined __USE_XOPEN2K24
> /* Find the first occurrence of NEEDLE in HAYSTACK.
> NEEDLE is NEEDLELEN bytes long;
> HAYSTACK is HAYSTACKLEN bytes long. */
> @@ -423,7 +423,9 @@ extern void *memmem (const void *__haystack, size_t __haystacklen,
> __THROW __attribute_pure__ __nonnull ((1, 3))
> __attr_access ((__read_only__, 1, 2))
> __attr_access ((__read_only__, 3, 4));
> +#endif
>
> +#ifdef __USE_MISC
> /* Copy N bytes of SRC to DEST, return pointer to bytes after the
> last written byte. */
Ok.
> extern void *__mempcpy (void *__restrict __dest,
> @@ -533,7 +535,7 @@ extern char *stpncpy (char *__restrict __dest,
> __THROW __nonnull ((1, 2));
> #endif
>
> -#ifdef __USE_MISC
> +#if defined __USE_MISC || defined __USE_XOPEN2K24
> /* Copy at most N - 1 characters from SRC to DEST. */
> extern size_t strlcpy (char *__restrict __dest,
> const char *__restrict __src, size_t __n)
Ok.
> diff --git a/string/tst-string-posix2024-fortify.c b/string/tst-string-posix2024-fortify.c
> +/* Process tst-string-posix2024-main.c in fortified POSIX.1-2024 mode. */
> +#undef _GNU_SOURCE
> +#define _POSIX_C_SOURCE 202405L
> +#define TEST_FORTIFY 1
> +
> +#include "tst-string-posix2024-main.c"
Ok.
> diff --git a/string/tst-string-posix2024-main.c b/string/tst-string-posix2024-main.c
> new file mode 100644
> index 00000000..4a52b09c
> --- /dev/null
> +++ b/string/tst-string-posix2024-main.c
> @@ -0,0 +1,45 @@
> +/* Check POSIX.1-2024 declarations in <string.h>.
> + Copyright (C) 2026 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <string.h>
> +
> +static int
> +do_test (void)
> +{
> + void *(*memmem_function) (const void *, size_t, const void *, size_t)
> + = memmem;
> + size_t (*strlcpy_function) (char *, const char *, size_t) = strlcpy;
> + size_t (*strlcat_function) (char *, const char *, size_t) = strlcat;
> +
> +#ifdef TEST_FORTIFY
> + size_t (*strlcpy_chk_function) (char *, const char *, size_t, size_t)
> + = __strlcpy_chk;
> + size_t (*strlcat_chk_function) (char *, const char *, size_t, size_t)
> + = __strlcat_chk;
> +#endif
> +
> + int result = memmem_function == NULL
> + || strlcpy_function == NULL
> + || strlcat_function == NULL;
> +#ifdef TEST_FORTIFY
> + result |= strlcpy_chk_function == NULL || strlcat_chk_function == NULL;
> +#endif
> + return result;
> +}
> +
> +#include <support/test-driver.c>
Ok.
> diff --git a/string/tst-string-posix2024.c b/string/tst-string-posix2024.c
> @@ -0,0 +1,5 @@
> +/* Process tst-string-posix2024-main.c in POSIX.1-2024 mode. */
> +#undef _GNU_SOURCE
> +#define _POSIX_C_SOURCE 202405L
> +
> +#include "tst-string-posix2024-main.c"
Ok.
> diff --git a/string/tst-string-xopen2024.c b/string/tst-string-xopen2024.c
> new file mode 100644
> index 00000000..8f1deaa9
> --- /dev/null
> +++ b/string/tst-string-xopen2024.c
> @@ -0,0 +1,5 @@
> +/* Process tst-string-posix2024-main.c in X/Open Issue 8 mode. */
> +#undef _GNU_SOURCE
> +#define _XOPEN_SOURCE 800
> +
> +#include "tst-string-posix2024-main.c"
Ok.
> diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile
> tst-mbsrtowcs \
> tst-mbstowcs \
> tst-wchar-h \
> + tst-wchar-posix2024 \
> + tst-wchar-posix2024-fortify \
> + tst-wchar-xopen2024 \
Ok.
> tst-wcrtomb \
> tst-wcslcat \
> @@ -270,6 +273,8 @@ CFLAGS-wcstold_l.c += $(strtox-CFLAGS)
> CFLAGS-wcstof128_l.c += $(strtox-CFLAGS)
> CFLAGS-wcstof_l.c += $(strtox-CFLAGS)
> CPPFLAGS-tst-wchar-h.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
> +CPPFLAGS-tst-wchar-posix2024-fortify.c += \
> + $(no-fortify-source) -D_FORTIFY_SOURCE=2
Ok.
> diff --git a/wcsmbs/bits/wchar2-decl.h b/wcsmbs/bits/wchar2-decl.h
> -#ifdef __USE_MISC
> +#if defined __USE_MISC || defined __USE_XOPEN2K24
> extern size_t __wcslcpy_chk (wchar_t *__dest, const wchar_t *__src, size_t __n,
> size_t __destlen) __THROW;
> extern size_t __REDIRECT_NTH (__wcslcpy_alias,
> @@ -291,6 +291,6 @@ extern size_t __wcslcat_chk (wchar_t *__dest, const wchar_t *__src, size_t __n,
> extern size_t __REDIRECT_NTH (__wcslcat_alias,
> (wchar_t *__dest, const wchar_t *__src,
> size_t __n), wcslcat);
> -#endif /* __USE_MISC */
> +#endif /* __USE_MISC || __USE_XOPEN2K24 */
>
> #endif /* bits/wchar2-decl.h. */
Ok.
> diff --git a/wcsmbs/bits/wchar2.h b/wcsmbs/bits/wchar2.h
> index 2966c0ec..bd99d520 100644
> --- a/wcsmbs/bits/wchar2.h
> +++ b/wcsmbs/bits/wchar2.h
> @@ -134,7 +134,7 @@ __NTH (wcsncat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
> return __wcsncat_alias (__dest, __src, __n);
> }
>
> -#ifdef __USE_MISC
> +#if defined __USE_MISC || defined __USE_XOPEN2K24
> __fortify_function __attribute_overloadable__ size_t
> __NTH (wcslcpy (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
> const wchar_t *__restrict __src, size_t __n))
> @@ -163,7 +163,7 @@ __NTH (wcslcat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
> __glibc_objsize (__dest) / sizeof (wchar_t));
> return __wcslcat_alias (__dest, __src, __n);
> }
> -#endif /* __USE_MISC */
> +#endif /* __USE_MISC || __USE_XOPEN2K24 */
Ok.
> diff --git a/wcsmbs/tst-wchar-posix2024-fortify.c b/wcsmbs/tst-wchar-posix2024-fortify.c
> new file mode 100644
> index 00000000..ff30525a
> --- /dev/null
> +++ b/wcsmbs/tst-wchar-posix2024-fortify.c
> @@ -0,0 +1,6 @@
> +/* Process tst-wchar-posix2024-main.c in fortified POSIX.1-2024 mode. */
> +#undef _GNU_SOURCE
> +#define _POSIX_C_SOURCE 202405L
> +#define TEST_FORTIFY 1
> +
> +#include "tst-wchar-posix2024-main.c"
Ok.
> diff --git a/wcsmbs/tst-wchar-posix2024-main.c b/wcsmbs/tst-wchar-posix2024-main.c
> new file mode 100644
> index 00000000..d744e548
> --- /dev/null
> +++ b/wcsmbs/tst-wchar-posix2024-main.c
> @@ -0,0 +1,41 @@
> +/* Check POSIX.1-2024 declarations in <wchar.h>.
> + Copyright (C) 2026 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <wchar.h>
> +
> +static int
> +do_test (void)
> +{
> + size_t (*wcslcpy_function) (wchar_t *, const wchar_t *, size_t) = wcslcpy;
> + size_t (*wcslcat_function) (wchar_t *, const wchar_t *, size_t) = wcslcat;
> +
> +#ifdef TEST_FORTIFY
> + size_t (*wcslcpy_chk_function) (wchar_t *, const wchar_t *, size_t, size_t)
> + = __wcslcpy_chk;
> + size_t (*wcslcat_chk_function) (wchar_t *, const wchar_t *, size_t, size_t)
> + = __wcslcat_chk;
> +#endif
> +
> + int result = wcslcpy_function == NULL || wcslcat_function == NULL;
> +#ifdef TEST_FORTIFY
> + result |= wcslcpy_chk_function == NULL || wcslcat_chk_function == NULL;
> +#endif
> + return result;
> +}
> +
> +#include <support/test-driver.c>
Ok.
> diff --git a/wcsmbs/tst-wchar-posix2024.c b/wcsmbs/tst-wchar-posix2024.c
> new file mode 100644
> index 00000000..09f62fca
> --- /dev/null
> +++ b/wcsmbs/tst-wchar-posix2024.c
> @@ -0,0 +1,5 @@
> +/* Process tst-wchar-posix2024-main.c in POSIX.1-2024 mode. */
> +#undef _GNU_SOURCE
> +#define _POSIX_C_SOURCE 202405L
> +
> +#include "tst-wchar-posix2024-main.c"
Ok.
> diff --git a/wcsmbs/tst-wchar-xopen2024.c b/wcsmbs/tst-wchar-xopen2024.c
> new file mode 100644
> index 00000000..5ac3172b
> --- /dev/null
> +++ b/wcsmbs/tst-wchar-xopen2024.c
> @@ -0,0 +1,5 @@
> +/* Process tst-wchar-posix2024-main.c in X/Open Issue 8 mode. */
> +#undef _GNU_SOURCE
> +#define _XOPEN_SOURCE 800
> +
> +#include "tst-wchar-posix2024-main.c"
Ok.
> diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
> index 449f3b4e..ec169ee6 100644
> --- a/wcsmbs/wchar.h
> +++ b/wcsmbs/wchar.h
> @@ -108,7 +108,7 @@ extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
> const wchar_t *__restrict __src, size_t __n)
> __THROW __nonnull ((1, 2));
>
> -#ifdef __USE_MISC
> +#if defined __USE_MISC || defined __USE_XOPEN2K24
> /* Copy at most N - 1 characters from SRC to DEST. */
> extern size_t wcslcpy (wchar_t *__restrict __dest,
> const wchar_t *__restrict __src, size_t __n)
Ok.
@@ -203,6 +203,9 @@ tests := \
tst-memmove-overflow \
tst-strerror-fail \
tst-strfry \
+ tst-string-posix2024 \
+ tst-string-posix2024-fortify \
+ tst-string-xopen2024 \
tst-strlcat \
tst-strlcat2 \
tst-strlcpy \
@@ -218,6 +221,9 @@ tests := \
tst-xmemset-opt \
# tests
+CPPFLAGS-tst-string-posix2024-fortify.c += \
+ $(no-fortify-source) -D_FORTIFY_SOURCE=2
+
tests-static-internal := \
test-memswap \
# tests-static-internal
@@ -162,7 +162,7 @@ __NTH (strncat (__fortify_clang_overload_arg (char *, __restrict, __dest),
__glibc_objsize (__dest));
}
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
extern size_t __strlcpy_chk (char *__dest, const char *__src, size_t __n,
size_t __destlen) __THROW;
extern size_t __REDIRECT_NTH (__strlcpy_alias,
@@ -197,6 +197,6 @@ __NTH (strlcat (__fortify_clang_overload_arg (char *, __restrict, __dest),
return __strlcat_chk (__dest, __src, __n, __glibc_objsize (__dest));
return __strlcat_alias (__dest, __src, __n);
}
-#endif /* __USE_MISC */
+#endif /* __USE_MISC || __USE_XOPEN2K24 */
#endif /* bits/string_fortified.h */
@@ -414,7 +414,7 @@ extern char *strcasestr (const char *__haystack, const char *__needle)
# endif
#endif
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
/* Find the first occurrence of NEEDLE in HAYSTACK.
NEEDLE is NEEDLELEN bytes long;
HAYSTACK is HAYSTACKLEN bytes long. */
@@ -423,7 +423,9 @@ extern void *memmem (const void *__haystack, size_t __haystacklen,
__THROW __attribute_pure__ __nonnull ((1, 3))
__attr_access ((__read_only__, 1, 2))
__attr_access ((__read_only__, 3, 4));
+#endif
+#ifdef __USE_MISC
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
last written byte. */
extern void *__mempcpy (void *__restrict __dest,
@@ -533,7 +535,7 @@ extern char *stpncpy (char *__restrict __dest,
__THROW __nonnull ((1, 2));
#endif
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
/* Copy at most N - 1 characters from SRC to DEST. */
extern size_t strlcpy (char *__restrict __dest,
const char *__restrict __src, size_t __n)
new file mode 100644
@@ -0,0 +1,6 @@
+/* Process tst-string-posix2024-main.c in fortified POSIX.1-2024 mode. */
+#undef _GNU_SOURCE
+#define _POSIX_C_SOURCE 202405L
+#define TEST_FORTIFY 1
+
+#include "tst-string-posix2024-main.c"
new file mode 100644
@@ -0,0 +1,45 @@
+/* Check POSIX.1-2024 declarations in <string.h>.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <string.h>
+
+static int
+do_test (void)
+{
+ void *(*memmem_function) (const void *, size_t, const void *, size_t)
+ = memmem;
+ size_t (*strlcpy_function) (char *, const char *, size_t) = strlcpy;
+ size_t (*strlcat_function) (char *, const char *, size_t) = strlcat;
+
+#ifdef TEST_FORTIFY
+ size_t (*strlcpy_chk_function) (char *, const char *, size_t, size_t)
+ = __strlcpy_chk;
+ size_t (*strlcat_chk_function) (char *, const char *, size_t, size_t)
+ = __strlcat_chk;
+#endif
+
+ int result = memmem_function == NULL
+ || strlcpy_function == NULL
+ || strlcat_function == NULL;
+#ifdef TEST_FORTIFY
+ result |= strlcpy_chk_function == NULL || strlcat_chk_function == NULL;
+#endif
+ return result;
+}
+
+#include <support/test-driver.c>
new file mode 100644
@@ -0,0 +1,5 @@
+/* Process tst-string-posix2024-main.c in POSIX.1-2024 mode. */
+#undef _GNU_SOURCE
+#define _POSIX_C_SOURCE 202405L
+
+#include "tst-string-posix2024-main.c"
new file mode 100644
@@ -0,0 +1,5 @@
+/* Process tst-string-posix2024-main.c in X/Open Issue 8 mode. */
+#undef _GNU_SOURCE
+#define _XOPEN_SOURCE 800
+
+#include "tst-string-posix2024-main.c"
@@ -179,6 +179,9 @@ tests := \
tst-mbsrtowcs \
tst-mbstowcs \
tst-wchar-h \
+ tst-wchar-posix2024 \
+ tst-wchar-posix2024-fortify \
+ tst-wchar-xopen2024 \
tst-wcpncpy \
tst-wcrtomb \
tst-wcslcat \
@@ -270,6 +273,8 @@ CFLAGS-wcstold_l.c += $(strtox-CFLAGS)
CFLAGS-wcstof128_l.c += $(strtox-CFLAGS)
CFLAGS-wcstof_l.c += $(strtox-CFLAGS)
CPPFLAGS-tst-wchar-h.c += $(no-fortify-source) -D_FORTIFY_SOURCE=2
+CPPFLAGS-tst-wchar-posix2024-fortify.c += \
+ $(no-fortify-source) -D_FORTIFY_SOURCE=2
CFLAGS-isoc99_wscanf.c += -fexceptions
CFLAGS-isoc99_fwscanf.c += -fexceptions
@@ -279,7 +279,7 @@ extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn,
#endif
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
extern size_t __wcslcpy_chk (wchar_t *__dest, const wchar_t *__src, size_t __n,
size_t __destlen) __THROW;
extern size_t __REDIRECT_NTH (__wcslcpy_alias,
@@ -291,6 +291,6 @@ extern size_t __wcslcat_chk (wchar_t *__dest, const wchar_t *__src, size_t __n,
extern size_t __REDIRECT_NTH (__wcslcat_alias,
(wchar_t *__dest, const wchar_t *__src,
size_t __n), wcslcat);
-#endif /* __USE_MISC */
+#endif /* __USE_MISC || __USE_XOPEN2K24 */
#endif /* bits/wchar2-decl.h. */
@@ -134,7 +134,7 @@ __NTH (wcsncat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
return __wcsncat_alias (__dest, __src, __n);
}
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
__fortify_function __attribute_overloadable__ size_t
__NTH (wcslcpy (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
const wchar_t *__restrict __src, size_t __n))
@@ -163,7 +163,7 @@ __NTH (wcslcat (__fortify_clang_overload_arg (wchar_t *, __restrict, __dest),
__glibc_objsize (__dest) / sizeof (wchar_t));
return __wcslcat_alias (__dest, __src, __n);
}
-#endif /* __USE_MISC */
+#endif /* __USE_MISC || __USE_XOPEN2K24 */
#ifdef __va_arg_pack
__fortify_function int
new file mode 100644
@@ -0,0 +1,6 @@
+/* Process tst-wchar-posix2024-main.c in fortified POSIX.1-2024 mode. */
+#undef _GNU_SOURCE
+#define _POSIX_C_SOURCE 202405L
+#define TEST_FORTIFY 1
+
+#include "tst-wchar-posix2024-main.c"
new file mode 100644
@@ -0,0 +1,41 @@
+/* Check POSIX.1-2024 declarations in <wchar.h>.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <wchar.h>
+
+static int
+do_test (void)
+{
+ size_t (*wcslcpy_function) (wchar_t *, const wchar_t *, size_t) = wcslcpy;
+ size_t (*wcslcat_function) (wchar_t *, const wchar_t *, size_t) = wcslcat;
+
+#ifdef TEST_FORTIFY
+ size_t (*wcslcpy_chk_function) (wchar_t *, const wchar_t *, size_t, size_t)
+ = __wcslcpy_chk;
+ size_t (*wcslcat_chk_function) (wchar_t *, const wchar_t *, size_t, size_t)
+ = __wcslcat_chk;
+#endif
+
+ int result = wcslcpy_function == NULL || wcslcat_function == NULL;
+#ifdef TEST_FORTIFY
+ result |= wcslcpy_chk_function == NULL || wcslcat_chk_function == NULL;
+#endif
+ return result;
+}
+
+#include <support/test-driver.c>
new file mode 100644
@@ -0,0 +1,5 @@
+/* Process tst-wchar-posix2024-main.c in POSIX.1-2024 mode. */
+#undef _GNU_SOURCE
+#define _POSIX_C_SOURCE 202405L
+
+#include "tst-wchar-posix2024-main.c"
new file mode 100644
@@ -0,0 +1,5 @@
+/* Process tst-wchar-posix2024-main.c in X/Open Issue 8 mode. */
+#undef _GNU_SOURCE
+#define _XOPEN_SOURCE 800
+
+#include "tst-wchar-posix2024-main.c"
@@ -108,7 +108,7 @@ extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
const wchar_t *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
-#ifdef __USE_MISC
+#if defined __USE_MISC || defined __USE_XOPEN2K24
/* Copy at most N - 1 characters from SRC to DEST. */
extern size_t wcslcpy (wchar_t *__restrict __dest,
const wchar_t *__restrict __src, size_t __n)