This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [bug] string.h inadequately respects __POSIX_VISIBLE


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

Attachment: pgpGADr6xbhiO.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]