From edc885ac79cee38da20f8e8b17ccc10fb625403e Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 27 Jun 2013 21:59:19 +0200 Subject: [PATCH] Adds support for the valgrind tool sgcheck. --- configure.ac | 12 ++++++++++-- sgcheck.supp | 7 +++++++ tommychain.h | 11 ++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 sgcheck.supp diff --git a/configure.ac b/configure.ac index 7e4ba7be..923737bc 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC AC_USE_SYSTEM_EXTENSIONS -AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind --leak-check=full --track-fds=yes --error-exitcode=1],[]) +AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[]) AC_CHECK_PROG([WINE],[wine],[wine],[]) AC_CHECK_PROG([ADVD2],[advd2],[advd2],[]) AM_CONDITIONAL(HAVE_ADVD2, [test x"$ADVD2" != x]) @@ -85,7 +85,15 @@ AC_ARG_ENABLE([coverage], AC_ARG_ENABLE([valgrind], [AS_HELP_STRING([--enable-valgrind],[enable the use of valgrind in testing])], [ - TESTENV="$VALGRIND" + TESTENV="$VALGRIND --leak-check=full --track-fds=yes --error-exitcode=1" + CFLAGS="$CFLAGS -DCHECKER" + ], + []) + +AC_ARG_ENABLE([sgcheck], + [AS_HELP_STRING([--enable-sgcheck],[enable the use of sgcheck in testing])], + [ + TESTENV="$VALGRIND --tool=exp-sgcheck --suppressions=sgcheck.supp --error-exitcode=1" CFLAGS="$CFLAGS -DCHECKER" ], []) diff --git a/sgcheck.supp b/sgcheck.supp new file mode 100644 index 00000000..76817cc4 --- /dev/null +++ b/sgcheck.supp @@ -0,0 +1,7 @@ +{ + printf reports false positves when printing more than one variables at time + exp-sgcheck:SorG + ... + fun:printf +} + diff --git a/tommychain.h b/tommychain.h index bc4a436d..bc9b3049 100644 --- a/tommychain.h +++ b/tommychain.h @@ -158,8 +158,10 @@ tommy_inline void tommy_chain_mergesort(tommy_chain* chain, tommy_compare_func* /* * Bit buckets of chains. * Each bucket contains 2^i nodes or it's empty. + * The chain at address TOMMY_CHAIN_BIT_MAX is an independet variable operating as "carry". + * We keep it in the same "bit" vector to avoid reports from the valgrind tool sgcheck. */ - tommy_chain bit[TOMMY_CHAIN_BIT_MAX]; + tommy_chain bit[TOMMY_CHAIN_BIT_MAX + 1]; /** * Value stored inside the bit bucket. @@ -174,13 +176,12 @@ tommy_inline void tommy_chain_mergesort(tommy_chain* chain, tommy_compare_func* counter = 0; while (1) { tommy_node* next; - tommy_chain carry; tommy_chain* last; /* carry bit to add */ - last = &carry; - carry.head = node; - carry.tail = node; + last = &bit[TOMMY_CHAIN_BIT_MAX]; + bit[TOMMY_CHAIN_BIT_MAX].head = node; + bit[TOMMY_CHAIN_BIT_MAX].tail = node; next = node->next; /* add the bit, propagating the carry */