pthread_setspecific.c raw

   1  #include "pthread_impl.h"
   2  
   3  int pthread_setspecific(pthread_key_t k, const void *x)
   4  {
   5  	struct pthread *self = __pthread_self();
   6  	/* Avoid unnecessary COW */
   7  	if (self->tsd[k] != x) {
   8  		self->tsd[k] = (void *)x;
   9  		self->tsd_used = 1;
  10  	}
  11  	return 0;
  12  }
  13