|
|
|
|
|
|
|
|
#undef abs |
|
|
#undef abs |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#define min(a,b) ((a)<(b)?(a):(b)) |
|
|
|
|
|
#define max(a,b) ((a)>(b)?(a):(b)) |
|
|
|
|
|
#define abs(x) ((x)>0?(x):-(x)) |
|
|
|
|
|
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
|
|
|
|
|
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) |
|
|
|
|
|
|
|
|
#define min(a, b) ({ \ |
|
|
|
|
|
typeof(a) _a = (a); \ |
|
|
|
|
|
typeof(b) _b = (b); \ |
|
|
|
|
|
(_a < _b) ? _a : _b; \ |
|
|
|
|
|
}) |
|
|
|
|
|
#define max(a, b) ({ \ |
|
|
|
|
|
typeof(a) _a = (a); \ |
|
|
|
|
|
typeof(b) _b = (b); \ |
|
|
|
|
|
(_a > _b) ? _a : _b; \ |
|
|
|
|
|
}) |
|
|
|
|
|
#define abs(x) ({ \ |
|
|
|
|
|
typeof(x) _x = (x); \ |
|
|
|
|
|
(_x > 0) ? _x : -_x; \ |
|
|
|
|
|
}) |
|
|
|
|
|
#define constrain(amt, low, high) ({ \ |
|
|
|
|
|
typeof(amt) _amt = (amt); \ |
|
|
|
|
|
typeof(low) _low = (low); \ |
|
|
|
|
|
typeof(high) _high = (high); \ |
|
|
|
|
|
(_amt < _low) ? _low : ((_amt > _high) ? _high : _amt); \ |
|
|
|
|
|
}) |
|
|
|
|
|
#define round(x) ({ \ |
|
|
|
|
|
typeof(x) _x = (x); \ |
|
|
|
|
|
(_x>=0) ? (long)(_x+0.5) : (long)(_x-0.5); \ |
|
|
|
|
|
}) |
|
|
#define radians(deg) ((deg)*DEG_TO_RAD) |
|
|
#define radians(deg) ((deg)*DEG_TO_RAD) |
|
|
#define degrees(rad) ((rad)*RAD_TO_DEG) |
|
|
#define degrees(rad) ((rad)*RAD_TO_DEG) |
|
|
#define sq(x) ((x)*(x)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define sq(x) ({ \ |
|
|
|
|
|
typeof(x) _x = (x); \ |
|
|
|
|
|
_x * _x; \ |
|
|
|
|
|
}) |
|
|
#define sei() __enable_irq() |
|
|
#define sei() __enable_irq() |
|
|
#define cli() __disable_irq() |
|
|
#define cli() __disable_irq() |
|
|
#define interrupts() __enable_irq() |
|
|
#define interrupts() __enable_irq() |