aarch32 support is an optional feature of ARMv8, as CPUs
which don't support aarch32 become more common, lets make
sure that lscpu can tell a user quickly if they are on a
machine that only supports 64-bit.
Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/personality.h>
#if (defined(__x86_64__) || defined(__i386__))
# if !defined( __SANITIZE_ADDRESS__)
defined(__s390x__) || defined(__s390__) || defined(__sparc_v9__)
m |= MODE_32BIT;
#endif
+
+#if defined(__aarch64__)
+ {
+ /* personality() is the most reliable way (since 4.7)
+ * to determine aarch32 support */
+ int pers = personality(PER_LINUX32);
+ if (pers != -1) {
+ personality(pers);
+ m |= MODE_32BIT;
+ }
+ m |= MODE_64BIT;
+ }
+#endif
return m;
}