blob: 20349f242f9f00b9941e0dc3ae9d6b48dfa0402d [file] [log] [blame]
Andrew Jeffery4622cad2020-11-03 22:20:18 +10301#ifndef _RANGE_H
2#define _RANGE_H
3
Younghyun Park99d8f122022-07-01 20:09:39 +00004#ifndef typeof
5#define typeof __typeof__
6#endif
7
Moritz Fischeraf0cd622022-06-28 19:00:18 -07008#ifndef MIN
Andrew Jeffery4622cad2020-11-03 22:20:18 +10309#define MIN(a, b) \
10 ({ \
11 typeof(a) _a = a; \
12 typeof(b) _b = b; \
13 _a < _b ? _a : _b; \
14 })
Moritz Fischeraf0cd622022-06-28 19:00:18 -070015#endif
Andrew Jeffery4622cad2020-11-03 22:20:18 +103016
Moritz Fischeraf0cd622022-06-28 19:00:18 -070017#ifndef MAX
Andrew Jeffery4622cad2020-11-03 22:20:18 +103018#define MAX(a, b) \
19 ({ \
20 typeof(a) _a = a; \
21 typeof(b) _b = b; \
22 _a > _b ? _a : _b; \
23 })
Moritz Fischeraf0cd622022-06-28 19:00:18 -070024#endif
Andrew Jeffery4622cad2020-11-03 22:20:18 +103025
26#endif