From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 5C5E8383FF47; Thu, 8 Dec 2022 16:17:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C5E8383FF47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670516244; bh=5AOcViAeszecypz1hLeS+DXHmtqIHwO5gThXs5ApQac=; h=From:To:Subject:Date:From; b=bX8Eh4t5SQwraW/Z9MK2kxKD/aQsYARnJGStoDa26HLfU1/+tzmtevzYjlIwiw5KU fB3+e8eKnOvE3kno2SZC6dOgMsxEhFS1XVvNSwOBgJa9aRWnbeu4UjnjYkR+Pm7kVG Ml8q1vZrdxvsO1aTYS9lhyBVOyaMSynCtHWfk898= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: define FILE as struct __sFILE64, not as __sFILE X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 6429a7a7f6e6881ae7b81b4b566ac6943aa74f2c X-Git-Newrev: 55de3fdd0e850eb4ed708dc8ea8cf1419b89ee03 Message-Id: <20221208161724.5C5E8383FF47@sourceware.org> Date: Thu, 8 Dec 2022 16:17:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D55de3fdd0e8= 50eb4ed708dc8ea8cf1419b89ee03 commit 55de3fdd0e850eb4ed708dc8ea8cf1419b89ee03 Author: Corinna Vinschen AuthorDate: Thu Dec 8 16:03:06 2022 +0100 Commit: Corinna Vinschen CommitDate: Thu Dec 8 17:16:20 2022 +0100 Cygwin: define FILE as struct __sFILE64, not as __sFILE =20 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. =20 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. =20 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. =20 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. =20 Fixes: 0f376ae22036 ("Cygwin: rename __sFILE to __sFILE64 for backward compatibility") Fixes: 2902b3a09e0a ("Cygwin: drop requirement to build newlib's stdio6= 4") Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/include/sys/reent.h | 18 +++++++++++++++++- winsup/cygwin/include/cygwin/config.h | 6 ------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reen= t.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 { =20 #define _REENT_SMALL_CHECK_INIT(ptr) /* nothing */ =20 +/* 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 */ }; =20 +#endif /* !__CYGWIN__ */ + #ifdef __CUSTOM_FILE_IO__ =20 /* Get custom _FILE definition. */ #include =20 #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() */ diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/= cygwin/config.h index c9c3565c63a3..2a708327890b 100644 --- a/winsup/cygwin/include/cygwin/config.h +++ b/winsup/cygwin/include/cygwin/config.h @@ -49,12 +49,6 @@ extern inline struct _reent *__getreent (void) =20 #define __FILENAME_MAX__ 4096 /* Keep in sync with PATH_MAX in limits.h. */ =20 -/* Unfortunately we defined __LARGE64_FILES until Cygwin 3.3.6, so - FILE was based on `struct __sFILE64'. The name is exposed into - userspace and consequentially used in C++ name mangling. We must - redefine __sFILE as __sFILE64 to stay backward compatible. */ -#define __sFILE __sFILE64 - /* The following block of macros is required to build newlib correctly for Cygwin. Changing them in applications has no or not the desired effect. Just leave them alone. */