diff options
author | Joshua Colp <jcolp@digium.com> | 2017-11-17 09:26:33 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-11-17 09:26:33 -0600 |
commit | 4dac92b99a2becf88d493b8ae1a0cdb714766e23 (patch) | |
tree | d16c42100ddd749738b037ebb6b9dd05a01b5092 | |
parent | b2c49d6c07d5ec2781c086c422ff8b90bf6a921c (diff) | |
parent | e9f8b317c38a36a8f4543ca77f785cb498ff567c (diff) |
Merge "Build: Make function constructor/destructor attributes mandatory."
-rw-r--r-- | autoconf/ast_gcc_attribute.m4 | 3 | ||||
-rwxr-xr-x | configure | 43 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | include/asterisk/optional_api.h | 4 |
4 files changed, 53 insertions, 4 deletions
diff --git a/autoconf/ast_gcc_attribute.m4 b/autoconf/ast_gcc_attribute.m4 index 4ade81404..b1972bedf 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) ) @@ -18177,6 +18177,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 @@ -18195,6 +18196,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 @@ -18222,6 +18224,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 @@ -18245,6 +18248,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 @@ -18263,6 +18267,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 @@ -18290,6 +18295,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 @@ -18313,6 +18319,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 @@ -18331,6 +18338,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 @@ -18358,6 +18366,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 @@ -18381,6 +18390,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 @@ -18399,6 +18409,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 @@ -18426,6 +18437,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 @@ -18449,6 +18461,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 @@ -18467,6 +18480,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 @@ -18494,6 +18508,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 @@ -18517,6 +18532,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 @@ -18535,6 +18551,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 @@ -18562,6 +18579,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 @@ -18585,6 +18603,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 @@ -18603,6 +18622,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 @@ -18630,6 +18650,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 @@ -18653,6 +18674,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 @@ -18671,6 +18693,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 @@ -18698,6 +18721,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 @@ -18721,6 +18745,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 @@ -18739,6 +18764,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 @@ -18766,6 +18792,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 @@ -18789,6 +18816,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 @@ -18807,6 +18835,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 @@ -18834,6 +18863,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 @@ -18851,12 +18881,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 @@ -18875,6 +18910,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 @@ -18902,6 +18938,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 @@ -18919,12 +18956,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 @@ -18943,6 +18984,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 @@ -18970,6 +19012,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 91da555a4..47c6b26d4 100644 --- a/configure.ac +++ b/configure.ac @@ -1150,7 +1150,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 1118dc7cd..1ac765162 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. |