[runtime] Add a remoting.h file and move the remoting related marshal function declar...
authorZoltan Varga <vargaz@gmail.com>
Fri, 28 Nov 2014 05:23:48 +0000 (06:23 +0100)
committerZoltan Varga <vargaz@gmail.com>
Fri, 28 Nov 2014 05:23:48 +0000 (06:23 +0100)
mono/metadata/Makefile.am
mono/metadata/marshal.c
mono/metadata/marshal.h
mono/metadata/remoting.c
mono/metadata/remoting.h [new file with mode: 0644]

index a99cd440611637609dd517423012e97b4b2ef0a5..cb83933ec1d79c7a666b0fa31d888506321853c5 100644 (file)
@@ -173,6 +173,7 @@ common_sources = \
        profiler-private.h      \
        rand.h                  \
        rand.c                  \
+       remoting.h              \
        remoting.c              \
        runtime.c               \
        security.c              \
index 80815cdddad4439b39419ece9b5b69fb72027f35..904e4041a68a6d6043c9088b1a3f774547aa4590 100644 (file)
@@ -36,6 +36,7 @@
 #include "mono/metadata/attrdefs.h"
 #include "mono/metadata/gc-internal.h"
 #include "mono/metadata/cominterop.h"
+#include "mono/metadata/remoting.h"
 #include "mono/metadata/reflection-internals.h"
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/mono-tls.h"
@@ -244,6 +245,7 @@ mono_marshal_init (void)
                register_icall (mono_gchandle_get_target, "mono_gchandle_get_target", "object int32", TRUE);
 
                mono_cominterop_init ();
+               mono_remoting_init ();
        }
 }
 
index e1f5b0794c128135fe025a4ebb87a8e5a2763b72..eb10aebac1f40742b17cdd28b1cc1357a9445772 100644 (file)
@@ -18,6 +18,7 @@
 #include <mono/metadata/opcodes.h>
 #include <mono/metadata/reflection.h>
 #include <mono/metadata/method-builder.h>
+#include <mono/metadata/remoting.h>
 
 #define mono_marshal_find_bitfield_offset(type, elem, byte_offset, bitmask) \
        do { \
@@ -606,40 +607,6 @@ mono_mb_create_and_cache_full (GHashTable *cache, gpointer key,
                                                           MonoMethodBuilder *mb, MonoMethodSignature *sig,
                                                           int max_stack, WrapperInfo *info, gboolean *out_found) MONO_INTERNAL;
 
-#ifndef DISABLE_REMOTING
-
-MonoMethod *
-mono_marshal_get_remoting_invoke (MonoMethod *method) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_xappdomain_invoke (MonoMethod *method) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_remoting_invoke_for_target (MonoMethod *method, MonoRemotingTarget target_type) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_remoting_invoke_with_check (MonoMethod *method) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_stfld_wrapper (MonoType *type) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_ldfld_wrapper (MonoType *type) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_ldflda_wrapper (MonoType *type) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_ldfld_remote_wrapper (MonoClass *klass) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_stfld_remote_wrapper (MonoClass *klass) MONO_INTERNAL;
-
-MonoMethod *
-mono_marshal_get_proxy_cancast (MonoClass *klass) MONO_INTERNAL;
-
-#endif
-
 G_END_DECLS
 
 #endif /* __MONO_MARSHAL_H__ */
index a45be530aff50291f5c29dab9943ef8073a3c24a..9002bf0f11e903cd63f8bdc2a8df1ca261830af0 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "config.h"
 
+#include "mono/metadata/remoting.h"
 #include "mono/metadata/marshal.h"
 #include "mono/metadata/abi-details.h"
 #include "mono/metadata/cominterop.h"
@@ -64,6 +65,9 @@ mono_marshal_xdomain_copy_out_value (MonoObject *src, MonoObject *dst);
 static MonoReflectionType *
 type_from_handle (MonoType *handle);
 
+static mono_mutex_t remoting_mutex;
+static gboolean remoting_mutex_inited;
+
 static MonoClass *byte_array_class;
 static MonoMethod *method_rs_serialize, *method_rs_deserialize, *method_exc_fixexc, *method_rs_appdomain_target;
 static MonoMethod *method_set_call_context, *method_needs_context_sink, *method_rs_serialize_exc;
@@ -76,6 +80,20 @@ register_icall (gpointer func, const char *name, const char *sigstr, gboolean sa
        mono_register_jit_icall (func, name, sig, save);
 }
 
+static inline void
+remoting_lock (void)
+{
+       g_assert (remoting_mutex_inited);
+       mono_mutex_lock (&remoting_mutex);
+}
+
+static inline void
+remoting_unlock (void)
+{
+       g_assert (remoting_mutex_inited);
+       mono_mutex_unlock (&remoting_mutex);
+}
+
 /*
  * Return the hash table pointed to by VAR, lazily creating it if neccesary.
  */
@@ -83,14 +101,14 @@ static GHashTable*
 get_cache (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func)
 {
        if (!(*var)) {
-               mono_marshal_lock_internal ();
+               remoting_lock ();
                if (!(*var)) {
                        GHashTable *cache = 
                                g_hash_table_new (hash_func, equal_func);
                        mono_memory_barrier ();
                        *var = cache;
                }
-               mono_marshal_unlock_internal ();
+               remoting_unlock ();
        }
        return *var;
 }
@@ -99,18 +117,25 @@ static GHashTable*
 get_cache_full (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func, GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
 {
        if (!(*var)) {
-               mono_marshal_lock_internal ();
+               remoting_lock ();
                if (!(*var)) {
                        GHashTable *cache = 
                                g_hash_table_new_full (hash_func, equal_func, key_destroy_func, value_destroy_func);
                        mono_memory_barrier ();
                        *var = cache;
                }
-               mono_marshal_unlock_internal ();
+               remoting_unlock ();
        }
        return *var;
 }
 
+void
+mono_remoting_init (void)
+{
+       mono_mutex_init (&remoting_mutex);
+       remoting_mutex_inited = TRUE;
+}
+
 static void
 mono_remoting_marshal_init (void)
 {
diff --git a/mono/metadata/remoting.h b/mono/metadata/remoting.h
new file mode 100644 (file)
index 0000000..3176ee4
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * remoting.h: Remoting support
+ *
+ * (C) 2004 Xamarin, Inc.  http://www.xamarin.com
+ *
+ */
+
+#ifndef __MONO_REMOTING_H__
+#define __MONO_REMOTING_H__
+
+#include "config.h"
+#include <mono/metadata/class.h>
+#include <mono/metadata/object-internals.h>
+#include <mono/metadata/class-internals.h>
+
+void mono_remoting_init (void) MONO_INTERNAL;
+
+#ifndef DISABLE_REMOTING
+
+MonoMethod *
+mono_marshal_get_remoting_invoke (MonoMethod *method) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_xappdomain_invoke (MonoMethod *method) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_remoting_invoke_for_target (MonoMethod *method, MonoRemotingTarget target_type) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_remoting_invoke_with_check (MonoMethod *method) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_stfld_wrapper (MonoType *type) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_ldfld_wrapper (MonoType *type) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_ldflda_wrapper (MonoType *type) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_ldfld_remote_wrapper (MonoClass *klass) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_stfld_remote_wrapper (MonoClass *klass) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_proxy_cancast (MonoClass *klass) MONO_INTERNAL;
+
+#endif
+
+#endif