Skip to content

FreeBSD crc32 cap detection for arm64 #4922

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ext/standard/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,30 @@
# if defined(__linux__)
# include <sys/auxv.h>
# include <asm/hwcap.h>
# elif defined(__FreeBSD__)
# include <sys/auxv.h>
# include <elf.h>
# endif

static inline int has_crc32_insn() {
/* Only go through the runtime detection once. */
static int res = -1;
if (res != -1)
return res;
# if defined(__linux__)
# if defined(HWCAP_CRC32)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Should be indented.

res = getauxval(AT_HWCAP) & HWCAP_CRC32;
return res;
# elif defined(HWCAP2_CRC32)
res = getauxval(AT_HWCAP2) & HWCAP2_CRC32;
return res;
# endif
# elif defined(__FreeBSD__)
# if defined(HWCAP_CRC32)
zend_long crc32 = 0;
if (elf_aux_info(AT_HWCAP, &crc32, sizeof(crc32)) == 0)
res = crc32 & HWCAP_CRC32;
Copy link
Member

Choose a reason for hiding this comment

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

res isn't returned here. This will only work on the second run.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah I forgot about this one but a lot had changed since and it s an useless change now, FreeBSD uses a wrapper to be closer to Linux.

# endif
# else
res = 0;
return res;
Expand Down