diff options
author | Matt Caswell <matt@openssl.org> | 2015-11-13 23:54:44 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-11-20 23:39:30 +0000 |
commit | 68487a9b0631d27be9a1f4565e7e652ae9cb6aad (patch) | |
tree | f08b9aedfa12d06d5602f2422def273b96f7ea2c /crypto/async/arch/async_posix.c | |
parent | 27949c353e68825f119410f8fd73ae1d667581c7 (diff) |
Convert __thread to pthreads for Thread Local Storage
In theory the pthreads approach for Thread Local Storage should be more
portable.
This also changes some APIs in order to accommodate this change. In
particular ASYNC_init_pool is renamed ASYNC_init_thread and
ASYNC_free_pool is renamed ASYNC_cleanup_thread. Also introduced ASYNC_init
and ASYNC_cleanup.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/async/arch/async_posix.c')
-rw-r--r-- | crypto/async/arch/async_posix.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/async/arch/async_posix.c b/crypto/async/arch/async_posix.c index 541c8b36b4..bd4b0c2f1b 100644 --- a/crypto/async/arch/async_posix.c +++ b/crypto/async/arch/async_posix.c @@ -61,11 +61,20 @@ # include <openssl/crypto.h> # include <openssl/async.h> -__thread async_ctx *posixctx; -__thread async_pool *posixpool; +pthread_key_t posixctx; +pthread_key_t posixpool; #define STACKSIZE 32768 +int async_thread_local_init(void) +{ + if (pthread_key_create(&posixctx, NULL) != 0 + || pthread_key_create(&posixpool, NULL) != 0) + return 0; + + return 1; +} + int async_fibre_init(async_fibre *fibre) { void *stack = NULL; |