https://git.reactos.org/?p=reactos.git;a=commitdiff;h=950e81437776242be39fe…
commit 950e81437776242be39fef4a8b0d0a17cf5882b7
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Jul 24 16:27:43 2021 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Wed Aug 4 02:03:07 2021 +0200
[CRT] Fix _fmode
Remove mingw-w64 version of _fmode. _fmode should not be linked directly into the executable. Instead, the export from msvcrt should be used. On Windows 10 it's defined to *__p__fmode(), which is exported from ucrtbase.dll
Also _fmode in msvcrt.dll is initialized with 0.
---
sdk/lib/crt/msvcrtex.cmake | 1 -
sdk/lib/crt/startup/startup.cmake | 1 -
sdk/lib/crt/startup/txtmode.c | 13 -------------
sdk/lib/crt/stdio/fmode.c | 2 +-
4 files changed, 1 insertion(+), 16 deletions(-)
diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake
index 32d1afc6046..5f9cad1b48f 100644
--- a/sdk/lib/crt/msvcrtex.cmake
+++ b/sdk/lib/crt/msvcrtex.cmake
@@ -15,7 +15,6 @@ list(APPEND MSVCRTEX_SOURCE
startup/charmax.c
startup/atonexit.c
startup/dllmain.c
- startup/txtmode.c
startup/pesect.c
startup/tlsmcrt.c
startup/tlsthrd.c
diff --git a/sdk/lib/crt/startup/startup.cmake b/sdk/lib/crt/startup/startup.cmake
index 1574d29e97b..37577e0e70d 100644
--- a/sdk/lib/crt/startup/startup.cmake
+++ b/sdk/lib/crt/startup/startup.cmake
@@ -12,7 +12,6 @@ list(APPEND CRT_STARTUP_SOURCE
startup/natstart.c
startup/charmax.c
startup/atonexit.c
- #startup/txtmode.c
startup/pesect.c
startup/tlsmcrt.c
startup/tlsthrd.c
diff --git a/sdk/lib/crt/startup/txtmode.c b/sdk/lib/crt/startup/txtmode.c
deleted file mode 100644
index 1f50d168b89..00000000000
--- a/sdk/lib/crt/startup/txtmode.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
- */
-
-#include <fcntl.h>
-
-/* Set default file mode to text */
-
-/* Is this correct? Default value of _fmode in msvcrt.dll is 0. */
-
-int _fmode = _O_TEXT;
diff --git a/sdk/lib/crt/stdio/fmode.c b/sdk/lib/crt/stdio/fmode.c
index 0469904c3e6..220a92d32c9 100644
--- a/sdk/lib/crt/stdio/fmode.c
+++ b/sdk/lib/crt/stdio/fmode.c
@@ -1,7 +1,7 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <precomp.h>
-int _fmode = _O_TEXT;
+int _fmode = 0;
/*
* @implemented
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0f3d052af9b0d6d8bcb5d…
commit 0f3d052af9b0d6d8bcb5d79c371cdaec99548890
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Sat Jul 24 16:27:20 2021 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Wed Aug 4 02:03:07 2021 +0200
[CRT] Remove _fmode and _commode initialization
This "initialization" copies the value of the local variable to the one exported from msvcrt, which is the same. Also there shouldn't be a local version of the variable in the first place.
---
sdk/lib/crt/startup/crtexe.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/sdk/lib/crt/startup/crtexe.c b/sdk/lib/crt/startup/crtexe.c
index 4e6f1e4d1f6..ea9b13aaf22 100644
--- a/sdk/lib/crt/startup/crtexe.c
+++ b/sdk/lib/crt/startup/crtexe.c
@@ -52,13 +52,6 @@ extern void __cdecl _fpreset (void);
#define SPACECHAR _T(' ')
#define DQUOTECHAR _T('\"')
-extern int * __MINGW_IMP_SYMBOL(_fmode);
-extern int * __MINGW_IMP_SYMBOL(_commode);
-
-#undef _fmode
-extern int _fmode;
-extern int * __MINGW_IMP_SYMBOL(_commode);
-#define _commode (* __MINGW_IMP_SYMBOL(_commode))
extern int _dowildcard;
extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
@@ -129,9 +122,6 @@ pre_c_init (void)
__set_app_type (_CONSOLE_APP);
__onexitbegin = __onexitend = (_PVFV *)(-1);
- * __MINGW_IMP_SYMBOL(_fmode) = _fmode;
- * __MINGW_IMP_SYMBOL(_commode) = _commode;
-
#ifdef WPRFLAG
_wsetargv();
#else