Move MIN, MAX, and CLAMP to macros.h
We shouldn't have to include the whole defs.h to get them. * defs.h (MIN, MAX, CLAMP): Move ... * macros.h: ... here.
This commit is contained in:
parent
f3d9348fd1
commit
bb9673ba1d
9
defs.h
9
defs.h
@ -75,15 +75,6 @@ const char *strerror(int);
|
||||
extern char *stpcpy(char *dst, const char *src);
|
||||
#endif
|
||||
|
||||
/* macros */
|
||||
#ifndef MAX
|
||||
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#define CLAMP(val, min, max) MIN(MAX(min, val), max)
|
||||
|
||||
/* Glibc has an efficient macro for sigemptyset
|
||||
* (it just does one or two assignments of 0 to internal vector of longs).
|
||||
*/
|
||||
|
8
macros.h
8
macros.h
@ -35,6 +35,14 @@
|
||||
#define STRINGIFY(...) #__VA_ARGS__
|
||||
#define STRINGIFY_VAL(...) STRINGIFY(__VA_ARGS__)
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#define CLAMP(val, min, max) MIN(MAX(min, val), max)
|
||||
|
||||
#ifndef offsetofend
|
||||
# define offsetofend(type_, member_) \
|
||||
(offsetof(type_, member_) + sizeof(((type_ *)0)->member_))
|
||||
|
Loading…
x
Reference in New Issue
Block a user