1 /** 2 * \file 3 * String internal calls for the corlib 4 * 5 * Author: 6 * Patrik Torstensson (patrik.torstensson@labs2.com) 7 * Duncan Mak (duncan@ximian.com) 8 * 9 * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com) 10 * Copyright 2004-2009 Novell, Inc (http://www.novell.com) 11 * Licensed under the MIT license. See LICENSE file in the project root for full license information. 12 */ 13 #include <config.h> 14 #include <stdlib.h> 15 #include <stdio.h> 16 #include <string.h> 17 #include "mono/utils/mono-membar.h" 18 #include <mono/metadata/string-icalls.h> 19 #include <mono/metadata/class-internals.h> 20 #include <mono/metadata/appdomain.h> 21 #include <mono/metadata/tabledefs.h> 22 #include <mono/metadata/loader.h> 23 #include <mono/metadata/object.h> 24 #include <mono/metadata/exception.h> 25 #include <mono/metadata/debug-helpers.h> 26 #include <mono/metadata/gc-internals.h> 27 28 /* This function is redirected to String.CreateString () 29 by mono_marshal_get_native_wrapper () */ 30 void ves_icall_System_String_ctor_RedirectToCreateString(void)31ves_icall_System_String_ctor_RedirectToCreateString (void) 32 { 33 g_assert_not_reached (); 34 } 35 36 MonoString * ves_icall_System_String_InternalAllocateStr(gint32 length)37ves_icall_System_String_InternalAllocateStr (gint32 length) 38 { 39 MonoError error; 40 MonoString *str = mono_string_new_size_checked (mono_domain_get (), length, &error); 41 mono_error_set_pending_exception (&error); 42 43 return str; 44 } 45 46 MonoString * ves_icall_System_String_InternalIntern(MonoString * str)47ves_icall_System_String_InternalIntern (MonoString *str) 48 { 49 MonoError error; 50 MonoString *res; 51 52 res = mono_string_intern_checked (str, &error); 53 if (!res) { 54 mono_error_set_pending_exception (&error); 55 return NULL; 56 } 57 return res; 58 } 59 60 MonoString * ves_icall_System_String_InternalIsInterned(MonoString * str)61ves_icall_System_String_InternalIsInterned (MonoString *str) 62 { 63 return mono_string_is_interned (str); 64 } 65 66 int ves_icall_System_String_GetLOSLimit(void)67ves_icall_System_String_GetLOSLimit (void) 68 { 69 int limit = mono_gc_get_los_limit (); 70 71 return (limit - 2 - G_STRUCT_OFFSET (MonoString, chars)) / 2; 72 } 73 74