diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-02-25 16:48:26 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-02-25 16:48:39 -0500 |
commit | f0b5f87eab1845cc54fadb50aa61ee497d4d8460 (patch) | |
tree | f75f96b875ca3d1eb44f52993bc2594afd09d34b /src/common/compat.h | |
parent | eb10d441b63c763c362dbb186b355747501e5424 (diff) | |
download | tor-f0b5f87eab1845cc54fadb50aa61ee497d4d8460.tar.gz tor-f0b5f87eab1845cc54fadb50aa61ee497d4d8460.zip |
Add the MIN and MAX macros for platforms that lack them
Diffstat (limited to 'src/common/compat.h')
-rw-r--r-- | src/common/compat.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/compat.h b/src/common/compat.h index 3b58bff8c4..14705d7d8d 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -553,6 +553,19 @@ void tor_cond_signal_all(tor_cond_t *cond); #endif #endif +/** Macros for MIN/MAX. Never use these when the arguments could have + * side-effects. + * {With GCC extensions we could probably define a safer MIN/MAX. But + * depending on that safety would be dangerous, since not every platform + * has it.} + **/ +#ifndef MAX +#define MAX(a,b) ( ((a)<(b)) ? (b) : (a) ) +#endif +#ifndef MIN +#define MIN(a,b) ( ((a)>(b)) ? (b) : (a) ) +#endif + /* Platform-specific helpers. */ #ifdef MS_WINDOWS char *format_win32_error(DWORD err); |