Mutex* __initialization_mutex_initializer = &getInitializationMutex();
static bool param_dumpErrors = utils::getConfigurationParameterBool("OPENCV_DUMP_ERRORS",
-#if defined(_DEBUG) || defined(__ANDROID__) || (defined(__GNUC__) && !defined(__EXCEPTIONS))
+#if defined(_DEBUG) || defined(__ANDROID__)
true
#else
false
#include <cstdlib> // std::abort
#endif
-#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__
+#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__ || defined __Fuchsia__
# include <unistd.h>
# include <fcntl.h>
# include <elf.h>
g_hwFeatureNames[CPU_AVX512_CNL] = "AVX512-CNL";
g_hwFeatureNames[CPU_AVX512_CLX] = "AVX512-CLX";
g_hwFeatureNames[CPU_AVX512_ICL] = "AVX512-ICL";
+
+ g_hwFeatureNames[CPU_RVV] = "RVV";
}
void initialize(void)
have[CV_CPU_VSX3] = (CV_VSX3);
#endif
+ #if defined __riscv && defined __riscv_vector
+ have[CV_CPU_RVV] = true;
+ #endif
+
bool skip_baseline_check = false;
#ifndef NO_GETENV
if (getenv("OPENCV_SKIP_CPU_BASELINE_CHECK"))
#ifdef HAVE_OPENCL
ocl::setUseOpenCL(flag);
#endif
-#ifdef HAVE_TEGRA_OPTIMIZATION
- ::tegra::setUseTegra(flag);
-#endif
}
bool useOptimized(void)
#endif
+#ifdef __GNUC__
+# if defined __clang__ || defined __APPLE__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Winvalid-noreturn"
+# endif
+#endif
+
void error( const Exception& exc )
{
#ifdef CV_ERROR_SET_TERMINATE_HANDLER
}
throw exc;
+#ifdef __GNUC__
+# if !defined __clang__ && !defined __APPLE__
+ // this suppresses this warning: "noreturn" function does return [enabled by default]
+ __builtin_trap();
+ // or use infinite loop: for (;;) {}
+# endif
+#endif
}
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
{
error(cv::Exception(_code, _err, _func, _file, _line));
+#ifdef __GNUC__
+# if !defined __clang__ && !defined __APPLE__
+ // this suppresses this warning: "noreturn" function does return [enabled by default]
+ __builtin_trap();
+ // or use infinite loop: for (;;) {}
+# endif
+#endif
}
+#ifdef __GNUC__
+# if defined __clang__ || defined __APPLE__
+# pragma GCC diagnostic pop
+# endif
+#endif
+
ErrorCallback
redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)
namespace cv {
bool __termination = false;
-}
-
-namespace cv
-{
-
-#if defined _WIN32 || defined WINCE
-
-struct Mutex::Impl
-{
- Impl()
- {
-#if (_WIN32_WINNT >= 0x0600)
- ::InitializeCriticalSectionEx(&cs, 1000, 0);
-#else
- ::InitializeCriticalSection(&cs);
-#endif
- refcount = 1;
- }
- ~Impl() { DeleteCriticalSection(&cs); }
-
- void lock() { EnterCriticalSection(&cs); }
- bool trylock() { return TryEnterCriticalSection(&cs) != 0; }
- void unlock() { LeaveCriticalSection(&cs); }
-
- CRITICAL_SECTION cs;
- int refcount;
-};
-
-#else
-
-struct Mutex::Impl
-{
- Impl()
- {
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
- pthread_mutex_init(&mt, &attr);
- pthread_mutexattr_destroy(&attr);
-
- refcount = 1;
- }
- ~Impl() { pthread_mutex_destroy(&mt); }
-
- void lock() { pthread_mutex_lock(&mt); }
- bool trylock() { return pthread_mutex_trylock(&mt) == 0; }
- void unlock() { pthread_mutex_unlock(&mt); }
-
- pthread_mutex_t mt;
- int refcount;
-};
-
-#endif
-
-Mutex::Mutex()
-{
- impl = new Mutex::Impl;
-}
-
-Mutex::~Mutex()
-{
- if( CV_XADD(&impl->refcount, -1) == 1 )
- delete impl;
- impl = 0;
-}
-
-Mutex::Mutex(const Mutex& m)
-{
- impl = m.impl;
- CV_XADD(&impl->refcount, 1);
-}
-
-Mutex& Mutex::operator = (const Mutex& m)
-{
- if (this != &m)
- {
- CV_XADD(&m.impl->refcount, 1);
- if( CV_XADD(&impl->refcount, -1) == 1 )
- delete impl;
- impl = m.impl;
- }
- return *this;
-}
-
-void Mutex::lock() { impl->lock(); }
-void Mutex::unlock() { impl->unlock(); }
-bool Mutex::trylock() { return impl->trylock(); }
//////////////////////////////// thread-local storage ////////////////////////////////
}
static TlsAbstraction* getTlsAbstraction()
{
-#ifdef CV_CXX11
static TlsAbstraction* instance = &getTlsAbstraction_();
-#else
- static TlsAbstraction* volatile instance = NULL;
- if (instance == NULL)
- {
- cv::AutoLock lock(cv::getInitializationMutex());
- if (instance == NULL)
- instance = &getTlsAbstraction_();
- }
-#endif
return DisposedSingletonMark<TlsAbstraction>::isDisposed() ? NULL : instance;
}
#ifdef WINRT
static __declspec( thread ) void* tlsData = NULL; // using C++11 thread attribute for local thread data
TlsAbstraction::TlsAbstraction() {}
-TlsAbstraction::~TlsAbstraction() {}
+TlsAbstraction::~TlsAbstraction()
+{
+ cv::__termination = true; // DllMain is missing in static builds
+}
void* TlsAbstraction::getData_() const
{
return tlsData;
}
TlsAbstraction::~TlsAbstraction()
{
+ cv::__termination = true; // DllMain is missing in static builds
#ifndef CV_USE_FLS
TlsFree(tlsKey);
#else // CV_USE_FLS
}
TlsAbstraction::~TlsAbstraction()
{
+ cv::__termination = true; // DllMain is missing in static builds
if (pthread_key_delete(tlsKey) != 0)
{
// Don't use logging here
}
cv::String valueStr = value.substr(0, pos);
cv::String suffixStr = value.substr(pos, value.length() - pos);
-#ifdef CV_CXX11
size_t v = (size_t)std::stoull(valueStr);
-#else
- size_t v = (size_t)atol(valueStr.c_str());
-#endif
if (suffixStr.length() == 0)
return v;
else if (suffixStr == "MB" || suffixStr == "Mb" || suffixStr == "mb")
cv::String utils::getConfigurationParameterString(const char* name, const char* defaultValue)
{
- return read<cv::String>(name, defaultValue);
+ return read<cv::String>(name, defaultValue ? cv::String(defaultValue) : cv::String());
}
utils::Paths utils::getConfigurationParameterPaths(const char* name, const utils::Paths &defaultValue)
ippFeatures = cpuFeatures;
const char* pIppEnv = getenv("OPENCV_IPP");
- cv::String env = pIppEnv;
+ cv::String env;
+ if(pIppEnv != NULL)
+ env = pIppEnv;
if(env.size())
{
#if IPP_VERSION_X100 >= 201900
const Ipp64u minorFeatures = 0;
#endif
- env = env.toLowerCase();
+ env = toLowerCase(env);
if(env.substr(0, 2) == "ne")
{
useIPP_NE = true;
}
#endif
-#if OPENCV_ABI_COMPATIBILITY > 300
unsigned long long getIppFeatures()
-#else
-int getIppFeatures()
-#endif
{
#ifdef HAVE_IPP
-#if OPENCV_ABI_COMPATIBILITY > 300
return getIPPSingleton().ippFeatures;
#else
- return (int)getIPPSingleton().ippFeatures;
-#endif
-#else
return 0;
#endif
}
#endif
}
-#if OPENCV_ABI_COMPATIBILITY < 400
-bool useIPP_NE()
-{
- return useIPP_NotExact();
-}
-
-void setUseIPP_NE(bool flag)
-{
- setUseIPP_NotExact(flag);
-}
-#endif
-
} // namespace ipp
} // namespace cv
-#ifdef HAVE_TEGRA_OPTIMIZATION
-
-namespace tegra {
-
-bool useTegra()
-{
- cv::CoreTLSData* data = cv::getCoreTlsData();
-
- if (data->useTegra < 0)
- {
- const char* pTegraEnv = getenv("OPENCV_TEGRA");
- if (pTegraEnv && (cv::String(pTegraEnv) == "disabled"))
- data->useTegra = false;
- else
- data->useTegra = true;
- }
-
- return (data->useTegra > 0);
-}
-
-void setUseTegra(bool flag)
-{
- cv::CoreTLSData* data = cv::getCoreTlsData();
- data->useTegra = flag;
-}
-
-} // namespace tegra
-
-#endif
-
/* End of file. */