Andrew Jeffery | 4622cad | 2020-11-03 22:20:18 +1030 | [diff] [blame] | 1 | #ifndef _RANGE_H |
2 | #define _RANGE_H | ||||
3 | |||||
Younghyun Park | 99d8f12 | 2022-07-01 20:09:39 +0000 | [diff] [blame] | 4 | #ifndef typeof |
5 | #define typeof __typeof__ | ||||
6 | #endif | ||||
7 | |||||
Moritz Fischer | af0cd62 | 2022-06-28 19:00:18 -0700 | [diff] [blame] | 8 | #ifndef MIN |
Andrew Jeffery | 4622cad | 2020-11-03 22:20:18 +1030 | [diff] [blame] | 9 | #define MIN(a, b) \ |
10 | ({ \ | ||||
11 | typeof(a) _a = a; \ | ||||
12 | typeof(b) _b = b; \ | ||||
13 | _a < _b ? _a : _b; \ | ||||
14 | }) | ||||
Moritz Fischer | af0cd62 | 2022-06-28 19:00:18 -0700 | [diff] [blame] | 15 | #endif |
Andrew Jeffery | 4622cad | 2020-11-03 22:20:18 +1030 | [diff] [blame] | 16 | |
Moritz Fischer | af0cd62 | 2022-06-28 19:00:18 -0700 | [diff] [blame] | 17 | #ifndef MAX |
Andrew Jeffery | 4622cad | 2020-11-03 22:20:18 +1030 | [diff] [blame] | 18 | #define MAX(a, b) \ |
19 | ({ \ | ||||
20 | typeof(a) _a = a; \ | ||||
21 | typeof(b) _b = b; \ | ||||
22 | _a > _b ? _a : _b; \ | ||||
23 | }) | ||||
Moritz Fischer | af0cd62 | 2022-06-28 19:00:18 -0700 | [diff] [blame] | 24 | #endif |
Andrew Jeffery | 4622cad | 2020-11-03 22:20:18 +1030 | [diff] [blame] | 25 | |
26 | #endif |