Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately

2015-02-19 Thread Jon TURNEY

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  

* 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 

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  

* 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 -   1.17
+++ cygwin/include/cygwin/stdlib.h  19 Feb 2015 12:41:00 -
@@ -11,6 +11,7 @@ details. */
 #ifndef _CYGWIN_STDLIB_H
 #define _CYGWIN_STDLIB_H
 
+#include 
 #include 
 
 #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);


[PATCH] Compile sigfe.s with CFLAGS

2015-02-19 Thread Jon TURNEY


CFLAGS isn't used when compiling the generated file sigfe.s, so if that 
contains -g, it lacks source debugging information.


2015-02-19  Jon TURNEY  

* Makefile.in (sigfe.o): Use CFLAGS.

Index: cygwin/Makefile.in
===
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.278
diff -u -u -p -r1.278 Makefile.in
--- cygwin/Makefile.in  28 Jan 2015 11:43:06 -  1.278
+++ cygwin/Makefile.in  19 Feb 2015 13:12:11 -
@@ -710,7 +710,7 @@ sigfe.s: $(DEF_FILE)
[ -s $@ ] && touch $@
 
 sigfe.o: sigfe.s
-   $(CC) -c -o $@ $<
+   $(CC) ${CFLAGS} -c -o $@ $<
 
 ctags: CTAGS
 tags:  CTAGS


Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately

2015-02-19 Thread Corinna Vinschen
Hi Jon,

On Feb 19 13:00, Jon TURNEY wrote:
>   * 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.

Looks good, please apply.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


pgpczBvTaDVEb.pgp
Description: PGP signature


Re: [PATCH] Compile sigfe.s with CFLAGS

2015-02-19 Thread Corinna Vinschen
On Feb 19 13:21, Jon TURNEY wrote:
>   * Makefile.in (sigfe.o): Use CFLAGS.

Please apply.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


pgpmlZMUyVfqp.pgp
Description: PGP signature