[Asterisk-code-review] Build: Make function constructor/destructor attributes manda... (asterisk[13])
Corey Farrell
asteriskteam at digium.com
Mon Nov 13 07:57:30 CST 2017
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7203
Change subject: Build: Make function constructor/destructor attributes mandatory.
......................................................................
Build: Make function constructor/destructor attributes mandatory.
This change causes the configure script to fail if the C compiler does
not support both function attributes constructor and destructor. These
were already required as modules cannot function without these attributes
and Asterisk requires modules.
This also has AST_GCC_ATTRIBUTE set a variable
ax_cv_have_func_attribute_$1. This is the same variable name used by
autoconf-archive's AX_GCC_FUNC_ATTRIBUTE, used for the same purpose.
Change-Id: Id68e8a1447f2a6d707c54b56350e7bfdb33fb663
---
M autoconf/ast_gcc_attribute.m4
M configure
M configure.ac
M include/asterisk/optional_api.h
4 files changed, 53 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/7203/1
diff --git a/autoconf/ast_gcc_attribute.m4 b/autoconf/ast_gcc_attribute.m4
index 4ade814..b1972be 100644
--- a/autoconf/ast_gcc_attribute.m4
+++ b/autoconf/ast_gcc_attribute.m4
@@ -7,6 +7,7 @@
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_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_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 d4271af..f64883b 100755
--- a/configure
+++ b/configure
@@ -17912,6 +17912,7 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 @@
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 @@
{ $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 @@
{ $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 da04005..30ff4ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1122,7 +1122,14 @@
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 394aed0..8d1498c 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.
--
To view, visit https://gerrit.asterisk.org/7203
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id68e8a1447f2a6d707c54b56350e7bfdb33fb663
Gerrit-Change-Number: 7203
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171113/75bba6a3/attachment.html>
More information about the asterisk-code-review
mailing list