comment/style fixes
[official-gcc.git] / libjava / include / boehm-gc.h
blobed8ac6aa2e34b6d298bc2496de279aa7b97829b7
1 // -*- c++ -*-
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
10 details. */
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 *)
18 extern "C"
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>
28 #include <string.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);
37 #endif
39 #ifndef LIBGCJ_GC_DEBUG
41 inline void *
42 _Jv_AllocObj (jsize size, jclass klass)
44 // This should call GC_GCJ_MALLOC, but that would involve
45 // including gc.h.
46 #ifdef THREAD_LOCAL_ALLOC
47 return GC_local_gcj_malloc (size, klass->vtable);
48 #else
49 return GC_gcj_malloc (size, klass->vtable);
50 #endif
53 inline void *
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);
59 # else
60 void * obj = GC_malloc_atomic(size);
61 # endif
62 *((_Jv_VTable **) obj) = klass->vtable;
63 #else
64 # ifdef THREAD_LOCAL_ALLOC
65 void * obj = GC_local_gcj_malloc(size, klass->vtable);
66 # else
67 void * obj = GC_gcj_malloc(size, klass->vtable);
68 # endif
69 #endif
70 return obj;
73 #else /* LIBGCJ_GC_DEBUG */
75 void *
76 _Jv_AllocObj (jsize size, jclass klass);
78 void *
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__ */