summaryrefslogtreecommitdiff
path: root/include/asterisk/module.h
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-05-04 15:26:37 -0400
committerCorey Farrell <git@cfware.com>2015-05-04 20:47:01 -0400
commita8bfa9e10445744581d18819c64729844ae837fb (patch)
treeea238e819c3440409df3027cd3c703394753c015 /include/asterisk/module.h
parentce21776aae2866f3c611f172c4d38fb53e806dcf (diff)
Modules: Make ast_module_info->self available to auxiliary sources.
ast_module_info->self is often needed to register items with the core. Many modules have ad-hoc code to make this pointer available to auxiliary sources. This change updates the module build process to make the needed information available to all sources in a module. ASTERISK-25056 #close Reported by: Corey Farrell Change-Id: I18c8cd58fbcb1b708425f6757becaeca9fa91815
Diffstat (limited to 'include/asterisk/module.h')
-rw-r--r--include/asterisk/module.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/asterisk/module.h b/include/asterisk/module.h
index 6d5e04dfc..f42749146 100644
--- a/include/asterisk/module.h
+++ b/include/asterisk/module.h
@@ -312,9 +312,9 @@ struct ast_module_user *__ast_module_user_add(struct ast_module *, struct ast_ch
void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
void __ast_module_user_hangup_all(struct ast_module *);
-#define ast_module_user_add(chan) __ast_module_user_add(ast_module_info->self, chan)
-#define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info->self, user)
-#define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info->self)
+#define ast_module_user_add(chan) __ast_module_user_add(AST_MODULE_SELF, chan)
+#define ast_module_user_remove(user) __ast_module_user_remove(AST_MODULE_SELF, user)
+#define ast_module_user_hangup_all() __ast_module_user_hangup_all(AST_MODULE_SELF)
struct ast_module *__ast_module_ref(struct ast_module *mod, const char *file, int line, const char *func);
void __ast_module_shutdown_ref(struct ast_module *mod, const char *file, int line, const char *func);
@@ -368,8 +368,13 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons
{ \
ast_module_unregister(&__mod_info); \
} \
+ struct ast_module *AST_MODULE_SELF_SYM(void) \
+ { \
+ return __mod_info.self; \
+ } \
static const __attribute__((unused)) struct ast_module_info *ast_module_info = &__mod_info
+
#define AST_MODULE_INFO_STANDARD(keystr, desc) \
AST_MODULE_INFO(keystr, AST_MODFLAG_LOAD_ORDER, desc, \
load_module, \
@@ -401,7 +406,9 @@ void __ast_module_unref(struct ast_module *mod, const char *file, int line, cons
/* forward declare this pointer in modules, so that macro/function
calls that need it can get it, since it will actually be declared
and populated at the end of the module's source file... */
+#if !defined(AST_IN_CORE)
static const __attribute__((unused)) struct ast_module_info *ast_module_info;
+#endif
#if !defined(EMBEDDED_MODULE)
#define __MODULE_INFO_SECTION
@@ -482,6 +489,10 @@ static void __restore_globals(void)
{ \
ast_module_unregister(&__mod_info); \
} \
+ struct ast_module *AST_MODULE_SELF_SYM(void) \
+ { \
+ return __mod_info.self; \
+ } \
static const struct ast_module_info *ast_module_info = &__mod_info
#define AST_MODULE_INFO_STANDARD(keystr, desc) \
@@ -527,7 +538,7 @@ static void __restore_globals(void)
* \retval 0 success
* \retval -1 failure.
*/
-#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self)
+#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, AST_MODULE_SELF)
/*!
* \brief Register an application using XML documentation.