1 #ifndef MACROS_H
2 #define MACROS_H
3 
4 #ifndef MIN // Windows or muslc likes to be broken
5 #define MIN(a,b) (((a)<(b))?(a):(b))
6 #else
7 #include <sys/param.h> // Provides MAX/MIN
8 #endif
9 
10 #ifndef MAX // Windows or muslc likes to be broken
11 #define MAX(a,b) (((a)>(b))?(a):(b))
12 #else
13 #include <sys/param.h> // Provides MAX/MIN
14 #endif
15 
16 // True if x and y are within the supplied rectangle
17 #define inrect(x, y, rx, ry, width, height) \
18     ((x) >= (rx) && (y) >= (ry) && (x) < ((rx) + (width)) && (y) < ((ry) + (height)))
19 
20 // This is hacky and almost never better, try to use an alternative.
21 #define strcpy2(x, y) (memcpy(x, y, sizeof(y) - 1))
22 
23 // Is the video stream just a selection of the desktop
24 #define isdesktop(x) ((size_t)(x) == 1)
25 
26 #define COUNTOF(x) (sizeof(x) / sizeof(*(x)))
27 
28 
29 // Wrap var in UNUSED(var) to correctly suppress warnings
30 #ifdef UNUSED
31 #undef UNUSED
32 #endif
33 #ifdef __GNUC__
34 #define UNUSED(x) UNUSED_##x __attribute__((__unused__))
35 #elif defined(__LCLINT__)
36 #define UNUSED(x) /*@unused@*/ x
37 #else
38 #define UNUSED(x) x
39 #endif
40 
41 #endif
42