New test.
[mono.git] / mono / metadata / gc-internal.h
1 /*
2  * metadata/gc-internal.h: GC icalls.
3  *
4  * Author: Paolo Molaro <lupus@ximian.com>
5  *
6  * (C) 2002 Ximian, Inc.
7  */
8
9 #ifndef __MONO_METADATA_GC_H__
10 #define __MONO_METADATA_GC_H__
11
12 #include <glib.h>
13 #include <mono/metadata/object-internals.h>
14
15 void   mono_object_register_finalizer               (MonoObject  *obj);
16 void   ves_icall_System_GC_InternalCollect          (int          generation);
17 gint64 ves_icall_System_GC_GetTotalMemory           (MonoBoolean  forceCollection);
18 void   ves_icall_System_GC_KeepAlive                (MonoObject  *obj);
19 void   ves_icall_System_GC_ReRegisterForFinalize    (MonoObject  *obj);
20 void   ves_icall_System_GC_SuppressFinalize         (MonoObject  *obj);
21 void   ves_icall_System_GC_WaitForPendingFinalizers (void);
22
23 MonoObject *ves_icall_System_GCHandle_GetTarget (guint32 handle);
24 guint32     ves_icall_System_GCHandle_GetTargetHandle (MonoObject *obj, guint32 handle, gint32 type);
25 void        ves_icall_System_GCHandle_FreeHandle (guint32 handle);
26 gpointer    ves_icall_System_GCHandle_GetAddrOfPinnedObject (guint32 handle);
27
28 extern void mono_gc_init (void);
29 extern void mono_gc_base_init (void);
30 extern void mono_gc_cleanup (void);
31 extern void mono_gc_enable (void);
32 extern void mono_gc_disable (void);
33
34 /*
35  * Return whenever the current thread is registered with the GC (i.e. started
36  * by the GC pthread wrappers on unix.
37  */
38 extern gboolean mono_gc_is_gc_thread (void);
39
40 /*
41  * Try to register a foreign thread with the GC, if we fail or the backend
42  * can't cope with this concept - we return FALSE.
43  */
44 extern gboolean mono_gc_register_thread (void *baseptr);
45
46 /* only valid after the RECLAIM_START GC event and before RECLAIM_END
47  * Not exported in public headers, but can be linked to (unsupported).
48  */
49 extern gboolean mono_object_is_alive (MonoObject* obj);
50 extern gboolean mono_gc_is_finalizer_thread (MonoThread *thread);
51 extern gpointer mono_gc_out_of_memory (size_t size);
52 extern void     mono_gc_enable_events (void);
53
54 /* disappearing link functionality */
55 void        mono_gc_weak_link_add    (void **link_addr, MonoObject *obj);
56 void        mono_gc_weak_link_remove (void **link_addr);
57 MonoObject *mono_gc_weak_link_get    (void **link_addr);
58
59 /* simple interface for data structures needed in the runtime */
60 void* mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits);
61 /* desc is the result from mono_gc_make_descr*. A NULL value means
62  * all the words contain GC pointers.
63  * The memory is non-moving and it will be explicitly deallocated.
64  * size bytes will be available from the returned address (ie, descr
65  * must not be stored in the returned memory)
66  */
67 void* mono_gc_alloc_fixed            (size_t size, void *descr);
68 void  mono_gc_free_fixed             (void* addr);
69
70 /* make sure the gchandle was allocated for an object in domain */
71 gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain);
72 void     mono_gchandle_free_domain  (MonoDomain *domain);
73
74 /* if there are finalizers to run, run them. Returns the number of finalizers run */
75 int      mono_gc_invoke_finalizers  (void);
76 gboolean mono_gc_pending_finalizers (void);
77 void     mono_gc_finalize_notify    (void);
78
79 void* mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size);
80 void* mono_gc_alloc_obj (MonoVTable *vtable, size_t size);
81 void* mono_gc_make_descr_for_string (void);
82 void* mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size);
83 void* mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, int numbits, size_t elem_size);
84
85 void  mono_gc_register_for_finalization (MonoObject *obj, void *user_data);
86 void  mono_gc_add_memory_pressure (gint64 value);
87 int   mono_gc_register_root (char *start, size_t size, void *descr);
88 void  mono_gc_deregister_root (char* addr);
89 #endif /* __MONO_METADATA_GC_H__ */
90