Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / include / boehm-gc.h
blobe7802b68035cc0e08df3f70171cdea7c3028fcc4
1 // -*- c++ -*-
2 // boehm-gc.h - Defines for Boehm collector.
4 /* Copyright (C) 1998, 1999, 2002, 2004 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 *);
24 // Enough stuff to inline _Jv_AllocObj. Ugly.
25 #include <gcj/javaprims.h>
26 #include <java/lang/Class.h>
27 #include <string.h>
29 #include <gc_ext_config.h> // for THREAD_LOCAL_ALLOC
31 extern "C" void * GC_gcj_malloc(size_t, void *);
32 extern "C" void * GC_malloc_atomic(size_t);
33 #ifdef THREAD_LOCAL_ALLOC
34 extern "C" void * GC_local_gcj_malloc(size_t, void *);
35 extern "C" void * GC_local_malloc_atomic(size_t);
36 #endif
38 #ifndef LIBGCJ_GC_DEBUG
40 inline void *
41 _Jv_AllocObj (jsize size, jclass klass)
43 // This should call GC_GCJ_MALLOC, but that would involve
44 // including gc.h.
45 #ifdef THREAD_LOCAL_ALLOC
46 return GC_local_gcj_malloc (size, klass->vtable);
47 #else
48 return GC_gcj_malloc (size, klass->vtable);
49 #endif
52 inline void *
53 _Jv_AllocPtrFreeObj (jsize size, jclass klass)
55 #ifdef JV_HASH_SYNCHRONIZATION
56 # ifdef THREAD_LOCAL_ALLOC
57 void * obj = GC_local_malloc_atomic(size);
58 # else
59 void * obj = GC_malloc_atomic(size);
60 # endif
61 *((_Jv_VTable **) obj) = klass->vtable;
62 #else
63 # ifdef THREAD_LOCAL_ALLOC
64 void * obj = GC_local_gcj_malloc(size, klass->vtable);
65 # else
66 void * obj = GC_gcj_malloc(size, klass->vtable);
67 # endif
68 #endif
69 return obj;
72 #else /* LIBGCJ_GC_DEBUG */
74 void *
75 _Jv_AllocObj (jsize size, jclass klass);
77 void *
78 _Jv_AllocPtrFreeObj (jsize size, jclass klass);
80 #endif /* LIBGCJ_GC_DEBUG */
82 // _Jv_AllocBytes (jsize size) should go here, too. But clients don't
83 // usually include this header.
85 #endif /* __JV_BOEHM_GC__ */