Merge pull request #2174 from stukselbax/master
[mono.git] / mono / metadata / mono-gc.h
1 /*
2  * mono-gc.h: GC related public interface
3  *
4  */
5 #ifndef __METADATA_MONO_GC_H__
6 #define __METADATA_MONO_GC_H__
7
8 #include <mono/metadata/object.h>
9
10 MONO_BEGIN_DECLS
11
12 typedef int (*MonoGCReferences) (MonoObject *obj, MonoClass *klass, uintptr_t size, uintptr_t num, MonoObject **refs, uintptr_t *offsets, void *data);
13
14 typedef enum {
15         // Roots external to Mono.  Embedders may only use this value.
16         MONO_ROOT_SOURCE_EXTERNAL = 0,
17         // Thread stack.  Must not be used to register roots.
18         MONO_ROOT_SOURCE_STACK = 1,
19         // Roots in the finalizer queue.  Must not be used to register roots.
20         MONO_ROOT_SOURCE_FINALIZER_QUEUE = 2,
21         // Managed static variables.
22         MONO_ROOT_SOURCE_STATIC = 3,
23         // Static variables with ThreadStaticAttribute.
24         MONO_ROOT_SOURCE_THREAD_STATIC = 4,
25         // Static variables with ContextStaticAttribute.
26         MONO_ROOT_SOURCE_CONTEXT_STATIC = 5,
27         // GCHandle structures.
28         MONO_ROOT_SOURCE_GC_HANDLE = 6,
29         // Roots in the just-in-time compiler.
30         MONO_ROOT_SOURCE_JIT = 7,
31         // Roots in the threading subsystem.
32         MONO_ROOT_SOURCE_THREADING = 8,
33         // Roots in application domains.
34         MONO_ROOT_SOURCE_DOMAIN = 9,
35         // Roots in reflection code.
36         MONO_ROOT_SOURCE_REFLECTION = 10,
37         // Roots from P/Invoke or other marshaling.
38         MONO_ROOT_SOURCE_MARSHAL = 11,
39         // Roots in the thread pool data structures.
40         MONO_ROOT_SOURCE_THREAD_POOL = 12,
41         // Roots in the debugger agent.
42         MONO_ROOT_SOURCE_DEBUGGER = 13,
43         // Handle structures, used for object passed to internal functions
44         MONO_ROOT_SOURCE_HANDLE = 14,
45 } MonoGCRootSource;
46
47 MONO_API void   mono_gc_collect         (int generation);
48 MONO_API int    mono_gc_max_generation  (void);
49 MONO_API int    mono_gc_get_generation  (MonoObject *object);
50 MONO_API int    mono_gc_collection_count (int generation);
51 MONO_API int64_t mono_gc_get_used_size   (void);
52 MONO_API int64_t mono_gc_get_heap_size   (void);
53 MONO_API int    mono_gc_invoke_finalizers (void);
54 /* heap walking is only valid in the pre-stop-world event callback */
55 MONO_API int    mono_gc_walk_heap        (int flags, MonoGCReferences callback, void *data);
56
57 MONO_END_DECLS
58
59 #endif /* __METADATA_MONO_GC_H__ */
60