[meta] Add embedding API function to get the default ALC (#35191)
authorRyan Lucia <rylucia@microsoft.com>
Thu, 23 Apr 2020 15:49:30 +0000 (11:49 -0400)
committerGitHub <noreply@github.com>
Thu, 23 Apr 2020 15:49:30 +0000 (11:49 -0400)
* Formatting fixes

* Add embedding API function get the default ALC

src/mono/mono/metadata/assembly-load-context.c
src/mono/mono/metadata/mono-private-unstable.h

index 4ef72e4..7aa927d 100644 (file)
@@ -9,6 +9,7 @@
 #include "mono/metadata/icall-decl.h"
 #include "mono/metadata/loader-internals.h"
 #include "mono/metadata/loaded-images-internals.h"
+#include "mono/metadata/mono-private-unstable.h"
 #include "mono/utils/mono-error-internals.h"
 #include "mono/utils/mono-logger-internals.h"
 
@@ -180,6 +181,13 @@ mono_alc_from_gchandle (MonoGCHandle alc_gchandle)
        return alc;
 }
 
+MonoGCHandle
+mono_alc_get_default_gchandle (void)
+{
+       // Because the default domain is never unloadable, this should be a strong handle and never change
+       return mono_domain_default_alc (mono_domain_get ())->gchandle;
+}
+
 static MonoAssembly*
 invoke_resolve_method (MonoMethod *resolve_method, MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, MonoError *error)
 {
index 4535578..abb02b4 100644 (file)
 
 typedef MonoGCHandle MonoAssemblyLoadContextGCHandle;
 
-MONO_API MONO_RT_EXTERNAL_ONLY
-MonoAssembly *mono_assembly_load_full_alc (MonoAssemblyLoadContextGCHandle alc_gchandle, MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status);
+MONO_API MONO_RT_EXTERNAL_ONLY MonoAssembly *
+mono_assembly_load_full_alc (MonoAssemblyLoadContextGCHandle alc_gchandle, MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status);
 
 typedef MonoAssembly * (*MonoAssemblyPreLoadFuncV3) (MonoAssemblyLoadContextGCHandle *alc_gchandle, MonoAssemblyName *aname, char **assemblies_path, gpointer user_data, MonoError *error);
-void mono_install_assembly_preload_hook_v3 (MonoAssemblyPreLoadFuncV3 func, gpointer user_data, gboolean append);
+
+MONO_API MONO_RT_EXTERNAL_ONLY void
+mono_install_assembly_preload_hook_v3 (MonoAssemblyPreLoadFuncV3 func, gpointer user_data, gboolean append);
+
+MONO_API MONO_RT_EXTERNAL_ONLY MonoAssemblyLoadContextGCHandle
+mono_alc_get_default_gchandle (void);
 
 #endif /*__MONO_METADATA_MONO_PRIVATE_UNSTABLE_H__*/