diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-30 04:22:33 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-09-30 04:22:33 +0000 |
commit | 669233d08dbd20b98eb5bb253860443a13495b1c (patch) | |
tree | 026a20b9f95b4b16255765de1be1c0dd7f913a54 /include | |
parent | fc1f5d6c20e119d54c33e0885f616cba27e771a7 (diff) |
Remove optional_api from 1.6.2 branch, since it is not currently working.
This is a blocking issue for the 1.6.2 release.
(closes issue #15914)
Reported by: mbeckwell
Branch: http://svn.digium.com/svn/asterisk/team/tilghman/optional_api_162
Tested by: mbeckwell
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@221042 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/agi.h | 22 | ||||
-rw-r--r-- | include/asterisk/monitor.h | 25 | ||||
-rw-r--r-- | include/asterisk/optional_api.h | 126 | ||||
-rw-r--r-- | include/asterisk/smdi.h | 42 |
4 files changed, 33 insertions, 182 deletions
diff --git a/include/asterisk/agi.h b/include/asterisk/agi.h index 36b60da7f..b3be6a06d 100644 --- a/include/asterisk/agi.h +++ b/include/asterisk/agi.h @@ -29,7 +29,6 @@ extern "C" { #include "asterisk/cli.h" #include "asterisk/xmldoc.h" -#include "asterisk/optional_api.h" typedef struct agi_state { int fd; /*!< FD for general output */ @@ -72,8 +71,7 @@ typedef struct agi_command { * \return 1 on success, 0 if the command is already registered * */ -AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd), - { return AST_OPTIONAL_API_UNAVAILABLE; }); +int ast_agi_register(struct ast_module *mod, agi_command *cmd) attribute_weak; /*! * \brief @@ -85,8 +83,7 @@ AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cm * \return 1 on success, 0 if the command was not already registered * */ -AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command *cmd), - { return AST_OPTIONAL_API_UNAVAILABLE; }); +int ast_agi_unregister(struct ast_module *mod, agi_command *cmd) attribute_weak; /*! * \brief @@ -97,14 +94,13 @@ AST_OPTIONAL_API(int, ast_agi_unregister, (struct ast_module *mod, agi_command * * \param mod Pointer to the module_info structure for the module that is registering the commands * \param cmd Pointer to the first entry in the array of command descriptors * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) - * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded + * \return 0 on success, -1 on failure * * \note If any command fails to register, all commands previously registered during the operation * will be unregistered. In other words, this function registers all the provided commands, or none * of them. */ -AST_OPTIONAL_API(int, ast_agi_register_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len), - { return AST_OPTIONAL_API_UNAVAILABLE; }); +int ast_agi_register_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len) attribute_weak; /*! * \brief @@ -115,13 +111,12 @@ AST_OPTIONAL_API(int, ast_agi_register_multiple, (struct ast_module *mod, struct * \param mod Pointer to the module_info structure for the module that is unregistering the commands * \param cmd Pointer to the first entry in the array of command descriptors * \param len Length of the array (use the ARRAY_LEN macro to determine this easily) - * \return 0 on success, -1 on failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded + * \return 0 on success, -1 on failure * * \note If any command fails to unregister, this function will continue to unregister the * remaining commands in the array; it will not reregister the already-unregistered commands. */ -AST_OPTIONAL_API(int, ast_agi_unregister_multiple, (struct ast_module *mod, struct agi_command *cmd, unsigned int len), - { return AST_OPTIONAL_API_UNAVAILABLE; }); +int ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd, unsigned int len) attribute_weak; /*! * \brief @@ -131,11 +126,10 @@ AST_OPTIONAL_API(int, ast_agi_unregister_multiple, (struct ast_module *mod, stru * \param fd The file descriptor for the AGI session (from struct agi_state) * \param chan Pointer to an associated Asterisk channel, if any * \param fmt printf-style format string - * \return 0 for success, -1 for failure, AST_OPTIONAL_API_UNAVAILABLE if res_agi is not loaded + * \return 0 for success, -1 for failure * */ -AST_OPTIONAL_API_ATTR(int, format(printf, 3, 4), ast_agi_send, (int fd, struct ast_channel *chan, char *fmt, ...), - { return AST_OPTIONAL_API_UNAVAILABLE; }); +int ast_agi_send(int fd, struct ast_channel *chan, char *fmt, ...) attribute_weak __attribute__((format(printf, 3, 4))); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/include/asterisk/monitor.h b/include/asterisk/monitor.h index 4014939bb..a732f6c12 100644 --- a/include/asterisk/monitor.h +++ b/include/asterisk/monitor.h @@ -24,7 +24,6 @@ #define _ASTERISK_MONITOR_H #include "asterisk/channel.h" -#include "asterisk/optional_api.h" enum AST_MONITORING_STATE { AST_MONITOR_RUNNING, @@ -51,27 +50,25 @@ struct ast_channel_monitor { }; /* Start monitoring a channel */ -AST_OPTIONAL_API(int, ast_monitor_start, (struct ast_channel *chan, const char - *format_spec, const char *fname_base, int need_lock, int stream_action), - { return -1; }); +int ast_monitor_start(struct ast_channel *chan, const char + *format_spec, const char *fname_base, int need_lock, int stream_action) + attribute_weak; /* Stop monitoring a channel */ -AST_OPTIONAL_API(int, ast_monitor_stop, (struct ast_channel *chan, int - need_lock), { return -1; }); +int ast_monitor_stop(struct ast_channel *chan, int need_lock) + attribute_weak; /* Change monitoring filename of a channel */ -AST_OPTIONAL_API(int, ast_monitor_change_fname, (struct ast_channel *chan, - const char *fname_base, int need_lock), { return -1; }); +int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, + int need_lock) attribute_weak; -AST_OPTIONAL_API(void, ast_monitor_setjoinfiles, (struct ast_channel *chan, - int turnon), { return; }); +void ast_monitor_setjoinfiles(struct ast_channel *chan, int turnon) + attribute_weak; /* Pause monitoring of a channel */ -AST_OPTIONAL_API(int, ast_monitor_pause, (struct ast_channel *chan), - { return -1; }); +int ast_monitor_pause(struct ast_channel *chan) attribute_weak; /* Unpause monitoring of a channel */ -AST_OPTIONAL_API(int, ast_monitor_unpause, (struct ast_channel *chan), - { return -1; }); +int ast_monitor_unpause(struct ast_channel *chan) attribute_weak; #endif /* _ASTERISK_MONITOR_H */ diff --git a/include/asterisk/optional_api.h b/include/asterisk/optional_api.h deleted file mode 100644 index 1af596ec1..000000000 --- a/include/asterisk/optional_api.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Asterisk -- An open source telephony toolkit. - * - * Copyright (C) 2008, Digium, Inc. - * - * Kevin P. Fleming <kpfleming@digium.com> - * - * See http://www.asterisk.org for more information about - * the Asterisk project. Please do not directly contact - * any of the maintainers of this project for assistance; - * the project provides a web site, mailing lists and IRC - * channels for your use. - * - * This program is free software, distributed under the terms of - * the GNU General Public License Version 2. See the LICENSE file - * at the top of the source tree. - */ - -#ifndef __ASTERISK_OPTIONAL_API_H -#define __ASTERISK_OPTIONAL_API_H - -/*! - * \file - * \brief Optional API function macros - * - * Some Asterisk API functions are provided by loadable modules, thus, - * they may or may not be available at run time depending on whether the - * providing module has been loaded or not. In addition, there are some - * modules that are consumers of these APIs that *optionally* use them; they - * have only a part of their functionality dependent on the APIs, and can - * provide the remainder even if the APIs are not available. - * - * To accomodate this situation, the AST_OPTIONAL_API macro allows an API - * function to be declared in a special way, if Asterisk being built on a - * platform that supports the GCC 'weak' and 'alias' attributes. If so, - * the API function is actually a weak symbol, which means if the provider - * of the API is not loaded, the symbol can still be referenced (unlike a - * strong symbol, which would cause an immediate fault if not defined when - * referenced), but it will return NULL signifying the linker/loader was - * not able to resolve the symbol. In addition, the macro defines a hidden - * 'stub' version of the API call, using a provided function body, and uses - * the alias attribute to make the API function symbol actually resolve to - * that hidden stub, but only when the *real* provider of the symbol has - * not been found. - * - * An example can be found in agi.h: - * - * \code - * AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd), - * { return AST_OPTIONAL_API_UNAVAILABLE; }); - * \endcode - * - * This defines the 'ast_agi_register' function as an optional API; if a - * consumer of this API is loaded when there is no provider of it, then - * calling this function will actually call the hidden stub, and return - * the value AST_OPTIONAL_API_UNAVAILABLE. This allows the consumer to - * safely know that the API is not available, and to avoid using any - * other APIs from the not-present provider. - * - * In the module providing the API, the AST_OPTIONAL_API macro must - * be informed that it should not build the hidden stub function or - * apply special aliases to the function prototype; this can be done - * by defining AST_API_MODULE just before including the header file - * containing the AST_OPTIONAL_API macro calls. - * - * \note If the GCC 'weak' and 'alias' attributes are not available, - * then the AST_OPTIONAL_API macro will result in a non-optional function - * definition; this means that any consumers of the API functions so - * defined will require that the provider of the API functions be - * loaded before they can reference the symbols. - */ - -#define __stringify_1(x) #x -#define __stringify(x) __stringify_1(x) - -/*! - * \brief A common value for optional API stub functions to return - * - * This value is defined as INT_MIN, the minimum value for an integer - * (maximum negative value), which can be used by any optional API - * functions that return a signed integer value and would not be - * able to return such a value under normal circumstances. - */ -#define AST_OPTIONAL_API_UNAVAILABLE INT_MIN - -#if defined(HAVE_ATTRIBUTE_weak_import) && !defined(AST_API_MODULE) -#define AST_OPTIONAL_API(result, name, proto, stub) result name proto __attribute__((weak_import)); -#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result name proto __attribute__((weak_import,attr)); -#elif defined(HAVE_ATTRIBUTE_weak) && defined(HAVE_ATTRIBUTE_alias) && !defined(AST_API_MODULE) && !defined(HAVE_ATTRIBUTE_weak_import) -#define AST_OPTIONAL_API(result, name, proto, stub) \ - static result __##name proto stub; \ - result __attribute__((weak, alias("__" __stringify(name)))) name proto; -#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ - static result __attribute__((attr)) __##name proto stub; \ - result __attribute__((weak, alias("__" __stringify(name)), attr)) name proto; -#else -/*! - * \brief Define an optional API function - * - * \param result The type of result the function returns - * \param name The name of the function - * \param proto The prototype (arguments) of the function - * \param stub The code block that will be used by the hidden stub when needed - * - * Example usage: - * \code - * AST_OPTIONAL_API(int, ast_agi_register, (struct ast_module *mod, agi_command *cmd), - * { return AST_OPTIONAL_API_UNAVAILABLE; }); - * \endcode - */ -#define AST_OPTIONAL_API(result, name, proto, stub) result name proto; -/*! - * \brief Define an optional API function with compiler attributes - * - * \param result The type of result the function returns - * \param attr Any compiler attributes to be applied to the function (without the __attribute__ wrapper) - * \param name The name of the function - * \param proto The prototype (arguments) of the function - * \param stub The code block that will be used by the hidden stub when needed - */ -#define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result __attribute__((attr)) name proto; -#endif - -#undef AST_API_MODULE - -#endif /* __ASTERISK_OPTIONAL_API_H */ diff --git a/include/asterisk/smdi.h b/include/asterisk/smdi.h index 9dbec6288..d5deb5e0d 100644 --- a/include/asterisk/smdi.h +++ b/include/asterisk/smdi.h @@ -37,7 +37,6 @@ #include "asterisk/config.h" #include "asterisk/module.h" #include "asterisk/astobj.h" -#include "asterisk/optional_api.h" #define SMDI_MESG_DESK_NUM_LEN 3 #define SMDI_MESG_DESK_TERM_LEN 4 @@ -85,8 +84,7 @@ struct ast_smdi_md_message { */ struct ast_smdi_interface; -AST_OPTIONAL_API(void, ast_smdi_interface_unref, (struct ast_smdi_interface - *iface), { return; }); +void ast_smdi_interface_unref(struct ast_smdi_interface *iface) attribute_weak; /*! * \brief Get the next SMDI message from the queue. @@ -98,8 +96,7 @@ AST_OPTIONAL_API(void, ast_smdi_interface_unref, (struct ast_smdi_interface * * \return the next SMDI message, or NULL if there were no pending messages. */ -AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop, (struct - ast_smdi_interface *iface), { return NULL; }); +struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface) attribute_weak; /*! * \brief Get the next SMDI message from the queue. @@ -113,8 +110,7 @@ AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop, (struct * \return the next SMDI message, or NULL if there were no pending messages and * the timeout has expired. */ -AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_wait, - (struct ast_smdi_interface *iface, int timeout), { return NULL; }); +struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout) attribute_weak; /*! * \brief Put an SMDI message back in the front of the queue. @@ -125,8 +121,7 @@ AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_wait, * should be used if a message was popped but is not going to be processed for * some reason, and the message needs to be returned to the queue. */ -AST_OPTIONAL_API(void, ast_smdi_md_message_putback, (struct ast_smdi_interface - *iface, struct ast_smdi_md_message *msg), { return; }); +void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg) attribute_weak; /*! * \brief Get the next SMDI message from the queue. @@ -138,8 +133,7 @@ AST_OPTIONAL_API(void, ast_smdi_md_message_putback, (struct ast_smdi_interface * * \return the next SMDI message, or NULL if there were no pending messages. */ -AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_pop, - (struct ast_smdi_interface *iface), { return NULL; }); +struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface) attribute_weak; /*! * \brief Get the next SMDI message from the queue. @@ -153,11 +147,9 @@ AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_pop, * \return the next SMDI message, or NULL if there were no pending messages and * the timeout has expired. */ -AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait, - (struct ast_smdi_interface *iface, int timeout), { return NULL; }); -AST_OPTIONAL_API(struct ast_smdi_mwi_message *, - ast_smdi_mwi_message_wait_station, (struct ast_smdi_interface *iface, int - timeout, const char *station), { return NULL; }); +struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout) attribute_weak; +struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait_station(struct ast_smdi_interface *iface, int + timeout, const char *station) attribute_weak; /*! * \brief Put an SMDI message back in the front of the queue. @@ -168,8 +160,7 @@ AST_OPTIONAL_API(struct ast_smdi_mwi_message *, * should be used if a message was popped but is not going to be processed for * some reason, and the message needs to be returned to the queue. */ -AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback, (struct ast_smdi_interface - *iface, struct ast_smdi_mwi_message *msg), { return; }); +void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg) attribute_weak; /*! * \brief Find an SMDI interface with the specified name. @@ -179,31 +170,26 @@ AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback, (struct ast_smdi_interface * actually returns an ASTOBJ reference and should be released using * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy). */ -AST_OPTIONAL_API(struct ast_smdi_interface *, ast_smdi_interface_find, - (const char *iface_name), { return NULL; }); +struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name) attribute_weak; /*! * \brief Set the MWI indicator for a mailbox. * \param iface the interface to use. * \param mailbox the mailbox to use. */ -AST_OPTIONAL_API(int, ast_smdi_mwi_set, (struct ast_smdi_interface *iface, - const char *mailbox), { return -1; }); +int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox) attribute_weak; /*! * \brief Unset the MWI indicator for a mailbox. * \param iface the interface to use. * \param mailbox the mailbox to use. */ -AST_OPTIONAL_API(int, ast_smdi_mwi_unset, (struct ast_smdi_interface *iface, - const char *mailbox), { return -1; }); +int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox) attribute_weak; /*! \brief ast_smdi_md_message destructor. */ -AST_OPTIONAL_API(void, ast_smdi_md_message_destroy, - (struct ast_smdi_md_message *msg), { return; }); +void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg) attribute_weak; /*! \brief ast_smdi_mwi_message destructor. */ -AST_OPTIONAL_API(void, ast_smdi_mwi_message_destroy, (struct - ast_smdi_mwi_message *msg), { return; }); +void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg) attribute_weak; #endif /* !ASTERISK_SMDI_H */ |