-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
py/misc: Add MP_ALIGNAS and MP_ALIGNOF macros. #18148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18148 +/- ##
=======================================
Coverage 98.38% 98.39%
=======================================
Files 171 171
Lines 22287 22276 -11
=======================================
- Hits 21928 21918 -10
+ Misses 359 358 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a9e2583 to
de20e35
Compare
|
Code size report: |
680b338 to
3a49b96
Compare
ad294a3 to
18384a2
Compare
Signed-off-by: Anson Mansfield <[email protected]>
The precise incantation required to declare a variable or type as having a particular alignment varies wildly between compilers and C standards. This adds a macro to abstract over these differences. Signed-off-by: Anson Mansfield <[email protected]>
Signed-off-by: Anson Mansfield <[email protected]>
18384a2 to
04bad3d
Compare
|
The added define logic here is quite complex (although well documented with comments!). In light of the related discussion in #18145, can things be simplified here? And since these macros aren't actually used anywhere (yet), is it really worth adding them? |
Probably at least a bit! If we're not aiming for And actually, one other reference it's only now occurred to me to check, the the implementation of An important difference between this and Maybe a reason this should actually not provide a base case? I wrote it with one originally as my original usage was just for a correctness-noncritical performance tweak, but perhaps it's still better to emit a warning/error.
Definitely an open question! There's a few other PRs like #18194 that would want to use this, and it'll at least make it more easily available for experiments like some of the early versions of #18147. I'll also note that there's several usages across existing code of |
Summary
The precise incantation required to declare a variable or type as having a particular alignment or to retrieve the alignment of a type varies wildly between compilers and C standards. This adds macros to abstract over these differences.
Originally developed as part of implementing #18147, though after some refactoring it was eventually dropped from that PR as no longer necessary in that specific case.
Testing
I've tested compiling code using these macros with appropriate spec-version flags across a number of compiler versions from https://godbolt.org, and can conform that it functions correctly.