patch-src_include_threads_h 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. --- freeradius-server-3.2.3.orig/src/include/threads.h 2023-05-26 15:56:52.000000000 +0200
  2. +++ freeradius-server-3.2.3/src/include/threads.h 2024-02-27 04:03:53.806994686 +0100
  3. @@ -92,7 +92,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. @@ -103,17 +103,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