-
Notifications
You must be signed in to change notification settings - Fork 8k
check for __has_attribute(x) and/or clang instead of only basing existence on ZEND_GCC_VERSION #21622
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?
check for __has_attribute(x) and/or clang instead of only basing existence on ZEND_GCC_VERSION #21622
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,7 +166,7 @@ typedef union _align_test { | |
| zend_long lng; | ||
| } align_test; | ||
|
|
||
| #if ZEND_GCC_VERSION >= 2000 | ||
| #if ZEND_GCC_VERSION >= 2000 || defined(__clang__) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly for a follow-up, but we could define C23's alignof in zend_portability.h, and then use it here:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we use MSVC to compile and aren't in C23 mode? It won't be defined at all, so we couldn't use it directly. I think that's for a follow up PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you would still need an
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about this, I don't think it makes sense.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
# define PLATFORM_ALIGNMENT (alignof(align_test) < 8 ? 8 : alignof(align_test))
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
# define PLATFORM_ALIGNMENT (_Alignof(align_test) < 8 ? 8 : _Alignof(align_test))
#elif ZEND_GCC_VERSION >= 2000 || defined(__clang__)
# define PLATFORM_ALIGNMENT (__alignof__(align_test) < 8 ? 8 : __alignof__(align_test))
#else
# define PLATFORM_ALIGNMENT (sizeof(align_test))
#endifwe could do this? It's a bit silly, but I don't want to use deprecated _Alignof in C23+ |
||
| # define PLATFORM_ALIGNMENT (__alignof__(align_test) < 8 ? 8 : __alignof__(align_test)) | ||
| #else | ||
| # define PLATFORM_ALIGNMENT (sizeof(align_test)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has existed in clang since basically forever, I went back all the way to version 5 and it's supported there