FreeBSD provides 'elf_aux_info' function that does the same as 'getauxval' on Linux.
Details
Diff Detail
Event Timeline
Can you upload this with full context (https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line)?
compiler-rt/lib/builtins/cpu_model.c | ||
---|---|---|
807 | This means non-linux, non-FreeBSD systems always return false even if they prvide a getauxval() function. I would do something like the following to ensure that it fails to compile on unsupported systems instead of always returning false: #if defined(__FreeBSD__) unsigned long hwcap = elf_aux_info(AT_HWCAP, &hwcap, sizeof(unsigned long)); #else unsigned long hwcap = getauxval(AT_HWCAP); #endif |
Address comment.
dim@FreeBSD.org committed a in slightly different version in FreeBSD src tree. Should I use its version instead?
Thanks!
I committed a change to FreeBSD in https://cgit.freebsd.org/src/commit/?id=efe67f33c322265eb303ec0ab40275100795b22a, which is almost identical. However, I also check the return value of elf_aux_info(), since (theoretically at least) it could fail. In that case, I'm assuming that HWCAP is also not working. :)
@MikaelUrankar any objections if I add that to this review?
This means non-linux, non-FreeBSD systems always return false even if they prvide a getauxval() function. I would do something like the following to ensure that it fails to compile on unsupported systems instead of always returning false: