Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions platform/Windows/src.Windows/arch/archdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,30 @@ void archdep_network_shutdown(void)
WSACleanup();
}

int archdep_init(int *argc, char **argv)
static BOOL CALLBACK archdep_init_stdio_once(PINIT_ONCE once, PVOID parameter, PVOID *context)
{
_fmode = O_BINARY;
(void)once;
(void)parameter;
(void)context;

_setmode(_fileno(stdin), O_BINARY);
_setmode(_fileno(stdout), O_BINARY);
return TRUE;
}

void archdep_init_stdio(void)
{
static INIT_ONCE once = INIT_ONCE_STATIC_INIT;

/* Repeating _setmode can block behind an active MCP stdin read. */
InitOnceExecuteOnce(&once, archdep_init_stdio_once, NULL, NULL);
}

int archdep_init(int *argc, char **argv)
{
_fmode = O_BINARY;

archdep_init_stdio();

argv0 = lib_stralloc(argv[0]);

Expand Down
1 change: 1 addition & 0 deletions platform/Windows/src.Windows/arch/archdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ extern void archdep_workaround_nop(const char *otto);

#define ARCHDEP_SOUND_OUTPUT_MODE SOUND_OUTPUT_SYSTEM

void archdep_init_stdio(void);
const char *archdep_home_path(void);

#endif
9 changes: 9 additions & 0 deletions src/RetroDebuggerAppInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
extern "C" void RD_HideDockIcon();
#endif

#ifdef WIN32
extern "C" void archdep_init_stdio(void);
#endif

#if MT_ENABLE_IMGUI_TEST_ENGINE
#include "CImGuiTestEngine.h"
#include "imgui_te_engine.h"
Expand Down Expand Up @@ -226,6 +230,11 @@ bool C64D_IsAutomatedRunCommandLine()

void MT_PreInit()
{
#ifdef WIN32
// Configure stdio before MCP can block reading stdin; VICE reuses this setup.
archdep_init_stdio();
#endif

if (C64D_IsAutomatedRunCommandLine())
// SDL3: SDL_setenv is gone. SDL_setenv_unsafe is the direct
// replacement and keeps the overwrite=0 semantics we rely on.
Expand Down
Loading