using wmaker with this is highly entertaining. not actually possible
(crashes and burns immediately), but highly entertaining. time to pull
out your favourite gdb frontend :)
>From 2e7d7fbc4c2638ccf0af4ffa8d13b814b5039e30 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Wed, 22 Sep 2010 18:00:34 +0200
Subject: [PATCH] Repair TEST_WITH_GC
- Got slightly renamed, though.
Signed-off-by: Tamas TEVESZ <[email protected]>
---
WINGs/memory.c | 27 +++++----------------------
configure.ac | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/WINGs/memory.c b/WINGs/memory.c
index 9d770b0..46b1332 100644
--- a/WINGs/memory.c
+++ b/WINGs/memory.c
@@ -29,9 +29,12 @@
#include <assert.h>
#include <signal.h>
-#ifdef TEST_WITH_GC
+#ifdef WITH_BOEHM_GC
#include <gc/gc.h>
-#endif
+#define malloc(x) GC_malloc(x)
+#define realloc(x, y) GC_realloc(x, y)
+#define free(x) GC_free(x)
+#endif /* WITH_BOEHM_GC */
#ifndef False
# define False 0
@@ -71,19 +74,11 @@ void *wmalloc(size_t size)
assert(size > 0);
-#ifdef TEST_WITH_GC
- tmp = GC_malloc(size);
-#else
tmp = malloc(size);
-#endif
if (tmp == NULL) {
wwarning("malloc() failed. Retrying after 2s.");
sleep(2);
-#ifdef TEST_WITH_GC
- tmp = GC_malloc(size);
-#else
tmp = malloc(size);
-#endif
if (tmp == NULL) {
if (Aborting) {
fputs("Really Bad Error: recursive malloc()
failure.", stderr);
@@ -108,19 +103,11 @@ void *wrealloc(void *ptr, size_t newsize)
wfree(ptr);
nptr = NULL;
} else {
-#ifdef TEST_WITH_GC
- nptr = GC_realloc(ptr, newsize);
-#else
nptr = realloc(ptr, newsize);
-#endif
if (nptr == NULL) {
wwarning("realloc() failed. Retrying after 2s.");
sleep(2);
-#ifdef TEST_WITH_GC
- nptr = GC_realloc(ptr, newsize);
-#else
nptr = realloc(ptr, newsize);
-#endif
if (nptr == NULL) {
if (Aborting) {
fputs("Really Bad Error: recursive
realloc() failure.", stderr);
@@ -164,11 +151,7 @@ void *wretain(void *ptr)
void wfree(void *ptr)
{
-#ifdef TEST_WITH_GC
- GC_free(ptr);
-#else
free(ptr);
-#endif
}
void wrelease(void *ptr)
diff --git a/configure.ac b/configure.ac
index de5b5a5..b834c1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -141,6 +141,22 @@ AC_ARG_WITH(libs-from, AS_HELP_STRING([--with-libs-from],
[pass compiler flags t
AC_ARG_WITH(incs-from, AS_HELP_STRING([--with-incs-from], [pass compiler flags
to look for header files]),
[inc_search_path="$withval $inc_search_path"])
+
+dnl Boehm-GC
+dnl ========
+with_boehm_gc=no
+AC_ARG_ENABLE([boehm-gc],
+ [AS_HELP_STRING([--enable-boehm-gc], [use Boehm GC instead of the default
libc malloc() [default=no]])],
+ [with_boehm_gc=$enableval])
+
+AS_IF([test "x$with_boehm_gc" = "xyes"],
+ AC_SEARCH_LIBS([GC_malloc], [gc],
+ [AC_DEFINE(WITH_BOEHM_GC, 1, [Define if Boehm GC is to be used])],
+ [AC_MSG_FAILURE([--enable-boehm-gc specified but test for libgc
failed])]
+ )
+)
+
+dnl
dnl ============================
dnl Checks for library functions
dnl ============================
--
1.7.0.4
--
[-]
mkdir /nonexistentFrom 2e7d7fbc4c2638ccf0af4ffa8d13b814b5039e30 Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Wed, 22 Sep 2010 18:00:34 +0200
Subject: [PATCH] Repair TEST_WITH_GC
- Got slightly renamed, though.
Signed-off-by: Tamas TEVESZ <[email protected]>
---
WINGs/memory.c | 27 +++++----------------------
configure.ac | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/WINGs/memory.c b/WINGs/memory.c
index 9d770b0..46b1332 100644
--- a/WINGs/memory.c
+++ b/WINGs/memory.c
@@ -29,9 +29,12 @@
#include <assert.h>
#include <signal.h>
-#ifdef TEST_WITH_GC
+#ifdef WITH_BOEHM_GC
#include <gc/gc.h>
-#endif
+#define malloc(x) GC_malloc(x)
+#define realloc(x, y) GC_realloc(x, y)
+#define free(x) GC_free(x)
+#endif /* WITH_BOEHM_GC */
#ifndef False
# define False 0
@@ -71,19 +74,11 @@ void *wmalloc(size_t size)
assert(size > 0);
-#ifdef TEST_WITH_GC
- tmp = GC_malloc(size);
-#else
tmp = malloc(size);
-#endif
if (tmp == NULL) {
wwarning("malloc() failed. Retrying after 2s.");
sleep(2);
-#ifdef TEST_WITH_GC
- tmp = GC_malloc(size);
-#else
tmp = malloc(size);
-#endif
if (tmp == NULL) {
if (Aborting) {
fputs("Really Bad Error: recursive malloc() failure.", stderr);
@@ -108,19 +103,11 @@ void *wrealloc(void *ptr, size_t newsize)
wfree(ptr);
nptr = NULL;
} else {
-#ifdef TEST_WITH_GC
- nptr = GC_realloc(ptr, newsize);
-#else
nptr = realloc(ptr, newsize);
-#endif
if (nptr == NULL) {
wwarning("realloc() failed. Retrying after 2s.");
sleep(2);
-#ifdef TEST_WITH_GC
- nptr = GC_realloc(ptr, newsize);
-#else
nptr = realloc(ptr, newsize);
-#endif
if (nptr == NULL) {
if (Aborting) {
fputs("Really Bad Error: recursive realloc() failure.", stderr);
@@ -164,11 +151,7 @@ void *wretain(void *ptr)
void wfree(void *ptr)
{
-#ifdef TEST_WITH_GC
- GC_free(ptr);
-#else
free(ptr);
-#endif
}
void wrelease(void *ptr)
diff --git a/configure.ac b/configure.ac
index de5b5a5..b834c1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -141,6 +141,22 @@ AC_ARG_WITH(libs-from, AS_HELP_STRING([--with-libs-from], [pass compiler flags t
AC_ARG_WITH(incs-from, AS_HELP_STRING([--with-incs-from], [pass compiler flags to look for header files]),
[inc_search_path="$withval $inc_search_path"])
+
+dnl Boehm-GC
+dnl ========
+with_boehm_gc=no
+AC_ARG_ENABLE([boehm-gc],
+ [AS_HELP_STRING([--enable-boehm-gc], [use Boehm GC instead of the default libc malloc() [default=no]])],
+ [with_boehm_gc=$enableval])
+
+AS_IF([test "x$with_boehm_gc" = "xyes"],
+ AC_SEARCH_LIBS([GC_malloc], [gc],
+ [AC_DEFINE(WITH_BOEHM_GC, 1, [Define if Boehm GC is to be used])],
+ [AC_MSG_FAILURE([--enable-boehm-gc specified but test for libgc failed])]
+ )
+)
+
+dnl
dnl ============================
dnl Checks for library functions
dnl ============================
--
1.7.0.4