From fcc47bc7ce2b56a6977024b1633e6596c3d7975e Mon Sep 17 00:00:00 2001 From: theraven Date: Wed, 25 May 2011 12:25:27 +0000 Subject: [PATCH] Fix building without GC support. Still need to make sure that some of the GC functions always work, since they are expected to be no-ops in non-GC mode. --- GNUmakefile | 1 + gc_boehm.c | 2 +- gc_none.c | 10 ++++++++++ gc_ops.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index dd65d80..f4e73ab 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -84,6 +84,7 @@ ifeq ($(boehm_gc), yes) libobjc_C_FILES += gc_boehm.c libobjc_LIBRARIES_DEPEND_UPON += -lgc-threaded libobjc_OBJCFLAGS += -fobjc-gc +libobjc_CPPFLAGS += -DENABLE_GC endif diff --git a/gc_boehm.c b/gc_boehm.c index dc5697b..35e2ad3 100644 --- a/gc_boehm.c +++ b/gc_boehm.c @@ -10,7 +10,7 @@ #include #include "gc_ops.h" #define I_HIDE_POINTERS -#include +#include #include #ifndef __clang__ diff --git a/gc_none.c b/gc_none.c index 784b64e..569e5b3 100644 --- a/gc_none.c +++ b/gc_none.c @@ -3,6 +3,7 @@ #include "gc_ops.h" #include "class.h" #include +#include static id allocate_class(Class cls, size_t extraBytes) { @@ -24,3 +25,12 @@ PRIVATE struct gc_ops *gc = &gc_ops_none; PRIVATE BOOL isGCEnabled = NO; +#ifndef ENABLE_GC +PRIVATE void enableGC(BOOL exclusive) +{ + fprintf(stderr, "Attempting to enable garbage collection, but your" + "Objective-C runtime was built without garbage collection" + "support\n"); + abort(); +} +#endif diff --git a/gc_ops.h b/gc_ops.h index 31babac..9cda3f0 100644 --- a/gc_ops.h +++ b/gc_ops.h @@ -32,6 +32,7 @@ struct gc_ops * -release / -autorelease messages become no-ops. */ void enableGC(BOOL exclusive); + /** * The mode for garbage collection */