#define _GC_H
+#include "config.h"
+#include "vm/types.h"
+
+#if defined(ENABLE_THREADS)
+# include "threads/native/threads.h"
+#endif
+
+
+/* Configuration Switches *****************************************************/
+
+/*#define GCCONF_FINALIZER*/
+/*#define GCCONF_HDRFLAG_REFERENCING*/
+
+
/* Debugging ******************************************************************/
#define GC_DEBUGGING
-#define GC_DEBUGGING2
+/*#define GC_DEBUGGING2*/
#if !defined(NDEBUG) && defined(GC_DEBUGGING)
# include <assert.h>
/* Development Break **********************************************************/
-#if 1 && defined(ENABLE_THREADS)
+#if 0 && defined(ENABLE_THREADS)
# error "GC does not work with threads enabled!"
#endif
#endif
-/* Global Variables ***********************************************************/
-
-static bool gc_pending;
-
-
/* Helper Macros **************************************************************/
#define GC_SET_FLAGS(obj, flags) ((obj)->hdrflags |= (flags))
#define GC_TEST_FLAGS(obj, flags) ((obj)->hdrflags & (flags))
#define POINTS_INTO(ptr, ptr_start, ptr_end) \
- ((void *) (ptr) > (ptr_start) && (void *) (ptr) < (ptr_end))
+ ((void *) (ptr) >= (ptr_start) && (void *) (ptr) < (ptr_end))
+
+
+/* Global Variables ***********************************************************/
+
+extern bool gc_pending;
+extern bool gc_notify_finalizer;
+
+
+/* Prototypes *****************************************************************/
+
+#if defined(ENABLE_THREADS)
+void gc_suspend(threadobject *thread, ucontext_t *context);
+#endif
+
+
+/* Statistics *****************************************************************/
+
+#if defined(ENABLE_STATISTICS)
+
+#define GCSTAT_INIT(cnt) { (cnt) = 0; }
+#define GCSTAT_COUNT(cnt) { (cnt)++; }
+#define GCSTAT_DEC(cnt) { (cnt)--; GC_ASSERT((cnt) >= 0); }
+#define GCSTAT_COUNT_MAX(cnt,max) { (cnt)++; if ((cnt) > (max)) (max) = (cnt); }
+
+extern int gcstat_mark_depth;
+extern int gcstat_mark_depth_max;
+extern int gcstat_mark_count;
+
+void gcstat_println();
+
+#endif /* defined(ENABLE_STATISTICS) */
#endif /* _GC_H */