diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk.h | 17 | ||||
-rw-r--r-- | include/asterisk/app.h | 4 | ||||
-rw-r--r-- | include/asterisk/bridge_technology.h | 2 | ||||
-rw-r--r-- | include/asterisk/bucket.h | 2 | ||||
-rw-r--r-- | include/asterisk/cli.h | 11 | ||||
-rw-r--r-- | include/asterisk/codec.h | 2 | ||||
-rw-r--r-- | include/asterisk/data.h | 4 | ||||
-rw-r--r-- | include/asterisk/format.h | 2 | ||||
-rw-r--r-- | include/asterisk/manager.h | 4 | ||||
-rw-r--r-- | include/asterisk/mod_format.h | 2 | ||||
-rw-r--r-- | include/asterisk/module.h | 19 | ||||
-rw-r--r-- | include/asterisk/parking.h | 2 | ||||
-rw-r--r-- | include/asterisk/pbx.h | 4 | ||||
-rw-r--r-- | include/asterisk/rtp_engine.h | 4 | ||||
-rw-r--r-- | include/asterisk/sorcery.h | 2 | ||||
-rw-r--r-- | include/asterisk/timing.h | 2 | ||||
-rw-r--r-- | include/asterisk/translate.h | 2 |
17 files changed, 59 insertions, 26 deletions
diff --git a/include/asterisk.h b/include/asterisk.h index 14e88e625..ab2a3ddef 100644 --- a/include/asterisk.h +++ b/include/asterisk.h @@ -271,4 +271,21 @@ struct ast_sched_context; #define __stringify_1(x) #x #define __stringify(x) __stringify_1(x) +#if defined(AST_IN_CORE) \ + || (!defined(AST_MODULE_SELF_SYM) \ + && (defined(STANDALONE) || defined(STANDALONE2) || defined(AST_NOT_MODULE))) + +#define AST_MODULE_SELF NULL + +#elif defined(AST_MODULE_SELF_SYM) + +/*! Retreive the 'struct ast_module *' for the current module. */ +#define AST_MODULE_SELF AST_MODULE_SELF_SYM() + +struct ast_module; +/* Internal/forward declaration, AST_MODULE_SELF should be used instead. */ +struct ast_module *AST_MODULE_SELF_SYM(void); + +#endif + #endif /* _ASTERISK_H */ diff --git a/include/asterisk/app.h b/include/asterisk/app.h index 6171dd4f2..3975fda7d 100644 --- a/include/asterisk/app.h +++ b/include/asterisk/app.h @@ -584,7 +584,7 @@ int ast_vm_is_registered(void); int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module); /*! \brief See \ref __ast_vm_register() */ -#define ast_vm_register(vm_table) __ast_vm_register(vm_table, ast_module_info ? ast_module_info->self : NULL) +#define ast_vm_register(vm_table) __ast_vm_register(vm_table, AST_MODULE_SELF) /*! * \brief Unregister the specified voicemail provider @@ -652,7 +652,7 @@ int ast_vm_greeter_is_registered(void); int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module); /*! \brief See \ref __ast_vm_greeter_register() */ -#define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, ast_module_info ? ast_module_info->self : NULL) +#define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, AST_MODULE_SELF) /*! * \brief Unregister the specified voicemail greeter provider diff --git a/include/asterisk/bridge_technology.h b/include/asterisk/bridge_technology.h index 01031e3a4..b83a51b69 100644 --- a/include/asterisk/bridge_technology.h +++ b/include/asterisk/bridge_technology.h @@ -182,7 +182,7 @@ struct ast_bridge_technology { int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *mod); /*! \brief See \ref __ast_bridge_technology_register() */ -#define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, ast_module_info->self) +#define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, AST_MODULE_SELF) /*! * \brief Unregister a bridge technology from use diff --git a/include/asterisk/bucket.h b/include/asterisk/bucket.h index c07fb0cbd..da83759ce 100644 --- a/include/asterisk/bucket.h +++ b/include/asterisk/bucket.h @@ -134,7 +134,7 @@ int ast_bucket_init(void); * * \note Once a scheme has been registered it can not be unregistered */ -#define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb) __ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb, ast_module_info ? ast_module_info->self : NULL) +#define ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb) __ast_bucket_scheme_register(name, bucket, file, create_cb, destroy_cb, AST_MODULE_SELF) /*! * \brief Register support for a specific scheme diff --git a/include/asterisk/cli.h b/include/asterisk/cli.h index 458ebc8aa..82363c15f 100644 --- a/include/asterisk/cli.h +++ b/include/asterisk/cli.h @@ -177,7 +177,7 @@ struct ast_cli_entry { const char * usage; /*!< Detailed usage information */ int inuse; /*!< For keeping track of usage */ - struct module *module; /*!< module this belongs to */ + struct ast_module *module; /*!< module this belongs to */ char *_full_cmd; /*!< built at load time from cmda[] */ int cmdlen; /*!< len up to the first invalid char [<{% */ /*! \brief This gets set in ast_cli_register() @@ -253,14 +253,19 @@ int ast_cli_command_multiple_full(int uid, int gid, int fd, size_t size, const c * \retval 0 on success * \retval -1 on failure */ -int ast_cli_register(struct ast_cli_entry *e); +#define ast_cli_register(e) __ast_cli_register(e, AST_MODULE_SELF) + +int __ast_cli_register(struct ast_cli_entry *e, struct ast_module *mod); /*! * \brief Register multiple commands * \param e pointer to first cli entry to register * \param len number of entries to register */ -int ast_cli_register_multiple(struct ast_cli_entry *e, int len); +#define ast_cli_register_multiple(e, len) \ + __ast_cli_register_multiple(e, len, AST_MODULE_SELF) + +int __ast_cli_register_multiple(struct ast_cli_entry *e, int len, struct ast_module *mod); /*! * \brief Unregisters a command or an array of commands diff --git a/include/asterisk/codec.h b/include/asterisk/codec.h index 28befec50..3873324b1 100644 --- a/include/asterisk/codec.h +++ b/include/asterisk/codec.h @@ -116,7 +116,7 @@ int __ast_codec_register(struct ast_codec *codec, struct ast_module *mod); * \retval 0 success * \retval -1 failure */ -#define ast_codec_register(codec) __ast_codec_register(codec, ast_module_info->self) +#define ast_codec_register(codec) __ast_codec_register(codec, AST_MODULE_SELF) /*! * \brief Retrieve a codec given a name, type, and sample rate diff --git a/include/asterisk/data.h b/include/asterisk/data.h index 3676b8df5..d6da1f7d6 100644 --- a/include/asterisk/data.h +++ b/include/asterisk/data.h @@ -360,7 +360,7 @@ struct ast_data_mapping_structure { */ int __ast_data_register(const char *path, const struct ast_data_handler *handler, const char *registrar, struct ast_module *mod); -#define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, ast_module_info->self) +#define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, AST_MODULE_SELF) #define ast_data_register_core(path, handler) __ast_data_register(path, handler, __FILE__, NULL) /*! @@ -376,7 +376,7 @@ int __ast_data_register(const char *path, const struct ast_data_handler *handler int __ast_data_register_multiple(const struct ast_data_entry *data_entries, size_t entries, const char *registrar, struct ast_module *mod); #define ast_data_register_multiple(data_entries, entries) \ - __ast_data_register_multiple(data_entries, entries, __FILE__, ast_module_info->self) + __ast_data_register_multiple(data_entries, entries, __FILE__, AST_MODULE_SELF) #define ast_data_register_multiple_core(data_entries, entries) \ __ast_data_register_multiple(data_entries, entries, __FILE__, NULL) diff --git a/include/asterisk/format.h b/include/asterisk/format.h index 3da2d8236..c99c8f3e8 100644 --- a/include/asterisk/format.h +++ b/include/asterisk/format.h @@ -247,7 +247,7 @@ int __ast_format_interface_register(const char *codec, const struct ast_format_i * \retval 0 success * \retval -1 failure */ -#define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, ast_module_info->self) +#define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, AST_MODULE_SELF) /*! * \brief Get the attribute data on a format diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index b5ede545e..1ec1cbae3 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -180,10 +180,10 @@ struct manager_action { /*! \brief External routines may register/unregister manager callbacks this way * \note Use ast_manager_register2() to register with help text for new manager commands */ -#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, ast_module_info->self, synopsis, NULL) +#define ast_manager_register(action, authority, func, synopsis) ast_manager_register2(action, authority, func, AST_MODULE_SELF, synopsis, NULL) /*! \brief Register a manager callback using XML documentation to describe the manager. */ -#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, ast_module_info->self, NULL, NULL) +#define ast_manager_register_xml(action, authority, func) ast_manager_register2(action, authority, func, AST_MODULE_SELF, NULL, NULL) /*! * \brief Register a manager callback using XML documentation to describe the manager. diff --git a/include/asterisk/mod_format.h b/include/asterisk/mod_format.h index 7f17741fa..bcd31deaa 100644 --- a/include/asterisk/mod_format.h +++ b/include/asterisk/mod_format.h @@ -128,7 +128,7 @@ struct ast_filestream { * \retval -1 on failure */ int __ast_format_def_register(const struct ast_format_def *f, struct ast_module *mod); -#define ast_format_def_register(f) __ast_format_def_register(f, ast_module_info->self) +#define ast_format_def_register(f) __ast_format_def_register(f, AST_MODULE_SELF) /*! * \brief Unregisters a file format 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. diff --git a/include/asterisk/parking.h b/include/asterisk/parking.h index a8832cdb8..4c93c3b45 100644 --- a/include/asterisk/parking.h +++ b/include/asterisk/parking.h @@ -196,7 +196,7 @@ struct ast_parking_bridge_feature_fn_table { int (* parking_park_bridge_channel)(struct ast_bridge_channel *parkee, const char *parkee_uuid, const char *parker_uuid, const char *app_data); /*! \brief The module info for the module registering this parking provider */ - const struct ast_module_info *module_info; + struct ast_module *module; }; /*! diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index 795af0584..c09de982a 100644 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -1406,7 +1406,7 @@ enum ast_custom_function_escalation { /*! * \brief Register a custom function */ -#define ast_custom_function_register(acf) __ast_custom_function_register(acf, ast_module_info->self) +#define ast_custom_function_register(acf) __ast_custom_function_register(acf, AST_MODULE_SELF) /*! * \brief Register a custom function which requires escalated privileges. @@ -1415,7 +1415,7 @@ enum ast_custom_function_escalation { * arbitrary code) or FILE() (for which write needs permission to change files * on the filesystem). */ -#define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, ast_module_info->self) +#define ast_custom_function_register_escalating(acf, escalation) __ast_custom_function_register_escalating(acf, escalation, AST_MODULE_SELF) /*! * \brief Register a custom function diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h index a1a17da43..a94cb4213 100644 --- a/include/asterisk/rtp_engine.h +++ b/include/asterisk/rtp_engine.h @@ -643,7 +643,7 @@ struct ast_rtp_glue { */ struct ast_rtp_payload_type *ast_rtp_engine_alloc_payload_type(void); -#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self) +#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, AST_MODULE_SELF) /*! * \brief Register an RTP engine @@ -696,7 +696,7 @@ int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_ void ast_rtp_engine_unregister_srtp(void); int ast_rtp_engine_srtp_is_registered(void); -#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self) +#define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, AST_MODULE_SELF) /*! * \brief Register RTP glue diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h index 874dac207..a5061c6ab 100644 --- a/include/asterisk/sorcery.h +++ b/include/asterisk/sorcery.h @@ -366,7 +366,7 @@ int __ast_sorcery_wizard_register(const struct ast_sorcery_wizard *interface, st /*! * \brief See \ref __ast_sorcery_wizard_register() */ -#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, ast_module_info ? ast_module_info->self : NULL) +#define ast_sorcery_wizard_register(interface) __ast_sorcery_wizard_register(interface, AST_MODULE_SELF) /*! * \brief Unregister a sorcery wizard diff --git a/include/asterisk/timing.h b/include/asterisk/timing.h index ff4947a0a..268200375 100644 --- a/include/asterisk/timing.h +++ b/include/asterisk/timing.h @@ -92,7 +92,7 @@ struct ast_timing_interface { * \retval non-Null handle to be passed to ast_unregister_timing_interface() on success * \since 1.6.1 */ -#define ast_register_timing_interface(i) _ast_register_timing_interface(i, ast_module_info->self) +#define ast_register_timing_interface(i) _ast_register_timing_interface(i, AST_MODULE_SELF) void *_ast_register_timing_interface(struct ast_timing_interface *funcs, struct ast_module *mod); diff --git a/include/asterisk/translate.h b/include/asterisk/translate.h index e8e4c02d2..87e9a2cab 100644 --- a/include/asterisk/translate.h +++ b/include/asterisk/translate.h @@ -241,7 +241,7 @@ struct ast_trans_pvt; int __ast_register_translator(struct ast_translator *t, struct ast_module *module); /*! \brief See \ref __ast_register_translator() */ -#define ast_register_translator(t) __ast_register_translator(t, ast_module_info->self) +#define ast_register_translator(t) __ast_register_translator(t, AST_MODULE_SELF) /*! * \brief Unregister a translator |