blob: 67acd5134a3d68c23eb80f020e64779783c11747 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include <stddef.h>
#include <stdio.h>
#include <assert.h>
#include <gc.h>
void *inter_main(void);
void *debug_int(void *i) {
int *p = (int *) i;
fprintf(stderr, "%d\n", *p);
return i;
}
void *debug_func_call(void *f) {
char *func_id = (char *) f;
fprintf(stderr, "%s\n", func_id);
return 0;
}
void *gc_alloc(int size) {
void *p = GC_MALLOC(size);
/*
* To get info about the GC discarding objects, use
* GC_REGISTER_FINALIZER(p, fn, arg, 0, 0);
*
* This runs fn(p, arg) when the object at p is finalised.
*
* More info in gc.h of Boehm garbage collector.
*/
return p;
}
int main() {
/*
* Initialising the GC is not necessary on all systems but may be required
* on some. Better safe than sorry! See gc.h for more info.
*/
GC_INIT();
int *ret = (int *) inter_main();
assert(ret);
return *ret;
}
|