/libs/headers/gc/gc_gcj.h

http://github.com/nddrylliog/ooc · C++ Header · 94 lines · 26 code · 14 blank · 54 comment · 0 complexity · 7b0b9c97767f75f4c4b9822c13493fc0 MD5 · raw file

  1. /*
  2. * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
  3. * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
  4. * Copyright 1996-1999 by Silicon Graphics. All rights reserved.
  5. * Copyright 1999 by Hewlett-Packard Company. All rights reserved.
  6. *
  7. * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  8. * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
  9. *
  10. * Permission is hereby granted to use or copy this program
  11. * for any purpose, provided the above notices are retained on all copies.
  12. * Permission to modify the code and to distribute modified code is granted,
  13. * provided the above notices are retained, and a notice that the code was
  14. * modified is included with the above copyright notice.
  15. */
  16. /* This file assumes the collector has been compiled with GC_GCJ_SUPPORT */
  17. /* and that an ANSI C compiler is available. */
  18. /*
  19. * We allocate objects whose first word contains a pointer to a struct
  20. * describing the object type. This struct contains a garbage collector mark
  21. * descriptor at offset MARK_DESCR_OFFSET. Alternatively, the objects
  22. * may be marked by the mark procedure passed to GC_init_gcj_malloc.
  23. */
  24. #ifndef GC_GCJ_H
  25. #define GC_GCJ_H
  26. #ifndef MARK_DESCR_OFFSET
  27. # define MARK_DESCR_OFFSET sizeof(word)
  28. #endif
  29. /* Gcj keeps GC descriptor as second word of vtable. This */
  30. /* probably needs to be adjusted for other clients. */
  31. /* We currently assume that this offset is such that: */
  32. /* - all objects of this kind are large enough to have */
  33. /* a value at that offset, and */
  34. /* - it is not zero. */
  35. /* These assumptions allow objects on the free list to be */
  36. /* marked normally. */
  37. #ifndef _GC_H
  38. # include "gc.h"
  39. #endif
  40. /* The following allocators signal an out of memory condition with */
  41. /* return GC_oom_fn(bytes); */
  42. /* The following function must be called before the gcj allocators */
  43. /* can be invoked. */
  44. /* mp_index and mp are the index and mark_proc (see gc_mark.h) */
  45. /* respectively for the allocated objects. Mark_proc will be */
  46. /* used to build the descriptor for objects allocated through the */
  47. /* debugging interface. The mark_proc will be invoked on all such */
  48. /* objects with an "environment" value of 1. The client may choose */
  49. /* to use the same mark_proc for some of its generated mark descriptors.*/
  50. /* In that case, it should use a different "environment" value to */
  51. /* detect the presence or absence of the debug header. */
  52. /* Mp is really of type mark_proc, as defined in gc_mark.h. We don't */
  53. /* want to include that here for namespace pollution reasons. */
  54. extern void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp);
  55. /* Allocate an object, clear it, and store the pointer to the */
  56. /* type structure (vtable in gcj). */
  57. /* This adds a byte at the end of the object if GC_malloc would.*/
  58. extern void * GC_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr);
  59. /* The debug versions allocate such that the specified mark_proc */
  60. /* is always invoked. */
  61. extern void * GC_debug_gcj_malloc(size_t lb,
  62. void * ptr_to_struct_containing_descr,
  63. GC_EXTRA_PARAMS);
  64. /* Similar to GC_gcj_malloc, but assumes that a pointer to near the */
  65. /* beginning of the resulting object is always maintained. */
  66. extern void * GC_gcj_malloc_ignore_off_page(size_t lb,
  67. void * ptr_to_struct_containing_descr);
  68. /* The kind numbers of normal and debug gcj objects. */
  69. /* Useful only for debug support, we hope. */
  70. extern int GC_gcj_kind;
  71. extern int GC_gcj_debug_kind;
  72. # ifdef GC_DEBUG
  73. # define GC_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
  74. # define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
  75. # else
  76. # define GC_GCJ_MALLOC(s,d) GC_gcj_malloc(s,d)
  77. # define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) \
  78. GC_gcj_malloc_ignore_off_page(s,d)
  79. # endif
  80. #endif /* GC_GCJ_H */