Skip to content

Commit bed4625

Browse files
authored
Merge pull request #961 from Unity-Technologies/unity-master-gc-enable-disable
GC enable/disable APIs for unity-master
2 parents a2b068d + 7f5ddea commit bed4625

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

mono/metadata/unity-utils.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#include <mono/metadata/tokentype.h>
3131
#include <mono/utils/mono-string.h>
3232

33+
#if HAVE_BDWGC_GC
34+
#include <external/bdwgc/include/gc.h>
35+
#endif
36+
3337
#include <glib.h>
3438

3539
#ifdef WIN32
@@ -900,6 +904,35 @@ mono_unity_get_unitytls_interface()
900904
return gUnitytlsInterface;
901905
}
902906

907+
// gc
908+
MONO_API void mono_unity_gc_enable()
909+
{
910+
#if HAVE_BDWGC_GC
911+
GC_enable();
912+
#else
913+
g_assert_not_reached ();
914+
#endif
915+
}
916+
917+
MONO_API void mono_unity_gc_disable()
918+
{
919+
#if HAVE_BDWGC_GC
920+
GC_disable();
921+
#else
922+
g_assert_not_reached ();
923+
#endif
924+
}
925+
926+
MONO_API int mono_unity_gc_is_disabled()
927+
{
928+
#if HAVE_BDWGC_GC
929+
return GC_is_disabled ();
930+
#else
931+
g_assert_not_reached ();
932+
return 0;
933+
#endif
934+
}
935+
903936
MONO_API void
904937
mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks)
905938
{

mono/metadata/unity-utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ typedef struct unitytls_interface_struct unitytls_interface_struct;
150150
MONO_API unitytls_interface_struct* mono_unity_get_unitytls_interface();
151151
MONO_API void mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks);
152152

153+
// gc
154+
MONO_API void mono_unity_gc_enable();
155+
MONO_API void mono_unity_gc_disable();
156+
MONO_API int mono_unity_gc_is_disabled();
157+
153158
//misc
154159
MonoAssembly* mono_unity_assembly_get_mscorlib();
155160
MonoImage* mono_unity_image_get_mscorlib();

0 commit comments

Comments
 (0)