First set of licensing changes
[mono.git] / mono / metadata / security-core-clr.c
index 07f5da24dbcb91568711a7d5e558ce2cda624d30..4c6589176b8da7d36be39242e0997c12c5e40afa 100644 (file)
@@ -6,6 +6,7 @@
  *     Sebastien Pouliot  <sebastien@ximian.com>
  *
  * Copyright 2007-2010 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <mono/metadata/class-internals.h>
@@ -16,7 +17,7 @@
 #include <mono/metadata/object.h>
 #include <mono/metadata/exception.h>
 #include <mono/metadata/debug-helpers.h>
-#include <mono/utils/mono-logger-internal.h>
+#include <mono/utils/mono-logger-internals.h>
 
 #include "security-core-clr.h"
 
@@ -122,30 +123,21 @@ mono_security_core_clr_is_platform_image (MonoImage *image)
 
 #ifndef DISABLE_SECURITY
 
+/* Class lazy loading functions */
+static GENERATE_GET_CLASS_WITH_CACHE (security_critical, System.Security, SecurityCriticalAttribute)
+static GENERATE_GET_CLASS_WITH_CACHE (security_safe_critical, System.Security, SecuritySafeCriticalAttribute)
+
 static MonoClass*
 security_critical_attribute (void)
 {
-       static MonoClass *klass = NULL;
-
-       if (!klass) {
-               klass = mono_class_from_name (mono_defaults.corlib, "System.Security", 
-                       "SecurityCriticalAttribute");
-       }
-       g_assert (klass);
-       return klass;
+       return mono_class_get_security_critical_class ();
 }
 
 static MonoClass*
 security_safe_critical_attribute (void)
 {
-       static MonoClass *klass = NULL;
+       return mono_class_get_security_safe_critical_class ();
 
-       if (!klass) {
-               klass = mono_class_from_name (mono_defaults.corlib, "System.Security", 
-                       "SecuritySafeCriticalAttribute");
-       }
-       g_assert (klass);
-       return klass;
 }
 
 /* sometime we get a NULL (not found) caller (e.g. get_reflection_caller) */
@@ -332,7 +324,7 @@ mono_security_core_clr_check_override (MonoClass *klass, MonoMethod *override, M
 static gboolean
 get_caller_no_reflection_related (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
 {
-       MonoMethod **dest = data;
+       MonoMethod **dest = (MonoMethod **)data;
        const char *ns;
 
        /* skip unmanaged frames */
@@ -436,7 +428,7 @@ typedef struct {
 static gboolean
 get_caller_of_elevated_trust_code (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
 {
-       ElevatedTrustCookie *cookie = data;
+       ElevatedTrustCookie *cookie = (ElevatedTrustCookie *)data;
 
        /* skip unmanaged frames and wrappers */
        if (!managed || (m->wrapper_type != MONO_WRAPPER_NONE))
@@ -917,7 +909,7 @@ mono_security_core_clr_level_from_cinfo (MonoCustomAttrInfo *cinfo, MonoImage *i
        if (cinfo && mono_custom_attrs_has_attr (cinfo, security_critical_attribute ()))
                level = MONO_SECURITY_CORE_CLR_CRITICAL;
 
-       return level;
+       return (MonoSecurityCoreCLRLevel)level;
 }
 
 /*