Repository: numpy/numpy
File: numpy/_core/src/common/npy_cpu_features.c (C)

Code before:
        npy__cpu_have[NPY_CPU_FEATURE_NEON_FP16] = npy__cpu_have[NPY_CPU_FEATURE_NEON];
    #endif
    #if defined(NPY_HAVE_NEON_VFPV4) || defined(__ARM_FEATURE_FMA)
        npy__cpu_have[NPY_CPU_FEATURE_NEON_VFPV4] = npy__cpu_have[NPY_CPU_FEATURE_NEON];
    #endif
#endif
}

/************** RISC-V 64 ***************/

#elif defined(__riscv) && __riscv_xlen == 64

#include <sys/auxv.h>

#ifndef HWCAP_RVV
    // https://github.com/torvalds/linux/blob/v6.8/arch/riscv/include/uapi/asm/hwcap.h#L24
    #define COMPAT_HWCAP_ISA_V	(1 << ('V' - 'A'))
#endif

static void
npy__cpu_init_features(void)
{
    memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#ifdef __linux__
    unsigned int hwcap = getauxval(AT_HWCAP);
#else
    unsigned long hwcap;
    elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
#endif
#endif
    if (hwcap & COMPAT_HWCAP_ISA_V) {
        npy__cpu_have[NPY_CPU_FEATURE_RVV]  = 1;
    }
}

/*********** Unsupported ARCH ***********/
#else
static void
npy__cpu_init_features(void)
{
    /*
     * just in case if the compiler doesn't respect ANSI
     * but for knowing platforms it still necessary, because @npy__cpu_init_features
     * may called multiple of times and we need to clear the disabled features by
     * ENV Var or maybe in the future we can support other methods like
     * global variables, go back to @npy__cpu_try_disable_env for more understanding
     */
    memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
}
#endif

Review comment (suggestion):
This changes the logic and doesn't  just extend it. Why not
```
#if defined(__FreeBSD__) || defined(__OpenBSD__)
,,,
#else
...
#endif
```

Code after:
        npy__cpu_have[NPY_CPU_FEATURE_NEON_FP16] = npy__cpu_have[NPY_CPU_FEATURE_NEON];
    #endif
    #if defined(NPY_HAVE_NEON_VFPV4) || defined(__ARM_FEATURE_FMA)
        npy__cpu_have[NPY_CPU_FEATURE_NEON_VFPV4] = npy__cpu_have[NPY_CPU_FEATURE_NEON];
    #endif
#endif
}

/************** RISC-V 64 ***************/

#elif defined(__riscv) && __riscv_xlen == 64

#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
    #include <sys/auxv.h>

    #ifndef HWCAP_RVV
        // https://github.com/torvalds/linux/blob/v6.8/arch/riscv/include/uapi/asm/hwcap.h#L24
        #define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A'))
    #endif
#endif

static void
npy__cpu_init_features(void)
{
    memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#ifdef __linux__
    unsigned int hwcap = getauxval(AT_HWCAP);
#else
    unsigned long hwcap;
    elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
#endif
    if (hwcap & COMPAT_HWCAP_ISA_V) {
        npy__cpu_have[NPY_CPU_FEATURE_RVV]  = 1;
    }
#endif
}

/*********** Unsupported ARCH ***********/
#else
static void
npy__cpu_init_features(void)
{
    /*
     * just in case if the compiler doesn't respect ANSI
     * but for knowing platforms it still necessary, because @npy__cpu_init_features
     * may called multiple of times and we need to clear the disabled features by
     * ENV Var or maybe in the future we can support other methods like
     * global variables, go back to @npy__cpu_try_disable_env for more understanding
     */
    memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);