Add -fnested-functions compile flag, if needed.

In order to use nested functions on some versions of GCC (e.g. GCC on OS X),
the -fnested-functions flag must be passed to the compiler. This patch adds
detection logic to ./configure to add the flag if necessary. It also adds
a comment to utils.h as to why the nested function needs a prototype.

(closes issue ASTERISK-20399)
Reported by: David M. Lee
Review: https://reviewboard.asterisk.org/r/2102/
........

Merged revisions 373119 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@373120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2012-09-18 15:50:35 +00:00
parent b0f01e5a6f
commit f8d815e19f
6 changed files with 5326 additions and 32615 deletions

View File

@@ -184,7 +184,7 @@ ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
_ASTCFLAGS+=-Wall _ASTCFLAGS+=-Wall
endif endif
_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_NESTED_FUNCTIONS) $(DEBUG)
ADDL_TARGETS= ADDL_TARGETS=
ifeq ($(AST_DEVMODE),yes) ifeq ($(AST_DEVMODE),yes)

37154
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1038,6 +1038,18 @@ else
fi fi
AC_SUBST(AST_NATIVE_ARCH) AC_SUBST(AST_NATIVE_ARCH)
dnl Nested functions required for RAII implementation
AC_MSG_CHECKING(for -fnested-functions)
AC_COMPILE_IFELSE(
dnl Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774
[AC_LANG_PROGRAM([], [auto void foo(void); void foo(void) {}])],
AC_MSG_RESULT(no)
[AST_NESTED_FUNCTIONS=],
AC_MSG_RESULT(required)
[AST_NESTED_FUNCTIONS=-fnested-functions]
)
AC_SUBST(AST_NESTED_FUNCTIONS)
AC_MSG_CHECKING(for sysinfo) AC_MSG_CHECKING(for sysinfo)
AC_LINK_IFELSE( AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <sys/sysinfo.h>], [AC_LANG_PROGRAM([#include <sys/sysinfo.h>],

View File

@@ -845,19 +845,19 @@
/* Define to 1 if you have the `strtoq' function. */ /* Define to 1 if you have the `strtoq' function. */
#undef HAVE_STRTOQ #undef HAVE_STRTOQ
/* Define to 1 if `ifr_ifru.ifru_hwaddr' is member of `struct ifreq'. */ /* Define to 1 if `ifr_ifru.ifru_hwaddr' is a member of `struct ifreq'. */
#undef HAVE_STRUCT_IFREQ_IFR_IFRU_IFRU_HWADDR #undef HAVE_STRUCT_IFREQ_IFR_IFRU_IFRU_HWADDR
/* Define to 1 if `uid' is member of `struct sockpeercred'. */ /* Define to 1 if `uid' is a member of `struct sockpeercred'. */
#undef HAVE_STRUCT_SOCKPEERCRED_UID #undef HAVE_STRUCT_SOCKPEERCRED_UID
/* Define to 1 if `st_blksize' is member of `struct stat'. */ /* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE #undef HAVE_STRUCT_STAT_ST_BLKSIZE
/* Define to 1 if `cr_uid' is member of `struct ucred'. */ /* Define to 1 if `cr_uid' is a member of `struct ucred'. */
#undef HAVE_STRUCT_UCRED_CR_UID #undef HAVE_STRUCT_UCRED_CR_UID
/* Define to 1 if `uid' is member of `struct ucred'. */ /* Define to 1 if `uid' is a member of `struct ucred'. */
#undef HAVE_STRUCT_UCRED_UID #undef HAVE_STRUCT_UCRED_UID
/* Define to 1 if you have the mISDN Supplemental Services library. */ /* Define to 1 if you have the mISDN Supplemental Services library. */
@@ -1135,6 +1135,9 @@
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME #undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */ /* Define to the version of this package. */
#undef PACKAGE_VERSION #undef PACKAGE_VERSION

View File

@@ -919,8 +919,9 @@ char *ast_utils_which(const char *binary, char *fullpath, size_t fullpath_size);
* \endcode * \endcode
*/ */
#define RAII_VAR(vartype, varname, initval, dtor) \ #define RAII_VAR(vartype, varname, initval, dtor) \
/* Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774 */ \
auto void _dtor_ ## varname (vartype * v); \ auto void _dtor_ ## varname (vartype * v); \
auto void _dtor_ ## varname (vartype * v) { dtor(*v); } \ void _dtor_ ## varname (vartype * v) { dtor(*v); } \
vartype varname __attribute__((cleanup(_dtor_ ## varname))) = (initval) vartype varname __attribute__((cleanup(_dtor_ ## varname))) = (initval)
#endif /* _ASTERISK_UTILS_H */ #endif /* _ASTERISK_UTILS_H */

View File

@@ -105,6 +105,7 @@ AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@
AST_TRAMPOLINES=@AST_TRAMPOLINES@ AST_TRAMPOLINES=@AST_TRAMPOLINES@
AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@ AST_NO_STRICT_OVERFLOW=@AST_NO_STRICT_OVERFLOW@
AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@ AST_SHADOW_WARNINGS=@AST_SHADOW_WARNINGS@
AST_NESTED_FUNCTIONS=@AST_NESTED_FUNCTIONS@
AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@ AST_FORTIFY_SOURCE=@AST_FORTIFY_SOURCE@
AST_MARCH_NATIVE=@AST_MARCH_NATIVE@ AST_MARCH_NATIVE=@AST_MARCH_NATIVE@