Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
ab19a27f
Unverified
Commit
ab19a27f
authored
5 years ago
by
espr14
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Prevent some macro pitfalls (#17956)
Co-authored-by:
espr14
<
espr14@users.noreply.github.com
>
parent
181739d0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Marlin/src/core/macros.h
+3
-5
3 additions, 5 deletions
Marlin/src/core/macros.h
with
3 additions
and
5 deletions
Marlin/src/core/macros.h
+
3
−
5
View file @
ab19a27f
...
@@ -102,7 +102,7 @@
...
@@ -102,7 +102,7 @@
#define SBI32(n,b) (n |= _BV32(b))
#define SBI32(n,b) (n |= _BV32(b))
#define CBI32(n,b) (n &= ~_BV32(b))
#define CBI32(n,b) (n &= ~_BV32(b))
#define cu(x) (
(
x)*(x)*(x))
#define cu(x) (
{__typeof__(x) _x = (x); (_
x)*(
_
x)*(
_
x)
;}
)
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
#define DEGREES(r) ((r)*180.0f/float(M_PI))
#define DEGREES(r) ((r)*180.0f/float(M_PI))
#define HYPOT2(x,y) (sq(x)+sq(y))
#define HYPOT2(x,y) (sq(x)+sq(y))
...
@@ -110,7 +110,7 @@
...
@@ -110,7 +110,7 @@
#define CIRCLE_AREA(R) (float(M_PI) * sq(float(R)))
#define CIRCLE_AREA(R) (float(M_PI) * sq(float(R)))
#define CIRCLE_CIRC(R) (2 * float(M_PI) * float(R))
#define CIRCLE_CIRC(R) (2 * float(M_PI) * float(R))
#define SIGN(a) (
(
a>0)-(a<0))
#define SIGN(a) (
{__typeof__(a) _a = (a); (_
a>0)-(
_
a<0)
;}
)
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
// Macros to constrain values
// Macros to constrain values
...
@@ -130,8 +130,6 @@
...
@@ -130,8 +130,6 @@
#else
#else
// Using GCC extensions, but Travis GCC version does not like it and gives
// "error: statement-expressions are not allowed outside functions nor in template-argument lists"
#define NOLESS(v, n) \
#define NOLESS(v, n) \
do{ \
do{ \
__typeof__(n) _n = (n); \
__typeof__(n) _n = (n); \
...
@@ -269,7 +267,7 @@
...
@@ -269,7 +267,7 @@
#define NEAR(x,y) NEAR_ZERO((x)-(y))
#define NEAR(x,y) NEAR_ZERO((x)-(y))
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x)))
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x)))
#define FIXFLOAT(f)
(
f + (f < 0 ? -0.00005f : 0.00005f))
#define FIXFLOAT(f)
({__typeof__(f) _f = (f); _
f + (
_
f < 0 ? -0.00005f : 0.00005f)
;}
)
//
//
// Maths macros that can be overridden by HAL
// Maths macros that can be overridden by HAL
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment