~ubuntu-branches/ubuntu/hardy/libgc/hardy-updates

« back to all changes in this revision

Viewing changes to include/gc_mark.h

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Murray
  • Date: 2005-02-03 00:50:53 UTC
  • mto: (3.1.1 etch) (1.2.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050203005053-9c0v9r2qcm2g1cfp
Tags: upstream-6.4
ImportĀ upstreamĀ versionĀ 6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
21
21
 * 
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.
26
24
 */
27
25
#ifndef GC_MARK_H
28
26
# define GC_MARK_H
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()     */
 
132
/* if required.                                                         */
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) : \
142
142
          msp)
143
143
 
 
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))
 
150
 
 
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.     */
 
154
 
 
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));
 
158
 
 
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));
 
167
 
 
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));
 
172
 
 
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));
 
180
 
 
181
/* FIXME - Should return void *, but that requires other changes.       */
 
182
 
 
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      */
 
190
                                /* objects.                             */ 
 
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
 
196
 
 
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.                */
 
201
 
144
202
#endif  /* GC_MARK_H */
145
203