PER Firmware
Loading...
Searching...
No Matches
max.h File Reference

Maximum value functions utility header. More...

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

Go to the source code of this file.

Macros

#define MAXOF2(a, b)
 
#define MAXOF3(a, b, c)
 
#define MAXOF4(a, b, c, d)
 
#define DISPATCH_MAXOF(_1, _2, _3, _4, NAME, ...)
 
#define MAXOF(...)
 

Functions

static signed int max2_signed (signed int a, signed int b)
 
static unsigned int max2_unsigned (unsigned int a, unsigned int b)
 
static float max2_float (float a, float b)
 

Detailed Description

Maximum value functions utility header.

Typesafe, supporting ints and floats. Generic MAXOF interface for 2, 3, or 4 arguments. Integer promotions also cover int8_t, uint8_t, int16_t, uint16_t

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ DISPATCH_MAXOF

#define DISPATCH_MAXOF ( _1,
_2,
_3,
_4,
NAME,
... )
Value:
NAME

◆ MAXOF

#define MAXOF ( ...)
Value:
DISPATCH_MAXOF(__VA_ARGS__, MAXOF4, MAXOF3, MAXOF2)(__VA_ARGS__)
#define MAXOF4(a, b, c, d)
Definition max.h:37
#define DISPATCH_MAXOF(_1, _2, _3, _4, NAME,...)
Definition max.h:41
#define MAXOF2(a, b)
Definition max.h:30
#define MAXOF3(a, b, c)
Definition max.h:36

◆ MAXOF2

#define MAXOF2 ( a,
b )
Value:
_Generic((a) + (b), \
signed int: max2_signed, \
unsigned int: max2_unsigned, \
float: max2_float \
)(a, b)
static signed int max2_signed(signed int a, signed int b)
Definition max.h:16
static unsigned int max2_unsigned(unsigned int a, unsigned int b)
Definition max.h:21
static float max2_float(float a, float b)
Definition max.h:26

◆ MAXOF3

#define MAXOF3 ( a,
b,
c )
Value:
MAXOF2(MAXOF2(a, b), c)

◆ MAXOF4

#define MAXOF4 ( a,
b,
c,
d )
Value:
MAXOF2(MAXOF2(a, b), MAXOF2(c, d))

Function Documentation

◆ max2_float()

static float max2_float ( float a,
float b )
inlinestatic

◆ max2_signed()

static signed int max2_signed ( signed int a,
signed int b )
inlinestatic

◆ max2_unsigned()

static unsigned int max2_unsigned ( unsigned int a,
unsigned int b )
inlinestatic