mirror of
https://github.com/troglobit/libite.git
synced 2026-10-15 10:29:31 +00:00
lite.h: Add min() and max() macros
These macros take care to avoid double evaluation. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
e42aca8856
commit
61254279b9
1 file changed
+14
@@ -181,6 +181,20 @@ static inline int string_case_compare (const char *a, const char *b)
|
||||
return strlen (a) == strlen (b) && !strcasecmp (a, b);
|
||||
}
|
||||
|
||||
#define min(a,b) \
|
||||
({ \
|
||||
__typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a < _b ? _a : _b; \
|
||||
})
|
||||
|
||||
#define max(a,b) \
|
||||
({ \
|
||||
__typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a > _b ? _a : _b; \
|
||||
})
|
||||
|
||||
/* Compat */
|
||||
#define copy_filep(src,dst) fcopyfile(src,dst)
|
||||
#define pidfile_read_pid(file) pifile_read(file)
|
||||
|
||||
Reference in new issue
Block a user