1:
2: #ifndef RUBY_GC_H
3: #define RUBY_GC_H 1
4:
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
12:
13:
14:
15: #ifndef RUBY_MARK_FREE_DEBUG
16: #define RUBY_MARK_FREE_DEBUG 0
17: #endif
18:
19: #if RUBY_MARK_FREE_DEBUG
20: extern int ruby_gc_debug_indent;
21:
22: static void
23: rb_gc_debug_indent(void)
24: {
25: printf("%*s", ruby_gc_debug_indent, "");
26: }
27:
28: static void
29: rb_gc_debug_body(char *mode, char *msg, int st, void *ptr)
30: {
31: if (st == 0) {
32: ruby_gc_debug_indent--;
33: }
34: rb_gc_debug_indent();
35: printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
36:
37: if (st) {
38: ruby_gc_debug_indent++;
39: }
40:
41: fflush(stdout);
42: }
43:
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
49:
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
57:
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
61: