1 #include <stdio.h> 2 #include <pthread.h> 3 #include <unistd.h> 4 5 void shared_check(); 6 // On some OS's (darwin) you must actually access a thread local variable 7 // before you can read it 8 int 9 touch_shared(); 10 11 // Create some TLS storage within the static executable. 12 __thread int var_static = 44; 13 fn_static(void * param)14void *fn_static(void *param) 15 { 16 var_static *= 2; 17 shared_check(); 18 usleep(1); // thread breakpoint 19 for(;;) 20 usleep(1); 21 } 22 main(int argc,char const * argv[])23int main (int argc, char const *argv[]) 24 { 25 pthread_t handle; 26 pthread_create(&handle, NULL, &fn_static, NULL); 27 touch_shared(); 28 for (; var_static;) 29 { 30 usleep(1); // main breakpoint 31 } 32 33 return 0; 34 } 35