1 #ifndef __CUTILS_THREADS_H__ 2 #define __CUTILS_THREADS_H__ 3 4 #include <pthread.h> 5 6 typedef struct { 7 pthread_mutex_t lock; 8 int has_tls; 9 pthread_key_t tls; 10 } thread_store_t; 11 12 #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } 13 14 extern "C" { 15 16 typedef void (*thread_store_destruct_t)(void* value); 17 18 void* thread_store_get(thread_store_t* store); 19 20 void thread_store_set(thread_store_t* store, 21 void* value, 22 thread_store_destruct_t destroy); 23 24 pid_t gettid(); 25 26 } 27 28 #endif 29