Add malloc predictor (PR middle-end/83023).
[official-gcc.git] / gcc / testsuite / gcc.dg / range.h
blob0b4d9e80befefec5ef3bab066add4640d3e28be0
1 #ifndef RANGE_H
3 /* Definitions of helper functions and macros to create expressions
4 in a specified range. Not all the symbols declared here are
5 defined. */
7 #define SIZE_MAX __SIZE_MAX__
8 #define DIFF_MAX __PTRDIFF_MAX__
9 #define DIFF_MIN (-DIFF_MAX - 1)
11 typedef __INT32_TYPE__ int32_t;
12 typedef __PTRDIFF_TYPE__ ptrdiff_t;
13 typedef __SIZE_TYPE__ size_t;
15 static inline ptrdiff_t signed_value (void)
17 extern volatile ptrdiff_t signed_value_source;
18 return signed_value_source;
21 static inline size_t unsigned_value (void)
23 extern volatile size_t unsigned_value_source;
24 return unsigned_value_source;
27 static inline ptrdiff_t signed_range (ptrdiff_t min, ptrdiff_t max)
29 ptrdiff_t val = signed_value ();
30 return val < min || max < val ? min : val;
33 static inline ptrdiff_t signed_anti_range (ptrdiff_t min, ptrdiff_t max)
35 ptrdiff_t val = signed_value ();
36 return min <= val && val <= max ? min == DIFF_MIN ? max + 1 : min - 1 : val;
39 static inline size_t unsigned_range (size_t min, size_t max)
41 size_t val = unsigned_value ();
42 return val < min || max < val ? min : val;
45 static inline size_t unsigned_anti_range (size_t min, size_t max)
47 size_t val = unsigned_value ();
48 return min <= val && val <= max ? min == 0 ? max + 1 : min - 1 : val;
51 #define SR(min, max) signed_range ((min), (max))
52 #define UR(min, max) unsigned_range ((min), (max))
54 #define SAR(min, max) signed_anti_range ((min), (max))
55 #define UAR(min, max) unsigned_anti_range ((min), (max))
57 #endif /* RANGE_H */