On Sun, Aug 30, 2020 at 07:50:59PM +0200, Joerg Sonnenberger wrote: > On Sun, Aug 30, 2020 at 05:18:43PM +0000, m...@netbsd.org wrote: > > On Sun, Aug 30, 2020 at 06:09:47PM +0200, Joerg Sonnenberger wrote: > > > On Sun, Aug 30, 2020 at 12:00:33PM +0000, co...@sdf.org wrote: > > > > Move the big "if _NETBSD_SOURCE" chunk to the "Implementation defined" > > > > section. > > > > Makes "at_quick_exit" and others visible for strict C/C++. > > > > > > alloca is not part of POSIX. > > > > > > Joerg > > > > Hmm, should I just remove lines 349, 139-140? > > > > #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ > > defined(_NETBSD_SOURCE) > > > > ... bunch of properly guarded things that need no additional guards ... > > > > #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ > > I can't tell since I don't know what problem you are trying to fix. Note > that strict C++ support is supposed to hide all things not in the C++ > standard or required to implement it. alloca certainly does not belong > into that. > > Joerg
The following script fails to compile, it shouldn't. #!/bin/sh cat << EOF > test.c #include <stdlib.h> #include <stdio.h> void f1(void) { puts("pushed first"); fflush(stdout); } void f2(void) { puts("pushed second"); } int main(void) { at_quick_exit(f1); at_quick_exit(f2); quick_exit(0); } EOF cc test.c -std=c11 -Werror The following patch fixes this issue: Fix incorrect ifdef guards. Some of stdlib.h is incorrectly only visible with POSIX/_NETBSD_SOURCE. This part of the file is already correctly guarded, so we can just remove the extra ifdefs. Index: stdlib.h =================================================================== RCS file: /cvsroot/src/include/stdlib.h,v retrieving revision 1.122 diff -u -r1.122 stdlib.h --- stdlib.h 26 May 2020 21:49:29 -0000 1.122 +++ stdlib.h 31 Aug 2020 00:24:24 -0000 @@ -136,10 +136,6 @@ int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); -#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ - defined(_NETBSD_SOURCE) - - /* * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 */ @@ -346,7 +342,6 @@ int reallocarr(void *, size_t, size_t); #endif /* _NETBSD_SOURCE */ -#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ #if defined(_NETBSD_SOURCE) qdiv_t qdiv(quad_t, quad_t);