mirror of https://github.com/libsdl-org/SDL
Merge cdbcd73bb9
into 1f727b61f3
This commit is contained in:
commit
369945599a
|
@ -151,6 +151,18 @@ extern "C" {
|
||||||
#define SDL_TriggerBreakpoint()
|
#define SDL_TriggerBreakpoint()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER > 1400)
|
||||||
|
#define SDL_Assume(cond) __assume(cond)
|
||||||
|
#elif SDL_HAS_BUILTIN(__builtin_assume)
|
||||||
|
#define SDL_Assume(cond) __builtin_assume(cond)
|
||||||
|
#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
|
||||||
|
#define SDL_Assume(cond) do { \
|
||||||
|
(__builtin_expect(!(cond), 0) ? __builtin_unreachable() : (void)0); \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define SDL_Assume(cond)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
|
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
|
||||||
# define SDL_FUNCTION __func__
|
# define SDL_FUNCTION __func__
|
||||||
#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
|
#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
|
||||||
|
|
|
@ -444,7 +444,20 @@ static int TestAssertions(bool verbose)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
TestAssume(SDL_bool verbose)
|
||||||
|
{
|
||||||
|
int max, count, i;
|
||||||
|
|
||||||
|
max = 16;
|
||||||
|
count = SDLTest_RandomIntegerInRange(0, max);
|
||||||
|
SDL_Assume(count <= max);
|
||||||
|
for (i = 0; i < count; i ++);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool verbose = true;
|
bool verbose = true;
|
||||||
|
@ -486,6 +499,7 @@ int main(int argc, char *argv[])
|
||||||
status += Test64Bit(verbose);
|
status += Test64Bit(verbose);
|
||||||
status += TestCPUInfo(verbose);
|
status += TestCPUInfo(verbose);
|
||||||
status += TestAssertions(verbose);
|
status += TestAssertions(verbose);
|
||||||
|
status += TestAssume(verbose);
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
SDLTest_CommonDestroyState(state);
|
SDLTest_CommonDestroyState(state);
|
||||||
|
|
Loading…
Reference in New Issue