File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,18 @@ assert can have unique static variables associated with it.
69
69
#define SDL_TriggerBreakpoint ()
70
70
#endif
71
71
72
+ #if defined(_MSC_VER )
73
+ #define SDL_Assume (cond ) __assume(cond)
74
+ #elif _SDL_HAS_BUILTIN (__builtin_assume )
75
+ #define SDL_Assume (cond ) __builtin_assume(cond)
76
+ #elif defined(__GNUC__ )
77
+ #define SDL_Assume (cond ) do { \
78
+ (__builtin_expect(!(cond), 0) ? __builtin_unreachable() : (void)0); \
79
+ } while (0)
80
+ #else
81
+ #define SDL_Assume (cond )
82
+ #endif
83
+
72
84
#if defined(__STDC_VERSION__ ) && (__STDC_VERSION__ >= 199901L ) /* C99 supports __func__ as a standard. */
73
85
# define SDL_FUNCTION __func__
74
86
#elif ((defined(__GNUC__ ) && (__GNUC__ >= 2 )) || defined(_MSC_VER ) || defined (__WATCOMC__ ))
Original file line number Diff line number Diff line change 11
11
*/
12
12
13
13
#include <stdio.h>
14
+ #include <time.h>
14
15
15
16
#include "SDL.h"
16
17
@@ -442,6 +443,19 @@ TestAssertions(SDL_bool verbose)
442
443
return (0 );
443
444
}
444
445
446
+ int
447
+ TestAssume (SDL_bool verbose )
448
+ {
449
+ int max , count , i ;
450
+
451
+ max = 16 ;
452
+ srand (time (0 ));
453
+ count = rand () % max ;
454
+ SDL_Assume (count <= max );
455
+ for (i = 0 ; i < count ; i ++ );
456
+ return (0 );
457
+ }
458
+
445
459
int
446
460
main (int argc , char * argv [])
447
461
{
@@ -463,6 +477,7 @@ main(int argc, char *argv[])
463
477
status += Test64Bit (verbose );
464
478
status += TestCPUInfo (verbose );
465
479
status += TestAssertions (verbose );
480
+ status += TestAssume (verbose );
466
481
467
482
return status ;
468
483
}
You can’t perform that action at this time.
0 commit comments