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