Skip to content

Commit f0c2da3

Browse files
committed
3rdparty: cpufeatures workaround
1 parent 3dee87b commit f0c2da3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

3rdparty/cpufeatures/cpu-features.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,25 @@ cpulist_read_from(CpuList* list, const char* filename)
515515
// its implementation does not parse /proc/self/auxv. Instead it depends
516516
// on values that are passed by the kernel at process-init time to the
517517
// C runtime initialization layer.
518+
#if 1
519+
// OpenCV calls CPU features check during library initialization stage
520+
// (under other dlopen() call).
521+
// Unfortunatelly, calling dlopen() recursively is not supported on some old
522+
// Android versions. Android fix is here:
523+
// - https://android-review.googlesource.com/#/c/32951/
524+
// - GitHub mirror: https://github.com/android/platform_bionic/commit/e19d702b8e330cef87e0983733c427b5f7842144
525+
__attribute__((weak)) unsigned long getauxval(unsigned long); // Lets linker to handle this symbol
526+
static uint32_t
527+
get_elf_hwcap_from_getauxval(int hwcap_type) {
528+
uint32_t ret = 0;
529+
if(getauxval != 0) {
530+
ret = (uint32_t)getauxval(hwcap_type);
531+
} else {
532+
D("getauxval() is not available\n");
533+
}
534+
return ret;
535+
}
536+
#else
518537
static uint32_t
519538
get_elf_hwcap_from_getauxval(int hwcap_type) {
520539
typedef unsigned long getauxval_func_t(unsigned long);
@@ -539,6 +558,7 @@ get_elf_hwcap_from_getauxval(int hwcap_type) {
539558
return ret;
540559
}
541560
#endif
561+
#endif
542562

543563
#if defined(__arm__)
544564
// Parse /proc/self/auxv to extract the ELF HW capabilities bitmap for the

0 commit comments

Comments
 (0)