* gc.c (set_heaps_increment): fix memory allocation strategy by
[ruby-svn.git] / gc.h
blobfe2e07ded067b4362231646ece0f369c6b0da7cc
2 #ifndef RUBY_GC_H
3 #define RUBY_GC_H 1
5 #if defined(__i386) && defined(__GNUC__)
6 #define SET_MACHINE_STACK_END(p) __asm__("mov %%esp, %0" : "=r" (*p))
7 #else
8 NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
9 #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
10 #define USE_CONSERVATIVE_STACK_END
11 #endif
13 /* for GC debug */
15 #ifndef RUBY_MARK_FREE_DEBUG
16 #define RUBY_MARK_FREE_DEBUG 0
17 #endif
19 #if RUBY_MARK_FREE_DEBUG
20 extern int ruby_gc_debug_indent;
22 static void
23 rb_gc_debug_indent(void)
25 printf("%*s", ruby_gc_debug_indent, "");
28 static void
29 rb_gc_debug_body(char *mode, char *msg, int st, void *ptr)
31 if (st == 0) {
32 ruby_gc_debug_indent--;
34 rb_gc_debug_indent();
35 printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
37 if (st) {
38 ruby_gc_debug_indent++;
41 fflush(stdout);
44 #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr)
45 #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr)
46 #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr)
47 #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr)
48 #define RUBY_GC_INFO rb_gc_debug_indent(); printf
50 #else
51 #define RUBY_MARK_ENTER(msg)
52 #define RUBY_MARK_LEAVE(msg)
53 #define RUBY_FREE_ENTER(msg)
54 #define RUBY_FREE_LEAVE(msg)
55 #define RUBY_GC_INFO if(0)printf
56 #endif
58 #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
59 #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
60 #endif /* RUBY_GC_H */