[bug] string.h inadequately respects __POSIX_VISIBLE
Corinna Vinschen
vinschen@redhat.com
Thu Jul 2 17:58:00 GMT 2015
On Jul 1 20:03, Colin Percival wrote:
> [Please CC on replies, since I'm not subscribed to the list.]
>
> Hi all,
>
> I distribute some code (spiped) which sets _POSIX_C_SOURCE=200809L, in an
> attempt at strict POSIX conformance. Alas, this triggers a conformance
> bug in newlib.
>
> In newlib/libc/include/sys/cdefs.h this value is correctly translated to
> define __POSIX_VISIBLE:
>
> 654 #if _POSIX_C_SOURCE >= 200809
> 655 #define __POSIX_VISIBLE 200809
> 656 #define __ISO_C_VISIBLE 1999
>
> but __POSIX_VISIBLE is not respected in newlib/libc/include/string.h when
> strdup is declared:
> 79 #if __XSI_VISIBLE >= 500
> 80 char *_EXFUN(strdup,(const char *));
> 81 #endif
>
> The test in this case should be
> #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
>
> It looks like strdup is the only function you're missing from string.h,
Hmm, a quick scan of FreeBSD's string.h turns up strndup as a candidate
as well. It's __XSI_VISIBLE >= 700 in newlib, __POSIX_VISIBLE >= 200809
in FreeBSD.
> but there are several others which you're declaring unconditionally or
> simply based on __POSIX_VISIBLE being defined rather than checking the
> exact value. I haven't checked the other header files in your libc.
Care to send patches against our git repo?
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150702/94aafc24/attachment.sig>
More information about the Newlib
mailing list