2 // boehm-gc.h - Defines for Boehm collector.
4 /* Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 #ifndef __JV_BOEHM_GC__
13 #define __JV_BOEHM_GC__
15 #define JV_MARKOBJ_DECL void *::_Jv_MarkObj (void *, void *, void *, void *)
16 #define JV_MARKARRAY_DECL void *::_Jv_MarkArray (void *, void *, void *, void *)
20 void *_Jv_MarkObj (void *, void *, void *, void *);
21 void *_Jv_MarkArray (void *, void *, void *, void *);
22 void _Jv_RegisterLibForGc (const void *);
25 // Enough stuff to inline _Jv_AllocObj. Ugly.
26 #include <gcj/javaprims.h>
27 #include <java/lang/Class.h>
30 #include <gc_ext_config.h> // for THREAD_LOCAL_ALLOC
32 extern "C" void * GC_gcj_malloc(size_t, void *);
33 extern "C" void * GC_malloc_atomic(size_t);
34 #ifdef THREAD_LOCAL_ALLOC
35 extern "C" void * GC_local_gcj_malloc(size_t, void *);
36 extern "C" void * GC_local_malloc_atomic(size_t);
39 #ifndef LIBGCJ_GC_DEBUG
42 _Jv_AllocObj (jsize size
, jclass klass
)
44 // This should call GC_GCJ_MALLOC, but that would involve
46 #ifdef THREAD_LOCAL_ALLOC
47 return GC_local_gcj_malloc (size
, klass
->vtable
);
49 return GC_gcj_malloc (size
, klass
->vtable
);
54 _Jv_AllocPtrFreeObj (jsize size
, jclass klass
)
56 #ifdef JV_HASH_SYNCHRONIZATION
57 # ifdef THREAD_LOCAL_ALLOC
58 void * obj
= GC_local_malloc_atomic(size
);
60 void * obj
= GC_malloc_atomic(size
);
62 *((_Jv_VTable
**) obj
) = klass
->vtable
;
64 # ifdef THREAD_LOCAL_ALLOC
65 void * obj
= GC_local_gcj_malloc(size
, klass
->vtable
);
67 void * obj
= GC_gcj_malloc(size
, klass
->vtable
);
73 #else /* LIBGCJ_GC_DEBUG */
76 _Jv_AllocObj (jsize size
, jclass klass
);
79 _Jv_AllocPtrFreeObj (jsize size
, jclass klass
);
81 #endif /* LIBGCJ_GC_DEBUG */
83 void _Jv_GCAttachThread ();
85 void _Jv_GCDetachThread ();
87 // _Jv_AllocBytes (jsize size) should go here, too. But clients don't
88 // usually include this header.
90 // Suspend the given thread. This includes suspending the calling thread.
91 extern "C" void _Jv_SuspendThread (_Jv_Thread_t
*);
93 // Resume a suspended thread.
94 extern "C" void _Jv_ResumeThread (_Jv_Thread_t
*);
96 // Is the given thread suspended?
97 extern "C" int _Jv_IsThreadSuspended (_Jv_Thread_t
*);
98 #endif /* __JV_BOEHM_GC__ */