Skip to content

Commit 7770fff

Browse files
Fix build error on AArch64 when HWCAP_CPUID is not defined
Fix #205
1 parent bcd2dea commit 7770fff

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libcpuid/cpuid_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,13 +1296,15 @@ int cpuid_present(void)
12961296
#if defined(PLATFORM_X86) || defined(PLATFORM_X64)
12971297
return cpuid_exists_by_eflags();
12981298
#elif defined(PLATFORM_AARCH64)
1299-
# if defined(HAVE_GETAUXVAL) /* Linux */
1299+
# if defined(HAVE_GETAUXVAL) && defined(HWCAP_CPUID) /* Linux */
13001300
return (getauxval(AT_HWCAP) & HWCAP_CPUID);
1301-
# elif defined(HAVE_ELF_AUX_INFO) /* FreeBSD */
1301+
# elif defined(HAVE_ELF_AUX_INFO) && defined(HWCAP_CPUID) /* FreeBSD */
13021302
unsigned long hwcap = 0;
13031303
if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) == 0)
13041304
return ((hwcap & HWCAP_CPUID) != 0);
1305-
# endif /* HAVE_GETAUXVAL */
1305+
# elif !defined(HWCAP_CPUID)
1306+
# warning HWCAP_CPUID is not defined on this AArch64 system, cpuid_present() will always return 0
1307+
# endif /* HWCAP_CPUID */
13061308
/* On AArch64, return 0 by default */
13071309
return 0;
13081310
#else

0 commit comments

Comments
 (0)