|
@@ -102,7 +102,7 @@
|
102
|
102
|
#define SBI32(n,b) (n |= _BV32(b))
|
103
|
103
|
#define CBI32(n,b) (n &= ~_BV32(b))
|
104
|
104
|
|
105
|
|
-#define cu(x) ((x)*(x)*(x))
|
|
105
|
+#define cu(x) ({__typeof__(x) _x = (x); (_x)*(_x)*(_x);})
|
106
|
106
|
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
|
107
|
107
|
#define DEGREES(r) ((r)*180.0f/float(M_PI))
|
108
|
108
|
#define HYPOT2(x,y) (sq(x)+sq(y))
|
|
@@ -110,7 +110,7 @@
|
110
|
110
|
#define CIRCLE_AREA(R) (float(M_PI) * sq(float(R)))
|
111
|
111
|
#define CIRCLE_CIRC(R) (2 * float(M_PI) * float(R))
|
112
|
112
|
|
113
|
|
-#define SIGN(a) ((a>0)-(a<0))
|
|
113
|
+#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
|
114
|
114
|
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
115
|
115
|
|
116
|
116
|
// Macros to constrain values
|
|
@@ -130,8 +130,6 @@
|
130
|
130
|
|
131
|
131
|
#else
|
132
|
132
|
|
133
|
|
- // Using GCC extensions, but Travis GCC version does not like it and gives
|
134
|
|
- // "error: statement-expressions are not allowed outside functions nor in template-argument lists"
|
135
|
133
|
#define NOLESS(v, n) \
|
136
|
134
|
do{ \
|
137
|
135
|
__typeof__(n) _n = (n); \
|
|
@@ -269,7 +267,7 @@
|
269
|
267
|
#define NEAR(x,y) NEAR_ZERO((x)-(y))
|
270
|
268
|
|
271
|
269
|
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x)))
|
272
|
|
-#define FIXFLOAT(f) (f + (f < 0 ? -0.00005f : 0.00005f))
|
|
270
|
+#define FIXFLOAT(f) ({__typeof__(f) _f = (f); _f + (_f < 0 ? -0.00005f : 0.00005f);})
|
273
|
271
|
|
274
|
272
|
//
|
275
|
273
|
// Maths macros that can be overridden by HAL
|