[bcl] Update BCL Linked Size
[mono-project.git] / libgc / include / gc_gcj.h
blob660d9d337a3df6e2dc55bb3e4dba91e748df824d
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.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
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.
17 /* This file assumes the collector has been compiled with GC_GCJ_SUPPORT */
18 /* and that an ANSI C compiler is available. */
21 * We allocate objects whose first word contains a pointer to a struct
22 * describing the object type. This struct contains a garbage collector mark
23 * descriptor at offset MARK_DESCR_OFFSET. Alternatively, the objects
24 * may be marked by the mark procedure passed to GC_init_gcj_malloc.
27 #ifndef GC_GCJ_H
29 #define GC_GCJ_H
31 #ifndef MARK_DESCR_OFFSET
32 # define MARK_DESCR_OFFSET sizeof(word)
33 #endif
34 /* Gcj keeps GC descriptor as second word of vtable. This */
35 /* probably needs to be adjusted for other clients. */
36 /* We currently assume that this offset is such that: */
37 /* - all objects of this kind are large enough to have */
38 /* a value at that offset, and */
39 /* - it is not zero. */
40 /* These assumptions allow objects on the free list to be */
41 /* marked normally. */
43 #ifndef _GC_H
44 # include "gc.h"
45 #endif
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 /* The following allocators signal an out of memory condition with */
52 /* return GC_oom_fn(bytes); */
54 /* The following function must be called before the gcj allocators */
55 /* can be invoked. */
56 /* mp_index and mp are the index and mark_proc (see gc_mark.h) */
57 /* respectively for the allocated objects. Mark_proc will be */
58 /* used to build the descriptor for objects allocated through the */
59 /* debugging interface. The mark_proc will be invoked on all such */
60 /* objects with an "environment" value of 1. The client may choose */
61 /* to use the same mark_proc for some of its generated mark descriptors.*/
62 /* In that case, it should use a different "environment" value to */
63 /* detect the presence or absence of the debug header. */
64 /* Mp is really of type mark_proc, as defined in gc_mark.h. We don't */
65 /* want to include that here for namespace pollution reasons. */
66 extern void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp);
68 /* Allocate an object, clear it, and store the pointer to the */
69 /* type structure (vtable in gcj). */
70 /* This adds a byte at the end of the object if GC_malloc would.*/
71 extern void * GC_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr);
72 /* The debug versions allocate such that the specified mark_proc */
73 /* is always invoked. */
74 extern void * GC_debug_gcj_malloc(size_t lb,
75 void * ptr_to_struct_containing_descr,
76 GC_EXTRA_PARAMS);
78 /* Similar to the above, but the size is in words, and we don't */
79 /* adjust it. The size is assumed to be such that it can be */
80 /* allocated as a small object. */
81 /* Unless it is known that the collector is not configured */
82 /* with USE_MARK_BYTES and unless it is known that the object */
83 /* has weak alignment requirements, lw must be even. */
84 extern void * GC_gcj_fast_malloc(size_t lw,
85 void * ptr_to_struct_containing_descr);
86 extern void * GC_debug_gcj_fast_malloc(size_t lw,
87 void * ptr_to_struct_containing_descr,
88 GC_EXTRA_PARAMS);
90 /* Similar to GC_gcj_malloc, but assumes that a pointer to near the */
91 /* beginning of the resulting object is always maintained. */
92 extern void * GC_gcj_malloc_ignore_off_page(size_t lb,
93 void * ptr_to_struct_containing_descr);
95 /* The kind numbers of normal and debug gcj objects. */
96 /* Useful only for debug support, we hope. */
97 extern int GC_gcj_kind;
99 extern int GC_gcj_debug_kind;
101 # if defined(GC_LOCAL_ALLOC_H) && defined(GC_REDIRECT_TO_LOCAL)
102 --> gc_local_alloc.h should be included after this. Otherwise
103 --> we undo the redirection.
104 # endif
106 # ifdef GC_DEBUG
107 # define GC_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
108 # define GC_GCJ_FAST_MALLOC(s,d) GC_debug_gcj_fast_malloc(s,d,GC_EXTRAS)
109 # define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
110 # else
111 # define GC_GCJ_MALLOC(s,d) GC_gcj_malloc(s,d)
112 # define GC_GCJ_FAST_MALLOC(s,d) GC_gcj_fast_malloc(s,d)
113 # define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) \
114 GC_gcj_malloc_ignore_off_page(s,d)
115 # endif
117 #ifdef __cplusplus
118 } // extern "C"
119 #endif
121 #endif /* GC_GCJ_H */