aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc/support
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-11-27 09:22:38 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2017-11-27 13:41:20 -0800
commitba0689fa2a7fa5f0684d6ce0cde61f453d565ef5 (patch)
treef49643582ba1b616637af4c85d05ae9db7b68cc8 /include/grpc/support
parenteaf67dbdf67821b76e67066f201f2fafe1f5859c (diff)
tls macro changes and UV fix
Diffstat (limited to 'include/grpc/support')
-rw-r--r--include/grpc/support/tls_gcc.h16
-rw-r--r--include/grpc/support/tls_msvc.h8
-rw-r--r--include/grpc/support/tls_pthread.h10
3 files changed, 28 insertions, 6 deletions
diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h
index 170baf82ca..c926400e8e 100644
--- a/include/grpc/support/tls_gcc.h
+++ b/include/grpc/support/tls_gcc.h
@@ -33,12 +33,18 @@ struct gpr_gcc_thread_local {
bool* inited;
};
+/** Use GPR_TLS_DECL to declare tls static variables outside a class */
#define GPR_TLS_DECL(name) \
static bool name##_inited = false; \
static __thread struct gpr_gcc_thread_local name = {0, &(name##_inited)}
-#define GPR_TLS_NON_STATIC_DECL(name) \
- bool name##_inited = false; \
+/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class.
+ * GPR_TLS_CLASS_DEF needs to be called to define this member. */
+#define GPR_TLS_CLASS_DECL(name) \
+ static bool name##_inited = false; \
+ static __thread struct gpr_gcc_thread_local name
+
+#define GPR_TLS_CLASS_DEF(name) \
__thread struct gpr_gcc_thread_local name = {0, &(name##_inited)}
#define gpr_tls_init(tls) \
@@ -75,8 +81,10 @@ struct gpr_gcc_thread_local {
#define GPR_TLS_DECL(name) \
static __thread struct gpr_gcc_thread_local name = {0}
-#define GPR_TLS_NON_STATIC_DECL(name) \
- __thread struct gpr_gcc_thread_local name = {0}
+#define GPR_TLS_CLASS_DECL(name) \
+ static __thread struct gpr_gcc_thread_local name
+
+#define GPR_TLS_CLASS_DEF(name) __thread struct gpr_gcc_thread_local name = {0}
#define gpr_tls_init(tls) \
do { \
diff --git a/include/grpc/support/tls_msvc.h b/include/grpc/support/tls_msvc.h
index e3a0921912..68a411f5d4 100644
--- a/include/grpc/support/tls_msvc.h
+++ b/include/grpc/support/tls_msvc.h
@@ -26,10 +26,16 @@ struct gpr_msvc_thread_local {
intptr_t value;
};
+/** Use GPR_TLS_DECL to declare tls static variables outside a class */
#define GPR_TLS_DECL(name) \
static __declspec(thread) struct gpr_msvc_thread_local name = {0}
-#define GPR_TLS_NON_STATIC_DECL(name) \
+/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class.
+ * GPR_TLS_CLASS_DEF needs to be called to define this member. */
+#define GPR_TLS_CLASS_DECL(name) \
+ static __declspec(thread) struct gpr_msvc_thread_local name
+
+#define GPR_TLS_CLASS_DEF(name) \
__declspec(thread) struct gpr_msvc_thread_local name = {0}
#define gpr_tls_init(tls) \
diff --git a/include/grpc/support/tls_pthread.h b/include/grpc/support/tls_pthread.h
index 09768d8423..249c8b16f8 100644
--- a/include/grpc/support/tls_pthread.h
+++ b/include/grpc/support/tls_pthread.h
@@ -29,8 +29,16 @@ struct gpr_pthread_thread_local {
pthread_key_t key;
};
+/** Use GPR_TLS_DECL to declare tls static variables outside a class */
#define GPR_TLS_DECL(name) static struct gpr_pthread_thread_local name = {0}
-#define GPR_TLS_NON_STATIC_DECL(name) struct gpr_pthread_thread_local name = {0}
+
+/** Use GPR_TLS_CLASS_DECL to declare tls static variable members of a class.
+ * GPR_TLS_CLASS_DEF needs to be called to define this member. */
+#define GPR_TLS_CLASS_DECL(name) static struct gpr_pthread_thread_local name
+
+/** Use GPR_TLS_CLASS_DEF to declare tls static variable members of a class.
+ * GPR_TLS_CLASS_DEF needs to be called to define this member. */
+#define GPR_TLS_CLASS_DEF(name) struct gpr_pthread_thread_local name = {0}
#define gpr_tls_init(tls) GPR_ASSERT(0 == pthread_key_create(&(tls)->key, NULL))
#define gpr_tls_destroy(tls) pthread_key_delete((tls)->key)