* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / gc.h
blob29fd6b407c90149389cedeabcc9287fac4e16591
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);}
61 #if STACK_GROW_DIRECTION > 0
62 # define STACK_UPPER(x, a, b) a
63 #elif STACK_GROW_DIRECTION < 0
64 # define STACK_UPPER(x, a, b) b
65 #else
66 RUBY_EXTERN int ruby_stack_grow_direction;
67 int ruby_get_stack_grow_direction(VALUE *addr);
68 # define stack_growup_p(x) ( \
69 (ruby_stack_grow_direction ? \
70 ruby_stack_grow_direction : \
71 ruby_get_stack_grow_direction(x)) > 0)
72 # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
73 #endif
75 #endif /* RUBY_GC_H */