forked from vitrine/wmaker
Rip out Boehm GC support.
This is done to simplify memory management across the boundary between C and Rust. While rewriting WINGs, we may want to be able to malloc/free with the libc allocator on both sides of that divide.
This commit is contained in:
@@ -34,13 +34,6 @@
|
||||
#include <stdnoreturn.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_BOEHM_GC
|
||||
#ifndef GC_DEBUG
|
||||
#define GC_DEBUG
|
||||
#endif /* !GC_DEBUG */
|
||||
#include <gc/gc.h>
|
||||
#endif /* USE_BOEHM_GC */
|
||||
|
||||
#ifndef False
|
||||
# define False 0
|
||||
#endif
|
||||
@@ -83,19 +76,11 @@ void *wmalloc(size_t size)
|
||||
|
||||
assert(size > 0);
|
||||
|
||||
#ifdef USE_BOEHM_GC
|
||||
tmp = GC_MALLOC(size);
|
||||
#else
|
||||
tmp = malloc(size);
|
||||
#endif
|
||||
if (tmp == NULL) {
|
||||
wwarning("malloc() failed. Retrying after 2s.");
|
||||
sleep(2);
|
||||
#ifdef USE_BOEHM_GC
|
||||
tmp = GC_MALLOC(size);
|
||||
#else
|
||||
tmp = malloc(size);
|
||||
#endif
|
||||
if (tmp == NULL) {
|
||||
if (Aborting) {
|
||||
fputs("Really Bad Error: recursive malloc() failure.", stderr);
|
||||
@@ -122,19 +107,11 @@ void *wrealloc(void *ptr, size_t newsize)
|
||||
wfree(ptr);
|
||||
nptr = NULL;
|
||||
} else {
|
||||
#ifdef USE_BOEHM_GC
|
||||
nptr = GC_REALLOC(ptr, newsize);
|
||||
#else
|
||||
nptr = realloc(ptr, newsize);
|
||||
#endif
|
||||
if (nptr == NULL) {
|
||||
wwarning("realloc() failed. Retrying after 2s.");
|
||||
sleep(2);
|
||||
#ifdef USE_BOEHM_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);
|
||||
@@ -179,21 +156,7 @@ void *wretain(void *ptr)
|
||||
void wfree(void *ptr)
|
||||
{
|
||||
if (ptr)
|
||||
#ifdef USE_BOEHM_GC
|
||||
/* This should eventually be removed, once the criss-cross
|
||||
* of wmalloc()d memory being free()d, malloc()d memory being
|
||||
* wfree()d, various misuses of calling wfree() on objects
|
||||
* allocated by libc malloc() and calling libc free() on
|
||||
* objects allocated by Boehm GC (think external libraries)
|
||||
* is cleaned up.
|
||||
*/
|
||||
if (GC_base(ptr) != 0)
|
||||
GC_FREE(ptr);
|
||||
else
|
||||
free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif
|
||||
ptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
18
configure.ac
18
configure.ac
@@ -351,24 +351,6 @@ AS_IF([test "x$enable_mwm_hints" = "xno"],
|
||||
AM_CONDITIONAL([USE_MWM_HINTS], [test "x$enable_mwm_hints" != "xno"])
|
||||
|
||||
|
||||
dnl Boehm GC
|
||||
dnl ========
|
||||
m4_divert_push([INIT_PREPARE])dnl
|
||||
AC_ARG_ENABLE([boehm-gc],
|
||||
[AS_HELP_STRING([--enable-boehm-gc], [use Boehm GC instead of the default libc malloc() [default=no]])],
|
||||
[AS_CASE(["$enableval"],
|
||||
[yes], [with_boehm_gc=yes],
|
||||
[no], [with_boehm_gc=no],
|
||||
[AC_MSG_ERROR([bad value $enableval for --enable-boehm-gc])] )],
|
||||
[with_boehm_gc=no])
|
||||
m4_divert_pop([INIT_PREPARE])dnl
|
||||
|
||||
AS_IF([test "x$with_boehm_gc" = "xyes"],
|
||||
AC_SEARCH_LIBS([GC_malloc], [gc],
|
||||
[AC_DEFINE(USE_BOEHM_GC, 1, [Define if Boehm GC is to be used])],
|
||||
[AC_MSG_FAILURE([--enable-boehm-gc specified but test for libgc failed])]))
|
||||
|
||||
|
||||
dnl LCOV
|
||||
dnl ====
|
||||
m4_divert_push([INIT_PREPARE])dnl
|
||||
|
||||
10
doc/build/Compilation.texi
vendored
10
doc/build/Compilation.texi
vendored
@@ -253,14 +253,6 @@ If found, then the library @emph{WRaster} can use the @emph{ImageMagick} library
|
||||
@sc{Window Maker} support more image formats, like @emph{SVG}, @emph{BMP}, @emph{TGA}, ...
|
||||
You can get it from @uref{http://www.imagemagick.org/}
|
||||
|
||||
@item @emph{Boehm GC}
|
||||
|
||||
This library can be used by the @emph{WINGs} utility toolkit to use a
|
||||
@cite{Boehm-Demers-Weiser Garbage Collector} instead of the traditional
|
||||
@command{malloc}/@command{free} functions from the @emph{libc}.
|
||||
You have to explicitly ask for its support though (@pxref{Configure Options}).
|
||||
You can get it from @uref{http://www.hboehm.info/gc/}
|
||||
|
||||
@end itemize
|
||||
|
||||
|
||||
@@ -468,8 +460,6 @@ You can find more information about the libraries in the
|
||||
@ref{Optional Dependencies}.
|
||||
|
||||
@table @option
|
||||
@item --enable-boehm-gc
|
||||
Never enabled by default, use Boehm GC instead of the default @emph{libc} @command{malloc()}
|
||||
|
||||
@item --disable-gif
|
||||
Disable GIF support in @emph{WRaster} library; when enabled use @file{libgif} or @file{libungif}.
|
||||
|
||||
Reference in New Issue
Block a user