1 /* boehm.c *********************************************************************
3 Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
5 See file COPYRIGHT for information on usage and disclaimer of warranties
7 Contains main() and variables for the global options.
8 This module does the following tasks:
9 - Interface to the Boehm GC
11 Authors: Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at
12 Changes: Andi Krall EMAIL: cacao@complang.tuwien.ac.at
13 Mark Probst EMAIL: cacao@complang.tuwien.ac.at
14 Philipp Tomsich EMAIL: cacao@complang.tuwien.ac.at
16 Last Change: $Id: boehm.c 210 2003-02-03 13:05:24Z stefan $
18 *******************************************************************************/
21 #include "threads/thread.h"
25 void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, void *);
27 struct otherstackcall;
29 typedef void *(*calltwoargs)(void *, u4);
31 struct otherstackcall {
37 static void *stackcall_twoargs(struct otherstackcall *p)
39 return (*p->p2)(p->p, p->l);
42 static void *stackcall_malloc(void *p, u4 bytelength)
44 return GC_MALLOC(bytelength);
47 static void *stackcall_malloc_atomic(void *p, u4 bytelength)
49 return GC_MALLOC_ATOMIC(bytelength);
52 static void *stackcall_malloc_uncollectable(void *p, u4 bytelength)
54 return GC_MALLOC_UNCOLLECTABLE(bytelength);
57 static void *stackcall_realloc(void *p, u4 bytelength)
59 return GC_REALLOC(p, bytelength);
62 #define MAINTHREADCALL(r,m,pp,ll) \
63 if (currentThread == NULL || currentThread == mainThread) { \
66 struct otherstackcall sc; \
70 r = (*asm_switchstackandcall)(CONTEXT(mainThread).usedStackTop, \
72 (void**)&(CONTEXT(currentThread).usedStackTop), &sc); \
75 void *heap_alloc_uncollectable(u4 bytelength)
78 MAINTHREADCALL(result, stackcall_malloc_uncollectable, NULL, bytelength);
82 void *heap_allocate (u4 bytelength, bool references, methodinfo *finalizer)
86 { MAINTHREADCALL(result, stackcall_malloc, NULL, bytelength); }
88 { MAINTHREADCALL(result, stackcall_malloc_atomic, NULL, bytelength); }
92 void *heap_reallocate(void *p, u4 bytelength)
95 MAINTHREADCALL(result, stackcall_realloc, p, bytelength);
99 void heap_init (u4 size, u4 startsize, void **stackbottom)
107 void heap_addreference (void **reflocation)
123 * These are local overrides for various environment variables in Emacs.
124 * Please do not remove this and leave it at the end of the file, where
125 * Emacs will automagically detect them.
126 * ---------------------------------------------------------------------
129 * indent-tabs-mode: t