[PATCH v2 1/2] libc: Make string.h POSIX.1-2024 compliant
Corinna Vinschen
vinschen@redhat.com
Wed Nov 19 11:11:33 GMT 2025
On Nov 15 00:26, Simon Barth wrote:
> POSIX.1-2024 added strlcpy, strlcat, and memmem to strings.h. Previously
> these functions were only available as parts of BSD or GNU extensions.
>
> Fix the header so that the symbol are visible for either the right
> extensions, or for POSIX.1-2024.
> ---
> newlib/libc/include/string.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
> index 32199c027..3e66ec3dd 100644
> --- a/newlib/libc/include/string.h
> +++ b/newlib/libc/include/string.h
> @@ -68,10 +68,12 @@ void * memccpy (void *__restrict, const void *__restrict, int, size_t);
> #endif
> #if __GNU_VISIBLE
> void * mempcpy (void *, const void *, size_t);
> -void * memmem (const void *, size_t, const void *, size_t);
> void * memrchr (const void *, int, size_t);
> void * rawmemchr (const void *, int);
> #endif
> +#if __GNU_VISIBLE || __POSIX_VISIBLE >= 202405
> +void * memmem (const void *, size_t, const void *, size_t);
> +#endif
> #if __POSIX_VISIBLE >= 200809
> char *stpcpy (char *__restrict, const char *__restrict);
> char *stpncpy (char *__restrict, const char *__restrict, size_t);
> @@ -111,7 +113,7 @@ int __xpg_strerror_r (int, char *, size_t);
> /* Reentrant version of strerror. */
> char * _strerror_r (struct _reent *, int, int, int *);
>
> -#if __BSD_VISIBLE
> +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 202405L
> size_t strlcat (char *, const char *, size_t);
> size_t strlcpy (char *, const char *, size_t);
> #endif
> --
> 2.51.2
I pushed this patch as is, but if you follow up with another patch
removing the guards, that would be fine.
Thanks,
Corinna
More information about the Newlib
mailing list