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 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 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


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

2024-05-08 Thread Pali Rohár
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
 ADD_UNDERSCORE(dup)
 ADD_UNDERSCORE(dup2)
 ADD_UNDERSCORE(ecvt)
 #ifndef UCRTBASE
+#ifdef CRTDLL
+; ADD_UNDERSCORE_DATA_DLL(environ)
+#else
 ; ADD_UNDERSCORE_DATA(environ)
 #endif
+#endif
 ADD_UNDERSCORE(eof)
 ADD_UNDERSCORE(execl)
 ADD_UNDERSCORE(execle)
@@ -50,8 +59,12 @@ ADD_UNDERSCORE(fputchar)
 ; ADD_UNDERSCORE(fstat)
 ; ADD_UNDERSCORE(ftime)
 #ifndef UCRTBASE
+#ifdef CRTDLL
+; ADD_UNDERSCORE_DATA_DLL(HUGE)
+#else
 ; ADD_UNDERSCORE_DATA(HUGE)
 #endif
+#endif
 ADD_UNDERSCORE(gcvt)
 ADD_UNDERSCORE(getch)
 ADD_UNDERSCORE(getche)
@@ -114,13 +127,23 @@ ADD_UNDERSCORE(strset)
 ADD_UNDERSCORE(strupr)
 ADD_UNDERSCORE(swab)
 #ifndef UCRTBASE
+// sys_errlist is without _dll suffix in crtdll.dll
 ; ADD_UNDERSCORE_DATA(sys_errlist)
+#ifdef CRTDLL
+; ADD_UNDERSCORE_DATA_DLL(sys_nerr)
+#else
 ; ADD_UNDERSCORE_DATA(sys_nerr)
 #endif
+#endif
 ADD_UNDERSCORE(tell)
 ADD_UNDERSCORE(tempnam)
 #ifndef UCRTBASE
+#ifdef CRTDLL
+ADD_UNDERSCORE_DATA_DLL(timezone)
+#else
 ADD_UNDERSCORE_DATA(timezone)
+#endif
+// tzname is without _dll suffix in crtdll.dll
 ADD_UNDERSCORE_DATA(tzname)
 ADD_UNDERSCORE(tzset)
 #endif
diff --git a/mingw-w64-crt/lib32/crtdll.def.in 
b/mingw-w64-crt/lib32/crtdll.def.in
index 47c5f4558085..06f4ee68ceee 100644
--- a/mingw-w64-crt/lib32/crtdll.def.in
+++ b/mingw-w64-crt/lib32/crtdll.def.in
@@ -623,6 +623,7 @@ _ltow
 _ultow
 
 ; include symbol aliases for compatibility with msvcrt.dll
+#define CRTDLL
 #define PRE_C95_SWPRINTF
 #define FIXED_SIZE_SYMBOLS
 #define NO_WIDE_FIXED_SIZE
-- 
2.20.1



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