Closed komh closed 1 year ago
The LIBCn change c9814d3bdcc8796b2c139ad33ae19427874b5625 responsible for this difference comes from #57.
However, seems that bumping _XOPEN_SOURCE to 700 is the right thing indeed, this is what GLIBC also does https://sourceware.org/git/?p=glibc.git;a=blob;f=include/features.h;h=9eae86a2d845d68cae0a543a4fa87034a8f019fd;hb=HEAD.
I actually did some more modifications (in particular, made _GNU_SOURCE also define _POSIX_SOURCE and _POSIX_C_SOURCE as they should).
There is a great chance that it will break building something else but at least LIBC itself builds fine with these changes (and that's already something). We will fix new problems as we find them — we are way behind the mainstream in terms of LIBC/POSIX compatibility so it's all expected.
Hi/2.
On kLIBC, strndup() is declared if __USE_GNU, which is defined by _GNU_SOURCE, is defined. However, on LIBCn, it is declared when __POSIX_VISIBLE >= 200809.
BTW, if defining _GNU_SOURCE and including features.h, __POSIX_VISIBLE is defined to 200112 because _XOPEN_SOURCE is defined to 600 not 700.
In addition, features.h says _GNU_SOURCE turns on all the other features. Therefore, defining_XOPEN_SOURCE to 700 is correct if _GNU_SOURCE is defined.
Here is the test program:
strndup.c
And here is the patch: