<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7203">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Build: Make function constructor/destructor attributes mandatory.<br><br>This change causes the configure script to fail if the C compiler does<br>not support both function attributes constructor and destructor. These<br>were already required as modules cannot function without these attributes<br>and Asterisk requires modules.<br><br>This also has AST_GCC_ATTRIBUTE set a variable<br>ax_cv_have_func_attribute_$1. This is the same variable name used by<br>autoconf-archive's AX_GCC_FUNC_ATTRIBUTE, used for the same purpose.<br><br>Change-Id: Id68e8a1447f2a6d707c54b56350e7bfdb33fb663<br>---<br>M autoconf/ast_gcc_attribute.m4<br>M configure<br>M configure.ac<br>M include/asterisk/optional_api.h<br>4 files changed, 53 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/7203/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/autoconf/ast_gcc_attribute.m4 b/autoconf/ast_gcc_attribute.m4<br>index 4ade814..b1972be 100644<br>--- a/autoconf/ast_gcc_attribute.m4<br>+++ b/autoconf/ast_gcc_attribute.m4<br>@@ -7,6 +7,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> m4_ifval([$4],$4=0)<br>+ax_cv_have_func_attribute_$1=0<br> <br> if test "x$2" = "x"<br> then<br>@@ -15,6 +16,7 @@<br> [])],<br> AC_MSG_RESULT(yes)<br> m4_ifval([$4],$4=1)<br>+ ax_cv_have_func_attribute_$1=1<br> AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),<br> AC_MSG_RESULT(no)<br> )<br>@@ -24,6 +26,7 @@<br> [])],<br> AC_MSG_RESULT(yes)<br> m4_ifval([$4],$4=1)<br>+ ax_cv_have_func_attribute_$1=1<br> AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),<br> AC_MSG_RESULT(no)<br> )<br>diff --git a/configure b/configure<br>index d4271af..f64883b 100755<br>--- a/configure<br>+++ b/configure<br>@@ -17912,6 +17912,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_pure=0<br> <br> if test "x" = "x"<br> then<br>@@ -17930,6 +17931,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_pure=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_pure 1<br>@@ -17957,6 +17959,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_pure=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_pure 1<br>@@ -17980,6 +17983,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_malloc=0<br> <br> if test "x" = "x"<br> then<br>@@ -17998,6 +18002,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_malloc=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_malloc 1<br>@@ -18025,6 +18030,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_malloc=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_malloc 1<br>@@ -18048,6 +18054,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_const=0<br> <br> if test "x" = "x"<br> then<br>@@ -18066,6 +18073,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_const=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_const 1<br>@@ -18093,6 +18101,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_const=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_const 1<br>@@ -18116,6 +18125,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_unused=0<br> <br> if test "x" = "x"<br> then<br>@@ -18134,6 +18144,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_unused=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_unused 1<br>@@ -18161,6 +18172,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_unused=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_unused 1<br>@@ -18184,6 +18196,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_always_inline=0<br> <br> if test "x" = "x"<br> then<br>@@ -18202,6 +18215,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_always_inline=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_always_inline 1<br>@@ -18229,6 +18243,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_always_inline=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_always_inline 1<br>@@ -18252,6 +18267,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_deprecated=0<br> <br> if test "x" = "x"<br> then<br>@@ -18270,6 +18286,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_deprecated=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_deprecated 1<br>@@ -18297,6 +18314,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_deprecated=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_deprecated 1<br>@@ -18320,6 +18338,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_sentinel=0<br> <br> if test "x" = "x"<br> then<br>@@ -18338,6 +18357,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_sentinel=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_sentinel 1<br>@@ -18365,6 +18385,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_sentinel=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_sentinel 1<br>@@ -18388,6 +18409,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_warn_unused_result=0<br> <br> if test "x" = "x"<br> then<br>@@ -18406,6 +18428,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_warn_unused_result=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_warn_unused_result 1<br>@@ -18433,6 +18456,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_warn_unused_result=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_warn_unused_result 1<br>@@ -18456,6 +18480,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_may_alias=0<br> <br> if test "x" = "x"<br> then<br>@@ -18474,6 +18499,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_may_alias=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_may_alias 1<br>@@ -18501,6 +18527,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_may_alias=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_may_alias 1<br>@@ -18524,6 +18551,7 @@<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_constructor=0<br> <br> if test "x" = "x"<br> then<br>@@ -18542,6 +18570,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_constructor=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_constructor 1<br>@@ -18569,6 +18598,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_constructor=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_constructor 1<br>@@ -18586,12 +18616,17 @@<br> CFLAGS="$saved_CFLAGS"<br> <br> <br>+if test "$ax_cv_have_func_attribute_constructor" != "1"; then<br>+ as_fn_error $? "*** Function constructor attribute is not supported by your compiler." "$LINENO" 5<br>+fi<br>+<br> <br> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler 'attribute destructor' support" >&5<br> $as_echo_n "checking for compiler 'attribute destructor' support... " >&6; }<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_destructor=0<br> <br> if test "x" = "x"<br> then<br>@@ -18610,6 +18645,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_destructor=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_destructor 1<br>@@ -18637,6 +18673,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_destructor=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_destructor 1<br>@@ -18654,12 +18691,16 @@<br> CFLAGS="$saved_CFLAGS"<br> <br> <br>+if test "$ax_cv_have_func_attribute_destructor" != "1"; then<br>+ as_fn_error $? "*** Function destructor attribute is not supported by your compiler." "$LINENO" 5<br>+fi<br> <br> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler 'attribute noreturn' support" >&5<br> $as_echo_n "checking for compiler 'attribute noreturn' support... " >&6; }<br> saved_CFLAGS="$CFLAGS"<br> CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"<br> <br>+ax_cv_have_func_attribute_noreturn=0<br> <br> if test "xnoreturn" = "x"<br> then<br>@@ -18678,6 +18719,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_noreturn=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_noreturn 1<br>@@ -18705,6 +18747,7 @@<br> { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5<br> $as_echo "yes" >&6; }<br> <br>+ ax_cv_have_func_attribute_noreturn=1<br> <br> cat >>confdefs.h <<_ACEOF<br> #define HAVE_ATTRIBUTE_noreturn 1<br>diff --git a/configure.ac b/configure.ac<br>index da04005..30ff4ac 100644<br>--- a/configure.ac<br>+++ b/configure.ac<br>@@ -1122,7 +1122,14 @@<br> AST_GCC_ATTRIBUTE(warn_unused_result)<br> AST_GCC_ATTRIBUTE(may_alias)<br> AST_GCC_ATTRIBUTE(constructor)<br>+if test "$ax_cv_have_func_attribute_constructor" != "1"; then<br>+ AC_MSG_ERROR([*** Function constructor attribute is not supported by your compiler.])<br>+fi<br>+<br> AST_GCC_ATTRIBUTE(destructor)<br>+if test "$ax_cv_have_func_attribute_destructor" != "1"; then<br>+ AC_MSG_ERROR([*** Function destructor attribute is not supported by your compiler.])<br>+fi<br> AST_GCC_ATTRIBUTE(noreturn,noreturn)<br> <br> AC_MSG_CHECKING(for -fsanitize=address support)<br>diff --git a/include/asterisk/optional_api.h b/include/asterisk/optional_api.h<br>index 394aed0..8d1498c 100644<br>--- a/include/asterisk/optional_api.h<br>+++ b/include/asterisk/optional_api.h<br>@@ -107,10 +107,6 @@<br> <br> #if defined(OPTIONAL_API)<br> <br>-#if !defined(HAVE_ATTRIBUTE_constructor) || !defined(HAVE_ATTRIBUTE_constructor)<br>-#error OPTIONAL_API requires compiler constructor/destructor support<br>-#endif<br>-<br> /*!<br> * \internal<br> * \brief Function pointer to an optional API function.<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7203">change 7203</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7203"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Id68e8a1447f2a6d707c54b56350e7bfdb33fb663 </div>
<div style="display:none"> Gerrit-Change-Number: 7203 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>