static int init_common(void) { int ret; /* Initialize the CRT debug allocator first, before our first malloc */ #if defined(GIT_MSVC_CRTDBG) git_win32__crtdbg_stacktrace_init(); git_win32__stack_init(); #endif /* Initialize any other subsystems that have global state */ if ((ret = git_allocator_global_init()) == 0 && (ret = git_hash_global_init()) == 0 && (ret = git_sysdir_global_init()) == 0 && (ret = git_filter_global_init()) == 0 && (ret = git_merge_driver_global_init()) == 0 && (ret = git_transport_ssh_global_init()) == 0 && (ret = git_openssl_stream_global_init()) == 0 && (ret = git_curl_stream_global_init()) == 0 && (ret = git_mbedtls_stream_global_init()) == 0) ret = git_mwindow_global_init(); GIT_MEMORY_BARRIER; return ret; }
int git_libgit2_init(void) { int ret; /* Enter the lock */ while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 0 -> 1 transition of the refcount */ if ((ret = git_atomic_inc(&git__n_inits)) == 1) { #if defined(GIT_MSVC_CRTDBG) git_win32__crtdbg_stacktrace_init(); git_win32__stack_init(); #endif if (synchronized_threads_init() < 0) ret = -1; } /* Exit the lock */ InterlockedExchange(&_mutex, 0); return ret; }