1From 30ce5ccd62446349d432ff65d3fe8d46872423c8 Mon Sep 17 00:00:00 2001
2From: Yi Zhao <yi.zhao@windriver.com>
3Date: Wed, 18 Jan 2017 14:59:39 +0800
4Subject: [PATCH] fix error for expansion of macro in thread.h
5
6The parameter declaration is missing in expansion of macro
7which cause the build error:
8| In file included from src/freeradius-devel/libradius.h:80:0,
9|                  from src/lib/log.c:26:
10| src/lib/log.c: In function '__fr_thread_local_destroy_fr_strerror_buffer':
11| src/lib/log.c:37:31: error: 'fr_strerror_buffer' undeclared (first use in this function)
12|  fr_thread_local_setup(char *, fr_strerror_buffer) /* macro */
13|                                ^
14
15Add the missing declaration in macro.
16
17Upstream-Status: Pending
18
19Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
20---
21 src/include/threads.h | 10 +++++-----
22 1 file changed, 5 insertions(+), 5 deletions(-)
23
24diff --git a/src/include/threads.h b/src/include/threads.h
25index e36d81dac0..2bcb6aadcb 100644
26--- a/src/include/threads.h
27+++ b/src/include/threads.h
28@@ -89,7 +89,7 @@ static _t __fr_thread_local_init_##_n(pthread_destructor_t func)\
29 #  define fr_thread_local_get(_n) _n
30 #elif defined(HAVE_PTHREAD_H)
31 #  include <pthread.h>
32-#  define fr_thread_local_setup(_t, _n) \
33+#  define fr_thread_local_setup(_t, _n) static __thread _t _n;\
34 static pthread_key_t __fr_thread_local_key_##_n;\
35 static pthread_once_t __fr_thread_local_once_##_n = PTHREAD_ONCE_INIT;\
36 static pthread_destructor_t __fr_thread_local_destructor_##_n = NULL;\
37@@ -100,17 +100,17 @@ static void __fr_thread_local_destroy_##_n(UNUSED void *unused)\
38 static void __fr_thread_local_key_init_##_n(void)\
39 {\
40 	(void) pthread_key_create(&__fr_thread_local_key_##_n, __fr_thread_local_destroy_##_n);\
41-	(void) pthread_setspecific(__fr_thread_local_key_##_n, &(_n));\
42 }\
43 static _t __fr_thread_local_init_##_n(pthread_destructor_t func)\
44 {\
45 	__fr_thread_local_destructor_##_n = func;\
46 	if (_n) return _n; \
47 	(void) pthread_once(&__fr_thread_local_once_##_n, __fr_thread_local_key_init_##_n);\
48+	(void) pthread_setspecific(__fr_thread_local_key_##_n, &(_n));\
49 	return _n;\
50 }
51-#  define fr_thread_local_init(_n, _f)			__fr_thread_local_init_##_n(_f)
52-#  define fr_thread_local_set(_n, _v)			__fr_thread_local_set_##_n(_v)
53-#  define fr_thread_local_get(_n)			__fr_thread_local_get_##_n()
54+#  define fr_thread_local_init(_n, _f)	__fr_thread_local_init_##_n(_f)
55+#  define fr_thread_local_set(_n, _v) ((int)!((_n = _v) || 1))
56+#  define fr_thread_local_get(_n) _n
57 #endif
58 #endif
59--
602.25.1
61
62