+2009-05-28 Zoltan Varga <vargaz@gmail.com>
+
+ * object-internals.h (MonoRuntimeCallbacks): New structure containing
+ callbacks supplied by the runtime.
+
+ * object.c (mono_install_callbacks): New internal function to install
+ the callbacks.
+
+ * object.c (mono_create_ftnptr): Move the implementation of this to
+ mini/.
+
+ * object.c (mono_get_addr_from_ftnptr): Ditto.
+
2009-05-27 Rodrigo Kumpera <rkumpera@novell.com>
* metadata-verify.c (parse_return_type): Proper byref check.
guint32 intType;
} MonoInterfaceTypeAttribute;
+/*
+ * Callbacks supplied by the runtime and called by the modules in metadata/
+ * This interface is easier to extend than adding a new function type +
+ * a new 'install' function for every callback.
+ */
+typedef struct {
+ gpointer (*create_ftnptr) (MonoDomain *domain, gpointer addr);
+ gpointer (*get_addr_from_ftnptr) (gpointer descr);
+} MonoRuntimeCallbacks;
+
/* used to free a dynamic method */
typedef void (*MonoFreeMethodFunc) (MonoDomain *domain, MonoMethod *method);
void
mono_install_free_method (MonoFreeMethodFunc func) MONO_INTERNAL;
+void
+mono_install_callbacks (MonoRuntimeCallbacks *cbs) MONO_INTERNAL;
+
void
mono_type_initialization_init (void) MONO_INTERNAL;
/* Main thread */
static MonoThread *main_thread;
+/* Functions supplied by the runtime */
+static MonoRuntimeCallbacks callbacks;
+
/**
* mono_thread_set_main:
* @thread: thread to set as the main thread
#error "MONO_IMT_SIZE cannot be larger than 32"
#endif
+void
+mono_install_callbacks (MonoRuntimeCallbacks *cbs)
+{
+ memcpy (&callbacks, cbs, sizeof (*cbs));
+}
+
void
mono_install_trampoline (MonoTrampoline func)
{
* mono_create_ftnptr:
*
* Given a function address, create a function descriptor for it.
- * This is only needed on IA64 and PPC64.
+ * This is only needed on some platforms.
*/
gpointer
mono_create_ftnptr (MonoDomain *domain, gpointer addr)
{
-#ifdef __ia64__
- gpointer *desc;
-
- desc = mono_domain_code_reserve (domain, 2 * sizeof (gpointer));
-
- desc [0] = addr;
- desc [1] = NULL;
-
- return desc;
-#elif defined(__ppc64__) || defined(__powerpc64__)
- gpointer *desc;
-
- desc = mono_domain_alloc0 (domain, 3 * sizeof (gpointer));
-
- desc [0] = addr;
- desc [1] = NULL;
- desc [2] = NULL;
-
- return desc;
-#else
- return addr;
-#endif
+ return callbacks.create_ftnptr (domain, addr);
}
/*
* mono_get_addr_from_ftnptr:
*
* Given a pointer to a function descriptor, return the function address.
- * This is only needed on IA64 and PPC64.
+ * This is only needed on some platforms.
*/
gpointer
mono_get_addr_from_ftnptr (gpointer descr)
{
-#if defined(__ia64__) || defined(__ppc64__) || defined(__powerpc64__)
- return *(gpointer*)descr;
-#else
- return descr;
-#endif
+ return callbacks.get_addr_from_ftnptr (descr);
}
#if 0