mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
Add support for the clang compiler; update RAII_VAR to use BlocksRuntime
RAII_VAR, which is used extensively in Asterisk to manage reference counted resources, uses a GCC extension to automatically invoke a cleanup function when a variable loses scope. While this functionality is incredibly useful and has prevented a large number of memory leaks, it also prevents Asterisk from being compiled with clang. This patch updates the RAII_VAR macro such that it can be compiled with clang. It makes use of the BlocksRuntime, which allows for a closure to be created that performs the actual cleanup. Note that this does not attempt to address the numerous warnings that the clang compiler catches in Asterisk. Much thanks for this patch goes to: * The folks on StackOverflow who asked this question and Leushenko for providing the answer that formed the basis of this code: http://stackoverflow.com/questions/24959440/rewrite-gcc-cleanup-macro-with-nested-function-for-clang * Diederik de Groot, who has been extremely patient in working on getting this patch into Asterisk. Review: https://reviewboard.asterisk.org/r/4370/ ASTERISK-24133 ASTERISK-23666 ASTERISK-20399 ASTERISK-20850 #close Reported by: Diederik de Groot patches: RAII_CLANG.patch uploaded by Diederik de Groot (License 6600) ........ Merged revisions 432807 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 432808 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432809 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
61
configure
vendored
61
configure
vendored
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
# From configure.ac Revision: 431093 .
|
||||
# From configure.ac Revision: 432282 .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for asterisk trunk.
|
||||
#
|
||||
@@ -687,6 +687,8 @@ PBX_RTLD_NOLOAD
|
||||
PBX_GLOB_BRACE
|
||||
PBX_GLOB_NOMAGIC
|
||||
AST_RPATH
|
||||
AST_CLANG_BLOCKS
|
||||
AST_CLANG_BLOCKS_LIBS
|
||||
AST_NESTED_FUNCTIONS
|
||||
AST_NATIVE_ARCH
|
||||
AST_SHADOW_WARNINGS
|
||||
@@ -17305,7 +17307,7 @@ fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wtrampolines support" >&5
|
||||
$as_echo_n "checking for -Wtrampolines support... " >&6; }
|
||||
if $(${CC} -Wtrampolines -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
|
||||
if $(${CC} -Wtrampolines -Werror -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
AST_TRAMPOLINES=-Wtrampolines
|
||||
@@ -17374,11 +17376,29 @@ $as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fnested-functions" >&5
|
||||
$as_echo_n "checking for -fnested-functions... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
#if defined(__clang__)
|
||||
choke
|
||||
#endif
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc -fnested-functions" >&5
|
||||
$as_echo_n "checking for gcc -fnested-functions... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
@@ -17390,16 +17410,41 @@ _ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
AST_NESTED_FUNCTIONS=
|
||||
AST_NESTED_FUNCTIONS=
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: required" >&5
|
||||
$as_echo "required" >&6; }
|
||||
AST_NESTED_FUNCTIONS=-fnested-functions
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
AST_NESTED_FUNCTIONS=-fnested-functions
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
|
||||
else
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang -fblocks" >&5
|
||||
$as_echo_n "checking for clang -fblocks... " >&6; }
|
||||
if test "`echo "int main(){return ^{return 42;}();}" | ${CC} -o /dev/null -fblocks -x c - 2>&1`" = ""; then
|
||||
AST_CLANG_BLOCKS_LIBS=""
|
||||
AST_CLANG_BLOCKS="-Wno-unknown-warning-option -fblocks"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
elif test "`echo "int main(){return ^{return 42;}();}" | ${CC} -o /dev/null -fblocks -x c -lBlocksRuntime - 2>&1`" = ""; then
|
||||
AST_CLANG_BLOCKS_LIBS="-lBlocksRuntime"
|
||||
AST_CLANG_BLOCKS="-fblocks"
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
else
|
||||
as_fn_error $? "\"BlocksRuntime is required for clang\"" "$LINENO" 5
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
|
||||
# Check whether --enable-rpath was given.
|
||||
if test "${enable_rpath+set}" = set; then :
|
||||
enableval=$enable_rpath; case "${enableval}" in
|
||||
|
Reference in New Issue
Block a user