Skip to content

Commit 6ef538d

Browse files
authored
[meta] Add embedding API function to get the default ALC (#35191)
* Formatting fixes * Add embedding API function get the default ALC
1 parent 9188a58 commit 6ef538d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/mono/mono/metadata/assembly-load-context.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "mono/metadata/icall-decl.h"
1010
#include "mono/metadata/loader-internals.h"
1111
#include "mono/metadata/loaded-images-internals.h"
12+
#include "mono/metadata/mono-private-unstable.h"
1213
#include "mono/utils/mono-error-internals.h"
1314
#include "mono/utils/mono-logger-internals.h"
1415

@@ -180,6 +181,13 @@ mono_alc_from_gchandle (MonoGCHandle alc_gchandle)
180181
return alc;
181182
}
182183

184+
MonoGCHandle
185+
mono_alc_get_default_gchandle (void)
186+
{
187+
// Because the default domain is never unloadable, this should be a strong handle and never change
188+
return mono_domain_default_alc (mono_domain_get ())->gchandle;
189+
}
190+
183191
static MonoAssembly*
184192
invoke_resolve_method (MonoMethod *resolve_method, MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, MonoError *error)
185193
{

src/mono/mono/metadata/mono-private-unstable.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616

1717
typedef MonoGCHandle MonoAssemblyLoadContextGCHandle;
1818

19-
MONO_API MONO_RT_EXTERNAL_ONLY
20-
MonoAssembly *mono_assembly_load_full_alc (MonoAssemblyLoadContextGCHandle alc_gchandle, MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status);
19+
MONO_API MONO_RT_EXTERNAL_ONLY MonoAssembly *
20+
mono_assembly_load_full_alc (MonoAssemblyLoadContextGCHandle alc_gchandle, MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status);
2121

2222
typedef MonoAssembly * (*MonoAssemblyPreLoadFuncV3) (MonoAssemblyLoadContextGCHandle *alc_gchandle, MonoAssemblyName *aname, char **assemblies_path, gpointer user_data, MonoError *error);
23-
void mono_install_assembly_preload_hook_v3 (MonoAssemblyPreLoadFuncV3 func, gpointer user_data, gboolean append);
23+
24+
MONO_API MONO_RT_EXTERNAL_ONLY void
25+
mono_install_assembly_preload_hook_v3 (MonoAssemblyPreLoadFuncV3 func, gpointer user_data, gboolean append);
26+
27+
MONO_API MONO_RT_EXTERNAL_ONLY MonoAssemblyLoadContextGCHandle
28+
mono_alc_get_default_gchandle (void);
2429

2530
#endif /*__MONO_METADATA_MONO_PRIVATE_UNSTABLE_H__*/

0 commit comments

Comments
 (0)