You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.5 KiB

  1. --- a/src/include/threads.h
  2. +++ b/src/include/threads.h
  3. @@ -89,7 +89,7 @@ static _t __fr_thread_local_init_##_n(pt
  4. # define fr_thread_local_get(_n) _n
  5. #elif defined(HAVE_PTHREAD_H)
  6. # include <pthread.h>
  7. -# define fr_thread_local_setup(_t, _n) \
  8. +# define fr_thread_local_setup(_t, _n) static __thread _t _n;\
  9. static pthread_key_t __fr_thread_local_key_##_n;\
  10. static pthread_once_t __fr_thread_local_once_##_n = PTHREAD_ONCE_INIT;\
  11. static pthread_destructor_t __fr_thread_local_destructor_##_n = NULL;\
  12. @@ -100,17 +100,17 @@ static void __fr_thread_local_destroy_##
  13. static void __fr_thread_local_key_init_##_n(void)\
  14. {\
  15. (void) pthread_key_create(&__fr_thread_local_key_##_n, __fr_thread_local_destroy_##_n);\
  16. - (void) pthread_setspecific(__fr_thread_local_key_##_n, &(_n));\
  17. }\
  18. static _t __fr_thread_local_init_##_n(pthread_destructor_t func)\
  19. {\
  20. __fr_thread_local_destructor_##_n = func;\
  21. if (_n) return _n; \
  22. (void) pthread_once(&__fr_thread_local_once_##_n, __fr_thread_local_key_init_##_n);\
  23. + (void) pthread_setspecific(__fr_thread_local_key_##_n, &(_n));\
  24. return _n;\
  25. }
  26. -# define fr_thread_local_init(_n, _f) __fr_thread_local_init_##_n(_f)
  27. -# define fr_thread_local_set(_n, _v) __fr_thread_local_set_##_n(_v)
  28. -# define fr_thread_local_get(_n) __fr_thread_local_get_##_n()
  29. +# define fr_thread_local_init(_n, _f) __fr_thread_local_init_##_n(_f)
  30. +# define fr_thread_local_set(_n, _v) ((int)!((_n = _v) || 1))
  31. +# define fr_thread_local_get(_n) _n
  32. #endif
  33. #endif