Tor 0.4.9.8
Loading...
Searching...
No Matches
cmp.h File Reference

Macro definitions for MIN, MAX, and CLAMP. More...

Go to the source code of this file.

Macros

#define MAX(a, b)
 
#define MIN(a, b)
 
#define CLAMP(min, v, max)
 
#define ABS(x)
 

Detailed Description

Macro definitions for MIN, MAX, and CLAMP.

Definition in file cmp.h.

Macro Definition Documentation

◆ ABS

#define ABS ( x)
Value:
( ((x)<0) ? -(x) : (x) )

Give the absolute value of x, independent of its type.

Definition at line 40 of file cmp.h.

Referenced by update_current_time().

◆ CLAMP

#define CLAMP ( min,
v,
max )
Value:
( ((v) < (min)) ? (min) : \
((v) > (max)) ? (max) : \
(v) )

Definition at line 34 of file cmp.h.

◆ MAX

#define MAX ( a,
b )
Value:
( ((a)<(b)) ? (b) : (a) )

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.}

Definition at line 22 of file cmp.h.

◆ MIN

#define MIN ( a,
b )
Value:
( ((a)>(b)) ? (b) : (a) )

Definition at line 25 of file cmp.h.