V2: Use a single definition of MIN and MAX in sources
[platform/upstream/flac.git] / src / libFLAC / include / private / macros.h
1 #ifndef FLAC__PRIVATE__MACROS_H
2 #define FLAC__PRIVATE__MACROS_H
3
4 #if defined(__GNUC__)
5
6 #define flac_max(a,b) \
7     ({ __typeof__ (a) _a = (a); \
8     __typeof__ (b) _b = (b); \
9     _a > _b ? _a : _b; })
10
11 #define flac_min(a,b) \
12     ({ __typeof__ (a) _a = (a); \
13     __typeof__ (b) _b = (b); \
14     _a < _b ? _a : _b; })
15
16 /* Whatever other unix that has sys/param.h */
17 #elif defined(HAVE_SYS_PARAM_H)
18 #include <sys/param.h>
19 #define flac_max(a,b) MAX(a,b)
20 #define flac_min(a,b) MIN(a,b)
21
22 /* Windows VS has them in stdlib.h.. XXX:Untested */
23 #elif defined(_MSC_VER)
24 #include <stdlib.h>
25 #define flac_max(a,b) __max(a,b)
26 #define flac_min(a,b) __min(a,b)
27 #endif
28
29 #endif