Loading...
Searching...
No Matches
utils.h File Reference

Various helper macros. More...

Detailed Description

Various helper macros.

Author
Marian Buschsieweke maria.nosp@m.n.bu.nosp@m.schsi.nosp@m.ewek.nosp@m.e@ovg.nosp@m.u.de

Definition in file utils.h.

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define CONCAT(a, b)   a ## b
 Concatenate the tokens a and b.
 
#define CONCAT3(a, b, c)   a ## b ## c
 Concatenate the tokens a , b , and c.
 
#define CONCAT4(a, b, c, d)   a ## b ## c ## d
 Concatenate the tokens a , b , c , and d.
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 Get the maximum of the two parameters.
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 Get the minimum of the two parameters.
 
#define ABS(x)   ((x) > 0 ? (x) : -(x))
 Returns the absolute value of x.
 
#define LIMIT(val, low, high)   ((val < low) ? low : (val > high) ? high : val)
 Limit a value to an inclusive range.
 

Macro Definition Documentation

◆ ABS

#define ABS (   x)    ((x) > 0 ? (x) : -(x))

Returns the absolute value of x.

Note
This is the trivial implementation that does evaluate the arguments more than once

Definition at line 73 of file utils.h.

◆ CONCAT

#define CONCAT (   a,
 
)    a ## b

Concatenate the tokens a and b.

Definition at line 29 of file utils.h.

◆ CONCAT3

#define CONCAT3 (   a,
  b,
 
)    a ## b ## c

Concatenate the tokens a , b , and c.

Definition at line 34 of file utils.h.

◆ CONCAT4

#define CONCAT4 (   a,
  b,
  c,
 
)    a ## b ## c ## d

Concatenate the tokens a , b , c , and d.

Definition at line 39 of file utils.h.

◆ LIMIT

#define LIMIT (   val,
  low,
  high 
)    ((val < low) ? low : (val > high) ? high : val)

Limit a value to an inclusive range.

If val is > high, high is returned. If val is < low, low is returned. Otherwise, val is returned.

Note
This macro evaluate its arguments more than once.
Parameters
[in]valvalue to limit
[in]lowminimum limit
[in]highmaximum limit
Returns
range limited value

Definition at line 90 of file utils.h.

◆ MAX

#define MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Get the maximum of the two parameters.

Note
This is the trivial implementation that does evaluate the arguments more than once

Definition at line 53 of file utils.h.

◆ MIN

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Get the minimum of the two parameters.

Note
This is the trivial implementation that does evaluate the arguments more than once

Definition at line 63 of file utils.h.