cp:
[official-gcc.git] / libjava / include / boehm-gc.h
blobcd421a44358fa55bb51a3ea72c4b0c158d57bfa9
1 // -*- c++ -*-
2 // boehm-gc.h - Defines for Boehm collector.
4 /* Copyright (C) 1998, 1999 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 JV_MARKOBJ_DECL;
21 JV_MARKARRAY_DECL;
24 // Enough stuff to inline _Jv_AllocObj. Ugly.
25 #include <gcj/javaprims.h>
26 #include <java/lang/Class.h>
27 #include <string.h>
29 extern "C" void * GC_gcj_malloc(size_t, void *);
30 extern "C" void * GC_malloc_atomic(size_t);
32 inline void *
33 _Jv_AllocObj (jsize size, jclass klass)
35 // This should call GC_GCJ_MALLOC, but that would involve
36 // including gc.h.
37 return GC_gcj_malloc (size, klass->vtable);
40 inline void *
41 _Jv_AllocPtrFreeObj (jsize size, jclass klass)
43 #ifdef JV_HASH_SYNCHRONIZATION
44 void * obj = GC_malloc_atomic(size);
45 *((_Jv_VTable **) obj) = klass->vtable;
46 #else
47 void * obj = GC_gcj_malloc(size, klass->vtable);
48 #endif
49 return obj;
52 // _Jv_AllocBytes (jsize size) should go here, too. But clients don't
53 // usually include this header.
55 #endif /* __JV_BOEHM_GC__ */