mirror of
https://github.com/opencv/opencv.git
synced 2024-12-05 01:39:13 +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
48 lines
1.8 KiB
C
48 lines
1.8 KiB
C
#ifndef FALLBACK_BUILTINS_H
|
|
#define FALLBACK_BUILTINS_H
|
|
|
|
#if defined(_MSC_VER) && !defined(__clang__)
|
|
#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)
|
|
|
|
#include <intrin.h>
|
|
|
|
/* This is not a general purpose replacement for __builtin_ctz. The function expects that value is != 0.
|
|
* Because of that assumption trailing_zero is not initialized and the return value is not checked.
|
|
* Tzcnt and bsf give identical results except when input value is 0, therefore this can not be allowed.
|
|
* If tzcnt instruction is not supported, the cpu will itself execute bsf instead.
|
|
* Performance tzcnt/bsf is identical on Intel cpu, tzcnt is faster than bsf on AMD cpu.
|
|
*/
|
|
static __forceinline int __builtin_ctz(unsigned int value) {
|
|
Assert(value != 0, "Invalid input value: 0");
|
|
# if defined(X86_FEATURES) && !(_MSC_VER < 1700)
|
|
return (int)_tzcnt_u32(value);
|
|
# else
|
|
unsigned long trailing_zero;
|
|
_BitScanForward(&trailing_zero, value);
|
|
return (int)trailing_zero;
|
|
# endif
|
|
}
|
|
#define HAVE_BUILTIN_CTZ
|
|
|
|
#ifdef _M_AMD64
|
|
/* This is not a general purpose replacement for __builtin_ctzll. The function expects that value is != 0.
|
|
* Because of that assumption trailing_zero is not initialized and the return value is not checked.
|
|
*/
|
|
static __forceinline int __builtin_ctzll(unsigned long long value) {
|
|
Assert(value != 0, "Invalid input value: 0");
|
|
# if defined(X86_FEATURES) && !(_MSC_VER < 1700)
|
|
return (int)_tzcnt_u64(value);
|
|
# else
|
|
unsigned long trailing_zero;
|
|
_BitScanForward64(&trailing_zero, value);
|
|
return (int)trailing_zero;
|
|
# endif
|
|
}
|
|
#define HAVE_BUILTIN_CTZLL
|
|
#endif // Microsoft AMD64
|
|
|
|
#endif // Microsoft AMD64/IA64/x86/ARM/ARM64 test
|
|
#endif // _MSC_VER & !clang
|
|
|
|
#endif // include guard FALLBACK_BUILTINS_H
|