Skip to content

Commit 5d1e9cd

Browse files
Merge pull request #5925 from maron2000/fix_msys2crash
Fix crash on launch in MinGW and UCRT 64-bit builds
2 parents b474767 + 18daeb8 commit 5d1e9cd

File tree

19 files changed

+210
-142
lines changed

19 files changed

+210
-142
lines changed

include/cross.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ static inline float powf (float x, float y) { return (float) pow (x,y); }
6666

6767
class Cross {
6868
public:
69-
static void GetPlatformResDir(std::string& in);
70-
static void GetPlatformConfigDir(std::string& in);
71-
static void GetPlatformConfigName(std::string& in);
72-
static void CreatePlatformConfigDir(std::string& in);
69+
static std::string GetPlatformResDir(void);
70+
static std::string GetPlatformConfigDir(void);
71+
static std::string GetPlatformConfigName(void);
72+
static std::string CreatePlatformConfigDir(void);
7373
static void ResolveHomedir(std::string & temp_line);
7474
static void CreateDir(std::string const& in);
7575
static bool IsPathAbsolute(std::string const& in);
@@ -129,4 +129,6 @@ bool read_directory_next(dir_information* dirp, char* entry_name, char* entry_sn
129129
void close_directory(dir_information* dirp);
130130

131131
FILE* fopen_wrap(const char* path, const char* mode);
132+
133+
const char* get_time(void);
132134
#endif

include/version_string.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@
3131
#define OS_PLATFORM_LONG "Visual Studio ARM"
3232
#endif
3333
#elif defined(__MINGW32__)
34+
#ifdef _UCRT
35+
#define OS_PLATFORM "UCRT"
36+
#define OS_PLATFORM_LONG "UCRT"
37+
#else
3438
#define OS_PLATFORM "MinGW"
3539
#define OS_PLATFORM_LONG "MinGW"
40+
#endif
3641
#else
3742
#define OS_PLATFORM "Windows"
3843
#define OS_PLATFORM_LONG "Windows"

src/dos/cdrom_image.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define IS_BIGENDIAN false
4343
#endif
4444

45+
#include "cross.h"
4546
#include "drives.h"
4647
#include "logging.h"
4748
#include "support.h"

src/dos/drive_local.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,14 +1173,14 @@ void getdrivezpath(std::string &path, std::string const& dirname) {
11731173
}
11741174
if (!path.size() || !ret) {
11751175
path = "";
1176-
Cross::GetPlatformConfigDir(path);
1176+
path = Cross::GetPlatformConfigDir();
11771177
path += dirname;
11781178
host_name = CodePageGuestToHost(path.c_str());
11791179
res=host_name == NULL?stat(path.c_str(),&cstat):ht_stat(host_name,&hstat);
11801180
ret=res==-1?false:((host_name == NULL?cstat.st_mode:hstat.st_mode) & S_IFDIR);
11811181
if (!ret) {
11821182
path = "";
1183-
Cross::GetPlatformResDir(path);
1183+
path = Cross::GetPlatformResDir();
11841184
path += dirname;
11851185
host_name = CodePageGuestToHost(path.c_str());
11861186
res=host_name == NULL?stat(path.c_str(),&cstat):ht_stat(host_name,&hstat);

src/dosbox.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,13 +956,13 @@ void Init_VGABIOS() {
956956
}
957957
if (rom_fp == NULL) {
958958
path = "";
959-
Cross::GetPlatformResDir(path);
959+
path = Cross::GetPlatformResDir();
960960
path += VGA_BIOS_rom;
961961
rom_fp = fopen(path.c_str(),"rb");
962962
}
963963
if (rom_fp == NULL) {
964964
path = "";
965-
Cross::GetPlatformConfigDir(path);
965+
path = Cross::GetPlatformConfigDir();
966966
path += VGA_BIOS_rom;
967967
rom_fp = fopen(path.c_str(),"rb");
968968
}

src/gui/menu_callback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ void Load_language_file() {
18581858
struct stat st;
18591859
std::string res_path, exepath = GetDOSBoxXPath();
18601860
std::string cwd = std::string(Temp_CurrentDir)+CROSS_FILESPLIT+"languages"+CROSS_FILESPLIT;
1861-
Cross::GetPlatformResDir(res_path);
1861+
res_path = Cross::GetPlatformResDir();
18621862
if (stat(cwd.c_str(),&st) != 0 && exepath.size())
18631863
cwd = exepath+(exepath.back()==CROSS_FILESPLIT?"":std::string(1, CROSS_FILESPLIT))+"languages"+CROSS_FILESPLIT;
18641864
if (stat(cwd.c_str(),&st) != 0 && res_path.size())

src/gui/midi_mt32.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ class MidiHandler_mt32 : public MidiHandler {
257257
}
258258

259259
if (!load_rom_set(romDir, model)) {
260-
Cross::GetPlatformResDir(romDir);
260+
romDir = Cross::GetPlatformResDir();
261261
if (!load_rom_set(romDir, model)) {
262-
Cross::GetPlatformConfigDir(romDir);
262+
romDir = Cross::GetPlatformConfigDir();
263263
if (!load_rom_set(romDir, model)) {
264264
delete service;
265265
service = NULL;

src/gui/render.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,9 +1319,9 @@ std::string LoadGLShader(Section_prop * section) {
13191319
path = "";
13201320
}
13211321
if (path.size() && !RENDER_GetShader(path,(char *)shader_src.c_str())) {
1322-
Cross::GetPlatformConfigDir(path);
1322+
path = Cross::GetPlatformConfigDir();
13231323
pathcfg = path + "glshaders" + CROSS_FILESPLIT + f;
1324-
Cross::GetPlatformResDir(path);
1324+
path = Cross::GetPlatformResDir();
13251325
pathres = path + "glshaders" + CROSS_FILESPLIT + f;
13261326
if (!RENDER_GetShader(pathcfg,(char *)shader_src.c_str()) && !RENDER_GetShader(pathres,(char *)shader_src.c_str()) && (sh->realpath==f || !RENDER_GetShader(f,(char *)shader_src.c_str()))) {
13271327
sh->SetValue("none");

src/gui/sdl_gui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,9 +2001,9 @@ class SaveDialog : public GUI::ToplevelWindow {
20012001
}
20022002
if (arg == MSG_Get("USE_USERCONFIG")) {
20032003
std::string config_path;
2004-
Cross::GetPlatformConfigDir(config_path);
2004+
config_path = Cross::GetPlatformConfigDir();
20052005
std::string fullpath,file;
2006-
Cross::GetPlatformConfigName(file);
2006+
file = Cross::GetPlatformConfigName();
20072007
const size_t last_slash_idx = config_path.find_last_of("\\/");
20082008
if (std::string::npos != last_slash_idx) {
20092009
fullpath = config_path.substr(0, last_slash_idx);

src/gui/sdl_mapper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5718,7 +5718,8 @@ void ReloadMapper(Section_prop *section, bool init) {
57185718
}
57195719
if (!loadfile) {
57205720
std::string exepath=GetDOSBoxXPath(), config_path, res_path;
5721-
Cross::GetPlatformConfigDir(config_path), Cross::GetPlatformResDir(res_path);
5721+
config_path = Cross::GetPlatformConfigDir();
5722+
res_path = Cross::GetPlatformResDir();
57225723
if (mapper.filename.size() && exepath.size()) {
57235724
loadfile=fopen((exepath+mapper.filename).c_str(),"rt");
57245725
if (!loadfile) {

0 commit comments

Comments
 (0)