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; }
static void init_once(void) { if ((init_error = git_mutex_init(&git__mwindow_mutex)) != 0) return; pthread_key_create(&_tls_key, &cb__free_status); /* Initialize any other subsystems that have global state */ if ((init_error = git_hash_global_init()) >= 0) init_error = git_sysdir_global_init(); GIT_MEMORY_BARRIER; }
static int synchronized_threads_init(void) { int error; _tls_index = TlsAlloc(); if (git_mutex_init(&git__mwindow_mutex)) return -1; /* Initialize any other subsystems that have global state */ if ((error = git_hash_global_init()) >= 0) error = git_sysdir_global_init(); win32_pthread_initialize(); return error; }
int git_hash_ctx_init(git_hash_ctx *ctx) { int error = 0; assert(ctx); /* * When compiled with GIT_THREADS, the global hash_prov data is * initialized with git_libgit2_init. Otherwise, it must be initialized * at first use. */ if (hash_prov.type == INVALID && (error = git_hash_global_init()) < 0) return error; memset(ctx, 0x0, sizeof(git_hash_ctx)); return (hash_prov.type == CNG) ? hash_ctx_cng_init(ctx) : hash_ctx_cryptoapi_init(ctx); }
int git_threads_init(void) { int error = 0; if (_tls_init) return 0; if (git_mutex_init(&git__mwindow_mutex)) return -1; pthread_key_create(&_tls_key, &cb__free_status); /* Initialize any other subsystems that have global state */ if ((error = git_hash_global_init()) >= 0) _tls_init = 1; GIT_MEMORY_BARRIER; return error; }
int git_threads_init(void) { int error; if (_tls_init) return 0; _tls_index = TlsAlloc(); if (git_mutex_init(&git__mwindow_mutex)) return -1; /* Initialize any other subsystems that have global state */ if ((error = git_hash_global_init()) >= 0 && (error = git_futils_dirs_global_init()) >= 0) _tls_init = 1; GIT_MEMORY_BARRIER; win32_pthread_initialize(); return error; }