summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rwxr-xr-xconfigure2
-rw-r--r--gc.c28
-rw-r--r--lib.c10
-rw-r--r--lib.h2
-rw-r--r--txr.c2
-rw-r--r--txr.h2
7 files changed, 39 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index e1954b41..5bdc3375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2014-01-10 Kaz Kylheku <kaz@kylheku.com>
+
+ * configure: Generate HAVE_VALGRIND as #define-d to 1, rathern
+ than just fdefined.
+
+ * gc.c: Use #if HAVE_VALGRIND instaed of #ifdef HAVE_VALGRIND,
+ consistently with other HAVE_* config variables.
+
+ * lib.c: Likewise.
+
+ * lib.h: Likewise.
+
+ * txr.c: Likewise.
+
+ * txr.h: Likewise.
+
2014-01-09 Kaz Kylheku <kaz@kylheku.com>
Fix broken Json parsing test case on MinGW.
diff --git a/configure b/configure
index 791f6c6e..6a29cab3 100755
--- a/configure
+++ b/configure
@@ -1104,7 +1104,7 @@ syntax error
fi
printf "okay\n"
- printf "#define HAVE_VALGRIND\n" >> config.h
+ printf "#define HAVE_VALGRIND 1\n" >> config.h
fi
#
diff --git a/gc.c b/gc.c
index 33328b9e..fd1658bc 100644
--- a/gc.c
+++ b/gc.c
@@ -33,7 +33,7 @@
#include <wchar.h>
#include <signal.h>
#include "config.h"
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
#include <valgrind/memcheck.h>
#endif
#include "lib.h"
@@ -62,7 +62,7 @@ typedef struct mach_context {
#define save_context(X) setjmp((X).buf)
int opt_gc_debug;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
int opt_vg_debug;
#endif
static val *gc_stack_bottom;
@@ -139,7 +139,7 @@ static void more(void)
heap->next = heap_list;
heap_list = heap;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (opt_vg_debug)
VALGRIND_MAKE_MEM_NOACCESS(&heap->block, sizeof heap->block);
#endif
@@ -164,12 +164,12 @@ val make_obj(void)
for (tries = 0; tries < 3; tries++) {
if (free_list) {
val ret = free_list;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (opt_vg_debug)
VALGRIND_MAKE_MEM_DEFINED(free_list, sizeof *free_list);
#endif
free_list = free_list->t.next;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (opt_vg_debug)
VALGRIND_MAKE_MEM_UNDEFINED(ret, sizeof *ret);
#endif
@@ -359,11 +359,11 @@ static void mark_mem_region(val *low, val *high)
while (low < high) {
val maybe_obj = *low;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
VALGRIND_MAKE_MEM_DEFINED(&maybe_obj, sizeof maybe_obj);
#endif
if (in_heap(maybe_obj)) {
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (opt_vg_debug)
VALGRIND_MAKE_MEM_DEFINED(maybe_obj, SIZEOF_PTR);
#endif
@@ -371,7 +371,7 @@ static void mark_mem_region(val *low, val *high)
if ((t & FREE) == 0) {
mark_obj(maybe_obj);
} else {
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (opt_vg_debug)
VALGRIND_MAKE_MEM_NOACCESS(maybe_obj, sizeof *maybe_obj);
#endif
@@ -416,7 +416,7 @@ static void mark(mach_context_t *pmc, val *gc_stack_top)
static int sweep_one(obj_t *block)
{
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
const int vg_dbg = opt_vg_debug;
#else
const int vg_dbg = 0;
@@ -439,7 +439,7 @@ static int sweep_one(obj_t *block)
}
if (block->t.type & FREE) {
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (vg_dbg)
VALGRIND_MAKE_MEM_NOACCESS(block, sizeof *block);
#endif
@@ -457,13 +457,13 @@ static int sweep_one(obj_t *block)
code which is still using the object will trip on
the freed object before it is recycled. */
if (vg_dbg || opt_gc_debug) {
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (vg_dbg && free_tail != &free_list)
VALGRIND_MAKE_MEM_DEFINED(free_tail, sizeof *free_tail);
#endif
*free_tail = block;
block->t.next = nil;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (vg_dbg) {
if (free_tail != &free_list)
VALGRIND_MAKE_MEM_NOACCESS(free_tail, sizeof *free_tail);
@@ -483,7 +483,7 @@ static int_ptr_t sweep(void)
{
int_ptr_t free_count = 0;
heap_t *heap;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
const int vg_dbg = opt_vg_debug;
#endif
@@ -505,7 +505,7 @@ static int_ptr_t sweep(void)
for (heap = heap_list; heap != 0; heap = heap->next) {
obj_t *block, *end;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
if (vg_dbg)
VALGRIND_MAKE_MEM_DEFINED(&heap->block, sizeof heap->block);
#endif
diff --git a/lib.c b/lib.c
index 54927f81..194e0c65 100644
--- a/lib.c
+++ b/lib.c
@@ -3594,7 +3594,7 @@ val vector(val length)
cnum alloc_plus = c_num(length) + 2;
val vec = make_obj();
val *v = (val *) chk_malloc(alloc_plus * sizeof *v);
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
vec->v.vec_true_start = v;
#endif
v += 2;
@@ -3629,7 +3629,7 @@ val vec_set_length(val vec, val length)
(new_alloc + 2) * sizeof *newvec);
vec->v.vec = newvec + 2;
set(vec->v.vec[vec_alloc], num(new_alloc));
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
vec->v.vec_true_start = newvec;
#endif
}
@@ -3718,7 +3718,7 @@ val copy_vec(val vec_in)
cnum alloc_plus = c_num(length) + 2;
val vec = make_obj();
val *v = (val *) chk_malloc(alloc_plus * sizeof *v);
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
vec->v.vec_true_start = v;
#endif
v += 2;
@@ -3759,7 +3759,7 @@ val sub_vec(val vec_in, val from, val to)
size_t nelem = c_num(to) - cfrom;
val vec = make_obj();
val *v = (val *) chk_malloc((nelem + 2) * sizeof *v);
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
vec->v.vec_true_start = v;
#endif
v += 2;
@@ -3859,7 +3859,7 @@ val cat_vec(val list)
vec = make_obj();
v = (val *) chk_malloc((total + 2) * sizeof *v);
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
vec->v.vec_true_start = v;
#endif
v += 2;
diff --git a/lib.h b/lib.h
index 95528ae6..f4558bf2 100644
--- a/lib.h
+++ b/lib.h
@@ -148,7 +148,7 @@ struct vec {
/* vec[-2] is allocated size */
/* vec[-1] is fill pointer */
val *vec;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
val *vec_true_start;
#endif
};
diff --git a/txr.c b/txr.c
index 15fc4ab1..6ad49e1d 100644
--- a/txr.c
+++ b/txr.c
@@ -296,7 +296,7 @@ int txr_main(int argc, char **argv)
argv++, argc--;
continue;
} else if (!strcmp(*argv, "--vg-debug")) {
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
opt_vg_debug = 1;
argv++, argc--;
continue;
diff --git a/txr.h b/txr.h
index 3da972c1..e4c138b5 100644
--- a/txr.h
+++ b/txr.h
@@ -29,7 +29,7 @@ extern int opt_nobindings;
extern int opt_lisp_bindings;
extern int opt_arraydims;
extern int opt_gc_debug;
-#ifdef HAVE_VALGRIND
+#if HAVE_VALGRIND
extern int opt_vg_debug;
#endif
extern int opt_derivative_regex;