aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/threadstorage.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk/threadstorage.h')
-rw-r--r--include/asterisk/threadstorage.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/asterisk/threadstorage.h b/include/asterisk/threadstorage.h
index cf6d47e32..ab586974f 100644
--- a/include/asterisk/threadstorage.h
+++ b/include/asterisk/threadstorage.h
@@ -85,7 +85,11 @@ void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len
* \endcode
*/
#define AST_THREADSTORAGE(name) \
- AST_THREADSTORAGE_CUSTOM(name, NULL, ast_free_ptr)
+ AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr, static)
+#define AST_THREADSTORAGE_PUBLIC(name) \
+ AST_THREADSTORAGE_CUSTOM_SCOPE(name, NULL, ast_free_ptr,)
+#define AST_THREADSTORAGE_EXTERNAL(name) \
+ extern struct ast_threadstorage name
/*!
* \brief Define a thread storage variable, with custom initialization and cleanup
@@ -103,10 +107,12 @@ void __ast_threadstorage_object_replace(void *key_old, void *key_new, size_t len
* AST_THREADSTORAGE_CUSTOM(my_buf, my_init, my_cleanup);
* \endcode
*/
+#define AST_THREADSTORAGE_CUSTOM(a,b,c) AST_THREADSTORAGE_CUSTOM_SCOPE(a,b,c,static)
+
#if !defined(DEBUG_THREADLOCALS)
-#define AST_THREADSTORAGE_CUSTOM(name, c_init, c_cleanup) \
+#define AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) \
static void __init_##name(void); \
-static struct ast_threadstorage name = { \
+scope struct ast_threadstorage name = { \
.once = THREADSTORAGE_ONCE_INIT, \
.key_init = __init_##name, \
.custom_init = c_init, \
@@ -116,9 +122,9 @@ static void __init_##name(void) \
pthread_key_create(&(name).key, c_cleanup); \
}
#else /* defined(DEBUG_THREADLOCALS) */
-#define AST_THREADSTORAGE_CUSTOM(name, c_init, c_cleanup) \
+#define AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) \
static void __init_##name(void); \
-static struct ast_threadstorage name = { \
+scope struct ast_threadstorage name = { \
.once = THREADSTORAGE_ONCE_INIT, \
.key_init = __init_##name, \
.custom_init = c_init, \