mirror of
https://github.com/opencv/opencv.git
synced 2025-06-21 10:30:51 +08:00
Merge pull request #15970 from akemimadoka:master
* Fix android armv7 c++_static init crash * core: move initialization of 'ios_base::Init' for Android
This commit is contained in:
parent
ca28274895
commit
54e6f5c237
@ -21,6 +21,8 @@ namespace logging {
|
|||||||
|
|
||||||
static LogLevel parseLogLevelConfiguration()
|
static LogLevel parseLogLevelConfiguration()
|
||||||
{
|
{
|
||||||
|
(void)getInitializationMutex(); // ensure initialization of global objects
|
||||||
|
|
||||||
static cv::String param_log_level = utils::getConfigurationParameterString("OPENCV_LOG_LEVEL",
|
static cv::String param_log_level = utils::getConfigurationParameterString("OPENCV_LOG_LEVEL",
|
||||||
#if defined NDEBUG
|
#if defined NDEBUG
|
||||||
"WARNING"
|
"WARNING"
|
||||||
|
@ -55,11 +55,26 @@
|
|||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
|
|
||||||
|
static void _initSystem()
|
||||||
|
{
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
// https://github.com/opencv/opencv/issues/14906
|
||||||
|
// "ios_base::Init" object is not a part of Android's "iostream" header (in case of clang toolchain, NDK 20).
|
||||||
|
// Ref1: https://en.cppreference.com/w/cpp/io/ios_base/Init
|
||||||
|
// The header <iostream> behaves as if it defines (directly or indirectly) an instance of std::ios_base::Init with static storage duration
|
||||||
|
// Ref2: https://github.com/gcc-mirror/gcc/blob/gcc-8-branch/libstdc%2B%2B-v3/include/std/iostream#L73-L74
|
||||||
|
static std::ios_base::Init s_iostream_initializer;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static Mutex* __initialization_mutex = NULL;
|
static Mutex* __initialization_mutex = NULL;
|
||||||
Mutex& getInitializationMutex()
|
Mutex& getInitializationMutex()
|
||||||
{
|
{
|
||||||
if (__initialization_mutex == NULL)
|
if (__initialization_mutex == NULL)
|
||||||
|
{
|
||||||
|
(void)_initSystem();
|
||||||
__initialization_mutex = new Mutex();
|
__initialization_mutex = new Mutex();
|
||||||
|
}
|
||||||
return *__initialization_mutex;
|
return *__initialization_mutex;
|
||||||
}
|
}
|
||||||
// force initialization (single-threaded environment)
|
// force initialization (single-threaded environment)
|
||||||
|
Loading…
Reference in New Issue
Block a user