mirror of
https://github.com/opencv/opencv.git
synced 2024-12-24 00:17:59 +08:00
85923c8f30
Update zlib-ng to 2.2.1 #26113 Release: https://github.com/zlib-ng/zlib-ng/releases/tag/2.2.1 ARM diagnostics patch: https://github.com/zlib-ng/zlib-ng/pull/1774 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/utsname.h>
|
|
|
|
#if defined(__linux__) && defined(HAVE_SYS_AUXV_H)
|
|
# include <sys/auxv.h>
|
|
#endif
|
|
|
|
#include "zbuild.h"
|
|
#include "riscv_features.h"
|
|
|
|
#define ISA_V_HWCAP (1 << ('v' - 'a'))
|
|
|
|
int Z_INTERNAL is_kernel_version_greater_or_equal_to_6_5() {
|
|
struct utsname buffer;
|
|
uname(&buffer);
|
|
|
|
int major, minor;
|
|
if (sscanf(buffer.release, "%d.%d", &major, &minor) != 2) {
|
|
// Something bad with uname()
|
|
return 0;
|
|
}
|
|
|
|
if (major > 6 || major == 6 && minor >= 5)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
void Z_INTERNAL riscv_check_features_compile_time(struct riscv_cpu_features *features) {
|
|
#if defined(__riscv_v) && defined(__linux__)
|
|
features->has_rvv = 1;
|
|
#else
|
|
features->has_rvv = 0;
|
|
#endif
|
|
}
|
|
|
|
void Z_INTERNAL riscv_check_features_runtime(struct riscv_cpu_features *features) {
|
|
#if defined(__linux__) && defined(HAVE_SYS_AUXV_H)
|
|
unsigned long hw_cap = getauxval(AT_HWCAP);
|
|
#else
|
|
unsigned long hw_cap = 0;
|
|
#endif
|
|
features->has_rvv = hw_cap & ISA_V_HWCAP;
|
|
}
|
|
|
|
void Z_INTERNAL riscv_check_features(struct riscv_cpu_features *features) {
|
|
if (is_kernel_version_greater_or_equal_to_6_5())
|
|
riscv_check_features_runtime(features);
|
|
else
|
|
riscv_check_features_compile_time(features);
|
|
}
|