GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ENH: cpu features detection implementation on FreeBSD ARM · plctlab/numpy@c47e962

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • numpy/core/src/common
    • npy_cpu_features.c.src
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎numpy/core/src/common/npy_cpu_features.c.src‎

Copy file name to clipboardExpand all lines: numpy/core/src/common/npy_cpu_features.c.src
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ npy__cpu_init_features_arm8(void)
500500
npy__cpu_have[NPY_CPU_FEATURE_ASIMD] = 1;
501501
}
502502

503-
#ifdef __linux__
503+
#if defined(__linux__) || defined(__FreeBSD__)
504504
/*
505505
* we aren't sure of what kind kernel or clib we deal with
506506
* so we play it safe
@@ -509,10 +509,23 @@ npy__cpu_init_features_arm8(void)
509509
#include "npy_cpuinfo_parser.h"
510510

511511
__attribute__((weak)) unsigned long getauxval(unsigned long); // linker should handle it
512+
#ifdef __FreeBSD__
513+
__attribute__((weak)) int elf_aux_info(int, void *, int); // linker should handle it
514+
515+
static unsigned long getauxval(unsigned long k)
516+
{
517+
unsigned long val = 0ul;
518+
if (elf_aux_info == 0 || elf_aux_info((int)k, (void *)&val, (int)sizeof(val)) != 0) {
519+
return 0ul;
520+
}
521+
return val;
522+
}
523+
#endif
512524
static int
513525
npy__cpu_init_features_linux(void)
514526
{
515527
unsigned long hwcap = 0, hwcap2 = 0;
528+
#ifdef __linux__
516529
if (getauxval != 0) {
517530
hwcap = getauxval(NPY__HWCAP);
518531
#ifdef __arm__
@@ -539,14 +552,24 @@ npy__cpu_init_features_linux(void)
539552
close(fd);
540553
}
541554
}
555+
#else
556+
hwcap = getauxval(NPY__HWCAP);
557+
#ifdef __arm__
558+
hwcap2 = getauxval(NPY__HWCAP2);
559+
#endif
560+
#endif
542561
if (hwcap == 0 && hwcap2 == 0) {
562+
#ifdef __linux__
543563
/*
544564
* try parsing with /proc/cpuinfo, if sandboxed
545565
* failback to compiler definitions
546566
*/
547567
if(!get_feature_from_proc_cpuinfo(&hwcap, &hwcap2)) {
548568
return 0;
549569
}
570+
#else
571+
return 0;
572+
#endif
550573
}
551574
#ifdef __arm__
552575
// Detect Arm8 (aarch32 state)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.