Kaydet (Commit) 445c647a authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

add a configure option to make assert() abort in release code

Change-Id: I93720ee3338426174b31a6ea6dba3af7ffb7e207
üst b42094b2
......@@ -21,6 +21,7 @@ export ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR=@ANDROID_NDK_TOOLCHAIN_VERSION_SUBDI
export ANDROID_NDK_GDBSERVER=@ANDROID_NDK_GDBSERVER@
export ANDROID_SDK_HOME=@ANDROID_SDK_HOME@
export AR=@AR@
export ASSERT_ALWAYS_ABORT=@ASSERT_ALWAYS_ABORT@
export ATL_INCLUDE=@ATL_INCLUDE@
export ATL_LIB=@ATL_LIB@
export AWTLIB=@AWTLIB@
......
......@@ -756,6 +756,11 @@ AC_ARG_ENABLE(werror,
of warnings as errors is disabled explicitly.)]),
,)
AC_ARG_ENABLE(assert-always-abort,
AS_HELP_STRING([--enable-assert-always-abort],
[make assert() abort even in release code.]),
,)
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[Include debugging information like with --enable-symbols, disable
......@@ -4011,6 +4016,18 @@ else
fi
AC_SUBST(EXTERNAL_WARNINGS_NOT_ERRORS)
dnl Set the ASSERT_ALWAYS_ABORT variable. (Activate --enable-assert-always-abort)
dnl ===================================================================
AC_MSG_CHECKING([whether to have assert to abort in release code])
if test -n "$enable_assert_always_abort" -a "$enable_assert_always_abort" = "yes"; then
ASSERT_ALWAYS_ABORT="TRUE"
AC_MSG_RESULT([yes])
else
ASSERT_ALWAYS_ABORT="FALSE"
AC_MSG_RESULT([no])
fi
AC_SUBST(ASSERT_ALWAYS_ABORT)
dnl Set the ENABLE_DEBUG variable.
dnl ===================================================================
AC_MSG_CHECKING([whether to do a debug build])
......
......@@ -31,6 +31,22 @@
#include <stddef.h>
/* we want to be able to compile release code while retaining the abort capabilities of assert().
* This presume that this include is called early... i.e before anyone else included assert.h
* which should more often than not be the case since macros.h is included by sal/types.h
* which is included at the top of most source (or should be)
*/
#ifdef ASSERT_ALWAYS_ABORT
# ifdef NDEBUG
# undef NDEBUG
# include <assert.h>
# define NDEBUG
# else /* Ndef NDEBUG */
# include <assert.h>
# endif /* Ndef NDEBUG */
#else /* NDef ASSERT_ALWAYS_ABORT */
# include <assert.h>
#endif /* NDef ASSERT_ALWAYS_ABORT */
#ifndef SAL_N_ELEMENTS
# if defined(__cplusplus) && ( defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L )
......
......@@ -228,6 +228,12 @@ gb_GLOBALDEFS += \
endif
endif
ifeq ($(strip $(ASSERT_ALWAYS_ABORT)),TRUE)
gb_GLOBALDEFS += \
-DASSERT_ALWAYS_ABORT \
endif
ifneq ($(strip $(ENABLE_GTK)),)
gb_GLOBALDEFS += -DENABLE_GTK
endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment