~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to gc.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#ifndef RUBY_GC_H
3
3
#define RUBY_GC_H 1
4
4
 
 
5
#if defined(__i386) && defined(__GNUC__)
 
6
#define SET_MACHINE_STACK_END(p) __asm__("mov %%esp, %0" : "=r" (*p))
 
7
#else
5
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
NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
6
14
 
7
15
/* for GC debug */
8
16
 
9
 
#ifndef MARK_FREE_DEBUG
10
 
#define MARK_FREE_DEBUG 0
 
17
#ifndef RUBY_MARK_FREE_DEBUG
 
18
#define RUBY_MARK_FREE_DEBUG 0
11
19
#endif
12
20
 
13
 
 
14
 
#if MARK_FREE_DEBUG
15
 
static int g_indent = 0;
 
21
#if RUBY_MARK_FREE_DEBUG
 
22
extern int ruby_gc_debug_indent = 0;
16
23
 
17
24
static void
18
25
rb_gc_debug_indent(void)
19
26
{
20
 
    int i;
21
 
    for (i = 0; i < g_indent; i++) {
22
 
        printf(" ");
23
 
    }
 
27
    printf("%*s", ruby_gc_debug_indent, "");
24
28
}
25
29
 
26
30
static void
27
31
rb_gc_debug_body(char *mode, char *msg, int st, void *ptr)
28
32
{
29
33
    if (st == 0) {
30
 
        g_indent--;
 
34
        ruby_gc_debug_indent--;
31
35
    }
32
36
    rb_gc_debug_indent();
33
37
    printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
 
38
 
34
39
    if (st) {
35
 
        g_indent++;
 
40
        ruby_gc_debug_indent++;
36
41
    }
 
42
 
37
43
    fflush(stdout);
38
44
}
39
45
 
40
 
#define MARK_REPORT_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr)
41
 
#define MARK_REPORT_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr)
42
 
#define FREE_REPORT_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr)
43
 
#define FREE_REPORT_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr)
44
 
#define GC_INFO                rb_gc_debug_indent(); printf
 
46
#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr)
 
47
#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr)
 
48
#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr)
 
49
#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr)
 
50
#define RUBY_GC_INFO         rb_gc_debug_indent(); printf
45
51
 
46
52
#else
47
 
#define MARK_REPORT_ENTER(msg)
48
 
#define MARK_REPORT_LEAVE(msg)
49
 
#define FREE_REPORT_ENTER(msg)
50
 
#define FREE_REPORT_LEAVE(msg)
51
 
#define GC_INFO if(0)printf
 
53
#define RUBY_MARK_ENTER(msg)
 
54
#define RUBY_MARK_LEAVE(msg)
 
55
#define RUBY_FREE_ENTER(msg)
 
56
#define RUBY_FREE_LEAVE(msg)
 
57
#define RUBY_GC_INFO if(0)printf
52
58
#endif
53
59
 
54
 
#define MARK_UNLESS_NULL(ptr) if(ptr){rb_gc_mark(ptr);}
55
 
#define FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
 
60
#define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);}
 
61
#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);}
56
62
#endif /* RUBY_GC_H */
57
63