Skip to content

Commit da47062

Browse files
committed
Fix regressions: build with VS2005 / older SDKs
dispserv_win32.c: provide QDC_DATABASE_CURRENT fallback for SDKs predating the Win7 CCD APIs. The runtime symbols are loaded via GetProcAddress when HAVE_DYLIB is set, so only the constant is missing. vfs_implementation.c: in retro_vfs_stat_impl LEGACY_WIN32 branch, call _stat64 explicitly instead of the bare _stat macro. The macro expands to _stat64i32 on VS2005+, mismatching the declared 'struct _stat64' buffer and silently truncating st_size for files >= 2 GiB. Falls back to _stati64 on VC6.
1 parent 8a2d293 commit da47062

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

gfx/display_servers/dispserv_win32.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
#define _WIN32_WINDOWS 0x0601
3030
#endif
3131

32+
/* QueryDisplayConfig and friends are Windows 7+. The SDK shipped
33+
* with VS2005 (and some older mingw-w64 versions) does not declare
34+
* QDC_DATABASE_CURRENT, even though the runtime symbols are loaded
35+
* via GetProcAddress when HAVE_DYLIB is set. Provide a fallback so
36+
* the code compiles on those toolchains; on a modern SDK this is a
37+
* no-op since the symbol is already defined in wingdi.h. */
38+
#ifndef QDC_DATABASE_CURRENT
39+
#define QDC_DATABASE_CURRENT 0x00000004
40+
#endif
41+
3242
/* VC6 needs objbase included before initguid, but nothing else does */
3343
#include <objbase.h>
3444
#include <initguid.h>

libretro-common/vfs/vfs_implementation.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,8 +1136,20 @@ int retro_vfs_stat_64_impl(const char *path, int64_t *size)
11361136

11371137
file_info = GetFileAttributes(path_local);
11381138

1139+
/* Use _stat64 explicitly to match the struct _stat64 buffer
1140+
* declared above. The bare _stat is a macro that expands to
1141+
* _stat64i32 on VS2005+ (or _stat32 with _USE_32BIT_TIME_T),
1142+
* neither of which match struct _stat64 -- passing the wrong
1143+
* struct silently truncates st_size. _stat64 has been in MSVC
1144+
* since VS2003 (_MSC_VER >= 1300) and is provided by mingw-w64.
1145+
* VC6 has no 64-bit time_t at all; _stati64 is the only match. */
1146+
#if defined(_MSC_VER) && _MSC_VER < 1300
11391147
if (file_info == INVALID_FILE_ATTRIBUTES
1140-
|| _stat(path_local, &stat_buf) != 0)
1148+
|| _stati64(path_local, (struct _stati64*)&stat_buf) != 0)
1149+
#else
1150+
if (file_info == INVALID_FILE_ATTRIBUTES
1151+
|| _stat64(path_local, &stat_buf) != 0)
1152+
#endif
11411153
{
11421154
free(path_local);
11431155
return 0;

0 commit comments

Comments
 (0)