[sheepdog] [PATCH] configure: enabling assert() in default

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Fri Aug 15 08:19:02 CEST 2014


At Fri, 15 Aug 2014 11:01:41 +0900,
Hitoshi Mitake wrote:
> 
> Enabling assert in default is better for development. This patch adds
> options for configure script: --enable-assert and --disable-assert. If
> a user want to disable assert, passing --disable-assert is required.
> 
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>  configure.ac   | 11 +++++++++++
>  include/util.h |  4 ++--
>  2 files changed, 13 insertions(+), 2 deletions(-)

Applied.

Thanks,
Hitoshi

> 
> diff --git a/configure.ac b/configure.ac
> index 6a9e552..f78aa3b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -206,6 +206,10 @@ AC_ARG_ENABLE([debug],
>  	[  --enable-debug          : enable debug build. ],
>  	[ default="no" ])
>  
> +AC_ARG_ENABLE([assert],
> +	[  --enable-assert          : enable assert. ],,
> +	[ enable_assert="yes" ],)
> +
>  AC_ARG_ENABLE([unittest],
>  	[  --enable-unittest       : enable unittest. ],
>  	[ default="no" ])
> @@ -295,6 +299,13 @@ else
>  	OPT_CFLAGS="-DNDEBUG"
>  fi
>  
> +if test "x${enable_assert}" = xyes; then
> +	AC_DEFINE_UNQUOTED([ASSERT], [1], [Enabling assert])
> +	PACKAGE_FEATURES="$PACKAGE_FEATURES assert"
> +else
> +	OPT_CFLAGS="-DNASSERT"
> +fi
> +
>  # gdb flags
>  if test "x${GCC}" = xyes; then
>  	GDB_FLAGS="-ggdb3"
> diff --git a/include/util.h b/include/util.h
> index d230f7f..9da872d 100644
> --- a/include/util.h
> +++ b/include/util.h
> @@ -215,7 +215,7 @@ double get_time_interval(const struct timespec *start,
>  #error "Don't include assert.h, use util.h for assert()"
>  #endif
>  
> -#ifndef NDEBUG
> +#ifndef NASSERT
>  #define assert(expr)						\
>  ({								\
>  	if (!(expr)) {						\
> @@ -225,7 +225,7 @@ double get_time_interval(const struct timespec *start,
>  })
>  #else
>  #define assert(expr) ((void)0)
> -#endif	/* NDEBUG */
> +#endif	/* NASSERT */
>  
>  #define SWAP(a, b) { typeof(a) tmp; tmp = a; a = b; b = tmp; }
>  
> -- 
> 1.8.3.2
> 



More information about the sheepdog mailing list