[asterisk-commits] kpfleming: trunk r153709 - in /trunk: ./ apps/ autoconf/ include/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Nov 2 17:34:40 CST 2008


Author: kpfleming
Date: Sun Nov  2 17:34:39 2008
New Revision: 153709

URL: http://svn.digium.com/view/asterisk?view=rev&rev=153709
Log:
instead of trying to forcibly load res_agi when app_stack is loaded (even if the administrator didn't want it loaded), use GCC weak symbols to determine whether it was loaded already or not; if it was loaded, then use it.


Modified:
    trunk/apps/app_stack.c
    trunk/autoconf/ast_gcc_attribute.m4
    trunk/configure
    trunk/configure.ac
    trunk/include/asterisk/agi.h
    trunk/include/asterisk/autoconfig.h.in
    trunk/include/asterisk/compiler.h

Modified: trunk/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_stack.c?view=diff&rev=153709&r1=153708&r2=153709
==============================================================================
--- trunk/apps/app_stack.c (original)
+++ trunk/apps/app_stack.c Sun Nov  2 17:34:39 2008
@@ -26,7 +26,7 @@
  */
 
 /*** MODULEINFO
-	<depend>res_agi</depend>
+	<use>res_agi</use>
  ***/
 
 #include "asterisk.h"
@@ -38,6 +38,9 @@
 #include "asterisk/app.h"
 #include "asterisk/manager.h"
 #include "asterisk/channel.h"
+
+/* usage of AGI is optional, so indicate that to the header file */
+#define ASTERISK_AGI_OPTIONAL
 #include "asterisk/agi.h"
 
 /*** DOCUMENTATION
@@ -104,7 +107,6 @@
 		</description>
 	</application>
  ***/
-static int agi_loaded = 0;
 
 static const char *app_gosub = "Gosub";
 static const char *app_gosubif = "GosubIf";
@@ -537,7 +539,7 @@
 {
 	struct ast_context *con;
 
-	if (agi_loaded) {
+	if (ast_agi_unregister) {
 		ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
 
 		if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
@@ -559,15 +561,10 @@
 {
 	struct ast_context *con;
 
-	if (!ast_module_check("res_agi.so")) {
-		if (ast_load_resource("res_agi.so") == AST_MODULE_LOAD_SUCCESS) {
-			agi_loaded = 1;
-		}
-	} else {
-		agi_loaded = 1;
-	}
-
-	if (agi_loaded) {
+	/* usage of AGI is optional, so check to see if the ast_agi_register()
+	   function is available; if so, use it.
+	*/
+	if (ast_agi_register) {
 		con = ast_context_find_or_create(NULL, NULL, "app_stack_gosub_virtual_context", "app_stack");
 		if (!con) {
 			ast_log(LOG_ERROR, "Virtual context 'app_stack_gosub_virtual_context' does not exist and unable to create\n");

Modified: trunk/autoconf/ast_gcc_attribute.m4
URL: http://svn.digium.com/view/asterisk/trunk/autoconf/ast_gcc_attribute.m4?view=diff&rev=153709&r1=153708&r2=153709
==============================================================================
--- trunk/autoconf/ast_gcc_attribute.m4 (original)
+++ trunk/autoconf/ast_gcc_attribute.m4 Sun Nov  2 17:34:39 2008
@@ -7,7 +7,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE(
-	AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
+	AC_LANG_PROGRAM([void __attribute__(($1)) *test(void *muffin, ...) {}],
 			[]),
 	AC_MSG_RESULT(yes)
 	AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),

Modified: trunk/configure.ac
URL: http://svn.digium.com/view/asterisk/trunk/configure.ac?view=diff&rev=153709&r1=153708&r2=153709
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sun Nov  2 17:34:39 2008
@@ -472,6 +472,7 @@
 AST_GCC_ATTRIBUTE(deprecated)
 AST_GCC_ATTRIBUTE(sentinel)
 AST_GCC_ATTRIBUTE(warn_unused_result)
+AST_GCC_ATTRIBUTE(weak)
 
 AC_MSG_CHECKING(for -ffunction-sections support)
 saved_CFLAGS="${CFLAGS}"

Modified: trunk/include/asterisk/agi.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/agi.h?view=diff&rev=153709&r1=153708&r2=153709
==============================================================================
--- trunk/include/asterisk/agi.h (original)
+++ trunk/include/asterisk/agi.h Sun Nov  2 17:34:39 2008
@@ -55,11 +55,17 @@
 	AST_LIST_ENTRY(agi_command) list;
 } agi_command;
 
-int ast_agi_fdprintf(struct ast_channel *chan, int fd, char *fmt, ...);
-int ast_agi_register(struct ast_module *mod, agi_command *cmd);
-int ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
-void ast_agi_register_multiple(struct ast_module *mod, agi_command *cmd, int len);
-void ast_agi_unregister_multiple(struct ast_module *mod, agi_command *cmd, int len);
+#if defined(ASTERISK_AGI_OPTIONAL)
+#define AGI_WEAK attribute_weak
+#else
+#define AGI_WEAK
+#endif
+
+int AGI_WEAK ast_agi_fdprintf(struct ast_channel *chan, int fd, char *fmt, ...);
+int AGI_WEAK ast_agi_register(struct ast_module *mod, agi_command *cmd);
+int AGI_WEAK ast_agi_unregister(struct ast_module *mod, agi_command *cmd);
+void AGI_WEAK ast_agi_register_multiple(struct ast_module *mod, agi_command *cmd, int len);
+void AGI_WEAK ast_agi_unregister_multiple(struct ast_module *mod, agi_command *cmd, int len);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: trunk/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/autoconfig.h.in?view=diff&rev=153709&r1=153708&r2=153709
==============================================================================
--- trunk/include/asterisk/autoconfig.h.in (original)
+++ trunk/include/asterisk/autoconfig.h.in Sun Nov  2 17:34:39 2008
@@ -116,6 +116,9 @@
 /* Define to 1 if your GCC C compiler supports the 'warn_unused_result'
    attribute. */
 #undef HAVE_ATTRIBUTE_warn_unused_result
+
+/* Define to 1 if your GCC C compiler supports the 'weak' attribute. */
+#undef HAVE_ATTRIBUTE_weak
 
 /* Define this to indicate the ${BKTR_DESCRIP} library */
 #undef HAVE_BKTR

Modified: trunk/include/asterisk/compiler.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/compiler.h?view=diff&rev=153709&r1=153708&r2=153709
==============================================================================
--- trunk/include/asterisk/compiler.h (original)
+++ trunk/include/asterisk/compiler.h Sun Nov  2 17:34:39 2008
@@ -68,4 +68,10 @@
 /* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
 #define SENTINEL ((char *)NULL)
 
+#ifdef HAVE_ATTRIBUTE_weak
+#define attribute_weak __attribute__((weak))
+#else
+#define attribute_weak
+#endif
+
 #endif /* _ASTERISK_COMPILER_H */




More information about the asterisk-commits mailing list