Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22004

How to Initalize Tread Local Storage in C

$
0
0
static __thread vars* ptr=NULL;void thread_init(vars* new_vars){    if(new_vars){        ptr=new_vars    }    printf("%p",ptr);}

__thread is GCC's extention

thread1 is one thread of main

thread1_child is child of thread1

call thread_init(a) in main //ptr is a, not NULL

call thread_init(b) in thread1 //ptr is b, not NULL

call thread_init(NULL) in thread1_child //ptr is NULL,not b

how to dynamically initialize(ptr of thread1 == ptr of thread1_child) ?


Viewing all articles
Browse latest Browse all 22004

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>