On 13/11/2013 14:37, Jon TURNEY wrote:
Not sure if this is wanted, but mesa likes to compile with '-std=c99 D_XOPEN_SOURCE=500', which leads to exciting crashes on x86_64 because initstate() is not prototyped. 2013-11-13 Jon TURNEY <jon.tur...@dronecode.org.uk> * include/cygwin/stdlib.h(initstate, random, setstate, srandom) : Prototype if not __STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.
It seems this doesn't do the correct thing if _GNU_SOURCE is defined (which is supposed to imply _XOPEN_SOURCE)
Attached is an additional patch which instead includes sys/cdefs.h, and uses __XSI_VISIBLE.
$ cat test.c #include <stdlib.h> int main() { return random(); } before: $ gcc test.c -Wall -ansi -D_GNU_SOURCE test.c: In function ‘main’: test.c:6:2: warning: implicit declaration of function ‘random’ after: $ gcc test.c -Wall -ansi -D_GNU_SOURCE
2015-02-19 Jon TURNEY <jon.tur...@dronecode.org.uk> * include/cygwin/stdlib.h (initstate, random, setstate, srandom): Check if __XSI_VISIBLE is set by sys/cdefs.h, rather than testing for _XOPEN_SOURCE directly, to work correctly when _GNU_SOURCE is set. Index: cygwin/include/cygwin/stdlib.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/stdlib.h,v retrieving revision 1.17 diff -u -u -p -r1.17 stdlib.h --- cygwin/include/cygwin/stdlib.h 9 Dec 2013 10:12:42 -0000 1.17 +++ cygwin/include/cygwin/stdlib.h 19 Feb 2015 12:41:00 -0000 @@ -11,6 +11,7 @@ details. */ #ifndef _CYGWIN_STDLIB_H #define _CYGWIN_STDLIB_H +#include <sys/cdefs.h> #include <cygwin/wait.h> #ifdef __cplusplus @@ -31,9 +32,7 @@ void setprogname (const char *); char *canonicalize_file_name (const char *); int unsetenv (const char *); #endif /*__STRICT_ANSI__*/ -#if !defined(__STRICT_ANSI__) \ - || (defined(_XOPEN_SOURCE) \ - && ((_XOPEN_SOURCE - 0 >= 500) || defined(_XOPEN_SOURCE_EXTENDED))) +#if !defined(__STRICT_ANSI__) || (__XSI_VISIBLE >= 500) char *initstate (unsigned seed, char *state, size_t size); long random (void); char *setstate (const char *state);