Skip to content

Commit f0dd781

Browse files
authored
Make processor_arm.cpp compile on musl (#34777)
1 parent 84dd4dd commit f0dd781

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/processor_arm.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
#include <fstream>
1111
#include <algorithm>
1212

13-
#if defined(_CPU_AARCH64_) || __GLIBC_PREREQ(2, 16)
13+
// This nesting is required to allow compilation on musl
14+
#define USE_DYN_GETAUXVAL
15+
#if defined(_CPU_AARCH64_)
16+
# undef USE_DYN_GETAUXVAL
1417
# include <sys/auxv.h>
15-
#else
16-
# define DYN_GETAUXVAL
18+
#elif defined(__GLIBC_PREREQ)
19+
# if __GLIBC_PREREQ(2, 16)
20+
# undef USE_DYN_GETAUXVAL
21+
# include <sys/auxv.h>
22+
# endif
1723
#endif
1824

1925
namespace ARM {
@@ -498,7 +504,7 @@ static constexpr size_t ncpu_names = sizeof(cpus) / sizeof(cpus[0]);
498504
# define AT_HWCAP2 26
499505
#endif
500506

501-
#if defined(DYN_GETAUXVAL)
507+
#if defined(USE_DYN_GETAUXVAL)
502508
static unsigned long getauxval_procfs(unsigned long type)
503509
{
504510
int fd = open("/proc/self/auxv", O_RDONLY);

0 commit comments

Comments
 (0)