diff --git a/autoconf/ast_gcc_attribute.m4 b/autoconf/ast_gcc_attribute.m4 index 4ade81404a4bf3f3f845599fed69748897924541..b1972bedf38ecf5dd77fafb6004c3eab67b76060 100644 --- a/autoconf/ast_gcc_attribute.m4 +++ b/autoconf/ast_gcc_attribute.m4 @@ -7,6 +7,7 @@ AC_MSG_CHECKING(for compiler 'attribute $1' support) saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" m4_ifval([$4],$4=0) +ax_cv_have_func_attribute_$1=0 if test "x$2" = "x" then @@ -15,6 +16,7 @@ AC_COMPILE_IFELSE( [])], AC_MSG_RESULT(yes) m4_ifval([$4],$4=1) + ax_cv_have_func_attribute_$1=1 AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]), AC_MSG_RESULT(no) ) @@ -24,6 +26,7 @@ AC_COMPILE_IFELSE( [])], AC_MSG_RESULT(yes) m4_ifval([$4],$4=1) + ax_cv_have_func_attribute_$1=1 AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]), AC_MSG_RESULT(no) ) diff --git a/configure b/configure index d4271af8928a9837ba144de2e523268b7d384aed..f64883be1270233ed04c0f839cd3bc26ea609bdd 100755 --- a/configure +++ b/configure @@ -17912,6 +17912,7 @@ $as_echo_n "checking for compiler 'attribute pure' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_pure=0 if test "x" = "x" then @@ -17930,6 +17931,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_pure=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_pure 1 @@ -17957,6 +17959,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_pure=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_pure 1 @@ -17980,6 +17983,7 @@ $as_echo_n "checking for compiler 'attribute malloc' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_malloc=0 if test "x" = "x" then @@ -17998,6 +18002,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_malloc=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_malloc 1 @@ -18025,6 +18030,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_malloc=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_malloc 1 @@ -18048,6 +18054,7 @@ $as_echo_n "checking for compiler 'attribute const' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_const=0 if test "x" = "x" then @@ -18066,6 +18073,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_const=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_const 1 @@ -18093,6 +18101,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_const=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_const 1 @@ -18116,6 +18125,7 @@ $as_echo_n "checking for compiler 'attribute unused' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_unused=0 if test "x" = "x" then @@ -18134,6 +18144,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_unused=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_unused 1 @@ -18161,6 +18172,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_unused=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_unused 1 @@ -18184,6 +18196,7 @@ $as_echo_n "checking for compiler 'attribute always_inline' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_always_inline=0 if test "x" = "x" then @@ -18202,6 +18215,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_always_inline=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_always_inline 1 @@ -18229,6 +18243,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_always_inline=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_always_inline 1 @@ -18252,6 +18267,7 @@ $as_echo_n "checking for compiler 'attribute deprecated' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_deprecated=0 if test "x" = "x" then @@ -18270,6 +18286,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_deprecated=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_deprecated 1 @@ -18297,6 +18314,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_deprecated=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_deprecated 1 @@ -18320,6 +18338,7 @@ $as_echo_n "checking for compiler 'attribute sentinel' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_sentinel=0 if test "x" = "x" then @@ -18338,6 +18357,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_sentinel=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_sentinel 1 @@ -18365,6 +18385,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_sentinel=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_sentinel 1 @@ -18388,6 +18409,7 @@ $as_echo_n "checking for compiler 'attribute warn_unused_result' support... " >& saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_warn_unused_result=0 if test "x" = "x" then @@ -18406,6 +18428,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_warn_unused_result=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_warn_unused_result 1 @@ -18433,6 +18456,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_warn_unused_result=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_warn_unused_result 1 @@ -18456,6 +18480,7 @@ $as_echo_n "checking for compiler 'attribute may_alias' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_may_alias=0 if test "x" = "x" then @@ -18474,6 +18499,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_may_alias=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_may_alias 1 @@ -18501,6 +18527,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_may_alias=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_may_alias 1 @@ -18524,6 +18551,7 @@ $as_echo_n "checking for compiler 'attribute constructor' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_constructor=0 if test "x" = "x" then @@ -18542,6 +18570,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_constructor=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_constructor 1 @@ -18569,6 +18598,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_constructor=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_constructor 1 @@ -18586,12 +18616,17 @@ fi CFLAGS="$saved_CFLAGS" +if test "$ax_cv_have_func_attribute_constructor" != "1"; then + as_fn_error $? "*** Function constructor attribute is not supported by your compiler." "$LINENO" 5 +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler 'attribute destructor' support" >&5 $as_echo_n "checking for compiler 'attribute destructor' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_destructor=0 if test "x" = "x" then @@ -18610,6 +18645,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_destructor=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_destructor 1 @@ -18637,6 +18673,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_destructor=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_destructor 1 @@ -18654,12 +18691,16 @@ fi CFLAGS="$saved_CFLAGS" +if test "$ax_cv_have_func_attribute_destructor" != "1"; then + as_fn_error $? "*** Function destructor attribute is not supported by your compiler." "$LINENO" 5 +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler 'attribute noreturn' support" >&5 $as_echo_n "checking for compiler 'attribute noreturn' support... " >&6; } saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +ax_cv_have_func_attribute_noreturn=0 if test "xnoreturn" = "x" then @@ -18678,6 +18719,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_noreturn=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_noreturn 1 @@ -18705,6 +18747,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + ax_cv_have_func_attribute_noreturn=1 cat >>confdefs.h <<_ACEOF #define HAVE_ATTRIBUTE_noreturn 1 diff --git a/configure.ac b/configure.ac index da0400516b7fa0f0564023608284f56d7fae873a..30ff4ac3175b8c41cd10d5798aa48838a1781a96 100644 --- a/configure.ac +++ b/configure.ac @@ -1122,7 +1122,14 @@ AST_GCC_ATTRIBUTE(sentinel) AST_GCC_ATTRIBUTE(warn_unused_result) AST_GCC_ATTRIBUTE(may_alias) AST_GCC_ATTRIBUTE(constructor) +if test "$ax_cv_have_func_attribute_constructor" != "1"; then + AC_MSG_ERROR([*** Function constructor attribute is not supported by your compiler.]) +fi + AST_GCC_ATTRIBUTE(destructor) +if test "$ax_cv_have_func_attribute_destructor" != "1"; then + AC_MSG_ERROR([*** Function destructor attribute is not supported by your compiler.]) +fi AST_GCC_ATTRIBUTE(noreturn,noreturn) AC_MSG_CHECKING(for -fsanitize=address support) diff --git a/include/asterisk/optional_api.h b/include/asterisk/optional_api.h index 394aed0e4c01a21b8f078118ef7c64b42fcff02e..8d1498ca9ba711b607ffcfc2ec7060cf81242dd9 100644 --- a/include/asterisk/optional_api.h +++ b/include/asterisk/optional_api.h @@ -107,10 +107,6 @@ #if defined(OPTIONAL_API) -#if !defined(HAVE_ATTRIBUTE_constructor) || !defined(HAVE_ATTRIBUTE_constructor) -#error OPTIONAL_API requires compiler constructor/destructor support -#endif - /*! * \internal * \brief Function pointer to an optional API function.