windows: OS version checks now cache results.
So these only have to talk to the Win32 API once per check, per process.
This commit is contained in:
parent
4fba663368
commit
56fa22c63b
1 changed files with 20 additions and 15 deletions
|
@ -197,33 +197,38 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// apply some static variables so we only call into the Win32 API once per process for each check.
|
||||||
|
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||||
|
#define CHECKWINVER(notdesktop_platform_result, test) return (notdesktop_platform_result);
|
||||||
|
#else
|
||||||
|
#define CHECKWINVER(notdesktop_platform_result, test) \
|
||||||
|
static SDL_bool checked = SDL_FALSE; \
|
||||||
|
static BOOL retval = FALSE; \
|
||||||
|
if (!checked) { \
|
||||||
|
retval = (test); \
|
||||||
|
checked = SDL_TRUE; \
|
||||||
|
} \
|
||||||
|
return retval;
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOL WIN_IsWindowsVistaOrGreater(void)
|
BOOL WIN_IsWindowsVistaOrGreater(void)
|
||||||
{
|
{
|
||||||
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
CHECKWINVER(TRUE, IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0));
|
||||||
return TRUE;
|
|
||||||
#else
|
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WIN_IsWindows7OrGreater(void)
|
BOOL WIN_IsWindows7OrGreater(void)
|
||||||
{
|
{
|
||||||
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
CHECKWINVER(TRUE, IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0));
|
||||||
return TRUE;
|
|
||||||
#else
|
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WIN_IsWindows8OrGreater(void)
|
BOOL WIN_IsWindows8OrGreater(void)
|
||||||
{
|
{
|
||||||
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
CHECKWINVER(TRUE, IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0));
|
||||||
return TRUE;
|
|
||||||
#else
|
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef CHECKWINVER
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
WAVExxxCAPS gives you 31 bytes for the device name, and just truncates if it's
|
WAVExxxCAPS gives you 31 bytes for the device name, and just truncates if it's
|
||||||
longer. However, since WinXP, you can use the WAVExxxCAPS2 structure, which
|
longer. However, since WinXP, you can use the WAVExxxCAPS2 structure, which
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue