PER Firmware
Loading...
Searching...
No Matches
abs.h
Go to the documentation of this file.
1#ifndef ABS_H
2#define ABS_H
3
14[[gnu::always_inline]]
15static inline signed int abs_i(int x) {
16 return (x < 0) ? -x : x;
17}
18
19[[gnu::always_inline]]
20static inline float abs_f(float x) {
21 return (x < 0.0f) ? -x : x;
22}
23
24#define ABS(x) _Generic((x) + 0, \
25 int: abs_i, \
26 float: abs_f \
27)((x))
28
29#endif // ABS_H