*
*/
-#include <openssl/e_os2.h>
-
-#if defined(OPENSSL_SYS_WINDOWS) && !defined(_WIN32_WINNT)
-/*
- * We default to requiring Windows Vista, Windows Server 2008 or later. We can
- * support lower versions if _WIN32_WINNT is explicity defined to something
- * less
- */
-# define _WIN32_WINNT 0x0600
-#endif
-
#include <internal/cryptlib_int.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <internal/err.h>
#include <stdlib.h>
+static void ossl_init_thread_stop(struct thread_local_inits_st *locals);
+
/* Implement "once" functionality */
#if !defined(OPENSSL_THREADS)
typedef int OPENSSL_INIT_ONCE;
}
static struct thread_local_inits_st *local = NULL;
-void *ossl_init_get_thread_local(int alloc)
+static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
{
+ static struct thread_local_inits_st *tmp;
+
+ tmp = local;
+
if (local == NULL && alloc)
- local = OPENSSL_zalloc(sizeof(*local));
- return local;
+ tmp = local = OPENSSL_zalloc(sizeof(*local));
+
+ if (!alloc)
+ local = NULL;
+
+ return tmp;
}
#elif defined(OPENSSL_SYS_WINDOWS)
}
}
-void *ossl_init_get_thread_local(int alloc)
+static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
{
struct thread_local_inits_st *local = TlsGetValue(threadstopkey);
local = OPENSSL_zalloc(sizeof *local);
TlsSetValue(threadstopkey, local);
}
+ if (!alloc) {
+ TlsSetValue(threadstopkey, NULL);
+ }
return local;
}
{
}
-void *ossl_init_get_thread_local(int alloc)
+static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc)
{
struct thread_local_inits_st *local = pthread_getspecific(threadstopkey);
local = OPENSSL_zalloc(sizeof *local);
pthread_setspecific(threadstopkey, local);
}
+ if (!alloc) {
+ pthread_setspecific(threadstopkey, NULL);
+ }
return local;
}
static void ossl_init_load_crypto_strings(void)
{
-#ifndef OPENSSL_NO_ERR
+ /*
+ * OPENSSL_NO_AUTOERRINIT is provided here to prevent at compile time
+ * pulling in all the error strings during static linking
+ */
+#if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT)
# ifdef OPENSSL_INIT_DEBUG
fprintf(stderr, "OPENSSL_INIT: ossl_init_load_crypto_strings: "
"err_load_crypto_strings_intern()\n");
zlib_inited = 1;
}
-void ossl_init_thread_stop(struct thread_local_inits_st *locals)
+static void ossl_init_thread_stop(struct thread_local_inits_st *locals)
{
/* Can't do much about this */
if (locals == NULL)
ossl_init_thread_stop_cleanup();
}
+void OPENSSL_INIT_thread_stop(void)
+{
+ ossl_init_thread_stop(
+ (struct thread_local_inits_st *)ossl_init_get_thread_local(0));
+}
+
int ossl_init_thread_start(uint64_t opts)
{
struct thread_local_inits_st *locals = ossl_init_get_thread_local(1);
}
if (opts & OPENSSL_INIT_LOAD_CONFIG) {
+ CRYPTO_w_lock(CRYPTO_LOCK_INIT);
if (settings != NULL) {
const OPENSSL_INIT_SETTINGS *curr;
curr = ossl_init_get_setting(settings,
OPENSSL_INIT_SET_CONF_FILENAME);
- config_filename = curr == NULL ? NULL : curr->value.type_string;
+ config_filename = (curr == NULL) ? NULL : curr->value.type_string;
+ } else {
+ config_filename = NULL;
}
ossl_init_once_run(&config, ossl_init_config);
+ CRYPTO_w_unlock(CRYPTO_LOCK_INIT);
}
if (opts & OPENSSL_INIT_ASYNC) {