diff options
author | Viktor Dukhovni <openssl-users@dukhovni.org> | 2016-05-15 13:02:17 -0400 |
---|---|---|
committer | Viktor Dukhovni <openssl-users@dukhovni.org> | 2016-05-16 12:16:26 -0400 |
commit | 5c4328f04f63bc288d4e069e1453ab18b0309f16 (patch) | |
tree | af382cc88ad40bd91388a6a1e3aec096554ac9bd /include/openssl/crypto.h | |
parent | b160f2823fb3bafdf8728ea251aab0d07888b934 (diff) | |
download | openssl-5c4328f04f63bc288d4e069e1453ab18b0309f16.zip openssl-5c4328f04f63bc288d4e069e1453ab18b0309f16.tar.gz openssl-5c4328f04f63bc288d4e069e1453ab18b0309f16.tar.bz2 |
Fold threads.h into crypto.h making API public
Document thread-safe lock creation
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'include/openssl/crypto.h')
-rw-r--r-- | include/openssl/crypto.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 5e16318..3d73c62 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -485,6 +485,44 @@ void OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, #endif void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings); +# if !defined(OPENSSL_THREADS) || defined(CRYPTO_TDEBUG) +typedef unsigned int CRYPTO_ONCE; +typedef unsigned int CRYPTO_THREAD_LOCAL; +typedef unsigned int CRYPTO_THREAD_ID; + +# define CRYPTO_ONCE_STATIC_INIT 0 +# elif defined(OPENSSL_SYS_WINDOWS) +# include <windows.h> +typedef DWORD CRYPTO_THREAD_LOCAL; +typedef DWORD CRYPTO_THREAD_ID; + +# if _WIN32_WINNT < 0x0600 +typedef LONG CRYPTO_ONCE; +# define CRYPTO_ONCE_STATIC_INIT 0 +# else +typedef INIT_ONCE CRYPTO_ONCE; +# define CRYPTO_ONCE_STATIC_INIT INIT_ONCE_STATIC_INIT +# endif + +# else +# include <pthread.h> +typedef pthread_once_t CRYPTO_ONCE; +typedef pthread_key_t CRYPTO_THREAD_LOCAL; +typedef pthread_t CRYPTO_THREAD_ID; + +# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT +# endif + +int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)); + +int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *)); +void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key); +int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val); +int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key); + +CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void); +int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b); + /* BEGIN ERROR CODES */ /* * The following lines are auto generated by the script mkerr.pl. Any changes |