Re: [Mingw-w64-public] [PATCH 6/9] crt: Fix DATA aliases for crtdll.dll

2024-05-20 Thread Martin Storsjö

On Mon, 20 May 2024, Pali Rohár wrote:


On Monday 20 May 2024 13:07:29 Martin Storsjö wrote:

On Thu, 9 May 2024, Pali Rohár wrote:


crtdll.dll library has some DATA symbols with _dll suffix.
Fix generating aliases for these symbols.
---
.../def-include/msvcrt-common.def.in  | 23 +++
mingw-w64-crt/lib32/crtdll.def.in |  1 +
2 files changed, 24 insertions(+)

diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in 
b/mingw-w64-crt/def-include/msvcrt-common.def.in
index 125982d5bf53..98ab6d6b62f8 100644
--- a/mingw-w64-crt/def-include/msvcrt-common.def.in
+++ b/mingw-w64-crt/def-include/msvcrt-common.def.in
@@ -2,6 +2,7 @@

#define ADD_UNDERSCORE(symbol) symbol == _ ## symbol
#define ADD_UNDERSCORE_DATA(symbol) symbol DATA == _ ## symbol
+#define ADD_UNDERSCORE_DATA_DLL(symbol) symbol DATA == _ ## symbol ## _dll
#define ADD_DOUBLE_UNDERSCORE(symbol) symbol == __ ## symbol

; This is list of symbol aliases from the Visual C++ 1.0 oldnames.lib library
@@ -22,14 +23,22 @@ ADD_UNDERSCORE(creat)
; ADD_UNDERSCORE(cscanf)
ADD_UNDERSCORE(cwait)
#ifndef UCRTBASE
+#ifdef CRTDLL
+ADD_UNDERSCORE_DATA_DLL(daylight)
+#else
ADD_UNDERSCORE_DATA(daylight)
#endif
+#endif


Instead of nesting these ifdefs, I think this would be clearer like this:

#ifdef CRTDLL
...
#elif !defined(UCRTBASE)
...
#endif

This seems to be the case for a couple of the other changes as well, but the
last ifdef, around sys_errlist and sys_nerr, probably is best to keep as is
here.

// Martin


That makes sense. Now I looked at it and I'm proposing following change
which also documents why those symbols are skipped for UCRT:


This looks good, thanks!

I applied the rest of these patches with these suggestions then, thanks!

// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 2/9] crt: Include msvcrt-common.def.in after declaring all library symbols

2024-05-20 Thread Martin Storsjö

On Mon, 20 May 2024, Pali Rohár wrote:


On Monday 20 May 2024 13:04:33 Martin Storsjö wrote:

On Thu, 9 May 2024, Pali Rohár wrote:


File msvcrt-common.def.in adds just symbol aliases, so include it in CRT
def files after having all symbols declared.

Note that some def files use DECORATED_EXPORT macro from func.def.in file,
so include func.def.in at beginning of each def file.


I guess def files also could use many other of the macros defined in
func.def.in, like F32(), F64() etc - not only DECORATED_EXPORT? (Not sure if
this is done in practice or not though.)

// Martin


That it truth. For example msvcrt.def.in uses also other macros from
func.def.in file.

So what about rephrasing commit message to something like this?

 Note that some def files use macros from func.def.in file,
 so include func.def.in at beginning of the file when needed.


This sounds good to me, thanks!

// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 6/9] crt: Fix DATA aliases for crtdll.dll

2024-05-20 Thread Pali Rohár
On Monday 20 May 2024 13:07:29 Martin Storsjö wrote:
> On Thu, 9 May 2024, Pali Rohár wrote:
> 
> > crtdll.dll library has some DATA symbols with _dll suffix.
> > Fix generating aliases for these symbols.
> > ---
> > .../def-include/msvcrt-common.def.in  | 23 +++
> > mingw-w64-crt/lib32/crtdll.def.in |  1 +
> > 2 files changed, 24 insertions(+)
> > 
> > diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in 
> > b/mingw-w64-crt/def-include/msvcrt-common.def.in
> > index 125982d5bf53..98ab6d6b62f8 100644
> > --- a/mingw-w64-crt/def-include/msvcrt-common.def.in
> > +++ b/mingw-w64-crt/def-include/msvcrt-common.def.in
> > @@ -2,6 +2,7 @@
> > 
> > #define ADD_UNDERSCORE(symbol) symbol == _ ## symbol
> > #define ADD_UNDERSCORE_DATA(symbol) symbol DATA == _ ## symbol
> > +#define ADD_UNDERSCORE_DATA_DLL(symbol) symbol DATA == _ ## symbol ## _dll
> > #define ADD_DOUBLE_UNDERSCORE(symbol) symbol == __ ## symbol
> > 
> > ; This is list of symbol aliases from the Visual C++ 1.0 oldnames.lib 
> > library
> > @@ -22,14 +23,22 @@ ADD_UNDERSCORE(creat)
> > ; ADD_UNDERSCORE(cscanf)
> > ADD_UNDERSCORE(cwait)
> > #ifndef UCRTBASE
> > +#ifdef CRTDLL
> > +ADD_UNDERSCORE_DATA_DLL(daylight)
> > +#else
> > ADD_UNDERSCORE_DATA(daylight)
> > #endif
> > +#endif
> 
> Instead of nesting these ifdefs, I think this would be clearer like this:
> 
> #ifdef CRTDLL
> ...
> #elif !defined(UCRTBASE)
> ...
> #endif
> 
> This seems to be the case for a couple of the other changes as well, but the
> last ifdef, around sys_errlist and sys_nerr, probably is best to keep as is
> here.
> 
> // Martin

That makes sense. Now I looked at it and I'm proposing following change
which also documents why those symbols are skipped for UCRT:

From 79abe4f3b5ab347327532d9aba0cfdaccb37dbb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= 
Date: Mon, 20 May 2024 20:44:47 +0200
Subject: [PATCH] crt: Fix DATA aliases for crtdll.dll

crtdll.dll library has some DATA symbols with _dll suffix.
Fix generating aliases for these symbols.

With this change also document why those symbols are not for UCRTBASE.
---
 .../def-include/msvcrt-common.def.in  | 45 ---
 mingw-w64-crt/lib32/crtdll.def.in |  1 +
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in 
b/mingw-w64-crt/def-include/msvcrt-common.def.in
index 125982d5bf53..b44c0daae656 100644
--- a/mingw-w64-crt/def-include/msvcrt-common.def.in
+++ b/mingw-w64-crt/def-include/msvcrt-common.def.in
@@ -2,6 +2,7 @@
 
 #define ADD_UNDERSCORE(symbol) symbol == _ ## symbol
 #define ADD_UNDERSCORE_DATA(symbol) symbol DATA == _ ## symbol
+#define ADD_UNDERSCORE_DATA_DLL(symbol) symbol DATA == _ ## symbol ## _dll
 #define ADD_DOUBLE_UNDERSCORE(symbol) symbol == __ ## symbol
 
 ; This is list of symbol aliases from the Visual C++ 1.0 oldnames.lib library
@@ -21,13 +22,21 @@ ADD_UNDERSCORE(close)
 ADD_UNDERSCORE(creat)
 ; ADD_UNDERSCORE(cscanf)
 ADD_UNDERSCORE(cwait)
-#ifndef UCRTBASE
+#if defined(UCRTBASE)
+; daylight variable is provided by ucrtbase_compat.c
+#elif defined(CRTDLL)
+ADD_UNDERSCORE_DATA_DLL(daylight)
+#else
 ADD_UNDERSCORE_DATA(daylight)
 #endif
 ADD_UNDERSCORE(dup)
 ADD_UNDERSCORE(dup2)
 ADD_UNDERSCORE(ecvt)
-#ifndef UCRTBASE
+#if defined(UCRTBASE)
+; _environ variable is not available in ucrtbase.dll and there is no 
replacement for it
+#elif defined(CRTDLL)
+; ADD_UNDERSCORE_DATA_DLL(environ)
+#else
 ; ADD_UNDERSCORE_DATA(environ)
 #endif
 ADD_UNDERSCORE(eof)
@@ -49,7 +58,11 @@ ADD_UNDERSCORE(fileno)
 ADD_UNDERSCORE(fputchar)
 ; ADD_UNDERSCORE(fstat)
 ; ADD_UNDERSCORE(ftime)
-#ifndef UCRTBASE
+#if defined(UCRTBASE)
+; _HUGE variable is not available in ucrtbase.dll and there is no replacement 
for it
+#elif defined(CRTDLL)
+; ADD_UNDERSCORE_DATA_DLL(HUGE)
+#else
 ; ADD_UNDERSCORE_DATA(HUGE)
 #endif
 ADD_UNDERSCORE(gcvt)
@@ -113,15 +126,37 @@ ADD_UNDERSCORE(strrev)
 ADD_UNDERSCORE(strset)
 ADD_UNDERSCORE(strupr)
 ADD_UNDERSCORE(swab)
-#ifndef UCRTBASE
+#if defined(UCRTBASE)
+; _sys_errlist variable is not available in ucrtbase.dll and there is no 
replacement for it
+#else
+// sys_errlist variable is without _dll suffix in crtdll.dll
 ; ADD_UNDERSCORE_DATA(sys_errlist)
+#endif
+#if defined(UCRTBASE)
+; _sys_nerr variable is not available in ucrtbase.dll and there is no 
replacement for it
+#elif defined(CRTDLL)
+; ADD_UNDERSCORE_DATA_DLL(sys_nerr)
+#else
 ; ADD_UNDERSCORE_DATA(sys_nerr)
 #endif
 ADD_UNDERSCORE(tell)
 ADD_UNDERSCORE(tempnam)
-#ifndef UCRTBASE
+#if defined(UCRTBASE)
+; timezone variable is provided by ucrtbase_compat.c
+#elif defined(CRTDLL)
+ADD_UNDERSCORE_DATA_DLL(timezone)
+#else
 ADD_UNDERSCORE_DATA(timezone)
+#endif
+#if defined(UCRTBASE)
+; tzname variable is provided by ucrtbase_compat.c
+#else
+// tzname variable is without _dll suffix in crtdll.dll
 ADD_UNDERSCORE_DATA(tzname)
+#endif
+#if defined(UCRTBASE)
+; tzset function is provided by 

Re: [Mingw-w64-public] [PATCH 2/9] crt: Include msvcrt-common.def.in after declaring all library symbols

2024-05-20 Thread Pali Rohár
On Monday 20 May 2024 13:04:33 Martin Storsjö wrote:
> On Thu, 9 May 2024, Pali Rohár wrote:
> 
> > File msvcrt-common.def.in adds just symbol aliases, so include it in CRT
> > def files after having all symbols declared.
> > 
> > Note that some def files use DECORATED_EXPORT macro from func.def.in file,
> > so include func.def.in at beginning of each def file.
> 
> I guess def files also could use many other of the macros defined in
> func.def.in, like F32(), F64() etc - not only DECORATED_EXPORT? (Not sure if
> this is done in practice or not though.)
> 
> // Martin

That it truth. For example msvcrt.def.in uses also other macros from
func.def.in file.

So what about rephrasing commit message to something like this?

  Note that some def files use macros from func.def.in file,
  so include func.def.in at beginning of the file when needed.


___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: crtdll.def.in: Fix library name and time symbol exports

2024-05-20 Thread Martin Storsjö

On Sun, 12 May 2024, Pali Rohár wrote:


Change library name to uppercase CRTDLL.dll and remove DATA keyword for all
time function symbols. This is how the original crtdll.dll library is defined.
---
mingw-w64-crt/lib32/crtdll.def.in | 12 ++--
1 file changed, 6 insertions(+), 6 deletions(-)


These three patches seemed fine, so I pushed them. Thanks!

// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH] crt: msvcr80.dll: Remove duplicated X64 fallback functions

2024-05-20 Thread Martin Storsjö

On Thu, 9 May 2024, Pali Rohár wrote:


Symbols __p___argv, __p__acmdln, __p__commode, __p__fmode, and __p__wcmdln
are available in X64 version of msvcr80.dll. This was clarified and fixed
in commit e0426704cce399a7517e4ec71360bbd1d5f880e3. So remove duplicated
definitions of fallback functions.
---
mingw-w64-crt/Makefile.am | 9 +
1 file changed, 1 insertion(+), 8 deletions(-)


This looks ok to me, and is independent of the other patches, so I pushed 
it.


// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 3/3] crt: msvcrt.def.in: Move arch-specific comments in #ifdef sections

2024-05-20 Thread Martin Storsjö

On Thu, 9 May 2024, Pali Rohár wrote:


So comments unrelated to processing architecture would be dropped by 
preprocessor.
---
mingw-w64-crt/lib-common/msvcrt.def.in | 8 +---
1 file changed, 5 insertions(+), 3 deletions(-)


This set of three patches looks ok to me, but depends on parts of the 
earlier 9-patch set, so it needs to wait for that one to be applied.


// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 9/9] crt: Rename msvcrt-common.def.in to crt-aliases.def.in

2024-05-20 Thread Martin Storsjö

On Thu, 9 May 2024, Pali Rohár wrote:


This file contains definitions of symbol aliases for any CRT library. It is
already used by msvcrt, crtdll and ucrt. So rename msvcrt-common.def.in to
crt-aliases.def.in as new name better match the purpose of the file.
---


The rest of these 9 patches seem fine to me, the only details I noticed 
was some parts of the commit message in 2/9 and ifdef style in 6/9.


// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 6/9] crt: Fix DATA aliases for crtdll.dll

2024-05-20 Thread Martin Storsjö

On Thu, 9 May 2024, Pali Rohár wrote:


crtdll.dll library has some DATA symbols with _dll suffix.
Fix generating aliases for these symbols.
---
.../def-include/msvcrt-common.def.in  | 23 +++
mingw-w64-crt/lib32/crtdll.def.in |  1 +
2 files changed, 24 insertions(+)

diff --git a/mingw-w64-crt/def-include/msvcrt-common.def.in 
b/mingw-w64-crt/def-include/msvcrt-common.def.in
index 125982d5bf53..98ab6d6b62f8 100644
--- a/mingw-w64-crt/def-include/msvcrt-common.def.in
+++ b/mingw-w64-crt/def-include/msvcrt-common.def.in
@@ -2,6 +2,7 @@

#define ADD_UNDERSCORE(symbol) symbol == _ ## symbol
#define ADD_UNDERSCORE_DATA(symbol) symbol DATA == _ ## symbol
+#define ADD_UNDERSCORE_DATA_DLL(symbol) symbol DATA == _ ## symbol ## _dll
#define ADD_DOUBLE_UNDERSCORE(symbol) symbol == __ ## symbol

; This is list of symbol aliases from the Visual C++ 1.0 oldnames.lib library
@@ -22,14 +23,22 @@ ADD_UNDERSCORE(creat)
; ADD_UNDERSCORE(cscanf)
ADD_UNDERSCORE(cwait)
#ifndef UCRTBASE
+#ifdef CRTDLL
+ADD_UNDERSCORE_DATA_DLL(daylight)
+#else
ADD_UNDERSCORE_DATA(daylight)
#endif
+#endif


Instead of nesting these ifdefs, I think this would be clearer like this:

#ifdef CRTDLL
...
#elif !defined(UCRTBASE)
...
#endif

This seems to be the case for a couple of the other changes as well, but 
the last ifdef, around sys_errlist and sys_nerr, probably is best to keep 
as is here.


// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


Re: [Mingw-w64-public] [PATCH 2/9] crt: Include msvcrt-common.def.in after declaring all library symbols

2024-05-20 Thread Martin Storsjö

On Thu, 9 May 2024, Pali Rohár wrote:


File msvcrt-common.def.in adds just symbol aliases, so include it in CRT
def files after having all symbols declared.

Note that some def files use DECORATED_EXPORT macro from func.def.in file,
so include func.def.in at beginning of each def file.


I guess def files also could use many other of the macros defined in 
func.def.in, like F32(), F64() etc - not only DECORATED_EXPORT? (Not sure 
if this is done in practice or not though.)


// Martin

___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public