[PATCH] Feature test macros overhaul: string.h and strings.h overlaps

Eric Blake eblake@redhat.com
Thu Apr 14 14:16:00 GMT 2016


On 04/13/2016 10:55 PM, Yaakov Selkowitz wrote:
> strings.h is the header mandated for these functions in POSIX.1 prior to
> 2008 (when most of these were removed).  The declarations in string.h are
> only for BSD compatibility.  But when both headers are included, avoid
> duplicate declarations.
> 
> Also, mark stpcpy and stpncpy as POSIX.1-2008.
> 
> Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
> ---
>  newlib/libc/include/string.h  | 14 +++++++-------
>  newlib/libc/include/strings.h |  5 +++++
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h
> index 68ee412..56c7fc2 100644
> --- a/newlib/libc/include/string.h
> +++ b/newlib/libc/include/string.h

> +#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
>  int	 _EXFUN(strcasecmp,(const char *, const char *));
>  #endif

POSIX says <string.h> can declare ANY str* function without it being
namespace pollution, so _this_ particular duplicate is not only okay,
but there are programs that have come to rely on it being duplicated
here, the way glibc does it (yes, those programs SHOULD be using
<strings.h>, but it doesn't hurt to copy glibc).

> -#if __BSD_VISIBLE || __POSIX_VISIBLE
> +#if __BSD_VISIBLE /* POSIX declaration is in <strings.h> */
>  int	_EXFUN(strncasecmp,(const char *, const char *, size_t));

Ditto.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20160414/00d0cf17/attachment.sig>


More information about the Newlib mailing list