This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
getauxv and ARMv7 platform detection
- From: Jeffrey Walton <noloader at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Mon, 20 May 2019 22:51:47 -0400
- Subject: getauxv and ARMv7 platform detection
- Reply-to: noloader at gmail dot com
Hi Everyone,
I just noticed the following code was failing on ARMv7 platforms:
// For older machines, like GCC 4.3 on ARMv6
#ifndef HWCAP_ARMv7
# define HWCAP_ARMv7 (1 << 29)
#endif
inline bool CPU_QueryARMv7()
{
if (getauxval(AT_HWCAP) & HWCAP_ARMv7) != 0)
return true;
return false;
}
Looking through Torvalds GitHub [1] I don't see a reliable define for
HWCAP_ARMv7 in hwcap.h.
I know I can fallback to NEON, but that misses earlier devices that
are ARMv7 but lacks NEON.
Searching is turning up a lot of spurious noise (for Aarch64/ARMv8),
and one hit for Mozilla working around the same problem [2].
My question is, how do we use getauxval to detect ARMv7 platforms?
Thanks in advance.
[1] https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/hwcap.h
[2] https://hg.mozilla.org/releases/mozilla-aurora/rev/522951ff7046fd2bdf3916c973fbfde27be0af31