* [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately
@ 2013-11-13 14:36 Jon TURNEY
2013-11-13 15:15 ` Christopher Faylor
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jon TURNEY @ 2013-11-13 14:36 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
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.turney@dronecode.org.uk>
* include/cygwin/stdlib.h(initstate, random, setstate, srandom) :
Prototype if not __STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.
[-- Attachment #2: initstate_xopen_source.patch --]
[-- Type: text/plain, Size: 925 bytes --]
Index: cygwin/include/cygwin/stdlib.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/stdlib.h,v
retrieving revision 1.13
diff -u -u -p -r1.13 stdlib.h
--- cygwin/include/cygwin/stdlib.h 21 May 2013 19:04:49 -0000 1.13
+++ cygwin/include/cygwin/stdlib.h 13 Nov 2013 14:28:35 -0000
@@ -31,10 +31,14 @@ void setprogname (const char *);
char *realpath (const char *, char *);
char *canonicalize_file_name (const char *);
int unsetenv (const char *);
+#endif /*__STRICT_ANSI__*/
+#if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE >= 500) || (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED))
char *initstate (unsigned seed, char *state, size_t size);
long random (void);
char *setstate (const char *state);
void srandom (unsigned);
+#endif
+#ifndef __STRICT_ANSI__
char *ptsname (int);
int ptsname_r(int, char *, size_t);
int getpt (void);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately
2013-11-13 14:36 [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately Jon TURNEY
@ 2013-11-13 15:15 ` Christopher Faylor
2013-11-13 15:18 ` Corinna Vinschen
2015-02-19 13:00 ` Jon TURNEY
2 siblings, 0 replies; 5+ messages in thread
From: Christopher Faylor @ 2013-11-13 15:15 UTC (permalink / raw)
To: cygwin-patches
On Wed, Nov 13, 2013 at 02:37:00PM +0000, 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.turney@dronecode.org.uk>
>
> * include/cygwin/stdlib.h(initstate, random, setstate, srandom) :
> Prototype if not __STRICT_ANSI__ or _XOPEN_SOURCE is defined appropriately.
Looks good to me. Please commit.
cgf
>Index: cygwin/include/cygwin/stdlib.h
>===================================================================
>RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/stdlib.h,v
>retrieving revision 1.13
>diff -u -u -p -r1.13 stdlib.h
>--- cygwin/include/cygwin/stdlib.h 21 May 2013 19:04:49 -0000 1.13
>+++ cygwin/include/cygwin/stdlib.h 13 Nov 2013 14:28:35 -0000
>@@ -31,10 +31,14 @@ void setprogname (const char *);
> char *realpath (const char *, char *);
> char *canonicalize_file_name (const char *);
> int unsetenv (const char *);
>+#endif /*__STRICT_ANSI__*/
>+#if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE >= 500) || (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED))
> char *initstate (unsigned seed, char *state, size_t size);
> long random (void);
> char *setstate (const char *state);
> void srandom (unsigned);
>+#endif
>+#ifndef __STRICT_ANSI__
> char *ptsname (int);
> int ptsname_r(int, char *, size_t);
> int getpt (void);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately
2013-11-13 14:36 [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately Jon TURNEY
2013-11-13 15:15 ` Christopher Faylor
@ 2013-11-13 15:18 ` Corinna Vinschen
2015-02-19 13:00 ` Jon TURNEY
2 siblings, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2013-11-13 15:18 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 619 bytes --]
On Nov 13 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.
Looks good to me. Please apply.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately
2013-11-13 14:36 [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately Jon TURNEY
2013-11-13 15:15 ` Christopher Faylor
2013-11-13 15:18 ` Corinna Vinschen
@ 2015-02-19 13:00 ` Jon TURNEY
2015-02-19 13:23 ` Corinna Vinschen
2 siblings, 1 reply; 5+ messages in thread
From: Jon TURNEY @ 2015-02-19 13:00 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 913 bytes --]
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.turney@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
[-- Attachment #2: stdlib.h.patch --]
[-- Type: text/plain, Size: 1238 bytes --]
2015-02-19 Jon TURNEY <jon.turney@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);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately
2015-02-19 13:00 ` Jon TURNEY
@ 2015-02-19 13:23 ` Corinna Vinschen
0 siblings, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2015-02-19 13:23 UTC (permalink / raw)
To: cygwin-patches
[-- Attachment #1: Type: text/plain, Size: 467 bytes --]
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
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-02-19 13:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 14:36 [PATCH] Prototype initstate() etc. if _XOPEN_SOURCE is defined appropriately Jon TURNEY
2013-11-13 15:15 ` Christopher Faylor
2013-11-13 15:18 ` Corinna Vinschen
2015-02-19 13:00 ` Jon TURNEY
2015-02-19 13:23 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).