boehm-gc.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // -*- c++ -*-
  2. // boehm-gc.h - Defines for Boehm collector.
  3. /* Copyright (C) 1998, 1999, 2002, 2004, 2006, 2007 Free Software Foundation
  4. This file is part of libgcj.
  5. This software is copyrighted work licensed under the terms of the
  6. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  7. details. */
  8. #ifndef __JV_BOEHM_GC__
  9. #define __JV_BOEHM_GC__
  10. #define JV_MARKOBJ_DECL void *::_Jv_MarkObj (void *, void *, void *, void *)
  11. #define JV_MARKARRAY_DECL void *::_Jv_MarkArray (void *, void *, void *, void *)
  12. extern "C"
  13. {
  14. void *_Jv_MarkObj (void *, void *, void *, void *);
  15. void *_Jv_MarkArray (void *, void *, void *, void *);
  16. void _Jv_RegisterLibForGc (const void *);
  17. }
  18. // Enough stuff to inline _Jv_AllocObj. Ugly.
  19. #include <gcj/javaprims.h>
  20. #include <java/lang/Class.h>
  21. #include <string.h>
  22. #include <gc_ext_config.h> // for THREAD_LOCAL_ALLOC
  23. extern "C" void * GC_gcj_malloc(size_t, void *);
  24. extern "C" void * GC_malloc_atomic(size_t);
  25. #ifdef THREAD_LOCAL_ALLOC
  26. extern "C" void * GC_local_gcj_malloc(size_t, void *);
  27. extern "C" void * GC_local_malloc_atomic(size_t);
  28. #endif
  29. #ifndef LIBGCJ_GC_DEBUG
  30. inline void *
  31. _Jv_AllocObj (jsize size, jclass klass)
  32. {
  33. // This should call GC_GCJ_MALLOC, but that would involve
  34. // including gc.h.
  35. #ifdef THREAD_LOCAL_ALLOC
  36. return GC_local_gcj_malloc (size, klass->vtable);
  37. #else
  38. return GC_gcj_malloc (size, klass->vtable);
  39. #endif
  40. }
  41. inline void *
  42. _Jv_AllocPtrFreeObj (jsize size, jclass klass)
  43. {
  44. #ifdef JV_HASH_SYNCHRONIZATION
  45. # ifdef THREAD_LOCAL_ALLOC
  46. void * obj = GC_local_malloc_atomic(size);
  47. # else
  48. void * obj = GC_malloc_atomic(size);
  49. # endif
  50. *((_Jv_VTable **) obj) = klass->vtable;
  51. #else
  52. # ifdef THREAD_LOCAL_ALLOC
  53. void * obj = GC_local_gcj_malloc(size, klass->vtable);
  54. # else
  55. void * obj = GC_gcj_malloc(size, klass->vtable);
  56. # endif
  57. #endif
  58. return obj;
  59. }
  60. #else /* LIBGCJ_GC_DEBUG */
  61. void *
  62. _Jv_AllocObj (jsize size, jclass klass);
  63. void *
  64. _Jv_AllocPtrFreeObj (jsize size, jclass klass);
  65. #endif /* LIBGCJ_GC_DEBUG */
  66. void _Jv_GCAttachThread ();
  67. void _Jv_GCDetachThread ();
  68. // _Jv_AllocBytes (jsize size) should go here, too. But clients don't
  69. // usually include this header.
  70. // Suspend the given thread. This includes suspending the calling thread.
  71. extern "C" void _Jv_SuspendThread (_Jv_Thread_t *);
  72. // Resume a suspended thread.
  73. extern "C" void _Jv_ResumeThread (_Jv_Thread_t *);
  74. // Is the given thread suspended?
  75. extern "C" int _Jv_IsThreadSuspended (_Jv_Thread_t *);
  76. #endif /* __JV_BOEHM_GC__ */