[Asterisk-code-review] Build: Make function constructor/destructor attributes manda... (asterisk[15])

Jenkins2 asteriskteam at digium.com
Fri Nov 17 09:45:12 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7202 )

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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



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 9a8fb40..70553fc 100755
--- a/configure
+++ b/configure
@@ -18139,6 +18139,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_pure=0
 
 if test "x" = "x"
 then
@@ -18157,6 +18158,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
@@ -18184,6 +18186,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
@@ -18207,6 +18210,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_malloc=0
 
 if test "x" = "x"
 then
@@ -18225,6 +18229,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
@@ -18252,6 +18257,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
@@ -18275,6 +18281,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_const=0
 
 if test "x" = "x"
 then
@@ -18293,6 +18300,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
@@ -18320,6 +18328,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
@@ -18343,6 +18352,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_unused=0
 
 if test "x" = "x"
 then
@@ -18361,6 +18371,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
@@ -18388,6 +18399,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
@@ -18411,6 +18423,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_always_inline=0
 
 if test "x" = "x"
 then
@@ -18429,6 +18442,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
@@ -18456,6 +18470,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
@@ -18479,6 +18494,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_deprecated=0
 
 if test "x" = "x"
 then
@@ -18497,6 +18513,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
@@ -18524,6 +18541,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
@@ -18547,6 +18565,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_sentinel=0
 
 if test "x" = "x"
 then
@@ -18565,6 +18584,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
@@ -18592,6 +18612,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
@@ -18615,6 +18636,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_warn_unused_result=0
 
 if test "x" = "x"
 then
@@ -18633,6 +18655,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
@@ -18660,6 +18683,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
@@ -18683,6 +18707,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_may_alias=0
 
 if test "x" = "x"
 then
@@ -18701,6 +18726,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
@@ -18728,6 +18754,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
@@ -18751,6 +18778,7 @@
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
 
+ax_cv_have_func_attribute_constructor=0
 
 if test "x" = "x"
 then
@@ -18769,6 +18797,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
@@ -18796,6 +18825,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
@@ -18813,12 +18843,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
@@ -18837,6 +18872,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
@@ -18864,6 +18900,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
@@ -18881,12 +18918,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
@@ -18905,6 +18946,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
@@ -18932,6 +18974,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 23ff526..f5c160c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1149,7 +1149,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 1118dc7..1ac7651 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/7202
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Id68e8a1447f2a6d707c54b56350e7bfdb33fb663
Gerrit-Change-Number: 7202
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171117/a164d2c9/attachment-0001.html>


More information about the asterisk-code-review mailing list