crtdll.dll and ucrt needs same implementation of __initenv and __winitenv
symbols. Deduplicate code and move it into a new misc/__initenv.c file.
---
 mingw-w64-crt/Makefile.am           |  2 ++
 mingw-w64-crt/crt/crtdll_compat.c   |  6 ------
 mingw-w64-crt/crt/ucrtbase_compat.c |  5 -----
 mingw-w64-crt/misc/__initenv.c      | 12 ++++++++++++
 4 files changed, 14 insertions(+), 11 deletions(-)
 create mode 100644 mingw-w64-crt/misc/__initenv.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 66e0afa0421a..bf9b4bc22316 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -238,6 +238,7 @@ src_msvcrt=\
 src_ucrtbase=\
   crt/ucrtbase_compat.c \
   math/_huge.c \
+  misc/__initenv.c \
   stdio/ucrt_fprintf.c \
   stdio/ucrt_fscanf.c \
   stdio/ucrt_fwprintf.c \
@@ -421,6 +422,7 @@ src_msvcr80_64=\
 src_crtdll=\
   crt/crtdll_compat.c \
   misc/___mb_cur_max_func.c \
+  misc/__initenv.c \
   misc/__p___argv.c \
   misc/__p__acmdln.c \
   misc/__p__commode.c \
diff --git a/mingw-w64-crt/crt/crtdll_compat.c 
b/mingw-w64-crt/crt/crtdll_compat.c
index 9bb48bd84095..35686658c3ff 100644
--- a/mingw-w64-crt/crt/crtdll_compat.c
+++ b/mingw-w64-crt/crt/crtdll_compat.c
@@ -7,12 +7,6 @@
 #include <internal.h>
 #include <math.h>
 
-/* Define __initenv and __winitenv as crtdll.dll does not provide them */
-static char ** local__initenv;
-static wchar_t ** local__winitenv;
-char *** __MINGW_IMP_SYMBOL(__initenv) = &local__initenv;
-wchar_t *** __MINGW_IMP_SYMBOL(__winitenv) = &local__winitenv;
-
 /* Define dummy __setusermatherr() function as crtdll.dll does not provide it 
*/
 #undef __setusermatherr
 void __setusermatherr(__UNUSED_PARAM(int (__cdecl *f)(struct _exception *))) { 
}
diff --git a/mingw-w64-crt/crt/ucrtbase_compat.c 
b/mingw-w64-crt/crt/ucrtbase_compat.c
index d01293abf615..02910ff2f4d8 100644
--- a/mingw-w64-crt/crt/ucrtbase_compat.c
+++ b/mingw-w64-crt/crt/ucrtbase_compat.c
@@ -111,11 +111,6 @@ unsigned int __cdecl _get_output_format(void)
   return 0;
 }
 
-static char ** local__initenv;
-static wchar_t ** local__winitenv;
-char *** __MINGW_IMP_SYMBOL(__initenv) = &local__initenv;
-wchar_t *** __MINGW_IMP_SYMBOL(__winitenv) = &local__winitenv;
-
 
 // These are required to provide the unrepfixed data symbols "timezone"
 // and "tzname"; we can't remap "timezone" via a define due to clashes
diff --git a/mingw-w64-crt/misc/__initenv.c b/mingw-w64-crt/misc/__initenv.c
new file mode 100644
index 000000000000..31fd87525bfe
--- /dev/null
+++ b/mingw-w64-crt/misc/__initenv.c
@@ -0,0 +1,12 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <internal.h>
+
+static char ** local__initenv;
+static wchar_t ** local__winitenv;
+char *** __MINGW_IMP_SYMBOL(__initenv) = &local__initenv;
+wchar_t *** __MINGW_IMP_SYMBOL(__winitenv) = &local__winitenv;
-- 
2.20.1



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

Reply via email to