File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -846,22 +846,30 @@ npy__cpu_init_features(void)
846846
847847#elif defined(__riscv ) && __riscv_xlen == 64
848848
849- #include <sys/auxv.h>
849+ #if defined(__linux__ ) || defined(__FreeBSD__ ) || defined(__OpenBSD__ )
850+ #include <sys/auxv.h>
850851
851- #ifndef HWCAP_RVV
852- // https://github.com/torvalds/linux/blob/v6.8/arch/riscv/include/uapi/asm/hwcap.h#L24
853- #define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A'))
852+ #ifndef HWCAP_RVV
853+ // https://github.com/torvalds/linux/blob/v6.8/arch/riscv/include/uapi/asm/hwcap.h#L24
854+ #define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A'))
855+ #endif
854856#endif
855857
856858static void
857859npy__cpu_init_features (void )
858860{
859861 memset (npy__cpu_have , 0 , sizeof (npy__cpu_have [0 ]) * NPY_CPU_FEATURE_MAX );
860-
862+ #if defined(__linux__ ) || defined(__FreeBSD__ ) || defined(__OpenBSD__ )
863+ #ifdef __linux__
861864 unsigned int hwcap = getauxval (AT_HWCAP );
865+ #else
866+ unsigned long hwcap ;
867+ elf_aux_info (AT_HWCAP , & hwcap , sizeof (hwcap ));
868+ #endif
862869 if (hwcap & COMPAT_HWCAP_ISA_V ) {
863870 npy__cpu_have [NPY_CPU_FEATURE_RVV ] = 1 ;
864871 }
872+ #endif
865873}
866874
867875/*********** Unsupported ARCH ***********/
You can’t perform that action at this time.
0 commit comments