public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_4-branch] Cygwin: define FILE as struct __sFILE64, not as __sFILE
@ 2022-12-08 18:03 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2022-12-08 18:03 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d59d4877f85983f776b9f49105cc24fb582e97df
commit d59d4877f85983f776b9f49105cc24fb582e97df
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Thu Dec 8 13:58:37 2022 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Thu Dec 8 18:53:24 2022 +0100
Cygwin: define FILE as struct __sFILE64, not as __sFILE
Until Cygwin 3.3.6, we define __LARGE64_FILES unconditionally, so we
were using the type __sFILE64 even for 64 bit. That was lazy and wrong.
so commit 2902b3a09e0a ("Cygwin: drop requirement to build newlib's
stdio64") tried to fix that.
Unfortunately this patch forgot to take the exposure of the typename
__sFILE64 in userspace into account. This leads to trouble in C++ due
to name mangling.
Commit 0f376ae22036 tried to fix this by just renaming __sFILE to
__sFILE64 by using a macro. While __sFILE and __sFILE64 are the same
size, they are not exactly congruent.
To avoid backward compatibility problems, make sure to define FILE
as the real __sFILE64, and make sure that __sFILE is not defined at
all on Cygwin.
Fixes: 0f376ae22036 ("Cygwin: rename __sFILE to __sFILE64 for backward
compatibility")
Fixes: 2902b3a09e0a ("Cygwin: drop requirement to build newlib's stdio64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
newlib/libc/include/sys/reent.h | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 71342bebca0d..6d8b005b2b56 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -144,6 +144,11 @@ struct __sbuf {
#define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */
+/* Cygwin must use __sFILE64 for backward compatibility, even though
+ it's not defining __LARGE64_FILES anymore. To make sure that __sFILE
+ is never defined, disable it here explicitely. */
+#ifndef __CYGWIN__
+
struct __sFILE {
unsigned char *_p; /* current position in (some) buffer */
int _r; /* read space left for getc() */
@@ -195,13 +200,24 @@ struct __sFILE {
int _flags2; /* for future use */
};
+#endif /* !__CYGWIN__ */
+
#ifdef __CUSTOM_FILE_IO__
/* Get custom _FILE definition. */
#include <sys/custom_file.h>
#else /* !__CUSTOM_FILE_IO__ */
-#ifdef __LARGE64_FILES
+/* Cygwin must use __sFILE64 for backward compatibility, even though
+ it's not defining __LARGE64_FILES anymore. It also has to make
+ sure the name is the same to satisfy C++ name mangling. Overloading
+ _fpos64_t just fixes a build problem. The _seek64 function is
+ actually never used without __LARGE64_FILES being defined. */
+#if defined (__LARGE64_FILES) || defined (__CYGWIN__)
+#ifdef __CYGWIN__
+#define _fpos64_t _fpos_t
+#endif
+
struct __sFILE64 {
unsigned char *_p; /* current position in (some) buffer */
int _r; /* read space left for getc() */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-08 18:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 18:03 [newlib-cygwin/cygwin-3_4-branch] Cygwin: define FILE as struct __sFILE64, not as __sFILE 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).