Skip to content

check for __has_attribute(x) and/or clang instead of only basing existence on ZEND_GCC_VERSION#21622

Open
henderkes wants to merge 2 commits intophp:masterfrom
henderkes:feat/zend-cold
Open

check for __has_attribute(x) and/or clang instead of only basing existence on ZEND_GCC_VERSION#21622
henderkes wants to merge 2 commits intophp:masterfrom
henderkes:feat/zend-cold

Conversation

@henderkes
Copy link
Copy Markdown
Contributor

initially found this for ZEND_COLD and then took a quick ctrl + shift + f for ZEND_GCC_VERSION >=


/* __builtin_cpu_supports has pclmul from gcc9 */
#if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
#if defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && (!defined(__GNUC__) || defined(__clang__) || (ZEND_GCC_VERSION >= 9000))
Copy link
Copy Markdown
Contributor Author

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

} align_test;

#if ZEND_GCC_VERSION >= 2000
#if ZEND_GCC_VERSION >= 2000 || defined(__clang__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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:

#if !defined(alignof)
# if ZEND_GCC_VERSION >= 2000 || defined(__clang__)
#  define alignof(x) __alignof__(x)
# endif
#endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you would still need an #ifdef alignof

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants