Convert __thread to pthreads for Thread Local Storage
[openssl.git] / crypto / async / arch / async_posix.c
index 541c8b36b428d9bea7e0caaad1931844e24a6caf..bd4b0c2f1b62cb5b70d1d457f5cab6ddc1365f30 100644 (file)
 # 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;