19
19
* This interface should not be used by normal C or C++ clients.
20
20
* It will be useful to runtimes for other languages.
22
* Note that this file is not "namespace-clean", i.e. it introduces names
23
* not prefixed with GC_, which may collide with the client's names. It
24
* should be included only in those few places that directly provide
25
* information to the collector.
22
* This is an experts-only interface! There are many ways to break the
23
* collector in subtle ways by using this functionality.
129
127
/* be reserved for exceptional cases. That will ensure that */
130
128
/* performance of this call is not extremely performance critical. */
131
129
/* (Otherwise we would need to inline GC_mark_and_push completely, */
132
/* which would tie the client code to a fixed colllector version.) */
130
/* which would tie the client code to a fixed collector version.) */
131
/* Note that mark procedures should explicitly call FIXUP_POINTER() */
133
133
struct GC_ms_entry *GC_mark_and_push
134
134
GC_PROTO((GC_PTR obj,
135
135
struct GC_ms_entry * mark_stack_ptr,
141
141
GC_mark_and_push(obj, msp, lim, src) : \
144
extern size_t GC_debug_header_size;
145
/* The size of the header added to objects allocated through */
146
/* the GC_debug routines. */
147
/* Defined as a variable so that client mark procedures don't */
148
/* need to be recompiled for collector version changes. */
149
#define GC_USR_PTR_FROM_BASE(p) ((GC_PTR)((char *)(p) + GC_debug_header_size))
151
/* And some routines to support creation of new "kinds", e.g. with */
152
/* custom mark procedures, by language runtimes. */
153
/* The _inner versions assume the caller holds the allocation lock. */
155
/* Return a new free list array. */
156
void ** GC_new_free_list GC_PROTO((void));
157
void ** GC_new_free_list_inner GC_PROTO((void));
159
/* Return a new kind, as specified. */
160
int GC_new_kind GC_PROTO((void **free_list, GC_word mark_descriptor_template,
161
int add_size_to_descriptor, int clear_new_objects));
162
/* The last two parameters must be zero or one. */
163
int GC_new_kind_inner GC_PROTO((void **free_list,
164
GC_word mark_descriptor_template,
165
int add_size_to_descriptor,
166
int clear_new_objects));
168
/* Return a new mark procedure identifier, suitable for use as */
169
/* the first argument in GC_MAKE_PROC. */
170
int GC_new_proc GC_PROTO((GC_mark_proc));
171
int GC_new_proc_inner GC_PROTO((GC_mark_proc));
173
/* Allocate an object of a given kind. Note that in multithreaded */
174
/* contexts, this is usually unsafe for kinds that have the descriptor */
175
/* in the object itself, since there is otherwise a window in which */
176
/* the descriptor is not correct. Even in the single-threaded case, */
177
/* we need to be sure that cleared objects on a free list don't */
178
/* cause a GC crash if they are accidentally traced. */
179
/* ptr_t */char * GC_generic_malloc GC_PROTO((GC_word lb, int k));
181
/* FIXME - Should return void *, but that requires other changes. */
183
typedef void (*GC_describe_type_fn) GC_PROTO((void *p, char *out_buf));
184
/* A procedure which */
185
/* produces a human-readable */
186
/* description of the "type" of object */
187
/* p into the buffer out_buf of length */
188
/* GC_TYPE_DESCR_LEN. This is used by */
189
/* the debug support when printing */
191
/* These functions should be as robust */
192
/* as possible, though we do avoid */
193
/* invoking them on objects on the */
194
/* global free list. */
195
# define GC_TYPE_DESCR_LEN 40
197
void GC_register_describe_type_fn GC_PROTO((int kind, GC_describe_type_fn knd));
198
/* Register a describe_type function */
199
/* to be used when printing objects */
200
/* of a particular kind. */
144
202
#endif /* GC_MARK_H */