#AC_PREREQ([2.62])
# when bumping version number below, keep it in sync with man/mono.1 too
-AC_INIT(mono, [4.7.0],
+AC_INIT(mono, [4.9.0],
[http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
AC_CONFIG_SRCDIR([README.md])
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
+#include <direct.h>
#ifdef G_OS_WIN32
#include <io.h>
return fd;
}
+gchar *
+g_mkdtemp (char *tmp_template)
+{
+ gunichar2* utf16_template;
+
+ utf16_template = u8to16 (tmp_template);
+
+ utf16_template = _wmktemp(utf16_template);
+ if (utf16_template && *utf16_template) {
+ if (_wmkdir (utf16_template) == 0){
+ char *ret = u16to8 (utf16_template);
+ g_free (utf16_template);
+ return ret;
+ }
+ }
+
+ g_free (utf16_template);
+ return NULL;
+}
+
#ifdef _MSC_VER
#pragma warning(disable:4701)
#endif
#define g_ascii_strtod strtod
#define g_ascii_isalnum isalnum
+#ifdef WIN32
+gchar *g_mkdtemp (gchar *tmpl);
+#else
+#define g_mkdtemp mkdtemp
+#endif
+
/*
* Pattern matching
*/
The
.I mcs
compiler is used to compile against the latest Mono Base Class Library
-version and fully implements C# 1.0, 2.0, 3.0 and 4.0 specifications.
+version and fully implements C# 1.0, 2.0, 3.0, 4.0, 5.0 and 6.0
+specifications.
.PP
See the section on packages for more information.
.PP
.TP
.I "Default"
Instruct compiler to use the latest version. Equivalent is to omit the
-switch (this currently defaults to the C# 4.0 language specification).
+switch (this currently defaults to the C# 6.0 language specification).
.TP
.I "ISO-1"
Restrict compiler to use only first ISO standardized features.
Restrict the compiler to use only the features available in C# 4.0
specification.
.TP
+.I "5"
+Restrict the compiler to use only the features available in C# 5.0
+specification.
+.TP
+.I "6"
+Restrict the compiler to use only the features available in C# 6.0
+specification.
+.TP
.I "experimental"
Enables unstable features from upcoming versions of the language.
.PP
Alternative licensing for the compiler is available from Xamarin.
.PP
.SH SEE ALSO
-csharp(1), mdb(1), mono(1), mopen(1), pkg-config(1), sn(1)
+csharp(1), mono(1), pkg-config(1), sn(1)
.PP
.SH BUGS
To report bugs in the compiler, you must file them on our bug tracking
Or you can use a comma delimited list of the workds CJK, MidWest,
Other, Rare and West to specificy which encoding assemblies to distribute.
.TP
-.TP
.I "-L path"
Adds the `path' do the search list for assemblies. The rules are the
same as for the compiler -lib: or -L flags.
+.TP
+.I "--library [LIB,]PATH"
+Embeds the dynamic library file pointed to by `PATH' and optionally
+give it the name `LIB' into the bundled executable. This is used to
+ship native library dependencies that are unpacked at startup and
+loaded from the runtime.
+.TP
.I "--lists-targets"
Lists all of the available local cross compilation targets available
as precompiled binaries on the Mono distribution server.
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.MailMessage))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.MailPriority))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpAccess))]
+#pragma warning disable 618
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpClient))]
+#pragma warning restore
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpDeliveryFormat))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpDeliveryMethod))]
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Mail.SmtpException))]
--- /dev/null
+//
+// DynamicMethod.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class DynamicMethod : MethodInfo, ICustomAttributeProvider
+ {
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, bool restrictedSkipVisibility)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Type owner)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public DynamicMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override MethodAttributes Attributes {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override CallingConventions CallingConvention {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type DeclaringType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public bool InitLocals { get; set; }
+
+ public override MethodImplAttributes MethodImplementationFlags {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override ParameterInfo ReturnParameter {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type ReturnType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public ILGenerator GetILGenerator ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ILGenerator GetILGenerator (int streamSize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override ParameterInfo[] GetParameters ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
TypeForwarders.cs
AssemblyInfo.cs
-
+DynamicMethod.cs
// THE SOFTWARE.
//
+#if !FULL_AOT_RUNTIME
[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Reflection.Emit.DynamicMethod))]
-
+#endif
System.Security.Cryptography.Hashing.Algorithms System.Security.Cryptography.RSA System.Security.Cryptography.RandomNumberGenerator \
System.Security.Principal.Windows System.Threading.Thread System.Threading.ThreadPool \
System.Xml.XPath System.Xml.XmlDocument System.Xml.Xsl.Primitives Microsoft.Win32.Registry.AccessControl System.Diagnostics.StackTrace System.Globalization.Extensions \
-System.IO.FileSystem.AccessControl System.Reflection.TypeExtensions \
+System.IO.FileSystem.AccessControl System.Reflection.TypeExtensions System.Reflection.Emit.Lightweight System.Reflection.Emit.ILGeneration System.Reflection.Emit \
System.Security.SecureString System.Threading.AccessControl System.Threading.Overlapped System.Xml.XPath.XDocument \
System.Security.Cryptography.Primitives System.Text.Encoding.CodePages System.IO.FileSystem.Watcher \
System.Security.Cryptography.ProtectedData System.ServiceProcess.ServiceController System.IO.Pipes
drawing_DEPS_SUBDIRS = System.Drawing.Primitives
-reflection_PARALLEL_SUBDIRS = System.Reflection.Emit.ILGeneration System.Reflection.Emit.Lightweight System.Reflection.Emit
-
monotouch_SUBDIRS = $(common_DEPS_SUBDIRS) $(mobile_only_DEPS_SUBDIRS)
monotouch_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(mobile_only_SUBDIRS)
mobile_static_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
net_4_x_SUBDIRS = $(common_DEPS_SUBDIRS) $(drawing_DEPS_SUBDIRS)
-net_4_x_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
+net_4_x_PARALLEL_SUBDIRS = $(common_SUBDIRS)
monodroid_SUBDIRS = $(monotouch_SUBDIRS)
-monodroid_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) $(reflection_PARALLEL_SUBDIRS)
+monodroid_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
xammac_SUBDIRS = $(monotouch_SUBDIRS)
xammac_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS)
System.Xml.Serialization \
Mono.CSharp \
Microsoft.CSharp \
- Mono.Security.Providers.DotNet \
- Mono.Security.Providers.NewSystemSource \
- Mono.Security.Providers.NewTls \
System.Runtime.InteropServices.RuntimeInformation \
System.Reflection.DispatchProxy \
System.Xml.XPath.XmlDocument \
System.ServiceModel.Internals \
SMDiagnostics \
System.Numerics \
+ System.Numerics.Vectors \
Mono.Data.Tds \
System.Transactions \
System.EnterpriseServices \
System.Data.Linq \
System.Net.Http \
System.Net.Http.WebRequest \
- Mono.Security.Providers.DotNet \
- Mono.Security.Providers.OldTls \
- Mono.Security.Providers.NewSystemSource \
- Mono.Security.Providers.NewTls \
System.Runtime.InteropServices.RuntimeInformation \
System.Reflection.Context \
System.Net.Http.WinHttpHandler \
System.Web.Http \
System.Web.Http.SelfHost \
System.Web.Http.WebHost \
- Mono.Security.Providers.NewSystemSource \
- Mono.Security.Providers.NewTls \
System.Runtime.InteropServices.RuntimeInformation
# These are the subdirs which depends on libs in net_4_x_dirs
System.ComponentModel.Composition.4.5 \
System.Windows \
System.Xml.Serialization \
- Mono.Security.Providers.DotNet \
- Mono.Security.Providers.OldTls \
System.DirectoryServices.Protocols \
RabbitMQ.Client \
Microsoft.VisualC \
module.SetDeclaringAssembly (temp);
var importer = new Compiler.ReflectionImporter (module, cc.BuiltinTypes) {
- IgnorePrivateMembers = false
+ IgnorePrivateMembers = false,
+ IgnoreCompilerGeneratedField = false
};
// Import all currently loaded assemblies
#include Mono.CSharp.dll.sources
-../corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
-../corlib/System.Reflection.Emit/FlowControl.cs
-../corlib/System.Reflection.Emit/OpCode.cs
-../corlib/System.Reflection.Emit/OpCodeNames.cs
-../corlib/System.Reflection.Emit/OpCodes.cs
-../corlib/System.Reflection.Emit/OpCodeType.cs
-../corlib/System.Reflection.Emit/OperandType.cs
../corlib/System.Reflection.Emit/PEFileKinds.cs
-../corlib/System.Reflection.Emit/Label.cs
../corlib/System.Reflection.Emit/MethodToken.cs
-../corlib/System.Reflection.Emit/StackBehaviour.cs
monotouch.cs
namespace System.Reflection.Emit
{
- public class ILGenerator
- {
- public void BeginCatchBlock (Type exceptionType)
- {
- throw new NotSupportedException ();
- }
-
- public Label BeginExceptionBlock ()
- {
- throw new NotSupportedException ();
- }
-
- public void BeginExceptFilterBlock ()
- {
- throw new NotSupportedException ();
- }
-
- public void BeginFinallyBlock ()
- {
- throw new NotSupportedException ();
- }
-
- public LocalBuilder DeclareLocal (params object[] args)
- {
- throw new NotSupportedException ();
- }
-
- public Label DefineLabel ()
- {
- throw new NotSupportedException ();
- }
-
- public void Emit (OpCode opcode)
- {
- throw new NotSupportedException ();
- }
-
- public void Emit (OpCode opcode, object args)
- {
- throw new NotSupportedException ();
- }
-
- public void EmitCall (OpCode opcode, params object[] args)
- {
- throw new NotSupportedException ();
- }
-
- public void EndExceptionBlock ()
- {
- throw new NotSupportedException ();
- }
-
- public void MarkLabel (Label loc)
- {
- throw new NotSupportedException ();
- }
-
- public int ILOffset { get; set; }
- }
-
public class TypeBuilder : Type
{
#region implemented abstract members of MemberInfo
}
}
- public class LocalBuilder : LocalVariableInfo
- {
- }
-
- public class GenericTypeParameterBuilder : Type
- {
- #region implemented abstract members of MemberInfo
-
- public override bool IsDefined (Type attributeType, bool inherit)
- {
- throw new NotSupportedException ();
- }
-
- public override object[] GetCustomAttributes (bool inherit)
- {
- throw new NotSupportedException ();
- }
-
- public override object[] GetCustomAttributes (Type attributeType, bool inherit)
- {
- throw new NotSupportedException ();
- }
-
- public override string Name {
- get {
- throw new NotSupportedException ();
- }
- }
-
- #endregion
-
- #region implemented abstract members of Type
-
- public override Type GetInterface (string name, bool ignoreCase)
- {
- throw new NotSupportedException ();
- }
-
- public override Type[] GetInterfaces ()
- {
- throw new NotSupportedException ();
- }
-
- public override Type GetElementType ()
- {
- throw new NotSupportedException ();
- }
-
- public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override EventInfo[] GetEvents (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override FieldInfo GetField (string name, BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override FieldInfo[] GetFields (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override MemberInfo[] GetMembers (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
- {
- throw new NotSupportedException ();
- }
-
- public override MethodInfo[] GetMethods (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override Type GetNestedType (string name, BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override Type[] GetNestedTypes (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override PropertyInfo[] GetProperties (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- protected override PropertyInfo GetPropertyImpl (string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
- {
- throw new NotSupportedException ();
- }
-
- protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
- {
- throw new NotSupportedException ();
- }
-
- protected override TypeAttributes GetAttributeFlagsImpl ()
- {
- throw new NotSupportedException ();
- }
-
- protected override bool HasElementTypeImpl ()
- {
- throw new NotSupportedException ();
- }
-
- protected override bool IsArrayImpl ()
- {
- throw new NotSupportedException ();
- }
-
- protected override bool IsByRefImpl ()
- {
- throw new NotSupportedException ();
- }
-
- protected override bool IsCOMObjectImpl ()
- {
- throw new NotSupportedException ();
- }
-
- protected override bool IsPointerImpl ()
- {
- throw new NotSupportedException ();
- }
-
- protected override bool IsPrimitiveImpl ()
- {
- throw new NotSupportedException ();
- }
-
- public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
- {
- throw new NotSupportedException ();
- }
-
- public override object InvokeMember (string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] namedParameters)
- {
- throw new NotSupportedException ();
- }
-
- public override Assembly Assembly {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override string AssemblyQualifiedName {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override Type BaseType {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override string FullName {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override Guid GUID {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override Module Module {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override string Namespace {
- get {
- throw new NotSupportedException ();
- }
- }
-
- public override Type UnderlyingSystemType {
- get {
- throw new NotSupportedException ();
- }
- }
-
- #endregion
-
- public void SetCustomAttribute (params object[] args)
- {
- throw new NotSupportedException ();
- }
-
- public void SetGenericParameterAttributes (GenericParameterAttributes genericParameterAttributes)
- {
- throw new NotSupportedException ();
- }
-
- public void SetInterfaceConstraints (params Type[] interfaceConstraints)
- {
- throw new NotSupportedException ();
- }
-
- public void SetBaseTypeConstraint (Type baseTypeConstraint)
- {
- throw new NotSupportedException ();
- }
- }
-
public class ConstructorBuilder : MethodBase
{
#region implemented abstract members of MemberInfo
}
}
- public class ParameterBuilder : ParameterInfo
- {
- public void SetConstant (object arg)
- {
- throw new NotSupportedException ();
- }
-
- public void SetCustomAttribute (params object[] args)
- {
- throw new NotSupportedException ();
- }
- }
-
public class EventBuilder
{
public void SetAddOnMethod (MethodBuilder mdBuilder)
}
}
- public class CustomAttributeBuilder
- {
- public CustomAttributeBuilder (params object[] args)
- {
- throw new NotSupportedException ();
- }
- }
}
\ No newline at end of file
Mono.Debugger.Soft/MethodEntryEventRequest.cs
Mono.Debugger.Soft/AssemblyLoadEventRequest.cs
Mono.Debugger.Soft/LocalVariable.cs
+Mono.Debugger.Soft/LocalScope.cs
Mono.Debugger.Soft/ParameterInfoMirror.cs
Mono.Debugger.Soft/Event.cs
Mono.Debugger.Soft/EventSet.cs
public string[] names;
public int[] live_range_start;
public int[] live_range_end;
+ public int[] scopes_start;
+ public int[] scopes_end;
}
struct PropInfo {
* with newer runtimes, and vice versa.
*/
internal const int MAJOR_VERSION = 2;
- internal const int MINOR_VERSION = 42;
+ internal const int MINOR_VERSION = 43;
enum WPSuspendPolicy {
NONE = 0,
var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_LOCALS_INFO, new PacketWriter ().WriteId (id));
LocalsInfo info = new LocalsInfo ();
+
+ if (Version.AtLeast (2, 43)) {
+ int nscopes = res.ReadInt ();
+ info.scopes_start = new int [nscopes];
+ info.scopes_end = new int [nscopes];
+ int last_start = 0;
+ for (int i = 0; i < nscopes; ++i) {
+ info.scopes_start [i] = last_start + res.ReadInt ();
+ info.scopes_end [i] = info.scopes_start [i] + res.ReadInt ();
+ last_start = info.scopes_start [i];
+ }
+ }
+
int nlocals = res.ReadInt ();
info.types = new long [nlocals];
for (int i = 0; i < nlocals; ++i)
--- /dev/null
+using System;
+
+namespace Mono.Debugger.Soft
+{
+ public class LocalScope : Mirror {
+
+ MethodMirror method;
+ int live_range_start, live_range_end;
+
+ internal LocalScope (VirtualMachine vm, MethodMirror method, int live_range_start, int live_range_end) : base (vm, 0) {
+ this.method = method;
+ this.live_range_start = live_range_start;
+ this.live_range_end = live_range_end;
+ }
+
+ public MethodMirror Method {
+ get {
+ return method;
+ }
+ }
+
+ public int LiveRangeStart {
+ get {
+ return live_range_start;
+ }
+ }
+
+ public int LiveRangeEnd {
+ get {
+ return live_range_end;
+ }
+ }
+ }
+}
+
ParameterInfoMirror[] param_info;
ParameterInfoMirror ret_param;
LocalVariable[] locals;
+ LocalScope[] scopes;
IList<Location> locations;
MethodBodyMirror body;
MethodMirror gmd;
}
}
+ public LocalScope [] GetScopes () {
+ vm.CheckProtocolVersion (2, 43);
+ GetLocals ();
+ return scopes;
+ }
+
public LocalVariable[] GetLocals () {
if (locals == null) {
LocalsInfo li = new LocalsInfo ();
for (int i = 0; i < li.names.Length; ++i)
locals [i + pi.Length] = new LocalVariable (vm, this, i, li.types [i], li.names [i], li.live_range_start [i], li.live_range_end [i], false);
+
+ if (vm.Version.AtLeast (2, 43)) {
+ scopes = new LocalScope [li.scopes_start.Length];
+ for (int i = 0; i < scopes.Length; ++i)
+ scopes [i] = new LocalScope (vm, this, li.scopes_start [i], li.scopes_end [i]);
+ }
}
return locals;
}
if (!listening) {
var pi = new Diag.ProcessStartInfo ();
- if (runtime != null)
+ if (runtime != null) {
pi.FileName = runtime;
- else
+ } else if (Path.DirectorySeparatorChar == '\\') {
+ string processExe = Diag.Process.GetCurrentProcess ().MainModule.FileName;
+ if (processExe != null) {
+ string fileName = Path.GetFileName (processExe);
+ if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
+ pi.FileName = processExe;
+ }
+ }
+ if (string.IsNullOrEmpty (pi.FileName))
pi.FileName = "mono";
pi.Arguments = String.Join (" ", args);
vm = VirtualMachineManager.Launch (pi, new LaunchOptions { AgentArgs = agent_args });
Assert.Fail ();
}
}
+
+ var scopes = frame.Method.GetScopes ();
+ Assert.AreEqual (2, scopes.Length);
}
Event step_once () {
+++ /dev/null
-thisdir = class/Mono.Security.Providers.DotNet
-SUBDIRS =
-include ../../build/rules.make
-
-LIBRARY = Mono.Security.Providers.DotNet.dll
-LIB_REFS = System Mono.Security
-LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign
-
-EXTRA_DISTFILES = README.md
-
-include ../../build/library.make
-
-$(the_lib): ../Mono.Security/Makefile
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.30729</ProductVersion>\r
- <SchemaVersion>2.0</SchemaVersion>\r
- <ProjectGuid>{391EDD2B-85AC-4FCA-B607-AAD6C51E6799}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <OutputPath>./../../class/lib/net_4_x</OutputPath>\r
- <IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
- <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
- <NoStdLib>True</NoStdLib>\r
- \r
- <NoConfig>True</NoConfig>\r
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>\r
- </RootNamespace>\r
- <AssemblyName>Mono.Security.Providers.DotNet</AssemblyName>\r
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
- <FileAlignment>512</FileAlignment>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- <DelaySign>true</DelaySign>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>false</Optimize>\r
- <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>true</Optimize>\r
- <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0, \r
- Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This\r
- is a problem to compile the Mono mscorlib.dll -->\r
- <PropertyGroup>\r
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
- </PropertyGroup>\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <ItemGroup>\r
- <Compile Include="..\..\build\common\Consts.cs" />\r
- <Compile Include="..\..\build\common\Locale.cs" />\r
- <Compile Include=".\Mono.Security.Providers.DotNet\DotNetSslStreamImpl.cs" />\r
- <Compile Include=".\Mono.Security.Providers.DotNet\DotNetTlsProvider.cs" />\r
- <Compile Include=".\Properties\AssemblyInfo.cs" />\r </ItemGroup>\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
- <PropertyGroup>\r
- <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PreBuildEvent>\r
- <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PreBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PostBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PostBuildEvent>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <ProjectReference Include="../corlib/corlib-net_4_x.csproj">\r
- <Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>\r
- <Name>corlib-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../System/System-net_4_x.csproj">\r
- <Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>\r
- <Name>System-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">\r
- <Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>\r
- <Name>Mono.Security-net_4_x</Name>\r
- </ProjectReference>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Folder Include="Properties\" />\r
- </ItemGroup>\r
-</Project>\r
-
+++ /dev/null
-./Properties/AssemblyInfo.cs
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-
-./Mono.Security.Providers.DotNet/DotNetTlsProvider.cs
-./Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs
+++ /dev/null
-//
-// DotNetSslStreamImpl.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.IO;
-using System.Net;
-using System.Net.Security;
-using System.Threading.Tasks;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-using System.Security.Principal;
-using System.Security.Cryptography;
-using MSI = Mono.Security.Interface;
-
-namespace Mono.Security.Providers.DotNet
-{
- class DotNetSslStreamImpl : MSI.IMonoSslStream
- {
- DotNetTlsProvider provider;
- SslStream impl;
-
- internal SslStream Impl {
- get {
- CheckDisposed ();
- return impl;
- }
- }
-
- public DotNetSslStreamImpl (
- Stream innerStream, bool leaveInnerStreamOpen, DotNetTlsProvider provider,
- RemoteCertificateValidationCallback userCertificateValidationCallback,
- LocalCertificateSelectionCallback userCertificateSelectionCallback)
- {
- this.provider = provider;
- impl = new SslStream (
- innerStream, leaveInnerStreamOpen,
- userCertificateValidationCallback,
- userCertificateSelectionCallback);
- }
-
- public void AuthenticateAsClient (string targetHost)
- {
- Impl.AuthenticateAsClient (targetHost);
- }
-
- public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- {
- Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
- }
-
- public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
- {
- return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
- }
-
- public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
- {
- return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
- }
-
- public void EndAuthenticateAsClient (IAsyncResult asyncResult)
- {
- Impl.EndAuthenticateAsClient (asyncResult);
- }
-
- public void AuthenticateAsServer (X509Certificate serverCertificate)
- {
- Impl.AuthenticateAsServer (serverCertificate);
- }
-
- public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- {
- Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
- }
-
- public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
- {
- return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
- }
-
- public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
- {
- return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
- }
-
- public void EndAuthenticateAsServer (IAsyncResult asyncResult)
- {
- Impl.EndAuthenticateAsServer (asyncResult);
- }
-
- public Task AuthenticateAsClientAsync (string targetHost)
- {
- return Impl.AuthenticateAsClientAsync (targetHost);
- }
-
- public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- {
- return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
- }
-
- public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
- {
- return Impl.AuthenticateAsServerAsync (serverCertificate);
- }
-
- public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- {
- return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
- }
-
- public void Flush ()
- {
- Impl.Flush ();
- }
-
- public int Read (byte[] buffer, int offset, int count)
- {
- return Impl.Read (buffer, offset, count);
- }
-
- public void Write (byte[] buffer)
- {
- Impl.Write (buffer);
- }
-
- public void Write (byte[] buffer, int offset, int count)
- {
- Impl.Write (buffer, offset, count);
- }
-
- public IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
- {
- return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
- }
-
- public int EndRead (IAsyncResult asyncResult)
- {
- return Impl.EndRead (asyncResult);
- }
-
- public IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
- {
- return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
- }
-
- public void EndWrite (IAsyncResult asyncResult)
- {
- Impl.EndWrite (asyncResult);
- }
-
- public TransportContext TransportContext {
- get { throw new NotSupportedException (); }
- }
-
- public bool IsAuthenticated {
- get { return Impl.IsAuthenticated; }
- }
-
- public bool IsMutuallyAuthenticated {
- get { return Impl.IsMutuallyAuthenticated; }
- }
-
- public bool IsEncrypted {
- get { return Impl.IsEncrypted; }
- }
-
- public bool IsSigned {
- get { return Impl.IsSigned; }
- }
-
- public bool IsServer {
- get { return Impl.IsServer; }
- }
-
- public CipherAlgorithmType CipherAlgorithm {
- get { return Impl.CipherAlgorithm; }
- }
-
- public int CipherStrength {
- get { return Impl.CipherStrength; }
- }
-
- public HashAlgorithmType HashAlgorithm {
- get { return Impl.HashAlgorithm; }
- }
-
- public int HashStrength {
- get { return Impl.HashStrength; }
- }
-
- public ExchangeAlgorithmType KeyExchangeAlgorithm {
- get { return Impl.KeyExchangeAlgorithm; }
- }
-
- public int KeyExchangeStrength {
- get { return KeyExchangeStrength; }
- }
-
- public bool CanRead {
- get { return Impl.CanRead; }
- }
-
- public bool CanTimeout {
- get { return Impl.CanTimeout; }
- }
-
- public bool CanWrite {
- get { return Impl.CanWrite; }
- }
-
- public long Length {
- get { return Impl.Length; }
- }
-
- public long Position {
- get { return Impl.Position; }
- }
-
- public void SetLength (long value)
- {
- Impl.SetLength (value);
- }
-
- public AuthenticatedStream AuthenticatedStream {
- get { return Impl; }
- }
-
- public int ReadTimeout {
- get { return Impl.ReadTimeout; }
- set { Impl.ReadTimeout = value; }
- }
-
- public int WriteTimeout {
- get { return Impl.WriteTimeout; }
- set { Impl.WriteTimeout = value; }
- }
-
- public bool CheckCertRevocationStatus {
- get { return Impl.CheckCertRevocationStatus; }
- }
-
- public X509Certificate InternalLocalCertificate {
- get {
- try {
- return LocalCertificate;
- } catch {
- return null;
- }
- }
- }
-
- public X509Certificate LocalCertificate {
- get { return Impl.LocalCertificate; }
- }
-
- public X509Certificate RemoteCertificate {
- get { return Impl.RemoteCertificate; }
- }
-
- public SslProtocols SslProtocol {
- get { return Impl.SslProtocol; }
- }
-
- MSI.MonoTlsProvider MSI.IMonoSslStream.Provider {
- get { return provider; }
- }
-
- MSI.MonoTlsConnectionInfo MSI.IMonoSslStream.GetConnectionInfo ()
- {
- return null;
- }
-
- void CheckDisposed ()
- {
- if (impl == null)
- throw new ObjectDisposedException ("MonoSslStream");
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- protected void Dispose (bool disposing)
- {
- if (impl != null && disposing) {
- impl.Dispose ();
- impl = null;
- }
- }
- }
-}
-
+++ /dev/null
-//
-// MonoDefaultTlsProvider.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.IO;
-using System.Net;
-using System.Net.Security;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-using Mono.Security.Interface;
-
-namespace Mono.Security.Providers.DotNet
-{
- /*
- * This provider only uses the public .NET APIs from System.dll.
- *
- * It is primarily intended for testing.
- */
- public class DotNetTlsProvider : MonoTlsProvider
- {
- static readonly Guid id = new Guid ("3a7b3a26-0dbd-4572-a5b8-fdce766bf0dd");
-
- public override Guid ID {
- get { return id; }
- }
-
- public override string Name {
- get { return "dotnet"; }
- }
-
- public override bool SupportsSslStream {
- get { return true; }
- }
-
- public override bool SupportsConnectionInfo {
- get { return false; }
- }
-
- public override bool SupportsMonoExtensions {
- get { return false; }
- }
-
- internal override bool SupportsTlsContext {
- get { return false; }
- }
-
- public override SslProtocols SupportedProtocols {
- get { return (SslProtocols)ServicePointManager.SecurityProtocol; }
- }
-
- public override IMonoSslStream CreateSslStream (
- Stream innerStream, bool leaveInnerStreamOpen,
- MonoTlsSettings settings = null)
- {
- if (settings != null)
- throw new NotSupportedException ("Mono-specific API Extensions not available.");
-
- RemoteCertificateValidationCallback validation_callback = null;
- LocalCertificateSelectionCallback selection_callback = null;
-
- if (settings != null) {
- validation_callback = ConvertCallback (settings.RemoteCertificateValidationCallback);
- selection_callback = ConvertCallback (settings.ClientCertificateSelectionCallback);
- }
-
- return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, this, validation_callback, selection_callback);
- }
-
- internal override IMonoTlsContext CreateTlsContext (
- string hostname, bool serverMode, TlsProtocols protocolFlags,
- X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
- bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
- MonoTlsSettings settings)
- {
- throw new NotSupportedException ();
- }
-
- internal static RemoteCertificateValidationCallback ConvertCallback (MonoRemoteCertificateValidationCallback callback)
- {
- if (callback == null)
- return null;
-
- return (s, c, ch, e) => callback (null, c, ch, (MonoSslPolicyErrors)e);
- }
-
- internal static LocalCertificateSelectionCallback ConvertCallback (MonoLocalCertificateSelectionCallback callback)
- {
- if (callback == null)
- return null;
-
- return (s, t, lc, rc, ai) => callback (t, lc, rc, ai);
- }
-
- }
-}
-
+++ /dev/null
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using System.Resources;
-using System.Security;
-using System.Security.Permissions;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about the system assembly
-
-[assembly: AssemblyVersion (Consts.FxVersion)]
-
-[assembly: AssemblyCompany ("MONO development team")]
-[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
-[assembly: AssemblyDescription ("Mono.Security.Providers.DotNet.dll")]
-[assembly: AssemblyProduct ("MONO CLI")]
-[assembly: AssemblyTitle ("Mono.Security.Providers.DotNet.dll")]
-[assembly: CLSCompliant (true)]
-[assembly: ComVisible (false)]
-[assembly: NeutralResourcesLanguage ("en-US")]
-
+++ /dev/null
-See mcs/class/Mono.Security.Providers.NewSystemSource/README.md for a detailed README.
+++ /dev/null
-thisdir = class/Mono.Security.Providers.NewSystemSource
-SUBDIRS =
-include ../../build/rules.make
-
-LIB_REFS = System
-
-LIBRARY = Mono.Security.Providers.NewSystemSource.dll
-
-LIB_MCS_FLAGS = -d:SECURITY_DEP \
- -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:MONO -d:FEATURE_PAL -d:MONO_FEATURE_NEW_TLS \
- -d:MONO_FEATURE_NEW_SYSTEM_SOURCE -d:DISABLE_CAS_USE
-
-ifdef MOBILE_PROFILE
-LIB_REFS += Mono.Security
-else
-LIB_REFS += MonoSecurity=Mono.Security
-LIB_MCS_FLAGS += -d:MONO_SECURITY_ALIAS
-endif
-
-EXTRA_DISTFILES = README.md
-
-include ../../build/library.make
-
-$(the_lib): ../Mono.Security/Makefile
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.30729</ProductVersion>\r
- <SchemaVersion>2.0</SchemaVersion>\r
- <ProjectGuid>{0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <OutputPath>./../../class/lib/net_4_x</OutputPath>\r
- <IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
- <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
- <NoStdLib>True</NoStdLib>\r
- \r
- <NoConfig>True</NoConfig>\r
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>\r
- </RootNamespace>\r
- <AssemblyName>Mono.Security.Providers.NewSystemSource</AssemblyName>\r
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
- <FileAlignment>512</FileAlignment>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- <DelaySign>true</DelaySign>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>false</Optimize>\r
- <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP;MONO;FEATURE_PAL;MONO_FEATURE_NEW_TLS;MONO_FEATURE_NEW_SYSTEM_SOURCE;DISABLE_CAS_USE;MONO_SECURITY_ALIAS</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>true</Optimize>\r
- <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP;MONO;FEATURE_PAL;MONO_FEATURE_NEW_TLS;MONO_FEATURE_NEW_SYSTEM_SOURCE;DISABLE_CAS_USE;MONO_SECURITY_ALIAS</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0, \r
- Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This\r
- is a problem to compile the Mono mscorlib.dll -->\r
- <PropertyGroup>\r
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
- </PropertyGroup>\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <ItemGroup>\r
- <Compile Include="..\..\build\common\Consts.cs" />\r
- <Compile Include="..\..\build\common\Locale.cs" />\r
- <Compile Include="..\..\build\common\SR.cs" />\r
- <Compile Include="..\referencesource\mscorlib\InternalApis\NDP_Common\inc\PinnableBufferCache.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\_LazyAsyncResult.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\_LoggingObject.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\_NTAuthentication.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\_SecureChannel.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\_SslSessionsCache.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\Logging.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_FixedSizeReader.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_HelperAsyncResults.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_SslState.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\_SslStream.cs" />\r
- <Compile Include="..\referencesource\System\net\System\Net\SecureProtocols\SslStream.cs" />\r
- <Compile Include="..\System\Mono.Net.Security\CallbackHelpers.cs" />\r
- <Compile Include="..\System\Mono.Net.Security\IMonoTlsProvider.cs" />\r
- <Compile Include="..\System\Mono.Net.Security\MonoTlsProviderFactory.cs" />\r
- <Compile Include="..\System\Mono.Net.Security\MonoTlsProviderWrapper.cs" />\r
- <Compile Include="..\System\ReferenceSources\_SecureChannel.cs" />\r
- <Compile Include="..\System\ReferenceSources\_SslState.cs" />\r
- <Compile Include="..\System\ReferenceSources\_SslStream.cs" />\r
- <Compile Include="..\System\ReferenceSources\Internal.cs" />\r
- <Compile Include="..\System\ReferenceSources\SR.cs" />\r
- <Compile Include="..\System\ReferenceSources\SR2.cs" />\r
- <Compile Include="..\System\ReferenceSources\SslStream.cs" />\r
- <Compile Include="..\System\ReferenceSources\SSPIConfiguration.cs" />\r
- <Compile Include="..\System\ReferenceSources\SSPISafeHandles.cs" />\r
- <Compile Include="..\System\ReferenceSources\SSPIWrapper.cs" />\r
- <Compile Include=".\Properties\AssemblyInfo.cs" />\r </ItemGroup>\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
- <PropertyGroup>\r
- <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PreBuildEvent>\r
- <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PreBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PostBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PostBuildEvent>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <ProjectReference Include="../corlib/corlib-net_4_x.csproj">\r
- <Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>\r
- <Name>corlib-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../System/System-net_4_x.csproj">\r
- <Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>\r
- <Name>System-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">\r
- <Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>\r
- <Name>Mono.Security-net_4_x</Name>\r
- <Aliases>MonoSecurity</Aliases> </ProjectReference>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Folder Include="Properties\" />\r
- </ItemGroup>\r
-</Project>\r
-
+++ /dev/null
-./Properties/AssemblyInfo.cs
-../../build/common/SR.cs
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-
-../referencesource/System/net/System/Net/Logging.cs
-../referencesource/System/net/System/Net/_SslSessionsCache.cs
-../referencesource/System/net/System/Net/_LazyAsyncResult.cs
-../referencesource/System/net/System/Net/_LoggingObject.cs
-../referencesource/System/net/System/Net/_NTAuthentication.cs
-../referencesource/System/net/System/Net/_SecureChannel.cs
-../referencesource/System/net/System/Net/SecureProtocols/SslStream.cs
-../referencesource/System/net/System/Net/SecureProtocols/_SslState.cs
-../referencesource/System/net/System/Net/SecureProtocols/_SslStream.cs
-../referencesource/System/net/System/Net/SecureProtocols/_FixedSizeReader.cs
-../referencesource/System/net/System/Net/SecureProtocols/_HelperAsyncResults.cs
-../referencesource/mscorlib/InternalApis/NDP_Common/inc/PinnableBufferCache.cs
-
-../System/ReferenceSources/SR.cs
-../System/ReferenceSources/SR2.cs
-../System/ReferenceSources/Internal.cs
-../System/ReferenceSources/SSPIWrapper.cs
-../System/ReferenceSources/SSPISafeHandles.cs
-../System/ReferenceSources/SslStream.cs
-../System/ReferenceSources/_SslState.cs
-../System/ReferenceSources/_SslStream.cs
-../System/ReferenceSources/_SecureChannel.cs
-../System/ReferenceSources/SSPIConfiguration.cs
-../System/Mono.Net.Security/CallbackHelpers.cs
-../System/Mono.Net.Security/IMonoTlsProvider.cs
-../System/Mono.Net.Security/MonoTlsProviderFactory.cs
-../System/Mono.Net.Security/MonoTlsProviderWrapper.cs
-
+++ /dev/null
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using System.Resources;
-using System.Security;
-using System.Security.Permissions;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about the system assembly
-
-[assembly: AssemblyVersion (Consts.FxVersion)]
-
-[assembly: AssemblyCompany ("MONO development team")]
-[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
-[assembly: AssemblyDescription ("Mono.Security.Providers.NewSystemSource.dll")]
-[assembly: AssemblyProduct ("MONO CLI")]
-[assembly: AssemblyTitle ("Mono.Security.Providers.NewSystemSource.dll")]
-[assembly: CLSCompliant (true)]
-[assembly: ComVisible (false)]
-[assembly: NeutralResourcesLanguage ("en-US")]
-
-[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
-[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+++ /dev/null
-Mono.Security.Interface / Mono.Security.Providers
-=================================================
-
-This is not a public API yet, but will eventually become public.
-
-
-Mono.Security.Interface
------------------------
-
-`Mono.Security.Interface` provides an abstraction layer for the TLS
-APIs that are currently being used by Mono's class libraries.
-
-The main API entry points are `MonoTlsProviderFactory.GetProvider()`
-and `MonoTlsProviderFactory.InstallProvider()`.
-
-Mono.Net.Security
------------------
-
-`Mono.Net.Security` provides the internal implementation and lives
-inside `System.dll` as private and internal APIs. `Mono.Security.dll`
-uses reflection to access these.
-
-On Mobile, the `Mono.Security.Interface` APIs are included as public
-APIs in `System.dll`.
-
-Mono.Security.Providers
------------------------
-
-Implementations of the `Mono.Security.Interface.MonoTlsProvider` class
-to provide TLS functionality.
-
-The default provider is inside `System.dll` - it will be used automatically
-if you don't explicitly install a custom provider, so simply call
-`MonoTlsProviderFactory.GetProvider()` to use it.
-
-* DotNet:
- Provides the default `SslStream` implementation from `System.dll`, only using
- public .NET types.
-
-* NewSystemSource:
- Compiles several referencesource files which would normally live inside
- `System.dll` if we compiled it with their `SslStream` implementation.
-
- This allows to keep the code in `System.dll` as-is, while still providing the
- new `SslStream`, which will be required by the new TLS code.
-
- `System.dll` needs to make its internals visible and we're using several compiler /
- external alias tricks in here to make this work.
-
- In this configuration, `MONO_SYSTEM_ALIAS`, `MONO_FEATURE_NEW_TLS` and
- `MONO_FEATURE_NEW_SYSTEM_SOURCE` (defining conditional for this configuration)
- are defined. We do not define `MONO_X509_ALIAS here`.
-
-The `Mono.Security.Providers.DotNet` and `Mono.Security.Providers.NewSystemSource` directory is currently
-enabled in the top-level `Makefile`, but the resulting binaries should only be used to test the new TLS
-code and not shipped as stable APIs.
-
-Pending changes
----------------
-
-This code is not actually being used in `System.dll` yet. I have some
-local changes which will switch the existing code in `WebClient`,
-`SmptClient` and `FtpWebRequest` over, but these need to be carefully
-tested.
-
-At the moment, this work branch only provides new code and build
-changes, which shuffle some stuff around. There are also several
-new files which are conditional and not actually being built by
-default.
-
-Build Configurations
---------------------
-
-* Normal build:
- Builds everything as before with some new APIs added, but without
- modifying any existing functionality.
-
-* Build with the `newtls` profile:
- Builds `System.dll` with the new `SslStream` implementation from the
- referencesource. This is currently a "build then throw away" profile
- and not enabled from the top-level Makefile. The resulting `System.dll`
- won't actually work at runtime since it's missing the new TLS code;
- building it helps find problems and ensures that it will actually
- be possible to build this once we deploy it.
-
-* Mono.Security.Providers:
- The new TLS code requires the newly built `System` and `Mono.Security.Providers.NewSystemSource`
- from this branch installed in the system. It is recommended to install it
- into a custom prefix and set that as custom runtime in Xamarin Studio.
-
-
-Last changed March 07th, 2015,
-Martin Baulig <martin.baulig@xamarin.com>
-
-
+++ /dev/null
-thisdir = class/Mono.Security.Providers.NewTls
-SUBDIRS =
-include ../../build/rules.make
-
-LIBRARY = Mono.Security.Providers.NewTls.dll
-LIB_REFS = System NewSystemSource=Mono.Security.Providers.NewSystemSource Mono.Security
-LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign
-
-include ../../build/library.make
-
-$(the_lib): ../Mono.Security/Makefile
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.30729</ProductVersion>\r
- <SchemaVersion>2.0</SchemaVersion>\r
- <ProjectGuid>{C8B8E524-BB3A-44E2-8C22-E3313E9F477C}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <OutputPath>./../../class/lib/net_4_x</OutputPath>\r
- <IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
- <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
- <NoStdLib>True</NoStdLib>\r
- \r
- <NoConfig>True</NoConfig>\r
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>\r
- </RootNamespace>\r
- <AssemblyName>Mono.Security.Providers.NewTls</AssemblyName>\r
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
- <FileAlignment>512</FileAlignment>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- <DelaySign>true</DelaySign>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>false</Optimize>\r
- <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>true</Optimize>\r
- <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0, \r
- Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This\r
- is a problem to compile the Mono mscorlib.dll -->\r
- <PropertyGroup>\r
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
- </PropertyGroup>\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <ItemGroup>\r
- <Compile Include="..\..\build\common\Consts.cs" />\r
- <Compile Include="..\..\build\common\Locale.cs" />\r
- <Compile Include="..\..\build\common\SR.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\ITlsConfiguration.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\ITlsContext.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\MonoNewTlsStream.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\MonoNewTlsStreamFactory.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\NewTlsProvider.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\TlsContextWrapper.cs" />\r
- <Compile Include=".\Mono.Security.Providers.NewTls\TlsProviderFactory.cs" />\r
- <Compile Include=".\Properties\AssemblyInfo.cs" />\r </ItemGroup>\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
- <PropertyGroup>\r
- <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PreBuildEvent>\r
- <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PreBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PostBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PostBuildEvent>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <ProjectReference Include="../corlib/corlib-net_4_x.csproj">\r
- <Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>\r
- <Name>corlib-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../System/System-net_4_x.csproj">\r
- <Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>\r
- <Name>System-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">\r
- <Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>\r
- <Name>Mono.Security-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource-net_4_x.csproj">\r
- <Project>{0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}</Project>\r
- <Name>Mono.Security.Providers.NewSystemSource-net_4_x</Name>\r
- <Aliases>NewSystemSource</Aliases> </ProjectReference>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Folder Include="Properties\" />\r
- </ItemGroup>\r
-</Project>\r
-
+++ /dev/null
-./Properties/AssemblyInfo.cs
-../../build/common/SR.cs
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-
-./Mono.Security.Providers.NewTls/ITlsConfiguration.cs
-./Mono.Security.Providers.NewTls/ITlsContext.cs
-
-./Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
-./Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
-./Mono.Security.Providers.NewTls/NewTlsProvider.cs
-./Mono.Security.Providers.NewTls/TlsContextWrapper.cs
-./Mono.Security.Providers.NewTls/TlsProviderFactory.cs
+++ /dev/null
-//
-// ITlsContext.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015-2016 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System;
-using System.Security.Cryptography;
-
-using Mono.Security.Interface;
-using MX = Mono.Security.X509;
-
-namespace Mono.Security.Providers.NewTls
-{
- interface ITlsConfiguration
- {
- bool HasCredentials {
- get;
- }
-
- void SetCertificate (MX.X509Certificate certificate, AsymmetricAlgorithm privateKey);
-
- bool? AskForClientCertificate {
- get; set;
- }
- }
-}
+++ /dev/null
-//
-// ITlsContext.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015-2016 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-extern alias NewSystemSource;
-
-using System;
-using System.Security.Cryptography;
-
-using Mono.Security.Interface;
-using MX = Mono.Security.X509;
-
-namespace Mono.Security.Providers.NewTls
-{
- interface ITlsContext : IDisposable
- {
- bool IsValid {
- get;
- }
-
- TlsException LastError {
- get;
- }
-
- bool ReceivedCloseNotify {
- get;
- }
-
- MonoTlsConnectionInfo ConnectionInfo {
- get;
- }
-
- MX.X509Certificate GetRemoteCertificate (out MX.X509CertificateCollection remoteCertificateStore);
-
- bool VerifyRemoteCertificate ();
-
- int GenerateNextToken (TlsBuffer incoming, TlsMultiBuffer outgoing);
-
- int DecryptMessage (ref TlsBuffer incoming);
-
- int EncryptMessage (ref TlsBuffer incoming);
-
- byte[] CreateAlert (Alert alert);
-
- byte[] CreateHelloRequest ();
- }
-}
-
+++ /dev/null
-//
-// MonoNewTlsStream.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-extern alias NewSystemSource;
-
-using EncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
-using LocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
-using RemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
-using SslStream = NewSystemSource::System.Net.Security.SslStream;
-
-using System;
-using System.IO;
-using System.Threading.Tasks;
-
-using MSI = Mono.Security.Interface;
-
-using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
-using System.Security.Cryptography.X509Certificates;
-
-namespace Mono.Security.Providers.NewTls
-{
- public class MonoNewTlsStream : SslStream, MSI.IMonoSslStream
- {
- MSI.MonoTlsProvider provider;
-
- internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
- : this (innerStream, false, provider, settings)
- {
- }
-
- internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
- : base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
- {
- this.provider = provider;
- }
-
- public MSI.MonoTlsProvider Provider {
- get { return provider; }
- }
-
- new public bool IsClosed {
- get { return base.IsClosed; }
- }
-
- public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
- {
- return GetMonoConnectionInfo ();
- }
-
- public Task Shutdown ()
- {
- return Task.Factory.FromAsync ((state, result) => BeginShutdown (state, result), EndShutdown, null);
- }
-
- public Task RequestRenegotiation ()
- {
- return Task.Factory.FromAsync ((state, result) => BeginRenegotiate (state, result), EndRenegotiate, null);
- }
-
- X509Certificate MSI.IMonoSslStream.InternalLocalCertificate {
- get { return InternalLocalCertificate; }
- }
-
- XAuthenticatedStream MSI.IMonoSslStream.AuthenticatedStream {
- get { return this; }
- }
- }
-}
-
-
+++ /dev/null
-//
-// MonoNewTlsStreamFactory.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-extern alias NewSystemSource;
-
-using XEncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
-using XSslPolicyErrors = NewSystemSource::System.Net.Security.SslPolicyErrors;
-using XLocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
-using XRemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
-
-using System;
-using System.IO;
-using System.Net.Security;
-using System.Security.Authentication;
-
-using Mono.Security.Interface;
-
-using PSSCX = System.Security.Cryptography.X509Certificates;
-using SSCX = System.Security.Cryptography.X509Certificates;
-
-namespace Mono.Security.Providers.NewTls
-{
- public static class MonoNewTlsStreamFactory
- {
- internal static IMonoSslStream CreateSslStream (
- Stream innerStream, bool leaveInnerStreamOpen,
- MonoTlsProvider provider, MonoTlsSettings settings = null)
- {
- return new MonoNewTlsStream (innerStream, leaveInnerStreamOpen, provider, settings);
- }
-
- public static MonoNewTlsStream CreateServer (
- Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
- SSCX.X509Certificate serverCertificate, bool clientCertificateRequired,
- SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- {
- var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
-
- try {
- stream.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
- } catch (Exception ex) {
- var tlsEx = stream.LastError;
- if (tlsEx != null)
- throw new AggregateException (ex, tlsEx);
- throw;
- }
-
- return stream;
- }
-
- public static MonoNewTlsStream CreateClient (
- Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
- string targetHost, PSSCX.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
- {
- var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
-
- try {
- stream.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
- } catch (Exception ex) {
- var tlsEx = stream.LastError;
- if (tlsEx != null)
- throw new AggregateException (ex, tlsEx);
- throw;
- }
- return stream;
- }
- }
-}
+++ /dev/null
-//
-// NewTlsProvider.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-extern alias NewSystemSource;
-
-using System;
-using System.IO;
-using System.Net;
-using System.Net.Security;
-using System.Security.Authentication;
-
-using MSI = Mono.Security.Interface;
-using MX = Mono.Security.X509;
-
-using PSSCX = System.Security.Cryptography.X509Certificates;
-using SSCX = System.Security.Cryptography.X509Certificates;
-
-namespace Mono.Security.Providers.NewTls
-{
- public class NewTlsProvider : MSI.MonoTlsProvider
- {
- static readonly Guid id = new Guid ("e5ff34f1-8b7a-4aa6-aff9-24719d709693");
-
- public override Guid ID {
- get { return id; }
- }
-
- public override string Name {
- get { return "newtls"; }
- }
-
- public override bool SupportsSslStream {
- get { return true; }
- }
-
- public override bool SupportsConnectionInfo {
- get { return true; }
- }
-
- public override bool SupportsMonoExtensions {
- get { return true; }
- }
-
- internal override bool SupportsTlsContext {
- get { return true; }
- }
-
- public override SslProtocols SupportedProtocols {
- get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
- }
-
- public override MSI.IMonoSslStream CreateSslStream (
- Stream innerStream, bool leaveInnerStreamOpen,
- MSI.MonoTlsSettings settings = null)
- {
- return MonoNewTlsStreamFactory.CreateSslStream (innerStream, leaveInnerStreamOpen, this, settings);
- }
-
- internal override MSI.IMonoTlsContext CreateTlsContext (
- string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- SSCX.X509Certificate serverCertificate, PSSCX.X509CertificateCollection clientCertificates,
- bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
- MSI.MonoTlsSettings settings)
- {
- var config = TlsProviderFactory.CreateTlsConfiguration (
- hostname, serverMode, protocolFlags, serverCertificate,
- remoteCertRequired, settings);
- return new TlsContextWrapper (config, serverMode);
- }
- }
-}
-
+++ /dev/null
-//
-// TlsContextWrapper.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-extern alias NewSystemSource;
-
-using System;
-using System.Security.Cryptography;
-
-using SSCX = System.Security.Cryptography.X509Certificates;
-using PSSCX = System.Security.Cryptography.X509Certificates;
-
-using MSI = Mono.Security.Interface;
-using MX = Mono.Security.X509;
-
-namespace Mono.Security.Providers.NewTls
-{
- class TlsContextWrapper : IDisposable, MSI.IMonoTlsContext
- {
- ITlsConfiguration config;
- ITlsContext context;
- bool serverMode;
-
- public TlsContextWrapper (ITlsConfiguration config, bool serverMode)
- {
- this.config = config;
- this.serverMode = serverMode;
- }
-
- public bool IsServer {
- get { return serverMode; }
- }
-
- public bool IsValid {
- get { return context != null && context.IsValid; }
- }
-
- public void Initialize (MSI.IMonoTlsEventSink eventSink)
- {
- if (context != null)
- throw new InvalidOperationException ();
- context = TlsProviderFactory.CreateTlsContext (config, serverMode, eventSink);
- }
-
- void Clear ()
- {
- if (context != null) {
- context.Dispose ();
- context = null;
- }
- }
-
- public ITlsConfiguration Configuration {
- get {
- if (config == null)
- throw new ObjectDisposedException ("TlsConfiguration");
- return config;
- }
- }
-
- public ITlsContext Context {
- get {
- if (!IsValid)
- throw new ObjectDisposedException ("TlsContext");
- return context;
- }
- }
-
- public bool HasCredentials {
- get { return Configuration.HasCredentials; }
- }
-
- public void SetCertificate (SSCX.X509Certificate certificate, AsymmetricAlgorithm privateKey)
- {
- var monoCert = new MX.X509Certificate (certificate.GetRawCertData ());
- Configuration.SetCertificate (monoCert, privateKey);
- }
-
- public int GenerateNextToken (MSI.IBufferOffsetSize incoming, out MSI.IBufferOffsetSize outgoing)
- {
- var input = incoming != null ? new MSI.TlsBuffer (BOSWrapper.Wrap (incoming)) : null;
- var output = new MSI.TlsMultiBuffer ();
- var retval = Context.GenerateNextToken (input, output);
- if (output.IsEmpty)
- outgoing = null;
- outgoing = BOSWrapper.Wrap (output.StealBuffer ());
- return (int)retval;
- }
-
- public int EncryptMessage (ref MSI.IBufferOffsetSize incoming)
- {
- var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
- var retval = Context.EncryptMessage (ref buffer);
- incoming = BOSWrapper.Wrap (buffer.GetRemaining ());
- return (int)retval;
- }
-
- public int DecryptMessage (ref MSI.IBufferOffsetSize incoming)
- {
- var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
- var retval = Context.DecryptMessage (ref buffer);
- incoming = buffer != null ? BOSWrapper.Wrap (buffer.GetRemaining ()) : null;
- return (int)retval;
- }
-
- class BOSWrapper : MSI.IBufferOffsetSize
- {
- public byte[] Buffer {
- get;
- private set;
- }
-
- public int Offset {
- get;
- private set;
- }
-
- public int Size {
- get;
- private set;
- }
-
- BOSWrapper (byte[] buffer, int offset, int size)
- {
- Buffer = buffer;
- Offset = offset;
- Size = size;
- }
-
- public static BOSWrapper Wrap (MSI.IBufferOffsetSize bos)
- {
- return bos != null ? new BOSWrapper (bos.Buffer, bos.Offset, bos.Size) : null;
- }
- }
-
- public byte[] CreateCloseNotify ()
- {
- return Context.CreateAlert (new MSI.Alert (MSI.AlertLevel.Warning, MSI.AlertDescription.CloseNotify));
- }
-
- public byte[] CreateHelloRequest ()
- {
- return Context.CreateHelloRequest ();
- }
-
- public SSCX.X509Certificate GetRemoteCertificate (out PSSCX.X509CertificateCollection remoteCertificateStore)
- {
- MX.X509CertificateCollection monoCollection;
- var remoteCert = Context.GetRemoteCertificate (out monoCollection);
- if (remoteCert == null) {
- remoteCertificateStore = null;
- return null;
- }
-
- remoteCertificateStore = new PSSCX.X509CertificateCollection ();
- foreach (var cert in monoCollection) {
- remoteCertificateStore.Add (new PSSCX.X509Certificate2 (cert.RawData));
- }
- return new PSSCX.X509Certificate2 (remoteCert.RawData);
-
- }
-
- public bool VerifyRemoteCertificate ()
- {
- return Context.VerifyRemoteCertificate ();
- }
-
- public Exception LastError {
- get {
- if (context != null)
- return context.LastError;
- return null;
- }
- }
-
- public bool ReceivedCloseNotify {
- get {
- return Context.ReceivedCloseNotify;
- }
- }
-
- public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
- {
- return Context.ConnectionInfo;
- }
-
- public void Dispose ()
- {
- Dispose (true);
- GC.SuppressFinalize (this);
- }
-
- void Dispose (bool disposing)
- {
- Clear ();
- }
- }
-}
-
+++ /dev/null
-//
-// TlsProviderFactory.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015-2016 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-extern alias NewSystemSource;
-
-using System;
-using System.IO;
-
-using System.Net;
-using System.Net.Security;
-using System.Security.Authentication;
-
-using MSI = Mono.Security.Interface;
-using MX = Mono.Security.X509;
-
-using PSSCX = System.Security.Cryptography.X509Certificates;
-using SSCX = System.Security.Cryptography.X509Certificates;
-
-namespace Mono.Security.Providers.NewTls
-{
- static class TlsProviderFactory
- {
- const string assemblyName = "Mono.Security.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2";
- const string tlsConfigTypeName = "Mono.Security.NewTls.TlsConfiguration";
- const string tlsContextTypeName = "Mono.Security.NewTls.TlsContext";
-
- static object CreateInstance (string typeName, object[] args)
- {
- var type = Type.GetType (typeName + ", " + assemblyName);
- return Activator.CreateInstance (type, args);
- }
-
- internal static ITlsConfiguration CreateTlsConfiguration (
- string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
- SSCX.X509Certificate serverCertificate, bool remoteCertRequired,
- MSI.MonoTlsSettings settings)
- {
- object[] args;
- ITlsConfiguration config;
- if (serverMode) {
- var cert = (PSSCX.X509Certificate2)serverCertificate;
- var monoCert = new MX.X509Certificate (cert.RawData);
- args = new object[] {
- (MSI.TlsProtocols)protocolFlags,
- (MSI.MonoTlsSettings)settings,
- monoCert,
- cert.PrivateKey
- };
- } else {
- args = new object[] {
- (MSI.TlsProtocols)protocolFlags,
- (MSI.MonoTlsSettings)settings,
- hostname
- };
- }
-
- config = (ITlsConfiguration)CreateInstance (tlsConfigTypeName, args);
-
- if (serverMode && remoteCertRequired)
- config.AskForClientCertificate = true;
-
- return config;
- }
-
- internal static ITlsContext CreateTlsContext (
- ITlsConfiguration config, bool serverMode,
- MSI.IMonoTlsEventSink eventSink)
- {
- return (ITlsContext)CreateInstance (
- tlsContextTypeName,
- new object[] { config, serverMode, eventSink });
- }
- }
-}
+++ /dev/null
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using System.Resources;
-using System.Security;
-using System.Security.Permissions;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about the system assembly
-
-[assembly: AssemblyVersion (Consts.FxVersion)]
-
-[assembly: AssemblyCompany ("Xamarin")]
-[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
-[assembly: AssemblyDescription ("Mono.Security.Providers.NewTls.dll")]
-[assembly: AssemblyProduct ("MONO CLI")]
-[assembly: AssemblyTitle ("Mono.Security.Providers.NewTls.dll")]
-[assembly: CLSCompliant (false)]
-[assembly: ComVisible (false)]
-[assembly: NeutralResourcesLanguage ("en-US")]
-
-[assembly: InternalsVisibleTo ("Mono.Security.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
+++ /dev/null
-Properties/AssemblyInfo.cs
-
-Mono.Security.Providers.NewTls/ITlsConfiguration.cs
-Mono.Security.Providers.NewTls/ITlsContext.cs
-
-Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
-Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
+++ /dev/null
-#include mobile_Mono.Security.Providers.NewTls.dll.sources
+++ /dev/null
-thisdir = class/Mono.Security.Providers.OldTls
-SUBDIRS =
-include ../../build/rules.make
-
-LIBRARY = Mono.Security.Providers.OldTls.dll
-LIB_REFS = System Mono.Security
-LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:SECURITY_DEP
-
-include ../../build/library.make
-
-$(the_lib): ../Mono.Security/Makefile
-
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
- <PropertyGroup>\r
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
- <ProductVersion>9.0.30729</ProductVersion>\r
- <SchemaVersion>2.0</SchemaVersion>\r
- <ProjectGuid>{E485E885-59B1-4081-BC66-56AAAFD8771A}</ProjectGuid>\r
- <OutputType>Library</OutputType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <OutputPath>./../../class/lib/net_4_x</OutputPath>\r
- <IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
- <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
- <NoStdLib>True</NoStdLib>\r
- \r
- <NoConfig>True</NoConfig>\r
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
- <AppDesignerFolder>Properties</AppDesignerFolder>\r
- <RootNamespace>\r
- </RootNamespace>\r
- <AssemblyName>Mono.Security.Providers.OldTls</AssemblyName>\r
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
- <FileAlignment>512</FileAlignment>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <SignAssembly>true</SignAssembly>\r
- <DelaySign>true</DelaySign>\r
- </PropertyGroup>\r
- <PropertyGroup>\r
- <AssemblyOriginatorKeyFile>../mono.pub</AssemblyOriginatorKeyFile>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
- <DebugSymbols>true</DebugSymbols>\r
- <DebugType>full</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>false</Optimize>\r
- <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
- <DebugType>pdbonly</DebugType>\r
- <NoWarn>1699,1030</NoWarn>\r
- <Optimize>true</Optimize>\r
- <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;DISABLE_CAS_USE;SECURITY_DEP</DefineConstants>\r
- <ErrorReport>prompt</ErrorReport>\r
- <WarningLevel>4</WarningLevel>\r
- </PropertyGroup>\r
- <!-- Set AddAdditionalExplicitAssemblyReferences to false, otherwise if targetting .NET4.0, \r
- Microsoft.NETFramework.props will force a dependency on the assembly System.Core. This\r
- is a problem to compile the Mono mscorlib.dll -->\r
- <PropertyGroup>\r
- <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
- </PropertyGroup>\r
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
- <ItemGroup>\r
- <Compile Include="..\..\build\common\Consts.cs" />\r
- <Compile Include="..\..\build\common\Locale.cs" />\r
- <Compile Include="..\..\build\common\MonoTODOAttribute.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Cryptography\MD5SHA1.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Cryptography\TlsHMAC.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientCertificate.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientCertificateVerify.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientFinished.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientHello.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsClientKeyExchange.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificateRequest.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerFinished.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerHello.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerHelloDone.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Client\TlsServerKeyExchange.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientCertificate.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientCertificateVerify.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientFinished.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientHello.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsClientKeyExchange.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerCertificate.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerCertificateRequest.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerFinished.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerHello.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerHelloDone.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake.Server\TlsServerKeyExchange.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake\ClientCertificateType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake\HandshakeMessage.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls.Handshake\HandshakeType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\Alert.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherAlgorithmType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherSuite.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherSuiteCollection.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\CipherSuiteFactory.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ClientContext.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ClientRecordProtocol.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ClientSessionCache.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ContentType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\Context.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\DebugHelper.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ExchangeAlgorithmType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\HandshakeState.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\HashAlgorithmType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\HttpsClientStream.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\RecordProtocol.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\RSASslSignatureDeformatter.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\RSASslSignatureFormatter.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SecurityCompressionType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SecurityParameters.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SecurityProtocolType.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ServerContext.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\ServerRecordProtocol.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslCipherSuite.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslClientStream.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslHandshakeHash.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslServerStream.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\SslStreamBase.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsCipherSuite.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsClientSettings.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsException.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsServerSettings.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.Protocol.Tls\TlsStream.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\AuthorityKeyIdentifierExtension.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\ExtendedKeyUsageExtension.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\GeneralNames.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\NetscapeCertTypeExtension.cs" />\r
- <Compile Include="..\Mono.Security\Mono.Security.X509.Extensions\SubjectAltNameExtension.cs" />\r
- <Compile Include="..\System\Mono.Net.Security\LegacySslStream.cs" />\r
- <Compile Include=".\Mono.Security.Providers.OldTls\OldTlsProvider.cs" />\r
- <Compile Include=".\Properties\AssemblyInfo.cs" />\r </ItemGroup>\r
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
- Other similar extension points exist, see Microsoft.Common.targets.\r
- <Target Name="BeforeBuild">\r
- </Target>\r
- <Target Name="AfterBuild">\r
- </Target>\r
- -->\r
- <PropertyGroup>\r
- <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PreBuildEvent>\r
- <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PreBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PostBuildEvent>\r
- <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
-\r
- </PostBuildEvent>\r
- </PropertyGroup>\r
- <ItemGroup>\r
- <ProjectReference Include="../corlib/corlib-net_4_x.csproj">\r
- <Project>{2CA6026B-2DC8-4C4C-A12C-1E8234049DB7}</Project>\r
- <Name>corlib-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../System/System-net_4_x.csproj">\r
- <Project>{2762E921-91A8-4C87-91E9-BA628013F753}</Project>\r
- <Name>System-net_4_x</Name>\r
- </ProjectReference>\r
- <ProjectReference Include="../Mono.Security/Mono.Security-net_4_x.csproj">\r
- <Project>{42D59DE7-586F-4ACF-BDD5-E7869E39E3EF}</Project>\r
- <Name>Mono.Security-net_4_x</Name>\r
- </ProjectReference>\r
- </ItemGroup>\r
- <ItemGroup>\r
- <Folder Include="Properties\" />\r
- </ItemGroup>\r
-</Project>\r
-
+++ /dev/null
-./Properties/AssemblyInfo.cs
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-../../build/common/MonoTODOAttribute.cs
-
-./Mono.Security.Providers.OldTls/OldTlsProvider.cs
-../System/Mono.Net.Security/LegacySslStream.cs
-
-../Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs
-../Mono.Security/Mono.Security.Cryptography/TlsHMAC.cs
-../Mono.Security/Mono.Security.Protocol.Tls/Alert.cs
-../Mono.Security/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
-../Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs
-../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs
-../Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ClientContext.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ClientSessionCache.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ContentType.cs
-../Mono.Security/Mono.Security.Protocol.Tls/Context.cs
-../Mono.Security/Mono.Security.Protocol.Tls/DebugHelper.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs
-../Mono.Security/Mono.Security.Protocol.Tls/HandshakeState.cs
-../Mono.Security/Mono.Security.Protocol.Tls/HashAlgorithmType.cs
-../Mono.Security/Mono.Security.Protocol.Tls/HttpsClientStream.cs
-../Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs
-../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs
-../Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SecurityCompressionType.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SecurityParameters.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs
-../Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SslHandshakeHash.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SslServerStream.cs
-../Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs
-../Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs
-../Mono.Security/Mono.Security.Protocol.Tls/TlsClientSettings.cs
-../Mono.Security/Mono.Security.Protocol.Tls/TlsException.cs
-../Mono.Security/Mono.Security.Protocol.Tls/TlsServerSettings.cs
-../Mono.Security/Mono.Security.Protocol.Tls/TlsStream.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs
-../Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs
-../Mono.Security/Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs
-../Mono.Security/Mono.Security.X509.Extensions/ExtendedKeyUsageExtension.cs
-../Mono.Security/Mono.Security.X509.Extensions/GeneralNames.cs
-../Mono.Security/Mono.Security.X509.Extensions/NetscapeCertTypeExtension.cs
-../Mono.Security/Mono.Security.X509.Extensions/SubjectAltNameExtension.cs
+++ /dev/null
-//
-// OldTlsProvider.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.IO;
-using System.Net;
-using System.Net.Security;
-using System.Security.Authentication;
-using System.Security.Cryptography.X509Certificates;
-using Mono.Security.Interface;
-using MNS = Mono.Net.Security;
-
-namespace Mono.Security.Providers.OldTls
-{
- public class OldTlsProvider : MonoTlsProvider
- {
- static readonly Guid id = new Guid ("cf8baa0d-c6ed-40ae-b512-dec8d097e9af");
-
- public override Guid ID {
- get { return id; }
- }
-
- public override string Name {
- get { return "old"; }
- }
-
- public override bool SupportsSslStream {
- get { return true; }
- }
-
- public override bool SupportsMonoExtensions {
- get { return false; }
- }
-
- public override bool SupportsConnectionInfo {
- get { return false; }
- }
-
- internal override bool SupportsTlsContext {
- get { return false; }
- }
-
- public override SslProtocols SupportedProtocols {
- get { return SslProtocols.Tls; }
- }
-
- public override IMonoSslStream CreateSslStream (
- Stream innerStream, bool leaveInnerStreamOpen,
- MonoTlsSettings settings = null)
- {
- var impl = new MNS.Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
- return new MNS.Private.MonoSslStreamImpl (impl);
- }
-
- internal override IMonoTlsContext CreateTlsContext (
- string hostname, bool serverMode, TlsProtocols protocolFlags,
- X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
- bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
- MonoTlsSettings settings)
- {
- throw new NotSupportedException ();
- }
- }
-}
-
+++ /dev/null
-//
-// AssemblyInfo.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-using System.Reflection;
-using System.Resources;
-using System.Security;
-using System.Security.Permissions;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about the system assembly
-
-[assembly: AssemblyVersion (Consts.FxVersion)]
-
-[assembly: AssemblyCompany ("MONO development team")]
-[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
-[assembly: AssemblyDescription ("Mono.Security.Providers.OldTls.dll")]
-[assembly: AssemblyProduct ("MONO CLI")]
-[assembly: AssemblyTitle ("Mono.Security.Providers.OldTls.dll")]
-[assembly: CLSCompliant (true)]
-[assembly: ComVisible (false)]
-[assembly: NeutralResourcesLanguage ("en-US")]
-
[assembly: InternalsVisibleTo ("System, PublicKey=00000000000000000400000000000000")]
#endif
-[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
-[assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
-[assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
-[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
-[assembly: InternalsVisibleTo ("Xamarin.BoringTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000099dd12eda85767ae6f06023ee28e711c7e5a212462095c83868c29db75eddf6d8e296e03824c14fedd5f55553fed0b6173be3cc985a4b7f9fb7c83ccff8ba3938563b3d1f45a81122f12a1bcb73edcaad61a8456c7595a6da5184b4dd9d10f011b949ef1391fccfeab1ba62aa51c267ef8bd57ef1b6ba5a4c515d0badb81a78f")]
get; set;
}
+ public string PeerDomainName {
+ get; set;
+ }
+
public override string ToString ()
{
return string.Format ("[MonoTlsConnectionInfo: {0}:{1}]", ProtocolVersion, CipherSuiteCode);
+++ /dev/null
-Test/App.config
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<configuration>
+ <connectionStrings>
+ <add name="test-connstring"
+ connectionString="Server=(local);Initial Catalog=someDb;User Id=someUser;Password=somePassword;Application Name=someAppName;Min Pool Size=5;Max Pool Size=500;Connect Timeout=10;Connection Lifetime=29;" />
+ </connectionStrings>
+ <appSettings file="Test/appSettings.config" />
+</configuration>
}
#endif
-#if !MOBILE
public AnonymousPipeServerStream (PipeDirection direction, HandleInheritability inheritability, int bufferSize, PipeSecurity pipeSecurity)
: base (direction, bufferSize)
{
if (direction == PipeDirection.InOut)
throw new NotSupportedException ("Anonymous pipe direction can only be either in or out.");
+#if MOBILE
+ throw new NotImplementedException ();
+#else
if (IsWindows)
impl = new Win32AnonymousPipeServer (this, direction, inheritability, bufferSize, pipeSecurity);
else
InitializeHandle (impl.Handle, false, false);
IsConnected = true;
- }
#endif
+ }
[MonoTODO]
public AnonymousPipeServerStream (PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle)
#endif
}
-#if !MOBILE
public NamedPipeClientStream (string serverName, string pipeName, PipeAccessRights desiredAccessRights, PipeOptions options, TokenImpersonationLevel impersonationLevel, HandleInheritability inheritability)
: base (ToDirection (desiredAccessRights), DefaultBufferSize)
{
if (impersonationLevel != TokenImpersonationLevel.None ||
inheritability != HandleInheritability.None)
throw ThrowACLException ();
-
+#if MOBILE
+ throw new NotImplementedException ();
+#else
if (IsWindows)
impl = new Win32NamedPipeClient (this, serverName, pipeName, desiredAccessRights, options, inheritability);
else
impl = new UnixNamedPipeClient (this, serverName, pipeName, desiredAccessRights, options, inheritability);
- }
#endif
+ }
+
~NamedPipeClientStream () {
Dispose (false);
}
throw new NotImplementedException ();
}
+ protected override internal void CheckPipePropertyOperations () {
+ base.CheckPipePropertyOperations();
+ }
+
public int NumberOfServerInstances {
get {
CheckPipePropertyOperations ();
}
#endif
-#if !MOBILE
public NamedPipeServerStream (string pipeName, PipeDirection direction, int maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, int inBufferSize, int outBufferSize, PipeSecurity pipeSecurity)
: this (pipeName, direction, maxNumberOfServerInstances, transmissionMode, options, inBufferSize, outBufferSize, pipeSecurity, HandleInheritability.None)
{
{
var rights = ToAccessRights (direction) | additionalAccessRights;
// FIXME: reject some rights declarations (for ACL).
-
+#if MOBILE
+ throw new NotImplementedException ();
+#else
if (IsWindows)
impl = new Win32NamedPipeServer (this, pipeName, maxNumberOfServerInstances, transmissionMode,
rights, options, inBufferSize, outBufferSize,
rights, options, inBufferSize, outBufferSize, inheritability);
InitializeHandle (impl.Handle, false, (options & PipeOptions.Asynchronous) != PipeOptions.None);
- }
#endif
+ }
public NamedPipeServerStream (PipeDirection direction, bool isAsync, bool isConnected, SafePipeHandle safePipeHandle)
: base (direction, DefaultBufferSize)
impl.Disconnect ();
}
-#if !MOBILE
[MonoTODO]
[SecurityPermission (SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)]
public void RunAsClient (PipeStreamImpersonationWorker impersonationWorker)
{
throw new NotImplementedException ();
}
-#endif
public void WaitForConnection ()
{
throw new NotImplementedException ();
}
-#if !MOBILE
// async operations
Action wait_connect_delegate;
{
wait_connect_delegate.EndInvoke (asyncResult);
}
-#endif
}
}
return new NotImplementedException ("ACL is not supported in Mono");
}
-#if !MOBILE
internal static PipeAccessRights ToAccessRights (PipeDirection direction)
{
switch (direction) {
throw new ArgumentOutOfRangeException ();
}
}
-#endif
protected PipeStream (PipeDirection direction, int bufferSize)
: this (direction, PipeTransmissionMode.Byte, bufferSize)
set { stream = value; }
}
-#if !MOBILE
protected bool IsHandleExposed { get; private set; }
-#endif
[MonoTODO]
public bool IsMessageComplete { get; private set; }
}
// initialize/dispose/state check
-#if MOBILE
- internal static void CheckPipePropertyOperations ()
- {
- }
-
- static void CheckReadOperations ()
- {
- }
- static void CheckWriteOperations ()
- {
- }
-#else
[MonoTODO]
protected internal virtual void CheckPipePropertyOperations ()
{
this.IsHandleExposed = isExposed;
this.IsAsync = isAsync;
}
-#endif
protected override void Dispose (bool disposing)
{
throw new NotSupportedException ();
}
-#if !MOBILE
public PipeSecurity GetAccessControl ()
{
+#if MOBILE
+ throw new PlatformNotSupportedException ();
+#else
return new PipeSecurity (SafePipeHandle,
AccessControlSections.Owner |
AccessControlSections.Group |
AccessControlSections.Access);
+#endif
}
public void SetAccessControl (PipeSecurity pipeSecurity)
{
+#if MOBILE
+ throw new PlatformNotSupportedException ();
+#else
if (pipeSecurity == null)
throw new ArgumentNullException ("pipeSecurity");
pipeSecurity.Persist (SafePipeHandle);
- }
#endif
+ }
// pipe I/O
// async
-#if !MOBILE
Func<byte [],int,int,int> read_delegate;
[HostProtection (SecurityAction.LinkDemand, ExternalThreading = true)]
{
write_delegate.EndInvoke (asyncResult);
}
-#endif
}
}
[TestFixture]
public class DataTableReadWriteXmlTest
{
- public static readonly string EOL = Environment.NewLine;
void StandardizeXmlFormat(ref string xml)
{
// Get XML for DataSet writes.
sw.GetStringBuilder().Length = 0;
ds.WriteXml(sw);
- string xmlDSNone = sw.ToString().Replace ("\n", EOL);
+ string xmlDSNone = sw.ToString();
sw.GetStringBuilder().Length = 0;
ds.WriteXml(sw, XmlWriteMode.DiffGram);
- string xmlDSDiffGram = sw.ToString().Replace ("\n", EOL);
+ string xmlDSDiffGram = sw.ToString();
sw.GetStringBuilder().Length = 0;
ds.WriteXml(sw, XmlWriteMode.WriteSchema);
sw.GetStringBuilder().Length = 0;
ds.WriteXml(sw);
- xmlDSNone = sw.ToString().Replace ("\n", EOL);
+ xmlDSNone = sw.ToString();
sw.GetStringBuilder().Length = 0;
ds.WriteXml(sw, XmlWriteMode.DiffGram);
- xmlDSDiffGram = sw.ToString().Replace ("\n", EOL);
+ xmlDSDiffGram = sw.ToString();
sw.GetStringBuilder().Length = 0;
ds.WriteXml(sw, XmlWriteMode.WriteSchema);
string TextString = GetNormalizedSchema (writer.ToString ());
//string TextString = writer.ToString ();
- EOL = "\n";
string substring = TextString.Substring (0, TextString.IndexOf (EOL));
TextString = TextString.Substring (TextString.IndexOf (EOL) + EOL.Length);
Assert.AreEqual ("<?xml version=\"1.0\" encoding=\"utf-16\"?>", substring, "test#01");
StringWriter sw = new StringWriter ();
XmlTextWriter xw = new XmlTextWriter (sw);
Doc.DataSet.WriteXml (xw);
- string s = sw.ToString ();
+ string s = sw.ToString ().Replace ("\r", "").Replace ("\n", Environment.NewLine);
Assert.AreEqual (xml, s, "#1");
- Assert.AreEqual (xml, Doc.InnerXml, "#2");
+ Assert.AreEqual (xml, Doc.InnerXml.Replace ("\r", "").Replace ("\n", Environment.NewLine), "#2");
Assert.AreEqual ("EndOfFile", Reader.ReadState.ToString (), "test#01");
DataSet Set = Doc.DataSet;
return null;
var c = (HttpHeaderValueCollection<U>) collection;
- if (c.Count == 0)
- return null;
+ if (c.Count == 0) {
+ if (c.InvalidValues == null)
+ return null;
+
+ return new List<string> (c.InvalidValues);
+ }
var list = new List<string> ();
foreach (var item in c) {
list.Add (item.ToString ());
}
+ if (c.InvalidValues != null)
+ list.AddRange (c.InvalidValues);
+
return list;
}
readonly List<T> list;
readonly HttpHeaders headers;
readonly HeaderInfo headerInfo;
+ List<string> invalidValues;
internal HttpHeaderValueCollection (HttpHeaders headers, HeaderInfo headerInfo)
{
}
}
+ internal List<string> InvalidValues {
+ get {
+ return invalidValues;
+ }
+ }
+
public bool IsReadOnly {
get {
return false;
list.AddRange (values);
}
+ internal void AddInvalidValue (string invalidValue)
+ {
+ if (invalidValues == null)
+ invalidValues = new List<string> ();
+
+ invalidValues.Add (invalidValue);
+ }
+
public void Clear ()
{
list.Clear ();
+ invalidValues = null;
}
public bool Contains (T item)
public override string ToString ()
{
- // This implementation prints different values than
- // what .NET does when one of the values is invalid
- // But it better represents what is actually hold by
- // the collection
- return string.Join (headerInfo.Separator, list);
+ var res = string.Join (headerInfo.Separator, list);
+
+ if (invalidValues != null)
+ res += string.Join (headerInfo.Separator, invalidValues);
+
+ return res;
}
public bool TryParseAdd (string input)
headers.Add (name, value);
}
+ var col = (HttpHeaderValueCollection<T>) value.Parsed;
+
if (value.HasStringValues) {
var hinfo = known_headers[name];
- if (value.Parsed == null)
- value.Parsed = hinfo.CreateCollection (this);
+ if (col == null) {
+ value.Parsed = col = new HttpHeaderValueCollection<T> (this, hinfo);
+ }
object pvalue;
for (int i = 0; i < value.Values.Count; ++i) {
- if (!hinfo.TryParse (value.Values[i], out pvalue))
- continue;
-
- hinfo.AddToCollection (value.Parsed, pvalue);
- value.Values.RemoveAt (i);
- --i;
+ var svalue = value.Values[i];
+ if (!hinfo.TryParse (svalue, out pvalue)) {
+ col.AddInvalidValue (svalue);
+ } else {
+ hinfo.AddToCollection (col, pvalue);
+ }
}
+
+ value.Values.Clear ();
}
- return (HttpHeaderValueCollection<T>) value.Parsed;
+ return col;
}
internal void SetValue<T> (string name, T value, Func<object, string> toStringConverter = null)
Assert.AreEqual ("kk, ttt", headers.Connection.ToString (), "#3");
}
+
+ [Test]
+ public void AddInvalid ()
+ {
+ HttpRequestMessage message = new HttpRequestMessage ();
+ HttpRequestHeaders headers = message.Headers;
+
+ headers.TryAddWithoutValidation ("User-Agent", "user,agent/1.0");
+
+ Assert.AreEqual (0, headers.UserAgent.Count, "#1");
+ Assert.AreEqual ("user,agent/1.0", headers.UserAgent.ToString (), "#2");
+
+ Assert.AreEqual ("User-Agent: user,agent/1.0\r\n", headers.ToString (), "#3");
+
+ headers.UserAgent.Clear ();
+ Assert.AreEqual ("", headers.UserAgent.ToString (), "#4");
+ Assert.AreEqual ("", headers.ToString (), "#5");
+ }
+
+ [Test]
+ public void AddInvalidAndValid ()
+ {
+ HttpRequestMessage message = new HttpRequestMessage ();
+ HttpRequestHeaders headers = message.Headers;
+
+ headers.TryAddWithoutValidation ("User-Agent", "user,agent/1.0");
+ headers.TryAddWithoutValidation("User-Agent", "agent2/2.0");
+
+ Assert.AreEqual (1, headers.UserAgent.Count, "#1");
+ Assert.AreEqual ("agent2/2.0user,agent/1.0", headers.UserAgent.ToString (), "#2");
+
+ Assert.AreEqual ("User-Agent: agent2/2.0 user,agent/1.0\r\n", headers.ToString (), "#3");
+
+ headers.UserAgent.Clear ();
+ Assert.AreEqual ("", headers.UserAgent.ToString (), "#4");
+ Assert.AreEqual ("", headers.ToString (), "#5");
+ }
}
}
else {
IPHostEntry he = Dns.Resolve (Dns.GetHostName());
if (he.AddressList.Length == 0) throw new RemotingException ("IP address could not be determined for this host");
- host = he.AddressList [0].ToString ();
+ AddressFamily addressFamily = (Socket.OSSupportsIPv4) ? AddressFamily.InterNetwork : AddressFamily.InterNetworkV6;
+ IPAddress addr = GetMachineAddress (he, addressFamily);
+ if (addr != null)
+ host = addr.ToString ();
+ else
+ host = he.AddressList [0].ToString ();
}
}
else
server_thread.Join ();
server_thread = null;
}
+
+ private static IPAddress GetMachineAddress (IPHostEntry host, AddressFamily addressFamily)
+ {
+ IPAddress result = null;
+ if (host != null) {
+ IPAddress[] addressList = host.AddressList;
+ for (int i = 0; i < addressList.Length; i++) {
+ if (addressList[i].AddressFamily == addressFamily) {
+ result = addressList[i];
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
}
class ClientConnection
{
class AppResourcesAssemblyBuilder
{
- static string framework_version = "4.5";
- static string profile_path = "net_4_x";
CompilationSection config;
CompilerInfo ci;
CodeDomProvider _provider;
string SetAlPath (ProcessStartInfo info)
{
if (RuntimeHelpers.RunningOnWindows) {
- string alPath;
- string monoPath;
- PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static|BindingFlags.NonPublic);
- MethodInfo get_gac = gac.GetGetMethod (true);
- string p = Path.GetDirectoryName ((string) get_gac.Invoke (null, null));
- monoPath = Path.Combine (Path.GetDirectoryName (Path.GetDirectoryName (p)), "bin\\mono.bat");
- if (!File.Exists (monoPath)) {
- monoPath = Path.Combine (Path.GetDirectoryName (Path.GetDirectoryName (p)), "bin\\mono.exe");
- if (!File.Exists (monoPath)) {
- monoPath = Path.Combine (Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (p))), "mono\\mono\\mini\\mono.exe");
- if (!File.Exists (monoPath))
- throw new FileNotFoundException ("Windows mono path not found: " + monoPath);
- }
- }
- alPath = Path.Combine (p, framework_version + "\\al.exe");
-
- if (!File.Exists (alPath)) {
- alPath = Path.Combine (Path.GetDirectoryName (p), "lib\\" + profile_path + "\\al.exe");
- if (!File.Exists (alPath))
- throw new FileNotFoundException ("Windows al path not found: " + alPath);
- }
-
- info.FileName = monoPath;
- return alPath + " ";
+ info.FileName = MonoToolsLocator.Mono;
+ return MonoToolsLocator.AssemblyLinker + " ";
} else {
- info.FileName = "al";
+ info.FileName = MonoToolsLocator.AssemblyLinker;
return String.Empty;
}
}
-
+
string BuildAssemblyPath (string cultureName)
{
string baseDir = Path.Combine (baseAssemblyDirectory, cultureName);
../../build/common/Consts.cs
../../build/common/Locale.cs
../../build/common/MonoTODOAttribute.cs
+../System/System/MonoExeLocator.cs
../System.Windows.Forms/System.Resources/AssemblyNamesTypeResolutionService.cs
../System.Windows.Forms/System.Resources/ByteArrayFromResXHandler.cs
../System.Windows.Forms/System.Resources/ResXNullRef.cs
//
// Author:
// Chris Toshok (toshok@novell.com)
+// Katharina Bogad (bogad@cs.tum.edu)
//
//
using System.Text;
using System.Collections.Specialized;
using System.Security.Permissions;
+using System.Web.Configuration;
namespace System.Web
{
this.name = name;
values = new CookieNVC();
Value = "";
+
+ HttpCookiesSection cookieConfig = (HttpCookiesSection) WebConfigurationManager.GetSection ("system.web/httpCookies");
+
+ if(!string.IsNullOrWhiteSpace(cookieConfig.Domain))
+ domain = cookieConfig.Domain;
+
+ if(cookieConfig.HttpOnlyCookies)
+ flags |= CookieFlags.HttpOnly;
+
+ if(cookieConfig.RequireSSL)
+ flags |= CookieFlags.Secure;
}
public HttpCookie (string name, string value)
../../build/common/MonoTODOAttribute.cs
Assembly/AssemblyInfo.cs
Assembly/Locale.cs
+../System/System/MonoExeLocator.cs
System.Resources/AssemblyNamesTypeResolutionService.cs
System.Resources/ByteArrayFromResXHandler.cs
System.Resources/ResXNullRef.cs
if (Assembly.GetEntryAssembly () == null)
throw new NotSupportedException ("The method 'Restart' is not supported by this application type.");
- string mono_path = null;
-
- //Get mono path
- PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static | BindingFlags.NonPublic);
- MethodInfo get_gac = null;
- if (gac != null)
- get_gac = gac.GetGetMethod (true);
-
- if (get_gac != null) {
- string gac_path = Path.GetDirectoryName ((string)get_gac.Invoke (null, null));
- string mono_prefix = Path.GetDirectoryName (Path.GetDirectoryName (gac_path));
-
- if (XplatUI.RunningOnUnix) {
- mono_path = Path.Combine (mono_prefix, "bin/mono");
- if (!File.Exists (mono_path))
- mono_path = "mono";
- } else {
- mono_path = Path.Combine (mono_prefix, "bin\\mono.bat");
-
- if (!File.Exists (mono_path))
- mono_path = Path.Combine (mono_prefix, "bin\\mono.exe");
-
- if (!File.Exists (mono_path))
- mono_path = Path.Combine (mono_prefix, "mono\\mono\\mini\\mono.exe");
-
- if (!File.Exists (mono_path))
- throw new FileNotFoundException (string.Format ("Windows mono path not found: '{0}'", mono_path));
- }
- }
+ string mono_path = MonoToolsLocator.Mono;
//Get command line arguments
StringBuilder argsBuilder = new StringBuilder ();
serializer.Serialize (writer, obj);
writer.Close ();
- Assert.AreEqual (@"<?xml version=""1.0"" encoding=""utf-16""?>
-<Bug594490Class xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xml:lang=""hello world"" />",
+ Assert.AreEqual (@"<?xml version=""1.0"" encoding=""utf-16""?>" + Environment.NewLine +
+ @"<Bug594490Class xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xml:lang=""hello world"" />",
writer.ToString (),
"Novell bug #594490 (https://bugzilla.novell.com/show_bug.cgi?id=594490) not fixed.");
}
[assembly: StringFreezing]
[assembly: DefaultDependency (LoadHint.Always)]
- [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
- [assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
- [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
- [assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
[assembly: InternalsVisibleTo ("Mono.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
- [assembly: InternalsVisibleTo ("Xamarin.BoringTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000099dd12eda85767ae6f06023ee28e711c7e5a212462095c83868c29db75eddf6d8e296e03824c14fedd5f55553fed0b6173be3cc985a4b7f9fb7c83ccff8ba3938563b3d1f45a81122f12a1bcb73edcaad61a8456c7595a6da5184b4dd9d10f011b949ef1391fccfeab1ba62aa51c267ef8bd57ef1b6ba5a4c515d0badb81a78f")]
internal class CSharpCodeCompiler : CSharpCodeGenerator, ICodeCompiler
{
- static string windowsMcsPath;
- static string windowsMonoPath;
- static string unixMcsCommand;
-
Mutex mcsOutMutex;
StringCollection mcsOutput;
- static CSharpCodeCompiler ()
- {
- if (Path.DirectorySeparatorChar == '\\') {
- PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static|BindingFlags.NonPublic);
- MethodInfo get_gac = gac.GetGetMethod (true);
- string p = Path.GetDirectoryName (
- (string) get_gac.Invoke (null, null));
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p)),
- "bin\\mono.bat");
- if (!File.Exists (windowsMonoPath))
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p)),
- "bin\\mono.exe");
- if (!File.Exists (windowsMonoPath))
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p))),
- "mono\\mono\\mini\\mono.exe");
- if (!File.Exists (windowsMonoPath))
- throw new FileNotFoundException ("Windows mono path not found: " + windowsMonoPath);
-
- windowsMcsPath = Path.Combine (p, "4.5\\mcs.exe");
- if (!File.Exists (windowsMcsPath))
- windowsMcsPath = Path.Combine(Path.GetDirectoryName (p), "lib\\build\\mcs.exe");
-
- if (!File.Exists (windowsMcsPath))
- throw new FileNotFoundException ("Windows mcs path not found: " + windowsMcsPath);
- } else {
- var mscorlibPath = new Uri (typeof (object).Assembly.CodeBase).LocalPath;
- var unixMcsPath = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "mcs"));
- if (File.Exists (unixMcsPath))
- unixMcsCommand = unixMcsPath;
- else
- unixMcsCommand = "mcs";
- }
- }
-
//
// Constructors
//
// FIXME: these lines had better be platform independent.
if (Path.DirectorySeparatorChar == '\\') {
- mcs.StartInfo.FileName = windowsMonoPath;
- mcs.StartInfo.Arguments = "\"" + windowsMcsPath + "\" " +
- BuildArgs (options, fileNames, ProviderOptions);
+ mcs.StartInfo.FileName = MonoToolsLocator.Mono;
+ mcs.StartInfo.Arguments = "\"" + MonoToolsLocator.CSharpCompiler + "\" ";
} else {
- mcs.StartInfo.FileName=unixMcsCommand;
- mcs.StartInfo.Arguments=BuildArgs(options, fileNames, ProviderOptions);
+ mcs.StartInfo.FileName = MonoToolsLocator.CSharpCompiler;
}
+ mcs.StartInfo.Arguments += BuildArgs (options, fileNames, ProviderOptions);
+
mcsOutput = new StringCollection ();
mcsOutMutex = new Mutex ();
/*
{
internal class VBCodeCompiler : VBCodeGenerator, ICodeCompiler
{
- static string windowsMonoPath;
- static string windowsvbncPath;
- static string unixVbncCommand;
-
- static VBCodeCompiler ()
- {
- if (Path.DirectorySeparatorChar == '\\') {
- PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static | BindingFlags.NonPublic);
- MethodInfo get_gac = gac.GetGetMethod (true);
- string p = Path.GetDirectoryName (
- (string) get_gac.Invoke (null, null));
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p)),
- "bin\\mono.bat");
- if (!File.Exists (windowsMonoPath))
- windowsMonoPath = Path.Combine (
- Path.GetDirectoryName (
- Path.GetDirectoryName (p)),
- "bin\\mono.exe");
- windowsvbncPath =
- Path.Combine (p, "2.0\\vbnc.exe");
- } else {
- var mscorlibPath = new Uri (typeof (object).Assembly.CodeBase).LocalPath;
- var unixMcsPath = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "vbnc"));
- if (File.Exists (unixMcsPath))
- unixVbncCommand = unixMcsPath;
- else
- unixVbncCommand = "vbnc";
- }
- }
-
public CompilerResults CompileAssemblyFromDom (CompilerParameters options, CodeCompileUnit e)
{
return CompileAssemblyFromDomBatch (options, new CodeCompileUnit[] { e });
string[] vbnc_output_lines;
// FIXME: these lines had better be platform independent.
if (Path.DirectorySeparatorChar == '\\') {
- vbnc.StartInfo.FileName = windowsMonoPath;
- vbnc.StartInfo.Arguments = windowsvbncPath + ' ' + BuildArgs (options, fileNames);
+ vbnc.StartInfo.FileName = MonoToolsLocator.Mono;
+ vbnc.StartInfo.Arguments = MonoToolsLocator.VBCompiler + ' ' + BuildArgs (options, fileNames);
} else {
- vbnc.StartInfo.FileName = "vbnc";
+ vbnc.StartInfo.FileName = MonoToolsLocator.VBCompiler;
vbnc.StartInfo.Arguments = BuildArgs (options, fileNames);
}
//Console.WriteLine (vbnc.StartInfo.Arguments);
static IMonoTlsProvider CreateDefaultProvider ()
{
#if SECURITY_DEP
- MSI.MonoTlsProvider provider = null;
-#if MONO_FEATURE_NEW_SYSTEM_SOURCE
- /*
- * This is a hack, which is used in the Mono.Security.Providers.NewSystemSource
- * assembly, which will provide a "fake" System.dll. Use the public Mono.Security
- * API to get the "real" System.dll's provider via reflection, then wrap it with
- * the "fake" version's perceived view.
- *
- * NewSystemSource needs to compile MonoTlsProviderFactory.cs, IMonoTlsProvider.cs,
- * MonoTlsProviderWrapper.cs and CallbackHelpers.cs from this directory and only these.
- */
- provider = MSI.MonoTlsProviderFactory.GetProvider ();
-#else
- provider = CreateDefaultProviderImpl ();
-#endif
+ MSI.MonoTlsProvider provider = CreateDefaultProviderImpl ();
if (provider != null)
return new Private.MonoTlsProviderWrapper (provider);
#endif
#endregion
-#if SECURITY_DEP && !MONO_FEATURE_NEW_SYSTEM_SOURCE
+#if SECURITY_DEP
static Dictionary<string,string> providerRegistration;
return;
providerRegistration = new Dictionary<string,string> ();
providerRegistration.Add ("legacy", "Mono.Net.Security.Private.MonoLegacyTlsProvider");
- providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
- providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
#if HAVE_BTLS
if (Mono.Btls.MonoBtlsProvider.IsSupported ())
providerRegistration.Add ("btls", "Mono.Btls.MonoBtlsProvider");
+++ /dev/null
-//
-// Internal.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-using System.Runtime.InteropServices;
-using System.Security.Cryptography.X509Certificates;
-
-namespace System.Net.Security
-{
- //From Schannel.h
- [Flags]
- internal enum SchProtocols
- {
- Zero = 0,
- PctClient = 0x00000002,
- PctServer = 0x00000001,
- Pct = (PctClient | PctServer),
- Ssl2Client = 0x00000008,
- Ssl2Server = 0x00000004,
- Ssl2 = (Ssl2Client | Ssl2Server),
- Ssl3Client = 0x00000020,
- Ssl3Server = 0x00000010,
- Ssl3 = (Ssl3Client | Ssl3Server),
- Tls10Client = 0x00000080,
- Tls10Server = 0x00000040,
- Tls10 = (Tls10Client | Tls10Server),
- Tls11Client = 0x00000200,
- Tls11Server = 0x00000100,
- Tls11 = (Tls11Client | Tls11Server),
- Tls12Client = 0x00000800,
- Tls12Server = 0x00000400,
- Tls12 = (Tls12Client | Tls12Server),
- Ssl3Tls = (Ssl3 | Tls10),
- UniClient = unchecked((int)0x80000000),
- UniServer = 0x40000000,
- Unified = (UniClient | UniServer),
- ClientMask = (PctClient | Ssl2Client | Ssl3Client | Tls10Client | Tls11Client | Tls12Client | UniClient),
- ServerMask = (PctServer | Ssl2Server | Ssl3Server | Tls10Server | Tls11Server | Tls12Server | UniServer)
- }
-
- //From Schannel.h
- [StructLayout (LayoutKind.Sequential)]
- internal class SslConnectionInfo
- {
- public readonly int Protocol;
- public readonly int DataCipherAlg;
- public readonly int DataKeySize;
- public readonly int DataHashAlg;
- public readonly int DataHashKeySize;
- public readonly int KeyExchangeAlg;
- public readonly int KeyExchKeySize;
-
- internal SslConnectionInfo (int protocol)
- {
- Protocol = protocol;
- }
- }
-}
+++ /dev/null
-//
-// SSPIConfiguration.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-#if MONO_SECURITY_ALIAS
-extern alias MonoSecurity;
-using MonoSecurity::Mono.Security.Interface;
-#else
-using Mono.Security.Interface;
-#endif
-using Mono.Net.Security;
-
-namespace System.Net.Security
-{
- internal interface SSPIConfiguration
- {
- IMonoTlsProvider Provider {
- get;
- }
-
- MonoTlsSettings Settings {
- get;
- }
-
- IMonoTlsEventSink EventSink {
- get;
- }
- }
-}
-#endif
+++ /dev/null
-//
-// SafeHandles.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-#if MONO_SECURITY_ALIAS
-extern alias MonoSecurity;
-using IMonoTlsContext = MonoSecurity::Mono.Security.Interface.IMonoTlsContext;
-#else
-using IMonoTlsContext = Mono.Security.Interface.IMonoTlsContext;
-#endif
-
-using System.Runtime.InteropServices;
-using System.Security.Cryptography.X509Certificates;
-
-namespace System.Net.Security
-{
- class DummySafeHandle : SafeHandle
- {
- protected DummySafeHandle ()
- : base ((IntPtr)(-1), true)
- {
- }
-
- protected override bool ReleaseHandle ()
- {
- return true;
- }
-
- public override bool IsInvalid {
- get { return handle == (IntPtr)(-1); }
- }
- }
-
- class SafeFreeCertContext : DummySafeHandle
- {
- }
-
- class SafeFreeCredentials : DummySafeHandle
- {
- SecureCredential credential;
-
- public X509Certificate2 Certificate {
- get {
- if (IsInvalid)
- throw new ObjectDisposedException ("Certificate");
- return credential.certificate;
- }
- }
-
- public SafeFreeCredentials (SecureCredential credential)
- {
- this.credential = credential;
- bool success = true;
- DangerousAddRef (ref success);
- }
-
- public override bool IsInvalid {
- get {
- return credential.certificate == null;
- }
- }
-
- protected override bool ReleaseHandle ()
- {
- credential.Clear ();
- return base.ReleaseHandle ();
- }
- }
-
- class SafeDeleteContext : DummySafeHandle
- {
- IMonoTlsContext context;
-
- public IMonoTlsContext Context {
- get {
- if (IsInvalid)
- throw new ObjectDisposedException ("TlsContext");
- return context;
- }
- }
-
- public SafeDeleteContext (IMonoTlsContext context)
- {
- this.context = context;
- }
-
- public override bool IsInvalid {
- get {
- return context == null || !context.IsValid;
- }
- }
-
- protected override bool ReleaseHandle ()
- {
- context.Dispose ();
- context = null;
- return base.ReleaseHandle ();
- }
- }
-
- struct SecureCredential
- {
- public const int CurrentVersion = 0x4;
-
- [Flags]
- public enum Flags
- {
- Zero = 0,
- NoSystemMapper = 0x02,
- NoNameCheck = 0x04,
- ValidateManual = 0x08,
- NoDefaultCred = 0x10,
- ValidateAuto = 0x20,
- SendAuxRecord = 0x00200000,
- UseStrongCrypto = 0x00400000
- }
-
- int version;
- internal X509Certificate2 certificate;
- SchProtocols protocols;
- EncryptionPolicy policy;
-
- public SecureCredential (int version, X509Certificate2 certificate, SecureCredential.Flags flags, SchProtocols protocols, EncryptionPolicy policy)
- {
- this.version = version;
- this.certificate = certificate;
- this.protocols = protocols;
- this.policy = policy;
- }
-
- public void Clear ()
- {
- certificate = null;
- }
- }
-
- internal class SafeCredentialReference : DummySafeHandle
- {
- //
- // Static cache will return the target handle if found the reference in the table.
- //
- internal SafeFreeCredentials _Target;
-
- //
- //
- internal static SafeCredentialReference CreateReference (SafeFreeCredentials target)
- {
- SafeCredentialReference result = new SafeCredentialReference (target);
- if (result.IsInvalid)
- return null;
-
- return result;
- }
-
- private SafeCredentialReference (SafeFreeCredentials target)
- : base ()
- {
- // Bumps up the refcount on Target to signify that target handle is statically cached so
- // its dispose should be postponed
- bool b = false;
- try {
- target.DangerousAddRef (ref b);
- } catch {
- if (b) {
- target.DangerousRelease ();
- b = false;
- }
- } finally {
- if (b) {
- _Target = target;
- SetHandle (new IntPtr (0)); // make this handle valid
- }
- }
- }
-
- override protected bool ReleaseHandle ()
- {
- SafeFreeCredentials target = _Target;
- if (target != null)
- target.DangerousRelease ();
- _Target = null;
- return true;
- }
- }
-
-}
-#endif
+++ /dev/null
-//
-// SSPIWrapper.cs
-//
-// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-//
-// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-#if MONO_SECURITY_ALIAS
-extern alias MonoSecurity;
-#endif
-
-#if MONO_SECURITY_ALIAS
-using MX = MonoSecurity::Mono.Security.X509;
-using MonoSecurity::Mono.Security.Interface;
-#else
-using MX = Mono.Security.X509;
-using Mono.Security.Interface;
-#endif
-
-using System.Runtime.InteropServices;
-using System.Security.Authentication.ExtendedProtection;
-using System.Security.Cryptography.X509Certificates;
-using MNS = Mono.Net.Security;
-
-namespace System.Net.Security
-{
- internal class SSPIInterface
- {
- public IMonoTlsContext Context {
- get;
- private set;
- }
-
- public IMonoTlsEventSink EventSink {
- get;
- private set;
- }
-
- public SSPIInterface (IMonoTlsContext context, IMonoTlsEventSink eventSink)
- {
- Context = context;
- EventSink = eventSink;
- }
- }
-
- internal static class GlobalSSPI
- {
- internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
- bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus, EncryptionPolicy encryptionPolicy,
- LocalCertSelectionCallback certSelectionDelegate, RemoteCertValidationCallback remoteValidationCallback, SSPIConfiguration userConfig)
- {
- if (userConfig.Settings != null && remoteValidationCallback != null)
- throw new InvalidOperationException ();
- var context = userConfig.Provider.CreateTlsContext (
- hostname, serverMode, (TlsProtocols)protocolFlags, serverCertificate, clientCertificates,
- remoteCertRequired, checkCertName, checkCertRevocationStatus,
- (MonoEncryptionPolicy)encryptionPolicy, userConfig.Settings);
- return new SSPIInterface (context, userConfig.EventSink);
- }
- }
-
- /*
- * SSPIWrapper _is a _class that provides a managed implementation of the equivalent
- * _class _in Microsofts .NET Framework.
- *
- * The SSPIWrapper class is used by the TLS/SSL stack to implement both the
- * protocol handshake as well as the encryption and decryption of messages.
- *
- * Microsoft's implementation of this class is merely a P/Invoke wrapper
- * around the native SSPI APIs on Windows. This implementation instead,
- * provides a managed implementation that uses the cross platform Mono.Security
- * to provide the equivalent functionality.
- *
- * Ideally, this should be abstracted with a different name, and decouple
- * the naming from the SSPIWrapper name, but this allows Mono to reuse
- * the .NET code with minimal changes.
- *
- * The "internal" methods here are the API that is consumed by the class
- * libraries.
- */
- internal static class SSPIWrapper
- {
- static void SetCredentials (SSPIInterface secModule, SafeFreeCredentials credentials)
- {
- if (credentials != null && !credentials.IsInvalid) {
- if (!secModule.Context.HasCredentials && credentials.Certificate != null) {
- var cert = new X509Certificate2 (credentials.Certificate.RawData);
- secModule.Context.SetCertificate (cert, credentials.Certificate.PrivateKey);
- }
- bool success = true;
- credentials.DangerousAddRef (ref success);
- }
- }
-
- /*
- * @safecontext is null on the first use, but it will become non-null for invocations
- * where the connection is being re-negotiated.
- *
- */
- internal static int AcceptSecurityContext (SSPIInterface secModule, ref SafeFreeCredentials credentials, ref SafeDeleteContext safeContext, ContextFlags inFlags, Endianness endianness, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ref ContextFlags outFlags)
- {
- if (endianness != Endianness.Native)
- throw new NotSupportedException ();
-
- if (safeContext == null) {
- if (credentials == null || credentials.IsInvalid)
- return (int)SecurityStatus.CredentialsNeeded;
-
- secModule.Context.Initialize (secModule.EventSink);
- safeContext = new SafeDeleteContext (secModule.Context);
- }
-
- SetCredentials (secModule, credentials);
-
- var incoming = GetInputBuffer (inputBuffer);
- IBufferOffsetSize outgoing;
-
- var retval = (int)safeContext.Context.GenerateNextToken (incoming, out outgoing);
- UpdateOutput (outgoing, outputBuffer);
- return retval;
- }
-
- internal static int InitializeSecurityContext (SSPIInterface secModule, ref SafeFreeCredentials credentials, ref SafeDeleteContext safeContext, string targetName, ContextFlags inFlags, Endianness endianness, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, ref ContextFlags outFlags)
- {
- if (inputBuffer != null)
- throw new InvalidOperationException ();
-
- if (safeContext == null) {
- secModule.Context.Initialize (secModule.EventSink);
- safeContext = new SafeDeleteContext (secModule.Context);
- }
-
- return InitializeSecurityContext (secModule, credentials, ref safeContext, targetName, inFlags, endianness, null, outputBuffer, ref outFlags);
- }
-
- internal static int InitializeSecurityContext (SSPIInterface secModule, SafeFreeCredentials credentials, ref SafeDeleteContext safeContext, string targetName, ContextFlags inFlags, Endianness endianness, SecurityBuffer[] inputBuffers, SecurityBuffer outputBuffer, ref ContextFlags outFlags)
- {
- if (endianness != Endianness.Native)
- throw new NotSupportedException ();
-
- SetCredentials (secModule, credentials);
-
- SecurityBuffer inputBuffer = null;
- if (inputBuffers != null) {
- if (inputBuffers.Length != 2 || inputBuffers [1].type != BufferType.Empty)
- throw new NotSupportedException ();
- inputBuffer = inputBuffers [0];
- }
-
- var incoming = GetInputBuffer (inputBuffer);
- IBufferOffsetSize outgoing = null;
-
- var retval = (int)safeContext.Context.GenerateNextToken (incoming, out outgoing);
- UpdateOutput (outgoing, outputBuffer);
- return retval;
- }
-
- internal static int EncryptMessage (SSPIInterface secModule, SafeDeleteContext safeContext, SecurityBuffer securityBuffer, uint sequenceNumber)
- {
- var incoming = GetInputBuffer (securityBuffer);
- var retval = (int)safeContext.Context.EncryptMessage (ref incoming);
- UpdateOutput (incoming, securityBuffer);
- return retval;
- }
-
- internal static int DecryptMessage (SSPIInterface secModule, SafeDeleteContext safeContext, SecurityBuffer securityBuffer, uint sequenceNumber)
- {
- var incoming = GetInputBuffer (securityBuffer);
- var retval = (int)safeContext.Context.DecryptMessage (ref incoming);
- UpdateOutput (incoming, securityBuffer);
- return retval;
- }
-
- internal static byte[] CreateShutdownMessage (SSPIInterface secModule, SafeDeleteContext safeContext)
- {
- return safeContext.Context.CreateCloseNotify ();
- }
-
- internal static byte[] CreateHelloRequestMessage (SSPIInterface secModule, SafeDeleteContext safeContext)
- {
- return safeContext.Context.CreateHelloRequest ();
- }
-
- internal static bool IsClosed (SSPIInterface secModule, SafeDeleteContext safeContext)
- {
- return safeContext.Context.ReceivedCloseNotify;
- }
-
- internal static SafeFreeCredentials AcquireCredentialsHandle (SSPIInterface SecModule, string package, CredentialUse intent, SecureCredential scc)
- {
- return new SafeFreeCredentials (scc);
- }
-
- public static ChannelBinding QueryContextChannelBinding (SSPIInterface SecModule, SafeDeleteContext securityContext, ContextAttribute contextAttribute)
- {
- return null;
- }
-
- internal static X509Certificate2 GetRemoteCertificate (SafeDeleteContext safeContext, out X509Certificate2Collection remoteCertificateStore)
- {
- X509CertificateCollection monoCollection;
- if (safeContext == null || safeContext.IsInvalid) {
- remoteCertificateStore = null;
- return null;
- }
- var monoCert = safeContext.Context.GetRemoteCertificate (out monoCollection);
- if (monoCert == null) {
- remoteCertificateStore = null;
- return null;
- }
-
- remoteCertificateStore = new X509Certificate2Collection ();
- foreach (var cert in monoCollection) {
- remoteCertificateStore.Add (cert);
- }
- return (X509Certificate2)monoCert;
- }
-
- internal static bool CheckRemoteCertificate (SafeDeleteContext safeContext)
- {
- return safeContext.Context.VerifyRemoteCertificate ();
- }
-
- internal static MonoTlsConnectionInfo GetMonoConnectionInfo (SSPIInterface SecModule, SafeDeleteContext securityContext)
- {
- return securityContext.Context.GetConnectionInfo ();
- }
-
- internal static SslConnectionInfo GetConnectionInfo (SSPIInterface SecModule, SafeDeleteContext securityContext)
- {
- var info = securityContext.Context.GetConnectionInfo ();
- if (info == null)
- return null;
-
- return new SslConnectionInfo ((int)info.ProtocolVersion);
- }
-
- class InputBuffer : IBufferOffsetSize
- {
- public byte[] Buffer {
- get;
- private set;
- }
-
- public int Offset {
- get;
- private set;
- }
-
- public int Size {
- get;
- private set;
- }
-
- public InputBuffer (byte[] buffer, int offset, int size)
- {
- Buffer = buffer;
- Offset = offset;
- Size = size;
- }
- }
-
- static IBufferOffsetSize GetInputBuffer (SecurityBuffer incoming)
- {
- return incoming != null ? new InputBuffer (incoming.token, incoming.offset, incoming.size) : null;
- }
-
- static void UpdateOutput (IBufferOffsetSize buffer, SecurityBuffer outputBuffer)
- {
- if (buffer != null) {
- outputBuffer.token = buffer.Buffer;
- outputBuffer.offset = buffer.Offset;
- outputBuffer.size = buffer.Size;
- outputBuffer.type = BufferType.Token;
- } else {
- outputBuffer.token = null;
- outputBuffer.size = outputBuffer.offset = 0;
- outputBuffer.type = BufferType.Empty;
- }
- }
- }
-}
-#endif
+++ /dev/null
-//
-// Mono-specific additions to Microsoft's SslStream.cs
-//
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-#if MONO_SECURITY_ALIAS
-extern alias MonoSecurity;
-using MonoSecurity::Mono.Security.Interface;
-#else
-using Mono.Security.Interface;
-#endif
-using System.Threading;
-using System.Security.Cryptography.X509Certificates;
-using MNS = Mono.Net.Security;
-
-namespace System.Net.Security
-{
- using System.Net.Sockets;
- using System.IO;
-
- partial class SslStream : IMonoTlsEventSink
- {
- #if SECURITY_DEP
- SSPIConfiguration _Configuration;
-
- internal SslStream (Stream innerStream, bool leaveInnerStreamOpen, EncryptionPolicy encryptionPolicy, MonoTlsProvider provider, MonoTlsSettings settings)
- : base (innerStream, leaveInnerStreamOpen)
- {
- if (encryptionPolicy != EncryptionPolicy.RequireEncryption && encryptionPolicy != EncryptionPolicy.AllowNoEncryption && encryptionPolicy != EncryptionPolicy.NoEncryption)
- throw new ArgumentException (SR.GetString (SR.net_invalid_enum, "EncryptionPolicy"), "encryptionPolicy");
-
- var validationHelper = MNS.ChainValidationHelper.CloneWithCallbackWrapper (provider, ref settings, myUserCertValidationCallbackWrapper);
-
- LocalCertSelectionCallback selectionCallback = null;
- if (validationHelper.HasCertificateSelectionCallback)
- selectionCallback = validationHelper.SelectClientCertificate;
-
- var internalProvider = new MNS.Private.MonoTlsProviderWrapper (provider);
- _Configuration = new MyConfiguration (internalProvider, settings, this);
- _SslState = new SslState (innerStream, null, selectionCallback, encryptionPolicy, _Configuration);
- }
-
- /*
- * Mono-specific version of 'userCertValidationCallbackWrapper'; we're called from ChainValidationHelper.ValidateChain() here.
- *
- * Since we're built without the PrebuiltSystem alias, we can't use 'SslPolicyErrors' here. This prevents us from creating a subclass of 'ChainValidationHelper'
- * as well as providing a custom 'ServerCertValidationCallback'.
- */
- bool myUserCertValidationCallbackWrapper (ServerCertValidationCallback callback, X509Certificate certificate, X509Chain chain, MonoSslPolicyErrors sslPolicyErrors)
- {
- m_RemoteCertificateOrBytes = certificate == null ? null : certificate.GetRawCertData ();
- if (callback == null) {
- if (!_SslState.RemoteCertRequired)
- sslPolicyErrors &= ~MonoSslPolicyErrors.RemoteCertificateNotAvailable;
-
- return (sslPolicyErrors == MonoSslPolicyErrors.None);
- }
-
- return MNS.ChainValidationHelper.InvokeCallback (callback, this, certificate, chain, sslPolicyErrors);
- }
-
- class MyConfiguration : SSPIConfiguration
- {
- MNS.IMonoTlsProvider provider;
- MonoTlsSettings settings;
- IMonoTlsEventSink eventSink;
-
- public MyConfiguration (MNS.IMonoTlsProvider provider, MonoTlsSettings settings, IMonoTlsEventSink eventSink)
- {
- this.provider = provider;
- this.settings = settings;
- this.eventSink = eventSink;
- }
-
- public MNS.IMonoTlsProvider Provider {
- get { return provider; }
- }
-
- public MonoTlsSettings Settings {
- get { return settings; }
- }
-
- public IMonoTlsEventSink EventSink {
- get { return eventSink; }
- }
- }
- #endif
-
- internal bool IsClosed {
- get { return _SslState.IsClosed; }
- }
-
- internal Exception LastError {
- get { return lastError; }
- }
-
- #region IMonoTlsEventSink
-
- Exception lastError;
-
- void IMonoTlsEventSink.Error (Exception exception)
- {
- Interlocked.CompareExchange<Exception> (ref lastError, exception, null);
- }
-
- void IMonoTlsEventSink.ReceivedCloseNotify ()
- {
- }
-
- #endregion
-
- internal IAsyncResult BeginShutdown (AsyncCallback asyncCallback, object asyncState)
- {
- return _SslState.BeginShutdown (asyncCallback, asyncState);
- }
-
- internal void EndShutdown (IAsyncResult asyncResult)
- {
- _SslState.EndShutdown (asyncResult);
- }
-
- internal IAsyncResult BeginRenegotiate (AsyncCallback asyncCallback, object asyncState)
- {
- return _SslState.BeginRenegotiate (asyncCallback, asyncState);
- }
-
- internal void EndRenegotiate (IAsyncResult asyncResult)
- {
- _SslState.EndRenegotiate (asyncResult);
- }
-
- internal X509Certificate InternalLocalCertificate {
- get { return _SslState.InternalLocalCertificate; }
- }
-
- internal MonoTlsConnectionInfo GetMonoConnectionInfo ()
- {
- return _SslState.GetMonoConnectionInfo ();
- }
- }
-}
-#endif
+++ /dev/null
-//
-// Mono-specific additions to Microsoft's _SecureChannel.cs
-//
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-#if MONO_SECURITY_ALIAS
-extern alias MonoSecurity;
-using MonoSecurity::Mono.Security.Interface;
-#else
-using Mono.Security.Interface;
-#endif
-namespace System.Net.Security
-{
- partial class SecureChannel
- {
- internal MonoTlsConnectionInfo GetMonoConnectionInfo ()
- {
- return SSPIWrapper.GetMonoConnectionInfo (m_SecModule, m_SecurityContext);
- }
-
- internal ProtocolToken CreateShutdownMessage ()
- {
- var buffer = SSPIWrapper.CreateShutdownMessage (m_SecModule, m_SecurityContext);
- return new ProtocolToken (buffer, SecurityStatus.ContinueNeeded);
- }
-
- internal ProtocolToken CreateHelloRequestMessage ()
- {
- var buffer = SSPIWrapper.CreateHelloRequestMessage (m_SecModule, m_SecurityContext);
- return new ProtocolToken (buffer, SecurityStatus.ContinueNeeded);
- }
-
- internal bool IsClosed {
- get {
- if (m_SecModule == null || m_SecurityContext == null || m_SecurityContext.IsClosed)
- return true;
- return SSPIWrapper.IsClosed (m_SecModule, m_SecurityContext);
- }
- }
- }
-}
-#endif
+++ /dev/null
-//
-// Mono-specific additions to Microsoft's _SslState.cs
-//
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-#if MONO_SECURITY_ALIAS
-extern alias MonoSecurity;
-using MonoSecurity::Mono.Security.Interface;
-#else
-using Mono.Security.Interface;
-#endif
-namespace System.Net.Security
-{
- using System.IO;
- using System.Threading;
- using System.Net.Sockets;
-
- partial class SslState
- {
- int _SentShutdown;
-
- internal MonoTlsConnectionInfo GetMonoConnectionInfo ()
- {
- return Context.GetMonoConnectionInfo ();
- }
-
- internal bool IsClosed {
- get { return Context.IsClosed; }
- }
-
- internal ProtocolToken CreateShutdownMessage ()
- {
- return Context.CreateShutdownMessage ();
- }
-
- internal ProtocolToken CreateHelloRequestMessage ()
- {
- return Context.CreateHelloRequestMessage ();
- }
-
- internal IAsyncResult BeginShutdown (AsyncCallback asyncCallback, object asyncState)
- {
- var shutdownResult = new ShutdownAsyncResult (this, asyncState, asyncCallback);
-
- if (Interlocked.CompareExchange (ref _SentShutdown, 1, 0) == 1) {
- shutdownResult.InvokeCallback ();
- return shutdownResult;
- }
-
- try
- {
- CheckThrow (false);
- shutdownResult.SentShutdown = true;
- SecureStream.BeginShutdown (shutdownResult);
- return shutdownResult;
- } catch (Exception e) {
- if (e is IOException)
- throw;
- throw new IOException (SR.GetString (SR.mono_net_io_shutdown), e);
- }
- }
-
- internal void EndShutdown (IAsyncResult asyncResult)
- {
- if (asyncResult == null)
- throw new ArgumentNullException ("asyncResult");
-
- var shutdownResult = asyncResult as ShutdownAsyncResult;
- if (shutdownResult == null)
- throw new ArgumentException (SR.GetString (SR.net_io_async_result, asyncResult.GetType ().FullName), "asyncResult");
-
- if (shutdownResult.SentShutdown)
- SecureStream.EndShutdown (shutdownResult);
- }
-
- internal IAsyncResult BeginRenegotiate (AsyncCallback asyncCallback, object asyncState)
- {
- var lazyResult = new LazyAsyncResult (this, asyncState, asyncCallback);
-
- if (Interlocked.Exchange (ref _NestedAuth, 1) == 1)
- throw new InvalidOperationException (SR.GetString (SR.net_io_invalidnestedcall, "BeginRenegotiate", "renegotiate"));
- if (Interlocked.CompareExchange (ref _PendingReHandshake, 1, 0) == 1)
- throw new InvalidOperationException (SR.GetString (SR.net_io_invalidnestedcall, "BeginRenegotiate", "renegotiate"));
-
- try {
- CheckThrow (false);
- SecureStream.BeginRenegotiate (lazyResult);
- return lazyResult;
- } catch (Exception e) {
- _NestedAuth = 0;
- if (e is IOException)
- throw;
- throw new IOException (SR.GetString (SR.mono_net_io_renegotiate), e);
- }
- }
-
- internal void EndRenegotiate (IAsyncResult result)
- {
- if (result == null)
- throw new ArgumentNullException ("asyncResult");
-
- LazyAsyncResult lazyResult = result as LazyAsyncResult;
- if (lazyResult == null)
- throw new ArgumentException (SR.GetString (SR.net_io_async_result, result.GetType ().FullName), "asyncResult");
-
- if (Interlocked.Exchange (ref _NestedAuth, 0) == 0)
- throw new InvalidOperationException (SR.GetString (SR.net_io_invalidendcall, "EndRenegotiate"));
-
- SecureStream.EndRenegotiate (lazyResult);
- }
-
- internal bool CheckEnqueueHandshakeWrite (byte[] buffer, AsyncProtocolRequest asyncRequest)
- {
- return CheckEnqueueHandshake (buffer, asyncRequest);
- }
-
- internal void StartReHandshake (AsyncProtocolRequest asyncRequest)
- {
- if (IsServer) {
- byte[] buffer = null;
- if (CheckEnqueueHandshakeRead (ref buffer, asyncRequest))
- return;
-
- StartReceiveBlob (buffer, asyncRequest);
- return;
- }
-
- ForceAuthentication (false, null, asyncRequest);
- }
-
- class ShutdownAsyncResult : LazyAsyncResult
- {
- public bool SentShutdown;
-
- internal ShutdownAsyncResult (SslState instance, object userState, AsyncCallback callback)
- : base (instance, userState, callback)
- {
- }
- }
- }
-}
-#endif
+++ /dev/null
-//
-// Mono-specific additions to Microsoft's _SslStream.cs
-//
-#if MONO_FEATURE_NEW_TLS && SECURITY_DEP
-namespace System.Net.Security
-{
- using System.IO;
- using System.Threading;
- using System.Net.Sockets;
-
- partial class _SslStream
- {
- static readonly AsyncCallback _HandshakeWriteCallback = new AsyncCallback (HandshakeWriteCallback);
- static readonly HandshakeProtocolCallback _ResumeHandshakeWriteCallback = new HandshakeProtocolCallback (ResumeHandshakeWriteCallback);
-
- internal void BeginShutdown (LazyAsyncResult lazyResult)
- {
- HandshakeProtocolRequest asyncRequest = new HandshakeProtocolRequest (lazyResult);
-
- if (Interlocked.Exchange (ref _NestedWrite, 1) == 1)
- throw new NotSupportedException (SR.GetString (SR.net_io_invalidnestedcall, (asyncRequest != null ? "BeginShutdown" : "Shutdown"), "shutdown"));
-
- bool failed = false;
- try
- {
- ProtocolToken message = _SslState.CreateShutdownMessage ();
- asyncRequest.SetNextRequest (HandshakeProtocolState.Shutdown, message, _ResumeHandshakeWriteCallback);
-
- StartHandshakeWrite (asyncRequest);
- } catch (Exception e) {
- _SslState.FinishWrite ();
- failed = true;
- throw;
- } finally {
- if (failed)
- _NestedWrite = 0;
- }
- }
-
- internal void EndShutdown (LazyAsyncResult lazyResult)
- {
- if (Interlocked.Exchange (ref _NestedWrite, 0) == 0)
- throw new InvalidOperationException (SR.GetString (SR.net_io_invalidendcall, "EndShutdown"));
-
- // No "artificial" timeouts implemented so far, InnerStream controls timeout.
- lazyResult.InternalWaitForCompletion ();
-
- if (lazyResult.Result is Exception) {
- if (lazyResult.Result is IOException)
- throw (Exception)lazyResult.Result;
- throw new IOException (SR.GetString (SR.mono_net_io_shutdown), (Exception)lazyResult.Result);
- }
- }
-
- internal void BeginRenegotiate (LazyAsyncResult lazyResult)
- {
- HandshakeProtocolRequest asyncRequest = new HandshakeProtocolRequest (lazyResult);
-
- if (Interlocked.Exchange (ref _NestedWrite, 1) == 1)
- throw new NotSupportedException (SR.GetString (SR.net_io_invalidnestedcall, (asyncRequest != null ? "BeginRenegotiate" : "Renegotiate"), "renegotiate"));
-
- bool failed = false;
- try
- {
- if (_SslState.IsServer) {
- ProtocolToken message = _SslState.CreateHelloRequestMessage ();
- asyncRequest.SetNextRequest (HandshakeProtocolState.SendHelloRequest, message, _ResumeHandshakeWriteCallback);
- } else {
- asyncRequest.SetNextRequest (HandshakeProtocolState.ClientRenegotiation, null, _ResumeHandshakeWriteCallback);
- }
-
- StartHandshakeWrite (asyncRequest);
- } catch (Exception e) {
- _SslState.FinishWrite ();
- failed = true;
- throw;
- } finally {
- if (failed)
- _NestedWrite = 0;
- }
- }
-
- internal void EndRenegotiate (LazyAsyncResult lazyResult)
- {
- if (Interlocked.Exchange (ref _NestedWrite, 0) == 0)
- throw new InvalidOperationException (SR.GetString (SR.net_io_invalidendcall, "EndRenegotiate"));
-
- // No "artificial" timeouts implemented so far, InnerStream controls timeout.
- lazyResult.InternalWaitForCompletion();
-
- if (lazyResult.Result is Exception) {
- if (lazyResult.Result is IOException)
- throw (Exception)lazyResult.Result;
- throw new IOException (SR.GetString (SR.mono_net_io_renegotiate), (Exception)lazyResult.Result);
- }
- }
-
- void StartHandshakeWrite (HandshakeProtocolRequest asyncRequest)
- {
- byte[] buffer = null;
- if (asyncRequest.Message != null) {
- buffer = asyncRequest.Message.Payload;
- if (buffer.Length != asyncRequest.Message.Size) {
- buffer = new byte [asyncRequest.Message.Size];
- Buffer.BlockCopy (asyncRequest.Message.Payload, 0, buffer, 0, buffer.Length);
- }
- }
-
- switch (asyncRequest.State) {
- case HandshakeProtocolState.ClientRenegotiation:
- case HandshakeProtocolState.ServerRenegotiation:
- _SslState.StartReHandshake (asyncRequest);
- return;
-
- case HandshakeProtocolState.SendHelloRequest:
- if (_SslState.CheckEnqueueHandshakeWrite (buffer, asyncRequest)) {
- // operation is async and has been queued, return.
- return;
- }
- break;
-
- case HandshakeProtocolState.Shutdown:
- if (_SslState.CheckEnqueueWrite (asyncRequest)) {
- // operation is async and has been queued, return.
- return;
- }
- break;
-
- default:
- throw new InvalidOperationException ();
- }
-
- if (_SslState.LastPayload != null)
- throw new InvalidOperationException ();
-
- // prepare for the next request
- IAsyncResult ar = ((NetworkStream)_SslState.InnerStream).BeginWrite (buffer, 0, buffer.Length, _HandshakeWriteCallback, asyncRequest);
- if (!ar.CompletedSynchronously)
- return;
-
- HandshakeWriteCallback (asyncRequest, ar);
- }
-
- static void HandshakeWriteCallback (IAsyncResult transportResult)
- {
- if (transportResult.CompletedSynchronously)
- return;
-
- HandshakeProtocolRequest asyncRequest = (HandshakeProtocolRequest)transportResult.AsyncState;
-
- SslState sslState = (SslState)asyncRequest.AsyncObject;
- sslState.SecureStream.HandshakeWriteCallback (asyncRequest, transportResult);
- }
-
- void HandshakeWriteCallback (HandshakeProtocolRequest asyncRequest, IAsyncResult transportResult)
- {
- try {
- _SslState.InnerStream.EndWrite (transportResult);
- } catch (Exception e) {
- _SslState.FinishWrite ();
- if (!asyncRequest.IsUserCompleted) {
- asyncRequest.CompleteWithError (e);
- return;
- }
- throw;
- }
-
- if (asyncRequest.State == HandshakeProtocolState.SendHelloRequest) {
- asyncRequest.SetNextRequest (HandshakeProtocolState.ServerRenegotiation, null, _ResumeHandshakeWriteCallback);
- StartHandshakeWrite (asyncRequest);
- return;
- }
-
- try {
- _SslState.FinishWrite ();
- asyncRequest.CompleteUser ();
- } catch (Exception e) {
- if (!asyncRequest.IsUserCompleted) {
- asyncRequest.CompleteWithError (e);
- return;
- }
- throw;
- }
- }
-
- static void ResumeHandshakeWriteCallback (HandshakeProtocolRequest asyncRequest)
- {
- try {
- ((_SslStream)asyncRequest.AsyncObject).StartHandshakeWrite (asyncRequest);
- } catch (Exception e) {
- if (asyncRequest.IsUserCompleted) {
- // This will throw on a worker thread.
- throw;
- }
- ((_SslStream)asyncRequest.AsyncObject)._SslState.FinishWrite ();
- asyncRequest.CompleteWithError (e);
- }
- }
-
- delegate void HandshakeProtocolCallback (HandshakeProtocolRequest asyncRequest);
-
- enum HandshakeProtocolState {
- None,
- Shutdown,
- SendHelloRequest,
- ServerRenegotiation,
- ClientRenegotiation
- }
-
- class HandshakeProtocolRequest : AsyncProtocolRequest
- {
- public ProtocolToken Message;
- public HandshakeProtocolState State;
-
- public HandshakeProtocolRequest (LazyAsyncResult userAsyncResult)
- : base (userAsyncResult)
- {
- State = HandshakeProtocolState.None;
- }
-
- public void SetNextRequest (HandshakeProtocolState state, ProtocolToken message, HandshakeProtocolCallback callback)
- {
- State = state;
- Message = message;
- SetNextRequest (null, 0, 0, (r) => callback ((HandshakeProtocolRequest)r));
- }
- }
- }
-}
-#endif
<Compile Include="Mono.Net.Security\MonoTlsStream.cs" />\r
<Compile Include="Mono.Net.Security\NoReflectionHelper.cs" />\r
<Compile Include="Mono.Net.Security\SystemCertificateValidator.cs" />\r
- <Compile Include="ReferenceSources\_SecureChannel.cs" />\r
- <Compile Include="ReferenceSources\_SslState.cs" />\r
- <Compile Include="ReferenceSources\_SslStream.cs" />\r
<Compile Include="ReferenceSources\AssertWrapper.cs" />\r
<Compile Include="ReferenceSources\AutoWebProxyScriptEngine.cs" />\r
<Compile Include="ReferenceSources\BinaryCompatibility.cs" />\r
<Compile Include="ReferenceSources\EnvironmentHelpers.cs" />\r
<Compile Include="ReferenceSources\HttpApi.cs" />\r
<Compile Include="ReferenceSources\HttpSysSettings.cs" />\r
- <Compile Include="ReferenceSources\Internal.cs" />\r
<Compile Include="ReferenceSources\Logging.cs" />\r
<Compile Include="ReferenceSources\NativeMethods.cs" />\r
<Compile Include="ReferenceSources\RequestCacheProtocol.cs" />\r
<Compile Include="ReferenceSources\SR.cs" />\r
<Compile Include="ReferenceSources\SR2.cs" />\r
<Compile Include="ReferenceSources\SRCategoryAttribute.cs" />\r
- <Compile Include="ReferenceSources\SslStream.cs" />\r
- <Compile Include="ReferenceSources\SSPIConfiguration.cs" />\r
- <Compile Include="ReferenceSources\SSPISafeHandles.cs" />\r
- <Compile Include="ReferenceSources\SSPIWrapper.cs" />\r
<Compile Include="ReferenceSources\Win32Exception.cs" />\r
<Compile Include="System.CodeDom.Compiler\CodeCompiler.cs" />\r
<Compile Include="System.CodeDom.Compiler\CodeDomConfigurationHandler.cs" />\r
<Compile Include="Mono.Net.Security\MonoTlsStream.cs" />\r
<Compile Include="Mono.Net.Security\NoReflectionHelper.cs" />\r
<Compile Include="Mono.Net.Security\SystemCertificateValidator.cs" />\r
- <Compile Include="ReferenceSources\_SecureChannel.cs" />\r
- <Compile Include="ReferenceSources\_SslState.cs" />\r
- <Compile Include="ReferenceSources\_SslStream.cs" />\r
<Compile Include="ReferenceSources\AssertWrapper.cs" />\r
<Compile Include="ReferenceSources\AutoWebProxyScriptEngine.cs" />\r
<Compile Include="ReferenceSources\BinaryCompatibility.cs" />\r
<Compile Include="ReferenceSources\EnvironmentHelpers.cs" />\r
<Compile Include="ReferenceSources\HttpApi.cs" />\r
<Compile Include="ReferenceSources\HttpSysSettings.cs" />\r
- <Compile Include="ReferenceSources\Internal.cs" />\r
<Compile Include="ReferenceSources\Logging.cs" />\r
<Compile Include="ReferenceSources\NativeMethods.cs" />\r
<Compile Include="ReferenceSources\RequestCacheProtocol.cs" />\r
<Compile Include="ReferenceSources\SR.cs" />\r
<Compile Include="ReferenceSources\SR2.cs" />\r
<Compile Include="ReferenceSources\SRCategoryAttribute.cs" />\r
- <Compile Include="ReferenceSources\SslStream.cs" />\r
- <Compile Include="ReferenceSources\SSPIConfiguration.cs" />\r
- <Compile Include="ReferenceSources\SSPISafeHandles.cs" />\r
- <Compile Include="ReferenceSources\SSPIWrapper.cs" />\r
<Compile Include="ReferenceSources\Win32Exception.cs" />\r
<Compile Include="System.CodeDom.Compiler\CodeCompiler.cs" />\r
<Compile Include="System.CodeDom.Compiler\CodeDomConfigurationHandler.cs" />\r
+++ /dev/null
-//
-// ExcludeFromCodeCoverageAttribute.cs
-//
-// Authors:
-// Jb Evain <jbevain@novell.com>
-//
-// Copyright (C) 2010 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-
-
-namespace System.Diagnostics.CodeAnalysis {
-
- [AttributeUsage (AttributeTargets.Class
- | AttributeTargets.Struct
- | AttributeTargets.Constructor
- | AttributeTargets.Method
- | AttributeTargets.Property
- | AttributeTargets.Event,
- AllowMultiple = false,
- Inherited = false)]
- public sealed class ExcludeFromCodeCoverageAttribute : Attribute
- {
- public ExcludeFromCodeCoverageAttribute ()
- {
- }
- }
-}
-
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
//
-// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
private IntPtr _readHandle;
private Thread _notifyThread;
private int _lastEntryWritten;
- private bool _notifying;
+ private Object _eventLock = new object();
public Win32EventLog (EventLog coreEventLog)
: base (coreEventLog)
public override void Close ()
{
- if (_readHandle != IntPtr.Zero) {
- CloseEventLog (_readHandle);
- _readHandle = IntPtr.Zero;
+ lock (_eventLock) {
+ if (_readHandle != IntPtr.Zero) {
+ CloseEventLog (_readHandle);
+ _readHandle = IntPtr.Zero;
+ }
}
}
public override void DisableNotification ()
{
- if (_notifyResetEvent != null) {
- _notifyResetEvent.Close ();
- _notifyResetEvent = null;
- }
-
- if (_notifyThread != null) {
- if (_notifyThread.ThreadState == System.Threading.ThreadState.Running)
- _notifyThread.Abort ();
+ lock (_eventLock) {
+ if (_notifyResetEvent != null) {
+ _notifyResetEvent.Close ();
+ _notifyResetEvent = null;
+ }
_notifyThread = null;
}
}
public override void EnableNotification ()
{
- _notifyResetEvent = new ManualResetEvent (false);
- _lastEntryWritten = OldestEventLogEntry + EntryCount;
- if (PInvoke.NotifyChangeEventLog (ReadHandle, _notifyResetEvent.Handle) == 0)
- throw new InvalidOperationException (string.Format (
- CultureInfo.InvariantCulture, "Unable to receive notifications"
- + " for log '{0}' on computer '{1}'.", CoreEventLog.GetLogName (),
- CoreEventLog.MachineName), new Win32Exception ());
- _notifyThread = new Thread (new ThreadStart (NotifyEventThread));
- _notifyThread.IsBackground = true;
- _notifyThread.Start ();
+ lock (_eventLock) {
+ if (_notifyResetEvent != null)
+ return;
+
+ _notifyResetEvent = new ManualResetEvent (false);
+ _lastEntryWritten = OldestEventLogEntry + EntryCount;
+ if (PInvoke.NotifyChangeEventLog (ReadHandle, _notifyResetEvent.Handle) == 0)
+ throw new InvalidOperationException (string.Format (
+ CultureInfo.InvariantCulture, "Unable to receive notifications"
+ + " for log '{0}' on computer '{1}'.", CoreEventLog.GetLogName (),
+ CoreEventLog.MachineName), new Win32Exception ());
+ _notifyThread = new Thread (() => NotifyEventThread(_notifyResetEvent));
+ _notifyThread.IsBackground = true;
+ _notifyThread.Start ();
+ }
}
- private void NotifyEventThread ()
+ private void NotifyEventThread (ManualResetEvent resetEvent)
{
while (true) {
- _notifyResetEvent.WaitOne ();
- lock (this) {
- // after a clear, we something get notified
- // twice for the same entry
- if (_notifying)
- return;
- _notifying = true;
+ try {
+ resetEvent.WaitOne ();
+ } catch (ObjectDisposedException e) {
+ // Notifications have been disabled and event
+ // has been closed but not yet nulled. End thread.
+ break;
}
- try {
+ lock (_eventLock) {
+ if (resetEvent != _notifyResetEvent) {
+ // A new thread has started with another reset event instance
+ // or DisableNotifications has been called, setting
+ // _notifyResetEvent to null. In both cases end this thread.
+ break;
+ }
+
+ if (_readHandle == IntPtr.Zero)
+ break;
+
int oldest_entry = OldestEventLogEntry;
if (_lastEntryWritten < oldest_entry)
_lastEntryWritten = oldest_entry;
CoreEventLog.OnEntryWritten (entry);
}
_lastEntryWritten = last_entry;
- } finally {
- lock (this)
- _notifying = false;
}
}
}
* effects on Linux, as the socket option is kludged by
* turning on or off PMTU discovery... */
this.DontFragment = false;
- this.NoDelay = false;
+ if (protocol_type == ProtocolType.Tcp)
+ this.NoDelay = false;
} else if (address_family == AddressFamily.InterNetworkV6) {
this.DualMode = true;
}
set {
ThrowIfDisposedAndClosed ();
ThrowIfUdp ();
-
SetSocketOption (SocketOptionLevel.Tcp, SocketOptionName.NoDelay, value ? 1 : 0);
}
}
StreamWriter writer = new StreamWriter (ms, encoding, 256);
writer.Write ("HTTP/{0} {1} {2}\r\n", version, status_code, status_description);
- string headers_str = headers.ToString ();
+ string headers_str = FormatHeaders (headers);
writer.Write (headers_str);
writer.Flush ();
- int preamble = (encoding.CodePage == 65001) ? 3 : encoding.GetPreamble ().Length;
+ int preamble = encoding.GetPreamble ().Length;
if (output_stream == null)
output_stream = context.Connection.GetResponseStream ();
HeadersSent = true;
}
+ static string FormatHeaders (WebHeaderCollection headers)
+ {
+ var sb = new StringBuilder();
+
+ for (int i = 0; i < headers.Count ; i++) {
+ string key = headers.GetKey (i);
+ if (WebHeaderCollection.AllowMultiValues (key)) {
+ foreach (string v in headers.GetValues (i)) {
+ sb.Append (key).Append (": ").Append (v).Append ("\r\n");
+ }
+ } else {
+ sb.Append (key).Append (": ").Append (headers.Get (i)).Append ("\r\n");
+ }
+ }
+
+ return sb.Append("\r\n").ToString();
+ }
+
static string CookieToClientString (Cookie cookie)
{
if (cookie.Name.Length == 0)
// Fields
public const int DefaultNonPersistentConnectionLimit = 4;
-#if MONOTOUCH
+#if MOBILE
public const int DefaultPersistentConnectionLimit = 10;
#else
public const int DefaultPersistentConnectionLimit = 2;
var value = s.Substring (pos_s + 1).Trim ();
var h = data.Headers;
- if (h.AllowMultiValues (header)) {
+ if (WebHeaderCollection.AllowMultiValues (header)) {
h.AddInternal (header, value);
} else {
h.SetInternal (header, value);
System.Diagnostics/TraceImpl.cs
System.Diagnostics/TraceSourceInfo.cs
System.Diagnostics/Win32EventLog.cs
-System.Diagnostics.CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs
System/Platform.cs
+System/MonoExeLocator.cs
System.IO.Compression/CompressionLevel.cs
System.IO.Compression/CompressionMode.cs
System.IO.Compression/DeflateStream.cs
ReferenceSources/ConfigurationManagerInternalFactory.cs
ReferenceSources/CAPI.cs
ReferenceSources/EnvironmentHelpers.cs
-ReferenceSources/Internal.cs
ReferenceSources/HttpApi.cs
ReferenceSources/HttpSysSettings.cs
ReferenceSources/LocalAppContextSwitches.cs
ReferenceSources/SRCategoryAttribute.cs
ReferenceSources/Win32Exception.cs
-ReferenceSources/SSPIConfiguration.cs
-ReferenceSources/SSPISafeHandles.cs
-ReferenceSources/SSPIWrapper.cs
-ReferenceSources/SslStream.cs
-ReferenceSources/_SecureChannel.cs
-ReferenceSources/_SslState.cs
-ReferenceSources/_SslStream.cs
-
../referencesource/System/misc/PrivilegedConfigurationManager.cs
../referencesource/System/regex/system/text/regularexpressions/Regex.cs
../referencesource/System/regex/system/text/regularexpressions/RegexBoyerMoore.cs
../referencesource/System/sys/system/IO/ports/InternalResources.cs
+../referencesource/System/sys/system/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs
+
../referencesource/System/sys/system/runtime/interopservices/DefaultParameterValueAttribute.cs
../referencesource/System/sys/system/runtime/interopservices/handlecollector.cs
--- /dev/null
+#if !MOBILE
+
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System {
+
+ static class MonoToolsLocator
+ {
+ public static readonly string Mono;
+ public static readonly string CSharpCompiler;
+ public static readonly string VBCompiler;
+ public static readonly string AssemblyLinker;
+
+ // TODO: Should be lazy
+ static MonoToolsLocator ()
+ {
+ var gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static | BindingFlags.NonPublic);
+ var getGacMethod = gac.GetGetMethod (true);
+ var GacPath = Path.GetDirectoryName ((string) getGacMethod.Invoke (null, null));
+
+ if (Path.DirectorySeparatorChar == '\\') {
+ string processExe = Process.GetCurrentProcess ().MainModule.FileName;
+ if (processExe != null) {
+ string fileName = Path.GetFileName (processExe);
+ if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
+ Mono = processExe;
+ }
+
+ if (!File.Exists (Mono))
+ Mono = Path.Combine (
+ Path.GetDirectoryName (
+ Path.GetDirectoryName (GacPath)),
+ "bin\\mono.exe");
+
+ if (!File.Exists (Mono))
+ Mono = Path.Combine (
+ Path.GetDirectoryName (
+ Path.GetDirectoryName (
+ Path.GetDirectoryName (GacPath))),
+ "mono\\mini\\mono.exe");
+
+ //if (!File.Exists (Mono))
+ // throw new FileNotFoundException ("Windows mono path not found: " + Mono);
+
+ CSharpCompiler = Path.Combine (GacPath, "4.5\\mcs.exe");
+ if (!File.Exists (CSharpCompiler))
+ CSharpCompiler = Path.Combine (Path.GetDirectoryName (GacPath), "lib\\build\\mcs.exe");
+
+ //if (!File.Exists (CSharpCompiler))
+ // throw new FileNotFoundException ("C# compiler not found at " + CSharpCompiler);
+
+ VBCompiler = Path.Combine (GacPath, "4.5\\vbnc.exe");
+ AssemblyLinker = Path.Combine (GacPath, "4.5\\al.exe");
+
+ if (!File.Exists (AssemblyLinker)) {
+ AssemblyLinker = Path.Combine (Path.GetDirectoryName (GacPath), "lib\\net_4_x\\al.exe");
+ // if (!File.Exists (AssemblyLinker))
+ // throw new FileNotFoundException ("Windows al path not found: " + AssemblyLinker);
+ }
+ } else {
+ Mono = Path.Combine (GacPath, "bin", "mono");
+ if (!File.Exists (Mono))
+ Mono = "mono";
+
+ var mscorlibPath = new Uri (typeof (object).Assembly.CodeBase).LocalPath;
+ CSharpCompiler = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "mcs"));
+ if (!File.Exists (CSharpCompiler))
+ CSharpCompiler = "mcs";
+
+ VBCompiler = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "vbnc"));
+ if (!File.Exists (VBCompiler))
+ VBCompiler = "vbnc";
+
+ AssemblyLinker = Path.GetFullPath (Path.Combine (mscorlibPath, "..", "..", "..", "..", "bin", "al"));
+ if (!File.Exists (AssemblyLinker))
+ AssemblyLinker = "al";
+ }
+ }
+ }
+}
+
+#endif
Assert.AreEqual (0, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("Clear3", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (0, entry.EventID, "#E8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#E9");
Assert.IsNotNull (entry.MachineName, "#E10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#E11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#E11");
Assert.IsNotNull (entry.ReplacementStrings, "#E12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#E13");
Assert.AreEqual ("Clear4", entry.ReplacementStrings [0], "#E14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1a", entry.ReplacementStrings[0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry1b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1", entry.ReplacementStrings[0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry2a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry2b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry3a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry3b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (0, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (0, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("test", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (56, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry2", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (ushort.MaxValue, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("WriteEntry2", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (888, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (343, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (2, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry3a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry3b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (0, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (0, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (0, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("test", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (56, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry6a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry6b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (ushort.MaxValue, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("WriteEntry6c", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (888, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (343, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (2, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (54, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry7a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry7b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (ushort.MaxValue, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("WriteEntry7c" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (56, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (76, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (89, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("test", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (56, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry8a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry8b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (ushort.MaxValue, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("WriteEntry8c", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (888, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (343, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (2, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (54, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry9a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry9b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (ushort.MaxValue, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("WriteEntry9c" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (56, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (76, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (89, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("test", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (54, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("WriteEntry9a", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (0, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#C13");
Assert.AreEqual ("WriteEntry9b" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#C14");
Assert.AreEqual (ushort.MaxValue, entry.EventID, "#D8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#D9");
Assert.IsNotNull (entry.MachineName, "#D10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#D11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#D11");
Assert.IsNotNull (entry.ReplacementStrings, "#D12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#D13");
Assert.AreEqual ("WriteEntry9c" + Environment.NewLine + "ok", entry.ReplacementStrings [0], "#D14");
Assert.AreEqual (56, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (76, entry.EventID, "#A8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#A9");
Assert.IsNotNull (entry.MachineName, "#A10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#A11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#A11");
Assert.IsNotNull (entry.ReplacementStrings, "#A12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#A13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#A14");
Assert.AreEqual (89, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("test", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (4, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("5", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (0, entry.ReplacementStrings.Length, "#C13");
Assert.IsNotNull (entry.Source, "#C14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (2, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("replace1", entry.ReplacementStrings[0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (4, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("5", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (0, entry.ReplacementStrings.Length, "#C13");
Assert.IsNotNull (entry.Source, "#C14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (3, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (2, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.IsNotNull (entry.Source, "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (4, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("5", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (0, entry.ReplacementStrings.Length, "#C13");
Assert.IsNotNull (entry.Source, "#C14");
Assert.AreEqual (666, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (2, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (4, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("5", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#C8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#C9");
Assert.IsNotNull (entry.MachineName, "#C10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#C11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#C11");
Assert.IsNotNull (entry.ReplacementStrings, "#C12");
Assert.AreEqual (0, entry.ReplacementStrings.Length, "#C13");
Assert.IsNotNull (entry.Source, "#C14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (3, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (666, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (2, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual ("replace1", entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (5, entry.EventID, "#B8");
Assert.AreEqual (entry.EventID, entry.InstanceId, "#B9");
Assert.IsNotNull (entry.MachineName, "#B10");
- Assert.AreEqual (Environment.MachineName, entry.MachineName, "#B11");
+ Assert.AreEqual (Environment.MachineName.ToUpper(), entry.MachineName.ToUpper(), "#B11");
Assert.IsNotNull (entry.ReplacementStrings, "#B12");
Assert.AreEqual (1, entry.ReplacementStrings.Length, "#B13");
Assert.AreEqual (string.Empty, entry.ReplacementStrings [0], "#B14");
Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
Assert.IsNull (ex.InnerException, "#4");
Assert.IsNotNull (ex.Message, "#5");
- Assert.AreEqual (2, ex.NativeErrorCode, "#6");
+ // TODO: On windows we get ACCESS_DENIED (5) instead of FILE_NOT_FOUND (2) and .NET
+ // gives ERROR_INVALID_PARAMETER (87). See https://bugzilla.xamarin.com/show_bug.cgi?id=44514
+ Assert.IsTrue (ex.NativeErrorCode == 2 || ex.NativeErrorCode == 5 || ex.NativeErrorCode == 87, "#6");
}
}
Assert.AreEqual (-2147467259, ex.ErrorCode, "#3");
Assert.IsNull (ex.InnerException, "#4");
Assert.IsNotNull (ex.Message, "#5");
- Assert.AreEqual (2, ex.NativeErrorCode, "#6");
+ // TODO: On windows we get ACCESS_DENIED (5) instead of FILE_NOT_FOUND (2) and .NET
+ // gives ERROR_INVALID_PARAMETER (87). See https://bugzilla.xamarin.com/show_bug.cgi?id=44514
+ Assert.IsTrue (ex.NativeErrorCode == 2 || ex.NativeErrorCode == 5 || ex.NativeErrorCode == 87, "#6");
}
}
path = "/bin/cat";
#endif
return new ProcessStartInfo (path);
- } else
- return new ProcessStartInfo ("type");
+ } else {
+ var psi = new ProcessStartInfo ("findstr");
+ psi.Arguments = "\"^\"";
+ return psi;
+ }
}
#endif // MONO_FEATURE_PROCESS_START
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("Could not found: {0} {1}\n", name.Name, name.Version);
- sb.AppendLine ("Looked in assemblies:");
+ sb.AppendLine ("Looked in modules:");
foreach (var o in modules) {
var m = (ProcessModule) o;
[Test]\r
public void AsyncGetHostByName ()\r
{\r
- IAsyncResult r;\r
- r = Dns.BeginGetHostByName (site1Name, new AsyncCallback (GetHostByNameCallback), null);\r
-\r
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);\r
IPHostEntry entry = Dns.EndGetHostByName (async);\r
SubTestValidIPHostEntry (entry);\r
Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");\r
}\r
\r
- void GetHostByNameCallback (IAsyncResult ar)\r
- {\r
- IPHostEntry h;\r
- h = Dns.EndGetHostByName (ar);\r
- SubTestValidIPHostEntry (h);\r
+ [Test]\r
+ public void AsyncGetHostByNameCallback ()\r
+ {\r
+ var evt = new ManualResetEvent (false);\r
+ Exception ex = null;\r
+ Dns.BeginGetHostByName (site1Name, new AsyncCallback ((IAsyncResult ar) =>\r
+ {\r
+ try {\r
+ IPHostEntry h;\r
+ h = Dns.EndGetHostByName (ar);\r
+ SubTestValidIPHostEntry (h);\r
+ } catch (Exception e) {\r
+ ex = e;\r
+ } finally {\r
+ evt.Set ();\r
+ }\r
+ }), null);\r
+\r
+ Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");\r
+ Assert.IsNull (ex, "Exception");\r
}\r
\r
[Test]\r
public void AsyncResolve ()\r
{\r
- IAsyncResult r;\r
- r = Dns.BeginResolve (site1Name, new AsyncCallback (ResolveCallback), null);\r
-\r
IAsyncResult async = Dns.BeginResolve (site1Dot, null, null);\r
IPHostEntry entry = Dns.EndResolve (async);\r
SubTestValidIPHostEntry (entry);\r
Assert.AreEqual (site1Dot, ip.ToString ());\r
}\r
\r
- void ResolveCallback (IAsyncResult ar)\r
- {\r
- IPHostEntry h = Dns.EndResolve (ar);\r
- SubTestValidIPHostEntry (h);\r
+ [Test]\r
+ public void AsyncResolveCallback ()\r
+ {\r
+ var evt = new ManualResetEvent (false);\r
+ Exception ex = null;\r
+ Dns.BeginResolve (site1Name, new AsyncCallback ((IAsyncResult ar) =>\r
+ {\r
+ try {\r
+ IPHostEntry h = Dns.EndResolve (ar);\r
+ SubTestValidIPHostEntry (h);\r
+ } catch (Exception e) {\r
+ ex = e;\r
+ } finally {\r
+ evt.Set ();\r
+ }\r
+ }), null);\r
+\r
+ Assert.IsTrue (evt.WaitOne (TimeSpan.FromSeconds (60)), "Wait");\r
+ Assert.IsNull (ex, "Exception");\r
}\r
\r
[Test]\r
try {\r
Dns.BeginGetHostAddresses (\r
(string) null,\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
try {\r
Dns.BeginGetHostAddresses (\r
"0.0.0.0",\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#A1");\r
} catch (ArgumentException ex) {\r
try {\r
Dns.BeginGetHostAddresses (\r
"::0",\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#B1");\r
} catch (ArgumentException ex) {\r
}\r
}\r
\r
- void GetHostAddressesCallback (IAsyncResult ar)\r
+ void ShouldntBeCalled (IAsyncResult ar)\r
{\r
- IPAddress [] addresses = Dns.EndGetHostAddresses (ar);\r
- Assert.IsNotNull (addresses);\r
+ Assert.Fail ("Should not be called");\r
}\r
\r
[Test]\r
{\r
try {\r
Dns.BeginResolve ((string) null,\r
- new AsyncCallback (ResolveCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
try {\r
Dns.BeginGetHostEntry (\r
(IPAddress) null,\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
try {\r
Dns.BeginGetHostEntry (\r
(string) null,\r
- new AsyncCallback (GetHostAddressesCallback),\r
+ new AsyncCallback (ShouldntBeCalled),\r
null);\r
Assert.Fail ("#1");\r
} catch (ArgumentNullException ex) {\r
return clientEndPoint;
}
+
+ [Test]
+ public void UserHeaderWithDoubleMultiValue ()
+ {
+ string uri = "http://localhost:" + NetworkHelpers.FindFreePort () + "/";
+
+ var l = new HttpListener ();
+ l.Prefixes.Add (uri);
+ l.Start ();
+ l.BeginGetContext (ar => {
+ var ctx = l.EndGetContext (ar);
+
+ var response = ctx.Response;
+ response.Headers.Add ("X-Custom-Header", "A");
+ response.Headers.Add ("X-Custom-Header", "B");
+
+ response.Close ();
+ }, null);
+
+ HttpWebRequest wr = HttpWebRequest.CreateHttp (uri);
+ var resp = wr.GetResponse ();
+ var vls = resp.Headers.GetValues ("X-Custom-Header");
+
+ Assert.AreEqual (2, vls.Length);
+
+ l.Close ();
+ }
[Test]
public void HttpClientIsDisconnectedCheckForWriteException()
[Category ("NotDotNet")]
public void UnixAbsoluteFilePath_WithSpecialChars1 ()
{
+ if (isWin32)
+ Assert.Ignore ();
+
Uri unixuri = new Uri ("/home/user/a@b");
Assert.AreEqual ("file", unixuri.Scheme, "UnixAbsoluteFilePath_WithSpecialChars #1");
}
[Category ("NotDotNet")]
public void UnixAbsoluteFilePath_WithSpecialChars2 ()
{
+ if (isWin32)
+ Assert.Ignore ();
+
Uri unixuri = new Uri ("/home/user/a:b");
Assert.AreEqual ("file", unixuri.Scheme, "UnixAbsoluteFilePath_WithSpecialChars #2");
}
[Category ("NotDotNet")]
public void UnixAbsolutePath_ReplaceRelative ()
{
+ if (isWin32)
+ Assert.Ignore ();
+
var u1 = new Uri ("/Users/demo/Projects/file.xml");
var u2 = new Uri (u1, "b.jpg");
[Test]
public void DotNetRelativeOrAbsoluteTest ()
{
+ // On windows the path /foo is parsed as BadFormat and checking
+ // if this is relative or absolute doesn't make sense.
+ if (isWin32)
+ Assert.Ignore();
+
FieldInfo useDotNetRelativeOrAbsoluteField = null;
bool useDotNetRelativeOrAbsoluteOld = false;
[Test]
public void ImplicitUnixFileWithUnicode ()
{
+ if (isWin32)
+ Assert.Ignore ();
+
string value = "/Library/Frameworks/System.Runtim…ee";
Uri uri;
Assert.IsTrue (Uri.TryCreate (value, UriKind.Absolute, out uri));
ReferenceSources/CAPI.cs
ReferenceSources/EnvironmentHelpers.cs
ReferenceSources/HttpApi.cs
-ReferenceSources/Internal.cs
ReferenceSources/LocalAppContextSwitches.cs
ReferenceSources/HttpSysSettings.cs
ReferenceSources/Logging.cs
../referencesource/System/net/System/Net/NetworkInformation/nodetype.cs
../referencesource/System/net/System/Net/NetworkInformation/pingexception.cs
+../referencesource/System/sys/system/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs
+
../referencesource/System/sys/system/IO/ports/InternalResources.cs
../referencesource/System/sys/system/runtime/interopservices/DefaultParameterValueAttribute.cs
../referencesource/System/sys/system/threading/Barrier.cs
../referencesource/System/sys/system/threading/semaphore.cs
+../referencesource/System/sys/system/windows/markup/ValueSerializerAttribute.cs
+
../referencesource/System/security/system/security/Authentication/ExtendedProtection/TokenBinding.cs
../referencesource/System/security/system/security/cryptography/oid.cs
[assembly: InternalsVisibleTo ("Xamarin.Mac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
#endif
-[assembly: InternalsVisibleTo ("Xamarin.BoringTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000099dd12eda85767ae6f06023ee28e711c7e5a212462095c83868c29db75eddf6d8e296e03824c14fedd5f55553fed0b6173be3cc985a4b7f9fb7c83ccff8ba3938563b3d1f45a81122f12a1bcb73edcaad61a8456c7595a6da5184b4dd9d10f011b949ef1391fccfeab1ba62aa51c267ef8bd57ef1b6ba5a4c515d0badb81a78f")]
[assembly: Guid ("BED7F4EA-1A96-11D2-8F08-00A0C9A6186D")]
--- /dev/null
+namespace System.Runtime.Versioning
+{
+ static class BinaryCompatibility
+ {
+ public static readonly bool TargetsAtLeast_Desktop_V4_5 = true;
+ public static readonly bool TargetsAtLeast_Desktop_V4_5_1 = true;
+ }
+}
\ No newline at end of file
{
static class CompatibilitySwitches
{
- public const bool IsAppEarlierThanSilverlight4 = false;
- public const bool IsAppEarlierThanWindowsPhone8 = false;
+ public static readonly bool IsAppEarlierThanSilverlight4 = false;
+ public static readonly bool IsAppEarlierThanWindowsPhone8 = false;
}
}
\ No newline at end of file
internal Object CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fillCache, ref StackCrawlMark stackMark)
{
- bool bNeedSecurityCheck = true;
- bool bCanBeCached = false;
- bool bSecurityCheckOff = false;
+ //bool bNeedSecurityCheck = true;
+ //bool bCanBeCached = false;
+ //bool bSecurityCheckOff = false;
if (!skipCheckThis)
CreateInstanceCheckThis();
- if (!fillCache)
- bSecurityCheckOff = true;
+ //if (!fillCache)
+ // bSecurityCheckOff = true;
return CreateInstanceMono (!publicOnly);
}
WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
}
+ [CLSCompliant (false)]
protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
{
}
{
}
+ [CLSCompliant (false)]
protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
{
}
private StackFrame[] frames;
readonly StackTrace[] captured_traces;
+#pragma warning disable 414
private bool debug_info;
-
- private static Dictionary<string, Func<StackTrace, string>> metadataHandlers;
+#pragma warning restore
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public StackTrace ()
bool AddFrames (StringBuilder sb)
{
- bool printOffset;
string debugInfo, indentation;
string unknown = Locale.GetText ("<unknown method>");
else {
string ret = String.Join (DirectorySeparatorStr, dirs, 0, target);
if (Environment.IsRunningOnWindows) {
+#if !MOBILE
// append leading '\' of the UNC path that was lost in STEP 3.
if (isUnc)
ret = Path.DirectorySeparatorStr + ret;
else
return current + ret;
}
+#endif
} else {
if (root != "" && ret.Length > 0 && ret [0] != '/')
ret = root + ret;
throw new ArgumentException (Locale.GetText ("Path is empty"));
if (path.IndexOfAny (Path.InvalidPathChars) != -1)
throw new ArgumentException (Locale.GetText ("Path contains invalid chars"));
+#if !MOBILE
if (Environment.IsRunningOnWindows) {
int idx = path.IndexOf (':');
if (idx >= 0 && idx != 1)
throw new ArgumentException (parameterName);
}
+#endif
}
internal static string DirectorySeparatorCharAsString {
return new AssemblyBuilder (name, null, access, false);
}
+ public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
+ {
+ throw new NotImplementedException ();
+ }
+
public ModuleBuilder DefineDynamicModule (string name)
{
return DefineDynamicModule (name, name, false, true);
--- /dev/null
+//
+// AssemblyBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public class AssemblyBuilder : Assembly
+ {
+ public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, System.Collections.Generic.IEnumerable<CustomAttributeBuilder> assemblyAttributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ModuleBuilder DefineDynamicModule (string name)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ModuleBuilder GetDynamicModule (string name)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ }
+}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !FULL_AOT_RUNTIME || IOS_REFLECTION
using System.Runtime.InteropServices;
namespace System.Reflection.Emit
RunAndCollect = 9
}
}
-#endif
--- /dev/null
+//
+// ConstructorBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class ConstructorBuilder : ConstructorInfo
+ {
+ public bool InitLocals { get; set; }
+
+ public override MethodAttributes Attributes {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type DeclaringType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public ParameterBuilder DefineParameter (int iSequence, ParameterAttributes attributes, string strParamName)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ILGenerator GetILGenerator ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ILGenerator GetILGenerator (int streamSize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override ParameterInfo[] GetParameters ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetImplementationFlags (MethodImplAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// CustomAttributeBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public class CustomAttributeBuilder
+ {
+ public CustomAttributeBuilder (ConstructorInfo con, object[] constructorArgs)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public CustomAttributeBuilder (ConstructorInfo con, object[] constructorArgs, FieldInfo[] namedFields, object[] fieldValues)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public CustomAttributeBuilder (ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public CustomAttributeBuilder (ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
return res;
}
+ public TypeInfo CreateTypeInfo()
+ {
+ return _tb.CreateTypeInfo ();
+ }
+
public override Type GetEnumUnderlyingType ()
{
return _underlyingType;
--- /dev/null
+//
+// EnumBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class EnumBuilder : TypeInfo
+ {
+ public FieldBuilder UnderlyingField {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Assembly Assembly {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string AssemblyQualifiedName {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type BaseType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string FullName {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Guid GUID {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Module Module {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Namespace {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public TypeInfo CreateTypeInfo ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineLiteral (string literalName, object literalValue)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override System.Type GetElementType ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// EventBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public class EventBuilder
+ {
+ public void AddOtherMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetAddOnMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetRaiseMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetRemoveOnMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// FieldBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class FieldBuilder : FieldInfo
+ {
+ public override FieldAttributes Attributes {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type DeclaringType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type FieldType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override object GetValue (object obj)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetConstant (object defaultValue)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetOffset (int iOffset)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// GenericTypeParameterBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class GenericTypeParameterBuilder : TypeInfo
+ {
+ public override Assembly Assembly {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string AssemblyQualifiedName {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type BaseType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string FullName {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Guid GUID {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Module Module {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Namespace {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type GetElementType ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetBaseTypeConstraint (Type baseTypeConstraint)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetGenericParameterAttributes (GenericParameterAttributes genericParameterAttributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetInterfaceConstraints (Type[] interfaceConstraints)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// ILGenerator.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public class ILGenerator
+ {
+ ILGenerator ()
+ {
+ }
+
+ public int ILOffset {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public virtual void BeginCatchBlock (Type exceptionType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void BeginExceptFilterBlock ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual Label BeginExceptionBlock ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void BeginFaultBlock ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void BeginFinallyBlock ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void BeginScope ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual LocalBuilder DeclareLocal (Type localType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual LocalBuilder DeclareLocal (Type localType, bool pinned)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual Label DefineLabel ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, byte arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, double arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, short arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, int arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, long arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, ConstructorInfo con)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, Label label)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, Label[] labels)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, LocalBuilder local)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, SignatureHelper signature)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, FieldInfo field)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, MethodInfo meth)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ [CLSCompliant (false)]
+ public void Emit (OpCode opcode, sbyte arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, float arg)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, string str)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void Emit (OpCode opcode, Type cls)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EmitCall (OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EmitCalli (OpCode opcode, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EmitWriteLine (LocalBuilder localBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EmitWriteLine (FieldInfo fld)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EmitWriteLine (string value)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EndExceptionBlock ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void EndScope ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void MarkLabel (Label loc)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void ThrowException (Type excType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public virtual void UsingNamespace (string usingNamespace)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ }
+}
+
+#endif
\ No newline at end of file
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if !FULL_AOT_RUNTIME || IOS_REFLECTION
using System.Runtime.InteropServices;
namespace System.Reflection.Emit {
}
}
}
-#endif
// (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
//
-#if !FULL_AOT_RUNTIME
using System;
using System.Reflection;
-using System.Reflection.Emit;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Reflection.Emit {
[ComVisible (true)]
+#if !FULL_AOT_RUNTIME
[ComDefaultInterface (typeof (_LocalBuilder))]
+#endif
[ClassInterface (ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
- public sealed class LocalBuilder : LocalVariableInfo, _LocalBuilder {
+ public sealed class LocalBuilder : LocalVariableInfo
+#if !FULL_AOT_RUNTIME
+ , _LocalBuilder
+#endif
+ {
// Some fields are already defined in LocalVariableInfo
#region Sync with reflection.h
internal int EndOffset {
get { return endOffset; }
}
-
+#if !FULL_AOT_RUNTIME
void _LocalBuilder.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
{
throw new NotImplementedException ();
}
+#endif
}
}
-#endif
--- /dev/null
+//
+// MethodBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class MethodBuilder : MethodInfo
+ {
+ public bool InitLocals { get; set; }
+
+ public override MethodAttributes Attributes {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type DeclaringType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public GenericTypeParameterBuilder[] DefineGenericParameters (string[] names)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ParameterBuilder DefineParameter (int position, ParameterAttributes attributes, string strParamName)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ILGenerator GetILGenerator ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ILGenerator GetILGenerator (int size)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override System.Reflection.ParameterInfo[] GetParameters ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetImplementationFlags (MethodImplAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetParameters (Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetReturnType (Type returnType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetSignature (Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// ModuleBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class ModuleBuilder : Module
+ {
+ public void CreateGlobalFunctions ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public EnumBuilder DefineEnum (string name, TypeAttributes visibility, Type underlyingType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineInitializedData (string name, byte[] data, FieldAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, int typesize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packsize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineUninitializedData (string name, int size, FieldAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodInfo GetArrayMethod (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// ParameterBuilder.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public class ParameterBuilder
+ {
+ ParameterBuilder ()
+ {
+ }
+
+ public int Attributes {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public bool IsIn {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public bool IsOptional {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public bool IsOut {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public int Position {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public virtual void SetConstant (object defaultValue)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// PropertyBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class PropertyBuilder : PropertyInfo
+ {
+ public override PropertyAttributes Attributes {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override bool CanRead {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override bool CanWrite {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type DeclaringType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type PropertyType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public void AddOtherMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetConstant (object defaultValue)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetGetMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetSetMethod (MethodBuilder mdBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override ParameterInfo[] GetIndexParameters ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// SignatureHelper.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public class SignatureHelper
+ {
+ SignatureHelper ()
+ {
+ }
+
+ public void AddArgument (Type clsArgument)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void AddArgument (Type argument, bool pinned)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void AddArgument (Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void AddArguments (Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void AddSentinel ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetFieldSigHelper (Module mod)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetLocalVarSigHelper ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetLocalVarSigHelper (Module mod)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetMethodSigHelper (CallingConventions callingConvention, Type returnType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetMethodSigHelper (Module mod, CallingConventions callingConvention, Type returnType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetMethodSigHelper (Module mod, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetPropertySigHelper (Module mod, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetPropertySigHelper (Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static SignatureHelper GetPropertySigHelper (Module mod, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public byte[] GetSignature ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+//
+// TypeBuilder.pns.cs
+//
+// Authors:
+// Marek Safar (marek.safar@gmail.com)
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if FULL_AOT_RUNTIME
+
+namespace System.Reflection.Emit
+{
+ public abstract class TypeBuilder : TypeInfo
+ {
+ public const int UnspecifiedTypeSize = 0;
+
+ public PackingSize PackingSize {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public int Size {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Assembly Assembly {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string AssemblyQualifiedName {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Type BaseType {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string FullName {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Guid GUID {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override Module Module {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Name {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public override string Namespace {
+ get {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+
+ public void AddInterfaceImplementation (Type interfaceType)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeInfo CreateTypeInfo ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ConstructorBuilder DefineConstructor (MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ConstructorBuilder DefineConstructor (MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ConstructorBuilder DefineDefaultConstructor (MethodAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public EventBuilder DefineEvent (string name, EventAttributes attributes, Type eventtype)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineField (string fieldName, Type type, FieldAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineField (string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public GenericTypeParameterBuilder[] DefineGenericParameters (string[] names)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineInitializedData (string name, byte[] data, FieldAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineMethod (string name, MethodAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineMethod (string name, MethodAttributes attributes, CallingConventions callingConvention)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineMethod (string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public MethodBuilder DefineMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void DefineMethodOverride (MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, int typeSize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, PackingSize packSize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, Type[] interfaces)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, PackingSize packSize, int typeSize)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public PropertyBuilder DefineProperty (string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public PropertyBuilder DefineProperty (string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public PropertyBuilder DefineProperty (string name, PropertyAttributes attributes, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public PropertyBuilder DefineProperty (string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public ConstructorBuilder DefineTypeInitializer ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public FieldBuilder DefineUninitializedData (string name, int size, FieldAttributes attributes)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static ConstructorInfo GetConstructor (Type type, ConstructorInfo constructor)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static FieldInfo GetField (Type type, FieldInfo field)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public static MethodInfo GetMethod (Type type, MethodInfo method)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public bool IsCreated ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetCustomAttribute (ConstructorInfo con, byte[] binaryAttribute)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public void SetParent (Type parent)
+ {
+ throw new PlatformNotSupportedException ();
+ }
+
+ public override Type GetElementType ()
+ {
+ throw new PlatformNotSupportedException ();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
#endif
internal class ResolveEventHolder {
+#pragma warning disable 67
public event ModuleResolveEventHandler ModuleResolve;
+#pragma warning restore
}
internal class UnmanagedMemoryStreamForModule : UnmanagedMemoryStream
{
+#pragma warning disable 414
Module module;
+#pragma warning restore
public unsafe UnmanagedMemoryStreamForModule (byte* pointer, long length, Module module)
: base (pointer, length)
// Try the assembly directory
string location = Path.GetDirectoryName (Location);
string fullName = Path.Combine (location, Path.Combine (culture.Name, an.Name + ".dll"));
- if (!throwOnFileNotFound && !File.Exists (fullName))
- return null;
- return (RuntimeAssembly)LoadFrom (fullName);
+ try {
+ return (RuntimeAssembly)LoadFrom (fullName);
+ } catch {
+ if (!throwOnFileNotFound && !File.Exists (fullName))
+ return null;
+ throw;
+ }
}
#if !MOBILE
const int COR_E_TARGET = unchecked ((int)0x80131603L);
const int COR_E_TARGETINVOCATION = unchecked ((int)0x80131604L);
const int COR_E_TARGETPARAMCOUNT = unchecked ((int)0x8002000EL);
- const int COR_E_THREADABORTED = unchecked ((int)0x80131530L);
+ //const int COR_E_THREADABORTED = unchecked ((int)0x80131530L);
const int COR_E_THREADINTERRUPTED = unchecked ((int)0x80131519L);
const int COR_E_THREADSTATE = unchecked ((int)0x80131520L);
- const int COR_E_THREADSTOP = unchecked ((int)0x80131521L);
+ //const int COR_E_THREADSTOP = unchecked ((int)0x80131521L);
const int COR_E_TYPEINITIALIZATION = unchecked ((int)0x80131534L);
const int COR_E_VERIFICATION = unchecked ((int)0x8013150DL);
//const int COR_E_WEAKREFERENCE = unchecked ((int)?);
{
}
+#pragma warning disable 67
public event Func<AssemblyLoadContext, System.Reflection.AssemblyName, System.Reflection.Assembly> Resolving;
public event Action<AssemblyLoadContext> Unloading;
+#pragma warning restore
}
}
internal class CADMethodReturnMessage : CADMessageBase {
object _returnValue;
CADArgHolder _exception = null;
+#pragma warning disable 414
Type [] _sig;
+#pragma warning restore
static internal CADMethodReturnMessage Create (IMessage callMsg) {
IMethodReturnMessage msg = callMsg as IMethodReturnMessage;
public abstract class NativeObjectSecurity : CommonObjectSecurity
{
ExceptionFromErrorCode exception_from_error_code;
+#if !MOBILE
ResourceType resource_type;
+#endif
protected internal delegate Exception ExceptionFromErrorCode (int errorCode,
string name, SafeHandle handle,
internal NativeObjectSecurity (CommonSecurityDescriptor securityDescriptor, ResourceType resourceType)
: base (securityDescriptor)
{
+#if !MOBILE
resource_type = resourceType;
+#endif
}
protected NativeObjectSecurity (bool isContainer,
: base (isContainer)
{
exception_from_error_code = exceptionFromErrorCode;
+#if !MOBILE
resource_type = resourceType;
+#endif
}
protected NativeObjectSecurity (bool isContainer,
[return: MarshalAs (UnmanagedType.Bool)]
static extern bool IsValidSecurityDescriptor (IntPtr descriptor);
+ /*
struct SecurityDescriptor
{
public byte Revision, Size;
public ushort ControlFlags;
public IntPtr Owner, Group, Sacl, Dacl;
}
+ */
#endregion
#endif
}
SetAuditRule((AuditRule)rule);
}
- protected void Persist (SafeHandle handle)
+ protected new void Persist (SafeHandle handle)
{
WriteLock ();
try {
// - SecurityManager.InternalDemand (declarative)
internal void CasOnlyDemand (int skip)
{
+#if !MONO
Assembly current = null;
AppDomain domain = null;
+#endif
if (_ignored == null) {
// special case when directly called from CodeAccessPermission.Demand
private IntPtr flags;
private IntPtr thread_pinning_ref;
private IntPtr abort_protected_block_count;
+ private int priority = (int) ThreadPriority.Normal;
+ private IntPtr owned_mutex;
/*
* These fields are used to avoid having to increment corlib versions
* when a new field is added to the unmanaged MonoThread structure.
*/
private IntPtr unused1;
private IntPtr unused2;
+
+ /* This is used only to check that we are in sync between the representation
+ * of MonoInternalThread in native and InternalThread in managed
+ *
+ * DO NOT RENAME! DO NOT ADD FIELDS AFTER! */
+ private IntPtr last;
#endregion
#pragma warning restore 169, 414, 649
private InternalThread internal_thread;
object m_ThreadStartArg;
object pending_exception;
- int priority = (int) ThreadPriority.Normal;
#endregion
#pragma warning restore 414
static Console ()
{
if (Environment.IsRunningOnWindows) {
+#if !MOBILE
//
// On Windows, follow the Windows tradition
//
-#if MOBILE
- // should never happen since Moonlight does not run on windows
- inputEncoding = outputEncoding = Encoding.Default;
-#else
try {
inputEncoding = Encoding.GetEncoding (WindowsConsole.GetInputCodePage ());
outputEncoding = Encoding.GetEncoding (WindowsConsole.GetOutputCodePage ());
* of icalls, do not require an increment.
*/
#pragma warning disable 169
- private const int mono_corlib_version = 154;
+ private const int mono_corlib_version = 156;
#pragma warning restore 169
[ComVisible (true)]
+++ /dev/null
-//
-// System.GC.cs
-//
-// Author:
-// Paolo Molaro (lupus@ximian.com)
-//
-// (C) 2001 Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Runtime.CompilerServices;
-using System.Runtime.ConstrainedExecution;
-using System.Security.Permissions;
-
-namespace System
-{
- public static class GC
- {
-
- public extern static int MaxGeneration {
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- get;
- }
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- extern static void InternalCollect (int generation);
-
- public static void Collect () {
- InternalCollect (MaxGeneration);
- }
-
- public static void Collect (int generation) {
- if (generation < 0)
- throw new ArgumentOutOfRangeException ("generation");
- InternalCollect (generation);
- }
-
- [MonoDocumentationNote ("mode parameter ignored")]
- public static void Collect (int generation, GCCollectionMode mode) {
- Collect (generation);
- }
-
- [MonoDocumentationNote ("mode and blocking parameters ignored")]
- public static void Collect (int generation, GCCollectionMode mode, bool blocking) {
- Collect (generation);
- }
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static int GetGeneration (object obj);
-
- public static int GetGeneration (WeakReference wo) {
- object obj = wo.Target;
- if (obj == null)
- throw new ArgumentException ();
- return GetGeneration (obj);
- }
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static long GetTotalMemory (bool forceFullCollection);
-
- /* this icall has weird semantics check the docs... */
- [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void KeepAlive (object obj);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void ReRegisterForFinalize (object obj);
-
- [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void SuppressFinalize (object obj);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void WaitForPendingFinalizers ();
-
- [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static int CollectionCount (int generation);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern static void RecordPressure (long bytesAllocated);
-
- public static void AddMemoryPressure (long bytesAllocated) {
- RecordPressure (bytesAllocated);
- }
-
- public static void RemoveMemoryPressure (long bytesAllocated) {
- RecordPressure (-bytesAllocated);
- }
-
- [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
- [MonoTODO]
- public static GCNotificationStatus WaitForFullGCApproach () {
- throw new NotImplementedException ();
- }
-
- [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
- [MonoTODO]
- public static GCNotificationStatus WaitForFullGCApproach (int millisecondsTimeout) {
- throw new NotImplementedException ();
- }
-
- [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
- [MonoTODO]
- public static GCNotificationStatus WaitForFullGCComplete () {
- throw new NotImplementedException ();
- }
-
- [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
- [MonoTODO]
- public static GCNotificationStatus WaitForFullGCComplete (int millisecondsTimeout) {
- throw new NotImplementedException ();
- }
-
- [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
- public static void RegisterForFullGCNotification (int maxGenerationThreshold, int largeObjectHeapThreshold) {
- if (maxGenerationThreshold < 1 || maxGenerationThreshold > 99)
- throw new ArgumentOutOfRangeException ("maxGenerationThreshold", maxGenerationThreshold, "maxGenerationThreshold must be between 1 and 99 inclusive");
- if (largeObjectHeapThreshold < 1 || largeObjectHeapThreshold > 99)
- throw new ArgumentOutOfRangeException ("largeObjectHeapThreshold", largeObjectHeapThreshold, "largeObjectHeapThreshold must be between 1 and 99 inclusive");
- throw new NotImplementedException ();
- }
-
- [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
- public static void CancelFullGCNotification () {
- throw new NotImplementedException ();
- }
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- internal extern static void register_ephemeron_array (Ephemeron[] array);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- extern static object get_ephemeron_tombstone ();
-
- internal static readonly object EPHEMERON_TOMBSTONE = get_ephemeron_tombstone ();
- }
-}
+++ /dev/null
-//
-// System.GCCollectionMode.cs
-//
-
-//
-// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-// Net 3.5 type
-
-namespace System
-{
- [Serializable]
- public enum GCCollectionMode {
- Default = 0,
- Forced = 1,
- Optimized = 2
- }
-}
+++ /dev/null
-//
-// System.GCNotificationStatus.cs
-//
-// Authors:
-// Gonzalo Paniagua (gonzalo@ximian.com)
-//
-// Copyright (C) 2009 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Collections.Generic;
-using System.Runtime.ConstrainedExecution;
-
-namespace System {
- public enum GCNotificationStatus {
- Succeeded,
- Failed,
- Canceled,
- Timeout,
- NotApplicable
- }
-}
case 'O': // logical
int second = stack.Pop().Int32; // it's a stack... the second value was pushed last
int first = stack.Pop().Int32;
- char c = format[pos];
- stack.Push(
- c == '+' ? (first + second) :
- c == '-' ? (first - second) :
- c == '*' ? (first * second) :
- c == '/' ? (first / second) :
- c == 'm' ? (first % second) :
- c == '^' ? (first ^ second) :
- c == '&' ? (first & second) :
- c == '|' ? (first | second) :
- c == '=' ? AsInt(first == second) :
- c == '>' ? AsInt(first > second) :
- c == '<' ? AsInt(first < second) :
- c == 'A' ? AsInt(AsBool(first) && AsBool(second)) :
- c == 'O' ? AsInt(AsBool(first) || AsBool(second)) :
- 0); // not possible; we just validated above
+ int res;
+ switch (format[pos]) {
+ case '+':
+ res = first + second;
+ break;
+ case '-':
+ res = first - second;
+ break;
+ case '*':
+ res = first * second;
+ break;
+ case '/':
+ res = first / second;
+ break;
+ case 'm':
+ res = first % second;
+ break;
+ case '^':
+ res = first ^ second;
+ break;
+ case '&':
+ res = first & second;
+ break;
+ case '|':
+ res = first | second;
+ break;
+ case '=':
+ res = AsInt(first == second);
+ break;
+ case '>':
+ res = AsInt(first > second);
+ break;
+ case '<':
+ res = AsInt(first < second);
+ break;
+ case 'A':
+ res = AsInt(AsBool(first) && AsBool(second));
+ break;
+ case 'O':
+ res = AsInt(AsBool(first) || AsBool(second));
+ break;
+ default:
+ res = 0;
+ break;
+ }
+ stack.Push(res);
break;
// Unary operations
return sign * (hour * 60) * 60;
}
- static TimeZoneInfo defaultZone;
internal static TimeZoneInfo Local {
get {
var id = GetDefaultTimeZoneName ();
- return defaultZone = GetTimeZone (id, id);
+ return GetTimeZone (id, id);
}
}
try {
ret = readlink (path, buf, buf.Length);
- } catch (DllNotFoundException e) {
+ } catch (DllNotFoundException) {
readlinkNotFound = true;
return null;
- } catch (EntryPointNotFoundException e) {
+ } catch (EntryPointNotFoundException) {
readlinkNotFound = true;
return null;
}
return tz.BaseUtcOffset;
}
- if (tzRule != null && tz.IsInDST (tzRule, stdUtcDateTime) && tz.IsInDST (tzRule, dstUtcDateTime)) {
+ if (tzRule != null && tz.IsInDST (tzRule, stdUtcDateTime)) {
+ // Replicate what .NET does when given a time which falls into the hour which is lost when
+ // DST starts. isDST should always be true but the offset should be BaseUtcOffset without the
+ // DST delta while in that hour.
isDST = true;
- return tz.BaseUtcOffset + tzRule.DaylightDelta;
+ if (tz.IsInDST (tzRule, dstUtcDateTime)) {
+ return tz.BaseUtcOffset + tzRule.DaylightDelta;
+ } else {
+ return tz.BaseUtcOffset;
+ }
}
return tz.BaseUtcOffset;
} else {
AdjustmentRule first = null, last = null;
+ // Rule start/end dates are either very specific or very broad depending on the platform
+ // 2015-10-04..2016-04-03 - Rule for a time zone in southern hemisphere on non-Windows platforms
+ // 2016-03-27..2016-10-03 - Rule for a time zone in northern hemisphere on non-Windows platforms
+ // 0001-01-01..9999-12-31 - Rule for a time zone on Windows
+
foreach (var rule in GetAdjustmentRules ()) {
- if (rule.DateStart.Year != year && rule.DateEnd.Year != year)
+ if (rule.DateStart.Year > year || rule.DateEnd.Year < year)
continue;
- if (rule.DateStart.Year == year)
+ if (rule.DateStart.Year <= year && (first == null || rule.DateStart.Year > first.DateStart.Year))
first = rule;
- if (rule.DateEnd.Year == year)
+ if (rule.DateEnd.Year >= year && (last == null || rule.DateEnd.Year < last.DateEnd.Year))
last = rule;
}
return false;
}
+ var inDelta = false;
for (var i = transitions.Count - 1; i >= 0; i--) {
var pair = transitions [i];
DateTime ttime = pair.Key;
TimeType ttype = pair.Value;
- if (ttime > date)
+ var delta = new TimeSpan (0, 0, ttype.Offset) - BaseUtcOffset;
+
+ if ((ttime + delta) > date) {
+ inDelta = ttime <= date;
continue;
+ }
offset = new TimeSpan (0, 0, ttype.Offset);
- isDst = ttype.IsDst;
+ if (inDelta) {
+ // Replicate what .NET does when given a time which falls into the hour which is lost when
+ // DST starts. isDST should be true but the offset should be the non-DST offset.
+ isDst = transitions [i - 1].Value.IsDst;
+ } else {
+ isDst = ttype.IsDst;
+ }
return true;
}
security = File.GetAccessControl (path);
security.SetOwner (new SecurityIdentifier ("WD"));
File.SetAccessControl (path, security);
+ // If we don't get an InvalidOperationException it could be that we are running
+ // with administrator privileges. Don't fail the test if that is the case.
+ WindowsIdentity identity = WindowsIdentity.GetCurrent ();
+ WindowsPrincipal principal = new WindowsPrincipal (identity);
+ if (principal.IsInRole (WindowsBuiltInRole.Administrator)) {
+ Assert.Ignore ("Running as Administrator");
+ }
} finally {
File.Delete (path);
}
{\r
public int id;\r
public Mutex mut;\r
+ public bool abandoned_exception;\r
public ConcClass(int id,Mutex mut)\r
{\r
this.id = id;\r
\r
public void WaitAndForget()\r
{\r
- this.Wait();\r
+ try {\r
+ this.Wait();\r
+ } catch (AbandonedMutexException) {\r
+ this.abandoned_exception = true;\r
+ }\r
+\r
this.marker = id;\r
}\r
public void WaitAndWait()\r
}\r
\r
[Test]\r
- public void TestWaitAndFoget1()\r
+ public void TestWaitAndForget1()\r
{\r
Mutex Sem = new Mutex(false);\r
ConcClassLoop class1 = new ConcClassLoop(1,Sem);\r
try {\r
thread1.Start();\r
TestUtil.WaitForNotAlive (thread1, "t1");\r
+ Assert.IsFalse (class1.abandoned_exception, "e1");\r
\r
thread2.Start();\r
TestUtil.WaitForNotAlive (thread2, "t2");\r
+ Assert.IsTrue (class2.abandoned_exception, "e2");\r
\r
Assert.AreEqual (class2.id, class2.marker);\r
} finally {\r
using System;
+using System.Collections.Generic;
using System.Threading;
using NUnit.Framework;
}
}
+ [Test]
+ public void WaitOneWithAbandonedMutex ()
+ {
+ using (var m = new Mutex (false)) {
+ var thread1 = new Thread (() => {
+ m.WaitOne ();
+ });
+ thread1.Start ();
+ thread1.Join (1000);
+ try {
+ m.WaitOne ();
+ Assert.Fail ("Expected AbandonedMutexException");
+ } catch (AbandonedMutexException) {
+ }
+ // Current thread should own the Mutex now
+ var signalled = false;
+ var thread2 = new Thread (() => {
+ signalled = m.WaitOne (100);
+ });
+ thread2.Start ();
+ thread2.Join (1000);
+ Assert.IsFalse (signalled);
+
+ // Since this thread owns the Mutex releasing it shouldn't fail
+ m.ReleaseMutex ();
+ // The Mutex should now be unowned
+ try {
+ m.ReleaseMutex ();
+ Assert.Fail ("Expected ApplicationException");
+ } catch (ApplicationException) {
+ }
+ }
+ }
+
+ [Test]
+ public void WaitOneWithAbandonedMutexAndMultipleThreads ()
+ {
+ using (var m = new Mutex (true)) {
+ var nonAbandoned = 0;
+ var abandoned = 0;
+ var n = 0;
+ var threads = new List<Thread> ();
+ for (int i = 0; i < 50; i++) {
+ var thread = new Thread (() => {
+ try {
+ m.WaitOne ();
+ nonAbandoned++;
+ } catch (AbandonedMutexException) {
+ abandoned++;
+ }
+ if (((n++) % 5) != 0)
+ m.ReleaseMutex ();
+ });
+ thread.Start ();
+ threads.Add (thread);
+ }
+ m.ReleaseMutex ();
+ foreach (var thread in threads) {
+ if (!thread.Join (1000)) {
+ Assert.Fail ("Timed out");
+ }
+ }
+ Assert.AreEqual (40, nonAbandoned);
+ Assert.AreEqual (10, abandoned);
+ }
+ }
+
+ [Test]
+ public void WaitAnyWithSecondMutexAbandoned ()
+ {
+ using (var m1 = new Mutex (false)) {
+ using (var m2 = new Mutex (false)) {
+ var mainProceed = false;
+ var thread2Proceed = false;
+ var thread1 = new Thread (() => {
+ m2.WaitOne ();
+ });
+ var thread2 = new Thread (() => {
+ m1.WaitOne ();
+ mainProceed = true;
+ while (!thread2Proceed) {
+ Thread.Sleep (10);
+ }
+ m1.ReleaseMutex ();
+ });
+ thread1.Start ();
+ thread1.Join (1000);
+ thread2.Start ();
+ while (!mainProceed) {
+ Thread.Sleep (10);
+ }
+ try {
+ WaitHandle.WaitAny (new WaitHandle [] { m1, m2 });
+ Assert.Fail ("Expected AbandonedMutexException");
+ } catch (AbandonedMutexException e) {
+ Assert.AreEqual (1, e.MutexIndex);
+ Assert.AreEqual (m2, e.Mutex);
+ } finally {
+ thread2Proceed = true;
+ thread2.Join (1000);
+ }
+
+ // Current thread should own the second Mutex now
+ var signalled = -1;
+ var thread3 = new Thread (() => {
+ signalled = WaitHandle.WaitAny (new WaitHandle [] { m1, m2 }, 0);
+ });
+ thread3.Start ();
+ thread3.Join (1000);
+ Assert.AreEqual (0, signalled);
+
+ // Since this thread owns the second Mutex releasing it shouldn't fail
+ m2.ReleaseMutex ();
+ // Second Mutex should now be unowned
+ try {
+ m2.ReleaseMutex ();
+ Assert.Fail ("Expected ApplicationException");
+ } catch (ApplicationException) {
+ }
+ // .NET allows the first Mutex which is now abandoned to be released multiple times by this thread
+ m1.ReleaseMutex ();
+ m1.ReleaseMutex ();
+ }
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (AbandonedMutexException))]
+ public void WaitAllWithOneAbandonedMutex ()
+ {
+ using (var m1 = new Mutex (false)) {
+ using (var m2 = new Mutex (false)) {
+ var thread = new Thread (() => {
+ m1.WaitOne ();
+ });
+ thread.Start ();
+ thread.Join (1000);
+ WaitHandle.WaitAll (new WaitHandle [] { m1, m2 });
+ }
+ }
+ }
+
#if MONO_FEATURE_THREAD_SUSPEND_RESUME
[Test]
public void WaitOneWithTimeoutAndSpuriousWake ()
}
[Test]
- [Culture ("en-us")]
+ [SetCulture ("en-us")]
public void ToUniversalTime_TimeZoneOffsetShouldNotOverflow ()
{
var m = DateTime.MaxValue;
res = m.ToUniversalTime ();
// It does not matter which time zone but we should never overflow or have DateTime.MinValue
- Assert.AreEqual (0, res.Year, "#10");
+ Assert.AreEqual (1, res.Year, "#10");
Assert.AreEqual (1, res.Month, "#11");
Assert.AreEqual (1, res.Day, "#12");
Assert.AreEqual (DateTimeKind.Utc, res.Kind, "#13");
}
[Test]
- [Culture ("en")]
+ [SetCulture ("en")]
public void TestParse()
{
// Boolean Decimal.TryParse(String, NumberStyles, IFormatProvider, Decimal)
}
[Test]
- [Culture ("en")]
+ [SetCulture ("en")]
public void TestToString()
{
// String Decimal.ToString()
}
[Test]
- [Culture ("en")]
+ [SetCulture ("en")]
public void TestNumberBufferLimit()
{
Decimal dE = 1234567890123456789012345.6785m;
}
[Test]
- [Culture ("en-US")]
+ [SetCulture ("en-US")]
public void Parse ()
{
int i = 0;
--- /dev/null
+//
+// GCTest.cs - NUnit Test Cases for GC
+//
+// Authors:
+// Marek Safar <marek.safar@gmail.com>
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Threading.Tasks;
+
+using NUnit.Framework;
+
+namespace MonoTests.System {
+
+ [TestFixture]
+ public class GCTest {
+
+ class MyFinalizeObject
+ {
+ public volatile static int finalized;
+
+ ~MyFinalizeObject ()
+ {
+ if (finalized++ == 0) {
+ GC.ReRegisterForFinalize (this);
+ }
+ }
+ }
+
+ static void Run_ReRegisterForFinalizeTest ()
+ {
+ var m = new WeakReference<MyFinalizeObject> (new MyFinalizeObject ());
+ m.SetTarget (null);
+ }
+
+ [Test]
+ public void ReRegisterForFinalizeTest ()
+ {
+ Run_ReRegisterForFinalizeTest ();
+ var t = Task.Factory.StartNew (() => {
+ do {
+ GC.Collect ();
+ GC.WaitForPendingFinalizers ();
+ Task.Yield ();
+ } while (MyFinalizeObject.finalized != 2);
+ });
+
+ Assert.IsTrue (t.Wait (5000));
+ }
+ }
+}
\ No newline at end of file
[Test]
public void DeltaNotInSeconds ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- throw new ArgumentOutOfRangeException ();;
DateTime dateStart = new DateTime (2007,01,01);
DateTime dateEnd = new DateTime (2008,01,01);
TimeZoneInfo.TransitionTime daylightTransitionStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1,1,1,2,0,0), 03, 11);
static FieldInfo cachedDataField;
static object localFieldObj;
+ public static string MapTimeZoneId (string id)
+ {
+ if (Environment.OSVersion.Platform == PlatformID.Unix)
+ return id;
+ else {
+ switch (id) {
+ case "Pacific/Auckland":
+ return "New Zealand Standard Time";
+ case "Europe/Athens":
+ return "GTB Standard Time";
+ case "US/Eastern":
+ return "Eastern Standard Time";
+ case "US/Pacific":
+ return "Pacific Standard Time";
+ case "Australia/Sydney":
+ case "Australia/Melbourne":
+ return "AUS Eastern Standard Time";
+ case "Europe/Brussels":
+ return "Romance Standard Time";
+ case "Africa/Kinshasa":
+ return "W. Central Africa Standard Time";
+ case "Europe/Rome":
+ case "Europe/Vatican":
+ return "W. Europe Standard Time";
+ case "Canada/Eastern":
+ return "Eastern Standard Time";
+ default:
+ Assert.Fail ($"No mapping defined for zone id '{id}'");
+ return null;
+ }
+ }
+ }
+
public static void SetLocal (TimeZoneInfo val)
{
if (localField == null) {
[Test]
public void GetLocal ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
TimeZoneInfo local = TimeZoneInfo.Local;
Assert.IsNotNull (local);
Assert.IsTrue (true);
[Test]
public void DSTInLondon ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
DateTime june01 = new DateTime (2007, 06, 01);
DateTime xmas = new DateTime (2007, 12, 25);
Assert.IsTrue (london.IsDaylightSavingTime (june01), "June 01 is DST in London");
[Test]
public void DSTTransisions ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
DateTime beforeDST = new DateTime (2007, 03, 25, 0, 59, 59, DateTimeKind.Unspecified);
DateTime startDST = new DateTime (2007, 03, 25, 2, 0, 0, DateTimeKind.Unspecified);
DateTime endDST = new DateTime (2007, 10, 28, 1, 59, 59, DateTimeKind.Unspecified);
[Test (Description="Description xambug #17155")]
public void AdjustmentRuleAfterNewYears ()
{
- TimeZoneInfo tz;
- if (Environment.OSVersion.Platform == PlatformID.Unix)
- tz = TimeZoneInfo.FindSystemTimeZoneById ("Pacific/Auckland"); // *nix
- else
- tz = TimeZoneInfo.FindSystemTimeZoneById ("New Zealand Standard Time"); // Windows
-
+ TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Pacific/Auckland"));
// DST start: 9/29/2013 2:00:00 AM
// DST end: 4/6/2014 3:00:00 AM
DateTime dt = new DateTime (2014, 1, 9, 23, 0, 0, DateTimeKind.Utc);
[Test] //Covers #25050
public void TestAthensDST ()
{
- TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
+ TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
var date = new DateTime (2014, 3, 30 , 2, 0, 0);
Assert.IsFalse (tzi.IsDaylightSavingTime (date));
Assert.AreEqual (new TimeSpan (2,0,0), tzi.GetUtcOffset (date));
}
+ [Test]
+ public void TestAthensDST_InDSTDelta ()
+ {
+ // In .NET GetUtcOffset() returns the BaseUtcOffset for times within the hour
+ // lost when DST starts but IsDaylightSavingTime() returns true.
+
+ TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
+
+ var date = new DateTime (2014, 3, 30 , 3, 0, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ date = new DateTime (2014, 3, 30 , 3, 1, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ date = new DateTime (2014, 3, 30 , 3, 59, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ date = new DateTime (2014, 3, 30 , 4, 0, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (3, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+ }
+
+ [Test]
+ public void TestAthensDST_InDSTDelta_NoTransitions ()
+ {
+ if (Environment.OSVersion.Platform != PlatformID.Unix)
+ Assert.Ignore ("TimeZoneInfo on Mono on Windows and .NET has no transitions");
+
+ // Repeat the previous test but this time force using AdjustmentRules by nulling out TimeZoneInfo.transitions
+
+ TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
+
+ var transitionsField = typeof (TimeZoneInfo).GetField ("transitions", BindingFlags.Instance | BindingFlags.NonPublic);
+ var transitions = transitionsField.GetValue (tzi);
+ Assert.IsNotNull (transitions, "Expected Athens TimeZoneInfo.transitions to be non-null");
+ transitionsField.SetValue (tzi, null);
+
+ try {
+
+ var date = new DateTime (2014, 3, 30 , 3, 0, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ date = new DateTime (2014, 3, 30 , 3, 1, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ date = new DateTime (2014, 3, 30 , 3, 59, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ date = new DateTime (2014, 3, 30 , 4, 0, 0);
+ Assert.IsTrue (tzi.IsDaylightSavingTime (date));
+ Assert.AreEqual (new TimeSpan (3, 0, 0), tzi.GetUtcOffset (date));
+ Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
+
+ } finally {
+ transitionsField.SetValue (tzi, transitions);
+ }
+ }
+
[Test] //Covers #41349
public void TestIsDST_DateTimeOffset ()
{
- TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
+ TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
var date = new DateTime (2014, 3, 30 , 2, 0, 0);
var offset = tzi.GetUtcOffset (date);
var dateOffset = new DateTimeOffset (date, offset);
[ExpectedException (typeof (ArgumentException))]
public void ConvertFromUtc_KindIsLocalException ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- throw new ArgumentException ();
TimeZoneInfo.ConvertTimeFromUtc (new DateTime (2007, 5, 3, 11, 8, 0, DateTimeKind.Local), TimeZoneInfo.Local);
}
[Test]
public void ConvertFromUTC_ConvertInWinter ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
DateTime utc = new DateTime (2007, 12, 25, 12, 0, 0);
DateTime converted = TimeZoneInfo.ConvertTimeFromUtc (utc, london);
Assert.AreEqual (utc, converted);
[Test]
public void ConvertFromUtc_ConvertInSummer ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
DateTime utc = new DateTime (2007, 06, 01, 12, 0, 0);
DateTime converted = TimeZoneInfo.ConvertTimeFromUtc (utc, london);
Assert.AreEqual (utc + new TimeSpan (1,0,0), converted);
[ExpectedException (typeof (ArgumentException))]
public void ConvertToUTC_KindIsLocalButSourceIsNot ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- throw new ArgumentException ();
TimeZoneInfo.ConvertTimeToUtc (new DateTime (2007, 5, 3, 12, 8, 0, DateTimeKind.Local), london);
}
[Test]
public void ConvertFromToUtc ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
DateTime utc = DateTime.UtcNow;
Assert.AreEqual (utc.Kind, DateTimeKind.Utc);
DateTime converted = TimeZoneInfo.ConvertTimeFromUtc (utc, london);
[Test]
public void ConvertToTimeZone ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
-
- TimeZoneInfo.ConvertTime (DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Pacific/Auckland"));
+ TimeZoneInfo.ConvertTime (DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Pacific/Auckland")));
}
[Test]
[Test (Description="Fix for xambug https://bugzilla.xamarin.com/show_bug.cgi?id=17155")]
public void ConvertTime_AdjustmentRuleAfterNewYears ()
{
- TimeZoneInfo tz;
- if (Environment.OSVersion.Platform == PlatformID.Unix)
- tz = TimeZoneInfo.FindSystemTimeZoneById ("Pacific/Auckland"); // *nix
- else
- tz = TimeZoneInfo.FindSystemTimeZoneById ("New Zealand Standard Time"); // Windows
+ TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Pacific/Auckland"));
// DST start: 9/29/2013 2:00:00 AM
// DST end: 4/6/2014 3:00:00 AM
[Test (Description="Fix the bug https://bugzilla.xamarin.com/show_bug.cgi?id=1849")]
public void ConvertTime_AjustmentConvertTimeWithSourceTimeZone () {
- TimeZoneInfo easternTimeZone;
- TimeZoneInfo pacificTimeZone;
-
- if (Environment.OSVersion.Platform == PlatformID.Unix) {
- // *nix
- easternTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("US/Eastern");
- pacificTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("US/Pacific");
- }
- else {
- // Windows
- easternTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("Eastern Standard Time");
- pacificTimeZone = TimeZoneInfo.FindSystemTimeZoneById ("Pacific Standard Time");
- }
+ TimeZoneInfo easternTimeZone = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("US/Eastern"));
+ TimeZoneInfo pacificTimeZone = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("US/Pacific"));
DateTime lastMidnight = new DateTime (new DateTime (2012, 06, 13).Ticks, DateTimeKind.Unspecified);
DateTime lastMidnightAsEST = TimeZoneInfo.ConvertTime (lastMidnight, pacificTimeZone, easternTimeZone);
[Test]
public void AmbiguousDates ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 0)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 1)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 2, 0, 0)));
[Test]
public void AmbiguousUTCDates ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 0, DateTimeKind.Utc)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 1, DateTimeKind.Utc)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 59, 59, DateTimeKind.Utc)));
[Test]
public void NotEmpty ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo> systemTZ = TimeZoneInfo.GetSystemTimeZones ();
Assert.IsNotNull(systemTZ, "SystemTZ is null");
Assert.IsFalse (systemTZ.Count == 0, "SystemTZ is empty");
[Test]
public void ContainsBrussels ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
global::System.Collections.ObjectModel.ReadOnlyCollection<TimeZoneInfo> systemTZ = TimeZoneInfo.GetSystemTimeZones ();
foreach (TimeZoneInfo tz in systemTZ) {
- if (tz.Id == "Europe/Brussels")
+ if (tz.Id == MapTimeZoneId ("Europe/Brussels"))
return;
}
Assert.Fail ("Europe/Brussels not found in SystemTZ");
[ExpectedException (typeof (TimeZoneNotFoundException))]
public void NonSystemTimezone ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- throw new TimeZoneNotFoundException ();
TimeZoneInfo.FindSystemTimeZoneById ("Neverland/The_Lagoon");
}
[Test]
public void FindBrusselsTZ ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+ TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
Assert.IsNotNull (brussels);
}
[Test]
public void OffsetIsCorrectInKinshasa ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById ("Africa/Kinshasa");
+ TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Africa/Kinshasa"));
Assert.AreEqual (new TimeSpan (1,0,0), kin.BaseUtcOffset, "BaseUtcOffset in Kinshasa is not +1h");
}
[Test]
public void OffsetIsCorrectInBrussels ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+ TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
Assert.AreEqual (new TimeSpan (1,0,0), brussels.BaseUtcOffset, "BaseUtcOffset for Brussels is not +1h");
}
[Test]
public void NoDSTInKinshasa ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById ("Africa/Kinshasa");
+ TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Africa/Kinshasa"));
Assert.IsFalse (kin.SupportsDaylightSavingTime);
}
[Test]
public void BrusselsSupportsDST ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+ TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
Assert.IsTrue (brussels.SupportsDaylightSavingTime);
}
[Test]
public void MelbourneSupportsDST ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo melbourne = TimeZoneInfo.FindSystemTimeZoneById ("Australia/Melbourne");
+ TimeZoneInfo melbourne = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Australia/Melbourne"));
Assert.IsTrue (melbourne.SupportsDaylightSavingTime);
}
[Test]
public void RomeAndVaticanSharesTime ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo rome = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Rome");
- TimeZoneInfo vatican = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Vatican");
+ TimeZoneInfo rome = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Rome"));
+ TimeZoneInfo vatican = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Vatican"));
Assert.IsTrue (rome.HasSameRules (vatican));
}
[ExpectedException (typeof(ArgumentException))]
public void DateIsNotAmbiguous ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- throw new ArgumentException ();
- TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+ TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
DateTime date = new DateTime (2007, 05, 11, 11, 40, 00);
brussels.GetAmbiguousTimeOffsets (date);
}
[Test]
public void AmbiguousOffsets ()
{
- if (Environment.OSVersion.Platform != PlatformID.Unix)
- Assert.Ignore ("Not running on Unix.");
- TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Brussels");
+ TimeZoneInfo brussels = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Brussels"));
DateTime date = new DateTime (2007, 10, 28, 2, 30, 00);
Assert.IsTrue (brussels.IsAmbiguousTime (date));
Assert.AreEqual (2, brussels.GetAmbiguousTimeOffsets (date).Length);
[Test]
public void TestSydneyDaylightChanges ()
{
- TimeZoneInfo tz;
- if (Environment.OSVersion.Platform == PlatformID.Unix)
- tz = TimeZoneInfo.FindSystemTimeZoneById ("Australia/Sydney");
- else
- tz = TimeZoneInfo.FindSystemTimeZoneById ("W. Australia Standard Time");
+ TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Australia/Sydney"));
var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
Assert.AreEqual (new DateTime (2014, 4, 6, 3, 0, 0), changes.End);
}
+ [Test]
+ public void TestAthensDaylightChanges ()
+ {
+ TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
+
+ var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
+
+ Assert.AreEqual (new TimeSpan (1, 0, 0), changes.Delta);
+ Assert.AreEqual (new DateTime (2014, 3, 30, 3, 0, 0), changes.Start);
+ Assert.AreEqual (new DateTime (2014, 10, 26, 4, 0, 0), changes.End);
+ }
+
[Test]
public void AllTimeZonesDaylightChanges ()
{
private void CET (TimeZone t1)
{
- Assert.AreEqual("CET", t1.StandardName, "A01");
- Assert.AreEqual("CEST", t1.DaylightName, "A02");
+ Assert.IsTrue("CET" == t1.StandardName || "W. Europe Standard Time" == t1.StandardName, "A01");
+ Assert.IsTrue("CEST" == t1.DaylightName || "W. Europe Daylight Time" == t1.DaylightName, "A02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "A03");
private void EST (TimeZone t1)
{
- // It could be EST though...
- //Assert.AreEqual("Eastern Standard Time", t1.StandardName, "B01");
- //Assert.AreEqual("Eastern Daylight Time", t1.DaylightName, "B02");
+ Assert.IsTrue("EST" == t1.StandardName || "Eastern Standard Time" == t1.StandardName, "B01");
+ Assert.IsTrue("EDT" == t1.DaylightName || "Eastern Daylight Time" == t1.DaylightName, "B02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "B03");
{
TimeZone t1 = TimeZone.CurrentTimeZone;
switch (t1.StandardName) {
+ case "W. Europe Standard Time":
case "CET":
CET (t1);
break;
[Test]
public void FindSystemTimeZoneById ()
{
- TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Canada/Eastern");
- Assert.AreEqual ("EDT", tzi.DaylightName, "DaylightName");
- Assert.AreEqual ("EST", tzi.StandardName, "StandardName");
+ TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfoTest.MapTimeZoneId ("Canada/Eastern"));
+ Assert.IsTrue ("EDT" == tzi.DaylightName || "Eastern Daylight Time" == tzi.DaylightName, "DaylightName");
+ Assert.IsTrue ("EST" == tzi.StandardName || "Eastern Standard Time" == tzi.StandardName, "StandardName");
Assert.IsTrue (tzi.SupportsDaylightSavingTime, "SupportsDaylightSavingTime");
}
#endif
const string ASSEMBLY_NAME = "MonoTests.System.TypeTest";
static int typeIndexer = 0;
+ static bool isMono = Type.GetType ("Mono.Runtime", false) != null;
[SetUp]
public void SetUp ()
Assert.AreEqual (t1.FullName, "System.__ComObject");
- if (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
- Environment.OSVersion.Platform == PlatformID.Win32NT)
+ if (!isMono && (Environment.OSVersion.Platform == PlatformID.Win32Windows ||
+ Environment.OSVersion.Platform == PlatformID.Win32NT))
Activator.CreateInstance(t1);
Assert.AreEqual (t2.FullName, "System.__ComObject");
System/EmptyArray.cs
System/Environment.cs
System/EnvironmentVariableTarget.cs
-System/GC.cs
-System/GCCollectionMode.cs
-System/GCNotificationStatus.cs
System/Guid.cs
System/IConsoleDriver.cs
System/IntPtr.cs
System.Reflection.Emit/TypeBuilder.cs
System.Reflection.Emit/TypeToken.cs
System.Reflection.Emit/UnmanagedMarshal.cs
+System.Reflection.Emit/AssemblyBuilder.pns.cs
+System.Reflection.Emit/ConstructorBuilder.pns.cs
+System.Reflection.Emit/CustomAttributeBuilder.pns.cs
+System.Reflection.Emit/EnumBuilder.pns.cs
+System.Reflection.Emit/EventBuilder.pns.cs
+System.Reflection.Emit/FieldBuilder.pns.cs
+System.Reflection.Emit/GenericTypeParameterBuilder.pns.cs
+System.Reflection.Emit/ILGenerator.pns.cs
+System.Reflection.Emit/MethodBuilder.pns.cs
+System.Reflection.Emit/ModuleBuilder.pns.cs
+System.Reflection.Emit/ParameterBuilder.pns.cs
+System.Reflection.Emit/PropertyBuilder.pns.cs
+System.Reflection.Emit/SignatureHelper.pns.cs
+System.Reflection.Emit/TypeBuilder.pns.cs
System.Reflection.Metadata/AssemblyExtensions.cs
System.Resources/Win32Resources.cs
System.Runtime/GCLargeObjectHeapCompactionMode.cs
ReferenceSources/SharedStatics.cs
ReferenceSources/SecurityContext.cs
ReferenceSources/PathInternal.cs
+ReferenceSources/BinaryCompatibility.cs
../referencesource/mscorlib/system/__filters.cs
../referencesource/mscorlib/system/__hresults.cs
../referencesource/mscorlib/system/flagsattribute.cs
../referencesource/mscorlib/system/formatexception.cs
../referencesource/mscorlib/system/FormattableString.cs
+../referencesource/mscorlib/system/gc.cs
../referencesource/mscorlib/system/guid.cs
../referencesource/mscorlib/system/iappdomain.cs
../referencesource/mscorlib/system/iappdomainsetup.cs
../referencesource/mscorlib/system/runtime/serialization/formatters/soapfault.cs
../referencesource/mscorlib/system/runtime/serialization/formatters/soapmessage.cs
-../referencesource/mscorlib/system/runtime/versioning/binarycompatibility.cs
../referencesource/mscorlib/system/runtime/versioning/componentguaranteesattribute.cs
../referencesource/mscorlib/system/runtime/versioning/multitargetinghelpers.cs
../referencesource/mscorlib/system/runtime/versioning/NonVersionableAttribute.cs
System/CharEnumeratorTest.cs
System/CharTest.cs
System/DelegateTest.cs
+System/GCTest.cs
System/ModuleHandleTest.cs
System/NullableTest.cs
System/ObsoleteAttributeTest.cs
private WebHeaderCollectionType m_Type;
#if MONO
- internal bool AllowMultiValues (string name)
+ internal static bool AllowMultiValues (string name)
{
var hinfo = HInfo[name];
// Is common header which supports multi value or it's unknown header
/// attached property.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
+#if !MOBILE
[TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
+#endif
public sealed class ValueSerializerAttribute : Attribute
{
/// <summary>
, IComparable<Boolean>, IEquatable<Boolean>
#endif
{
-
+#pragma warning disable 649
//
// Member Variables
//
private bool m_value;
+#pragma warning disable
// The true value.
//
Contract.EndContractBlock();
if (count > 0) {
+#if !MONO
int i = _size;
+#endif
_size -= count;
if (index < _size) {
Array.Copy(_items, index + count, _items, index, _size - index);
Byte[] decodedBytes = new Byte[resultLength];
// Convert Base64 chars into bytes:
- Int32 actualResultLength;
fixed (Byte* decodedBytesPtr = decodedBytes)
- actualResultLength = FromBase64_Decode(inputPtr, inputLength, decodedBytesPtr, resultLength);
+ FromBase64_Decode(inputPtr, inputLength, decodedBytesPtr, resultLength);
// Note that actualResultLength can differ from resultLength if the caller is modifying the array
// as it is being converted. Silently ignore the failure.
public static class GC
{
+#if MONO
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static int GetCollectionCount (int generation);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static int GetMaxGeneration ();
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static void InternalCollect (int generation);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static void RecordPressure (long bytesAllocated);
+
+ // TODO: Move following to ConditionalWeakTable
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ internal extern static void register_ephemeron_array (Ephemeron[] array);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ extern static object get_ephemeron_tombstone ();
+
+ internal static readonly object EPHEMERON_TOMBSTONE = get_ephemeron_tombstone ();
+#else
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
private static extern void _RemoveMemoryPressure(UInt64 bytesAllocated);
+#endif
[System.Security.SecurityCritical] // auto-generated_required
public static void AddMemoryPressure (long bytesAllocated) {
}
Contract.EndContractBlock();
+#if MONO
+ RecordPressure (bytesAllocated);
+#else
_AddMemoryPressure((ulong)bytesAllocated);
+#endif
}
[System.Security.SecurityCritical] // auto-generated_required
}
Contract.EndContractBlock();
+#if MONO
+ RecordPressure (-bytesAllocated);
+#else
_RemoveMemoryPressure((ulong) bytesAllocated);
+#endif
}
//
[System.Security.SecuritySafeCritical] // auto-generated
public static void Collect() {
+#if MONO
+ InternalCollect (MaxGeneration);
+#else
//-1 says to GC all generations.
_Collect(-1, (int)InternalGCCollectionMode.Blocking);
+#endif
}
[System.Security.SecuritySafeCritical] // auto-generated
iInternalModes |= (int)InternalGCCollectionMode.NonBlocking;
}
+#if MONO
+ InternalCollect (generation);
+#else
_Collect(generation, iInternalModes);
+#endif
}
[System.Security.SecuritySafeCritical] // auto-generated
throw new ArgumentOutOfRangeException("generation", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
}
Contract.EndContractBlock();
+
+#if MONO
+ return GetCollectionCount(generation);
+#else
return _CollectionCount(generation, 0);
+#endif
}
+#if !MONO
// pass in true to get the BGC or FGC count.
[System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
Contract.EndContractBlock();
return _CollectionCount(generation, (getSpecialGCCount ? 1 : 0));
}
+#endif
// This method DOES NOT DO ANYTHING in and of itself. It's used to
// prevent a finalizable object from losing any outstanding references
//
[System.Security.SecuritySafeCritical] // auto-generated
public static int GetGeneration(WeakReference wo) {
+#if MONO
+ object obj = wo.Target;
+ if (obj == null)
+ throw new ArgumentException ();
+ return GetGeneration (obj);
+#else
int result = GetGenerationWR(wo.m_handle);
KeepAlive(wo);
return result;
+#endif
}
// Returns the maximum GC generation. Currently assumes only 1 heap.
get { return GetMaxGeneration(); }
}
+#if MONO
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ public extern static void WaitForPendingFinalizers ();
+#else
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void _WaitForPendingFinalizers();
+
[System.Security.SecuritySafeCritical] // auto-generated
public static void WaitForPendingFinalizers() {
// QCalls can not be exposed from mscorlib directly, need to wrap it.
_WaitForPendingFinalizers();
}
+#endif
// Indicates that the system should not call the Finalize() method on
// an object that would normally require this call.
// the GC heap. This does not return the total size of the GC heap, but
// only the live objects in the GC heap.
//
+#if MONO
+ [MethodImplAttribute (MethodImplOptions.InternalCall)]
+ public extern static long GetTotalMemory (bool forceFullCollection);
+
+ static bool _RegisterForFullGCNotification(int maxGenerationPercentage, int largeObjectHeapPercentage)
+ {
+ throw new NotImplementedException ();
+ }
+
+ static bool _CancelFullGCNotification ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ static int _WaitForFullGCApproach (int millisecondsTimeout)
+ {
+ throw new NotImplementedException ();
+ }
+
+ static int _WaitForFullGCComplete (int millisecondsTimeout)
+ {
+ throw new NotImplementedException ();
+ }
+
+#else
[System.Security.SecuritySafeCritical] // auto-generated
public static long GetTotalMemory(bool forceFullCollection) {
long size = GetTotalMemory();
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int _WaitForFullGCComplete(int millisecondsTimeout);
+#endif
[SecurityCritical]
public static void RegisterForFullGCNotification(int maxGenerationThreshold, int largeObjectHeapThreshold)
[SecurityCritical]
static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
{
+#if MONO
+ throw new NotImplementedException ();
+#else
StartNoGCRegionStatus status = (StartNoGCRegionStatus)_StartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);
if (status == StartNoGCRegionStatus.AmountTooLarge)
throw new ArgumentOutOfRangeException("totalSize",
else if (status == StartNoGCRegionStatus.NotEnoughMemory)
return false;
return true;
+#endif
}
[SecurityCritical]
[SecurityCritical]
static EndNoGCRegionStatus EndNoGCRegionWorker()
{
+#if MONO
+ throw new NotImplementedException ();
+#else
EndNoGCRegionStatus status = (EndNoGCRegionStatus)_EndNoGCRegion();
if (status == EndNoGCRegionStatus.NotInProgress)
throw new InvalidOperationException("NoGCRegion mode must be set");
throw new InvalidOperationException("Allocated memory exceeds specified memory for NoGCRegion mode");
return EndNoGCRegionStatus.Succeeded;
+#endif
}
[SecurityCritical]
internal const int UNICODE_CATEGORY_OFFSET = 0;
internal const int BIDI_CATEGORY_OFFSET = 1;
+#pragma warning disable 414
static bool s_initialized = InitTable();
+#pragma warning restore
// The native pointer to the 12:4:4 index table of the Unicode cateogry data.
[SecurityCritical]
[NonSerialized]
private String m_sortName; // The name that defines our behavior
+#if !MONO
[NonSerialized]
private IntPtr m_dataHandle;
[NonSerialized]
private IntPtr m_handleOrigin;
+#endif
////////////////////////////////////////////////////////////////////////
//
// the following fields are defined to keep the compatibility with Whidbey.
// don't change/remove the names/types of these fields.
#if FEATURE_USE_LCID || MONO
+#pragma warning disable 169
[OptionalField(VersionAdded = 1)]
private int win32LCID; // mapped sort culture id of this instance
+#pragma warning restore
private int culture; // the culture ID used to create this instance.
#endif
[OnDeserializing]
{
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "options");
}
+
+#if !MONO
byte[] keyData = null;
+#endif
// The OS doesn't have quite the same behavior so we have to test for empty inputs
if (String.IsNullOrEmpty(source))
{
+#if !MONO
// Empty strings get an empty sort key
keyData = EmptyArray<Byte>.Value;
+#endif
// Fake value to test though so we can verify our flags
source = "\x0000";
}
[OptionalField(VersionAdded = 1)]
private bool m_useUserOverride;
#if !FEATURE_CORECLR
+#pragma warning disable 169
[OptionalField(VersionAdded = 1)]
private bool bUseCalendarInfo;
[OptionalField(VersionAdded = 1)]
internal bool m_isDefaultCalendar; // NEVER USED, DO NOT USE THIS! (Serialized in Whidbey)
[OptionalField(VersionAdded = 2)]
private static volatile Hashtable s_calendarNativeNames; // NEVER USED, DO NOT USE THIS! (Serialized in Whidbey)
+#pragma warning restore
#endif // !FEATURE_CORECLR
// This was synthesized by Whidbey so we knew what words might appear in the middle of a date string
ClearTokenHashTable();
}
}
-
+#if !MONO
// Whitespaces that we allow in the month names.
// U+00a0 is non-breaking space.
static char[] MonthSpaces = {' ', '\u00a0'};
+#endif
internal bool HasSpacesInMonthNames {
get {
parseInfo.fAllowInnerWhite = ((styles & DateTimeStyles.AllowInnerWhite) != 0);
parseInfo.fAllowTrailingWhite = ((styles & DateTimeStyles.AllowTrailingWhite) != 0);
+#if !MONO
// We need the original values of the following two below.
String originalFormat = formatParam;
+#endif
if (formatParam.Length == 1) {
if (((result.flags & ParseFlags.CaptureOffset) != 0) && formatParam[0] == 'U') {
[System.Security.SecuritySafeCritical] // auto-generated
private static EraInfo[] GetErasFromRegistry()
{
+#if MONO
+ return null;
+#else
// Look in the registry key and see if we can find any ranges
int iFoundEras = 0;
EraInfo[] registryEraRanges = null;
-#if !MONO
+
try
{
// Need to access registry
registryEraRanges[i].maxEraYear = registryEraRanges[i-1].yearOffset + 1 - registryEraRanges[i].yearOffset;
}
}
-#endif
+
// Return our ranges
return registryEraRanges;
+#endif
}
//
m_NlsVersion = nlsVersion;
if(customVersion == Guid.Empty) {
+#if !MONO
byte[] b = BitConverter.GetBytes(effectiveId);
+#endif
byte b1 = (byte) ((uint) effectiveId >> 24);
byte b2 = (byte) ((effectiveId & 0x00FF0000) >> 16);
byte b3 = (byte) ((effectiveId & 0x0000FF00) >> 8);
// put in InternalReadChars.
int charsRead = 0;
int numBytes = 0;
- long posSav = posSav = 0;
+ long posSav = 0;
if (m_stream.CanSeek)
posSav = m_stream.Position;
[System.Security.SecuritySafeCritical]
get
{
+#pragma warning disable 219
String demandDir;
+#pragma warning restore
if (this is DirectoryInfo)
demandDir = Directory.GetDemandDir(FullPath, true);
else
[System.Security.SecurityCritical]
get
{
+#pragma warning disable 219
String demandDir;
+#pragma warning restore
if (this is DirectoryInfo)
demandDir = Directory.GetDemandDir(FullPath, true);
else
// This information isn't guaranteed to be correct, but is our second
// best effort at a file or directory involved, after the exception
// message.
+#pragma warning disable 414
[NonSerialized]
private String _maybeFullPath; // For debuggers on partial trust code
+#pragma warning restore
public IOException()
: base(Environment.GetResourceString("Arg_IOException")) {
// write any buffered data to those streams even during finalization, which
// is generally the right thing to do.
if (stream != null) {
+#pragma warning disable 184
// Note: flush on the underlying stream can throw (ex., low disk space)
if (disposing || (LeaveOpen && stream is __ConsoleStream))
{
+#pragma warning restore
#if FEATURE_ASYNC_IO
CheckAsyncTaskInProgress();
#endif
// Jun 08: for cases other than ACCESS_DENIED, we'll assert instead of throw to give release builds more opportunity to fallback.
//
-
+#pragma warning disable 168
catch (FileLoadException fle)
+#pragma warning restore
{
#if !MONO
// Ignore cases where the loader gets an access
private bool UseManifest; // Use Assembly manifest, or grovel disk.
+#pragma warning disable 414
// unused! But need to keep for serialization
[OptionalField(VersionAdded = 1)]
private bool UseSatelliteAssem; // Are all the .resources files in the
// main assembly, or in satellite assemblies for each culture?
+#pragma warning restore
#if RESOURCE_SATELLITE_CONFIG
private static volatile Hashtable _installedSatelliteInfo; // Give the user the option
// to prevent certain satellite assembly probes via a config file.
// My private debugging aid. Set to 5 or 6 for verbose output. Set to 3
// for summary level information.
internal static readonly int DEBUG = 0; //Making this const causes C# to consider all of the code that it guards unreachable.
-
+#if FEATURE_APPX
private static volatile bool s_IsAppXModel;
+#endif
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
private void Init()
#region Non-TransparentProxy case
if (name == null)
throw new ArgumentNullException("name");
-
+#if MONO
+ throw new NotImplementedException ();
+#else
bool[] isByRef = modifiers == null ? null : modifiers[0].IsByRefArray;
// pass LCID_ENGLISH_US if no explicit culture is specified to match the behavior of VB
int lcid = (culture == null ? 0x0409 : culture.LCID);
-#if MONO
- throw new NotImplementedException ();
-#else
return InvokeDispMethod(name, bindingFlags, target, providedArgs, isByRef, lcid, namedParams);
#endif
#endregion
if (binder == null)
binder = DefaultBinder;
+#if !MONO
bool bDefaultBinder = (binder == DefaultBinder);
+#endif
#endregion
#region Delegate to Activator.CreateInstance
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
internal sealed class TypeDependencyAttribute: Attribute
{
-
+#pragma warning disable 414
private string typeName;
+#pragma warning restore
public TypeDependencyAttribute (string typeName)
{
{
// Private members that will hold the relevant details.
private Exception m_Exception;
+#if !MONO
private string m_remoteStackTrace;
+#endif
private object m_stackTrace;
+#if !MONO
private object m_dynamicMethods;
private UIntPtr m_IPForWatsonBuckets;
private Object m_WatsonBuckets;
+#endif
private ExceptionDispatchInfo(Exception exception)
{
#endif
}
+#if !MONO
internal UIntPtr IPForWatsonBuckets
{
get
return m_WatsonBuckets;
}
}
+#endif
internal object BinaryStackTraceArray
{
}
}
+#if !MONO
internal object DynamicMethodArray
{
get
return m_remoteStackTrace;
}
}
+#endif
// This static method is used to create an instance of ExceptionDispatchInfo for
// the specified exception object and save all the required details that maybe
internal sealed class BinaryMethodCall
{
+#if FEATURE_REMOTING
String uri;
+#endif
String methodName;
String typeName;
+#if FEATURE_REMOTING
Type[] instArgs;
+#endif
Object[] args;
+#if FEATURE_REMOTING
Object methodSignature;
+#endif
Object callContext;
+#if FEATURE_REMOTING
String scallContext;
Object properties;
+#endif
Type[] argTypes;
bool bArgsPrimitive = true;
MessageEnum messageEnum;
// if not the args are written out as a separate array
internal Object[] WriteArray(String uri, String methodName, String typeName, Type[] instArgs, Object[] args, Object methodSignature, Object callContext, Object[] properties)
{
+#if FEATURE_REMOTING
this.uri = uri;
+#endif
this.methodName = methodName;
this.typeName = typeName;
+#if FEATURE_REMOTING
this.instArgs = instArgs;
+#endif
this.args = args;
+#if FEATURE_REMOTING
this.methodSignature = methodSignature;
+#endif
this.callContext = callContext;
+#if FEATURE_REMOTING
this.properties = properties;
+#endif
int arraySize = 0;
if (args == null || args.Length == 0)
{
if (callContext is String)
BinaryUtil.NVTraceI("callContext", (String)callContext);
+#if FEATURE_REMOTING
else
BinaryUtil.NVTraceI("callContext", scallContext);
+#endif
}
if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
{
Object returnValue;
Object[] args;
+#if FEATURE_REMOTING
Exception exception;
+#endif
Object callContext;
+#if FEATURE_REMOTING
String scallContext;
Object properties;
+#endif
Type[] argTypes;
bool bArgsPrimitive = true;
MessageEnum messageEnum;
this.returnValue = returnValue;
this.args = args;
+#if FEATURE_REMOTING
this.exception = exception;
+#endif
this.callContext = callContext;
+#if FEATURE_REMOTING
this.properties = properties;
+#endif
int arraySize = 0;
if (args == null || args.Length == 0)
{
if (callContext is String)
BinaryUtil.NVTraceI("callContext", (String)callContext);
+#if FEATURE_REMOTING
else
BinaryUtil.NVTraceI("callContext", scallContext);
+#endif
}
if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
}
internal BinaryObjectString binaryObjectString;
+#if !MONO
internal BinaryCrossAppDomainString binaryCrossAppDomainString;
+#endif
internal void WriteObjectString(int objectId, String value)
{
private void WriteArrayAsBytes(Array array, int typeLength)
{
InternalWriteItemNull();
+#if !MONO
int byteLength = array.Length*typeLength;
+#endif
int arrayOffset = 0;
if (byteBuffer == null)
byteBuffer = new byte[chunkSize];
internal BinaryAssembly binaryAssembly;
+#if !MONO
internal BinaryCrossAppDomainAssembly crossAppDomainAssembly;
+#endif
internal void WriteAssembly(Type type, String assemblyString, int assemId, bool isNew)
{
[Serializable]
internal sealed class BinaryMethodCallMessage
{
+#pragma warning disable 414
Object[] _inargs = null;
+#pragma warning restore
String _methodName = null;
String _typeName = null;
Object _methodSignature = null;
[Serializable]
internal class BinaryMethodReturnMessage
{
+#pragma warning disable 414
Object[] _outargs = null;
+#pragma warning restore
Exception _exception = null;
Object _returnValue = null;
internal Object m_topObject;
internal Header[] headers;
internal HeaderHandler handler;
+#pragma warning disable 649
internal SerObjectInfoInit serObjectInfoInit;
+#pragma warning restore
internal IFormatterConverter m_formatterConverter;
// Stack of Object ParseRecords
{
SerTrace.Log( this, "ParseArray Entry");
+#if !MONO
long genId = pr.PRobjectId;
+#endif
if (pr.PRarrayTypeEnum == InternalArrayTypeE.Base64)
{
ParseRecord objectPr = (ParseRecord)stack.Peek();
+#if !MONO
String objName = null;
if (objectPr != null)
objName = objectPr.PRname;
+#endif
#if _DEBUG
SerTrace.Log( this, "ParseMember ",objectPr.PRobjectId," ",pr.PRname);
TypeInformation typeInfo = BinaryFormatter.GetTypeInformation(resolvedType);
if (typeInfo.HasTypeForwardedFrom)
{
+#pragma warning disable 219
Assembly typeFowardedFromAssembly = null;
+#pragma warning restore
try
{
// if this Assembly.Load failed, we still want to throw security exception
{
for (int i=0; i<Count(); i++)
{
+#if _DEBUG
Object obj = objects[i];
-#if _DEBUG
SerTrace.Log(this, "Stack Dump ",stackId," "+((obj is ITrace)?((ITrace)obj).Trace():""));
#endif
}
internal long m_fixupCount;
internal ISurrogateSelector m_selector;
internal StreamingContext m_context;
+#if !FEATURE_PAL
bool m_isCrossAppDomain;
+#endif
[System.Security.SecuritySafeCritical] // auto-generated
public ObjectManager(ISurrogateSelector selector, StreamingContext context) : this(selector, context, true, false) {
m_objects = new ObjectHolder[DefaultInitialSize];
m_selector = selector;
m_context = context;
+#if !FEATURE_PAL
m_isCrossAppDomain = isCrossAppDomain;
+#endif
}
int[] arrayIndex = null;
ValueTypeFixupInfo currFixup=null;
Object fixupObj=holder.ObjectValue;
+#if false
ObjectHolder originalHolder = holder;
+#endif
Contract.Assert(holder!=null, "[TypedReferenceBuilder.ctor]holder!=null");
Contract.Assert(holder.RequiresValueTypeFixup, "[TypedReferenceBuilder.ctor]holder.RequiresValueTypeFixup");
// Traverse the hierarchy to find all methods with the particular attribute
while (baseType != null && baseType != typeof(Object))
{
+#if !MONO
RuntimeType rt = (RuntimeType)baseType;
+#endif
// Get all methods which are declared on this type, instance and public or nonpublic
MethodInfo[] mis = baseType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
#if _DEBUG
// Invoke all OnSerializingMethods
if (m_OnSerializingMethods != null)
{
+#if !MONO
Object[] p = new Object[] {context};
+#endif
SerializationEventHandler handler = null;
foreach(MethodInfo m in m_OnSerializingMethods)
{
// Invoke all OnDeserializingMethods
if (m_OnDeserializingMethods != null)
{
+#if !MONO
Object[] p = new Object[] {context};
+#endif
SerializationEventHandler handler = null;
foreach(MethodInfo m in m_OnDeserializingMethods)
{
// Invoke all OnDeserializingMethods
if (m_OnDeserializedMethods != null)
{
+#if !MONO
Object[] p = new Object[] {context};
+#endif
SerializationEventHandler handler = null;
foreach(MethodInfo m in m_OnDeserializedMethods)
{
switch (enumerator.Name)
{
case VersionKey:
- string version = info.GetString(VersionKey);
+ info.GetString(VersionKey);
break;
case AuthenticationTypeKey:
private string _hashName;
private byte[] _password;
private HashAlgorithm _hash;
+#if !MONO
private CspParameters _cspParams;
-#if !MONO
+
[System.Security.SecurityCritical] // auto-generated
private SafeProvHandle _safeProvHandle = null;
private SafeProvHandle ProvHandle {
this.Salt = salt;
this.HashName = hashName;
_password = password;
+#if !MONO
_cspParams = cspParams;
+#endif
}
//
private byte[] m_salt;
private HMACSHA1 m_hmacsha1; // The pseudo-random generator function used in PBKDF2
private byte[] m_password;
+#if !MONO
private CspParameters m_cspParams = new CspParameters();
+#endif
private uint m_iterations;
private uint m_block;
using System.Security.Permissions;
using System.Diagnostics.Contracts;
+#if !MONO
// Object layout of the RSAParameters structure
internal class RSACspObject {
internal byte[] Exponent;
internal byte[] InverseQ;
internal byte[] D;
}
+#endif
[System.Runtime.InteropServices.ComVisible(true)]
public sealed partial class RSACryptoServiceProvider : RSA
}
while (true) {
+#if !MONO
int p = pos;
int i = pos;
+#endif
while (pos < len) {
ch = format[pos];
StringBuilder fmt = null;
if (ch == ':') {
pos++;
+#if !MONO
p = pos;
i = pos;
+#endif
while (true) {
if (pos == len) FormatError();
ch = format[pos];
if (newValue == null)
newValue = "";
+#if !MONO
int deltaLength = newValue.Length - oldValue.Length;
+#endif
int[] replacements = null; // A list of replacement positions in a chunk to apply
int replacementsCount = 0;
{
// Replacing mutates the blocks, so we need to convert to logical index and back afterward.
int index = indexInChunk + chunk.m_ChunkOffset;
+#if !MONO
int indexBeforeAdjustment = index;
+#endif
// See if we accumulated any replacements, if so apply them
ReplaceAllInChunk(replacements, replacementsCount, chunk, oldValue.Length, newValue);
/// <typeparam name="T">The kind of elements contained within.</typeparam>
internal class SparselyPopulatedArray<T> where T : class
{
+#if DEBUG
private readonly SparselyPopulatedArrayFragment<T> m_head;
+#endif
private volatile SparselyPopulatedArrayFragment<T> m_tail;
/// <summary>
/// <param name="initialSize">How many array slots to pre-allocate.</param>
internal SparselyPopulatedArray(int initialSize)
{
- m_head = m_tail = new SparselyPopulatedArrayFragment<T>(initialSize);
+#if DEBUG
+ m_head =
+#endif
+ m_tail = new SparselyPopulatedArrayFragment<T>(initialSize);
}
#if DEBUG
else
{
//This is the original 4.0 behaviour
- var asyncResult = beginMethod(iar =>
+ beginMethod(iar =>
{
FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
}, state);
else
{
//quirk for previous versions
- var asyncResult = beginMethod(arg1, iar =>
+ beginMethod(arg1, iar =>
{
FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
}, state);
else
{
//quirk for previous versions
- var asyncResult = beginMethod(arg1, arg2, iar =>
+ beginMethod(arg1, arg2, iar =>
{
FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
}, state);
else
{
//quirk for previous versions
- var asyncResult = beginMethod(arg1, arg2, arg3, iar =>
+ beginMethod(arg1, arg2, arg3, iar =>
{
FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
}, state);
get { return m_cancellationToken; }
set
{
+#if !MONO
if (value == null)
throw new ArgumentNullException("CancellationToken");
+#endif
m_cancellationToken = value;
}
}
}
}
+#if !MONO
// ETW event for Parallel Invoke Begin
int forkJoinContextID = 0;
Task callerTask = null;
-#if !MONO
+
if (TplEtwProvider.Log.IsEnabled())
{
forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
}, null);
}
+#if !MONO
// ETW event for Parallel For begin
int forkJoinContextID = 0;
Task callingTask = null;
-#if !MONO
+
if (TplEtwProvider.Log.IsEnabled())
{
forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
}, null);
}
+#if !MONO
// ETW event for Parallel For begin
Task callerTask = null;
int forkJoinContextID = 0;
-#if !MONO
+
if (TplEtwProvider.Log.IsEnabled())
{
forkJoinContextID = Interlocked.Increment(ref s_forkJoinContextID);
/// </summary>
internal class ParallelLoopStateFlags
{
+#pragma warning disable 649
internal static int PLS_NONE;
+#pragma warning restore
internal static int PLS_EXCEPTIONAL = 1;
internal static int PLS_BROKEN = 2;
internal static int PLS_STOPPED = 4;
{
oldState = m_LoopStateFlags;
if ((oldState & illegalStates) != 0) return false;
+#pragma warning disable 420
if (Interlocked.CompareExchange(ref m_LoopStateFlags, oldState | newState, oldState) == oldState)
+#pragma warning restore
{
return true;
}
/// <summary>The action to invoke.</summary>
protected readonly Action m_action;
+#if !MONO
protected int m_continuationId;
+#endif
/// <summary>Initializes the continuation.</summary>
/// <param name="action">The action to invoke. Must not be null.</param>
throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong",name));
}
Contract.EndContractBlock();
- Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
#if !MONO
+ Win32Native.SECURITY_ATTRIBUTES secAttrs = null;
+
#if FEATURE_MACL
// For ACL's, get the security descriptor from the EventWaitHandleSecurity.
if (eventSecurity != null) {
// The head and tail of the queue. We enqueue to the head, and dequeue from the tail.
internal volatile QueueSegment queueHead;
internal volatile QueueSegment queueTail;
+#if !MONO
internal bool loggingEnabled;
+#endif
internal static SparseArray<WorkStealingQueue> allThreadQueues = new SparseArray<WorkStealingQueue>(16); //
public struct TypedReference
{
#if MONO
+#pragma warning disable 169
RuntimeTypeHandle type;
+#pragma warning restore
#endif
private IntPtr Value;
private IntPtr Type;
--- /dev/null
+// CS0029: Cannot implicitly convert type `string' to `int'
+// Line: 8
+
+class A<T> where T : CB, IA
+{
+ void Foo (T t)
+ {
+ t.Prop = "3";
+ }
+}
+
+class CB : CA
+{
+}
+
+class CA
+{
+ public int Prop { get; set; }
+}
+
+interface IA
+{
+ string Prop { get; set; }
+}
\ No newline at end of file
--- /dev/null
+// CS0122: `A.Y' is inaccessible due to its protection level
+// Line: 8
+
+public class Test
+{
+ public static void Main ()
+ {
+ var x = nameof (A.Y);
+ }
+}
+
+public class A
+{
+ private int Y { get; set; }
+}
\ No newline at end of file
--- /dev/null
+// CS0219: The constant `C' is never used
+// Line: 9
+// Compiler options: -warn:3 -warnaserror
+
+class C
+{
+ public static void Main ()
+ {
+ const int C = 1;
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS0619: `A.X' is obsolete: `'
+// Line: 10
+
+using System;
+
+public class Test
+{
+ public static void Main()
+ {
+ var m = nameof (A.X);
+ }
+}
+
+public class A
+{
+ [Obsolete ("", true)]
+ public int X;
+}
--- /dev/null
+// CS1070: The type `C' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `CS1070-lib-missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
+// Line: 5
+// Compiler options: -r:CS1070-lib.dll
+
+public class D
+{
+ static void Main ()
+ {
+ new C ();
+ }
+}
\ No newline at end of file
--- /dev/null
+// CS1501: No overload for method `Call' takes `0' arguments
+// Line: 8
+
+class A<T> where T : CB, IA
+{
+ void Foo (T t)
+ {
+ t.Call ();
+ }
+}
+
+class CB : CA
+{
+}
+
+class CA
+{
+ public void Call (int arg)
+ {
+ }
+}
+
+interface IA
+{
+ void Call (bool arg, int arg2);
+}
throw new InternalErrorException (tc, e);
}
}
+
+ if (PartialContainer != null && PartialContainer != this) {
+ containers = null;
+ }
}
return true;
public override void ExpandBaseInterfaces ()
{
+ DoResolveTypeParameters ();
+
if (!IsPartialPart)
DoExpandBaseInterfaces ();
protected override void DoDefineContainer ()
{
DefineBaseTypes ();
-
- DoResolveTypeParameters ();
}
//
this.name = name;
}
- static void Error_MethodGroupWithTypeArguments (ResolveContext rc, Location loc)
- {
- rc.Report.Error (8084, loc, "An argument to nameof operator cannot be method group with type arguments");
- }
-
protected override Expression DoResolve (ResolveContext rc)
{
throw new NotSupportedException ();
rc.Report.FeatureIsNotAvailable (rc.Module.Compiler, Location, "nameof operator");
var res = sn.LookupNameExpression (rc, MemberLookupRestrictions.IgnoreAmbiguity | MemberLookupRestrictions.NameOfExcluded);
- if (sn.HasTypeArguments && res is MethodGroupExpr) {
- Error_MethodGroupWithTypeArguments (rc, expr.Location);
- }
+ var me = res as MemberExpr;
+ if (me != null)
+ me.ResolveNameOf (rc, sn);
return true;
}
return false;
}
- var mg = res as MethodGroupExpr;
- if (mg != null) {
- var emg = res as ExtensionMethodGroupExpr;
- if (emg != null && !emg.ResolveNameOf (rc, ma)) {
- return true;
- }
-
- if (!mg.HasAccessibleCandidate (rc)) {
- ErrorIsInaccesible (rc, ma.GetSignatureForError (), loc);
- }
-
- if (ma.HasTypeArguments) {
- Error_MethodGroupWithTypeArguments (rc, ma.Location);
- }
+ var me = res as MemberExpr;
+ if (me != null) {
+ me.ResolveNameOf (rc, ma);
}
//
public static Expression MemberLookup (IMemberContext rc, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc)
{
var members = MemberCache.FindMembers (queried_type, name, false);
- if (members == null)
- return null;
- Expression expr;
- do {
- expr = MemberLookupToExpression (rc, members, errorMode, queried_type, name, arity, restrictions, loc);
- if (expr != null)
- return expr;
+ if (members != null) {
+ Expression expr;
+ do {
+ expr = MemberLookupToExpression (rc, members, errorMode, queried_type, name, arity, restrictions, loc);
+ if (expr != null)
+ return expr;
- if (members [0].DeclaringType.BaseType == null)
- members = null;
- else
- members = MemberCache.FindMembers (members [0].DeclaringType.BaseType, name, false);
- } while (members != null);
+ if (members [0].DeclaringType.BaseType == null)
+ members = null;
+ else
+ members = MemberCache.FindMembers (members [0].DeclaringType.BaseType, name, false);
+ } while (members != null);
+ }
+
+ var tps = queried_type as TypeParameterSpec;
+ if (tps != null) {
+ members = MemberCache.FindInterfaceMembers (tps, name);
+ if (members != null)
+ return MemberLookupToExpression (rc, members, errorMode, queried_type, name, arity, restrictions, loc);
+ }
- return expr;
+ return null;
}
public static Expression MemberLookupToExpression (IMemberContext rc, IList<MemberSpec> members, bool errorMode, TypeSpec queried_type, string name, int arity, MemberLookupRestrictions restrictions, Location loc)
if ((restrictions & MemberLookupRestrictions.InvocableOnly) != 0) {
if (member is MethodSpec) {
- //
- // Interface members that are hidden by class members are removed from the set. This
- // step only has an effect if T is a type parameter and T has both an effective base
- // class other than object and a non-empty effective interface set
- //
- var tps = queried_type as TypeParameterSpec;
- if (tps != null && tps.HasTypeConstraint)
- members = RemoveHiddenTypeParameterMethods (members);
-
return new MethodGroupExpr (members, queried_type, loc);
}
return null;
}
- static IList<MemberSpec> RemoveHiddenTypeParameterMethods (IList<MemberSpec> members)
- {
- if (members.Count < 2)
- return members;
-
- //
- // If M is a method, then all non-method members declared in an interface declaration
- // are removed from the set, and all methods with the same signature as M declared in
- // an interface declaration are removed from the set
- //
-
- bool copied = false;
- for (int i = 0; i < members.Count; ++i) {
- var method = members[i] as MethodSpec;
- if (method == null) {
- if (!copied) {
- copied = true;
- members = new List<MemberSpec> (members);
- }
-
- members.RemoveAt (i--);
- continue;
- }
-
- if (!method.DeclaringType.IsInterface)
- continue;
-
- for (int ii = 0; ii < members.Count; ++ii) {
- var candidate = members[ii] as MethodSpec;
- if (candidate == null || !candidate.DeclaringType.IsClass)
- continue;
-
- if (!TypeSpecComparer.Override.IsEqual (candidate.Parameters, method.Parameters))
- continue;
-
- if (!AParametersCollection.HasSameParameterDefaults (candidate.Parameters, method.Parameters))
- continue;
-
- if (!copied) {
- copied = true;
- members = new List<MemberSpec> (members);
- }
-
- members.RemoveAt (i--);
- break;
- }
- }
-
- return members;
- }
-
protected static void Error_NamedArgument (NamedArgument na, Report Report)
{
Report.Error (1742, na.Location, "An element access expression cannot use named argument");
return this;
}
+ public virtual void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+ {
+
+ }
+
protected void EmitInstance (EmitContext ec, bool prepare_for_load)
{
var inst = new InstanceEmitter (InstanceExpression, TypeSpec.IsValueType (InstanceExpression.Type));
// For extension methodgroup we are not looking for base members but parent
// namespace extension methods
//
- public override IList<MemberSpec> GetBaseMembers (TypeSpec baseType)
+ public override IList<MemberSpec> GetBaseMembers (TypeSpec type)
{
// TODO: candidates are null only when doing error reporting, that's
// incorrect. We have to discover same extension methods in error mode
Convert.ImplicitBoxingConversion (null, argType, extensionType) != null;
}
- public bool ResolveNameOf (ResolveContext rc, MemberAccess ma)
+ public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
{
- rc.Report.Error (8093, ma.Location, "An argument to nameof operator cannot be extension method group");
-
- // Not included in C#6
- /*
- ExtensionExpression = ExtensionExpression.Resolve (rc);
- if (ExtensionExpression == null)
- return false;
-
- var argType = ExtensionExpression.Type;
- foreach (MethodSpec candidate in Candidates) {
- if (ExtensionMethodGroupExpr.IsExtensionTypeCompatible (argType, candidate.Parameters.ExtensionMethodType))
- return true;
- }
-
- // TODO: Scan full hierarchy
-
- ma.Error_TypeDoesNotContainDefinition (rc, argType, ma.Name);
- */
- return false;
+ rc.Report.Error (8093, expr.Location, "An argument to nameof operator cannot be extension method group");
}
public override MethodGroupExpr LookupExtensionMethod (ResolveContext rc)
return base.ResolveMemberAccess (ec, left, original);
}
+ public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+ {
+ if (!HasAccessibleCandidate (rc)) {
+ ErrorIsInaccesible (rc, expr.GetSignatureForError (), loc);
+ }
+
+ if (expr.HasTypeArguments) {
+ rc.Report.Error (8084, expr.Location, "An argument to nameof operator cannot be method group with type arguments");
+ }
+ }
+
public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
{
type_arguments = ta;
#region IBaseMembersProvider Members
- public virtual IList<MemberSpec> GetBaseMembers (TypeSpec baseType)
+ public virtual IList<MemberSpec> GetBaseMembers (TypeSpec type)
{
- return baseType == null ? null : MemberCache.FindMembers (baseType, Methods [0].Name, false);
+ var baseType = type.BaseType;
+
+ IList<MemberSpec> members = baseType == null ? null : MemberCache.FindMembers (baseType, Methods [0].Name, false);
+
+ if (members == null && !type.IsInterface) {
+ var tps = queried_type as TypeParameterSpec;
+ if (tps != null)
+ members = MemberCache.FindInterfaceMembers (tps, Methods [0].Name);
+ }
+
+ return members;
}
public IParametersMember GetOverrideMemberParameters (MemberSpec member)
// Restore expanded arguments
candidate_args = args;
}
- } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType.BaseType)) != null);
+ } while (best_candidate_rate != 0 && (type_members = base_provider.GetBaseMembers (type_members[0].DeclaringType)) != null);
//
// We've found exact match
return constant.GetSignatureForError ();
}
+ public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+ {
+ constant.CheckObsoleteness (rc, expr.Location);
+ }
+
public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
{
Error_TypeArgumentsCannotBeUsed (ec, "constant", GetSignatureForError (), loc);
return this;
}
+ public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+ {
+ spec.CheckObsoleteness (rc, expr.Location);
+ }
+
public void SetFieldAssigned (FlowAnalysisContext fc)
{
if (!IsInstance)
return true;
}
+ public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+ {
+ if (!best_candidate.IsAccessible (rc))
+ ErrorIsInaccesible (rc, best_candidate.GetSignatureForError (), expr.Location);
+
+ best_candidate.CheckObsoleteness (rc, expr.Location);
+ }
+
public void SetBackingFieldAssigned (FlowAnalysisContext fc)
{
if (backing_field != null) {
return TypeManager.CSharpSignature (spec);
}
+ public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+ {
+ spec.CheckObsoleteness (rc, expr.Location);
+ }
+
public override void SetTypeArguments (ResolveContext ec, TypeArguments ta)
{
Error_TypeArgumentsCannotBeUsed (ec, "event", GetSignatureForError (), loc);
public override Expression ConvertResult (ResolveContext ec, Binary b)
{
if (left != null) {
- b.left = EmptyCast.Create (b.left, left);
+ b.left = Convert.UserDefinedConversion (ec, b.left, left, Convert.UserConversionRestriction.ImplicitOnly, b.loc) ?? EmptyCast.Create (b.left, left);
} else if (right != null) {
- b.right = EmptyCast.Create (b.right, right);
+ b.right = Convert.UserDefinedConversion (ec, b.right, right, Convert.UserConversionRestriction.ImplicitOnly, b.loc) ?? EmptyCast.Create (b.right, right);
}
TypeSpec r_type = ReturnType;
#region IBaseMembersProvider Members
- IList<MemberSpec> OverloadResolver.IBaseMembersProvider.GetBaseMembers (TypeSpec baseType)
+ IList<MemberSpec> OverloadResolver.IBaseMembersProvider.GetBaseMembers (TypeSpec type)
{
- return baseType == null ? null : MemberCache.FindMembers (baseType, MemberCache.IndexerNameAlias, false);
+ var baseType = type.BaseType;
+ var members = baseType == null ? null : MemberCache.FindMembers (baseType, MemberCache.IndexerNameAlias, false);
+
+ if (members == null && !type.IsInterface) {
+ var tps = queried_type as TypeParameterSpec;
+ if (tps != null)
+ members = MemberCache.FindInterfaceMembers (tps, MemberCache.IndexerNameAlias);
+ }
+
+ return members;
}
IParametersMember OverloadResolver.IBaseMembersProvider.GetOverrideMemberParameters (MemberSpec member)
int errors = ec.Report.Errors;
type.CreateContainer ();
type.DefineContainer ();
+ type.ExpandBaseInterfaces ();
type.Define ();
if ((ec.Report.Errors - errors) == 0) {
parent.Module.AddAnonymousType (type);
TypeSpec[] targs;
TypeSpec[] ifaces_defined;
TypeSpec effective_base;
+ MemberCache interface_cache;
//
// Creates type owned type parameter
}
}
+ public MemberCache InterfaceCache {
+ get {
+ return interface_cache;
+ }
+ }
+
//
// Unexpanded interfaces list
//
// For a type parameter the membercache is the union of the sets of members of the types
// specified as a primary constraint or secondary constraint
//
+ bool has_user_base_type = false;
if (BaseType.BuiltinType != BuiltinTypeSpec.Type.Object && BaseType.BuiltinType != BuiltinTypeSpec.Type.ValueType) {
cache.AddBaseType (BaseType);
+ has_user_base_type = true;
}
if (InterfacesDefined != null) {
+ var icache = cache;
+ if (has_user_base_type) {
+ //
+ // type-parameter lookup rules are more complicated that other types lookup rules.
+ // Effective base class and its base types member have priority over interface
+ // constraints which means we cannot lookup interface members before class members
+ // hence we setup secondary cache for such cases.
+ //
+ interface_cache = new MemberCache ();
+ icache = interface_cache;
+ }
+
foreach (var iface_type in InterfacesDefined) {
- cache.AddInterface (iface_type);
+ icache.AddInterface (iface_type);
}
}
var ifaces = tps == null ? ta.Interfaces : tps.InterfacesDefined;
if (ifaces != null) {
+ var icache = cache;
+ if (has_user_base_type) {
+ interface_cache = new MemberCache ();
+ icache = interface_cache;
+ }
+
foreach (var iface_type in ifaces) {
- cache.AddInterface (iface_type);
+ icache.AddInterface (iface_type);
}
}
}
compiled_types = new Dictionary<MetaType, TypeSpec> (40, ReferenceEquality<MetaType>.Default);
assembly_2_definition = new Dictionary<Assembly, IAssemblyDefinition> (ReferenceEquality<Assembly>.Default);
IgnorePrivateMembers = true;
+ IgnoreCompilerGeneratedField = true;
}
#region Properties
public bool IgnorePrivateMembers { get; set; }
+ public bool IgnoreCompilerGeneratedField { get; set; }
+
#endregion
public abstract void AddCompiledType (TypeBuilder builder, TypeSpec spec);
break;
default:
// Ignore private fields (even for error reporting) to not require extra dependencies
- if ((IgnorePrivateMembers && !declaringType.IsStruct) ||
- HasAttribute (CustomAttributeData.GetCustomAttributes (fi), "CompilerGeneratedAttribute", CompilerServicesNamespace))
+ if (IgnorePrivateMembers && !declaringType.IsStruct)
+ return null;
+
+ if (IgnoreCompilerGeneratedField && HasAttribute (CustomAttributeData.GetCustomAttributes (fi), "CompilerGeneratedAttribute", CompilerServicesNamespace))
return null;
mod = Modifiers.PRIVATE;
public static MemberSpec FindMember (TypeSpec container, MemberFilter filter, BindingRestriction restrictions)
{
+ if (filter.Kind == MemberKind.Method && container.Kind == MemberKind.TypeParameter && filter.Parameters == null)
+ throw new NotSupportedException ("type parameters methods cannot be lookup up due to two stage setup");
+
+ IList<MemberSpec> applicable;
+ var top_container = container;
+
do {
- IList<MemberSpec> applicable;
if (container.MemberCache.member_hash.TryGetValue (filter.Name, out applicable)) {
// Start from the end because interface members are in reverse order
for (int i = applicable.Count - 1; i >= 0; i--) {
container = container.BaseType;
} while (container != null);
+ var tps = top_container as TypeParameterSpec;
+ if (tps != null && tps.InterfaceCache != null) {
+ if (tps.InterfaceCache.member_hash.TryGetValue (filter.Name, out applicable)) {
+ for (int i = applicable.Count - 1; i >= 0; i--) {
+ var entry = applicable [i];
+
+ if ((restrictions & BindingRestriction.NoAccessors) != 0 && entry.IsAccessor)
+ continue;
+
+ if ((restrictions & BindingRestriction.OverrideOnly) != 0 && (entry.Modifiers & Modifiers.OVERRIDE) == 0)
+ continue;
+
+ if (!filter.Equals (entry))
+ continue;
+
+ return entry;
+ }
+ }
+ }
+
return null;
}
//
public static IList<MemberSpec> FindMembers (TypeSpec container, string name, bool declaredOnlyClass)
{
- IList<MemberSpec> applicable;
-
do {
+ IList<MemberSpec> applicable;
+
if (container.MemberCache.member_hash.TryGetValue (name, out applicable) || declaredOnlyClass)
return applicable;
return null;
}
+ public static IList<MemberSpec> FindInterfaceMembers (TypeParameterSpec typeParameter, string name)
+ {
+ if (typeParameter.InterfaceCache != null) {
+ IList<MemberSpec> applicable;
+ typeParameter.InterfaceCache.member_hash.TryGetValue (name, out applicable);
+ return applicable;
+ }
+
+ return null;
+ }
+
//
// Finds the nested type in container
//
backing_field = new Field (Parent,
new TypeExpression (MemberType, Location),
- Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
+ Modifiers.BACKING_FIELD | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN | Modifiers.PRIVATE | (ModFlags & (Modifiers.STATIC | Modifiers.UNSAFE)),
MemberName, null);
Parent.PartialContainer.Members.Add (backing_field);
backing_field.Initializer = Initializer;
- backing_field.ModFlags &= ~Modifiers.COMPILER_GENERATED;
// Call define because we passed fields definition
backing_field.Define ();
case "/pdb":
case "/preferreduilang":
case "/publicsign":
+ case "/publicsign+":
+ case "/publicsign-":
case "/reportanalyzer":
case "/ruleset":
case "/sqmsessionguid":
public override void Emit (EmitContext ec)
{
+ if (!Variable.IsUsed)
+ ec.Report.Warning (219, 3, loc, "The constant `{0}' is never used", Variable.Name);
+
// Nothing to emit, not even sequence point
}
}
}
+ public bool IsUsed {
+ get {
+ return (flags & Flags.Used) != 0;
+ }
+ }
+
public bool IsFixed {
get {
return (flags & Flags.FixedVariable) != 0;
public Expression CreateReferenceExpression (ResolveContext rc, Location loc)
{
- if (IsConstant && const_value != null)
+ if (IsConstant && const_value != null) {
+ SetIsUsed ();
return Constant.CreateConstantFromValue (Type, const_value.GetValue (), loc);
+ }
return new LocalVariableReference (this, loc);
}
//
storey.CreateContainer ();
storey.DefineContainer ();
+ storey.ExpandBaseInterfaces ();
if (Original.Explicit.HasCapturedThis && Original.ParametersBlock.TopBlock.ThisReferencesFromChildrenBlock != null) {
var imported = MemberDefinition as ImportedTypeDefinition;
if (imported != null && Kind != MemberKind.MissingType)
imported.DefineInterfaces (this);
-
}
return ifaces;
public TypeSpec Element { get; private set; }
+ public override IList<TypeSpec> Interfaces {
+ set {
+ throw new NotSupportedException ();
+ }
+ }
+
bool ITypeDefinition.IsComImport {
get {
return false;
readonly int rank;
readonly ModuleContainer module;
- private ArrayContainer (ModuleContainer module, TypeSpec element, int rank)
+ ArrayContainer (ModuleContainer module, TypeSpec element, int rank)
: base (MemberKind.ArrayType, element, null)
{
this.module = module;
this.rank = rank;
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return BaseType.Interfaces;
+ }
+ }
+
public int Rank {
get {
return rank;
if (!module.ArrayTypesCache.TryGetValue (key, out ac)) {
ac = new ArrayContainer (module, element, rank);
ac.BaseType = module.Compiler.BuiltinTypes.Array;
- ac.Interfaces = ac.BaseType.Interfaces;
module.ArrayTypesCache.Add (key, ac);
}
class ReferenceContainer : ElementTypeSpec
{
- private ReferenceContainer (TypeSpec element)
+ ReferenceContainer (TypeSpec element)
: base (MemberKind.Class, element, null) // TODO: Kind.Class is most likely wrong
{
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return null;
+ }
+ }
+
public override MetaType GetMetaInfo ()
{
if (info == null) {
state &= ~StateFlags.CLSCompliant_Undetected;
}
+ public override IList<TypeSpec> Interfaces {
+ get {
+ return null;
+ }
+ }
+
public override MetaType GetMetaInfo ()
{
if (info == null) {
--- /dev/null
+class X<T1, T2, U>
+ where T1 : class, T2
+ where T2 : class
+ where U : A, T1
+{
+}
+
+class A
+{
+}
+
+class F
+{
+ public static void Main ()
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+class A<T> where T : CB, IA
+{
+ void Foo (T t)
+ {
+ t.Prop = 3;
+ long l = t.Prop2;
+ t["1"] = "2";
+ }
+}
+
+class A2<T, U>
+ where T : CB, U
+ where U : IA
+{
+ void Foo (T t)
+ {
+ t.Prop = 3;
+ long l = t.Prop2;
+ t["1"] = "2";
+ }
+}
+
+class CB : CA
+{
+}
+
+class CA
+{
+ public int Prop { get; set; }
+
+ public string this [byte b] { get { return ""; } }
+}
+
+interface IA
+{
+ string Prop { get; set; }
+ long Prop2 { get; }
+
+ string this [string b] { get; set; }
+}
+
+class X
+{
+ public static void Main ()
+ {
+ }
+}
\ No newline at end of file
using System;
using System.Reflection;
+using System.Runtime.CompilerServices;
[assembly: Test]
Assert (ei.GetRemoveMethod ().GetCustomAttributes (true), false, 44);
Assert (ei.GetRemoveMethod ().ReturnTypeCustomAttributes.GetCustomAttributes (true), false, 45);
FieldInfo fi = typeof(Test_3).GetField ("e_1", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
- Assert (fi.GetCustomAttributes (true), true, 46);
+ Assert (fi.GetCustomAttributes (typeof (CompilerGeneratedAttribute), true), true, 46);
+ Assert (fi.GetCustomAttributes (typeof (TestAttribute), true), true, 47);
ei = typeof(Test_3).GetEvent ("e_2");
Assert (ei.GetCustomAttributes (true), false, 51);
Assert (ei.GetRemoveMethod ().GetCustomAttributes (true), true, 54);
Assert (ei.GetRemoveMethod ().ReturnTypeCustomAttributes.GetCustomAttributes (true), false, 55);
fi = typeof(Test_3).GetField ("e_2", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
- Assert (fi.GetCustomAttributes (true), false, 56);
+ Assert (fi.GetCustomAttributes (typeof (CompilerGeneratedAttribute), true), true, 56);
+ Assert (fi.GetCustomAttributes (typeof (TestAttribute), true), false, 57);
ei = typeof(Test_4).GetEvent ("e_2");
Assert (ei.GetCustomAttributes (true), false, 71);
Assert (ei.GetRemoveMethod ().GetCustomAttributes (true), false, 74);
Assert (ei.GetRemoveMethod ().ReturnTypeCustomAttributes.GetCustomAttributes (true), true, 75);
fi = typeof(Test_3).GetField ("e_2", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
- Assert (fi.GetCustomAttributes (true), false, 76);
+ Assert (fi.GetCustomAttributes (typeof (CompilerGeneratedAttribute), true), true, 76);
+ Assert (fi.GetCustomAttributes (typeof (TestAttribute), true), false, 77);
ei = typeof(Test_4).GetEvent ("e_3");
Assert (ei.GetCustomAttributes (true), false, 81);
Assert (ei.GetRemoveMethod ().ReturnTypeCustomAttributes.GetCustomAttributes (true), false, 86);
Assert (ei.GetRemoveMethod ().GetParameters ()[0].GetCustomAttributes (true), true, 87);
fi = typeof(Test_3).GetField ("e_2", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
- Assert (fi.GetCustomAttributes (true), false, 88);
+ Assert (fi.GetCustomAttributes (typeof (CompilerGeneratedAttribute), true), true, 86);
+ Assert (fi.GetCustomAttributes (typeof (TestAttribute), true), false, 87);
return failed ? 1 : 0;
}
--- /dev/null
+// Compiler options: -unsafe
+
+using System;
+
+struct nint
+{
+ public static nint operator * (nint a, nint b)
+ {
+ return a;
+ }
+
+ public static implicit operator long (nint v)
+ {
+ return 0;
+ }
+}
+
+class X
+{
+ public static void Main ()
+ {
+ nint width;
+ nint bytesPerRow;
+
+ unsafe {
+ var da = (uint*)0;
+ var dp1 = da + width * bytesPerRow;
+ var dp2 = width * bytesPerRow + da;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+partial class A
+{
+}
+
+partial class A
+{
+ enum E
+ {
+ None = 0,
+ All = 1
+ }
+}
+
+class X
+{
+ public static void Main ()
+ {
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
+ <test name="gtest-638.cs">
+ <type name="X`3[T1,T2,U]">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="F">
+ <method name="Void Main()" attrs="150">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
+ <test name="gtest-639.cs">
+ <type name="A`1[T]">
+ <method name="Void Foo(T)" attrs="129">
+ <size>53</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="CB">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="CA">
+ <method name="Int32 get_Prop()" attrs="2182">
+ <size>14</size>
+ </method>
+ <method name="Void set_Prop(Int32)" attrs="2182">
+ <size>8</size>
+ </method>
+ <method name="System.String get_Item(Byte)" attrs="2182">
+ <size>14</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="X">
+ <method name="Void Main()" attrs="150">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="A2`2[T,U]">
+ <method name="Void Foo(T)" attrs="129">
+ <size>53</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="gtest-anontype-01.cs">
<type name="Test">
<method name="Int32 Main()" attrs="150">
<size>80</size>
</method>
<method name="Int32 Main()" attrs="150">
- <size>1169</size>
+ <size>1309</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
+ <test name="test-940.cs">
+ <type name="nint">
+ <method name="nint op_Multiply(nint, nint)" attrs="2198">
+ <size>10</size>
+ </method>
+ <method name="Int64 op_Implicit(nint)" attrs="2198">
+ <size>11</size>
+ </method>
+ </type>
+ <type name="X">
+ <method name="Void Main()" attrs="150">
+ <size>46</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-95.cs">
<type name="X">
<method name="Int32 Main()" attrs="150">
</method>
</type>
</test>
+ <test name="test-partial-35.cs">
+ <type name="A">
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="X">
+ <method name="Void Main()" attrs="150">
+ <size>2</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-pattern-01.cs">
<type name="TypePattern">
<method name="Int32 Main()" attrs="150">
string direction = first && HasExtensionParameter ? "this" : "in";
first = false;
- if (parameter.ParameterType is ByReferenceType)
+ var pt = parameter.ParameterType;
+ var brt = pt as ByReferenceType;
+ if (brt != null) {
direction = parameter.IsOut ? "out" : "ref";
+ pt = brt.ElementType;
+ }
- TypeReference t = parameter.ParameterType;
- AddAttribute ("type", Utils.CleanupTypeName (t));
+ AddAttribute ("type", Utils.CleanupTypeName (pt));
if (parameter.IsOptional) {
AddAttribute ("optional", "true");
ParameterDefinition info = infos [i];
- if (info.ParameterType.IsByReference) {
- string modifier;
- if ((info.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out)
- modifier = "out";
- else
- modifier = "ref";
-
- signature.Append (modifier);
- signature.Append (" ");
- }
-
signature.Append (Utils.CleanupTypeName (info.ParameterType));
}
SUBDIRS =
include ../../build/rules.make
-LIB_REFS = Mono.Security
-LOCAL_MCS_FLAGS = -unsafe
+LIB_REFS = System Mono.Security System.Security
+LOCAL_MCS_FLAGS = -unsafe -define:NO_SYMBOL_WRITER
PROGRAM = gacutil.exe
using System.IO;
using System.Diagnostics;
using System.Text;
-using System.Reflection;
using System.Collections;
using System.Globalization;
using System.Runtime.InteropServices;
using Mono.Security;
using Mono.Security.Cryptography;
+using IKVM.Reflection;
+
namespace Mono.Tools {
public class Driver {
private static bool silent;
static bool in_bootstrap;
+ private static Universe _universe;
public static int Main (string [] args)
{
AssemblyName an = null;
try {
- assembly = Assembly.LoadFrom (name);
+ assembly = ReflectionOnlyLoadFrom (name);
} catch {
WriteLine (string.Format (failure_msg, name) + "The file specified is not a valid assembly.");
return false;
}
}
+ private static Universe GetUniverse () {
+ if (_universe == null) {
+ _universe = new Universe (UniverseOptions.MetadataOnly);
+ }
+ return _universe;
+ }
+
+ private static Assembly ReflectionOnlyLoadFrom (string fileName)
+ {
+ return GetUniverse ().LoadFile (fileName);
+ }
+ private static AssemblyName GetCorlibName ()
+ {
+ return GetUniverse ().Mscorlib.GetName ();
+ }
+
private static bool CheckReferencedAssemblies (AssemblyName an)
{
- AppDomain d = null;
try {
- Assembly a = Assembly.LoadFrom (an.CodeBase);
- AssemblyName corlib = typeof (object).Assembly.GetName ();
+ Assembly a = ReflectionOnlyLoadFrom (an.CodeBase);
+ AssemblyName corlib = GetCorlibName ();
foreach (AssemblyName ref_an in a.GetReferencedAssemblies ()) {
if (ref_an.Name == corlib.Name) // Just do a string compare so we can install on diff versions
} catch (Exception e) {
WriteLine (e.ToString ()); // This should be removed pre beta3
return false;
- } finally {
- if (d != null) {
- try {
- AppDomain.Unload (d);
- } catch { }
- }
}
return true;
static bool LoadConfig (bool quiet)
{
- MethodInfo config = typeof (System.Environment).GetMethod ("GetMachineConfigPath",
- BindingFlags.Static | BindingFlags.NonPublic);
+ System.Reflection.MethodInfo config = typeof (System.Environment).GetMethod ("GetMachineConfigPath",
+ System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
if (config != null) {
string path = (string) config.Invoke (null, null);
// Note: MustVerify is based on the original token (by design). Public key
// remapping won't affect if the assembly is verified or not.
- if (StrongNameManager.MustVerify (an)) {
+ if (StrongNameManager.MustVerify (new System.Reflection.AssemblyName (an.FullName))) {
RSA rsa = CryptoConvert.FromCapiPublicKeyBlob (publicKey, 12);
StrongName sn = new StrongName (rsa);
if (sn.Verify (assemblyFile)) {
public static extern int symlink (string oldpath, string newpath);
private static string GetGacDir () {
- PropertyInfo gac = typeof (System.Environment).GetProperty ("GacPath",
- BindingFlags.Static|BindingFlags.NonPublic);
+ System.Reflection.PropertyInfo gac = typeof (System.Environment).GetProperty ("GacPath",
+ System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.NonPublic);
if (gac == null) {
WriteLine ("ERROR: Mono runtime not detected, please use " +
"the mono runtime for gacutil.exe");
Environment.Exit (1);
}
- MethodInfo get_gac = gac.GetGetMethod (true);
+ System.Reflection.MethodInfo get_gac = gac.GetGetMethod (true);
return (string) get_gac.Invoke (null, null);
}
private static string GetLibDir () {
- MethodInfo libdir = typeof (System.Environment).GetMethod ("internalGetGacPath",
- BindingFlags.Static|BindingFlags.NonPublic);
+ System.Reflection.MethodInfo libdir = typeof (System.Environment).GetMethod ("internalGetGacPath",
+ System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.NonPublic);
if (libdir == null) {
WriteLine ("ERROR: Mono runtime not detected, please use " +
"the mono runtime for gacutil.exe");
driver.cs
../security/StrongNameManager.cs
+../../../external/ikvm/reflect/*.cs
+../../../external/ikvm/reflect/Metadata/*.cs
+../../../external/ikvm/reflect/Emit/*.cs
+../../../external/ikvm/reflect/Reader/*.cs
+../../../external/ikvm/reflect/Writer/*.cs
+../../../external/ikvm/reflect/Impl/ITypeOwner.cs
+../../../external/ikvm/reflect/Impl/SymbolSupport.cs
using System.Text;
using IKVM.Reflection;
using System.Linq;
-using System.Diagnostics;
using System.Net;
using System.Threading.Tasks;
static string output = "a.out";
static string object_out = null;
static List<string> link_paths = new List<string> ();
+ static Dictionary<string,string> libraries = new Dictionary<string,string> ();
static bool autodeps = false;
static bool keeptemp = false;
static bool compile_only = false;
cross_target = args [++i];
break;
+ case "--library":
+ if (i+1 == top){
+ Help ();
+ return 1;
+ }
+ if (custom_mode){
+ Console.Error.WriteLine ("--library can only be used with --simple/--runtime/--cross mode");
+ Help ();
+ return 1;
+ }
+ var lspec = args [++i];
+ var p = lspec.IndexOf (",");
+ string alias, path;
+ if (p == -1){
+ alias = Path.GetFileName (lspec);
+ path = lspec;
+ } else {
+ alias = lspec.Substring (0, p);
+ path = lspec.Substring (p+1);
+ }
+ if (!File.Exists (path)){
+ Console.Error.WriteLine ($"The specified library file {path} does not exist");
+ return 1;
+ }
+ libraries [alias] = path;
+ break;
+
case "--fetch-target":
if (i+1 == top){
Help ();
return 1;
}
var env = args [++i];
- var p = env.IndexOf ('=');
+ p = env.IndexOf ('=');
if (p == -1)
environment.Add (env, "");
else
foreach (var url in files){
string fname = LocateFile (new Uri (url).LocalPath);
- string aname = Path.GetFileName (fname);
+ string aname = MakeBundle.GetAssemblyName (fname);
maker.Add ("assembly:" + aname, fname);
if (File.Exists (fname + ".config"))
foreach (var key in environment.Keys)
maker.AddStringPair ("env:" + key, key, environment [key]);
}
+ if (libraries.Count > 0){
+ foreach (var alias_and_path in libraries){
+ maker.Add ("library:" + alias_and_path.Key, alias_and_path.Value);
+ }
+ }
maker.Dump ();
maker.Close ();
return true;
var symbolEscapeRE = new System.Text.RegularExpressions.Regex ("[^\\w_]");
foreach (var url in files) {
string fname = LocateFile (new Uri (url).LocalPath);
- string aname = Path.GetFileName (fname);
+ string aname = MakeBundle.GetAssemblyName (fname);
string encoded = symbolEscapeRE.Replace (aname, "_");
if (prog == null)
string monoPath = GetEnv("MONOPREFIX", @"C:\Program Files (x86)\Mono");
string[] includes = new string[] {winsdkPath + @"\Include\um", winsdkPath + @"\Include\shared", vsPath + @"\include", monoPath + @"\include\mono-2.0", "." };
- string[] libs = new string[] { winsdkPath + @"\Lib\winv6.3\um\x86" , vsPath + @"\lib" };
+ // string[] libs = new string[] { winsdkPath + @"\Lib\winv6.3\um\x86" , vsPath + @"\lib" };
var linkLibraries = new string[] { "kernel32.lib",
"version.lib",
"Ws2_32.lib",
static readonly Universe universe = new Universe ();
static readonly Dictionary<string, string> loaded_assemblies = new Dictionary<string, string> ();
-
+
+ public static string GetAssemblyName (string path)
+ {
+ string name = Path.GetFileName (path);
+
+ // A bit of a hack to support satellite assemblies. They all share the same name but
+ // are placed in subdirectories named after the locale they implement. Also, all of
+ // them end in .resources.dll, therefore we can use that to detect the circumstances.
+ if (name.EndsWith (".resources.dll", StringComparison.OrdinalIgnoreCase)) {
+ string dir = Path.GetDirectoryName (path);
+ int idx = dir.LastIndexOf (Path.DirectorySeparatorChar);
+ if (idx >= 0) {
+ name = dir.Substring (idx + 1) + Path.DirectorySeparatorChar + name;
+ Console.WriteLine ($"Storing satellite assembly '{path}' with name '{name}'");
+ } else if (!quiet)
+ Console.WriteLine ($"Warning: satellite assembly {path} doesn't have locale path prefix, name conflicts possible");
+ }
+
+ return name;
+ }
+
static bool QueueAssembly (List<string> files, string codebase)
{
//Console.WriteLine ("CODE BASE IS {0}", codebase);
return true;
var path = new Uri(codebase).LocalPath;
- var name = Path.GetFileName (path);
+ var name = GetAssemblyName (path);
string found;
if (loaded_assemblies.TryGetValue (name, out found)) {
Error (string.Format ("Duplicate assembly name `{0}'. Both `{1}' and `{2}' use same assembly name.", name, path, found));
{
Console.WriteLine ("Usage is: mkbundle [options] assembly1 [assembly2...]\n\n" +
"Options:\n" +
- " --config F Bundle system config file `F'\n" +
- " --config-dir D Set MONO_CFG_DIR to `D'\n" +
- " --deps Turns on automatic dependency embedding (default on simple)\n" +
- " -L path Adds `path' to the search path for assemblies\n" +
- " --machine-config F Use the given file as the machine.config for the application.\n" +
- " -o out Specifies output filename\n" +
- " --nodeps Turns off automatic dependency embedding (default on custom)\n" +
- " --skip-scan Skip scanning assemblies that could not be loaded (but still embed them).\n" +
- " --i18n ENCODING none, all or comma separated list of CJK, MidWest, Other, Rare, West.\n" +
- " -v Verbose output\n" +
+ " --config F Bundle system config file `F'\n" +
+ " --config-dir D Set MONO_CFG_DIR to `D'\n" +
+ " --deps Turns on automatic dependency embedding (default on simple)\n" +
+ " -L path Adds `path' to the search path for assemblies\n" +
+ " --machine-config F Use the given file as the machine.config for the application.\n" +
+ " -o out Specifies output filename\n" +
+ " --nodeps Turns off automatic dependency embedding (default on custom)\n" +
+ " --skip-scan Skip scanning assemblies that could not be loaded (but still embed them).\n" +
+ " --i18n ENCODING none, all or comma separated list of CJK, MidWest, Other, Rare, West.\n" +
+ " -v Verbose output\n" +
"\n" +
"--simple Simple mode does not require a C toolchain and can cross compile\n" +
- " --cross TARGET Generates a binary for the given TARGET\n"+
- " --local-targets Lists locally available targets\n" +
- " --list-targets Lists available targets on the remote server\n" +
- " --options OPTIONS Embed the specified Mono command line options on target\n" +
- " --runtime RUNTIME Manually specifies the Mono runtime to use\n" +
- " --target-server URL Specified a server to download targets from, default is " + target_server + "\n" +
- " --env KEY=VALUE Hardcodes an environment variable for the target\n" +
+ " --cross TARGET Generates a binary for the given TARGET\n"+
+ " --env KEY=VALUE Hardcodes an environment variable for the target\n" +
+ " --library [LIB,]PATH Bundles the specified dynamic library to be used at runtime\n" +
+ " LIB is optional shortname for file located at PATH\n" +
+ " --list-targets Lists available targets on the remote server\n" +
+ " --local-targets Lists locally available targets\n" +
+ " --options OPTIONS Embed the specified Mono command line options on target\n" +
+ " --runtime RUNTIME Manually specifies the Mono runtime to use\n" +
+ " --target-server URL Specified a server to download targets from, default is " + target_server + "\n" +
"\n" +
"--custom Builds a custom launcher, options for --custom\n" +
- " -c Produce stub only, do not compile\n" +
- " -oo obj Specifies output filename for helper object file\n" +
+ " -c Produce stub only, do not compile\n" +
+ " -oo obj Specifies output filename for helper object file\n" +
" --dos2unix[=true|false]\n" +
- " When no value provided, or when `true` specified\n" +
- " `dos2unix` will be invoked to convert paths on Windows.\n" +
- " When `--dos2unix=false` used, dos2unix is NEVER used.\n" +
- " --keeptemp Keeps the temporary files\n" +
- " --static Statically link to mono libs\n" +
- " --nomain Don't include a main() function, for libraries\n" +
- " --custom-main C Link the specified compilation unit (.c or .obj) with entry point/init code\n" +
- " -z Compress the assemblies before embedding.\n" +
- " --static-ctor ctor Add a constructor call to the supplied function.\n" +
- " You need zlib development headers and libraries.\n");
+ " When no value provided, or when `true` specified\n" +
+ " `dos2unix` will be invoked to convert paths on Windows.\n" +
+ " When `--dos2unix=false` used, dos2unix is NEVER used.\n" +
+ " --keeptemp Keeps the temporary files\n" +
+ " --static Statically link to mono libs\n" +
+ " --nomain Don't include a main() function, for libraries\n" +
+ " --custom-main C Link the specified compilation unit (.c or .obj) with entry point/init code\n" +
+ " -z Compress the assemblies before embedding.\n" +
+ " --static-ctor ctor Add a constructor call to the supplied function.\n" +
+ " You need zlib development headers and libraries.\n");
}
[DllImport ("libc")]
PROGRAM = mono-symbolicate.exe
LOCAL_MCS_FLAGS = \
- /D:NO_AUTHENTICODE
+ /D:NO_AUTHENTICODE /D:CECIL
-LIB_REFS = Mono.Cecil Mono.Cecil.Mdb System.Xml System.Core System
+LIB_REFS = System.Xml System.Core System
include ../../build/executable.make
SymbolManager.cs
Logger.cs
../../class/Mono.Options/Mono.Options/Options.cs
+
+../../../external/cecil/Mono/*.cs
+../../../external/cecil/Mono.Cecil/ArrayType.cs
+../../../external/cecil/Mono.Cecil/AssemblyDefinition.cs
+../../../external/cecil/Mono.Cecil/AssemblyFlags.cs
+../../../external/cecil/Mono.Cecil/AssemblyHashAlgorithm.cs
+../../../external/cecil/Mono.Cecil/AssemblyLinkedResource.cs
+../../../external/cecil/Mono.Cecil/AssemblyNameDefinition.cs
+../../../external/cecil/Mono.Cecil/AssemblyNameReference.cs
+../../../external/cecil/Mono.Cecil/AssemblyReader.cs
+../../../external/cecil/Mono.Cecil/AssemblyWriter.cs
+../../../external/cecil/Mono.Cecil/BaseAssemblyResolver.cs
+../../../external/cecil/Mono.Cecil/CallSite.cs
+../../../external/cecil/Mono.Cecil/CustomAttribute.cs
+../../../external/cecil/Mono.Cecil/DefaultAssemblyResolver.cs
+../../../external/cecil/Mono.Cecil/EmbeddedResource.cs
+../../../external/cecil/Mono.Cecil/EventAttributes.cs
+../../../external/cecil/Mono.Cecil/EventDefinition.cs
+../../../external/cecil/Mono.Cecil/EventReference.cs
+../../../external/cecil/Mono.Cecil/ExportedType.cs
+../../../external/cecil/Mono.Cecil/FieldAttributes.cs
+../../../external/cecil/Mono.Cecil/FieldDefinition.cs
+../../../external/cecil/Mono.Cecil/FieldReference.cs
+../../../external/cecil/Mono.Cecil/FileAttributes.cs
+../../../external/cecil/Mono.Cecil/FunctionPointerType.cs
+../../../external/cecil/Mono.Cecil/GenericInstanceMethod.cs
+../../../external/cecil/Mono.Cecil/GenericInstanceType.cs
+../../../external/cecil/Mono.Cecil/GenericParameter.cs
+../../../external/cecil/Mono.Cecil/GenericParameterAttributes.cs
+../../../external/cecil/Mono.Cecil/IConstantProvider.cs
+../../../external/cecil/Mono.Cecil/ICustomAttributeProvider.cs
+../../../external/cecil/Mono.Cecil/IGenericInstance.cs
+../../../external/cecil/Mono.Cecil/IGenericParameterProvider.cs
+../../../external/cecil/Mono.Cecil/IMarshalInfoProvider.cs
+../../../external/cecil/Mono.Cecil/IMemberDefinition.cs
+../../../external/cecil/Mono.Cecil/IMetadataScope.cs
+../../../external/cecil/Mono.Cecil/IMetadataTokenProvider.cs
+../../../external/cecil/Mono.Cecil/IMethodSignature.cs
+../../../external/cecil/Mono.Cecil/Import.cs
+../../../external/cecil/Mono.Cecil/LinkedResource.cs
+../../../external/cecil/Mono.Cecil/ManifestResourceAttributes.cs
+../../../external/cecil/Mono.Cecil/MarshalInfo.cs
+../../../external/cecil/Mono.Cecil/MemberDefinitionCollection.cs
+../../../external/cecil/Mono.Cecil/MemberReference.cs
+../../../external/cecil/Mono.Cecil/MetadataResolver.cs
+../../../external/cecil/Mono.Cecil/MetadataSystem.cs
+../../../external/cecil/Mono.Cecil/MethodAttributes.cs
+../../../external/cecil/Mono.Cecil/MethodCallingConvention.cs
+../../../external/cecil/Mono.Cecil/MethodDefinition.cs
+../../../external/cecil/Mono.Cecil/MethodImplAttributes.cs
+../../../external/cecil/Mono.Cecil/MethodReference.cs
+../../../external/cecil/Mono.Cecil/MethodReturnType.cs
+../../../external/cecil/Mono.Cecil/MethodSemanticsAttributes.cs
+../../../external/cecil/Mono.Cecil/MethodSpecification.cs
+../../../external/cecil/Mono.Cecil/Modifiers.cs
+../../../external/cecil/Mono.Cecil/ModuleDefinition.cs
+../../../external/cecil/Mono.Cecil/ModuleKind.cs
+../../../external/cecil/Mono.Cecil/ModuleReference.cs
+../../../external/cecil/Mono.Cecil/NativeType.cs
+../../../external/cecil/Mono.Cecil/ParameterAttributes.cs
+../../../external/cecil/Mono.Cecil/ParameterDefinition.cs
+../../../external/cecil/Mono.Cecil/ParameterDefinitionCollection.cs
+../../../external/cecil/Mono.Cecil/ParameterReference.cs
+../../../external/cecil/Mono.Cecil/PinnedType.cs
+../../../external/cecil/Mono.Cecil/PInvokeAttributes.cs
+../../../external/cecil/Mono.Cecil/PInvokeInfo.cs
+../../../external/cecil/Mono.Cecil/PointerType.cs
+../../../external/cecil/Mono.Cecil/PropertyAttributes.cs
+../../../external/cecil/Mono.Cecil/PropertyDefinition.cs
+../../../external/cecil/Mono.Cecil/PropertyReference.cs
+../../../external/cecil/Mono.Cecil/ReferenceType.cs
+../../../external/cecil/Mono.Cecil/Resource.cs
+../../../external/cecil/Mono.Cecil/SecurityDeclaration.cs
+../../../external/cecil/Mono.Cecil/SentinelType.cs
+../../../external/cecil/Mono.Cecil/TargetRuntime.cs
+../../../external/cecil/Mono.Cecil/Treatments.cs
+../../../external/cecil/Mono.Cecil/TypeAttributes.cs
+../../../external/cecil/Mono.Cecil/TypeDefinition.cs
+../../../external/cecil/Mono.Cecil/TypeDefinitionCollection.cs
+../../../external/cecil/Mono.Cecil/TypeParser.cs
+../../../external/cecil/Mono.Cecil/TypeReference.cs
+../../../external/cecil/Mono.Cecil/TypeSpecification.cs
+../../../external/cecil/Mono.Cecil/TypeSystem.cs
+../../../external/cecil/Mono.Cecil/VariantType.cs
+../../../external/cecil/Mono.Cecil/WindowsRuntimeProjections.cs
+../../../external/cecil/Mono.Cecil.Cil/*.cs
+../../../external/cecil/Mono.Cecil.Metadata/*.cs
+../../../external/cecil/Mono.Cecil.PE/*.cs
+../../../external/cecil/Mono.Collections.Generic/*.cs
+../../../external/cecil/Mono.Security.Cryptography/*.cs
+../../../external/cecil/System.Security.Cryptography/*.cs
+../../../external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbReader.cs
+../../../external/cecil/symbols/mdb/Mono.Cecil.Mdb/MdbWriter.cs
+../../../external/cecil/symbols/mdb/Mono.CompilerServices.SymbolWriter/*.cs
#include <mono/metadata/assembly.h>
#include <mono/metadata/appdomain.h>
#include <mono/utils/bsearch.h>
+#include <mono/utils/mono-counters.h>
static void setup_filter (MonoImage *image);
static gboolean should_include_type (int idx);
exit (1);
}
+static void
+thread_state_init (MonoThreadUnwindState *ctx)
+{
+}
+
int
main (int argc, char *argv [])
{
+ MonoThreadInfoRuntimeCallbacks ticallbacks;
+
GList *input_files = NULL, *l;
int i, j;
if (input_files == NULL)
usage ();
+ CHECKED_MONO_INIT ();
+ mono_counters_init ();
+ memset (&ticallbacks, 0, sizeof (ticallbacks));
+ ticallbacks.thread_state_init = thread_state_init;
+#ifndef HOST_WIN32
+ mono_w32handle_init ();
+#endif
+ mono_threads_runtime_init (&ticallbacks);
+
mono_install_assembly_load_hook (monodis_assembly_load_hook, NULL);
mono_install_assembly_search_hook (monodis_assembly_search_hook, NULL);
access.h \
context.h \
error.h \
- events.h \
io.h \
io-trace.h \
io-layer.h \
io-portability.h \
macros.h \
messages.h \
- mutexes.h \
processes.h \
security.h \
- semaphores.h \
sockets.h \
status.h \
timefuncs.h \
context.h \
error.c \
error.h \
- events.c \
- events.h \
- event-private.h \
io.c \
io.h \
io-portability.c \
macros.h \
messages.c \
messages.h \
- mutexes.c \
- mutexes.h \
- mutex-private.h \
posix.c \
processes.c \
processes.h \
process-private.h \
security.c \
security.h \
- semaphores.c \
- semaphores.h \
- semaphore-private.h \
- shared.c \
- shared.h \
sockets.c \
sockets.h \
socket-private.h \
+++ /dev/null
-/*
- * event-private.h: Private definitions for event handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_EVENT_PRIVATE_H_
-#define _WAPI_EVENT_PRIVATE_H_
-
-#include <config.h>
-#include <glib.h>
-#include <pthread.h>
-
-#include "wapi-private.h"
-
-struct _WapiHandle_event
-{
- gboolean manual;
- guint32 set_count;
-};
-
-struct _WapiHandle_namedevent
-{
- struct _WapiHandle_event e;
- WapiSharedNamespace sharedns;
-};
-
-void
-_wapi_event_init (void);
-
-#endif /* _WAPI_EVENT_PRIVATE_H_ */
+++ /dev/null
-/*
- * events.c: Event handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <pthread.h>
-#include <string.h>
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/event-private.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/mono-once.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/utils/w32handle.h>
-
-static void event_signal(gpointer handle);
-static gboolean event_own (gpointer handle);
-static void event_details (gpointer data);
-static const gchar* event_typename (void);
-static gsize event_typesize (void);
-
-static void namedevent_signal (gpointer handle);
-static gboolean namedevent_own (gpointer handle);
-static void namedevent_details (gpointer data);
-static const gchar* namedevent_typename (void);
-static gsize namedevent_typesize (void);
-
-static MonoW32HandleOps _wapi_event_ops = {
- NULL, /* close */
- event_signal, /* signal */
- event_own, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- event_details, /* details */
- event_typename, /* typename */
- event_typesize, /* typesize */
-};
-
-static MonoW32HandleOps _wapi_namedevent_ops = {
- NULL, /* close */
- namedevent_signal, /* signal */
- namedevent_own, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- namedevent_details, /* details */
- namedevent_typename, /* typename */
- namedevent_typesize, /* typesize */
-};
-
-void
-_wapi_event_init (void)
-{
- mono_w32handle_register_ops (MONO_W32HANDLE_EVENT, &_wapi_event_ops);
- mono_w32handle_register_ops (MONO_W32HANDLE_NAMEDEVENT, &_wapi_namedevent_ops);
-
- mono_w32handle_register_capabilities (MONO_W32HANDLE_EVENT,
- (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
- mono_w32handle_register_capabilities (MONO_W32HANDLE_NAMEDEVENT,
- (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
-}
-
-static const char* event_handle_type_to_string (MonoW32HandleType type)
-{
- switch (type) {
- case MONO_W32HANDLE_EVENT: return "event";
- case MONO_W32HANDLE_NAMEDEVENT: return "named event";
- default:
- g_assert_not_reached ();
- }
-}
-
-static gboolean event_handle_own (gpointer handle, MonoW32HandleType type)
-{
- struct _WapiHandle_event *event_handle;
- gboolean ok;
-
- ok = mono_w32handle_lookup (handle, type, (gpointer *)&event_handle);
- if (!ok) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
-
- if (!event_handle->manual) {
- g_assert (event_handle->set_count > 0);
- event_handle->set_count --;
-
- if (event_handle->set_count == 0)
- mono_w32handle_set_signal_state (handle, FALSE, FALSE);
- }
-
- return TRUE;
-}
-
-static void event_signal(gpointer handle)
-{
- SetEvent(handle);
-}
-
-static gboolean event_own (gpointer handle)
-{
- return event_handle_own (handle, MONO_W32HANDLE_EVENT);
-}
-
-static void namedevent_signal (gpointer handle)
-{
- SetEvent (handle);
-}
-
-/* NB, always called with the shared handle lock held */
-static gboolean namedevent_own (gpointer handle)
-{
- return event_handle_own (handle, MONO_W32HANDLE_NAMEDEVENT);
-}
-
-static void event_details (gpointer data)
-{
- struct _WapiHandle_event *event = (struct _WapiHandle_event *)data;
- g_print ("manual: %s, set_count: %d",
- event->manual ? "TRUE" : "FALSE", event->set_count);
-}
-
-static void namedevent_details (gpointer data)
-{
- struct _WapiHandle_namedevent *namedevent = (struct _WapiHandle_namedevent *)data;
- g_print ("manual: %s, set_count: %d, name: \"%s\"",
- namedevent->e.manual ? "TRUE" : "FALSE", namedevent->e.set_count, namedevent->sharedns.name);
-}
-
-static const gchar* event_typename (void)
-{
- return "Event";
-}
-
-static gsize event_typesize (void)
-{
- return sizeof (struct _WapiHandle_event);
-}
-
-static const gchar* namedevent_typename (void)
-{
- return "N.Event";
-}
-
-static gsize namedevent_typesize (void)
-{
- return sizeof (struct _WapiHandle_namedevent);
-}
-
-static gpointer event_handle_create (struct _WapiHandle_event *event_handle, MonoW32HandleType type, gboolean manual, gboolean initial)
-{
- gpointer handle;
- int thr_ret;
-
- event_handle->manual = manual;
- event_handle->set_count = (initial && !manual) ? 1 : 0;
-
- handle = mono_w32handle_new (type, event_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating %s handle",
- __func__, event_handle_type_to_string (type));
- SetLastError (ERROR_GEN_FAILURE);
- return NULL;
- }
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (initial)
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
-
- return handle;
-}
-
-static gpointer event_create (gboolean manual, gboolean initial)
-{
- struct _WapiHandle_event event_handle;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
- __func__, event_handle_type_to_string (MONO_W32HANDLE_EVENT));
- return event_handle_create (&event_handle, MONO_W32HANDLE_EVENT, manual, initial);
-}
-
-static gpointer namedevent_create (gboolean manual, gboolean initial, const gunichar2 *name G_GNUC_UNUSED)
-{
- gpointer handle;
- gchar *utf8_name;
- int thr_ret;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
- __func__, event_handle_type_to_string (MONO_W32HANDLE_NAMEDEVENT));
-
- /* w32 seems to guarantee that opening named objects can't race each other */
- thr_ret = _wapi_namespace_lock ();
- g_assert (thr_ret == 0);
-
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-
- handle = _wapi_search_handle_namespace (MONO_W32HANDLE_NAMEDEVENT, utf8_name);
- if (handle == INVALID_HANDLE_VALUE) {
- /* The name has already been used for a different object. */
- handle = NULL;
- SetLastError (ERROR_INVALID_HANDLE);
- } else if (handle) {
- /* Not an error, but this is how the caller is informed that the event wasn't freshly created */
- SetLastError (ERROR_ALREADY_EXISTS);
-
- /* this is used as creating a new handle */
- mono_w32handle_ref (handle);
- } else {
- /* A new named event */
- struct _WapiHandle_namedevent namedevent_handle;
-
- strncpy (&namedevent_handle.sharedns.name [0], utf8_name, MAX_PATH);
- namedevent_handle.sharedns.name [MAX_PATH] = '\0';
-
- handle = event_handle_create ((struct _WapiHandle_event*) &namedevent_handle, MONO_W32HANDLE_NAMEDEVENT, manual, initial);
- }
-
- g_free (utf8_name);
-
- thr_ret = _wapi_namespace_unlock (NULL);
- g_assert (thr_ret == 0);
-
- return handle;
-}
-
-
-/**
- * CreateEvent:
- * @security: Ignored for now.
- * @manual: Specifies whether the new event handle has manual or auto
- * reset behaviour.
- * @initial: Specifies whether the new event handle is initially
- * signalled or not.
- * @name:Pointer to a string specifying the name of this name, or
- * %NULL. Currently ignored.
- *
- * Creates a new event handle.
- *
- * An event handle is signalled with SetEvent(). If the new handle is
- * a manual reset event handle, it remains signalled until it is reset
- * with ResetEvent(). An auto reset event remains signalled until a
- * single thread has waited for it, at which time the event handle is
- * automatically reset to unsignalled.
- *
- * Return value: A new handle, or %NULL on error.
- */
-gpointer CreateEvent(WapiSecurityAttributes *security G_GNUC_UNUSED,
- gboolean manual, gboolean initial,
- const gunichar2 *name G_GNUC_UNUSED)
-{
- /* Need to blow away any old errors here, because code tests
- * for ERROR_ALREADY_EXISTS on success (!) to see if an event
- * was freshly created
- */
- SetLastError (ERROR_SUCCESS);
-
- return name ? namedevent_create (manual, initial, name) : event_create (manual, initial);
-}
-
-/**
- * PulseEvent:
- * @handle: The event handle.
- *
- * Sets the event handle @handle to the signalled state, and then
- * resets it to unsignalled after informing any waiting threads.
- *
- * If @handle is a manual reset event, all waiting threads that can be
- * released immediately are released. @handle is then reset. If
- * @handle is an auto reset event, one waiting thread is released even
- * if multiple threads are waiting.
- *
- * Return value: %TRUE on success, %FALSE otherwise. (Currently only
- * ever returns %TRUE).
- */
-gboolean PulseEvent(gpointer handle)
-{
- MonoW32HandleType type;
- struct _WapiHandle_event *event_handle;
- int thr_ret;
-
- if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- switch (type = mono_w32handle_get_type (handle)) {
- case MONO_W32HANDLE_EVENT:
- case MONO_W32HANDLE_NAMEDEVENT:
- break;
- default:
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&event_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pulsing %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (!event_handle->manual) {
- event_handle->set_count = 1;
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
- } else {
- mono_w32handle_set_signal_state (handle, TRUE, TRUE);
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- /* For a manual-reset event, we're about to try and get the handle
- * lock again, so give other threads a chance */
- sched_yield ();
-
- /* Reset the handle signal state */
-
- /* I'm not sure whether or not we need a barrier here to make sure
- * that all threads waiting on the event have proceeded. Currently
- * we rely on broadcasting a condition. */
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- mono_w32handle_set_signal_state (handle, FALSE, FALSE);
- }
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- return TRUE;
-}
-
-/**
- * ResetEvent:
- * @handle: The event handle.
- *
- * Resets the event handle @handle to the unsignalled state.
- *
- * Return value: %TRUE on success, %FALSE otherwise. (Currently only
- * ever returns %TRUE).
- */
-gboolean ResetEvent(gpointer handle)
-{
- MonoW32HandleType type;
- struct _WapiHandle_event *event_handle;
- int thr_ret;
-
- SetLastError (ERROR_SUCCESS);
-
- if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- switch (type = mono_w32handle_get_type (handle)) {
- case MONO_W32HANDLE_EVENT:
- case MONO_W32HANDLE_NAMEDEVENT:
- break;
- default:
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&event_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: resetting %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (!mono_w32handle_issignalled (handle)) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: no need to reset %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: obtained write lock on %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
-
- mono_w32handle_set_signal_state (handle, FALSE, FALSE);
- }
-
- event_handle->set_count = 0;
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- return TRUE;
-}
-
-/**
- * SetEvent:
- * @handle: The event handle
- *
- * Sets the event handle @handle to the signalled state.
- *
- * If @handle is a manual reset event, it remains signalled until it
- * is reset with ResetEvent(). An auto reset event remains signalled
- * until a single thread has waited for it, at which time @handle is
- * automatically reset to unsignalled.
- *
- * Return value: %TRUE on success, %FALSE otherwise. (Currently only
- * ever returns %TRUE).
- */
-gboolean SetEvent(gpointer handle)
-{
- MonoW32HandleType type;
- struct _WapiHandle_event *event_handle;
- int thr_ret;
-
- if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return(FALSE);
- }
-
- switch (type = mono_w32handle_get_type (handle)) {
- case MONO_W32HANDLE_EVENT:
- case MONO_W32HANDLE_NAMEDEVENT:
- break;
- default:
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&event_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting %s handle %p",
- __func__, event_handle_type_to_string (type), handle);
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (!event_handle->manual) {
- event_handle->set_count = 1;
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
- } else {
- mono_w32handle_set_signal_state (handle, TRUE, TRUE);
- }
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- return TRUE;
-}
-
-gpointer OpenEvent (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, const gunichar2 *name)
-{
- gpointer handle;
- gchar *utf8_name;
- int thr_ret;
-
- /* w32 seems to guarantee that opening named objects can't
- * race each other
- */
- thr_ret = _wapi_namespace_lock ();
- g_assert (thr_ret == 0);
-
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named event [%s]", __func__, utf8_name);
-
- handle = _wapi_search_handle_namespace (MONO_W32HANDLE_NAMEDEVENT,
- utf8_name);
- if (handle == INVALID_HANDLE_VALUE) {
- /* The name has already been used for a different
- * object.
- */
- SetLastError (ERROR_INVALID_HANDLE);
- goto cleanup;
- } else if (!handle) {
- /* This name doesn't exist */
- SetLastError (ERROR_FILE_NOT_FOUND); /* yes, really */
- goto cleanup;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named event handle %p", __func__, handle);
-
-cleanup:
- g_free (utf8_name);
-
- _wapi_namespace_unlock (NULL);
-
- return handle;
-
-}
+++ /dev/null
-/*
- * events.h: Event handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_EVENTS_H_
-#define _WAPI_EVENTS_H_
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-extern gpointer CreateEvent (WapiSecurityAttributes *security, gboolean manual,
- gboolean initial, const gunichar2 *name);
-extern gboolean PulseEvent (gpointer handle);
-extern gboolean ResetEvent (gpointer handle);
-extern gboolean SetEvent (gpointer handle);
-extern gpointer OpenEvent (guint32 access, gboolean inherit,
- const gunichar2 *name);
-
-G_END_DECLS
-
-#endif /* _WAPI_EVENTS_H_ */
* 4MB array.
*/
static GHashTable *file_share_hash;
-static mono_mutex_t file_share_hash_mutex;
-
-#define file_share_hash_lock() mono_os_mutex_lock (&file_share_hash_mutex)
-#define file_share_hash_unlock() mono_os_mutex_unlock (&file_share_hash_mutex)
+static mono_mutex_t file_share_mutex;
static void
_wapi_handle_share_release (_WapiFileShare *share_info)
{
- int thr_ret;
+ /* Prevent new entries racing with us */
+ mono_os_mutex_lock (&file_share_mutex);
g_assert (share_info->handle_refs > 0);
-
- /* Prevent new entries racing with us */
- thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_FILESHARE);
- g_assert(thr_ret == 0);
+ share_info->handle_refs -= 1;
- if (InterlockedDecrement ((gint32 *)&share_info->handle_refs) == 0) {
- file_share_hash_lock ();
+ if (share_info->handle_refs == 0)
g_hash_table_remove (file_share_hash, share_info);
- file_share_hash_unlock ();
- }
- thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_FILESHARE);
- g_assert (thr_ret == 0);
+ mono_os_mutex_unlock (&file_share_mutex);
}
static gint
guint32 *old_sharemode, guint32 *old_access, struct _WapiFileShare **share_info)
{
struct _WapiFileShare *file_share;
- int thr_ret;
gboolean exists = FALSE;
/* Prevent new entries racing with us */
- thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_FILESHARE);
- g_assert (thr_ret == 0);
+ mono_os_mutex_lock (&file_share_mutex);
_WapiFileShare tmp;
* info. This is needed even if SHM is disabled, to track sharing inside
* the current process.
*/
- if (!file_share_hash) {
+ if (!file_share_hash)
file_share_hash = g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, NULL, g_free);
- mono_os_mutex_init_recursive (&file_share_hash_mutex);
- }
tmp.device = device;
tmp.inode = inode;
- file_share_hash_lock ();
-
file_share = (_WapiFileShare *)g_hash_table_lookup (file_share_hash, &tmp);
if (file_share) {
*old_sharemode = file_share->sharemode;
*old_access = file_share->access;
*share_info = file_share;
- InterlockedIncrement ((gint32 *)&file_share->handle_refs);
+ g_assert (file_share->handle_refs > 0);
+ file_share->handle_refs += 1;
+
exists = TRUE;
} else {
file_share = g_new0 (_WapiFileShare, 1);
g_hash_table_insert (file_share_hash, file_share, file_share);
}
- file_share_hash_unlock ();
-
- thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_FILESHARE);
- g_assert (thr_ret == 0);
+ mono_os_mutex_unlock (&file_share_mutex);
return(exists);
}
MonoThreadInfo *info = mono_thread_info_current ();
buf_size = buf_size < 8192 ? 8192 : (buf_size > 65536 ? 65536 : buf_size);
- buf = (char *) malloc (buf_size);
+ buf = (char *) g_malloc (buf_size);
for (;;) {
remain = read (src_fd, buf, buf_size);
if (report_errors)
_wapi_set_last_error_from_errno ();
- free (buf);
+ g_free (buf);
return FALSE;
}
if (remain == 0) {
if (report_errors)
_wapi_set_last_error_from_errno ();
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write failed.", __func__);
- free (buf);
+ g_free (buf);
return FALSE;
}
}
}
- free (buf);
+ g_free (buf);
return TRUE ;
}
_wapi_io_init (void)
{
mono_os_mutex_init (&stdhandle_mutex);
+ mono_os_mutex_init (&file_share_mutex);
mono_w32handle_register_ops (MONO_W32HANDLE_FILE, &_wapi_file_ops);
mono_w32handle_register_ops (MONO_W32HANDLE_CONSOLE, &_wapi_console_ops);
void
_wapi_io_cleanup (void)
{
- if (file_share_hash) {
+ mono_os_mutex_destroy (&file_share_mutex);
+
+ if (file_share_hash)
g_hash_table_destroy (file_share_hash);
- mono_os_mutex_destroy (&file_share_hash_mutex);
- }
}
+++ /dev/null
-/*
- * mutex-private.h: Private definitions for mutex handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_MUTEX_PRIVATE_H_
-#define _WAPI_MUTEX_PRIVATE_H_
-
-#include <config.h>
-#include <glib.h>
-#include <pthread.h>
-#include <sys/types.h>
-
-#include "wapi-private.h"
-
-struct _WapiHandle_mutex
-{
- pthread_t tid;
- guint32 recursion;
-};
-
-struct _WapiHandle_namedmutex
-{
- struct _WapiHandle_mutex m;
- WapiSharedNamespace sharedns;
-};
-
-void
-_wapi_mutex_init (void);
-
-#endif /* _WAPI_MUTEX_PRIVATE_H_ */
+++ /dev/null
-/*
- * mutexes.c: Mutex handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002-2006 Ximian, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <pthread.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/mutex-private.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/mono-once.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/utils/w32handle.h>
-
-static void mutex_signal(gpointer handle);
-static gboolean mutex_own (gpointer handle);
-static gboolean mutex_is_owned (gpointer handle);
-static void mutex_prewait (gpointer handle);
-static void mutex_details (gpointer data);
-static const gchar* mutex_typename (void);
-static gsize mutex_typesize (void);
-
-static void namedmutex_signal (gpointer handle);
-static gboolean namedmutex_own (gpointer handle);
-static gboolean namedmutex_is_owned (gpointer handle);
-static void namedmutex_prewait (gpointer handle);
-static void namedmutex_details (gpointer data);
-static const gchar* namedmutex_typename (void);
-static gsize namedmutex_typesize (void);
-
-static MonoW32HandleOps _wapi_mutex_ops = {
- NULL, /* close */
- mutex_signal, /* signal */
- mutex_own, /* own */
- mutex_is_owned, /* is_owned */
- NULL, /* special_wait */
- mutex_prewait, /* prewait */
- mutex_details, /* details */
- mutex_typename, /* typename */
- mutex_typesize, /* typesize */
-};
-
-static MonoW32HandleOps _wapi_namedmutex_ops = {
- NULL, /* close */
- namedmutex_signal, /* signal */
- namedmutex_own, /* own */
- namedmutex_is_owned, /* is_owned */
- NULL, /* special_wait */
- namedmutex_prewait, /* prewait */
- namedmutex_details, /* details */
- namedmutex_typename, /* typename */
- namedmutex_typesize, /* typesize */
-};
-
-void
-_wapi_mutex_init (void)
-{
- mono_w32handle_register_ops (MONO_W32HANDLE_MUTEX, &_wapi_mutex_ops);
- mono_w32handle_register_ops (MONO_W32HANDLE_NAMEDMUTEX, &_wapi_namedmutex_ops);
-
- mono_w32handle_register_capabilities (MONO_W32HANDLE_MUTEX,
- (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL | MONO_W32HANDLE_CAP_OWN));
- mono_w32handle_register_capabilities (MONO_W32HANDLE_NAMEDMUTEX,
- (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL | MONO_W32HANDLE_CAP_OWN));
-}
-
-static const char* mutex_handle_type_to_string (MonoW32HandleType type)
-{
- switch (type) {
- case MONO_W32HANDLE_MUTEX: return "mutex";
- case MONO_W32HANDLE_NAMEDMUTEX: return "named mutex";
- default:
- g_assert_not_reached ();
- }
-}
-
-static gboolean
-mutex_handle_own (gpointer handle, MonoW32HandleType type)
-{
- struct _WapiHandle_mutex *mutex_handle;
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
- g_warning ("%s: error looking up %s handle %p", __func__, mutex_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p, tid %p, recursion %u",
- __func__, mutex_handle_type_to_string (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion);
-
- mono_thread_info_own_mutex (mono_thread_info_current (), handle);
-
- mutex_handle->tid = pthread_self ();
- mutex_handle->recursion++;
-
- mono_w32handle_set_signal_state (handle, FALSE, FALSE);
-
- return TRUE;
-}
-
-static gboolean
-mutex_handle_is_owned (gpointer handle, MonoW32HandleType type)
-{
- struct _WapiHandle_mutex *mutex_handle;
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
- g_warning ("%s: error looking up %s handle %p", __func__, mutex_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing ownership %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
-
- if (mutex_handle->recursion > 0 && pthread_equal (mutex_handle->tid, pthread_self ())) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p owned by %p",
- __func__, mutex_handle_type_to_string (type), handle, (gpointer) pthread_self ());
- return TRUE;
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p not owned by %p, but locked %d times by %p",
- __func__, mutex_handle_type_to_string (type), handle, (gpointer) pthread_self (), mutex_handle->recursion, (gpointer) mutex_handle->tid);
- return FALSE;
- }
-}
-
-static void mutex_signal(gpointer handle)
-{
- ReleaseMutex(handle);
-}
-
-static gboolean mutex_own (gpointer handle)
-{
- return mutex_handle_own (handle, MONO_W32HANDLE_MUTEX);
-}
-
-static gboolean mutex_is_owned (gpointer handle)
-{
-
- return mutex_handle_is_owned (handle, MONO_W32HANDLE_MUTEX);
-}
-
-static void namedmutex_signal (gpointer handle)
-{
- ReleaseMutex(handle);
-}
-
-/* NB, always called with the shared handle lock held */
-static gboolean namedmutex_own (gpointer handle)
-{
- return mutex_handle_own (handle, MONO_W32HANDLE_NAMEDMUTEX);
-}
-
-static gboolean namedmutex_is_owned (gpointer handle)
-{
- return mutex_handle_is_owned (handle, MONO_W32HANDLE_NAMEDMUTEX);
-}
-
-static void mutex_handle_prewait (gpointer handle, MonoW32HandleType type)
-{
- /* If the mutex is not currently owned, do nothing and let the
- * usual wait carry on. If it is owned, check that the owner
- * is still alive; if it isn't we override the previous owner
- * and assume that process exited abnormally and failed to
- * clean up.
- */
- struct _WapiHandle_mutex *mutex_handle;
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
- return;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pre-waiting %s handle %p, owned? %s",
- __func__, mutex_handle_type_to_string (type), handle, mutex_handle->recursion != 0 ? "true" : "false");
-}
-
-/* The shared state is not locked when prewait methods are called */
-static void mutex_prewait (gpointer handle)
-{
- mutex_handle_prewait (handle, MONO_W32HANDLE_MUTEX);
-}
-
-/* The shared state is not locked when prewait methods are called */
-static void namedmutex_prewait (gpointer handle)
-{
- mutex_handle_prewait (handle, MONO_W32HANDLE_NAMEDMUTEX);
-}
-
-static void mutex_details (gpointer data)
-{
- struct _WapiHandle_mutex *mut = (struct _WapiHandle_mutex *)data;
-
-#ifdef PTHREAD_POINTER_ID
- g_print ("own: %5p, count: %5u", mut->tid, mut->recursion);
-#else
- g_print ("own: %5ld, count: %5u", mut->tid, mut->recursion);
-#endif
-}
-
-static void namedmutex_details (gpointer data)
-{
- struct _WapiHandle_namedmutex *namedmut = (struct _WapiHandle_namedmutex *)data;
-
-#ifdef PTHREAD_POINTER_ID
- g_print ("own: %5p, count: %5u, name: \"%s\"",
- namedmut->m.tid, namedmut->m.recursion, namedmut->sharedns.name);
-#else
- g_print ("own: %5ld, count: %5u, name: \"%s\"",
- namedmut->m.tid, namedmut->m.recursion, namedmut->sharedns.name);
-#endif
-}
-
-static const gchar* mutex_typename (void)
-{
- return "Mutex";
-}
-
-static gsize mutex_typesize (void)
-{
- return sizeof (struct _WapiHandle_mutex);
-}
-
-static const gchar* namedmutex_typename (void)
-{
- return "N.Mutex";
-}
-
-static gsize namedmutex_typesize (void)
-{
- return sizeof (struct _WapiHandle_namedmutex);
-}
-
-/* When a thread exits, any mutexes it still holds need to be signalled. */
-void wapi_mutex_abandon (gpointer handle, pid_t pid, pthread_t tid)
-{
- MonoW32HandleType type;
- struct _WapiHandle_mutex *mutex_handle;
- int thr_ret;
-
- switch (type = mono_w32handle_get_type (handle)) {
- case MONO_W32HANDLE_MUTEX:
- case MONO_W32HANDLE_NAMEDMUTEX:
- break;
- default:
- g_assert_not_reached ();
- }
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
- return;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: abandon %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (pthread_equal (mutex_handle->tid, tid)) {
- mutex_handle->recursion = 0;
- mutex_handle->tid = 0;
-
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: abandoned %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
- }
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-}
-
-static gpointer mutex_handle_create (struct _WapiHandle_mutex *mutex_handle, MonoW32HandleType type, gboolean owned)
-{
- gpointer handle;
- int thr_ret;
-
- mutex_handle->tid = 0;
- mutex_handle->recursion = 0;
-
- handle = mono_w32handle_new (type, mutex_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating %s handle",
- __func__, mutex_handle_type_to_string (type));
- SetLastError (ERROR_GEN_FAILURE);
- return NULL;
- }
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (owned)
- mutex_handle_own (handle, type);
- else
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
-
- return handle;
-}
-
-static gpointer mutex_create (gboolean owned)
-{
- struct _WapiHandle_mutex mutex_handle;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
- __func__, mutex_handle_type_to_string (MONO_W32HANDLE_MUTEX));
- return mutex_handle_create (&mutex_handle, MONO_W32HANDLE_MUTEX, owned);
-}
-
-static gpointer namedmutex_create (gboolean owned, const gunichar2 *name)
-{
- gpointer handle;
- gchar *utf8_name;
- int thr_ret;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
- __func__, mutex_handle_type_to_string (MONO_W32HANDLE_NAMEDMUTEX));
-
- /* w32 seems to guarantee that opening named objects can't race each other */
- thr_ret = _wapi_namespace_lock ();
- g_assert (thr_ret == 0);
-
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-
- handle = _wapi_search_handle_namespace (MONO_W32HANDLE_NAMEDMUTEX, utf8_name);
- if (handle == INVALID_HANDLE_VALUE) {
- /* The name has already been used for a different object. */
- handle = NULL;
- SetLastError (ERROR_INVALID_HANDLE);
- } else if (handle) {
- /* Not an error, but this is how the caller is informed that the mutex wasn't freshly created */
- SetLastError (ERROR_ALREADY_EXISTS);
-
- /* this is used as creating a new handle */
- mono_w32handle_ref (handle);
- } else {
- /* A new named mutex */
- struct _WapiHandle_namedmutex namedmutex_handle;
-
- strncpy (&namedmutex_handle.sharedns.name [0], utf8_name, MAX_PATH);
- namedmutex_handle.sharedns.name [MAX_PATH] = '\0';
-
- handle = mutex_handle_create ((struct _WapiHandle_mutex*) &namedmutex_handle, MONO_W32HANDLE_NAMEDMUTEX, owned);
- }
-
- g_free (utf8_name);
-
- thr_ret = _wapi_namespace_unlock (NULL);
- g_assert (thr_ret == 0);
-
- return handle;
-}
-
-/**
- * CreateMutex:
- * @security: Ignored for now.
- * @owned: If %TRUE, the mutex is created with the calling thread
- * already owning the mutex.
- * @name:Pointer to a string specifying the name of this mutex, or
- * %NULL.
- *
- * Creates a new mutex handle. A mutex is signalled when no thread
- * owns it. A thread acquires ownership of the mutex by waiting for
- * it with WaitForSingleObject() or WaitForMultipleObjects(). A
- * thread relinquishes ownership with ReleaseMutex().
- *
- * A thread that owns a mutex can specify the same mutex in repeated
- * wait function calls without blocking. The thread must call
- * ReleaseMutex() an equal number of times to release the mutex.
- *
- * Return value: A new handle, or %NULL on error.
- */
-gpointer CreateMutex(WapiSecurityAttributes *security G_GNUC_UNUSED, gboolean owned, const gunichar2 *name)
-{
- /* Need to blow away any old errors here, because code tests
- * for ERROR_ALREADY_EXISTS on success (!) to see if a mutex
- * was freshly created */
- SetLastError (ERROR_SUCCESS);
-
- return name ? namedmutex_create (owned, name) : mutex_create (owned);
-}
-
-/**
- * ReleaseMutex:
- * @handle: The mutex handle.
- *
- * Releases ownership if the mutex handle @handle.
- *
- * Return value: %TRUE on success, %FALSE otherwise. This function
- * fails if the calling thread does not own the mutex @handle.
- */
-gboolean ReleaseMutex(gpointer handle)
-{
- MonoW32HandleType type;
- struct _WapiHandle_mutex *mutex_handle;
- pthread_t tid;
- int thr_ret;
- gboolean ret;
-
- if (handle == NULL) {
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- switch (type = mono_w32handle_get_type (handle)) {
- case MONO_W32HANDLE_MUTEX:
- case MONO_W32HANDLE_NAMEDMUTEX:
- break;
- default:
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: releasing %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- tid = pthread_self ();
-
- if (!pthread_equal (mutex_handle->tid, tid)) {
- ret = FALSE;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: we don't own %s handle %p (owned by %ld, me %ld)",
- __func__, mutex_handle_type_to_string (type), handle, mutex_handle->tid, tid);
- } else {
- ret = TRUE;
-
- /* OK, we own this mutex */
- mutex_handle->recursion--;
-
- if (mutex_handle->recursion == 0) {
- mono_thread_info_disown_mutex (mono_thread_info_current (), handle);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking %s handle %p",
- __func__, mutex_handle_type_to_string (type), handle);
-
- mutex_handle->tid = 0;
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
- }
- }
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- return ret;
-}
-
-gpointer OpenMutex (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, const gunichar2 *name)
-{
- gpointer handle;
- gchar *utf8_name;
- int thr_ret;
-
- /* w32 seems to guarantee that opening named objects can't
- * race each other
- */
- thr_ret = _wapi_namespace_lock ();
- g_assert (thr_ret == 0);
-
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named mutex [%s]", __func__, utf8_name);
-
- handle = _wapi_search_handle_namespace (MONO_W32HANDLE_NAMEDMUTEX,
- utf8_name);
- if (handle == INVALID_HANDLE_VALUE) {
- /* The name has already been used for a different
- * object.
- */
- SetLastError (ERROR_INVALID_HANDLE);
- goto cleanup;
- } else if (!handle) {
- /* This name doesn't exist */
- SetLastError (ERROR_FILE_NOT_FOUND); /* yes, really */
- goto cleanup;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named mutex handle %p", __func__, handle);
-
-cleanup:
- g_free (utf8_name);
-
- _wapi_namespace_unlock (NULL);
-
- return handle;
-}
+++ /dev/null
-/*
- * mutexes.h: Mutex handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_MUTEXES_H_
-#define _WAPI_MUTEXES_H_
-
-#include <glib.h>
-
-#include <pthread.h>
-
-G_BEGIN_DECLS
-
-extern gpointer CreateMutex (WapiSecurityAttributes *security, gboolean owned,
- const gunichar2 *name);
-extern gboolean ReleaseMutex (gpointer handle);
-extern gpointer OpenMutex (guint32 access, gboolean inherit,
- const gunichar2 *name);
-
-void
-wapi_mutex_abandon (gpointer data, pid_t pid, pthread_t tid);
-
-G_END_DECLS
-
-#endif /* _WAPI_MUTEXES_H_ */
+ sizeof (info->dlpi_phnum))
return (-1);
- struct dl_phdr_info *cpy = calloc(1, sizeof(struct dl_phdr_info));
+ struct dl_phdr_info *cpy = g_calloc (1, sizeof(struct dl_phdr_info));
if (!cpy)
return (-1);
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
mod->inode, mod->filename, mod->address_start, mod->address_end);
- free(info);
+ g_free (info);
if (g_slist_find_custom (ret, mod, find_procmodule) == NULL) {
ret = g_slist_prepend (ret, mod);
if (sysctl(mib, 4, NULL, &size, NULL, 0) < 0)
return(ret);
- if ((pi = malloc(size)) == NULL)
+ if ((pi = g_malloc (size)) == NULL)
return(ret);
if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
if (errno == ENOMEM) {
- free(pi);
+ g_free (pi);
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't allocate enough memory for kproc info", __func__);
}
return(ret);
if (strlen (pi->kp_proc.p_comm) > 0)
ret = g_strdup (pi->kp_proc.p_comm);
- free(pi);
+ g_free (pi);
#endif
#elif defined(USE_BSD_LOADER)
#if defined(__FreeBSD__)
return(ret);
}
- if ((pi = malloc(size)) == NULL)
+ if ((pi = g_malloc (size)) == NULL)
return(ret);
if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
if (errno == ENOMEM) {
- free(pi);
+ g_free (pi);
MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't allocate enough memory for kproc info", __func__);
}
return(ret);
if (strlen (pi->ki_comm) > 0)
ret = g_strdup (pi->ki_comm);
- free(pi);
+ g_free (pi);
#elif defined(__OpenBSD__)
mib [0] = CTL_KERN;
mib [1] = KERN_PROC;
return(ret);
}
- if ((pi = malloc(size)) == NULL)
+ if ((pi = g_malloc (size)) == NULL)
return(ret);
mib[5] = (int)(size / sizeof(struct kinfo_proc));
if ((sysctl (mib, 6, pi, &size, NULL, 0) < 0) ||
(size != sizeof (struct kinfo_proc))) {
if (errno == ENOMEM) {
- free(pi);
+ g_free (pi);
goto retry;
}
return(ret);
if (strlen (pi->p_comm) > 0)
ret = g_strdup (pi->p_comm);
- free(pi);
+ g_free (pi);
#endif
#elif defined(USE_HAIKU_LOADER)
image_info imageInfo;
+++ /dev/null
-/*
- * semaphore-private.h: Private definitions for semaphore handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_SEMAPHORE_PRIVATE_H_
-#define _WAPI_SEMAPHORE_PRIVATE_H_
-
-#include <config.h>
-#include <glib.h>
-
-#include "wapi-private.h"
-
-/* emulate sem_t, so that we can prod the internal state more easily */
-struct _WapiHandle_sem
-{
- guint32 val;
- gint32 max;
-};
-
-struct _WapiHandle_namedsem
-{
- struct _WapiHandle_sem s;
- WapiSharedNamespace sharedns;
-};
-
-void
-_wapi_semaphore_init (void);
-
-#endif /* _WAPI_SEMAPHORE_PRIVATE_H_ */
+++ /dev/null
-/*
- * semaphores.c: Semaphore handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-#include <pthread.h>
-#ifdef HAVE_SEMAPHORE_H
-#include <semaphore.h>
-#endif
-#include <errno.h>
-#include <string.h>
-#include <sys/time.h>
-
-#include <mono/io-layer/wapi.h>
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/semaphore-private.h>
-#include <mono/io-layer/io-trace.h>
-#include <mono/utils/mono-once.h>
-#include <mono/utils/mono-logger-internals.h>
-#include <mono/utils/w32handle.h>
-
-static void sema_signal(gpointer handle);
-static gboolean sema_own (gpointer handle);
-static void sema_details (gpointer data);
-static const gchar* sema_typename (void);
-static gsize sema_typesize (void);
-
-static void namedsema_signal (gpointer handle);
-static gboolean namedsema_own (gpointer handle);
-static void namedsema_details (gpointer data);
-static const gchar* namedsema_typename (void);
-static gsize namedsema_typesize (void);
-
-static MonoW32HandleOps _wapi_sem_ops = {
- NULL, /* close */
- sema_signal, /* signal */
- sema_own, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- sema_details, /* details */
- sema_typename, /* typename */
- sema_typesize, /* typesize */
-};
-
-static MonoW32HandleOps _wapi_namedsem_ops = {
- NULL, /* close */
- namedsema_signal, /* signal */
- namedsema_own, /* own */
- NULL, /* is_owned */
- NULL, /* special_wait */
- NULL, /* prewait */
- namedsema_details, /* details */
- namedsema_typename, /* typename */
- namedsema_typesize, /* typesize */
-};
-
-void
-_wapi_semaphore_init (void)
-{
- mono_w32handle_register_ops (MONO_W32HANDLE_SEM, &_wapi_sem_ops);
- mono_w32handle_register_ops (MONO_W32HANDLE_NAMEDSEM, &_wapi_namedsem_ops);
-
- mono_w32handle_register_capabilities (MONO_W32HANDLE_SEM,
- (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
- mono_w32handle_register_capabilities (MONO_W32HANDLE_NAMEDSEM,
- (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
-}
-
-static const char* sem_handle_type_to_string (MonoW32HandleType type)
-{
- switch (type) {
- case MONO_W32HANDLE_SEM: return "sem";
- case MONO_W32HANDLE_NAMEDSEM: return "named sem";
- default:
- g_assert_not_reached ();
- }
-}
-
-static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type)
-{
- struct _WapiHandle_sem *sem_handle;
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&sem_handle)) {
- g_warning ("%s: error looking up %s handle %p",
- __func__, sem_handle_type_to_string (type), handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p",
- __func__, sem_handle_type_to_string (type), handle);
-
- sem_handle->val--;
-
- if (sem_handle->val == 0)
- mono_w32handle_set_signal_state (handle, FALSE, FALSE);
-
- return TRUE;
-}
-
-static void sema_signal(gpointer handle)
-{
- ReleaseSemaphore(handle, 1, NULL);
-}
-
-static gboolean sema_own (gpointer handle)
-{
- return sem_handle_own (handle, MONO_W32HANDLE_SEM);
-}
-
-static void namedsema_signal (gpointer handle)
-{
- ReleaseSemaphore (handle, 1, NULL);
-}
-
-/* NB, always called with the shared handle lock held */
-static gboolean namedsema_own (gpointer handle)
-{
- return sem_handle_own (handle, MONO_W32HANDLE_NAMEDSEM);
-}
-
-static void sema_details (gpointer data)
-{
- struct _WapiHandle_sem *sem = (struct _WapiHandle_sem *)data;
- g_print ("val: %5u, max: %5d", sem->val, sem->max);
-}
-
-static void namedsema_details (gpointer data)
-{
- struct _WapiHandle_namedsem *namedsem = (struct _WapiHandle_namedsem *)data;
- g_print ("val: %5u, max: %5d, name: \"%s\"", namedsem->s.val, namedsem->s.max, namedsem->sharedns.name);
-}
-
-static const gchar* sema_typename (void)
-{
- return "Semaphore";
-}
-
-static gsize sema_typesize (void)
-{
- return sizeof (struct _WapiHandle_sem);
-}
-
-static const gchar* namedsema_typename (void)
-{
- return "N.Semaphore";
-}
-
-static gsize namedsema_typesize (void)
-{
- return sizeof (struct _WapiHandle_namedsem);
-}
-
-static gpointer sem_handle_create (struct _WapiHandle_sem *sem_handle, MonoW32HandleType type, gint32 initial, gint32 max)
-{
- gpointer handle;
- int thr_ret;
-
- sem_handle->val = initial;
- sem_handle->max = max;
-
- handle = mono_w32handle_new (type, sem_handle);
- if (handle == INVALID_HANDLE_VALUE) {
- g_warning ("%s: error creating %s handle",
- __func__, sem_handle_type_to_string (type));
- SetLastError (ERROR_GEN_FAILURE);
- return NULL;
- }
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- if (initial != 0)
- mono_w32handle_set_signal_state (handle, TRUE, FALSE);
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
- __func__, sem_handle_type_to_string (type), handle);
-
- return handle;
-}
-
-static gpointer sem_create (gint32 initial, gint32 max)
-{
- struct _WapiHandle_sem sem_handle;
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle, initial %d max %d",
- __func__, sem_handle_type_to_string (MONO_W32HANDLE_SEM), initial, max);
- return sem_handle_create (&sem_handle, MONO_W32HANDLE_SEM, initial, max);
-}
-
-static gpointer namedsem_create (gint32 initial, gint32 max, const gunichar2 *name)
-{
- gpointer handle;
- gchar *utf8_name;
- int thr_ret;
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle, initial %d max %d name \"%s\"",
- __func__, sem_handle_type_to_string (MONO_W32HANDLE_NAMEDSEM), initial, max, name);
-
- /* w32 seems to guarantee that opening named objects can't race each other */
- thr_ret = _wapi_namespace_lock ();
- g_assert (thr_ret == 0);
-
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named sem name [%s] initial %d max %d", __func__, utf8_name, initial, max);
-
- handle = _wapi_search_handle_namespace (MONO_W32HANDLE_NAMEDSEM, utf8_name);
- if (handle == INVALID_HANDLE_VALUE) {
- /* The name has already been used for a different object. */
- handle = NULL;
- SetLastError (ERROR_INVALID_HANDLE);
- } else if (handle) {
- /* Not an error, but this is how the caller is informed that the semaphore wasn't freshly created */
- SetLastError (ERROR_ALREADY_EXISTS);
-
- /* this is used as creating a new handle */
- mono_w32handle_ref (handle);
- } else {
- /* A new named semaphore */
- struct _WapiHandle_namedsem namedsem_handle;
-
- strncpy (&namedsem_handle.sharedns.name [0], utf8_name, MAX_PATH);
- namedsem_handle.sharedns.name [MAX_PATH] = '\0';
-
- handle = sem_handle_create ((struct _WapiHandle_sem*) &namedsem_handle, MONO_W32HANDLE_NAMEDSEM, initial, max);
- }
-
- g_free (utf8_name);
-
- thr_ret = _wapi_namespace_unlock (NULL);
- g_assert (thr_ret == 0);
-
- return handle;
-}
-
-
-/**
- * CreateSemaphore:
- * @security: Ignored for now.
- * @initial: The initial count for the semaphore. The value must be
- * greater than or equal to zero, and less than or equal to @max.
- * @max: The maximum count for this semaphore. The value must be
- * greater than zero.
- * @name: Pointer to a string specifying the name of this semaphore,
- * or %NULL. Currently ignored.
- *
- * Creates a new semaphore handle. A semaphore is signalled when its
- * count is greater than zero, and unsignalled otherwise. The count
- * is decreased by one whenever a wait function releases a thread that
- * was waiting for the semaphore. The count is increased by calling
- * ReleaseSemaphore().
- *
- * Return value: a new handle, or NULL
- */
-gpointer CreateSemaphore(WapiSecurityAttributes *security G_GNUC_UNUSED, gint32 initial, gint32 max, const gunichar2 *name)
-{
- if (max <= 0) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: max <= 0", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(NULL);
- }
-
- if (initial > max || initial < 0) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: initial>max or < 0", __func__);
-
- SetLastError (ERROR_INVALID_PARAMETER);
- return(NULL);
- }
-
- /* Need to blow away any old errors here, because code tests
- * for ERROR_ALREADY_EXISTS on success (!) to see if a
- * semaphore was freshly created
- */
- SetLastError (ERROR_SUCCESS);
-
- return name ? namedsem_create (initial, max, name) : sem_create (initial, max);
-}
-
-/**
- * ReleaseSemaphore:
- * @handle: The semaphore handle to release.
- * @count: The amount by which the semaphore's count should be
- * increased.
- * @prevcount: Pointer to a location to store the previous count of
- * the semaphore, or %NULL.
- *
- * Increases the count of semaphore @handle by @count.
- *
- * Return value: %TRUE on success, %FALSE otherwise.
- */
-gboolean ReleaseSemaphore(gpointer handle, gint32 count, gint32 *prevcount)
-{
- MonoW32HandleType type;
- struct _WapiHandle_sem *sem_handle;
- int thr_ret;
- gboolean ret;
-
- if (!handle) {
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- switch (type = mono_w32handle_get_type (handle)) {
- case MONO_W32HANDLE_SEM:
- case MONO_W32HANDLE_NAMEDSEM:
- break;
- default:
- SetLastError (ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (!mono_w32handle_lookup (handle, type, (gpointer *)&sem_handle)) {
- g_warning ("%s: error looking up sem handle %p", __func__, handle);
- return FALSE;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: releasing %s handle %p",
- __func__, sem_handle_type_to_string (type), handle);
-
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
-
- /* Do this before checking for count overflow, because overflowing
- * max is a listed technique for finding the current value */
- if (prevcount)
- *prevcount = sem_handle->val;
-
- /* No idea why max is signed, but thats the spec :-( */
- if (sem_handle->val + count > (guint32)sem_handle->max) {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p val %d count %d max %d, max value would be exceeded",
- __func__, sem_handle_type_to_string (type), handle, sem_handle->val, count, sem_handle->max, count);
-
- ret = FALSE;
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p val %d count %d max %d",
- __func__, sem_handle_type_to_string (type), handle, sem_handle->val, count, sem_handle->max, count);
-
- sem_handle->val += count;
- mono_w32handle_set_signal_state (handle, TRUE, TRUE);
-
- ret = TRUE;
- }
-
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
-
- return ret;
-}
-
-gpointer OpenSemaphore (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED,
- const gunichar2 *name)
-{
- gpointer handle;
- gchar *utf8_name;
- int thr_ret;
-
- /* w32 seems to guarantee that opening named objects can't
- * race each other
- */
- thr_ret = _wapi_namespace_lock ();
- g_assert (thr_ret == 0);
-
- utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named sem [%s]", __func__, utf8_name);
-
- handle = _wapi_search_handle_namespace (MONO_W32HANDLE_NAMEDSEM,
- utf8_name);
- if (handle == INVALID_HANDLE_VALUE) {
- /* The name has already been used for a different
- * object.
- */
- SetLastError (ERROR_INVALID_HANDLE);
- goto cleanup;
- } else if (!handle) {
- /* This name doesn't exist */
- SetLastError (ERROR_FILE_NOT_FOUND); /* yes, really */
- goto cleanup;
- }
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named sem handle %p", __func__, handle);
-
-cleanup:
- g_free (utf8_name);
-
- _wapi_namespace_unlock (NULL);
-
- return handle;
-}
+++ /dev/null
-/*
- * semaphores.h: Semaphore handles
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002 Ximian, Inc.
- */
-
-#ifndef _WAPI_SEMAPHORES_H_
-#define _WAPI_SEMAPHORES_H_
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-extern gpointer CreateSemaphore(WapiSecurityAttributes *security,
- gint32 initial, gint32 max,
- const gunichar2 *name);
-extern gboolean ReleaseSemaphore(gpointer handle, gint32 count,
- gint32 *prevcount);
-extern gpointer OpenSemaphore (guint32 access, gboolean inherit,
- const gunichar2 *name);
-
-G_END_DECLS
-#endif /* _WAPI_SEMAPHORES_H_ */
+++ /dev/null
-/*
- * shared.c: Shared memory handling, and daemon launching
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002-2006 Novell, Inc.
- */
-
-#include <config.h>
-#include <glib.h>
-
-#include <mono/io-layer/wapi-private.h>
-#include <mono/io-layer/shared.h>
-#include <mono/utils/mono-os-mutex.h>
-
-#define DEBUGLOG(...)
-//#define DEBUGLOG(...) g_message(__VA_ARGS__);
-
-static mono_mutex_t noshm_sems[_WAPI_SHARED_SEM_COUNT];
-
-void
-_wapi_shm_semaphores_init (void)
-{
- int i;
- for (i = 0; i < _WAPI_SHARED_SEM_COUNT; i++)
- mono_os_mutex_init (&noshm_sems [i]);
-}
-
-int
-_wapi_shm_sem_lock (int sem)
-{
- DEBUGLOG ("%s: locking nosem %d", __func__, sem);
- mono_os_mutex_lock (&noshm_sems[sem]);
- return 0;
-}
-
-int
-_wapi_shm_sem_trylock (int sem)
-{
- DEBUGLOG ("%s: trying to lock nosem %d", __func__, sem);
- return mono_os_mutex_trylock (&noshm_sems[sem]);
-}
-
-int
-_wapi_shm_sem_unlock (int sem)
-{
- DEBUGLOG ("%s: unlocking nosem %d", __func__, sem);
- mono_os_mutex_unlock (&noshm_sems[sem]);
- return 0;
-}
+++ /dev/null
-/*
- * shared.h: Shared memory handle, and daemon launching
- *
- * Author:
- * Dick Porter (dick@ximian.com)
- *
- * (C) 2002-2006 Novell, Inc.
- */
-
-#ifndef _WAPI_SHARED_H_
-#define _WAPI_SHARED_H_
-
-extern void _wapi_shm_semaphores_init (void);
-extern int _wapi_shm_sem_lock (int sem);
-extern int _wapi_shm_sem_trylock (int sem);
-extern int _wapi_shm_sem_unlock (int sem);
-
-#endif /* _WAPI_SHARED_H_ */
ret = mono_w32handle_wait_one (handle, timeout, alertable);
if (ret == MONO_W32HANDLE_WAIT_RET_SUCCESS_0)
return WAIT_OBJECT_0;
+ else if (ret == MONO_W32HANDLE_WAIT_RET_ABANDONED_0)
+ return WAIT_ABANDONED_0;
else if (ret == MONO_W32HANDLE_WAIT_RET_ALERTED)
return WAIT_IO_COMPLETION;
else if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT)
ret = mono_w32handle_signal_and_wait (signal_handle, wait, timeout, alertable);
if (ret == MONO_W32HANDLE_WAIT_RET_SUCCESS_0)
return WAIT_OBJECT_0;
+ else if (ret == MONO_W32HANDLE_WAIT_RET_ABANDONED_0)
+ return WAIT_ABANDONED_0;
else if (ret == MONO_W32HANDLE_WAIT_RET_ALERTED)
return WAIT_IO_COMPLETION;
else if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT)
MonoW32HandleWaitRet ret;
ret = mono_w32handle_wait_multiple (handles, numobjects, waitall, timeout, alertable);
- if (ret >= MONO_W32HANDLE_WAIT_RET_SUCCESS_0)
+ if (ret >= MONO_W32HANDLE_WAIT_RET_SUCCESS_0 && ret <= MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + numobjects - 1)
return WAIT_OBJECT_0 + (ret - MONO_W32HANDLE_WAIT_RET_SUCCESS_0);
+ else if (ret >= MONO_W32HANDLE_WAIT_RET_ABANDONED_0 && ret <= MONO_W32HANDLE_WAIT_RET_ABANDONED_0 + numobjects - 1)
+ return WAIT_ABANDONED_0 + (ret - MONO_W32HANDLE_WAIT_RET_ABANDONED_0);
else if (ret == MONO_W32HANDLE_WAIT_RET_ALERTED)
return WAIT_IO_COMPLETION;
else if (ret == MONO_W32HANDLE_WAIT_RET_TIMEOUT)
#include <mono/io-layer/wapi.h>
#include <mono/io-layer/io.h>
-#include <mono/io-layer/shared.h>
#include <mono/utils/mono-os-mutex.h>
extern gboolean _wapi_has_shut_down;
-typedef struct
-{
- gchar name[MAX_PATH + 1];
-} WapiSharedNamespace;
-
-#include <mono/io-layer/event-private.h>
#include <mono/io-layer/io-private.h>
-#include <mono/io-layer/mutex-private.h>
-#include <mono/io-layer/semaphore-private.h>
#include <mono/io-layer/socket-private.h>
#include <mono/io-layer/process-private.h>
#include <mono/utils/w32handle.h>
guint32 offset;
};
-#define _WAPI_SHARED_SEM_NAMESPACE 0
-/*#define _WAPI_SHARED_SEM_COLLECTION 1*/
-#define _WAPI_SHARED_SEM_FILESHARE 2
-#define _WAPI_SHARED_SEM_PROCESS_COUNT_LOCK 6
-#define _WAPI_SHARED_SEM_PROCESS_COUNT 7
-#define _WAPI_SHARED_SEM_COUNT 8 /* Leave some future expansion space */
-
struct _WapiFileShare
{
#ifdef WAPI_FILE_SHARE_PLATFORM_EXTRA_DATA
typedef struct _WapiFileShare _WapiFileShare;
-gpointer
-_wapi_search_handle_namespace (MonoW32HandleType type, gchar *utf8_name);
-
-static inline int _wapi_namespace_lock (void)
-{
- return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
-}
-
-/* This signature makes it easier to use in pthread cleanup handlers */
-static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
-{
- return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
-}
-
#endif /* _WAPI_PRIVATE_H_ */
#define SetLastError wapi_SetLastError
#define TransmitFile wapi_TransmitFile
#define GetThreadContext wapi_GetThreadContext
-#define CreateEvent wapi_CreateEvent
-#define PulseEvent wapi_PulseEvent
-#define ResetEvent wapi_ResetEvent
-#define SetEvent wapi_SetEvent
-#define OpenEvent wapi_OpenEvent
#define CloseHandle wapi_CloseHandle
#define DuplicateHandle wapi_DuplicateHandle
#define CreateFile wapi_CreateFile
#define UnlockFile wapi_UnlockFile
#define GetVolumeInformation wapi_GetVolumeInformation
#define FormatMessage wapi_FormatMessage
-#define CreateMutex wapi_CreateMutex
-#define ReleaseMutex wapi_ReleaseMutex
-#define OpenMutex wapi_OpenMutex
#define ShellExecuteEx wapi_ShellExecuteEx
#define CreateProcess wapi_CreateProcess
#define CreateProcessWithLogonW wapi_CreateProcessWithLogonW
#define SetPriorityClass wapi_SetPriorityClass
#define ImpersonateLoggedOnUser wapi_ImpersonateLoggedOnUser
#define RevertToSelf wapi_RevertToSelf
-#define CreateSemaphore wapi_CreateSemaphore
-#define ReleaseSemaphore wapi_ReleaseSemaphore
-#define OpenSemaphore wapi_OpenSemaphore
#define WSASetLastError wapi_WSASetLastError
#define WSAGetLastError wapi_WSAGetLastError
#define WSAIoctl wapi_WSAIoctl
#include "wapi.h"
-#include "event-private.h"
#include "io-trace.h"
#include "io.h"
-#include "mutex-private.h"
#include "process-private.h"
-#include "semaphore-private.h"
-#include "shared.h"
#include "socket-private.h"
#include "mono/utils/mono-lazy-init.h"
void
wapi_init (void)
{
- _wapi_shm_semaphores_init ();
_wapi_io_init ();
_wapi_processes_init ();
- _wapi_semaphore_init ();
- _wapi_mutex_init ();
- _wapi_event_init ();
_wapi_socket_init ();
}
return _wapi_pid;
}
-static gboolean
-_WAPI_SHARED_NAMESPACE (MonoW32HandleType type)
-{
- switch (type) {
- case MONO_W32HANDLE_NAMEDMUTEX:
- case MONO_W32HANDLE_NAMEDSEM:
- case MONO_W32HANDLE_NAMEDEVENT:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-typedef struct {
- gpointer ret;
- MonoW32HandleType type;
- gchar *utf8_name;
-} _WapiSearchHandleNamespaceData;
-
-static gboolean mono_w32handle_search_namespace_callback (gpointer handle, gpointer data, gpointer user_data)
-{
- _WapiSearchHandleNamespaceData *search_data;
- MonoW32HandleType type;
- WapiSharedNamespace *sharedns;
-
- type = mono_w32handle_get_type (handle);
- if (!_WAPI_SHARED_NAMESPACE (type))
- return FALSE;
-
- search_data = (_WapiSearchHandleNamespaceData*) user_data;
-
- switch (type) {
- case MONO_W32HANDLE_NAMEDMUTEX: sharedns = &((struct _WapiHandle_namedmutex*) data)->sharedns; break;
- case MONO_W32HANDLE_NAMEDSEM: sharedns = &((struct _WapiHandle_namedsem*) data)->sharedns; break;
- case MONO_W32HANDLE_NAMEDEVENT: sharedns = &((struct _WapiHandle_namedevent*) data)->sharedns; break;
- default:
- g_assert_not_reached ();
- }
-
- if (strcmp (sharedns->name, search_data->utf8_name) == 0) {
- if (type != search_data->type) {
- /* Its the wrong type, so fail now */
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p matches name but is wrong type: %s",
- __func__, handle, mono_w32handle_ops_typename (type));
- search_data->ret = INVALID_HANDLE_VALUE;
- } else {
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p matches name and type",
- __func__, handle);
- search_data->ret = handle;
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-/* Returns the offset of the metadata array, or INVALID_HANDLE_VALUE on error, or NULL for
- * not found
- */
-gpointer _wapi_search_handle_namespace (MonoW32HandleType type, gchar *utf8_name)
-{
- _WapiSearchHandleNamespaceData search_data;
-
- g_assert(_WAPI_SHARED_NAMESPACE(type));
-
- MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Lookup for handle named [%s] type %s",
- __func__, utf8_name, mono_w32handle_ops_typename (type));
-
- search_data.ret = NULL;
- search_data.type = type;
- search_data.utf8_name = utf8_name;
- mono_w32handle_foreach (mono_w32handle_search_namespace_callback, &search_data);
- return search_data.ret;
-}
-
/* Lots more to implement here, but this is all we need at the moment */
gboolean
DuplicateHandle (gpointer srcprocess, gpointer src, gpointer targetprocess, gpointer *target,
#include <mono/io-layer/access.h>
#include <mono/io-layer/context.h>
#include <mono/io-layer/error.h>
-#include <mono/io-layer/events.h>
#include <mono/io-layer/messages.h>
-#include <mono/io-layer/mutexes.h>
#include <mono/io-layer/processes.h>
#include <mono/io-layer/security.h>
-#include <mono/io-layer/semaphores.h>
#include <mono/io-layer/sockets.h>
#include <mono/io-layer/status.h>
#include <mono/io-layer/timefuncs.h>
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
/* FIXME: Can just use realloc(). */
- pathv = (char **)(pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) :
- malloc(newsize));
+ pathv = (char **)(pglob->gl_pathv ? g_realloc ((char *)pglob->gl_pathv, newsize) :
+ g_malloc (newsize));
if (pathv == NULL) {
if (pglob->gl_pathv) {
- free(pglob->gl_pathv);
+ g_free (pglob->gl_pathv);
pglob->gl_pathv = NULL;
}
return(WAPI_GLOB_NOSPACE);
*limitp += len;
if ((copy = (char *)malloc(len)) != NULL) {
if (g_Ctoc(path, copy, len)) {
- free(copy);
+ g_free (copy);
return(WAPI_GLOB_NOSPACE);
}
pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
pp = pglob->gl_pathv + pglob->gl_offs;
for (i = pglob->gl_pathc; i--; ++pp)
if (*pp)
- free(*pp);
- free(pglob->gl_pathv);
+ g_free (*pp);
+ g_free (pglob->gl_pathv);
pglob->gl_pathv = NULL;
}
}
if HOST_WIN32
win32_sources = \
- console-win32.c
+ console-win32.c \
+ w32mutex-win32.c \
+ w32semaphore-win32.c \
+ w32event-win32.c
platform_sources = $(win32_sources)
assembliesdir = $(exec_prefix)/lib
confdir = $(sysconfdir)
unix_sources = \
- console-unix.c
+ console-unix.c \
+ w32mutex-unix.c \
+ w32semaphore-unix.c \
+ w32event-unix.c
platform_sources = $(unix_sources)
endif
seq-points-data.h \
seq-points-data.c \
handle.c \
- handle.h
-
+ handle.h \
+ w32mutex.h \
+ w32mutex-utils.h \
+ w32semaphore.h \
+ w32event.h \
+ w32handle-namespace.h \
+ w32handle-namespace.c
# These source files have compile time dependencies on GC code
gc_dependent_sources = \
#include <mono/metadata/tokentype.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/abi-details.h>
#include <mono/utils/mono-uri.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-path.h>
* Changes which are already detected at runtime, like the addition
* of icalls, do not require an increment.
*/
-#define MONO_CORLIB_VERSION 154
+#define MONO_CORLIB_VERSION 156
typedef struct
{
int version = mono_get_corlib_version ();
if (version != MONO_CORLIB_VERSION)
return g_strdup_printf ("expected corlib version %d, found %d.", MONO_CORLIB_VERSION, version);
- else
- return NULL;
+
+ /* Check that the managed and unmanaged layout of MonoInternalThread matches */
+ guint32 native_offset = (guint32) MONO_STRUCT_OFFSET (MonoInternalThread, last);
+ guint32 managed_offset = mono_field_get_offset (mono_class_get_field_from_name (mono_defaults.internal_thread_class, "last"));
+ if (native_offset != managed_offset)
+ return g_strdup_printf ("expected InternalThread.last field offset %u, found %u. See InternalThread.last comment", native_offset, managed_offset);
+
+ return NULL;
}
/**
return NULL;
}
-static gboolean
-prevent_running_reference_assembly (MonoAssembly *ass, MonoError *error)
-{
- mono_error_init (error);
- gboolean refasm = mono_assembly_get_reference_assembly_attribute (ass, error);
- if (!is_ok (error))
- return TRUE;
- if (refasm) {
- mono_error_set_bad_image (error, ass->image, "Could not load file or assembly or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.\n");
- return TRUE;
- }
- return FALSE;
-}
-
MonoReflectionAssembly *
ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean refOnly)
{
MonoDomain *domain = mono_domain_get ();
char *name, *filename;
MonoImageOpenStatus status = MONO_IMAGE_OK;
- MonoAssembly *ass = NULL;
-
- name = NULL;
- result = NULL;
-
- mono_error_init (&error);
+ MonoAssembly *ass;
if (fname == NULL) {
- mono_error_set_argument_null (&error, "assemblyFile", "");
- goto leave;
+ MonoException *exc = mono_get_exception_argument_null ("assemblyFile");
+ mono_set_pending_exception (exc);
+ return NULL;
}
name = filename = mono_string_to_utf8_checked (fname, &error);
- if (!is_ok (&error))
- goto leave;
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
ass = mono_assembly_open_full (filename, &status, refOnly);
if (!ass) {
+ MonoException *exc;
+
if (status == MONO_IMAGE_IMAGE_INVALID)
- mono_error_set_bad_image_name (&error, name, "");
+ exc = mono_get_exception_bad_image_format2 (NULL, fname);
else
- mono_error_set_exception_instance (&error, mono_get_exception_file_not_found2 (NULL, fname));
- goto leave;
+ exc = mono_get_exception_file_not_found2 (NULL, fname);
+ g_free (name);
+ mono_set_pending_exception (exc);
+ return NULL;
}
- if (!refOnly && prevent_running_reference_assembly (ass, &error))
- goto leave;
+ g_free (name);
result = mono_assembly_get_object_checked (domain, ass, &error);
-
-leave:
- mono_error_set_pending_exception (&error);
- g_free (name);
+ if (!result)
+ mono_error_set_pending_exception (&error);
return result;
}
return NULL;
}
- if (!refonly && prevent_running_reference_assembly (ass, &error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
-
refass = mono_assembly_get_object_checked (domain, ass, &error);
if (!refass)
mono_error_set_pending_exception (&error);
MonoAssembly *ass;
MonoAssemblyName aname;
MonoReflectionAssembly *refass = NULL;
- gchar *name = NULL;
+ gchar *name;
gboolean parsed;
g_assert (assRef);
if (mono_error_set_pending_exception (&error))
return NULL;
parsed = mono_assembly_name_parse (name, &aname);
+ g_free (name);
if (!parsed) {
/* This is a parse error... */
if (!refOnly) {
refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
- if (!is_ok (&error))
- goto leave;
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
}
return refass;
}
/* MS.NET doesn't seem to call the assembly resolve handler for refonly assemblies */
if (!refOnly) {
refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
- if (!is_ok (&error))
- goto leave;
+ if (!mono_error_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
}
else
refass = NULL;
- if (!refass)
- goto leave;
- ass = refass->assembly;
+ if (!refass) {
+ return NULL;
+ }
}
- if (!refOnly && prevent_running_reference_assembly (ass, &error))
- goto leave;
-
- g_assert (ass);
- if (refass == NULL) {
+ if (refass == NULL)
refass = mono_assembly_get_object_checked (domain, ass, &error);
- if (!is_ok (&error))
- goto leave;
- }
-
- MONO_OBJECT_SETREF (refass, evidence, evidence);
-leave:
- g_free (name);
- mono_error_set_pending_exception (&error);
+ if (refass == NULL)
+ mono_error_set_pending_exception (&error);
+ else
+ MONO_OBJECT_SETREF (refass, evidence, evidence);
return refass;
}
unload_data *thread_data;
MonoNativeThreadId tid;
MonoDomain *caller_domain = mono_domain_get ();
- MonoThreadParm tp;
/* printf ("UNLOAD STARTING FOR %s (%p) IN THREAD 0x%x.\n", domain->friendly_name, domain, mono_native_thread_id_get ()); */
* First we create a separate thread for unloading, since
* we might have to abort some threads, including the current one.
*/
- tp.priority = MONO_THREAD_PRIORITY_NORMAL;
- tp.stack_size = 0;
- tp.creation_flags = 0;
- thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, &tp, &tid);
+ thread_handle = mono_threads_create_thread (unload_thread_main, thread_data, 0, &tid);
if (thread_handle == NULL)
return;
if (mono_thread_internal_has_appdomain_ref (mono_thread_internal_current (), domain) && (mono_thread_interruption_requested ())) {
/* The unload thread tries to abort us */
/* The icall wrapper will execute the abort */
+ mono_threads_close_thread_handle (thread_handle);
unload_data_unref (thread_data);
return;
}
}
+ mono_threads_close_thread_handle (thread_handle);
+
if (thread_data->failure_reason) {
/* Roll back the state change */
domain->state = MONO_APPDOMAIN_CREATED;
--- /dev/null
+/*
+ * Copyright 2015 Xamarin Inc
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+#ifndef __MONO_METADATA_ASSEMBLY_INTERNALS_H__
+#define __MONO_METADATA_ASSEMBLY_INTERNALS_H__
+
+#include <mono/metadata/assembly.h>
+
+MONO_API MonoImage* mono_assembly_load_module_checked (MonoAssembly *assembly, uint32_t idx, MonoError *error);
+
+#endif /* __MONO_METADATA_ASSEMBLY_INTERNALS_H__ */
#include <string.h>
#include <stdlib.h>
#include "assembly.h"
+#include "assembly-internals.h"
#include "image.h"
+#include "image-internals.h"
#include "object-internals.h"
#include <mono/metadata/loader.h>
#include <mono/metadata/tabledefs.h>
aname.major, aname.minor, aname.build, aname.revision,
strlen ((char*)aname.public_key_token) == 0 ? "(none)" : (char*)aname.public_key_token, extra_msg);
g_free (extra_msg);
-
- } else if (!image->assembly->ref_only) {
- MonoError error;
- if (mono_assembly_get_reference_assembly_attribute (reference, &error)) {
- mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY, "The following reference assembly assembly referenced from %s was not loaded. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context:\n"
- " Assembly: %s (assemblyref_index=%d)\n"
- " Version: %d.%d.%d.%d\n"
- " Public Key: %s\n",
- image->name, aname.name, index,
- aname.major, aname.minor, aname.build, aname.revision,
- strlen ((char*)aname.public_key_token) == 0 ? "(none)" : (char*)aname.public_key_token);
- reference = NULL; /* don't load reference assemblies for execution */
- }
- if (!is_ok (&error)) {
- reference = NULL;
- mono_error_cleanup (&error);
- }
}
mono_assemblies_lock ();
{
int i;
char *name;
+ gchar *lowercase_filename;
MonoImage *image = NULL;
-
+ gboolean is_satellite = FALSE;
/*
* we do a very simple search for bundled assemblies: it's not a general
* purpose assembly loading mechanism.
if (!bundles)
return NULL;
+ lowercase_filename = g_utf8_strdown (filename, -1);
+ is_satellite = g_str_has_suffix (lowercase_filename, ".resources.dll");
+ g_free (lowercase_filename);
name = g_path_get_basename (filename);
-
mono_assemblies_lock ();
for (i = 0; !image && bundles [i]; ++i) {
- if (strcmp (bundles [i]->name, name) == 0) {
+ if (strcmp (bundles [i]->name, is_satellite ? filename : name) == 0) {
image = mono_image_open_from_data_with_name ((char*)bundles [i]->data, bundles [i]->size, FALSE, status, refonly, name);
break;
}
mono_assemblies_unlock ();
if (image) {
mono_image_addref (image);
- mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Assembly Loader loaded assembly from bundle: '%s'.", name);
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Assembly Loader loaded assembly from bundle: '%s'.", is_satellite ? filename : name);
g_free (name);
return image;
}
if (!g_ascii_strcasecmp (retargetable, "yes")) {
flags |= ASSEMBLYREF_RETARGETABLE_FLAG;
} else if (g_ascii_strcasecmp (retargetable, "no")) {
- free (retargetable_uq);
+ g_free (retargetable_uq);
goto cleanup_and_fail;
}
- free (retargetable_uq);
+ g_free (retargetable_uq);
tmp++;
continue;
}
else if (!g_ascii_strcasecmp (procarch, "AMD64"))
arch = MONO_PROCESSOR_ARCHITECTURE_AMD64;
else {
- free (procarch_uq);
+ g_free (procarch_uq);
goto cleanup_and_fail;
}
- free (procarch_uq);
+ g_free (procarch_uq);
tmp++;
continue;
}
key_uq == NULL ? key : key_uq,
flags, arch, aname, save_public_key);
- free (dllname_uq);
- free (version_uq);
- free (culture_uq);
- free (token_uq);
- free (key_uq);
+ g_free (dllname_uq);
+ g_free (version_uq);
+ g_free (culture_uq);
+ g_free (token_uq);
+ g_free (key_uq);
g_strfreev (parts);
return res;
MonoImage*
mono_assembly_load_module (MonoAssembly *assembly, guint32 idx)
{
- return mono_image_load_file_for_image (assembly->image, idx);
+ MonoError error;
+ MonoImage *result = mono_assembly_load_module_checked (assembly, idx, &error);
+ mono_error_assert_ok (&error);
+ return result;
}
+MONO_API MonoImage*
+mono_assembly_load_module_checked (MonoAssembly *assembly, uint32_t idx, MonoError *error)
+{
+ return mono_image_load_file_for_image_checked (assembly->image, idx, error);
+}
+
+
/**
* mono_assembly_foreach:
* @func: function to invoke for each assembly loaded
#ifndef _MONONET_METADATA_ASSEMBLY_H_
#define _MONONET_METADATA_ASSEMBLY_H_
+#include <mono/utils/mono-error.h>
#include <mono/metadata/image.h>
MONO_BEGIN_DECLS
MONO_API void mono_assembly_get_assemblyref (MonoImage *image, int index, MonoAssemblyName *aname);
MONO_API void mono_assembly_load_reference (MonoImage *image, int index);
MONO_API void mono_assembly_load_references (MonoImage *image, MonoImageOpenStatus *status);
-MONO_API MonoImage* mono_assembly_load_module (MonoAssembly *assembly, uint32_t idx);
+MONO_RT_EXTERNAL_ONLY MONO_API MonoImage* mono_assembly_load_module (MonoAssembly *assembly, uint32_t idx);
MONO_API void mono_assembly_close (MonoAssembly *assembly);
MONO_API void mono_assembly_setrootdir (const char *root_dir);
MONO_API MONO_CONST_RETURN char *mono_assembly_getrootdir (void);
static void
transport_start_receive (void)
{
- MonoThreadParm tp;
-
transport_connect ();
if (!listen_fd)
return;
- tp.priority = MONO_THREAD_PRIORITY_NORMAL;
- tp.stack_size = 0;
- tp.creation_flags = 0;
- receiver_thread_handle = mono_threads_create_thread (receiver_thread, NULL, &tp, NULL);
+ receiver_thread_handle = mono_threads_create_thread (receiver_thread, NULL, 0, NULL);
g_assert (receiver_thread_handle);
}
static void
boehm_thread_unregister (MonoThreadInfo *p);
static void
+boehm_thread_detach (MonoThreadInfo *p);
+static void
register_test_toggleref_callback (void);
#define BOEHM_GC_BIT_FINALIZER_AWARE 1
memset (&cb, 0, sizeof (cb));
cb.thread_register = boehm_thread_register;
cb.thread_unregister = boehm_thread_unregister;
+ cb.thread_detach = boehm_thread_detach;
cb.mono_method_is_critical = (gboolean (*)(void *))mono_runtime_is_critical_method;
mono_threads_init (&cb, sizeof (MonoThreadInfo));
mono_threads_add_joinable_thread ((gpointer)tid);
}
+static void
+boehm_thread_detach (MonoThreadInfo *p)
+{
+ if (mono_thread_internal_current_is_attached ())
+ mono_thread_detach_internal (mono_thread_internal_current ());
+}
+
gboolean
mono_object_is_alive (MonoObject* o)
{
size_t imt_slots_with_collisions;
size_t imt_max_collisions_in_slot;
size_t imt_method_count_when_max_collisions;
- size_t imt_thunks_size;
+ size_t imt_trampolines_size;
size_t jit_info_table_insert_count;
size_t jit_info_table_remove_count;
size_t jit_info_table_lookup_count;
#include <string.h>
#include <stdlib.h>
#include <mono/metadata/image.h>
+#include <mono/metadata/image-internals.h>
#include <mono/metadata/assembly.h>
+#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/metadata.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/profiler-private.h>
goto done;
case MONO_RESOLUTION_SCOPE_MODULEREF:
- module = mono_image_load_module (image, idx);
+ module = mono_image_load_module_checked (image, idx, error);
if (module)
res = mono_class_from_name_checked (module, nspace, name, error);
goto done;
/* set the parent to something useful and safe, but mark the type as broken */
parent = mono_defaults.object_class;
mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, NULL);
- g_assert (parent);
}
klass->parent = parent;
if (cols [MONO_FILE_FLAGS] == FILE_CONTAINS_NO_METADATA)
continue;
- file_image = mono_image_load_file_for_image (image, i + 1);
+ file_image = mono_image_load_file_for_image_checked (image, i + 1, error);
if (file_image) {
klass = mono_class_from_name_checked (file_image, name_space, name, error);
if (klass || !is_ok (error))
impl = cols [MONO_EXP_TYPE_IMPLEMENTATION];
if ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE) {
- loaded_image = mono_assembly_load_module (image->assembly, impl >> MONO_IMPLEMENTATION_BITS);
+ loaded_image = mono_assembly_load_module_checked (image->assembly, impl >> MONO_IMPLEMENTATION_BITS, error);
if (!loaded_image)
return NULL;
klass = mono_class_from_name_checked_aux (loaded_image, name_space, name, visited_images, error);
GHashTable *method_rgctx_hash;
GHashTable *generic_virtual_cases;
- MonoThunkFreeList **thunk_free_lists;
-
- GHashTable *generic_virtual_thunks;
/* Information maintained by the JIT engine */
gpointer runtime_info;
/*thread pool jobs, used to coordinate shutdown.*/
volatile int threadpool_jobs;
- HANDLE cleanup_semaphore;
+ gpointer cleanup_semaphore;
/* Contains the compiled runtime invoke wrapper used by finalizers */
gpointer finalize_runtime_invoke;
#include <mono/metadata/mono-config.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/runtime.h>
+#include <mono/metadata/w32mutex.h>
+#include <mono/metadata/w32semaphore.h>
+#include <mono/metadata/w32event.h>
#include <metadata/threads.h>
#include <metadata/profiler-private.h>
#include <mono/metadata/coree.h>
chunk = mp->chunks;
while (chunk) {
next = (LockFreeMempoolChunk *)chunk->prev;
- mono_vfree (chunk, mono_pagesize ());
+ mono_vfree (chunk, mono_pagesize (), MONO_MEM_ACCOUNT_DOMAIN);
chunk = next;
}
g_free (mp);
size = mono_pagesize ();
while (size - sizeof (LockFreeMempoolChunk) < len)
size += mono_pagesize ();
- chunk = (LockFreeMempoolChunk *)mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE);
+ chunk = (LockFreeMempoolChunk *)mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE, MONO_MEM_ACCOUNT_DOMAIN);
g_assert (chunk);
chunk->mem = (guint8 *)ALIGN_PTR_TO ((char*)chunk + sizeof (LockFreeMempoolChunk), 16);
chunk->size = ((char*)chunk + size) - (char*)chunk->mem;
#ifndef HOST_WIN32
mono_w32handle_init ();
+ mono_w32handle_namespace_init ();
wapi_init ();
#endif
+ mono_w32mutex_init ();
+ mono_w32semaphore_init ();
+ mono_w32event_init ();
+
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters_init ();
#endif
mono_profiler_appdomain_name (domain, domain->friendly_name);
- /* Have to do this quite late so that we at least have System.Object */
- MonoError custom_attr_error;
- if (mono_assembly_get_reference_assembly_attribute (ass, &custom_attr_error)) {
- char *corlib_file = g_build_filename (mono_assembly_getrootdir (), "mono", current_runtime->framework_version, "mscorlib.dll", NULL);
- g_print ("Could not load file or assembly %s. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.", corlib_file);
- g_free (corlib_file);
- exit (1);
- }
- mono_error_assert_ok (&custom_attr_error);
-
return domain;
}
g_hash_table_destroy (domain->generic_virtual_cases);
domain->generic_virtual_cases = NULL;
}
- if (domain->generic_virtual_thunks) {
- g_hash_table_destroy (domain->generic_virtual_thunks);
- domain->generic_virtual_thunks = NULL;
- }
if (domain->ftnptrs_hash) {
g_hash_table_destroy (domain->ftnptrs_hash);
domain->ftnptrs_hash = NULL;
}
}
- free (messages);
+ g_free (messages);
return g_string_free (text, FALSE);
#else
return g_strdup ("");
MonoRawHandle mono_stack_mark_pop_value (MonoThreadInfo *info, HandleStackMark *stackmark, MonoRawHandle value);
void mono_stack_mark_record_size (MonoThreadInfo *info, HandleStackMark *stackmark, const char *func_name);
-static void
+static inline void
mono_stack_mark_init (MonoThreadInfo *info, HandleStackMark *stackmark)
{
HandleStack *handles = (HandleStack *)info->handle_stack;
stackmark->chunk = handles->top;
}
-static void
+static inline void
mono_stack_mark_pop (MonoThreadInfo *info, HandleStackMark *stackmark)
{
HandleStack *handles = (HandleStack *)info->handle_stack;
ICALL(ENV_20, "set_ExitCode", mono_environment_exitcode_set)
ICALL_TYPE(GC, "System.GC", GC_0)
-ICALL(GC_0, "CollectionCount", mono_gc_collection_count)
+ICALL(GC_0, "GetCollectionCount", mono_gc_collection_count)
ICALL(GC_0a, "GetGeneration", mono_gc_get_generation)
+ICALL(GC_0b, "GetMaxGeneration", mono_gc_max_generation)
ICALL(GC_1, "GetTotalMemory", ves_icall_System_GC_GetTotalMemory)
ICALL(GC_2, "InternalCollect", ves_icall_System_GC_InternalCollect)
ICALL(GC_3, "KeepAlive", ves_icall_System_GC_KeepAlive)
-ICALL(GC_4, "ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize)
ICALL(GC_4a, "RecordPressure", mono_gc_add_memory_pressure)
-ICALL(GC_5, "SuppressFinalize", ves_icall_System_GC_SuppressFinalize)
ICALL(GC_6, "WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers)
-ICALL(GC_7, "get_MaxGeneration", mono_gc_max_generation)
+ICALL(GC_6b, "_ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize)
+ICALL(GC_7, "_SuppressFinalize", ves_icall_System_GC_SuppressFinalize)
ICALL(GC_9, "get_ephemeron_tombstone", ves_icall_System_GC_get_ephemeron_tombstone)
ICALL(GC_8, "register_ephemeron_array", ves_icall_System_GC_register_ephemeron_array)
#include <mono/metadata/threadpool-ms-io.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/reflection.h>
+#include <mono/metadata/image-internals.h>
#include <mono/metadata/assembly.h>
+#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/exception.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/file-mmap.h>
#include <mono/metadata/seq-points-data.h>
#include <mono/metadata/handle.h>
+#include <mono/metadata/w32mutex.h>
+#include <mono/metadata/w32semaphore.h>
+#include <mono/metadata/w32event.h>
#include <mono/io-layer/io-layer.h>
#include <mono/utils/monobitset.h>
#include <mono/utils/mono-time.h>
/* if we have no info we are optimistic and assume there is enough room */
if (!stack_addr)
return TRUE;
-#ifdef HOST_WIN32
- // FIXME: Windows dynamically extends the stack, so stack_addr might be close
- // to the current sp
- return TRUE;
-#endif
current = (guint8 *)&stack_addr;
if (current > stack_addr) {
if ((current - stack_addr) < min_size)
g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE);
file_idx = impl >> MONO_IMPLEMENTATION_BITS;
- module = mono_image_load_file_for_image (assembly->assembly->image, file_idx);
- if (!module)
+ module = mono_image_load_file_for_image_checked (assembly->assembly->image, file_idx, &error);
+ if (mono_error_set_pending_exception (&error) || !module)
return NULL;
}
else
mono_array_setref (res, j, rm);
}
else {
- MonoImage *m = mono_image_load_file_for_image (image, i + 1);
+ MonoImage *m = mono_image_load_file_for_image_checked (image, i + 1, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (!m) {
MonoString *fname = mono_string_new (mono_domain_get (), mono_metadata_string_heap (image, cols [MONO_FILE_NAME]));
mono_set_pending_exception (mono_get_exception_file_not_found2 (NULL, fname));
/* Append data from all modules in the assembly */
for (i = 0; i < table->rows; ++i) {
if (!(mono_metadata_decode_row_col (table, i, MONO_FILE_FLAGS) & FILE_CONTAINS_NO_METADATA)) {
- MonoImage *loaded_image = mono_assembly_load_module (image->assembly, i + 1);
+ MonoImage *loaded_image = mono_assembly_load_module_checked (image->assembly, i + 1, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (loaded_image) {
MonoArray *ex2;
MonoArray *res2;
if (strstr (codepage, "utf_8") != NULL)
*int_code_page |= 0x10000000;
- free (codepage);
+ g_free (codepage);
if (want_name && *int_code_page == -1)
return mono_string_new (mono_domain_get (), cset);
MonoImage *
mono_find_image_owner (void *ptr);
+MonoImage*
+mono_image_load_file_for_image_checked (MonoImage *image, int fileidx, MonoError *error);
+
+MonoImage*
+mono_image_load_module_checked (MonoImage *image, int idx, MonoError *error);
+
#endif /* __MONO_METADATA_IMAGE_INTERNALS_H__ */
};
static GHashTable *loaded_images_hashes [4] = {NULL, NULL, NULL, NULL};
-static GHashTable *get_loaded_images_hash (gboolean refonly)
+static GHashTable *
+get_loaded_images_hash (gboolean refonly)
{
int idx = refonly ? IMAGES_HASH_PATH_REFONLY : IMAGES_HASH_PATH;
return loaded_images_hashes [idx];
}
-static GHashTable *get_loaded_images_by_name_hash (gboolean refonly)
+static GHashTable *
+get_loaded_images_by_name_hash (gboolean refonly)
{
int idx = refonly ? IMAGES_HASH_NAME_REFONLY : IMAGES_HASH_NAME;
return loaded_images_hashes [idx];
}
+// Change the assembly set in `image` to the assembly set in `assemblyImage`. Halt if overwriting is attempted.
+// Can be used on modules loaded through either the "file" or "module" mechanism
+static gboolean
+assign_assembly_parent_for_netmodule (MonoImage *image, MonoImage *assemblyImage, MonoError *error)
+{
+ // Assembly to assign
+ MonoAssembly *assembly = assemblyImage->assembly;
+
+ while (1) {
+ // Assembly currently assigned
+ MonoAssembly *assemblyOld = image->assembly;
+ if (assemblyOld) {
+ if (assemblyOld == assembly)
+ return TRUE;
+ mono_error_set_bad_image (error, assemblyImage, "Attempted to load module %s which has already been loaded by assembly %s. This is not supported in Mono.", image->name, assemblyOld->image->name);
+ return FALSE;
+ }
+ gpointer result = InterlockedExchangePointer((gpointer *)&image->assembly, assembly);
+ if (result == assembly)
+ return TRUE;
+ }
+}
+
static gboolean debug_assembly_unload = FALSE;
#define mono_images_lock() if (mutex_inited) mono_os_mutex_lock (&images_mutex)
}
/**
- * mono_image_load_module:
+ * mono_image_load_module_checked:
*
* Load the module with the one-based index IDX from IMAGE and return it. Return NULL if
- * it cannot be loaded.
+ * it cannot be loaded. NULL without MonoError being set will be interpreted as "not found".
*/
MonoImage*
-mono_image_load_module (MonoImage *image, int idx)
+mono_image_load_module_checked (MonoImage *image, int idx, MonoError *error)
{
MonoTableInfo *t;
MonoTableInfo *file_table;
GList *list_iter, *valid_modules = NULL;
MonoImageOpenStatus status;
+ mono_error_init (error);
+
if ((image->module_count == 0) || (idx > image->module_count || idx <= 0))
return NULL;
if (image->modules_loaded [idx - 1])
}
if (valid) {
module_ref = g_build_filename (base_dir, name, NULL);
- image->modules [idx - 1] = mono_image_open_full (module_ref, &status, refonly);
- if (image->modules [idx - 1]) {
- mono_image_addref (image->modules [idx - 1]);
- image->modules [idx - 1]->assembly = image->assembly;
+ MonoImage *moduleImage = mono_image_open_full (module_ref, &status, refonly);
+ if (moduleImage) {
+ if (!assign_assembly_parent_for_netmodule (moduleImage, image, error)) {
+ mono_image_close (moduleImage);
+ g_free (module_ref);
+ g_free (base_dir);
+ g_list_free (valid_modules);
+ return NULL;
+ }
+
+ image->modules [idx - 1] = image;
+
#ifdef HOST_WIN32
if (image->modules [idx - 1]->is_module_handle)
mono_image_fixup_vtable (image->modules [idx - 1]);
return image->modules [idx - 1];
}
+MonoImage*
+mono_image_load_module (MonoImage *image, int idx)
+{
+ MonoError error;
+ MonoImage *result = mono_image_load_module_checked (image, idx, &error);
+ mono_error_assert_ok (&error);
+ return result;
+}
+
static gpointer
class_key_extract (gpointer value)
{
free_hash (cache->thunk_invoke_cache);
}
+static void
+mono_image_close_except_pools_all (MonoImage**images, int image_count)
+{
+ for (int i = 0; i < image_count; ++i) {
+ if (images [i]) {
+ if (!mono_image_close_except_pools (images [i]))
+ images [i] = NULL;
+ }
+ }
+}
+
/*
* Returns whether mono_image_close_finish() must be called as well.
* We must unload images in two steps because clearing the domain in
g_free (image->name);
g_free (image->guid);
g_free (image->version);
- g_free (image->files);
}
if (image->method_cache)
g_free (image->image_info);
}
- for (i = 0; i < image->module_count; ++i) {
- if (image->modules [i]) {
- if (!mono_image_close_except_pools (image->modules [i]))
- image->modules [i] = NULL;
- }
- }
+ mono_image_close_except_pools_all (image->files, image->file_count);
+ mono_image_close_except_pools_all (image->modules, image->module_count);
if (image->modules_loaded)
g_free (image->modules_loaded);
return TRUE;
}
+static void
+mono_image_close_all (MonoImage**images, int image_count)
+{
+ for (int i = 0; i < image_count; ++i) {
+ if (images [i])
+ mono_image_close_finish (images [i]);
+ }
+ if (images)
+ g_free (images);
+}
+
void
mono_image_close_finish (MonoImage *image)
{
image->references = NULL;
}
- for (i = 0; i < image->module_count; ++i) {
- if (image->modules [i])
- mono_image_close_finish (image->modules [i]);
- }
- if (image->modules)
- g_free (image->modules);
+ mono_image_close_all (image->files, image->file_count);
+ mono_image_close_all (image->modules, image->module_count);
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes -= mono_mempool_get_allocated (image->mempool);
return data;
}
+// Returning NULL with no error set will be interpeted as "not found"
MonoImage*
-mono_image_load_file_for_image (MonoImage *image, int fileidx)
+mono_image_load_file_for_image_checked (MonoImage *image, int fileidx, MonoError *error)
{
char *base_dir, *name;
MonoImage *res;
const char *fname;
guint32 fname_id;
+ mono_error_init (error);
+
if (fileidx < 1 || fileidx > t->rows)
return NULL;
} else {
int i;
/* g_print ("loaded file %s from %s (%p)\n", name, image->name, image->assembly); */
- res->assembly = image->assembly;
+ if (!assign_assembly_parent_for_netmodule (res, image, error)) {
+ mono_image_unlock (image);
+ mono_image_close (res);
+ return NULL;
+ }
+
for (i = 0; i < res->module_count; ++i) {
if (res->modules [i] && !res->modules [i]->assembly)
res->modules [i]->assembly = image->assembly;
}
- if (!image->files)
+ if (!image->files) {
image->files = g_new0 (MonoImage*, t->rows);
+ image->file_count = t->rows;
+ }
image->files [fileidx - 1] = res;
mono_image_unlock (image);
/* vtable fixup can't happen with the image lock held */
return res;
}
+MonoImage*
+mono_image_load_file_for_image (MonoImage *image, int fileidx)
+{
+ MonoError error;
+ MonoImage *result = mono_image_load_file_for_image_checked (image, fileidx, &error);
+ mono_error_assert_ok (&error);
+ return result;
+}
+
/**
* mono_image_get_strong_name:
* @image: a MonoImage
#include <stdio.h>
#include <mono/utils/mono-publib.h>
+#include <mono/utils/mono-error.h>
MONO_BEGIN_DECLS
MONO_API uint32_t mono_image_get_entry_point (MonoImage *image);
MONO_API const char *mono_image_get_resource (MonoImage *image, uint32_t offset, uint32_t *size);
-MONO_API MonoImage* mono_image_load_file_for_image (MonoImage *image, int fileidx);
+MONO_RT_EXTERNAL_ONLY MONO_API MonoImage* mono_image_load_file_for_image (MonoImage *image, int fileidx);
-MONO_API MonoImage* mono_image_load_module (MonoImage *image, int idx);
+MONO_RT_EXTERNAL_ONLY MONO_API MonoImage* mono_image_load_module (MonoImage *image, int idx);
MONO_API const char* mono_image_get_name (MonoImage *image);
MONO_API const char* mono_image_get_filename (MonoImage *image);
return res;
}
+void
+mono_loader_register_module (const char *name, MonoDl *module)
+{
+ if (!global_module_map)
+ global_module_map = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (global_module_map, g_strdup (name), module);
+}
+
static MonoDl *internal_module;
static gboolean
AsyncStackWalkUserData ud = { func, user_data };
mono_sigctx_to_monoctx (initial_sig_context, &ctx);
- mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, NULL, MONO_UNWIND_SIGNAL_SAFE, &ud);
+ mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (async_stack_walk_adapter, &ctx, MONO_UNWIND_SIGNAL_SAFE, &ud);
}
static gboolean
#include <mono/metadata/metadata.h>
#include <mono/metadata/image.h>
#include <mono/utils/mono-error.h>
+#include <mono/utils/mono-dl.h>
MONO_BEGIN_DECLS
void*
mono_lookup_internal_call_full (MonoMethod *method, mono_bool *uses_handles);
+void
+mono_loader_register_module (const char *name, MonoDl *module);
MONO_API const char*
mono_lookup_icall_symbol (MonoMethod *m);
len += bytes_converted + 1;
}
- darwin_locale = (char *) malloc (len + 1);
+ darwin_locale = (char *) g_malloc (len + 1);
CFStringGetBytes (locale_language, CFRangeMake (0, CFStringGetLength (locale_language)), kCFStringEncodingMacRoman, 0, FALSE, (UInt8 *) darwin_locale, len, &bytes_converted);
darwin_locale[bytes_converted] = '-';
if (locale_cfstr) {
len = CFStringGetMaximumSizeForEncoding (CFStringGetLength (locale_cfstr), kCFStringEncodingMacRoman) + 1;
- darwin_locale = (char *) malloc (len);
+ darwin_locale = (char *) g_malloc (len);
if (!CFStringGetCString (locale_cfstr, darwin_locale, len, kCFStringEncodingMacRoman)) {
- free (darwin_locale);
+ g_free (darwin_locale);
CFRelease (locale);
darwin_locale = NULL;
return NULL;
if (klass->element_class->byval_arg.type == MONO_TYPE_CLASS) {
for(i = 0; i < array->max_length; ++i)
mono_marshal_free_ccw (mono_array_get (array, MonoObject*, i));
- free(nativeArray);
+ g_free (nativeArray);
}
#endif
}
for (i = 1; i < symbols; ++i) {
g_print ("\t%s\n", names [i]);
}
- free (names);
+ g_free (names);
mono_os_mutex_unlock (&mempool_tracing_lock);
}
struct _MonoImage {
/*
- * The number of assemblies which reference this MonoImage though their 'image'
- * field plus the number of images which reference this MonoImage through their
- * 'modules' field, plus the number of threads holding temporary references to
- * this image between calls of mono_image_open () and mono_image_close ().
+ * This count is incremented during these situations:
+ * - An assembly references this MonoImage though its 'image' field
+ * - This MonoImage is present in the 'files' field of an image
+ * - This MonoImage is present in the 'modules' field of an image
+ * - A thread is holding a temporary reference to this MonoImage between
+ * calls to mono_image_open and mono_image_close ()
*/
int ref_count;
MonoAssembly **references;
int nreferences;
- /* Code files in the assembly. */
+ /* Code files in the assembly. The main assembly has a "file" table and also a "module"
+ * table, where the module table is a subset of the file table. We track both lists,
+ * and because we can lazy-load them at different times we reference-increment both.
+ */
MonoImage **modules;
guint32 module_count;
gboolean *modules_loaded;
- /*
- * Files in the assembly. Items are either NULL or alias items in modules, so this does not impact ref_count.
- * Protected by the image lock.
- */
MonoImage **files;
+ guint32 file_count;
gpointer aot_module;
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/marshal.h>
+#include <mono/metadata/w32event.h>
#include <mono/utils/mono-threads.h>
#include <mono/metadata/profiler-private.h>
#include <mono/utils/mono-time.h>
#endif
thread = mono_thread_internal_current ();
- mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
+ /*
+ * If we allow interruption, we check the test state for an abort request before going into sleep.
+ * This is a workaround to the fact that Thread.Abort does non-sticky interruption of semaphores.
+ *
+ * Semaphores don't support the sticky interruption with mono_thread_info_install_interrupt.
+ *
+ * A better fix would be to switch to wait with something that allows sticky interrupts together
+ * with wrapping it with abort_protected_block_count for the non-alertable cases.
+ * And somehow make this whole dance atomic and not crazy expensive. Good luck.
+ *
+ */
+ if (allow_interruption) {
+ if (!mono_thread_test_and_set_state (thread, (MonoThreadState)(ThreadState_StopRequested | ThreadState_AbortRequested), ThreadState_WaitSleepJoin)) {
+ wait_ret = MONO_SEM_TIMEDWAIT_RET_ALERTED;
+ goto done_waiting;
+ }
+ } else {
+ mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
+ }
/*
* We pass ALERTABLE instead of allow_interruption since we have to check for the
wait_ret = mono_coop_sem_timedwait (mon->entry_sem, waitms, MONO_SEM_FLAGS_ALERTABLE);
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
-
+
+done_waiting:
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->thread_queue_len--;
#endif
gboolean
mono_monitor_enter (MonoObject *obj)
{
+ gint32 res;
+ gboolean allow_interruption = TRUE;
if (G_UNLIKELY (!obj)) {
mono_set_pending_exception (mono_get_exception_argument_null ("obj"));
return FALSE;
}
- return mono_monitor_try_enter_internal (obj, INFINITE, FALSE) == 1;
+
+ /*
+ * An inquisitive mind could ask what's the deal with this loop.
+ * It exists to deal with interrupting a monitor enter that happened within an abort-protected block, like a .cctor.
+ *
+ * The thread will be set with a pending abort and the wait might even be interrupted. Either way, once we call mono_thread_interruption_checkpoint,
+ * it will return NULL meaning we can't be aborted right now. Once that happens we switch to non-alertable.
+ */
+ do {
+ res = mono_monitor_try_enter_internal (obj, INFINITE, allow_interruption);
+ /*This means we got interrupted during the wait and didn't got the monitor.*/
+ if (res == -1) {
+ MonoException *exc = mono_thread_interruption_checkpoint ();
+ if (exc) {
+ mono_set_pending_exception (exc);
+ return FALSE;
+ } else {
+ //we detected a pending interruption but it turned out to be a false positive, we ignore it from now on (this feels like a hack, right?, threads.c should give us less confusing directions)
+ allow_interruption = FALSE;
+ }
+ }
+ } while (res == -1);
+ return TRUE;
}
gboolean
ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (MonoObject *obj, guint32 ms, char *lockTaken)
{
gint32 res;
+ gboolean allow_interruption = TRUE;
if (G_UNLIKELY (!obj)) {
mono_set_pending_exception (mono_get_exception_argument_null ("obj"));
return;
}
do {
- res = mono_monitor_try_enter_internal (obj, ms, TRUE);
+ res = mono_monitor_try_enter_internal (obj, ms, allow_interruption);
/*This means we got interrupted during the wait and didn't got the monitor.*/
if (res == -1) {
MonoException *exc = mono_thread_interruption_checkpoint ();
if (exc) {
mono_set_pending_exception (exc);
return;
+ } else {
+ //we detected a pending interruption but it turned out to be a false positive, we ignore it from now on (this feels like a hack, right?, threads.c should give us less confusing directions)
+ allow_interruption = FALSE;
}
}
} while (res == -1);
if (mon->wait_list != NULL) {
LOCK_DEBUG (g_message ("%s: (%d) signalling and dequeuing handle %p", __func__, mono_thread_info_get_small_id (), mon->wait_list->data));
- SetEvent (mon->wait_list->data);
+ mono_w32event_set (mon->wait_list->data);
mon->wait_list = g_slist_remove (mon->wait_list, mon->wait_list->data);
}
}
while (mon->wait_list != NULL) {
LOCK_DEBUG (g_message ("%s: (%d) signalling and dequeuing handle %p", __func__, mono_thread_info_get_small_id (), mon->wait_list->data));
- SetEvent (mon->wait_list->data);
+ mono_w32event_set (mon->wait_list->data);
mon->wait_list = g_slist_remove (mon->wait_list, mon->wait_list->data);
}
}
if (mono_thread_current_check_pending_interrupt ())
return FALSE;
- event = CreateEvent (NULL, FALSE, FALSE, NULL);
+ event = mono_w32event_create (FALSE, FALSE);
if (event == NULL) {
mono_set_pending_exception (mono_get_exception_synchronization_lock ("Failed to set up wait event"));
return FALSE;
return FALSE;
// Allocate suffcient memory for available data based on the previous sysctl call
- if ((buf = malloc(needed)) == NULL)
+ if ((buf = g_malloc (needed)) == NULL)
return FALSE;
// Second sysctl call to retrieve data into appropriately sized buffer
mono_array_setref (*gw_addr_list, gwnum, addr_string);
gwnum++;
}
- free(buf);
+ g_free (buf);
return TRUE;
}
void *
mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
{
- MonoObject *obj = calloc (1, size);
+ MonoObject *obj = g_calloc (1, size);
obj->vtable = vtable;
void *
mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length)
{
- MonoArray *obj = calloc (1, size);
+ MonoArray *obj = g_calloc (1, size);
obj->obj.vtable = vtable;
obj->max_length = max_length;
void *
mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size)
{
- MonoArray *obj = calloc (1, size);
+ MonoArray *obj = g_calloc (1, size);
obj->obj.vtable = vtable;
obj->max_length = max_length;
void *
mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len)
{
- MonoString *obj = calloc (1, size);
+ MonoString *obj = g_calloc (1, size);
obj->object.vtable = vtable;
obj->length = len;
gsize flags;
gpointer thread_pinning_ref;
gsize abort_protected_block_count;
+ gint32 priority;
+ GPtrArray *owned_mutexes;
/*
* These fields are used to avoid having to increment corlib versions
* when a new field is added to this structure.
*/
gsize unused1;
gsize unused2;
+
+ /* This is used only to check that we are in sync between the representation
+ * of MonoInternalThread in native and InternalThread in managed
+ *
+ * DO NOT RENAME! DO NOT ADD FIELDS AFTER! */
+ gpointer last;
};
struct _MonoThread {
struct _MonoInternalThread *internal_thread;
MonoObject *start_obj;
MonoException *pending_exception;
- gint32 priority;
};
typedef struct {
guint8 has_target_code;
};
-typedef gpointer (*MonoImtThunkBuilder) (MonoVTable *vtable, MonoDomain *domain,
+typedef gpointer (*MonoImtTrampolineBuilder) (MonoVTable *vtable, MonoDomain *domain,
MonoIMTCheckItem **imt_entries, int count, gpointer fail_trunk);
void
-mono_install_imt_thunk_builder (MonoImtThunkBuilder func);
+mono_install_imt_trampoline_builder (MonoImtTrampolineBuilder func);
void
-mono_set_always_build_imt_thunks (gboolean value);
+mono_set_always_build_imt_trampolines (gboolean value);
void
mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot);
MonoMethod *method, gpointer code);
gpointer
-mono_method_alloc_generic_virtual_thunk (MonoDomain *domain, int size);
+mono_method_alloc_generic_virtual_trampoline (MonoDomain *domain, int size);
typedef enum {
MONO_UNHANDLED_POLICY_LEGACY,
DECL_OFFSET(MonoInternalThread, tid)
DECL_OFFSET(MonoInternalThread, small_id)
DECL_OFFSET(MonoInternalThread, static_data)
+DECL_OFFSET(MonoInternalThread, last)
DECL_OFFSET(MonoMulticastDelegate, delegates)
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/w32event.h>
#include <mono/utils/strenc.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-error-internals.h>
}
static MonoDelegateTrampoline arch_create_delegate_trampoline = default_delegate_trampoline;
-static MonoImtThunkBuilder imt_thunk_builder;
-static gboolean always_build_imt_thunks;
+static MonoImtTrampolineBuilder imt_trampoline_builder;
+static gboolean always_build_imt_trampolines;
#if (MONO_IMT_SIZE > 32)
#error "MONO_IMT_SIZE cannot be larger than 32"
}
void
-mono_install_imt_thunk_builder (MonoImtThunkBuilder func) {
- imt_thunk_builder = func;
+mono_install_imt_trampoline_builder (MonoImtTrampolineBuilder func)
+{
+ imt_trampoline_builder = func;
}
void
-mono_set_always_build_imt_thunks (gboolean value)
+mono_set_always_build_imt_trampolines (gboolean value)
{
- always_build_imt_thunks = value;
+ always_build_imt_trampolines = value;
}
/**
break;
}
- free (hashes_start);
+ g_free (hashes_start);
/* Report the result */
return c % MONO_IMT_SIZE;
}
imt_emit_ir (sorted_array, 0, number_of_entries, result);
- free (sorted_array);
+ g_free (sorted_array);
return result;
}
MONO_REQ_GC_NEUTRAL_MODE;
if (imt_builder_entry != NULL) {
- if (imt_builder_entry->children == 0 && !fail_tramp && !always_build_imt_thunks) {
+ if (imt_builder_entry->children == 0 && !fail_tramp && !always_build_imt_trampolines) {
/* No collision, return the vtable slot contents */
return vtable->vtable [imt_builder_entry->value.vtable_slot];
} else {
- /* Collision, build the thunk */
+ /* Collision, build the trampoline */
GPtrArray *imt_ir = imt_sort_slot_entries (imt_builder_entry);
gpointer result;
int i;
- result = imt_thunk_builder (vtable, domain,
+ result = imt_trampoline_builder (vtable, domain,
(MonoIMTCheckItem**)imt_ir->pdata, imt_ir->len, fail_tramp);
for (i = 0; i < imt_ir->len; ++i)
g_free (g_ptr_array_index (imt_ir, i));
if (has_generic_virtual || has_variant_iface) {
/*
- * There might be collisions later when the the thunk is expanded.
+ * There might be collisions later when the the trampoline is expanded.
*/
imt_collisions_bitmap |= (1 << i);
/*
- * The IMT thunk might be called with an instance of one of the
+ * The IMT trampoline might be called with an instance of one of the
* generic virtual methods, so has to fallback to the IMT trampoline.
*/
imt [i] = initialize_imt_slot (vt, domain, imt_builder [i], callbacks.get_imt_trampoline (vt, i));
entry = next;
}
}
- free (imt_builder);
+ g_free (imt_builder);
/* we OR the bitmap since we may build just a single imt slot at a time */
vt->imt_collisions_bitmap |= imt_collisions_bitmap;
}
* @imt_slot: slot in the IMT table
*
* Fill the given @imt_slot in the IMT table of @vtable with
- * a trampoline or a thunk for the case of collisions.
+ * a trampoline or a trampoline for the case of collisions.
* This is part of the internal mono API.
*
* LOCKING: Take the domain lock.
mono_loader_unlock ();
}
-
-/*
- * The first two free list entries both belong to the wait list: The
- * first entry is the pointer to the head of the list and the second
- * entry points to the last element. That way appending and removing
- * the first element are both O(1) operations.
- */
-#ifdef MONO_SMALL_CONFIG
-#define NUM_FREE_LISTS 6
-#else
-#define NUM_FREE_LISTS 12
-#endif
-#define FIRST_FREE_LIST_SIZE 64
-#define MAX_WAIT_LENGTH 50
#define THUNK_THRESHOLD 10
-/*
- * LOCKING: The domain lock must be held.
- */
-static void
-init_thunk_free_lists (MonoDomain *domain)
-{
- MONO_REQ_GC_NEUTRAL_MODE;
-
- if (domain->thunk_free_lists)
- return;
- domain->thunk_free_lists = (MonoThunkFreeList **)mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS);
-}
-
-static int
-list_index_for_size (int item_size)
-{
- int i = 2;
- int size = FIRST_FREE_LIST_SIZE;
-
- while (item_size > size && i < NUM_FREE_LISTS - 1) {
- i++;
- size <<= 1;
- }
-
- return i;
-}
-
/**
- * mono_method_alloc_generic_virtual_thunk:
+ * mono_method_alloc_generic_virtual_trampoline:
* @domain: a domain
* @size: size in bytes
*
* Allocs size bytes to be used for the code of a generic virtual
- * thunk. It's either allocated from the domain's code manager or
+ * trampoline. It's either allocated from the domain's code manager or
* reused from a previously invalidated piece.
*
* LOCKING: The domain lock must be held.
*/
gpointer
-mono_method_alloc_generic_virtual_thunk (MonoDomain *domain, int size)
+mono_method_alloc_generic_virtual_trampoline (MonoDomain *domain, int size)
{
MONO_REQ_GC_NEUTRAL_MODE;
static gboolean inited = FALSE;
- static int generic_virtual_thunks_size = 0;
-
- guint32 *p;
- int i;
- MonoThunkFreeList **l;
-
- init_thunk_free_lists (domain);
+ static int generic_virtual_trampolines_size = 0;
- size += sizeof (guint32);
- if (size < sizeof (MonoThunkFreeList))
- size = sizeof (MonoThunkFreeList);
-
- i = list_index_for_size (size);
- for (l = &domain->thunk_free_lists [i]; *l; l = &(*l)->next) {
- if ((*l)->size >= size) {
- MonoThunkFreeList *item = *l;
- *l = item->next;
- return ((guint32*)item) + 1;
- }
- }
-
- /* no suitable item found - search lists of larger sizes */
- while (++i < NUM_FREE_LISTS) {
- MonoThunkFreeList *item = domain->thunk_free_lists [i];
- if (!item)
- continue;
- g_assert (item->size > size);
- domain->thunk_free_lists [i] = item->next;
- return ((guint32*)item) + 1;
- }
-
- /* still nothing found - allocate it */
if (!inited) {
- mono_counters_register ("Generic virtual thunk bytes",
- MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &generic_virtual_thunks_size);
+ mono_counters_register ("Generic virtual trampoline bytes",
+ MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &generic_virtual_trampolines_size);
inited = TRUE;
}
- generic_virtual_thunks_size += size;
-
- p = (guint32 *)mono_domain_code_reserve (domain, size);
- *p = size;
-
- mono_domain_lock (domain);
- if (!domain->generic_virtual_thunks)
- domain->generic_virtual_thunks = g_hash_table_new (NULL, NULL);
- g_hash_table_insert (domain->generic_virtual_thunks, p, p);
- mono_domain_unlock (domain);
-
- return p + 1;
-}
-
-/*
- * LOCKING: The domain lock must be held.
- */
-static void
-invalidate_generic_virtual_thunk (MonoDomain *domain, gpointer code)
-{
- MONO_REQ_GC_NEUTRAL_MODE;
-
- guint32 *p = (guint32 *)code;
- MonoThunkFreeList *l = (MonoThunkFreeList*)(p - 1);
- gboolean found = FALSE;
-
- mono_domain_lock (domain);
- if (!domain->generic_virtual_thunks)
- domain->generic_virtual_thunks = g_hash_table_new (NULL, NULL);
- if (g_hash_table_lookup (domain->generic_virtual_thunks, l))
- found = TRUE;
- mono_domain_unlock (domain);
-
- if (!found)
- /* Not allocated by mono_method_alloc_generic_virtual_thunk (), i.e. AOT */
- return;
- init_thunk_free_lists (domain);
-
- while (domain->thunk_free_lists [0] && domain->thunk_free_lists [0]->length >= MAX_WAIT_LENGTH) {
- MonoThunkFreeList *item = domain->thunk_free_lists [0];
- int length = item->length;
- int i;
-
- /* unlink the first item from the wait list */
- domain->thunk_free_lists [0] = item->next;
- domain->thunk_free_lists [0]->length = length - 1;
-
- i = list_index_for_size (item->size);
-
- /* put it in the free list */
- item->next = domain->thunk_free_lists [i];
- domain->thunk_free_lists [i] = item;
- }
-
- l->next = NULL;
- if (domain->thunk_free_lists [1]) {
- domain->thunk_free_lists [1] = domain->thunk_free_lists [1]->next = l;
- domain->thunk_free_lists [0]->length++;
- } else {
- g_assert (!domain->thunk_free_lists [0]);
+ generic_virtual_trampolines_size += size;
- domain->thunk_free_lists [0] = domain->thunk_free_lists [1] = l;
- domain->thunk_free_lists [0]->length = 1;
- }
+ return mono_domain_code_reserve (domain, size);
}
typedef struct _GenericVirtualCase {
* Registers a call via unmanaged code to a generic virtual method
* instantiation or variant interface method. If the number of calls reaches a threshold
* (THUNK_THRESHOLD), the method is added to the vtable slot's generic
- * virtual method thunk.
+ * virtual method trampoline.
*/
void
mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtable,
static gboolean inited = FALSE;
static int num_added = 0;
+ static int num_freed = 0;
GenericVirtualCase *gvc, *list;
MonoImtBuilderEntry *entries;
if (!domain->generic_virtual_cases)
domain->generic_virtual_cases = g_hash_table_new (mono_aligned_addr_hash, NULL);
+ if (!inited) {
+ mono_counters_register ("Generic virtual cases", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_added);
+ mono_counters_register ("Freed IMT trampolines", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_freed);
+ inited = TRUE;
+ }
+
/* Check whether the case was already added */
list = (GenericVirtualCase *)g_hash_table_lookup (domain->generic_virtual_cases, vtable_slot);
gvc = list;
g_hash_table_insert (domain->generic_virtual_cases, vtable_slot, gvc);
- if (!inited) {
- mono_counters_register ("Generic virtual cases", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_added);
- inited = TRUE;
- }
num_added++;
}
int displacement = (gpointer*)vtable_slot - (gpointer*)vtable;
int imt_slot = MONO_IMT_SIZE + displacement;
- /* Force the rebuild of the thunk at the next call */
+ /* Force the rebuild of the trampoline at the next call */
imt_trampoline = callbacks.get_imt_trampoline (vtable, imt_slot);
*vtable_slot = imt_trampoline;
} else {
sorted = imt_sort_slot_entries (entries);
- *vtable_slot = imt_thunk_builder (NULL, domain, (MonoIMTCheckItem**)sorted->pdata, sorted->len,
- vtable_trampoline);
+ *vtable_slot = imt_trampoline_builder (NULL, domain, (MonoIMTCheckItem**)sorted->pdata, sorted->len,
+ vtable_trampoline);
while (entries) {
MonoImtBuilderEntry *next = entries->next;
for (i = 0; i < sorted->len; ++i)
g_free (g_ptr_array_index (sorted, i));
g_ptr_array_free (sorted, TRUE);
- }
-#ifndef __native_client__
- /* We don't re-use any thunks as there is a lot of overhead */
- /* to deleting and re-using code in Native Client. */
- if (old_thunk != vtable_trampoline && old_thunk != imt_trampoline)
- invalidate_generic_virtual_thunk (domain, old_thunk);
-#endif
+ if (old_thunk != vtable_trampoline && old_thunk != imt_trampoline)
+ num_freed ++;
+ }
}
mono_domain_unlock (domain);
mono_monitor_exit ((MonoObject*) ares);
if (wait_event != NULL)
- SetEvent (wait_event);
+ mono_w32event_set (wait_event);
mono_error_init (&error); //the else branch would leave it in an undefined state
if (ac->cb_method)
mono_gc_alloc_fixed (size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg)
{
/* FIXME: do a single allocation */
- void *res = calloc (1, size);
+ void *res = g_calloc (1, size);
if (!res)
return NULL;
if (!mono_gc_register_root ((char *)res, size, descr, source, msg)) {
- free (res);
+ g_free (res);
res = NULL;
}
return res;
mono_gc_free_fixed (void* addr)
{
mono_gc_deregister_root ((char *)addr);
- free (addr);
+ g_free (addr);
}
/*
info->client_info.signal = 0;
#endif
- /* On win32, stack_start_limit should be 0, since the stack can grow dynamically */
mono_thread_info_get_stack_bounds (&staddr, &stsize);
if (staddr) {
-#ifndef HOST_WIN32
info->client_info.stack_start_limit = staddr;
-#endif
info->client_info.stack_end = staddr + stsize;
} else {
gsize stack_bottom = (gsize)stack_bottom_fallback;
* so we assume that if the domain is still registered, we can detach
* the thread
*/
- if (mono_domain_get ())
+ if (mono_thread_internal_current_is_attached ())
mono_thread_detach_internal (mono_thread_internal_current ());
}
CloseHandle (handle);
- return result != (DWORD)-1;
+ return result != (DWORD)-1 && result > 0;
}
gboolean
g_free (entry);
}
-
-
static GENERATE_GET_CLASS_WITH_CACHE (marshal_as_attribute, System.Runtime.InteropServices, MarshalAsAttribute);
#ifndef DISABLE_REFLECTION_EMIT
static guint32 mono_image_get_inflated_method_token (MonoDynamicImage *assembly, MonoMethod *m);
static MonoMethod * inflate_method (MonoReflectionType *type, MonoObject *obj, MonoError *error);
-static guint32 create_typespec (MonoDynamicImage *assembly, MonoType *type);
-
#define mono_type_array_get_and_resolve(array, index, error) mono_reflection_type_get_handle ((MonoReflectionType*)mono_array_get (array, gpointer, index), error)
static void mono_image_module_basic_init (MonoReflectionModuleBuilder *module);
return mono_dynstream_insert_string (sh, str);
}
-static guint32
-string_heap_insert_mstring (MonoDynamicStream *sh, MonoString *str, MonoError *error)
-{
- return mono_dynstream_insert_mstring (sh, str, error);
-}
-
static guint32
mono_image_add_stream_data (MonoDynamicStream *stream, const char *data, guint32 len)
{
return mono_dynstream_add_data (stream, data, len);
}
-static guint32
-mono_image_add_stream_zero (MonoDynamicStream *stream, guint32 len)
-{
- return mono_dynstream_add_zero (stream, len);
-}
-
-static void
-stream_data_align (MonoDynamicStream *stream)
-{
- mono_dynstream_data_align (stream);
-}
-
/*
* Despite the name, we handle also TypeSpec (with the above helper).
*/
#endif
}
-#ifndef DISABLE_REFLECTION_EMIT
-static MonoClass *
-default_class_from_mono_type (MonoType *type)
-{
- MONO_REQ_GC_NEUTRAL_MODE;
-
- switch (type->type) {
- case MONO_TYPE_OBJECT:
- return mono_defaults.object_class;
- case MONO_TYPE_VOID:
- return mono_defaults.void_class;
- case MONO_TYPE_BOOLEAN:
- return mono_defaults.boolean_class;
- case MONO_TYPE_CHAR:
- return mono_defaults.char_class;
- case MONO_TYPE_I1:
- return mono_defaults.sbyte_class;
- case MONO_TYPE_U1:
- return mono_defaults.byte_class;
- case MONO_TYPE_I2:
- return mono_defaults.int16_class;
- case MONO_TYPE_U2:
- return mono_defaults.uint16_class;
- case MONO_TYPE_I4:
- return mono_defaults.int32_class;
- case MONO_TYPE_U4:
- return mono_defaults.uint32_class;
- case MONO_TYPE_I:
- return mono_defaults.int_class;
- case MONO_TYPE_U:
- return mono_defaults.uint_class;
- case MONO_TYPE_I8:
- return mono_defaults.int64_class;
- case MONO_TYPE_U8:
- return mono_defaults.uint64_class;
- case MONO_TYPE_R4:
- return mono_defaults.single_class;
- case MONO_TYPE_R8:
- return mono_defaults.double_class;
- case MONO_TYPE_STRING:
- return mono_defaults.string_class;
- default:
- g_warning ("default_class_from_mono_type: implement me 0x%02x\n", type->type);
- g_assert_not_reached ();
- }
-
- return NULL;
-}
-#endif
-
guint32
mono_reflection_method_count_clauses (MonoReflectionILGen *ilgen)
{
}
return mb->mhandle;
}
-
-static MonoClassField*
-fieldbuilder_to_mono_class_field (MonoClass *klass, MonoReflectionFieldBuilder* fb, MonoError *error)
-{
- MonoClassField *field;
- MonoType *custom;
-
- mono_error_init (error);
-
- field = g_new0 (MonoClassField, 1);
-
- field->name = mono_string_to_utf8_image (klass->image, fb->name, error);
- mono_error_assert_ok (error);
- if (fb->attrs || fb->modreq || fb->modopt) {
- MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)fb->type, error);
- if (!is_ok (error)) {
- g_free (field);
- return NULL;
- }
- field->type = mono_metadata_type_dup (NULL, type);
- field->type->attrs = fb->attrs;
-
- g_assert (image_is_dynamic (klass->image));
- custom = add_custom_modifiers ((MonoDynamicImage*)klass->image, field->type, fb->modreq, fb->modopt, error);
- g_free (field->type);
- if (!is_ok (error)) {
- g_free (field);
- return NULL;
- }
- field->type = mono_metadata_type_dup (klass->image, custom);
- g_free (custom);
- } else {
- field->type = mono_reflection_type_get_handle ((MonoReflectionType*)fb->type, error);
- if (!is_ok (error)) {
- g_free (field);
- return NULL;
- }
- }
- if (fb->offset != -1)
- field->offset = fb->offset;
- field->parent = klass;
- mono_save_custom_attrs (klass->image, field, fb->cattrs);
-
- // FIXME: Can't store fb->def_value/RVA, is it needed for field_on_insts ?
-
- return field;
-}
#endif
#ifndef DISABLE_REFLECTION_EMIT
#include <mono/metadata/object-internals.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/metadata/threadpool-ms-io.h>
+#include <mono/metadata/w32event.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-complex.h>
gboolean suspended;
} ThreadPool;
+typedef struct {
+ gint32 ref;
+ MonoCoopCond cond;
+} ThreadPoolDomainCleanupSemaphore;
+
typedef enum {
TRANSITION_WARMUP,
TRANSITION_INITIALIZING,
}
if (create) {
+ ThreadPoolDomainCleanupSemaphore *cleanup_semaphore;
+ cleanup_semaphore = g_new0 (ThreadPoolDomainCleanupSemaphore, 1);
+ cleanup_semaphore->ref = 2;
+ mono_coop_cond_init (&cleanup_semaphore->cond);
+
g_assert(!domain->cleanup_semaphore);
- domain->cleanup_semaphore = CreateSemaphore(NULL, 0, 1, NULL);
+ domain->cleanup_semaphore = cleanup_semaphore;
tpdomain = g_new0 (ThreadPoolDomain, 1);
tpdomain->domain = domain;
g_assert (tpdomain->domain->threadpool_jobs >= 0);
if (tpdomain->domain->threadpool_jobs == 0 && mono_domain_is_unloading (tpdomain->domain)) {
+ ThreadPoolDomainCleanupSemaphore *cleanup_semaphore;
gboolean removed;
removed = domain_remove(tpdomain);
g_assert (removed);
- g_assert(tpdomain->domain->cleanup_semaphore);
- ReleaseSemaphore (tpdomain->domain->cleanup_semaphore, 1, NULL);
+ cleanup_semaphore = (ThreadPoolDomainCleanupSemaphore*) tpdomain->domain->cleanup_semaphore;
+ g_assert (cleanup_semaphore);
+
+ mono_coop_cond_signal (&cleanup_semaphore->cond);
+
+ if (InterlockedDecrement (&cleanup_semaphore->ref) == 0) {
+ mono_coop_cond_destroy (&cleanup_semaphore->cond);
+ g_free (cleanup_semaphore);
+ tpdomain->domain->cleanup_semaphore = NULL;
+ }
+
domain_free (tpdomain);
tpdomain = NULL;
}
if (ares->handle) {
wait_event = mono_wait_handle_get_handle ((MonoWaitHandle*) ares->handle);
} else {
- wait_event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ wait_event = mono_w32event_create (TRUE, FALSE);
g_assert(wait_event);
MonoWaitHandle *wait_handle = mono_wait_handle_new (mono_object_domain (ares), wait_event, error);
if (!is_ok (error)) {
gboolean
mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout)
{
- guint32 res;
- gint64 now, end;
+ gint64 end;
ThreadPoolDomain *tpdomain;
+ ThreadPoolDomainCleanupSemaphore *cleanup_semaphore;
+ gboolean ret;
g_assert (domain);
g_assert (timeout >= -1);
mono_lazy_initialize(&status, initialize);
mono_coop_mutex_lock(&threadpool->domains_lock);
- tpdomain = domain_get(domain, FALSE);
+ tpdomain = domain_get (domain, FALSE);
if (!tpdomain || tpdomain->outstanding_request == 0) {
mono_coop_mutex_unlock(&threadpool->domains_lock);
return TRUE;
}
- g_assert(domain->cleanup_semaphore);
- if (timeout != -1) {
- now = mono_msec_ticks();
- if (now > end) {
- mono_coop_mutex_unlock(&threadpool->domains_lock);
- return FALSE;
- }
- }
+ g_assert (domain->cleanup_semaphore);
+ cleanup_semaphore = (ThreadPoolDomainCleanupSemaphore*) domain->cleanup_semaphore;
- MONO_ENTER_GC_SAFE;
- res = WaitForSingleObjectEx(domain->cleanup_semaphore, timeout != -1 ? end - now : timeout, FALSE);
- MONO_EXIT_GC_SAFE;
+ ret = TRUE;
- CloseHandle(domain->cleanup_semaphore);
- domain->cleanup_semaphore = NULL;
+ do {
+ if (timeout == -1) {
+ mono_coop_cond_wait (&cleanup_semaphore->cond, &threadpool->domains_lock);
+ } else {
+ gint64 now;
+ gint res;
+
+ now = mono_msec_ticks();
+ if (now > end) {
+ ret = FALSE;
+ break;
+ }
+
+ res = mono_coop_cond_timedwait (&cleanup_semaphore->cond, &threadpool->domains_lock, end - now);
+ if (res != 0) {
+ ret = FALSE;
+ break;
+ }
+ }
+ } while (tpdomain->outstanding_request != 0);
+
+ if (InterlockedDecrement (&cleanup_semaphore->ref) == 0) {
+ mono_coop_cond_destroy (&cleanup_semaphore->cond);
+ g_free (cleanup_semaphore);
+ domain->cleanup_semaphore = NULL;
+ }
mono_coop_mutex_unlock(&threadpool->domains_lock);
- return res == WAIT_OBJECT_0;
+ return ret;
}
void
ThreadApartmentState_Unknown = 0x00000002
} MonoThreadApartmentState;
+typedef enum {
+ MONO_THREAD_PRIORITY_LOWEST = 0,
+ MONO_THREAD_PRIORITY_BELOW_NORMAL = 1,
+ MONO_THREAD_PRIORITY_NORMAL = 2,
+ MONO_THREAD_PRIORITY_ABOVE_NORMAL = 3,
+ MONO_THREAD_PRIORITY_HIGHEST = 4,
+} MonoThreadPriority;
+
#define SPECIAL_STATIC_NONE 0
#define SPECIAL_STATIC_THREAD 1
#define SPECIAL_STATIC_CONTEXT 2
void ves_icall_System_Threading_Thread_SetCachedCurrentCulture (MonoThread *this_obj, MonoObject *culture);
MonoObject* ves_icall_System_Threading_Thread_GetCachedCurrentUICulture (MonoInternalThread *this_obj);
void ves_icall_System_Threading_Thread_SetCachedCurrentUICulture (MonoThread *this_obj, MonoObject *culture);
-HANDLE ves_icall_System_Threading_Mutex_CreateMutex_internal(MonoBoolean owned, MonoString *name, MonoBoolean *created);
-MonoBoolean ves_icall_System_Threading_Mutex_ReleaseMutex_internal (HANDLE handle );
-HANDLE ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights, gint32 *error);
-HANDLE ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error);
-MonoBoolean ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (HANDLE handle, gint32 releaseCount, gint32 *prevcount);
-HANDLE ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error);
-HANDLE ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error);
-gboolean ves_icall_System_Threading_Events_SetEvent_internal (HANDLE handle);
-gboolean ves_icall_System_Threading_Events_ResetEvent_internal (HANDLE handle);
-void ves_icall_System_Threading_Events_CloseEvent_internal (HANDLE handle);
-HANDLE ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error);
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms);
gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms);
void mono_thread_set_state (MonoInternalThread *thread, MonoThreadState state);
void mono_thread_clr_state (MonoInternalThread *thread, MonoThreadState state);
gboolean mono_thread_test_state (MonoInternalThread *thread, MonoThreadState test);
+gboolean mono_thread_test_and_set_state (MonoInternalThread *thread, MonoThreadState test, MonoThreadState set);
void mono_thread_init_apartment_state (void);
void mono_thread_cleanup_apartment_state (void);
void mono_threads_end_abort_protected_block (void);
MonoException* mono_thread_try_resume_interruption (void);
+gboolean
+mono_thread_internal_current_is_attached (void);
+
+void
+mono_thread_internal_describe (MonoInternalThread *internal, GString *str);
+
+gboolean
+mono_thread_internal_is_current (MonoInternalThread *internal);
+
#endif /* _MONO_METADATA_THREADS_TYPES_H_ */
#include <mono/utils/mono-threads-coop.h>
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/w32handle.h>
+#include <mono/metadata/w32event.h>
+#include <mono/metadata/w32mutex.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/abi-details.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
MonoThread *thread;
thread = create_thread_object (domain);
- thread->priority = MONO_THREAD_PRIORITY_NORMAL;
MONO_OBJECT_SETREF (thread, internal_thread, internal);
MONO_GC_REGISTER_ROOT_PINNING (thread->thread_pinning_ref, MONO_ROOT_SOURCE_THREADING, "thread pinning reference");
}
+ thread->priority = MONO_THREAD_PRIORITY_NORMAL;
+
return thread;
}
+static void
+mono_thread_internal_set_priority (MonoInternalThread *internal, MonoThreadPriority priority)
+{
+ g_assert (internal);
+ g_assert (internal->handle);
+
+ g_assert (priority >= MONO_THREAD_PRIORITY_LOWEST);
+ g_assert (priority <= MONO_THREAD_PRIORITY_HIGHEST);
+ g_assert (MONO_THREAD_PRIORITY_LOWEST < MONO_THREAD_PRIORITY_HIGHEST);
+
+#ifdef HOST_WIN32
+ BOOL res;
+
+ res = SetThreadPriority (internal->handle, priority - 2);
+ if (!res)
+ g_error ("%s: SetThreadPriority failed, error %d", __func__, GetLastError ());
+#else /* HOST_WIN32 */
+ pthread_t tid;
+ int policy;
+ struct sched_param param;
+ gint res;
+
+ tid = thread_get_tid (internal);
+
+ res = pthread_getschedparam (tid, &policy, ¶m);
+ if (res != 0)
+ g_error ("%s: pthread_getschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res);
+
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ int max, min;
+
+ /* Necessary to get valid priority range */
+
+ min = sched_get_priority_min (policy);
+ max = sched_get_priority_max (policy);
+
+ if (max > 0 && min >= 0 && max > min) {
+ double srange, drange, sposition, dposition;
+ srange = MONO_THREAD_PRIORITY_HIGHEST - MONO_THREAD_PRIORITY_LOWEST;
+ drange = max - min;
+ sposition = priority - MONO_THREAD_PRIORITY_LOWEST;
+ dposition = (sposition / srange) * drange;
+ param.sched_priority = (int)(dposition + min);
+ } else
+#endif
+ {
+ switch (policy) {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ param.sched_priority = 50;
+ break;
+#ifdef SCHED_BATCH
+ case SCHED_BATCH:
+#endif
+ case SCHED_OTHER:
+ param.sched_priority = 0;
+ break;
+ default:
+ g_error ("%s: unknown policy %d", __func__, policy);
+ }
+ }
+
+ res = pthread_setschedparam (tid, policy, ¶m);
+ if (res != 0) {
+ if (res == EPERM) {
+ g_warning ("%s: pthread_setschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res);
+ return;
+ }
+ g_error ("%s: pthread_setschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res);
+ }
+#endif /* HOST_WIN32 */
+}
+
static void
mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset, gboolean threadlocal);
info = mono_thread_info_current ();
internal = thread->internal_thread;
- internal->handle = mono_thread_info_get_handle (info);
+ internal->handle = mono_thread_info_duplicate_handle (info);
internal->tid = MONO_NATIVE_THREAD_ID_TO_UINT (mono_native_thread_id_get ());
internal->thread_info = info;
internal->small_id = info->small_id;
return 0;
}
+ mono_thread_internal_set_priority (internal, internal->priority);
+
tid = internal->tid;
start_delegate = start_info->start_delegate;
* for the current thead */
mono_thread_cleanup_apartment_state ();
- thread_cleanup (internal);
+ mono_thread_detach_internal (internal);
internal->tid = 0;
- /* Remove the reference to the thread object in the TLS data,
- * so the thread object can be finalized. This won't be
- * reached if the thread threw an uncaught exception, so those
- * thread handles will stay referenced :-( (This is due to
- * missing support for scanning thread-specific data in the
- * Boehm GC - the io-layer keeps a GC-visible hash of pointers
- * to TLS data.)
- */
- SET_CURRENT_OBJECT (NULL);
-
return(0);
}
StartInfo *start_info = NULL;
HANDLE thread_handle;
MonoNativeThreadId tid;
- MonoThreadParm tp;
gboolean ret;
if (start_delegate)
if (stack_size == 0)
stack_size = default_stacksize_for_thread (internal);
- tp.priority = thread->priority;
- tp.stack_size = stack_size;
- tp.creation_flags = 0;
-
- thread_handle = mono_threads_create_thread (start_wrapper, start_info, &tp, &tid);
+ thread_handle = mono_threads_create_thread (start_wrapper, start_info, stack_size, &tid);
if (thread_handle == NULL) {
/* The thread couldn't be created, so set an exception */
mono_coop_sem_wait (&start_info->registered, MONO_SEM_FLAGS_NONE);
+ mono_threads_close_thread_handle (thread_handle);
+
THREAD_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") Done launching thread %p (%"G_GSIZE_FORMAT")", __func__, mono_native_thread_id_get (), internal, (gsize)internal->tid));
ret = !start_info->failed;
mono_error_init (error);
thread = create_thread_object (domain);
- thread->priority = MONO_THREAD_PRIORITY_NORMAL;
internal = create_internal_thread ();
MONO_OBJECT_SETREF (thread, internal_thread, internal);
+ LOCK_THREAD (internal);
+
res = create_thread (thread, internal, NULL, (MonoThreadStart) func, arg, threadpool_thread, stack_size, error);
return_val_if_nok (error, NULL);
- /* Check that the managed and unmanaged layout of MonoInternalThread matches */
-#ifndef MONO_CROSS_COMPILE
- if (mono_check_corlib_version () == NULL)
- g_assert (((char*)&internal->unused2 - (char*)internal) == mono_defaults.internal_thread_class->fields [mono_defaults.internal_thread_class->field.count - 1].offset);
-#endif
+ UNLOCK_THREAD (internal);
return internal;
}
MonoNativeThreadId tid;
gsize stack_ptr;
- if ((internal = mono_thread_internal_current ())) {
+ if (mono_thread_internal_current_is_attached ()) {
if (domain != mono_domain_get ())
mono_domain_set (domain, TRUE);
/* Already attached */
THREAD_DEBUG (g_message ("%s: mono_thread_detach for %p (%"G_GSIZE_FORMAT")", __func__, thread, (gsize)thread->tid));
+#ifndef HOST_WIN32
+ mono_w32mutex_abandon ();
+#endif
+
thread_cleanup (thread);
SET_CURRENT_OBJECT (NULL);
return FALSE;
}
+gboolean
+mono_thread_internal_current_is_attached (void)
+{
+ MonoInternalThread *internal;
+
+ internal = GET_CURRENT_OBJECT ();
+ if (!internal)
+ return FALSE;
+
+ return TRUE;
+}
+
void
mono_thread_exit (void)
{
THREAD_DEBUG (g_message ("%s: mono_thread_exit for %p (%"G_GSIZE_FORMAT")", __func__, thread, (gsize)thread->tid));
- thread_cleanup (thread);
- SET_CURRENT_OBJECT (NULL);
- mono_domain_unset ();
+ mono_thread_detach_internal (thread);
/* we could add a callback here for embedders to use. */
if (mono_thread_get_main () && (thread == mono_thread_get_main ()->internal_thread))
exit (mono_environment_exitcode_get ());
+
mono_thread_info_exit ();
}
MonoInternalThread *internal = this_obj->internal_thread;
LOCK_THREAD (internal);
- if (internal->handle != NULL)
- priority = mono_thread_info_get_priority ((MonoThreadInfo*) internal->thread_info);
- else
- priority = this_obj->priority;
+ priority = internal->priority;
UNLOCK_THREAD (internal);
+
return priority;
}
MonoInternalThread *internal = this_obj->internal_thread;
LOCK_THREAD (internal);
- this_obj->priority = priority;
+ internal->priority = priority;
if (internal->handle != NULL)
- mono_thread_info_set_priority ((MonoThreadInfo*) internal->thread_info, this_obj->priority);
+ mono_thread_internal_set_priority (internal, priority);
UNLOCK_THREAD (internal);
}
THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") returning %d", __func__, mono_native_thread_id_get (), ret));
mono_error_set_pending_exception (&error);
- /*
- * These need to be here. See MSDN dos on WaitForMultipleObjects.
- */
- if (ret >= WAIT_OBJECT_0 && ret <= WAIT_OBJECT_0 + numhandles - 1) {
- return map_native_wait_result_to_managed (ret - WAIT_OBJECT_0);
- }
- else if (ret >= WAIT_ABANDONED_0 && ret <= WAIT_ABANDONED_0 + numhandles - 1) {
- return map_native_wait_result_to_managed (ret - WAIT_ABANDONED_0);
- }
- else {
- /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
- return map_native_wait_result_to_managed (ret);
- }
+
+ /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+ return map_native_wait_result_to_managed (ret);
}
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms)
return map_native_wait_result_to_managed (ret);
}
-HANDLE ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
-{
- HANDLE mutex;
-
- *created = TRUE;
-
- if (name == NULL) {
- mutex = CreateMutex (NULL, owned, NULL);
- } else {
- mutex = CreateMutex (NULL, owned, mono_string_chars (name));
-
- if (GetLastError () == ERROR_ALREADY_EXISTS) {
- *created = FALSE;
- }
- }
-
- return(mutex);
-}
-
-MonoBoolean ves_icall_System_Threading_Mutex_ReleaseMutex_internal (HANDLE handle ) {
- return(ReleaseMutex (handle));
-}
-
-HANDLE ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name,
- gint32 rights,
- gint32 *error)
-{
- HANDLE ret;
-
- *error = ERROR_SUCCESS;
-
- ret = OpenMutex (rights, FALSE, mono_string_chars (name));
- if (ret == NULL) {
- *error = GetLastError ();
- }
-
- return(ret);
-}
-
-
-HANDLE ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error)
-{
- HANDLE sem;
-
- if (name == NULL) {
- sem = CreateSemaphore (NULL, initialCount, maximumCount, NULL);
- } else {
- sem = CreateSemaphore (NULL, initialCount, maximumCount,
- mono_string_chars (name));
- }
-
- *error = GetLastError ();
-
- return(sem);
-}
-
-MonoBoolean ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (HANDLE handle, gint32 releaseCount, gint32 *prevcount)
-{
- return ReleaseSemaphore (handle, releaseCount, prevcount);
-}
-
-HANDLE ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error)
-{
- HANDLE sem;
-
- sem = OpenSemaphore (rights, FALSE, mono_string_chars (name));
-
- *error = GetLastError ();
-
- return(sem);
-}
-
-HANDLE ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error)
-{
- HANDLE event;
-
- if (name == NULL) {
- event = CreateEvent (NULL, manual, initial, NULL);
- } else {
- event = CreateEvent (NULL, manual, initial,
- mono_string_chars (name));
- }
-
- *error = GetLastError ();
-
- return(event);
-}
-
-gboolean ves_icall_System_Threading_Events_SetEvent_internal (HANDLE handle) {
- return (SetEvent(handle));
-}
-
-gboolean ves_icall_System_Threading_Events_ResetEvent_internal (HANDLE handle) {
- return (ResetEvent(handle));
-}
-
-void
-ves_icall_System_Threading_Events_CloseEvent_internal (HANDLE handle) {
- CloseHandle (handle);
-}
-
-HANDLE ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name,
- gint32 rights,
- gint32 *error)
-{
- HANDLE ret;
-
- ret = OpenEvent (rights, FALSE, mono_string_chars (name));
- if (ret == NULL) {
- *error = GetLastError ();
- } else {
- *error = ERROR_SUCCESS;
- }
-
- return(ret);
-}
-
gint32 ves_icall_System_Threading_Interlocked_Increment_Int (gint32 *location)
{
return InterlockedIncrement (location);
* be notified, since it has to rebuild the list of threads to
* wait for.
*/
- SetEvent (background_change_event);
+ mono_w32event_set (background_change_event);
}
}
* be notified, since it has to rebuild the list of threads to
* wait for.
*/
- SetEvent (background_change_event);
+ mono_w32event_set (background_change_event);
}
}
mono_os_mutex_init_recursive(&interlocked_mutex);
mono_os_mutex_init_recursive(&joinable_threads_mutex);
- background_change_event = CreateEvent (NULL, TRUE, FALSE, NULL);
+ background_change_event = mono_w32event_create (TRUE, FALSE);
g_assert(background_change_event != NULL);
mono_init_static_data_info (&thread_static_info);
UNLOCK_THREAD (current_thread);
}
- /*since we're killing the thread, unset the current domain.*/
- mono_domain_unset ();
+ /*since we're killing the thread, detach it.*/
+ mono_thread_detach_internal (current_thread);
/* Wake up other threads potentially waiting for us */
mono_thread_info_exit ();
* interrupt the main thread if it is waiting for all
* the other threads.
*/
- SetEvent (background_change_event);
+ mono_w32event_set (background_change_event);
mono_threads_unlock ();
}
THREAD_DEBUG (g_message ("%s: There are %d threads to join", __func__, mono_g_hash_table_size (threads));
mono_g_hash_table_foreach (threads, print_tids, NULL));
- ResetEvent (background_change_event);
+ mono_w32event_reset (background_change_event);
wait->num=0;
/*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
memset (wait->threads, 0, MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
#if 0
/* This no longer works with remote unwinding */
g_string_append_printf (text, " tid=0x%p this=0x%p ", (gpointer)(gsize)thread->tid, thread);
- mono_thread_info_describe (info, text);
+ mono_thread_internal_describe (thread, text);
g_string_append (text, "\n");
#endif
UNLOCK_THREAD (thread);
}
+/**
+ * mono_thread_test_and_set_state:
+ *
+ * Test if current state of @thread include @test. If it does not, OR @set into the state.
+ *
+ * Returns TRUE is @set was OR'd in.
+ */
+gboolean
+mono_thread_test_and_set_state (MonoInternalThread *thread, MonoThreadState test, MonoThreadState set)
+{
+ LOCK_THREAD (thread);
+
+ if ((thread->state & test) != 0) {
+ UNLOCK_THREAD (thread);
+ return FALSE;
+ }
+
+ thread->state |= set;
+ UNLOCK_THREAD (thread);
+
+ return TRUE;
+}
+
void
mono_thread_clr_state (MonoInternalThread *thread, MonoThreadState state)
{
return NULL;
return mono_thread_resume_interruption ();
-}
\ No newline at end of file
+}
+
+/* Returns TRUE if the current thread is ready to be interrupted. */
+gboolean
+mono_threads_is_ready_to_be_interrupted (void)
+{
+ MonoInternalThread *thread;
+
+ thread = mono_thread_internal_current ();
+ LOCK_THREAD (thread);
+ if (thread->state & (MonoThreadState)(ThreadState_StopRequested | ThreadState_SuspendRequested | ThreadState_AbortRequested)) {
+ UNLOCK_THREAD (thread);
+ return FALSE;
+ }
+
+ if (thread->abort_protected_block_count || mono_get_eh_callbacks ()->mono_current_thread_has_handle_block_guard ()) {
+ UNLOCK_THREAD (thread);
+ return FALSE;
+ }
+
+ UNLOCK_THREAD (thread);
+ return TRUE;
+}
+
+void
+mono_thread_internal_describe (MonoInternalThread *internal, GString *text)
+{
+ g_string_append_printf (text, ", thread handle : %p", internal->handle);
+
+ if (internal->thread_info) {
+ g_string_append (text, ", state : ");
+ mono_thread_info_describe_interrupt_token ((MonoThreadInfo*) internal->thread_info, text);
+ }
+
+ if (internal->owned_mutexes) {
+ int i;
+
+ g_string_append (text, ", owns : [");
+ for (i = 0; i < internal->owned_mutexes->len; i++)
+ g_string_append_printf (text, i == 0 ? "%p" : ", %p", g_ptr_array_index (internal->owned_mutexes, i));
+ g_string_append (text, "]");
+ }
+}
+
+gboolean
+mono_thread_internal_is_current (MonoInternalThread *internal)
+{
+ g_assert (internal);
+ return mono_native_thread_id_equals (mono_native_thread_id_get (), MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid));
+}
--- /dev/null
+/*
+ * w32event-unix.c: Runtime support for managed Event on Unix
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "w32event.h"
+
+#include "w32handle-namespace.h"
+#include "mono/io-layer/io-layer.h"
+#include "mono/utils/mono-logger-internals.h"
+#include "mono/utils/w32handle.h"
+
+typedef struct {
+ gboolean manual;
+ guint32 set_count;
+} MonoW32HandleEvent;
+
+struct MonoW32HandleNamedEvent {
+ MonoW32HandleEvent e;
+ MonoW32HandleNamespace sharedns;
+};
+
+static gboolean event_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
+{
+ MonoW32HandleEvent *event_handle;
+ gboolean ok;
+
+ *statuscode = WAIT_OBJECT_0;
+
+ ok = mono_w32handle_lookup (handle, type, (gpointer *)&event_handle);
+ if (!ok) {
+ g_warning ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ if (!event_handle->manual) {
+ g_assert (event_handle->set_count > 0);
+ event_handle->set_count --;
+
+ if (event_handle->set_count == 0)
+ mono_w32handle_set_signal_state (handle, FALSE, FALSE);
+ }
+
+ return TRUE;
+}
+
+static void event_signal(gpointer handle)
+{
+ ves_icall_System_Threading_Events_SetEvent_internal (handle);
+}
+
+static gboolean event_own (gpointer handle, guint32 *statuscode)
+{
+ return event_handle_own (handle, MONO_W32HANDLE_EVENT, statuscode);
+}
+
+static void namedevent_signal (gpointer handle)
+{
+ ves_icall_System_Threading_Events_SetEvent_internal (handle);
+}
+
+/* NB, always called with the shared handle lock held */
+static gboolean namedevent_own (gpointer handle, guint32 *statuscode)
+{
+ return event_handle_own (handle, MONO_W32HANDLE_NAMEDEVENT, statuscode);
+}
+
+static void event_details (gpointer data)
+{
+ MonoW32HandleEvent *event = (MonoW32HandleEvent *)data;
+ g_print ("manual: %s, set_count: %d",
+ event->manual ? "TRUE" : "FALSE", event->set_count);
+}
+
+static void namedevent_details (gpointer data)
+{
+ MonoW32HandleNamedEvent *namedevent = (MonoW32HandleNamedEvent *)data;
+ g_print ("manual: %s, set_count: %d, name: \"%s\"",
+ namedevent->e.manual ? "TRUE" : "FALSE", namedevent->e.set_count, namedevent->sharedns.name);
+}
+
+static const gchar* event_typename (void)
+{
+ return "Event";
+}
+
+static gsize event_typesize (void)
+{
+ return sizeof (MonoW32HandleEvent);
+}
+
+static const gchar* namedevent_typename (void)
+{
+ return "N.Event";
+}
+
+static gsize namedevent_typesize (void)
+{
+ return sizeof (MonoW32HandleNamedEvent);
+}
+
+void
+mono_w32event_init (void)
+{
+ static MonoW32HandleOps event_ops = {
+ NULL, /* close */
+ event_signal, /* signal */
+ event_own, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ event_details, /* details */
+ event_typename, /* typename */
+ event_typesize, /* typesize */
+ };
+
+ static MonoW32HandleOps namedevent_ops = {
+ NULL, /* close */
+ namedevent_signal, /* signal */
+ namedevent_own, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ namedevent_details, /* details */
+ namedevent_typename, /* typename */
+ namedevent_typesize, /* typesize */
+ };
+
+ mono_w32handle_register_ops (MONO_W32HANDLE_EVENT, &event_ops);
+ mono_w32handle_register_ops (MONO_W32HANDLE_NAMEDEVENT, &namedevent_ops);
+
+ mono_w32handle_register_capabilities (MONO_W32HANDLE_EVENT,
+ (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
+ mono_w32handle_register_capabilities (MONO_W32HANDLE_NAMEDEVENT,
+ (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
+}
+
+gpointer
+mono_w32event_create (gboolean manual, gboolean initial)
+{
+ gpointer handle;
+ gint32 error;
+
+ handle = ves_icall_System_Threading_Events_CreateEvent_internal (manual, initial, NULL, &error);
+ if (error != ERROR_SUCCESS)
+ g_assert (!handle);
+
+ return handle;
+}
+
+void
+mono_w32event_set (gpointer handle)
+{
+ ves_icall_System_Threading_Events_SetEvent_internal (handle);
+}
+
+void
+mono_w32event_reset (gpointer handle)
+{
+ ves_icall_System_Threading_Events_ResetEvent_internal (handle);
+}
+
+static gpointer event_handle_create (MonoW32HandleEvent *event_handle, MonoW32HandleType type, gboolean manual, gboolean initial)
+{
+ gpointer handle;
+ int thr_ret;
+
+ event_handle->manual = manual;
+ event_handle->set_count = (initial && !manual) ? 1 : 0;
+
+ handle = mono_w32handle_new (type, event_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating %s handle",
+ __func__, mono_w32handle_ops_typename (type));
+ SetLastError (ERROR_GEN_FAILURE);
+ return NULL;
+ }
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ if (initial)
+ mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ return handle;
+}
+
+static gpointer event_create (gboolean manual, gboolean initial)
+{
+ MonoW32HandleEvent event_handle;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
+ __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_EVENT));
+ return event_handle_create (&event_handle, MONO_W32HANDLE_EVENT, manual, initial);
+}
+
+static gpointer namedevent_create (gboolean manual, gboolean initial, const gunichar2 *name G_GNUC_UNUSED)
+{
+ gpointer handle;
+ gchar *utf8_name;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
+ __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDEVENT));
+
+ /* w32 seems to guarantee that opening named objects can't race each other */
+ mono_w32handle_namespace_lock ();
+
+ utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
+
+ handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDEVENT, utf8_name);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* The name has already been used for a different object. */
+ handle = NULL;
+ SetLastError (ERROR_INVALID_HANDLE);
+ } else if (handle) {
+ /* Not an error, but this is how the caller is informed that the event wasn't freshly created */
+ SetLastError (ERROR_ALREADY_EXISTS);
+
+ /* mono_w32handle_namespace_search_handle already adds a ref to the handle */
+ } else {
+ /* A new named event */
+ MonoW32HandleNamedEvent namedevent_handle;
+
+ strncpy (&namedevent_handle.sharedns.name [0], utf8_name, MAX_PATH);
+ namedevent_handle.sharedns.name [MAX_PATH] = '\0';
+
+ handle = event_handle_create ((MonoW32HandleEvent*) &namedevent_handle, MONO_W32HANDLE_NAMEDEVENT, manual, initial);
+ }
+
+ g_free (utf8_name);
+
+ mono_w32handle_namespace_unlock ();
+
+ return handle;
+}
+
+gpointer
+ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error)
+{
+ gpointer event;
+
+ /* Need to blow away any old errors here, because code tests
+ * for ERROR_ALREADY_EXISTS on success (!) to see if an event
+ * was freshly created */
+ SetLastError (ERROR_SUCCESS);
+
+ event = name ? namedevent_create (manual, initial, mono_string_chars (name)) : event_create (manual, initial);
+
+ *error = GetLastError ();
+
+ return event;
+}
+
+gboolean
+ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle)
+{
+ MonoW32HandleType type;
+ MonoW32HandleEvent *event_handle;
+ int thr_ret;
+
+ if (handle == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ switch (type = mono_w32handle_get_type (handle)) {
+ case MONO_W32HANDLE_EVENT:
+ case MONO_W32HANDLE_NAMEDEVENT:
+ break;
+ default:
+ SetLastError (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&event_handle)) {
+ g_warning ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ if (!event_handle->manual) {
+ event_handle->set_count = 1;
+ mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+ } else {
+ mono_w32handle_set_signal_state (handle, TRUE, TRUE);
+ }
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ return TRUE;
+}
+
+gboolean
+ves_icall_System_Threading_Events_ResetEvent_internal (gpointer handle)
+{
+ MonoW32HandleType type;
+ MonoW32HandleEvent *event_handle;
+ int thr_ret;
+
+ SetLastError (ERROR_SUCCESS);
+
+ if (handle == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return(FALSE);
+ }
+
+ switch (type = mono_w32handle_get_type (handle)) {
+ case MONO_W32HANDLE_EVENT:
+ case MONO_W32HANDLE_NAMEDEVENT:
+ break;
+ default:
+ SetLastError (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&event_handle)) {
+ g_warning ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: resetting %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ if (!mono_w32handle_issignalled (handle)) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: no need to reset %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ } else {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: obtained write lock on %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ mono_w32handle_set_signal_state (handle, FALSE, FALSE);
+ }
+
+ event_handle->set_count = 0;
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ return TRUE;
+}
+
+void
+ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle)
+{
+ CloseHandle (handle);
+}
+
+gpointer
+ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights G_GNUC_UNUSED, gint32 *error)
+{
+ gpointer handle;
+ gchar *utf8_name;
+
+ *error = ERROR_SUCCESS;
+
+ /* w32 seems to guarantee that opening named objects can't race each other */
+ mono_w32handle_namespace_lock ();
+
+ utf8_name = g_utf16_to_utf8 (mono_string_chars (name), -1, NULL, NULL, NULL);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named event [%s]", __func__, utf8_name);
+
+ handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDEVENT, utf8_name);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* The name has already been used for a different object. */
+ *error = ERROR_INVALID_HANDLE;
+ goto cleanup;
+ } else if (!handle) {
+ /* This name doesn't exist */
+ *error = ERROR_FILE_NOT_FOUND;
+ goto cleanup;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named event handle %p", __func__, handle);
+
+cleanup:
+ g_free (utf8_name);
+
+ mono_w32handle_namespace_unlock ();
+
+ return handle;
+}
+
+MonoW32HandleNamespace*
+mono_w32event_get_namespace (MonoW32HandleNamedEvent *event)
+{
+ return &event->sharedns;
+}
--- /dev/null
+/*
+ * w32event-win32.c: Runtime support for managed Event on Win32
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "w32event.h"
+
+#include <windows.h>
+#include <winbase.h>
+
+void
+mono_w32event_init (void)
+{
+}
+
+gpointer
+mono_w32event_create (gboolean manual, gboolean initial)
+{
+ return CreateEvent (NULL, manual, initial, NULL);
+}
+
+void
+mono_w32event_set (gpointer handle)
+{
+ SetEvent (handle);
+}
+
+void
+mono_w32event_reset (gpointer handle)
+{
+ ResetEvent (handle);
+}
+
+gpointer
+ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error)
+{
+ gpointer event;
+
+ event = CreateEvent (NULL, manual, initial, name ? mono_string_chars (name) : NULL);
+
+ *error = GetLastError ();
+
+ return event;
+}
+
+gboolean
+ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle)
+{
+ return SetEvent (handle);
+}
+
+gboolean
+ves_icall_System_Threading_Events_ResetEvent_internal (gpointer handle)
+{
+ return ResetEvent (handle);
+}
+
+void
+ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle)
+{
+ CloseHandle (handle);
+}
+
+gpointer
+ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error)
+{
+ gpointer handle;
+
+ *error = ERROR_SUCCESS;
+
+ handle = OpenEvent (rights, FALSE, mono_string_chars (name));
+ if (!handle)
+ *error = GetLastError ();
+
+ return handle;
+}
--- /dev/null
+
+#ifndef _MONO_METADATA_W32EVENT_H_
+#define _MONO_METADATA_W32EVENT_H_
+
+#include <config.h>
+#include <glib.h>
+
+#include "object.h"
+#include "w32handle-namespace.h"
+
+void
+mono_w32event_init (void);
+
+gpointer
+mono_w32event_create (gboolean manual, gboolean initial);
+
+void
+mono_w32event_set (gpointer handle);
+
+void
+mono_w32event_reset (gpointer handle);
+
+gpointer
+ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error);
+
+gboolean
+ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle);
+
+gboolean
+ves_icall_System_Threading_Events_ResetEvent_internal (gpointer handle);
+
+void
+ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle);
+
+gpointer
+ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error);
+
+typedef struct MonoW32HandleNamedEvent MonoW32HandleNamedEvent;
+
+MonoW32HandleNamespace*
+mono_w32event_get_namespace (MonoW32HandleNamedEvent *event);
+
+#endif /* _MONO_METADATA_W32EVENT_H_ */
--- /dev/null
+/*
+ * w32handle-namespace.c: namespace for w32handles
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+
+#ifndef HOST_WIN32
+
+#include "w32handle-namespace.h"
+
+#include "w32mutex.h"
+#include "w32semaphore.h"
+#include "w32event.h"
+#include "mono/io-layer/io-layer.h"
+#include "mono/utils/mono-logger-internals.h"
+#include "mono/utils/mono-coop-mutex.h"
+
+static MonoCoopMutex lock;
+
+void
+mono_w32handle_namespace_init (void)
+{
+ mono_coop_mutex_init (&lock);
+}
+
+void
+mono_w32handle_namespace_lock (void)
+{
+ mono_coop_mutex_lock (&lock);
+}
+
+void
+mono_w32handle_namespace_unlock (void)
+{
+ mono_coop_mutex_unlock (&lock);
+}
+
+static gboolean
+has_namespace (MonoW32HandleType type)
+{
+ switch (type) {
+ case MONO_W32HANDLE_NAMEDMUTEX:
+ case MONO_W32HANDLE_NAMEDSEM:
+ case MONO_W32HANDLE_NAMEDEVENT:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+typedef struct {
+ gpointer ret;
+ MonoW32HandleType type;
+ gchar *name;
+} NamespaceSearchHandleData;
+
+static gboolean
+mono_w32handle_namespace_search_handle_callback (gpointer handle, gpointer data, gpointer user_data)
+{
+ NamespaceSearchHandleData *search_data;
+ MonoW32HandleType type;
+ MonoW32HandleNamespace *sharedns;
+
+ type = mono_w32handle_get_type (handle);
+ if (!has_namespace (type))
+ return FALSE;
+
+ search_data = (NamespaceSearchHandleData*) user_data;
+
+ switch (type) {
+ case MONO_W32HANDLE_NAMEDMUTEX: sharedns = mono_w32mutex_get_namespace ((MonoW32HandleNamedMutex*) data); break;
+ case MONO_W32HANDLE_NAMEDSEM: sharedns = mono_w32semaphore_get_namespace ((MonoW32HandleNamedSemaphore*) data); break;
+ case MONO_W32HANDLE_NAMEDEVENT: sharedns = mono_w32event_get_namespace ((MonoW32HandleNamedEvent*) data); break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ if (strcmp (sharedns->name, search_data->name) == 0) {
+ if (type != search_data->type) {
+ /* Its the wrong type, so fail now */
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p matches name but is wrong type: %s",
+ __func__, handle, mono_w32handle_ops_typename (type));
+ search_data->ret = INVALID_HANDLE_VALUE;
+ } else {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p matches name and type",
+ __func__, handle);
+
+ /* we do not want the handle to be destroyed before we return it */
+ mono_w32handle_ref (handle);
+
+ search_data->ret = handle;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gpointer
+mono_w32handle_namespace_search_handle (MonoW32HandleType type, gchar *name)
+{
+ NamespaceSearchHandleData search_data;
+
+ if (!has_namespace (type))
+ g_error ("%s: type %s does not have a namespace", __func__, type);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Lookup for handle named [%s] type %s",
+ __func__, name, mono_w32handle_ops_typename (type));
+
+ search_data.ret = NULL;
+ search_data.type = type;
+ search_data.name = name;
+ mono_w32handle_foreach (mono_w32handle_namespace_search_handle_callback, &search_data);
+ return search_data.ret;
+}
+
+#endif
--- /dev/null
+
+#ifndef _MONO_METADATA_W32HANDLE_NAMESPACE_H_
+#define _MONO_METADATA_W32HANDLE_NAMESPACE_H_
+
+#include <config.h>
+#include <glib.h>
+
+#include "mono/utils/w32handle.h"
+
+#define MONO_W32HANDLE_NAMESPACE_MAX_PATH 260
+
+typedef struct {
+ gchar name [MONO_W32HANDLE_NAMESPACE_MAX_PATH + 1];
+} MonoW32HandleNamespace;
+
+void
+mono_w32handle_namespace_init (void);
+
+void
+mono_w32handle_namespace_lock (void);
+
+void
+mono_w32handle_namespace_unlock (void);
+
+gpointer
+mono_w32handle_namespace_search_handle (MonoW32HandleType type, gchar *name);
+
+#endif /* _MONO_METADATA_W32HANDLE_NAMESPACE_H_ */
\ No newline at end of file
--- /dev/null
+/*
+ * w32mutex-unix.c: Runtime support for managed Mutex on Unix
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "w32mutex.h"
+
+#include <pthread.h>
+
+#include "w32handle-namespace.h"
+#include "mono/io-layer/io-layer.h"
+#include "mono/metadata/object-internals.h"
+#include "mono/utils/mono-logger-internals.h"
+#include "mono/utils/mono-threads.h"
+#include "mono/utils/w32handle.h"
+
+typedef struct {
+ MonoNativeThreadId tid;
+ guint32 recursion;
+ gboolean abandoned;
+} MonoW32HandleMutex;
+
+struct MonoW32HandleNamedMutex {
+ MonoW32HandleMutex m;
+ MonoW32HandleNamespace sharedns;
+};
+
+static void
+thread_own_mutex (MonoInternalThread *internal, gpointer handle)
+{
+ mono_w32handle_ref (handle);
+
+ /* if we are not on the current thread, there is a
+ * race condition when allocating internal->owned_mutexes */
+ g_assert (mono_thread_internal_is_current (internal));
+
+ if (!internal->owned_mutexes)
+ internal->owned_mutexes = g_ptr_array_new ();
+
+ g_ptr_array_add (internal->owned_mutexes, handle);
+}
+
+static void
+thread_disown_mutex (MonoInternalThread *internal, gpointer handle)
+{
+ gboolean removed;
+
+ g_assert (mono_thread_internal_is_current (internal));
+
+ g_assert (internal->owned_mutexes);
+ removed = g_ptr_array_remove (internal->owned_mutexes, handle);
+ g_assert (removed);
+
+ mono_w32handle_unref (handle);
+}
+
+static gboolean
+mutex_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
+{
+ MonoW32HandleMutex *mutex_handle;
+
+ *statuscode = WAIT_OBJECT_0;
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
+ g_warning ("%s: error looking up %s handle %p", __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p, before: [tid: %p, recursion: %d], after: [tid: %p, recursion: %d], abandoned: %s",
+ __func__, mono_w32handle_ops_typename (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion, (gpointer) pthread_self (), mutex_handle->recursion + 1, mutex_handle->abandoned ? "true" : "false");
+
+ if (mutex_handle->recursion != 0) {
+ g_assert (pthread_equal (pthread_self (), mutex_handle->tid));
+ mutex_handle->recursion++;
+ } else {
+ mutex_handle->tid = pthread_self ();
+ mutex_handle->recursion = 1;
+
+ thread_own_mutex (mono_thread_internal_current (), handle);
+ }
+
+ if (mutex_handle->abandoned) {
+ mutex_handle->abandoned = FALSE;
+ *statuscode = WAIT_ABANDONED_0;
+ }
+
+ mono_w32handle_set_signal_state (handle, FALSE, FALSE);
+
+ return TRUE;
+}
+
+static gboolean
+mutex_handle_is_owned (gpointer handle, MonoW32HandleType type)
+{
+ MonoW32HandleMutex *mutex_handle;
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
+ g_warning ("%s: error looking up %s handle %p", __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing ownership %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ if (mutex_handle->recursion > 0 && pthread_equal (mutex_handle->tid, pthread_self ())) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p owned by %p",
+ __func__, mono_w32handle_ops_typename (type), handle, (gpointer) pthread_self ());
+ return TRUE;
+ } else {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p not owned by %p, tid: %p recursion: %d",
+ __func__, mono_w32handle_ops_typename (type), handle, (gpointer) pthread_self (), (gpointer) mutex_handle->tid, mutex_handle->recursion);
+ return FALSE;
+ }
+}
+
+static void mutex_signal(gpointer handle)
+{
+ ves_icall_System_Threading_Mutex_ReleaseMutex_internal (handle);
+}
+
+static gboolean mutex_own (gpointer handle, guint32 *statuscode)
+{
+ return mutex_handle_own (handle, MONO_W32HANDLE_MUTEX, statuscode);
+}
+
+static gboolean mutex_is_owned (gpointer handle)
+{
+
+ return mutex_handle_is_owned (handle, MONO_W32HANDLE_MUTEX);
+}
+
+static void namedmutex_signal (gpointer handle)
+{
+ ves_icall_System_Threading_Mutex_ReleaseMutex_internal (handle);
+}
+
+/* NB, always called with the shared handle lock held */
+static gboolean namedmutex_own (gpointer handle, guint32 *statuscode)
+{
+ return mutex_handle_own (handle, MONO_W32HANDLE_NAMEDMUTEX, statuscode);
+}
+
+static gboolean namedmutex_is_owned (gpointer handle)
+{
+ return mutex_handle_is_owned (handle, MONO_W32HANDLE_NAMEDMUTEX);
+}
+
+static void mutex_handle_prewait (gpointer handle, MonoW32HandleType type)
+{
+ /* If the mutex is not currently owned, do nothing and let the
+ * usual wait carry on. If it is owned, check that the owner
+ * is still alive; if it isn't we override the previous owner
+ * and assume that process exited abnormally and failed to
+ * clean up.
+ */
+ MonoW32HandleMutex *mutex_handle;
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
+ g_warning ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ return;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pre-waiting %s handle %p, owned? %s",
+ __func__, mono_w32handle_ops_typename (type), handle, mutex_handle->recursion != 0 ? "true" : "false");
+}
+
+/* The shared state is not locked when prewait methods are called */
+static void mutex_prewait (gpointer handle)
+{
+ mutex_handle_prewait (handle, MONO_W32HANDLE_MUTEX);
+}
+
+/* The shared state is not locked when prewait methods are called */
+static void namedmutex_prewait (gpointer handle)
+{
+ mutex_handle_prewait (handle, MONO_W32HANDLE_NAMEDMUTEX);
+}
+
+static void mutex_details (gpointer data)
+{
+ MonoW32HandleMutex *mut = (MonoW32HandleMutex *)data;
+
+#ifdef PTHREAD_POINTER_ID
+ g_print ("own: %5p, count: %5u", mut->tid, mut->recursion);
+#else
+ g_print ("own: %5ld, count: %5u", mut->tid, mut->recursion);
+#endif
+}
+
+static void namedmutex_details (gpointer data)
+{
+ MonoW32HandleNamedMutex *namedmut = (MonoW32HandleNamedMutex *)data;
+
+#ifdef PTHREAD_POINTER_ID
+ g_print ("own: %5p, count: %5u, name: \"%s\"",
+ namedmut->m.tid, namedmut->m.recursion, namedmut->sharedns.name);
+#else
+ g_print ("own: %5ld, count: %5u, name: \"%s\"",
+ namedmut->m.tid, namedmut->m.recursion, namedmut->sharedns.name);
+#endif
+}
+
+static const gchar* mutex_typename (void)
+{
+ return "Mutex";
+}
+
+static gsize mutex_typesize (void)
+{
+ return sizeof (MonoW32HandleMutex);
+}
+
+static const gchar* namedmutex_typename (void)
+{
+ return "N.Mutex";
+}
+
+static gsize namedmutex_typesize (void)
+{
+ return sizeof (MonoW32HandleNamedMutex);
+}
+
+void
+mono_w32mutex_init (void)
+{
+ static MonoW32HandleOps mutex_ops = {
+ NULL, /* close */
+ mutex_signal, /* signal */
+ mutex_own, /* own */
+ mutex_is_owned, /* is_owned */
+ NULL, /* special_wait */
+ mutex_prewait, /* prewait */
+ mutex_details, /* details */
+ mutex_typename, /* typename */
+ mutex_typesize, /* typesize */
+ };
+
+ static MonoW32HandleOps namedmutex_ops = {
+ NULL, /* close */
+ namedmutex_signal, /* signal */
+ namedmutex_own, /* own */
+ namedmutex_is_owned, /* is_owned */
+ NULL, /* special_wait */
+ namedmutex_prewait, /* prewait */
+ namedmutex_details, /* details */
+ namedmutex_typename, /* typename */
+ namedmutex_typesize, /* typesize */
+ };
+
+ mono_w32handle_register_ops (MONO_W32HANDLE_MUTEX, &mutex_ops);
+ mono_w32handle_register_ops (MONO_W32HANDLE_NAMEDMUTEX, &namedmutex_ops);
+
+ mono_w32handle_register_capabilities (MONO_W32HANDLE_MUTEX,
+ (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL | MONO_W32HANDLE_CAP_OWN));
+ mono_w32handle_register_capabilities (MONO_W32HANDLE_NAMEDMUTEX,
+ (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL | MONO_W32HANDLE_CAP_OWN));
+}
+
+static gpointer mutex_handle_create (MonoW32HandleMutex *mutex_handle, MonoW32HandleType type, gboolean owned)
+{
+ gpointer handle;
+ int thr_ret;
+ guint32 statuscode;
+
+ mutex_handle->tid = 0;
+ mutex_handle->recursion = 0;
+ mutex_handle->abandoned = FALSE;
+
+ handle = mono_w32handle_new (type, mutex_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating %s handle",
+ __func__, mono_w32handle_ops_typename (type));
+ SetLastError (ERROR_GEN_FAILURE);
+ return NULL;
+ }
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ if (owned)
+ mutex_handle_own (handle, type, &statuscode);
+ else
+ mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ return handle;
+}
+
+static gpointer mutex_create (gboolean owned)
+{
+ MonoW32HandleMutex mutex_handle;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
+ __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_MUTEX));
+ return mutex_handle_create (&mutex_handle, MONO_W32HANDLE_MUTEX, owned);
+}
+
+static gpointer namedmutex_create (gboolean owned, const gunichar2 *name)
+{
+ gpointer handle;
+ gchar *utf8_name;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
+ __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDMUTEX));
+
+ /* w32 seems to guarantee that opening named objects can't race each other */
+ mono_w32handle_namespace_lock ();
+
+ utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
+
+ handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDMUTEX, utf8_name);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* The name has already been used for a different object. */
+ handle = NULL;
+ SetLastError (ERROR_INVALID_HANDLE);
+ } else if (handle) {
+ /* Not an error, but this is how the caller is informed that the mutex wasn't freshly created */
+ SetLastError (ERROR_ALREADY_EXISTS);
+
+ /* mono_w32handle_namespace_search_handle already adds a ref to the handle */
+ } else {
+ /* A new named mutex */
+ MonoW32HandleNamedMutex namedmutex_handle;
+
+ strncpy (&namedmutex_handle.sharedns.name [0], utf8_name, MAX_PATH);
+ namedmutex_handle.sharedns.name [MAX_PATH] = '\0';
+
+ handle = mutex_handle_create ((MonoW32HandleMutex*) &namedmutex_handle, MONO_W32HANDLE_NAMEDMUTEX, owned);
+ }
+
+ g_free (utf8_name);
+
+ mono_w32handle_namespace_unlock ();
+
+ return handle;
+}
+
+gpointer
+ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
+{
+ gpointer mutex;
+
+ *created = TRUE;
+
+ /* Need to blow away any old errors here, because code tests
+ * for ERROR_ALREADY_EXISTS on success (!) to see if a mutex
+ * was freshly created */
+ SetLastError (ERROR_SUCCESS);
+
+ if (!name) {
+ mutex = mutex_create (owned);
+ } else {
+ mutex = namedmutex_create (owned, mono_string_chars (name));
+
+ if (GetLastError () == ERROR_ALREADY_EXISTS)
+ *created = FALSE;
+ }
+
+ return mutex;
+}
+
+MonoBoolean
+ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
+{
+ MonoW32HandleType type;
+ MonoW32HandleMutex *mutex_handle;
+ pthread_t tid;
+ int thr_ret;
+ gboolean ret;
+
+ if (handle == NULL) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ switch (type = mono_w32handle_get_type (handle)) {
+ case MONO_W32HANDLE_MUTEX:
+ case MONO_W32HANDLE_NAMEDMUTEX:
+ break;
+ default:
+ SetLastError (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
+ g_warning ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: releasing %s handle %p, tid: %p recursion: %d",
+ __func__, mono_w32handle_ops_typename (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion);
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ tid = pthread_self ();
+
+ if (mutex_handle->abandoned) {
+ // The Win32 ReleaseMutex() function returns TRUE for abandoned mutexes
+ ret = TRUE;
+ } else if (!pthread_equal (mutex_handle->tid, tid)) {
+ ret = FALSE;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: we don't own %s handle %p (owned by %ld, me %ld)",
+ __func__, mono_w32handle_ops_typename (type), handle, mutex_handle->tid, tid);
+ } else {
+ ret = TRUE;
+
+ /* OK, we own this mutex */
+ mutex_handle->recursion--;
+
+ if (mutex_handle->recursion == 0) {
+ thread_disown_mutex (mono_thread_internal_current (), handle);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking %s handle %p, tid: %p recusion : %d",
+ __func__, mono_w32handle_ops_typename (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion);
+
+ mutex_handle->tid = 0;
+ mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+ }
+ }
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ return ret;
+}
+
+gpointer
+ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights G_GNUC_UNUSED, gint32 *error)
+{
+ gpointer handle;
+ gchar *utf8_name;
+
+ *error = ERROR_SUCCESS;
+
+ /* w32 seems to guarantee that opening named objects can't race each other */
+ mono_w32handle_namespace_lock ();
+
+ utf8_name = g_utf16_to_utf8 (mono_string_chars (name), -1, NULL, NULL, NULL);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named mutex [%s]",
+ __func__, utf8_name);
+
+ handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDMUTEX, utf8_name);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* The name has already been used for a different object. */
+ *error = ERROR_INVALID_HANDLE;
+ goto cleanup;
+ } else if (!handle) {
+ /* This name doesn't exist */
+ *error = ERROR_FILE_NOT_FOUND;
+ goto cleanup;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named mutex handle %p",
+ __func__, handle);
+
+cleanup:
+ g_free (utf8_name);
+
+ mono_w32handle_namespace_unlock ();
+
+ return handle;
+}
+
+void
+mono_w32mutex_abandon (void)
+{
+ MonoInternalThread *internal;
+
+ g_assert (mono_thread_internal_current_is_attached ());
+
+ internal = mono_thread_internal_current ();
+ g_assert (internal);
+
+ if (!internal->owned_mutexes)
+ return;
+
+ while (internal->owned_mutexes->len) {
+ MonoW32HandleType type;
+ MonoW32HandleMutex *mutex_handle;
+ MonoNativeThreadId tid;
+ gpointer handle;
+ int thr_ret;
+
+ handle = g_ptr_array_index (internal->owned_mutexes, 0);
+
+ switch (type = mono_w32handle_get_type (handle)) {
+ case MONO_W32HANDLE_MUTEX:
+ case MONO_W32HANDLE_NAMEDMUTEX:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&mutex_handle)) {
+ g_error ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: abandoning %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ tid = MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid);
+
+ if (!pthread_equal (mutex_handle->tid, tid))
+ g_error ("%s: trying to release mutex %p acquired by thread %p from thread %p",
+ __func__, handle, (gpointer) mutex_handle->tid, (gpointer) tid);
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ mutex_handle->recursion = 0;
+ mutex_handle->tid = 0;
+ mutex_handle->abandoned = TRUE;
+
+ mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+
+ thread_disown_mutex (internal, handle);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: abandoned %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+ }
+
+ g_ptr_array_free (internal->owned_mutexes, TRUE);
+ internal->owned_mutexes = NULL;
+}
+
+MonoW32HandleNamespace*
+mono_w32mutex_get_namespace (MonoW32HandleNamedMutex *mutex)
+{
+ return &mutex->sharedns;
+}
--- /dev/null
+/*
+ * w32mutex-win32.c: Runtime support for managed Mutex on Win32
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "w32mutex.h"
+
+#include <windows.h>
+#include <winbase.h>
+
+void
+mono_w32mutex_init (void)
+{
+}
+
+gpointer
+ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
+{
+ HANDLE mutex;
+
+ *created = TRUE;
+
+ if (!name) {
+ mutex = CreateMutex (NULL, owned, NULL);
+ } else {
+ mutex = CreateMutex (NULL, owned, mono_string_chars (name));
+
+ if (GetLastError () == ERROR_ALREADY_EXISTS)
+ *created = FALSE;
+ }
+
+ return mutex;
+}
+
+MonoBoolean
+ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
+{
+ return ReleaseMutex (handle);
+}
+
+gpointer
+ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights, gint32 *error)
+{
+ HANDLE ret;
+
+ *error = ERROR_SUCCESS;
+
+ ret = OpenMutex (rights, FALSE, mono_string_chars (name));
+ if (!ret)
+ *error = GetLastError ();
+
+ return ret;
+}
--- /dev/null
+
+#ifndef _MONO_METADATA_W32MUTEX_H_
+#define _MONO_METADATA_W32MUTEX_H_
+
+#include <config.h>
+#include <glib.h>
+
+#include "object.h"
+#include "w32handle-namespace.h"
+
+void
+mono_w32mutex_init (void);
+
+gpointer
+ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created);
+
+MonoBoolean
+ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle);
+
+gpointer
+ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights, gint32 *error);
+
+typedef struct MonoW32HandleNamedMutex MonoW32HandleNamedMutex;
+
+MonoW32HandleNamespace*
+mono_w32mutex_get_namespace (MonoW32HandleNamedMutex *mutex);
+
+#ifndef HOST_WIN32
+void
+mono_w32mutex_abandon (void);
+#endif
+
+#endif /* _MONO_METADATA_W32MUTEX_H_ */
--- /dev/null
+/*
+ * w32semaphore-unix.c: Runtime support for managed Semaphore on Unix
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "w32semaphore.h"
+
+#include "w32handle-namespace.h"
+#include "mono/io-layer/io-layer.h"
+#include "mono/utils/mono-logger-internals.h"
+#include "mono/utils/w32handle.h"
+
+typedef struct {
+ guint32 val;
+ gint32 max;
+} MonoW32HandleSemaphore;
+
+struct MonoW32HandleNamedSemaphore {
+ MonoW32HandleSemaphore s;
+ MonoW32HandleNamespace sharedns;
+};
+
+static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type, guint32 *statuscode)
+{
+ MonoW32HandleSemaphore *sem_handle;
+
+ *statuscode = WAIT_OBJECT_0;
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&sem_handle)) {
+ g_warning ("%s: error looking up %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ sem_handle->val--;
+
+ if (sem_handle->val == 0)
+ mono_w32handle_set_signal_state (handle, FALSE, FALSE);
+
+ return TRUE;
+}
+
+static void sema_signal(gpointer handle)
+{
+ ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal(handle, 1, NULL);
+}
+
+static gboolean sema_own (gpointer handle, guint32 *statuscode)
+{
+ return sem_handle_own (handle, MONO_W32HANDLE_SEM, statuscode);
+}
+
+static void namedsema_signal (gpointer handle)
+{
+ ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (handle, 1, NULL);
+}
+
+/* NB, always called with the shared handle lock held */
+static gboolean namedsema_own (gpointer handle, guint32 *statuscode)
+{
+ return sem_handle_own (handle, MONO_W32HANDLE_NAMEDSEM, statuscode);
+}
+
+static void sema_details (gpointer data)
+{
+ MonoW32HandleSemaphore *sem = (MonoW32HandleSemaphore *)data;
+ g_print ("val: %5u, max: %5d", sem->val, sem->max);
+}
+
+static void namedsema_details (gpointer data)
+{
+ MonoW32HandleNamedSemaphore *namedsem = (MonoW32HandleNamedSemaphore *)data;
+ g_print ("val: %5u, max: %5d, name: \"%s\"", namedsem->s.val, namedsem->s.max, namedsem->sharedns.name);
+}
+
+static const gchar* sema_typename (void)
+{
+ return "Semaphore";
+}
+
+static gsize sema_typesize (void)
+{
+ return sizeof (MonoW32HandleSemaphore);
+}
+
+static const gchar* namedsema_typename (void)
+{
+ return "N.Semaphore";
+}
+
+static gsize namedsema_typesize (void)
+{
+ return sizeof (MonoW32HandleNamedSemaphore);
+}
+
+void
+mono_w32semaphore_init (void)
+{
+ static MonoW32HandleOps sem_ops = {
+ NULL, /* close */
+ sema_signal, /* signal */
+ sema_own, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ sema_details, /* details */
+ sema_typename, /* typename */
+ sema_typesize, /* typesize */
+ };
+
+ static MonoW32HandleOps namedsem_ops = {
+ NULL, /* close */
+ namedsema_signal, /* signal */
+ namedsema_own, /* own */
+ NULL, /* is_owned */
+ NULL, /* special_wait */
+ NULL, /* prewait */
+ namedsema_details, /* details */
+ namedsema_typename, /* typename */
+ namedsema_typesize, /* typesize */
+ };
+
+ mono_w32handle_register_ops (MONO_W32HANDLE_SEM, &sem_ops);
+ mono_w32handle_register_ops (MONO_W32HANDLE_NAMEDSEM, &namedsem_ops);
+
+ mono_w32handle_register_capabilities (MONO_W32HANDLE_SEM,
+ (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
+ mono_w32handle_register_capabilities (MONO_W32HANDLE_NAMEDSEM,
+ (MonoW32HandleCapability)(MONO_W32HANDLE_CAP_WAIT | MONO_W32HANDLE_CAP_SIGNAL));
+}
+
+static gpointer
+sem_handle_create (MonoW32HandleSemaphore *sem_handle, MonoW32HandleType type, gint32 initial, gint32 max)
+{
+ gpointer handle;
+ int thr_ret;
+
+ sem_handle->val = initial;
+ sem_handle->max = max;
+
+ handle = mono_w32handle_new (type, sem_handle);
+ if (handle == INVALID_HANDLE_VALUE) {
+ g_warning ("%s: error creating %s handle",
+ __func__, mono_w32handle_ops_typename (type));
+ SetLastError (ERROR_GEN_FAILURE);
+ return NULL;
+ }
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ if (initial != 0)
+ mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ return handle;
+}
+
+static gpointer
+sem_create (gint32 initial, gint32 max)
+{
+ MonoW32HandleSemaphore sem_handle;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle, initial %d max %d",
+ __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_SEM), initial, max);
+ return sem_handle_create (&sem_handle, MONO_W32HANDLE_SEM, initial, max);
+}
+
+static gpointer
+namedsem_create (gint32 initial, gint32 max, const gunichar2 *name)
+{
+ gpointer handle;
+ gchar *utf8_name;
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle, initial %d max %d name \"%s\"",
+ __func__, mono_w32handle_ops_typename (MONO_W32HANDLE_NAMEDSEM), initial, max, name);
+
+ /* w32 seems to guarantee that opening named objects can't race each other */
+ mono_w32handle_namespace_lock ();
+
+ utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named sem name [%s] initial %d max %d", __func__, utf8_name, initial, max);
+
+ handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDSEM, utf8_name);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* The name has already been used for a different object. */
+ handle = NULL;
+ SetLastError (ERROR_INVALID_HANDLE);
+ } else if (handle) {
+ /* Not an error, but this is how the caller is informed that the semaphore wasn't freshly created */
+ SetLastError (ERROR_ALREADY_EXISTS);
+
+ /* mono_w32handle_namespace_search_handle already adds a ref to the handle */
+ } else {
+ /* A new named semaphore */
+ MonoW32HandleNamedSemaphore namedsem_handle;
+
+ strncpy (&namedsem_handle.sharedns.name [0], utf8_name, MAX_PATH);
+ namedsem_handle.sharedns.name [MAX_PATH] = '\0';
+
+ handle = sem_handle_create ((MonoW32HandleSemaphore*) &namedsem_handle, MONO_W32HANDLE_NAMEDSEM, initial, max);
+ }
+
+ g_free (utf8_name);
+
+ mono_w32handle_namespace_unlock ();
+
+ return handle;
+}
+
+gpointer
+ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error)
+{
+ gpointer sem;
+
+ if (maximumCount <= 0) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: maximumCount <= 0", __func__);
+
+ *error = ERROR_INVALID_PARAMETER;
+ return NULL;
+ }
+
+ if (initialCount > maximumCount || initialCount < 0) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: initialCount > maximumCount or < 0", __func__);
+
+ *error = ERROR_INVALID_PARAMETER;
+ return NULL;
+ }
+
+ /* Need to blow away any old errors here, because code tests
+ * for ERROR_ALREADY_EXISTS on success (!) to see if a
+ * semaphore was freshly created
+ */
+ SetLastError (ERROR_SUCCESS);
+
+ if (!name)
+ sem = sem_create (initialCount, maximumCount);
+ else
+ sem = namedsem_create (initialCount, maximumCount, mono_string_chars (name));
+
+ *error = GetLastError ();
+
+ return sem;
+}
+
+MonoBoolean
+ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount)
+{
+ MonoW32HandleType type;
+ MonoW32HandleSemaphore *sem_handle;
+ int thr_ret;
+ MonoBoolean ret;
+
+ if (!handle) {
+ SetLastError (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ switch (type = mono_w32handle_get_type (handle)) {
+ case MONO_W32HANDLE_SEM:
+ case MONO_W32HANDLE_NAMEDSEM:
+ break;
+ default:
+ SetLastError (ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if (!mono_w32handle_lookup (handle, type, (gpointer *)&sem_handle)) {
+ g_warning ("%s: error looking up sem handle %p", __func__, handle);
+ return FALSE;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: releasing %s handle %p",
+ __func__, mono_w32handle_ops_typename (type), handle);
+
+ thr_ret = mono_w32handle_lock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ /* Do this before checking for count overflow, because overflowing
+ * max is a listed technique for finding the current value */
+ if (prevcount)
+ *prevcount = sem_handle->val;
+
+ /* No idea why max is signed, but thats the spec :-( */
+ if (sem_handle->val + releaseCount > (guint32)sem_handle->max) {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p val %d count %d max %d, max value would be exceeded",
+ __func__, mono_w32handle_ops_typename (type), handle, sem_handle->val, releaseCount, sem_handle->max);
+
+ ret = FALSE;
+ } else {
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p val %d count %d max %d",
+ __func__, mono_w32handle_ops_typename (type), handle, sem_handle->val, releaseCount, sem_handle->max);
+
+ sem_handle->val += releaseCount;
+ mono_w32handle_set_signal_state (handle, TRUE, TRUE);
+
+ ret = TRUE;
+ }
+
+ thr_ret = mono_w32handle_unlock_handle (handle);
+ g_assert (thr_ret == 0);
+
+ return ret;
+}
+
+gpointer
+ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error)
+{
+ gpointer handle;
+ gchar *utf8_name;
+
+ *error = ERROR_SUCCESS;
+
+ /* w32 seems to guarantee that opening named objects can't race each other */
+ mono_w32handle_namespace_lock ();
+
+ utf8_name = g_utf16_to_utf8 (mono_string_chars (name), -1, NULL, NULL, NULL);
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named sem [%s]", __func__, utf8_name);
+
+ handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDSEM, utf8_name);
+ if (handle == INVALID_HANDLE_VALUE) {
+ /* The name has already been used for a different object. */
+ *error = ERROR_INVALID_HANDLE;
+ goto cleanup;
+ } else if (!handle) {
+ /* This name doesn't exist */
+ *error = ERROR_FILE_NOT_FOUND;
+ goto cleanup;
+ }
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named sem handle %p", __func__, handle);
+
+cleanup:
+ g_free (utf8_name);
+
+ mono_w32handle_namespace_unlock ();
+
+ return handle;
+}
+
+MonoW32HandleNamespace*
+mono_w32semaphore_get_namespace (MonoW32HandleNamedSemaphore *semaphore)
+{
+ return &semaphore->sharedns;
+}
--- /dev/null
+/*
+ * w32semaphore-win32.c: Runtime support for managed Semaphore on Win32
+ *
+ * Author:
+ * Ludovic Henry (luhenry@microsoft.com)
+ *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "w32semaphore.h"
+
+#include <windows.h>
+#include <winbase.h>
+
+void
+mono_w32semaphore_init (void)
+{
+}
+
+gpointer
+ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error)
+{
+ HANDLE sem;
+
+ sem = CreateSemaphore (NULL, initialCount, maximumCount, name ? mono_string_chars (name) : NULL);
+
+ *error = GetLastError ();
+
+ return sem;
+}
+
+MonoBoolean
+ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount)
+{
+ return ReleaseSemaphore (handle, releaseCount, prevcount);
+}
+
+gpointer
+ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error)
+{
+ HANDLE sem;
+
+ sem = OpenSemaphore (rights, FALSE, mono_string_chars (name));
+
+ *error = GetLastError ();
+
+ return sem;
+}
\ No newline at end of file
--- /dev/null
+
+#ifndef _MONO_METADATA_W32SEMAPHORE_H_
+#define _MONO_METADATA_W32SEMAPHORE_H_
+
+#include <config.h>
+#include <glib.h>
+
+#include "object.h"
+#include "w32handle-namespace.h"
+
+void
+mono_w32semaphore_init (void);
+
+gpointer
+ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error);
+
+MonoBoolean
+ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount);
+
+gpointer
+ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error);
+
+typedef struct MonoW32HandleNamedSemaphore MonoW32HandleNamedSemaphore;
+
+MonoW32HandleNamespace*
+mono_w32semaphore_get_namespace (MonoW32HandleNamedSemaphore *semaphore);
+
+#endif /* _MONO_METADATA_W32SEMAPHORE_H_ */
/* Trampoline argument */
arm_ldrx (code, ARMREG_IP1, ARMREG_IP0, 0);
- /* Same as arch_emit_imt_thunk () */
+ /* Same as arch_emit_imt_trampoline () */
labels [0] = code;
arm_ldrx (code, ARMREG_IP0, ARMREG_IP1, 0);
arm_cmpx (code, ARMREG_IP0, MONO_ARCH_RGCTX_REG);
emit_code_bytes (acfg, buf, code - buf);
common_tramp_size = code - buf;
- acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_IMT_THUNK] = common_tramp_size;
+ acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_IMT] = common_tramp_size;
arm64_emit_tramp_page_specific_code (acfg, pagesize, common_tramp_size, specific_tramp_size);
}
}
static void
-arm64_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
+arm64_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
guint8 buf [128];
guint8 *code, *labels [16];
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_SPECIFIC] = 16;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_STATIC_RGCTX] = 16;
- acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_IMT_THUNK] = 72;
+ acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_IMT] = 72;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_GSHAREDVT_ARG] = 16;
/* Unwind info for specifc trampolines */
}
/*
- * arch_emit_imt_thunk:
+ * arch_emit_imt_trampoline:
*
- * Emit an IMT thunk usable in full-aot mode. The thunk uses 1 got slot which
+ * Emit an IMT trampoline usable in full-aot mode. The trampoline uses 1 got slot which
* points to an array of pointer pairs. The pairs of the form [key, ptr], where
* key is the IMT key, and ptr holds the address of a memory location holding
* the address to branch to if the IMT arg matches the key. The array is
* TRAMP_SIZE is set to the size of the emitted trampoline.
*/
static void
-arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
+arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
#if defined(TARGET_AMD64)
guint8 *buf, *code;
*tramp_size = code - buf + 4;
#elif defined(TARGET_ARM64)
- arm64_emit_imt_thunk (acfg, offset, tramp_size);
+ arm64_emit_imt_trampoline (acfg, offset, tramp_size);
#elif defined(TARGET_POWERPC)
guint8 buf [128];
guint8 *code, *labels [16];
return opts->mode == MONO_AOT_MODE_FULL;
}
+static
+gboolean mono_aot_mode_is_hybrid (MonoAotOptions *opts)
+{
+ return opts->mode == MONO_AOT_MODE_HYBRID;
+}
+
static void add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, const char *ref);
static void
add_generic_class (MonoAotCompile *acfg, MonoClass *klass, gboolean force, const char *ref)
{
/* This might lead to a huge code blowup so only do it if neccesary */
- if (!mono_aot_mode_is_full (&acfg->aot_opts) && !force)
+ if (!mono_aot_mode_is_full (&acfg->aot_opts) && !mono_aot_mode_is_hybrid (&acfg->aot_opts) && !force)
return;
add_generic_class_with_depth (acfg, klass, 0, ref);
* These include the following:
* - specific trampolines
* - static rgctx invoke trampolines
- * - imt thunks
+ * - imt trampolines
* These trampolines have the same code, they are parameterized by GOT
* slots.
* They are defined in this file, in the arch_... routines instead of
case MONO_AOT_TRAMP_STATIC_RGCTX:
sprintf (symbol, "static_rgctx_trampolines");
break;
- case MONO_AOT_TRAMP_IMT_THUNK:
- sprintf (symbol, "imt_thunks");
+ case MONO_AOT_TRAMP_IMT:
+ sprintf (symbol, "imt_trampolines");
break;
case MONO_AOT_TRAMP_GSHAREDVT_ARG:
sprintf (symbol, "gsharedvt_arg_trampolines");
arch_emit_static_rgctx_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 2;
break;
- case MONO_AOT_TRAMP_IMT_THUNK:
- arch_emit_imt_thunk (acfg, tramp_got_offset, &tramp_size);
+ case MONO_AOT_TRAMP_IMT:
+ arch_emit_imt_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 1;
break;
case MONO_AOT_TRAMP_GSHAREDVT_ARG:
method = cfg->orig_method;
/* Emit unbox trampoline */
- if (mono_aot_mode_is_full (&acfg->aot_opts) && cfg->orig_method->klass->valuetype && !(acfg->aot_opts.llvm_only && cfg->compile_llvm)) {
+ if (mono_aot_mode_is_full (&acfg->aot_opts) && cfg->orig_method->klass->valuetype) {
sprintf (symbol, "ut_%d", get_method_index (acfg, method));
emit_section_change (acfg, ".text", 0);
int call_size;
if (acfg->cfgs [i]) {
- if (acfg->aot_opts.llvm_only && acfg->cfgs [i]->compile_llvm)
- /* Obtained by calling a generated function in the LLVM image */
- arch_emit_direct_call (acfg, symbol, FALSE, FALSE, NULL, &call_size);
- else
- arch_emit_direct_call (acfg, acfg->cfgs [i]->asm_symbol, FALSE, acfg->thumb_mixed && acfg->cfgs [i]->compile_llvm, NULL, &call_size);
+ arch_emit_direct_call (acfg, acfg->cfgs [i]->asm_symbol, FALSE, acfg->thumb_mixed && acfg->cfgs [i]->compile_llvm, NULL, &call_size);
} else {
arch_emit_direct_call (acfg, symbol, FALSE, FALSE, NULL, &call_size);
}
method = cfg->orig_method;
- if (mono_aot_mode_is_full (&acfg->aot_opts) && cfg->orig_method->klass->valuetype && !(acfg->aot_opts.llvm_only && cfg->compile_llvm)) {
+ if (mono_aot_mode_is_full (&acfg->aot_opts) && cfg->orig_method->klass->valuetype) {
index = get_method_index (acfg, method);
emit_int32 (acfg, index);
method = cfg->orig_method;
- if (mono_aot_mode_is_full (&acfg->aot_opts) && cfg->orig_method->klass->valuetype && !(acfg->aot_opts.llvm_only && cfg->compile_llvm)) {
+ if (mono_aot_mode_is_full (&acfg->aot_opts) && cfg->orig_method->klass->valuetype) {
#ifdef MONO_ARCH_AOT_SUPPORTED
int call_size;
break;
}
- free (hashes_start);
+ g_free (hashes_start);
return c;
}
if (acfg->num_trampoline_got_entries) {
symbols [sindex ++] = "specific_trampolines";
symbols [sindex ++] = "static_rgctx_trampolines";
- symbols [sindex ++] = "imt_thunks";
+ symbols [sindex ++] = "imt_trampolines";
symbols [sindex ++] = "gsharedvt_arg_trampolines";
} else {
symbols [sindex ++] = NULL;
HANDLE handle;
gpointer *user_data;
MonoMethod **methods;
- MonoThreadParm tp;
methods_len = acfg->methods->len;
user_data [1] = acfg;
user_data [2] = frag;
- tp.priority = MONO_THREAD_PRIORITY_NORMAL;
- tp.stack_size = 0;
- tp.creation_flags = 0;
- handle = mono_threads_create_thread (compile_thread_main, (gpointer) user_data, &tp, NULL);
+ handle = mono_threads_create_thread (compile_thread_main, (gpointer) user_data, 0, NULL);
g_ptr_array_add (threads, handle);
}
g_free (methods);
for (i = 0; i < threads->len; ++i) {
WaitForSingleObjectEx (g_ptr_array_index (threads, i), INFINITE, FALSE);
+ mono_threads_close_thread_handle (g_ptr_array_index (threads, i));
}
} else {
methods_len = 0;
}
#if defined(MONO_ARCH_GSHAREDVT_SUPPORTED)
- if (acfg->aot_opts.llvm_only || mono_aot_mode_is_full (&acfg->aot_opts)) {
+ if (acfg->aot_opts.llvm_only || mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts)) {
acfg->opts |= MONO_OPT_GSHAREDVT;
opts |= MONO_OPT_GSHAREDVT;
}
#ifdef MONO_ARCH_GSHARED_SUPPORTED
acfg->num_trampolines [MONO_AOT_TRAMP_STATIC_RGCTX] = mono_aot_mode_is_full (&acfg->aot_opts) ? acfg->aot_opts.nrgctx_trampolines : 0;
#endif
- acfg->num_trampolines [MONO_AOT_TRAMP_IMT_THUNK] = mono_aot_mode_is_full (&acfg->aot_opts) ? acfg->aot_opts.nimt_trampolines : 0;
+ acfg->num_trampolines [MONO_AOT_TRAMP_IMT] = mono_aot_mode_is_full (&acfg->aot_opts) ? acfg->aot_opts.nimt_trampolines : 0;
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED
if (acfg->opts & MONO_OPT_GSHAREDVT)
acfg->num_trampolines [MONO_AOT_TRAMP_GSHAREDVT_ARG] = mono_aot_mode_is_full (&acfg->aot_opts) ? acfg->aot_opts.ngsharedvt_arg_trampolines : 0;
amodule->mono_eh_frame = (guint8 *)info->mono_eh_frame;
amodule->trampolines [MONO_AOT_TRAMP_SPECIFIC] = (guint8 *)info->specific_trampolines;
amodule->trampolines [MONO_AOT_TRAMP_STATIC_RGCTX] = (guint8 *)info->static_rgctx_trampolines;
- amodule->trampolines [MONO_AOT_TRAMP_IMT_THUNK] = (guint8 *)info->imt_thunks;
+ amodule->trampolines [MONO_AOT_TRAMP_IMT] = (guint8 *)info->imt_trampolines;
amodule->trampolines [MONO_AOT_TRAMP_GSHAREDVT_ARG] = (guint8 *)info->gsharedvt_arg_trampolines;
if (!strcmp (assembly->aname.name, "mscorlib"))
sprintf (symbol_name, "specific_trampolines_page_%s_p", is_generic ? "gen" : "sp");
else if (tramp_type == MONO_AOT_TRAMP_STATIC_RGCTX)
sprintf (symbol_name, "rgctx_trampolines_page_%s_p", is_generic ? "gen" : "sp");
- else if (tramp_type == MONO_AOT_TRAMP_IMT_THUNK)
+ else if (tramp_type == MONO_AOT_TRAMP_IMT)
sprintf (symbol_name, "imt_trampolines_page_%s_p", is_generic ? "gen" : "sp");
else if (tramp_type == MONO_AOT_TRAMP_GSHAREDVT_ARG)
sprintf (symbol_name, "gsharedvt_trampolines_page_%s_p", is_generic ? "gen" : "sp");
tpage = load_function (amodule, "specific_trampolines_page");
else if (tramp_type == MONO_AOT_TRAMP_STATIC_RGCTX)
tpage = load_function (amodule, "rgctx_trampolines_page");
- else if (tramp_type == MONO_AOT_TRAMP_IMT_THUNK)
+ else if (tramp_type == MONO_AOT_TRAMP_IMT)
tpage = load_function (amodule, "imt_trampolines_page");
else if (tramp_type == MONO_AOT_TRAMP_GSHAREDVT_ARG)
tpage = load_function (amodule, "gsharedvt_arg_trampolines_page");
void *code;
gpointer *data;
- code = get_new_trampoline_from_page (MONO_AOT_TRAMP_IMT_THUNK);
+ code = get_new_trampoline_from_page (MONO_AOT_TRAMP_IMT);
data = (gpointer*)((char*)code - MONO_AOT_TRAMP_PAGE_SIZE);
data [0] = arg;
}
static void
-no_imt_thunk (void)
+no_imt_trampoline (void)
{
- g_assert_not_reached ();
+ g_assert_not_reached ();
}
gpointer
-mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
+mono_aot_get_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
{
guint32 got_offset;
gpointer code;
MonoAotModule *amodule;
if (mono_llvm_only)
- return no_imt_thunk;
+ return no_imt_trampoline;
real_count = 0;
for (i = 0; i < count; ++i) {
if (USE_PAGE_TRAMPOLINES) {
code = get_new_imt_trampoline_from_page (buf);
} else {
- code = get_numerous_trampoline (MONO_AOT_TRAMP_IMT_THUNK, 1, &amodule, &got_offset, NULL);
+ code = get_numerous_trampoline (MONO_AOT_TRAMP_IMT, 1, &amodule, &got_offset, NULL);
amodule->got [got_offset] = buf;
}
}
gpointer
-mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
+mono_aot_get_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
{
g_assert_not_reached ();
return NULL;
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
-#define MINOR_VERSION 42
+#define MINOR_VERSION 43
typedef enum {
CMD_SET_VM = 1,
static void
start_debugger_thread (void)
{
- MonoThreadParm tp;
-
- tp.priority = MONO_THREAD_PRIORITY_NORMAL;
- tp.stack_size = 0;
- tp.creation_flags = 0;
- debugger_thread_handle = mono_threads_create_thread (debugger_thread, NULL, &tp, NULL);
+ debugger_thread_handle = mono_threads_create_thread (debugger_thread, NULL, 0, NULL);
g_assert (debugger_thread_handle);
}
locals = mono_debug_lookup_locals (method);
if (!locals) {
+ if (CHECK_PROTOCOL_VERSION (2, 43)) {
+ /* Scopes */
+ buffer_add_int (buf, 1);
+ buffer_add_int (buf, 0);
+ buffer_add_int (buf, header->code_size);
+ }
buffer_add_int (buf, header->num_locals);
/* Types */
for (i = 0; i < header->num_locals; ++i) {
buffer_add_int (buf, header->code_size);
}
} else {
+ if (CHECK_PROTOCOL_VERSION (2, 43)) {
+ /* Scopes */
+ buffer_add_int (buf, locals->num_blocks);
+ int last_start = 0;
+ for (i = 0; i < locals->num_blocks; ++i) {
+ buffer_add_int (buf, locals->code_blocks [i].start_offset - last_start);
+ buffer_add_int (buf, locals->code_blocks [i].end_offset - locals->code_blocks [i].start_offset);
+ last_start = locals->code_blocks [i].start_offset;
+ }
+ }
+
num_locals = locals->num_locals;
buffer_add_int (buf, num_locals);
} else if (strcmp (argv [i], "--llvmonly") == 0) {
mono_aot_only = TRUE;
mono_llvm_only = TRUE;
+ } else if (strcmp (argv [i], "--hybrid-aot") == 0) {
} else if (strcmp (argv [i], "--print-vtable") == 0) {
mono_print_vtable = TRUE;
} else if (strcmp (argv [i], "--stats") == 0) {
/*
* This wastes memory but the memory usage is bounded since
- * mono_method_add_generic_virtual_invocation () eventually builds an imt thunk for
+ * mono_method_add_generic_virtual_invocation () eventually builds an imt trampoline for
* this vtable slot so we are not called any more for this instantiation.
*/
MonoFtnDesc *ftndesc = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, arg);
/*
* This wastes memory but the memory usage is bounded since
- * mono_method_add_generic_virtual_invocation () eventually builds an imt thunk for
+ * mono_method_add_generic_virtual_invocation () eventually builds an imt trampoline for
* this vtable slot so we are not called any more for this instantiation.
*/
MonoFtnDesc *ftndesc = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, arg);
+/*
+ * main.c: The main entry point for the mono executable
+ *
+ * The main entry point does a few things:
+ *
+ * * It probes whether the executable has a bundle appended
+ * at the end, and if so, registers the various bundled
+ * resources with Mono and executes the contained bundle
+ *
+ * * Parses the MONO_ENV_OPTIONS variable to treat the
+ * contents of the variable as command line arguments for
+ * the mono runtime
+ *
+ * * Launches Mono, by calling mono_main.
+ */
#include <config.h>
#include <fcntl.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/mono-config.h>
#include <mono/utils/mono-mmap.h>
+#include <mono/utils/mono-dl.h>
#include "mini.h"
#ifdef HAVE_UNISTD_H
return mono_main (argc, argv);
}
+/*
+ * The Mono executable can initialize itself from a payload attached
+ * at the end of the main program. The payload contains the
+ * main assembly, one or more managed assemblies, configuration
+ * files and other assets that are used instead of launching a
+ * program from the command line.
+ *
+ * The startup sequence probes for a magical signature at the end of
+ * the executable, if the 16 characters "xmonkeysloveplay" are found,
+ * the code expects the 64-bits just before it to contain an offset
+ * within the executable with a directory of assets.
+ *
+ * All pointers in the file format are encoded as little-endian values
+ *
+ * The format of the file is thus:
+ *
+ * Location Content
+ * -------- -------
+ * lenght-16 Optional "xmonkeysloveplay", indicating that a
+ * bundled payload is contained in the executable.
+ * length-24 pointer to the directory in the file, address DIR
+ *
+ * DIR 32-bit value with the number of entries in the directory
+ * DIR+4 First directory entry.
+ *
+ * Each directory entry is made up of:
+ * 4-bytes uint32_t containing the size of a string (STR)
+ * STRING UTF8 encoded and \0 terminated string
+ * 8-bytes uint64_t offset in the file with the payload associated with STRING
+ * 4-bytes uint32_t size of the asset
+ *
+ * The following are the known directory entries, without the quotes:
+ * "assembly:NAME" An assembly with the name NAME, assembly is in the payload
+ * "config:NAME" A configuration file (usually file.dll.config) in the payload that is
+ * loaded as the config file for an assembly
+ * "systemconfig:" Treats as a Mono system configuration, payload contains the config file.
+ * "options:" The payload contains command line options to initialize Mono, as if you
+ had set them on MONO_ENV_OPTIONS
+ * "config_dir:DIR" Configures the MONO_PATH to point to point to DIR
+ * "machineconfig:" The payload contains the machine.config file to use at runtime
+ * "env:" Sets the environment variable to the value encoded in the payload
+ * payload contains: 1-byte lenght for the \0 terminated variable,
+ * followed by the value.
+ * "library:NAME" Bundled dynamic library NAME, payload contains the dynamic library
+ */
#define STREAM_INT(x) GUINT32_TO_LE((*(uint32_t*)x))
#define STREAM_LONG(x) GUINT64_TO_LE((*(uint64_t*)x))
return buffer;
}
+/* Did we initialize the temporary directory for dynamic libraries */
+static int bundle_save_library_initialized;
+
+/* List of bundled libraries we unpacked */
+static GSList *bundle_library_paths;
+
+/* Directory where we unpacked dynamic libraries */
+static char *bundled_dylibrary_directory;
+
+static void
+delete_bundled_libraries ()
+{
+ GSList *list;
+
+ for (list = bundle_library_paths; list != NULL; list = list->next){
+ unlink (list->data);
+ }
+ rmdir (bundled_dylibrary_directory);
+}
+
+static void
+bundle_save_library_initialize ()
+{
+ bundle_save_library_initialized = 1;
+ char *path = g_build_filename (g_get_tmp_dir (), "mono-bundle-XXXXXX");
+ bundled_dylibrary_directory = g_mkdtemp (path);
+ g_free (path);
+ if (bundled_dylibrary_directory == NULL)
+ return;
+ atexit (delete_bundled_libraries);
+}
+
+static void
+save_library (int fd, uint64_t offset, uint64_t size, const char *destfname)
+{
+ MonoDl *lib;
+ char *file, *buffer, *err;
+ if (!bundle_save_library_initialized)
+ bundle_save_library_initialize ();
+
+ file = g_build_filename (bundled_dylibrary_directory, destfname);
+ buffer = load_from_region (fd, offset, size);
+ g_file_set_contents (file, buffer, size, NULL);
+ lib = mono_dl_open (file, MONO_DL_LAZY, &err);
+ if (err != NULL){
+ fprintf (stderr, "Error loading shared library: %s\n", file);
+ exit (1);
+ }
+ mono_loader_register_module (destfname, lib);
+ bundle_library_paths = g_slist_append (bundle_library_paths, file);
+
+ g_free (buffer);
+}
+
static gboolean
probe_embedded (const char *program, int *ref_argc, char **ref_argv [])
{
uint8_t count = *data++;
char *value = data + count + 1;
g_setenv (data, value, FALSE);
+ } else if (strncmp (kind, "library:", strlen ("library:")) == 0){
+ save_library (fd, offset, item_size, kind + strlen ("library:"));
} else {
fprintf (stderr, "Unknown stream on embedded package: %s\n", kind);
exit (1);
}
}
g_array_append_val (assemblies, last);
-
+
mono_register_bundled_assemblies ((const MonoBundledAssembly **) assemblies->data);
new_argv = g_new (char *, (*ref_argc)+1);
for (j = 0; j < *ref_argc; j++)
/* helper methods signatures */
static MonoMethodSignature *helper_sig_domain_get;
static MonoMethodSignature *helper_sig_rgctx_lazy_fetch_trampoline;
-static MonoMethodSignature *helper_sig_llvmonly_imt_thunk;
-
+static MonoMethodSignature *helper_sig_llvmonly_imt_trampoline;
/* type loading helpers */
static GENERATE_GET_CLASS_WITH_CACHE (runtime_helpers, System.Runtime.CompilerServices, RuntimeHelpers)
{
helper_sig_domain_get = mono_create_icall_signature ("ptr");
helper_sig_rgctx_lazy_fetch_trampoline = mono_create_icall_signature ("ptr ptr");
- helper_sig_llvmonly_imt_thunk = mono_create_icall_signature ("ptr ptr ptr");
+ helper_sig_llvmonly_imt_trampoline = mono_create_icall_signature ("ptr ptr ptr");
}
static MONO_NEVER_INLINE void
if (is_set) {
EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, load, &eklass->byval_arg, args [2]->dreg, 0);
EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, &eklass->byval_arg, addr->dreg, 0, load->dreg);
- if (mini_type_is_reference (fsig->params [2]))
+ if (mini_type_is_reference (&eklass->byval_arg))
emit_write_barrier (cfg, addr, load);
} else {
EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, load, &eklass->byval_arg, addr->dreg, 0);
icall_args [0] = thunk_arg_ins;
icall_args [1] = emit_get_rgctx_method (cfg, context_used,
cmethod, MONO_RGCTX_INFO_METHOD);
- ftndesc_ins = mono_emit_calli (cfg, helper_sig_llvmonly_imt_thunk, icall_args, thunk_addr_ins, NULL, NULL);
+ ftndesc_ins = mono_emit_calli (cfg, helper_sig_llvmonly_imt_trampoline, icall_args, thunk_addr_ins, NULL, NULL);
return emit_llvmonly_calli (cfg, fsig, sp, ftndesc_ins);
}
icall_args [0] = thunk_arg_ins;
icall_args [1] = emit_get_rgctx_method (cfg, context_used,
cmethod, MONO_RGCTX_INFO_METHOD);
- ftndesc_ins = mono_emit_calli (cfg, helper_sig_llvmonly_imt_thunk, icall_args, thunk_addr_ins, NULL, NULL);
+ ftndesc_ins = mono_emit_calli (cfg, helper_sig_llvmonly_imt_trampoline, icall_args, thunk_addr_ins, NULL, NULL);
ftndesc_ins->dreg = ftndesc_reg;
/*
* Unlike normal iface calls, these imt thunks can return NULL, i.e. when they are passed an instantiation
if (cfg->gsharedvt && mini_is_gsharedvt_signature (fsig))
GSHAREDVT_FAILURE (*ip);
- if (cfg->backend->have_generalized_imt_thunk && cfg->backend->gshared_supported && cmethod->wrapper_type == MONO_WRAPPER_NONE) {
+ if (cfg->backend->have_generalized_imt_trampoline && cfg->backend->gshared_supported && cmethod->wrapper_type == MONO_WRAPPER_NONE) {
g_assert (!imt_arg);
if (!context_used)
g_assert (cmethod->is_inflated);
return result;
}
-inline gboolean
+static inline gboolean
allocate_parameter_register_for_valuetype_win64 (ArgInfo *arg_info, ArgumentClass arg_class, guint32 arg_size, guint32 *current_int_reg, guint32 *current_float_reg)
{
return allocate_register_for_valuetype_win64 (arg_info, arg_class, arg_size, param_regs, PARAM_REGS, float_param_regs, FLOAT_PARAM_REGS, current_int_reg, current_float_reg);
}
-inline gboolean
+static inline gboolean
allocate_return_register_for_valuetype_win64 (ArgInfo *arg_info, ArgumentClass arg_class, guint32 arg_size, guint32 *current_int_reg, guint32 *current_float_reg)
{
return allocate_register_for_valuetype_win64 (arg_info, arg_class, arg_size, return_regs, RETURN_REGS, float_return_regs, FLOAT_RETURN_REGS, current_int_reg, current_float_reg);
* LOCKING: called with the domain lock held
*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
int i;
size += item->chunk_size;
}
if (fail_tramp)
- code = (guint8 *)mono_method_alloc_generic_virtual_thunk (domain, size);
+ code = (guint8 *)mono_method_alloc_generic_virtual_trampoline (domain, size);
else
code = (guint8 *)mono_domain_code_reserve (domain, size);
start = code;
}
if (!fail_tramp)
- mono_stats.imt_thunks_size += code - start;
+ mono_stats.imt_trampolines_size += code - start;
g_assert (code - start <= size);
mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE, NULL);
#define MONO_ARCH_EXC_REG AMD64_RAX
#define MONO_ARCH_HAVE_CMOV_OPS 1
#define MONO_ARCH_HAVE_EXCEPTIONS_INIT 1
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#define MONO_ARCH_HAVE_LIVERANGE_OPS 1
#define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
#define MONO_ARCH_HAVE_GET_TRAMPOLINES 1
if (!mono_aot_only)
breakpoint_tramp = mini_get_breakpoint_trampoline ();
} else {
- ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
- bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
+ ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, MONO_MEM_ACCOUNT_OTHER);
+ bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, MONO_MEM_ACCOUNT_OTHER);
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
}
#endif
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
int size, i;
size += 4 * count; /* The ARM_ADD_REG_IMM to pop the stack */
if (fail_tramp)
- code = mono_method_alloc_generic_virtual_thunk (domain, size);
+ code = mono_method_alloc_generic_virtual_trampoline (domain, size);
else
code = mono_domain_code_reserve (domain, size);
start = code;
unwind_ops = mono_arch_get_cie_program ();
#ifdef DEBUG_IMT
- g_print ("Building IMT thunk for class %s %s entries %d code size %d code at %p end %p vtable %p fail_tramp %p\n", vtable->klass->name_space, vtable->klass->name, count, size, start, ((guint8*)start) + size, vtable, fail_tramp);
+ g_print ("Building IMT trampoline for class %s %s entries %d code size %d code at %p end %p vtable %p fail_tramp %p\n", vtable->klass->name_space, vtable->klass->name, count, size, start, ((guint8*)start) + size, vtable, fail_tramp);
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
g_print ("method %d (%p) %s vtable slot %p is_equals %d chunk size %d\n", i, item->key, ((MonoMethod*)item->key)->name, &vtable->vtable [item->value.vtable_slot], item->is_equals, item->chunk_size);
mono_arch_flush_icache ((guint8*)start, size);
mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE, NULL);
- mono_stats.imt_thunks_size += code - start;
+ mono_stats.imt_trampolines_size += code - start;
g_assert (DISTANCE (start, code) <= size);
#define MONO_ARCH_NEED_DIV_CHECK 1
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1
#define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1
arm_ldrx_lit (code, ARMREG_IP0, code + 8);
arm_brx (code, ARMREG_IP0);
*(guint64*)code = (guint64)target;
+ code += sizeof (guint64);
mono_arch_flush_icache (p, code - p);
return code;
#if __APPLE__
sys_icache_invalidate (code, size);
#else
- __clear_cache (code, code + size);
+ /* Don't rely on GCC's __clear_cache implementation, as it caches
+ * icache/dcache cache line sizes, that can vary between cores on
+ * big.LITTLE architectures. */
+ guint64 end = (guint64) (code + size);
+ guint64 addr, ctr_el0;
+ static size_t icache_line_size = 0xffff, dcache_line_size = 0xffff;
+ size_t isize, dsize;
+
+ asm volatile ("mrs %0, ctr_el0" : "=r" (ctr_el0));
+ isize = 4 << ((ctr_el0 >> 0 ) & 0xf);
+ dsize = 4 << ((ctr_el0 >> 16) & 0xf);
+
+ /* determine the global minimum cache line size */
+ icache_line_size = isize = MIN (icache_line_size, isize);
+ dcache_line_size = dsize = MIN (dcache_line_size, dsize);
+
+ addr = (guint64) code & ~(guint64) (dsize - 1);
+ for (; addr < end; addr += dsize)
+ asm volatile("dc civac, %0" : : "r" (addr) : "memory");
+ asm volatile("dsb ish" : : : "memory");
+
+ addr = (guint64) code & ~(guint64) (isize - 1);
+ for (; addr < end; addr += isize)
+ asm volatile("ic ivau, %0" : : "r" (addr) : "memory");
+
+ asm volatile ("dsb ish" : : : "memory");
+ asm volatile ("isb" : : : "memory");
#endif
#endif
}
}
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
int i, buf_len, imt_reg;
guint8 *buf, *code;
#if DEBUG_IMT
- printf ("building IMT thunk for class %s %s entries %d code size %d code at %p end %p vtable %p\n", vtable->klass->name_space, vtable->klass->name, count, size, start, ((guint8*)start) + size, vtable);
+ printf ("building IMT trampoline for class %s %s entries %d code size %d code at %p end %p vtable %p\n", vtable->klass->name_space, vtable->klass->name, count, size, start, ((guint8*)start) + size, vtable);
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
printf ("method %d (%p) %s vtable slot %p is_equals %d chunk size %d\n", i, item->key, item->key->name, &vtable->vtable [item->value.vtable_slot], item->is_equals, item->chunk_size);
}
if (fail_tramp)
- buf = mono_method_alloc_generic_virtual_thunk (domain, buf_len);
+ buf = mono_method_alloc_generic_virtual_trampoline (domain, buf_len);
else
buf = mono_domain_code_reserve (domain, buf_len);
code = buf;
#else /* DISABLE_JIT */
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
g_assert_not_reached ();
return NULL;
#define MONO_ARCH_EXC_REG ARMREG_R0
#define MONO_ARCH_HAVE_XP_UNWIND 1
#define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE 1
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#define MONO_ARCH_USE_SIGACTION 1
#define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
#define MONO_ARCH_HAVE_CONTEXT_SET_INT_REG 1
if (mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE)) {
/* mprotect can fail for the main thread stack */
- gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED);
+ gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED, MONO_MEM_ACCOUNT_EXCEPTIONS);
g_assert (gaddr == tls->stack_ovf_guard_base);
tls->stack_ovf_valloced = TRUE;
}
/* Setup an alternate signal stack */
- tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON);
+ tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON, MONO_MEM_ACCOUNT_EXCEPTIONS);
tls->signal_stack_size = MONO_ARCH_SIGNAL_STACK_SIZE;
g_assert (tls->signal_stack);
g_assert (err == 0);
if (tls->signal_stack)
- mono_vfree (tls->signal_stack, MONO_ARCH_SIGNAL_STACK_SIZE);
+ mono_vfree (tls->signal_stack, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MEM_ACCOUNT_EXCEPTIONS);
if (tls->stack_ovf_valloced)
- mono_vfree (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size);
+ mono_vfree (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MEM_ACCOUNT_EXCEPTIONS);
else
mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_READ|MONO_MMAP_WRITE);
}
for (i =0; i < size; ++i) {
mono_runtime_printf_err ("\t%s", names [i]);
}
- free (names);
+ g_free (names);
/* Try to get more meaningful information using gdb */
g_string_append (text, "\n\"<unnamed thread>\"");
g_string_append_printf (text, " tid=0x%p this=0x%p ", (gpointer)(gsize)thread->tid, thread);
- mono_thread_info_describe ((MonoThreadInfo*) thread->thread_info, text);
+ mono_thread_internal_describe (thread, text);
g_string_append (text, "\n");
#ifdef MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX
* LOCKING: called with the domain lock held
*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
int i;
int size = 0;
size = code.buf - buf;
if (fail_tramp) {
- start = mono_method_alloc_generic_virtual_thunk (domain, size + 16);
+ start = mono_method_alloc_generic_virtual_trampoline (domain, size + 16);
start = (gpointer)ALIGN_TO (start, 16);
} else {
start = mono_domain_code_reserve (domain, size);
#define MONO_ARCH_HAVE_INVALIDATE_METHOD 1
#define MONO_ARCH_HAVE_SAVE_UNWIND_INFO 1
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#endif /* __MONO_MINI_IA64_H__ */
* can work around that by doing a volatile load + cond branch from
* localloc-ed memory.
*/
- //set_failure (ctx, "basic block too long");
+ if (!cfg->llvm_only)
+ set_failure (ctx, "basic block too long");
cbb = gen_bb (ctx, "CONT_LONG_BB");
LLVMBuildBr (ctx->builder, cbb);
ctx->builder = builder = create_builder (ctx);
if (info->trampoline_size [0]) {
fields [tindex ++] = AddJitGlobal (module, eltype, "specific_trampolines");
fields [tindex ++] = AddJitGlobal (module, eltype, "static_rgctx_trampolines");
- fields [tindex ++] = AddJitGlobal (module, eltype, "imt_thunks");
+ fields [tindex ++] = AddJitGlobal (module, eltype, "imt_trampolines");
fields [tindex ++] = AddJitGlobal (module, eltype, "gsharedvt_arg_trampolines");
} else {
fields [tindex ++] = LLVMConstNull (eltype);
{
mono_os_mutex_init_recursive (&mini_arch_mutex);
- ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
- bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
+ ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, MONO_MEM_ACCOUNT_OTHER);
+ bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, MONO_MEM_ACCOUNT_OTHER);
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
}
* LOCKING: called with the domain lock held
*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
int i;
int size = 0;
/* the initial load of the vtable address */
size += MIPS_LOAD_SEQUENCE_LENGTH;
if (fail_tramp) {
- code = mono_method_alloc_generic_virtual_thunk (domain, size);
+ code = mono_method_alloc_generic_virtual_trampoline (domain, size);
} else {
code = mono_domain_code_reserve (domain, size);
}
}
if (!fail_tramp)
- mono_stats.imt_thunks_size += code - start;
+ mono_stats.imt_trampolines_size += code - start;
g_assert (code - start <= size);
mono_arch_flush_icache (start, size);
#define MONO_ARCH_HAVE_DECOMPOSE_OPTS 1
#define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
#define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
#define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
mono_os_mutex_init_recursive (&mini_arch_mutex);
- ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
- bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
+ ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, MONO_MEM_ACCOUNT_OTHER);
+ bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, MONO_MEM_ACCOUNT_OTHER);
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_ppc_throw_exception", mono_ppc_throw_exception);
* LOCKING: called with the domain lock held
*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
int i;
int size = 0;
/* the initial load of the vtable address */
size += PPC_LOAD_SEQUENCE_LENGTH + LOADSTORE_SIZE;
if (fail_tramp) {
- code = mono_method_alloc_generic_virtual_thunk (domain, size);
+ code = mono_method_alloc_generic_virtual_trampoline (domain, size);
} else {
code = mono_domain_code_reserve (domain, size);
}
}
if (!fail_tramp)
- mono_stats.imt_thunks_size += code - start;
+ mono_stats.imt_trampolines_size += code - start;
g_assert (code - start <= size);
mono_arch_flush_icache (start, size);
#define MONO_ARCH_HAVE_DECOMPOSE_OPTS 1
#define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1
typedef struct {
MonoVTable *vtable;
int slot;
-} IMTThunkInfo;
+} IMTTrampInfo;
-typedef gpointer (*IMTThunkFunc) (gpointer *arg, MonoMethod *imt_method);
+typedef gpointer (*IMTTrampFunc) (gpointer *arg, MonoMethod *imt_method);
/*
- * mini_llvmonly_initial_imt_thunk:
+ * mini_llvmonly_initial_imt_tramp:
*
- * This function is called the first time a call is made through an IMT thunk.
- * It should have the same signature as the mono_llvmonly_imt_thunk_... functions.
+ * This function is called the first time a call is made through an IMT trampoline.
+ * It should have the same signature as the mono_llvmonly_imt_tramp_... functions.
*/
static gpointer
-mini_llvmonly_initial_imt_thunk (gpointer *arg, MonoMethod *imt_method)
+mini_llvmonly_initial_imt_tramp (gpointer *arg, MonoMethod *imt_method)
{
- IMTThunkInfo *info = (IMTThunkInfo*)arg;
+ IMTTrampInfo *info = (IMTTrampInfo*)arg;
gpointer *imt;
gpointer *ftndesc;
- IMTThunkFunc func;
+ IMTTrampFunc func;
mono_vtable_build_imt_slot (info->vtable, info->slot);
imt = (gpointer*)info->vtable;
imt -= MONO_IMT_SIZE;
- /* Return what the real IMT thunk returns */
+ /* Return what the real IMT trampoline returns */
ftndesc = imt [info->slot];
func = ftndesc [0];
- if (func == (IMTThunkFunc)mini_llvmonly_initial_imt_thunk)
+ if (func == (IMTTrampFunc)mini_llvmonly_initial_imt_tramp)
/* Happens when the imt slot contains only a generic virtual method */
return NULL;
return func ((gpointer *)ftndesc [1], imt_method);
/* This is called indirectly through an imt slot. */
static gpointer
-mono_llvmonly_imt_thunk (gpointer *arg, MonoMethod *imt_method)
+mono_llvmonly_imt_tramp (gpointer *arg, MonoMethod *imt_method)
{
int i = 0;
- /* arg points to an array created in mono_llvmonly_get_imt_thunk () */
+ /* arg points to an array created in mono_llvmonly_get_imt_trampoline () */
while (arg [i] && arg [i] != imt_method)
i += 2;
g_assert (arg [i]);
return arg [i + 1];
}
-/* Optimized versions of mono_llvmonly_imt_thunk () for different table sizes */
+/* Optimized versions of mono_llvmonly_imt_trampoline () for different table sizes */
static gpointer
-mono_llvmonly_imt_thunk_1 (gpointer *arg, MonoMethod *imt_method)
+mono_llvmonly_imt_tramp_1 (gpointer *arg, MonoMethod *imt_method)
{
//g_assert (arg [0] == imt_method);
return arg [1];
}
static gpointer
-mono_llvmonly_imt_thunk_2 (gpointer *arg, MonoMethod *imt_method)
+mono_llvmonly_imt_tramp_2 (gpointer *arg, MonoMethod *imt_method)
{
//g_assert (arg [0] == imt_method || arg [2] == imt_method);
if (arg [0] == imt_method)
}
static gpointer
-mono_llvmonly_imt_thunk_3 (gpointer *arg, MonoMethod *imt_method)
+mono_llvmonly_imt_tramp_3 (gpointer *arg, MonoMethod *imt_method)
{
//g_assert (arg [0] == imt_method || arg [2] == imt_method || arg [4] == imt_method);
if (arg [0] == imt_method)
}
/*
- * A version of the imt thunk used for generic virtual/variant iface methods.
- * Unlikely a normal imt thunk, its possible that IMT_METHOD is not found
+ * A version of the imt trampoline used for generic virtual/variant iface methods.
+ * Unlikely a normal imt trampoline, its possible that IMT_METHOD is not found
* in the search table. The original JIT code had a 'fallback' trampoline it could
* call, but we can't do that, so we just return NULL, and the compiled code
* will handle it.
*/
static gpointer
-mono_llvmonly_fallback_imt_thunk (gpointer *arg, MonoMethod *imt_method)
+mono_llvmonly_fallback_imt_tramp (gpointer *arg, MonoMethod *imt_method)
{
int i = 0;
}
static gpointer
-mono_llvmonly_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
+mono_llvmonly_get_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp)
{
gpointer *buf;
gpointer *res;
gboolean virtual_generic = FALSE;
/*
- * Create an array which is passed to the imt thunk functions.
+ * Create an array which is passed to the imt trampoline functions.
* The array contains MonoMethod-function descriptor pairs, terminated by a NULL entry.
*/
res = (void **)mono_domain_alloc (domain, 2 * sizeof (gpointer));
switch (real_count) {
case 1:
- res [0] = mono_llvmonly_imt_thunk_1;
+ res [0] = mono_llvmonly_imt_tramp_1;
break;
case 2:
- res [0] = mono_llvmonly_imt_thunk_2;
+ res [0] = mono_llvmonly_imt_tramp_2;
break;
case 3:
- res [0] = mono_llvmonly_imt_thunk_3;
+ res [0] = mono_llvmonly_imt_tramp_3;
break;
default:
- res [0] = mono_llvmonly_imt_thunk;
+ res [0] = mono_llvmonly_imt_tramp;
break;
}
if (virtual_generic || fail_tramp)
- res [0] = mono_llvmonly_fallback_imt_thunk;
+ res [0] = mono_llvmonly_fallback_imt_tramp;
res [1] = buf;
return res;
if (mono_llvm_only) {
if (slot_index < 0) {
- /* Initialize the IMT thunks to a 'trampoline' so the generated code doesn't have to initialize it */
+ /* Initialize the IMT trampoline to a 'trampoline' so the generated code doesn't have to initialize it */
// FIXME: Memory management
gpointer *ftndesc = g_malloc (2 * sizeof (gpointer));
- IMTThunkInfo *info = g_new0 (IMTThunkInfo, 1);
+ IMTTrampInfo *info = g_new0 (IMTTrampInfo, 1);
info->vtable = vt;
info->slot = index;
- ftndesc [0] = mini_llvmonly_initial_imt_thunk;
+ ftndesc [0] = mini_llvmonly_initial_imt_tramp;
ftndesc [1] = info;
mono_memory_barrier ();
return ftndesc;
}
if (mono_llvm_only) {
- mono_install_imt_thunk_builder (mono_llvmonly_get_imt_thunk);
- mono_set_always_build_imt_thunks (TRUE);
+ mono_install_imt_trampoline_builder (mono_llvmonly_get_imt_trampoline);
+ mono_set_always_build_imt_trampolines (TRUE);
} else if (mono_aot_only) {
- mono_install_imt_thunk_builder (mono_aot_get_imt_thunk);
+ mono_install_imt_trampoline_builder (mono_aot_get_imt_trampoline);
} else {
- mono_install_imt_thunk_builder (mono_arch_build_imt_thunk);
+ mono_install_imt_trampoline_builder (mono_arch_build_imt_trampoline);
}
/*Init arch tls information only after the metadata side is inited to make sure we see dynamic appdomain tls keys*/
*/
mono_runtime_set_no_exec (TRUE);
+ mono_mem_account_register_counters ();
+
#define JIT_RUNTIME_WORKS
#ifdef JIT_RUNTIME_WORKS
mono_install_runtime_cleanup ((MonoDomainFunc)mini_cleanup);
g_print ("IMT colliding slots: %ld\n", mono_stats.imt_slots_with_collisions);
g_print ("IMT max collisions: %ld\n", mono_stats.imt_max_collisions_in_slot);
g_print ("IMT methods at max col: %ld\n", mono_stats.imt_method_count_when_max_collisions);
- g_print ("IMT thunks size: %ld\n", mono_stats.imt_thunks_size);
+ g_print ("IMT trampolines size: %ld\n", mono_stats.imt_trampolines_size);
g_print ("JIT info table inserts: %ld\n", mono_stats.jit_info_table_insert_count);
g_print ("JIT info table removes: %ld\n", mono_stats.jit_info_table_remove_count);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/*
- * imt thunking size values
+ * imt trampoline size values
*/
#define CMP_SIZE 24
#define LOADCON_SIZE 20
mono_set_partial_sharing_supported (FALSE);
mono_os_mutex_init_recursive (&mini_arch_mutex);
- ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
- bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
+ ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, MONO_MEM_ACCOUNT_OTHER);
+ bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, MONO_MEM_ACCOUNT_OTHER);
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
code = (guint8 *) &breakpointCode;
mono_arch_cleanup (void)
{
if (ss_trigger_page)
- mono_vfree (ss_trigger_page, mono_pagesize ());
+ mono_vfree (ss_trigger_page, mono_pagesize (), MONO_MEM_ACCOUNT_OTHER);
if (bp_trigger_page)
- mono_vfree (bp_trigger_page, mono_pagesize ());
+ mono_vfree (bp_trigger_page, mono_pagesize (), MONO_MEM_ACCOUNT_OTHER);
mono_os_mutex_destroy (&mini_arch_mutex);
}
/*------------------------------------------------------------------*/
/* */
-/* Name - mono_arch_build_imt_thunk. */
+/* Name - mono_arch_build_imt_trampoline. */
/* */
/* Function - */
/* */
/*------------------------------------------------------------------*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain,
- MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain,
+ MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
int i;
int size = 0;
}
if (fail_tramp)
- code = mono_method_alloc_generic_virtual_thunk (domain, size);
+ code = mono_method_alloc_generic_virtual_trampoline (domain, size);
else
code = mono_domain_code_reserve (domain, size);
mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE, NULL);
if (!fail_tramp)
- mono_stats.imt_thunks_size += (code - start);
+ mono_stats.imt_trampolines_size += (code - start);
g_assert (code - start <= size);
- snprintf(trampName, sizeof(trampName), "%d_imt_thunk_trampoline", domain->domain_id);
+ snprintf(trampName, sizeof(trampName), "%d_imt_trampoline", domain->domain_id);
mono_tramp_info_register (mono_tramp_info_create (trampName, start, code - start, NULL, NULL), domain);
return (start);
* LOCKING: called with the domain lock held
*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
- gpointer fail_tramp)
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+ gpointer fail_tramp)
{
int i;
int size = 0;
size += item->chunk_size;
}
if (fail_tramp)
- code = mono_method_alloc_generic_virtual_thunk (domain, size * 4);
+ code = mono_method_alloc_generic_virtual_trampoline (domain, size * 4);
else
code = mono_domain_code_reserve (domain, size * 4);
start = code;
mono_arch_flush_icache ((guint8*)start, (code - start) * 4);
- mono_stats.imt_thunks_size += (code - start) * 4;
+ mono_stats.imt_trampolines_size += (code - start) * 4;
g_assert (code - start <= size);
mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, NULL), domain);
vtable_slot = mini_resolve_imt_method (vt, vtable_slot, imt_method, &impl_method, &addr, &need_rgctx_tramp, &variant_iface, error);
return_val_if_nok (error, NULL);
- /* This is the vcall slot which gets called through the IMT thunk */
+ /* This is the vcall slot which gets called through the IMT trampoline */
vtable_slot_to_patch = vtable_slot;
if (addr) {
* LOCKING: called with the domain lock held
*/
gpointer
-mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
+mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
int i;
size += item->chunk_size;
}
if (fail_tramp)
- code = mono_method_alloc_generic_virtual_thunk (domain, size);
+ code = mono_method_alloc_generic_virtual_trampoline (domain, size);
else
code = mono_domain_code_reserve (domain, size);
start = code;
}
if (!fail_tramp)
- mono_stats.imt_thunks_size += code - start;
+ mono_stats.imt_trampolines_size += code - start;
g_assert (code - start <= size);
#if DEBUG_IMT
if (vtable)
buff = g_strdup_printf ("imt_%s_%s_entries_%d", vtable->klass->name_space, vtable->klass->name, count);
else
- buff = g_strdup_printf ("imt_thunk_entries_%d", count);
+ buff = g_strdup_printf ("imt_trampoline_entries_%d", count);
mono_emit_jit_tramp (start, code - start, buff);
g_free (buff);
}
#define MONO_ARCH_VTABLE_REG X86_EDX
#define MONO_ARCH_RGCTX_REG MONO_ARCH_IMT_REG
#define MONO_ARCH_EXC_REG X86_EAX
-#define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1
+#define MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE 1
#define MONO_ARCH_HAVE_LIVERANGE_OPS 1
#define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
#define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1
#ifdef MONO_ARCH_HAVE_OBJC_GET_SELECTOR
backend->have_objc_get_selector = 1;
#endif
-#ifdef MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK
- backend->have_generalized_imt_thunk = 1;
+#ifdef MONO_ARCH_HAVE_GENERALIZED_IMT_TRAMPOLINE
+ backend->have_generalized_imt_trampoline = 1;
#endif
#ifdef MONO_ARCH_GSHARED_SUPPORTED
backend->gshared_supported = 1;
typedef enum {
MONO_AOT_TRAMP_SPECIFIC = 0,
MONO_AOT_TRAMP_STATIC_RGCTX = 1,
- MONO_AOT_TRAMP_IMT_THUNK = 2,
+ MONO_AOT_TRAMP_IMT = 2,
MONO_AOT_TRAMP_GSHAREDVT_ARG = 3,
MONO_AOT_TRAMP_NUM = 4
} MonoAotTrampoline;
/* Blocks of various kinds of trampolines */
gpointer specific_trampolines;
gpointer static_rgctx_trampolines;
- gpointer imt_thunks;
+ gpointer imt_trampolines;
gpointer gsharedvt_arg_trampolines;
/* In static mode, points to a table of global symbols for trampolines etc */
gpointer globals;
guint emulate_div : 1;
guint emulate_long_shift_opts : 1;
guint have_objc_get_selector : 1;
- guint have_generalized_imt_thunk : 1;
+ guint have_generalized_imt_trampoline : 1;
guint have_tls_get : 1;
guint have_tls_get_reg : 1;
guint have_liverange_ops: 1;
gpointer mono_aot_get_unbox_trampoline (MonoMethod *method);
gpointer mono_aot_get_lazy_fetch_trampoline (guint32 slot);
gpointer mono_aot_get_static_rgctx_trampoline (gpointer ctx, gpointer addr);
-gpointer mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
+gpointer mono_aot_get_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
gpointer mono_aot_get_gsharedvt_arg_trampoline(gpointer arg, gpointer addr);
guint8* mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len);
guint32 mono_aot_method_hash (MonoMethod *method);
gpointer mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
MonoMethod* mono_arch_find_imt_method (mgreg_t *regs, guint8 *code);
MonoVTable* mono_arch_find_static_call_vtable (mgreg_t *regs, guint8 *code);
-gpointer mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
+gpointer mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
void mono_arch_notify_pending_exc (MonoThreadInfo *info);
guint8* mono_arch_get_call_target (guint8 *code);
guint32 mono_arch_get_plt_info_offset (guint8 *plt_entry, mgreg_t *regs, guint8 *code);
/* we resolved an unknown class (unless we had the code unloaded) */
if (cd) {
/*printf ("resolved unknown: %s\n", name);*/
- free (cd->name);
+ g_free (cd->name);
cd->name = pstrdup (name);
return cd;
}
cd->code = code;
cd->len = len;
/*printf ("resolved unknown: %s\n", name);*/
- free (cd->name);
+ g_free (cd->name);
cd->name = pstrdup (name);
return cd;
}
add_rev_class_hashed (n, to->rev_hash_size, to->rev_hash [i].klass, to->rev_hash [i].count);
}
if (to->rev_hash)
- free (to->rev_hash);
+ g_free (to->rev_hash);
to->rev_hash = n;
}
to->rev_count += add_rev_class_hashed (to->rev_hash, to->rev_hash_size, from, 1);
add_heap_hashed (n, &res, hs->hash_size, hs->class_hash [i]->klass, hs->class_hash [i]->total_size, hs->class_hash [i]->count);
}
if (hs->class_hash)
- free (hs->class_hash);
+ g_free (hs->class_hash);
hs->class_hash = n;
}
res = NULL;
HeapObjectDesc* ho = alloc_heap_obj (objaddr, hash [i]->hklass, hash [i]->num_refs + num);
*ref_offset = hash [i]->num_refs;
memcpy (ho->refs, hash [i]->refs, hash [i]->num_refs * sizeof (uintptr_t));
- free (hash [i]);
+ g_free (hash [i]);
hash [i] = ho;
return ho;
}
add_heap_hashed_obj (n, hs->objects_hash_size, hs->objects_hash [i]);
}
if (hs->objects_hash)
- free (hs->objects_hash);
+ g_free (hs->objects_hash);
hs->objects_hash = n;
}
hs->objects_count += add_heap_hashed_obj (hs->objects_hash, hs->objects_hash_size, obj);
}
}
fprintf (outfile, "Total unmarked: %zd/%zd\n", num_unmarked, hs->objects_count);
- free (marks);
+ g_free (marks);
}
static void
for (i = 0; i < hs->objects_hash_size; ++i) {
HeapObjectDesc *ho = hs->objects_hash [i];
if (ho)
- free (ho);
+ g_free (ho);
}
if (hs->objects_hash)
- free (hs->objects_hash);
+ g_free (hs->objects_hash);
hs->objects_hash = NULL;
hs->objects_hash_size = 0;
hs->objects_count = 0;
add_trace_hashed (n, trace->size, trace->traces [i].bt, trace->traces [i].count);
}
if (trace->traces)
- free (trace->traces);
+ g_free (trace->traces);
trace->traces = n;
}
trace->count += add_trace_hashed (trace->traces, trace->size, bt, value);
if (debug)
fprintf (outfile, "handle (%s) %u created for object %p\n", get_handle_name (htype), handle, (void*)OBJ_ADDR (objdiff));
if (frames != sframes)
- free (frames);
+ g_free (frames);
} else if (subtype == TYPE_GC_HANDLE_DESTROYED || subtype == TYPE_GC_HANDLE_DESTROYED_BT) {
int has_bt = subtype == TYPE_GC_HANDLE_DESTROYED_BT;
int num_bt = 0;
if (debug)
fprintf (outfile, "handle (%s) %u destroyed\n", get_handle_name (htype), handle);
if (frames != sframes)
- free (frames);
+ g_free (frames);
} else if (subtype == TYPE_GC_FINALIZE_START) {
// TODO: Generate a finalizer report based on these events.
if (debug)
tracked_creation (OBJ_ADDR (objdiff), cd, len, bt, time_base);
}
if (frames != sframes)
- free (frames);
+ g_free (frames);
break;
}
case TYPE_METHOD: {
hs->roots_extra = thread->roots_extra;
hs->roots_types = thread->roots_types;
} else {
- free (thread->roots);
- free (thread->roots_extra);
- free (thread->roots_types);
+ g_free (thread->roots);
+ g_free (thread->roots_extra);
+ g_free (thread->roots_types);
}
thread->num_roots = 0;
thread->size_roots = 0;
if (debug)
fprintf (outfile, "monitor %s for object %p\n", monitor_ev_name (event), (void*)OBJ_ADDR (objdiff));
if (frames != sframes)
- free (frames);
+ g_free (frames);
break;
}
case TYPE_EXCEPTION: {
add_trace_thread (thread, &exc_traces, 1);
}
if (frames != sframes)
- free (frames);
+ g_free (frames);
if (debug)
fprintf (outfile, "throw %p\n", (void*)OBJ_ADDR (objdiff));
}
if (cd->root_references)
fprintf (outfile, "\t\t%zd root references (%zd pinning)\n", cd->root_references, cd->pinned_references);
dump_rev_claases (rev_sorted, cd->rev_count);
- free (rev_sorted);
+ g_free (rev_sorted);
}
- free (sorted);
+ g_free (sorted);
}
static int
*top++ = 0;
from_secs = atof (val);
to_secs = atof (top);
- free (val);
+ g_free (val);
if (from_secs > to_secs) {
usage ();
return 1;
sourceLoc = mono_debug_lookup_source_location (method, dmji->line_numbers[i].native_offset, mono_domain_get());
if (sourceLoc == NULL)
{
- free(vtuneMethod.line_number_table);
+ g_free (vtuneMethod.line_number_table);
vtuneMethod.line_number_table = NULL;
vtuneMethod.line_number_size = 0;
break;
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &vtuneMethod);
if (vtuneMethod.source_file_name != NULL)
- free(vtuneMethod.source_file_name);
+ g_free (vtuneMethod.source_file_name);
if (vtuneMethod.line_number_table != NULL)
- free(vtuneMethod.line_number_table);
+ g_free (vtuneMethod.line_number_table);
g_free (signature);
g_free (name);
if (runtime_inited)
mono_free (name);
else
- free (name);
+ g_free (name);
send_if_needed (prof);
if (runtime_inited)
mono_free (name);
else
- free (name);
+ g_free (name);
send_if_needed (prof);
add_code_page (n, size_code_pages, code_pages [i]);
}
if (code_pages)
- free (code_pages);
+ g_free (code_pages);
code_pages = n;
}
num_code_pages += add_code_page (code_pages, size_code_pages, ip & CPAGE_MASK);
filename = buf;
}
}
- obj = calloc (sizeof (BinaryObject), 1);
+ obj = g_calloc (sizeof (BinaryObject), 1);
obj->addr = (void*)info->dlpi_addr;
obj->name = pstrdup (filename);
obj->next = prof->binary_objects;
names = backtrace_symbols (&ip, 1);
if (names) {
const char* p = names [0];
- free (names);
+ g_free (names);
return p;
}
*/
int i, count = 0;
mmap_mask = num_pages * getpagesize () - 1;
num_perf = mono_cpu_count ();
- perf_data = calloc (num_perf, sizeof (PerfData));
+ perf_data = g_calloc (num_perf, sizeof (PerfData));
for (i = 0; i < num_perf; ++i) {
count += setup_perf_event_for_cpu (perf_data + i, i);
}
if (count)
return 1;
- free (perf_data);
+ g_free (perf_data);
perf_data = NULL;
return 0;
}
if (agent->counter == counter) {
agent->value_size = 0;
if (agent->value) {
- free (agent->value);
+ g_free (agent->value);
agent->value = NULL;
}
mono_os_mutex_unlock (&counters_mutex);
counters_emit (profiler);
buffer_size = 8;
- buffer = calloc (1, buffer_size);
+ buffer = g_calloc (1, buffer_size);
mono_os_mutex_lock (&counters_mutex);
continue; // FIXME error
} else if (size > buffer_size) {
buffer_size = size;
- buffer = realloc (buffer, buffer_size);
+ buffer = g_realloc (buffer, buffer_size);
}
memset (buffer, 0, buffer_size);
type = mono_counter_get_type (counter);
if (!agent->value) {
- agent->value = calloc (1, size);
+ agent->value = g_calloc (1, size);
agent->value_size = size;
} else {
if (type == MONO_COUNTER_STRING) {
}
if (type == MONO_COUNTER_STRING && size > agent->value_size) {
- agent->value = realloc (agent->value, size);
+ agent->value = g_realloc (agent->value, size);
agent->value_size = size;
}
if (size > 0)
memcpy (agent->value, buffer, size);
}
- free (buffer);
+ g_free (buffer);
emit_value (logbuffer, 0);
PROF_TLS_FREE ();
- free (prof->args);
- free (prof);
+ g_free (prof->args);
+ g_free (prof);
}
static char*
mono_free (name);
free_info:
- free (info);
+ g_free (info);
}
g_ptr_array_free (entry->methods, TRUE);
int s = strlen (nf) + 32;
char *p = (char *)malloc (s);
snprintf (p, s, "|mprof-report '--out=%s' -", nf);
- free (nf);
+ g_free (nf);
nf = p;
}
}
// FIXME: We should free this stuff too.
mono_lock_free_allocator_init_size_class (&prof->sample_size_class, SAMPLE_SLOT_SIZE (num_frames), SAMPLE_BLOCK_SIZE);
- mono_lock_free_allocator_init_allocator (&prof->sample_allocator, &prof->sample_size_class);
+ mono_lock_free_allocator_init_allocator (&prof->sample_allocator, &prof->sample_size_class, MONO_MEM_ACCOUNT_PROFILER);
mono_lock_free_queue_init (&prof->sample_reuse_queue);
// FIXME: We should free this stuff too.
mono_lock_free_allocator_init_size_class (&prof->writer_entry_size_class, sizeof (WriterQueueEntry), WRITER_ENTRY_BLOCK_SIZE);
- mono_lock_free_allocator_init_allocator (&prof->writer_entry_allocator, &prof->writer_entry_size_class);
+ mono_lock_free_allocator_init_allocator (&prof->writer_entry_allocator, &prof->writer_entry_size_class, MONO_MEM_ACCOUNT_PROFILER);
mono_lock_free_queue_init (&prof->writer_queue);
mono_os_sem_init (&prof->writer_queue_sem, 0);
if (strcmp (val, "mono") == 0) {
do_mono_sample = 1;
sample_type = SAMPLE_CYCLES;
- free (val);
+ g_free (val);
return;
}
for (smode = sample_modes; smode->name; smode++) {
} else {
sample_freq = 100;
}
- free (val);
+ g_free (val);
}
static void
return;
if (strcmp (val, "ondemand") == 0) {
hs_mode_ondemand = 1;
- free (val);
+ g_free (val);
return;
}
count = strtoul (val, &end, 10);
hs_mode_gc = count;
else
usage (1);
- free (val);
+ g_free (val);
}
/*
fast_time = 2;
else
usage (1);
- free (val);
+ g_free (val);
continue;
}
if ((opt = match_option (p, "report", NULL)) != p) {
if ((opt = match_option (p, "port", &val)) != p) {
char *end;
command_port = strtoul (val, &end, 10);
- free (val);
+ g_free (val);
continue;
}
if ((opt = match_option (p, "maxframes", &val)) != p) {
num_frames = strtoul (val, &end, 10);
if (num_frames > MAX_FRAMES)
num_frames = MAX_FRAMES;
- free (val);
+ g_free (val);
notraces = num_frames == 0;
continue;
}
max_allocated_sample_hits = strtoul (val, &end, 10);
if (!max_allocated_sample_hits)
max_allocated_sample_hits = G_MAXINT32;
- free (val);
+ g_free (val);
continue;
}
if ((opt = match_option (p, "calldepth", &val)) != p) {
char *end;
max_call_depth = strtoul (val, &end, 10);
- free (val);
+ g_free (val);
continue;
}
if ((opt = match_option (p, "counters", NULL)) != p) {
#include <pthread.h>
#include <sched.h>
#endif
-
+#include <glib.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#ifdef HOST_WIN32
static int tls_data;
-#define DECL_TLS_DATA TlsData *tls; tls = (TlsData *) TlsGetValue (tls_data); if (tls == NULL) { tls = (TlsData *) calloc (sizeof (TlsData), 1); TlsSetValue (tls_data, tls); }
+#define DECL_TLS_DATA TlsData *tls; tls = (TlsData *) TlsGetValue (tls_data); if (tls == NULL) { tls = (TlsData *) g_calloc (sizeof (TlsData), 1); TlsSetValue (tls_data, tls); }
#define TLS_INIT(x) x = TlsAlloc()
#elif HAVE_KW_THREAD
static __thread TlsData tls_data;
#define TLS_INIT(x)
#else
static pthread_key_t tls_data;
-#define DECL_TLS_DATA TlsData *tls; tls = (TlsData *) pthread_getspecific (tls_data); if (tls == NULL) { tls = (TlsData *) calloc (sizeof (TlsData), 1); pthread_setspecific (tls_data, tls); }
+#define DECL_TLS_DATA TlsData *tls; tls = (TlsData *) pthread_getspecific (tls_data); if (tls == NULL) { tls = (TlsData *) g_calloc (sizeof (TlsData), 1); pthread_setspecific (tls_data, tls); }
#define TLS_INIT(x) pthread_key_create(&x, NULL)
#endif
void
sgen_card_table_init (SgenRememberedSet *remset)
{
- sgen_cardtable = (guint8 *)sgen_alloc_os_memory (CARD_COUNT_IN_BYTES, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "card table");
+ sgen_cardtable = (guint8 *)sgen_alloc_os_memory (CARD_COUNT_IN_BYTES, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "card table", MONO_MEM_ACCOUNT_SGEN_CARD_TABLE);
#ifdef SGEN_HAVE_OVERLAPPING_CARDS
- sgen_shadow_cardtable = (guint8 *)sgen_alloc_os_memory (CARD_COUNT_IN_BYTES, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "shadow card table");
+ sgen_shadow_cardtable = (guint8 *)sgen_alloc_os_memory (CARD_COUNT_IN_BYTES, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "shadow card table", MONO_MEM_ACCOUNT_SGEN_SHADOW_CARD_TABLE);
#endif
#ifdef HEAVY_STATISTICS
#undef HANDLE_PTR
#define HANDLE_PTR(ptr,obj) do { \
if (*(ptr) && !sgen_ptr_in_nursery ((char*)*(ptr)) && !is_major_or_los_object_marked ((GCObject*)*(ptr))) { \
- if (!sgen_get_remset ()->find_address_with_cards (start, cards, (char*)(ptr))) { \
+ if (!cards || !sgen_get_remset ()->find_address_with_cards (start, cards, (char*)(ptr))) { \
GCVTable __vt = SGEN_LOAD_VTABLE (obj); \
SGEN_LOG (0, "major->major reference %p at offset %zd in object %p (%s.%s) not found in remsets.", *(ptr), (char*)(ptr) - (char*)(obj), (obj), sgen_client_vtable_get_namespace (__vt), sgen_client_vtable_get_name (__vt)); \
binary_protocol_missing_remset ((obj), __vt, (int) ((char*)(ptr) - (char*)(obj)), *(ptr), (gpointer)LOAD_VTABLE(*(ptr)), object_is_pinned (*(ptr))); \
else
cards = sgen_get_major_collector ()->get_cardtable_mod_union_for_reference (start);
- SGEN_ASSERT (0, cards, "we must have mod union for marked major objects");
-
#include "sgen-scan-object.h"
}
{
missing_remsets = FALSE;
- major_collector.iterate_objects (ITERATE_OBJECTS_ALL, (IterateObjectCallbackFunc)check_mod_union_callback, (void*)FALSE);
+ major_collector.iterate_objects (ITERATE_OBJECTS_SWEEP_ALL, (IterateObjectCallbackFunc)check_mod_union_callback, (void*)FALSE);
sgen_los_iterate_objects ((IterateObjectCallbackFunc)check_mod_union_callback, (void*)TRUE);
setup_valid_nursery_objects (void)
{
if (!valid_nursery_objects)
- valid_nursery_objects = (GCObject **)sgen_alloc_os_memory (DEFAULT_NURSERY_SIZE, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging data");
+ valid_nursery_objects = (GCObject **)sgen_alloc_os_memory (DEFAULT_NURSERY_SIZE, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging data", MONO_MEM_ACCOUNT_SGEN_DEBUGGING);
valid_nursery_object_count = 0;
sgen_scan_area_with_callback (nursery_section->data, nursery_section->end_data, setup_mono_sgen_scan_area_with_callback, NULL, FALSE, FALSE);
}
{
char *start = (char*)obj;
gboolean allow_missing_pinned = (gboolean) (size_t) data;
- SgenDescriptor desc = sgen_obj_get_descriptor (obj);
+ SgenDescriptor desc = sgen_obj_get_descriptor_safe (obj);
#include "sgen-scan-object.h"
}
g_assert (sgen_gray_object_queue_is_empty (queue));
- sgen_gray_object_queue_trim_free_list (queue);
binary_protocol_finish_gray_stack_end (sgen_timestamp (), generation);
}
* Return whether any objects were late-pinned due to being out of memory.
*/
static gboolean
-collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_queue, gboolean finish_up_concurrent_mark)
+collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_queue)
{
gboolean needs_major;
size_t max_garbage_amount;
gc_stats.minor_gc_count ++;
- if (whole_heap_check_before_collection) {
- sgen_clear_nursery_fragments ();
- sgen_check_whole_heap (finish_up_concurrent_mark);
- }
-
sgen_process_fin_stage_entries ();
/* pin from pinned handles */
if (remset_consistency_checks)
sgen_check_remset_consistency ();
+ if (whole_heap_check_before_collection) {
+ sgen_clear_nursery_fragments ();
+ sgen_check_whole_heap (FALSE);
+ }
+
TV_GETTIME (atv);
time_minor_pinning += TV_ELAPSED (btv, atv);
SGEN_LOG (2, "Finding pinned pointers: %zd in %lld usecs", sgen_get_pinned_count (), (long long)TV_ELAPSED (btv, atv));
sgen_clear_nursery_fragments ();
if (whole_heap_check_before_collection)
- sgen_check_whole_heap (mode == COPY_OR_MARK_FROM_ROOTS_FINISH_CONCURRENT);
+ sgen_check_whole_heap (TRUE);
TV_GETTIME (btv);
time_major_pre_collection_fragment_clear += TV_ELAPSED (atv, btv);
if (old_next_pin_slot)
*old_next_pin_slot = sgen_get_pinned_count ();
- /*
- * We don't actually pin when starting a concurrent collection, so the remset
- * consistency check won't work.
- */
- if (remset_consistency_checks && mode != COPY_OR_MARK_FROM_ROOTS_START_CONCURRENT)
- sgen_check_remset_consistency ();
-
TV_GETTIME (btv);
time_major_pinning += TV_ELAPSED (atv, btv);
SGEN_LOG (2, "Finding pinned pointers: %zd in %lld usecs", sgen_get_pinned_count (), (long long)TV_ELAPSED (atv, btv));
reset_heap_boundaries ();
sgen_update_heap_boundaries ((mword)sgen_get_nursery_start (), (mword)sgen_get_nursery_end ());
- if (whole_heap_check_before_collection)
- sgen_check_whole_heap (FALSE);
-
/* walk the pin_queue, build up the fragment list of free memory, unmark
* pinned objects as we go, memzero() the empty fragments so they are ready for the
* next allocations.
if (concurrent_collection_in_progress)
major_update_concurrent_collection ();
- if (collect_nursery (reason, FALSE, NULL, FALSE) && !concurrent_collection_in_progress) {
+ if (collect_nursery (reason, FALSE, NULL) && !concurrent_collection_in_progress) {
overflow_generation_to_collect = GENERATION_OLD;
overflow_reason = "Minor overflow";
}
} else {
SGEN_ASSERT (0, generation_to_collect == GENERATION_OLD, "We should have handled nursery collections above");
if (major_collector.is_concurrent && !wait_to_finish) {
- collect_nursery ("Concurrent start", FALSE, NULL, FALSE);
+ collect_nursery ("Concurrent start", FALSE, NULL);
major_start_concurrent_collection (reason);
oldest_generation_collected = GENERATION_NURSERY;
} else if (major_do_collection (reason, FALSE, wait_to_finish)) {
*/
if (overflow_generation_to_collect == GENERATION_NURSERY)
- collect_nursery (overflow_reason, TRUE, NULL, FALSE);
+ collect_nursery (overflow_reason, TRUE, NULL);
else
major_do_collection (overflow_reason, TRUE, wait_to_finish);
{
sgen_stop_world (0);
sgen_clear_nursery_fragments ();
- sgen_check_whole_heap (FALSE);
+ sgen_check_whole_heap (TRUE);
sgen_restart_world (0);
}
ITERATE_OBJECTS_SWEEP = 1,
ITERATE_OBJECTS_NON_PINNED = 2,
ITERATE_OBJECTS_PINNED = 4,
- ITERATE_OBJECTS_ALL = ITERATE_OBJECTS_NON_PINNED | ITERATE_OBJECTS_PINNED,
ITERATE_OBJECTS_SWEEP_NON_PINNED = ITERATE_OBJECTS_SWEEP | ITERATE_OBJECTS_NON_PINNED,
ITERATE_OBJECTS_SWEEP_PINNED = ITERATE_OBJECTS_SWEEP | ITERATE_OBJECTS_PINNED,
ITERATE_OBJECTS_SWEEP_ALL = ITERATE_OBJECTS_SWEEP | ITERATE_OBJECTS_NON_PINNED | ITERATE_OBJECTS_PINNED
void (*sweep) (void);
gboolean (*have_swept) (void);
void (*finish_sweeping) (void);
- void (*free_swept_blocks) (size_t allowance);
+ void (*free_swept_blocks) (size_t section_reserve);
void (*check_scan_starts) (void);
void (*dump_heap) (FILE *heap_dump_file);
gint64 (*get_used_size) (void);
{
GrayQueueSection *section;
- HEAVY_STAT (stat_gray_queue_section_alloc ++);
-
if (queue->alloc_prepare_func)
queue->alloc_prepare_func (queue);
queue->free_list = section->next;
STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_FREE_LIST, GRAY_QUEUE_SECTION_STATE_FLOATING);
} else {
+ HEAVY_STAT (stat_gray_queue_section_alloc ++);
+
/* Allocate a new section */
section = (GrayQueueSection *)sgen_alloc_internal (INTERNAL_MEM_GRAY_QUEUE);
STATE_SET (section, GRAY_QUEUE_SECTION_STATE_FLOATING);
8, 16, 24, 32, 40, 48, 64, 80,
96, 128, 160, 192, 224, 248, 296, 320,
384, 448, 504, 528, 584, 680, 816, 1088,
- 1360, 2044, 2336, 2728, 3272, 4092, 5456, 8188 };
+ 1360, 2046, 2336, 2728, 3272, 4094, 5456, 8190 };
#else
static const int allocator_sizes [] = {
8, 16, 24, 32, 40, 48, 64, 80,
- 96, 128, 160, 192, 224, 248, 320, 328,
- 384, 448, 528, 584, 680, 816, 1016, 1088,
- 1360, 2040, 2336, 2728, 3272, 4088, 5456, 8184 };
+ 96, 128, 160, 192, 224, 248, 296, 320,
+ 384, 448, 504, 528, 584, 680, 816, 1088,
+ 1360, 2044, 2336, 2728, 3272, 4092, 5456, 8188 };
#endif
#define NUM_ALLOCATORS (sizeof (allocator_sizes) / sizeof (int))
void *p;
if (size > allocator_sizes [NUM_ALLOCATORS - 1]) {
- p = sgen_alloc_os_memory (size, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), NULL);
+ p = sgen_alloc_os_memory (size, (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), NULL, MONO_MEM_ACCOUNT_SGEN_INTERNAL);
if (!p)
sgen_assert_memory_alloc (NULL, size, description_for_type (type));
} else {
return;
if (size > allocator_sizes [NUM_ALLOCATORS - 1])
- sgen_free_os_memory (addr, size, SGEN_ALLOC_INTERNAL);
+ sgen_free_os_memory (addr, size, SGEN_ALLOC_INTERNAL, MONO_MEM_ACCOUNT_SGEN_INTERNAL);
else
mono_lock_free_free (addr, block_size (size));
}
for (i = 0; i < NUM_ALLOCATORS; ++i) {
allocator_block_sizes [i] = block_size (allocator_sizes [i]);
mono_lock_free_allocator_init_size_class (&size_classes [i], allocator_sizes [i], allocator_block_sizes [i]);
- mono_lock_free_allocator_init_allocator (&allocators [i], &size_classes [i]);
+ mono_lock_free_allocator_init_allocator (&allocators [i], &size_classes [i], MONO_MEM_ACCOUNT_SGEN_INTERNAL);
}
for (size = mono_pagesize (); size <= LOCK_FREE_ALLOC_SB_MAX_SIZE; size <<= 1) {
if (!sgen_memgov_try_alloc_space (LOS_SECTION_SIZE, SPACE_LOS))
return NULL;
- section = (LOSSection *)sgen_alloc_os_memory_aligned (LOS_SECTION_SIZE, LOS_SECTION_SIZE, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), NULL);
+ section = (LOSSection *)sgen_alloc_os_memory_aligned (LOS_SECTION_SIZE, LOS_SECTION_SIZE, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), NULL, MONO_MEM_ACCOUNT_SGEN_LOS);
if (!section)
return NULL;
los_num_objects--;
#ifdef USE_MALLOC
- free (obj);
+ g_free (obj);
#else
if (size > LOS_SECTION_OBJECT_LIMIT) {
int pagesize = mono_pagesize ();
size += sizeof (LOSObject);
size = SGEN_ALIGN_UP_TO (size, pagesize);
- sgen_free_os_memory ((gpointer)SGEN_ALIGN_DOWN_TO ((mword)obj, pagesize), size, SGEN_ALLOC_HEAP);
+ sgen_free_os_memory ((gpointer)SGEN_ALIGN_DOWN_TO ((mword)obj, pagesize), size, SGEN_ALLOC_HEAP, MONO_MEM_ACCOUNT_SGEN_LOS);
los_memory_usage_total -= size;
sgen_memgov_release_space (size, SPACE_LOS);
} else {
sgen_ensure_free_space (size, GENERATION_OLD);
#ifdef USE_MALLOC
- obj = malloc (size + sizeof (LOSObject));
+ obj = g_malloc (size + sizeof (LOSObject));
memset (obj, 0, size + sizeof (LOSObject));
#else
if (size > LOS_SECTION_OBJECT_LIMIT) {
int pagesize = mono_pagesize ();
size_t alloc_size = SGEN_ALIGN_UP_TO (obj_size, pagesize);
if (sgen_memgov_try_alloc_space (alloc_size, SPACE_LOS)) {
- obj = (LOSObject *)sgen_alloc_os_memory (alloc_size, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), NULL);
+ obj = (LOSObject *)sgen_alloc_os_memory (alloc_size, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), NULL, MONO_MEM_ACCOUNT_SGEN_LOS);
if (obj) {
los_memory_usage_total += alloc_size;
obj = randomize_los_object_start (obj, obj_size, alloc_size, pagesize);
prev->next = next;
else
los_sections = next;
- sgen_free_os_memory (section, LOS_SECTION_SIZE, SGEN_ALLOC_HEAP);
+ sgen_free_os_memory (section, LOS_SECTION_SIZE, SGEN_ALLOC_HEAP, MONO_MEM_ACCOUNT_SGEN_LOS);
sgen_memgov_release_space (LOS_SECTION_SIZE, SPACE_LOS);
section = next;
--los_num_sections;
static guint64 stat_major_blocks_freed = 0;
static guint64 stat_major_blocks_lazy_swept = 0;
-#if SIZEOF_VOID_P != 8
static guint64 stat_major_blocks_freed_ideal = 0;
static guint64 stat_major_blocks_freed_less_ideal = 0;
static guint64 stat_major_blocks_freed_individual = 0;
static guint64 stat_major_blocks_alloced_less_ideal = 0;
-#endif
#ifdef SGEN_COUNT_NUMBER_OF_MAJOR_OBJECTS_MARKED
static guint64 num_major_objects_marked = 0;
{
char *start;
if (nursery_align)
- start = (char *)sgen_alloc_os_memory_aligned (nursery_size, nursery_align, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), "nursery");
+ start = (char *)sgen_alloc_os_memory_aligned (nursery_size, nursery_align, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), "nursery", MONO_MEM_ACCOUNT_SGEN_NURSERY);
else
- start = (char *)sgen_alloc_os_memory (nursery_size, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), "nursery");
+ start = (char *)sgen_alloc_os_memory (nursery_size, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), "nursery", MONO_MEM_ACCOUNT_SGEN_NURSERY);
return start;
}
for (;;) {
p = (char *)sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * alloc_num, MS_BLOCK_SIZE,
(SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE),
- alloc_num == 1 ? "major heap section" : NULL);
+ alloc_num == 1 ? "major heap section" : NULL, MONO_MEM_ACCOUNT_SGEN_MARKSWEEP);
if (p)
break;
alloc_num >>= 1;
gboolean pinned = flags & ITERATE_OBJECTS_PINNED;
MSBlockInfo *block;
+ /* No actual sweeping will take place if we are in the middle of a major collection. */
major_finish_sweep_checking ();
FOREACH_BLOCK_NO_LOCK (block) {
int count = MS_BLOCK_FREE / block->obj_size;
continue;
if (!block->pinned && !non_pinned)
continue;
- if (sweep && lazy_sweep) {
+ if (sweep && lazy_sweep && !block_is_swept_or_marking (block)) {
sweep_block (block);
SGEN_ASSERT (6, block->state == BLOCK_STATE_SWEPT, "Block must be swept after sweeping");
}
for (i = 0; i < count; ++i) {
void **obj = (void**) MS_BLOCK_OBJ (block, i);
- /*
- * We've finished sweep checking, but if we're sweeping lazily and
- * the flags don't require us to sweep, the block might still need
- * sweeping. In that case, we need to consult the mark bits to tell
- * us whether an object slot is live.
- */
- if (!block_is_swept_or_marking (block)) {
- int word, bit;
- SGEN_ASSERT (6, !sweep && block->state == BLOCK_STATE_NEED_SWEEPING, "Has sweeping not finished?");
- MS_CALC_MARK_BIT (word, bit, obj);
- if (!MS_MARK_BIT (block, word, bit))
- continue;
- }
if (MS_OBJ_ALLOCED (obj, block))
callback ((GCObject*)obj, block->obj_size, data);
}
#endif
}
-#if SIZEOF_VOID_P != 8
static int
compare_pointers (const void *va, const void *vb) {
char *a = *(char**)va, *b = *(char**)vb;
return 1;
return 0;
}
-#endif
/*
* This is called with sweep completed and the world stopped.
*/
static void
-major_free_swept_blocks (size_t allowance)
+major_free_swept_blocks (size_t section_reserve)
{
- /* FIXME: This is probably too much. It's assuming all objects are small. */
- size_t section_reserve = allowance / MS_BLOCK_SIZE;
-
SGEN_ASSERT (0, sweep_state == SWEEP_STATE_SWEPT, "Sweeping must have finished before freeing blocks");
#ifdef TARGET_WIN32
return;
#endif
-#if SIZEOF_VOID_P != 8
{
int i, num_empty_blocks_orig, num_blocks, arr_length;
void *block;
* we're iterating.
*/
int j;
- sgen_free_os_memory (empty_block_arr [first], MS_BLOCK_SIZE * num_blocks, SGEN_ALLOC_HEAP);
+ sgen_free_os_memory (empty_block_arr [first], MS_BLOCK_SIZE * num_blocks, SGEN_ALLOC_HEAP, MONO_MEM_ACCOUNT_SGEN_MARKSWEEP);
for (j = first; j <= d; ++j)
empty_block_arr [j] = NULL;
dest = first;
*/
if (num_empty_blocks <= num_major_sections)
return;
-#endif
while (num_empty_blocks > section_reserve) {
void *next = *(void**)empty_blocks;
- sgen_free_os_memory (empty_blocks, MS_BLOCK_SIZE, SGEN_ALLOC_HEAP);
+ sgen_free_os_memory (empty_blocks, MS_BLOCK_SIZE, SGEN_ALLOC_HEAP, MONO_MEM_ACCOUNT_SGEN_MARKSWEEP);
empty_blocks = next;
/*
* Needs not be atomic because this is running
--num_empty_blocks;
++stat_major_blocks_freed;
-#if SIZEOF_VOID_P != 8
++stat_major_blocks_freed_individual;
-#endif
}
}
mono_counters_register ("# major blocks allocated", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_alloced);
mono_counters_register ("# major blocks freed", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_freed);
mono_counters_register ("# major blocks lazy swept", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_lazy_swept);
-#if SIZEOF_VOID_P != 8
mono_counters_register ("# major blocks freed ideally", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_freed_ideal);
mono_counters_register ("# major blocks freed less ideally", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_freed_less_ideal);
mono_counters_register ("# major blocks freed individually", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_freed_individual);
mono_counters_register ("# major blocks allocated less ideally", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_major_blocks_alloced_less_ideal);
-#endif
collector->section_size = MAJOR_SECTION_SIZE;
/* FIXME: Why is this here? */
if (major_collector.free_swept_blocks)
- major_collector.free_swept_blocks (allowance);
+ major_collector.free_swept_blocks (major_collector.get_num_major_sections () * SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO);
major_collection_trigger_size = new_heap_size + allowance;
* This must not require any lock.
*/
void*
-sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_description)
+sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_description, MonoMemAccountType type)
{
void *ptr;
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
- ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
+ ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE), type);
sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
}
/* size must be a power of 2 */
+// FIXME: remove assert_description
void*
-sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags, const char *assert_description)
+sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags, const char *assert_description, MonoMemAccountType type)
{
void *ptr;
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
- ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
+ ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE), type);
sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
* Free the memory returned by sgen_alloc_os_memory (), returning it to the OS.
*/
void
-sgen_free_os_memory (void *addr, size_t size, SgenAllocFlags flags)
+sgen_free_os_memory (void *addr, size_t size, SgenAllocFlags flags, MonoMemAccountType type)
{
g_assert (!(flags & ~SGEN_ALLOC_HEAP));
- mono_vfree (addr, size);
+ mono_vfree (addr, size, type);
SGEN_ATOMIC_ADD_P (total_alloc, -(gssize)size);
total_alloc_max = MAX (total_alloc_max, total_alloc);
}
debug_print_allowance = debug_allowance;
major_collection_trigger_size = MIN_MINOR_COLLECTION_ALLOWANCE;
- mono_counters_register ("Memgov alloc", MONO_COUNTER_GC | MONO_COUNTER_WORD | MONO_COUNTER_BYTES | MONO_COUNTER_VARIABLE, &total_alloc);
- mono_counters_register ("Memgov max alloc", MONO_COUNTER_GC | MONO_COUNTER_WORD | MONO_COUNTER_BYTES | MONO_COUNTER_MONOTONIC, &total_alloc_max);
+ mono_counters_register ("Memgov alloc", MONO_COUNTER_GC | MONO_COUNTER_WORD | MONO_COUNTER_BYTES | MONO_COUNTER_VARIABLE, (void*)&total_alloc);
+ mono_counters_register ("Memgov max alloc", MONO_COUNTER_GC | MONO_COUNTER_WORD | MONO_COUNTER_BYTES | MONO_COUNTER_MONOTONIC, (void*)&total_alloc_max);
mono_coop_mutex_init (&log_entries_mutex);
} SgenLogEntry;
/* OS memory allocation */
-void* sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_description);
-void* sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags, const char *assert_description);
-void sgen_free_os_memory (void *addr, size_t size, SgenAllocFlags flags);
+void* sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_description, MonoMemAccountType type);
+void* sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags, const char *assert_description, MonoMemAccountType type);
+void sgen_free_os_memory (void *addr, size_t size, SgenAllocFlags flags, MonoMemAccountType type);
/* Error handling */
void sgen_assert_memory_alloc (void *ptr, size_t requested_size, const char *assert_description);
current_file_size += buffer->index;
- sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL);
+ sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL, MONO_MEM_ACCOUNT_SGEN_BINARY_PROTOCOL);
}
static void
if (buffer && buffer->index + length <= BINARY_PROTOCOL_BUFFER_SIZE)
return buffer;
- new_buffer = (BinaryProtocolBuffer *)sgen_alloc_os_memory (sizeof (BinaryProtocolBuffer), (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging memory");
+ new_buffer = (BinaryProtocolBuffer *)sgen_alloc_os_memory (sizeof (BinaryProtocolBuffer), (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging memory", MONO_MEM_ACCOUNT_SGEN_BINARY_PROTOCOL);
new_buffer->next = buffer;
new_buffer->index = 0;
if (InterlockedCompareExchangePointer ((void**)&binary_protocol_buffers, new_buffer, buffer) != buffer) {
- sgen_free_os_memory (new_buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL);
+ sgen_free_os_memory (new_buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL, MONO_MEM_ACCOUNT_SGEN_BINARY_PROTOCOL);
goto retry;
}
}
static void
-worker_try_finish (void)
+worker_try_finish (WorkerData *data)
{
State old_state;
} while (!set_state (old_state, STATE_NOT_WORKING));
binary_protocol_worker_finish (sgen_timestamp (), forced_stop);
+
+ sgen_gray_object_queue_trim_free_list (&data->private_gray_queue);
}
void
sgen_thread_pool_job_enqueue (job);
preclean_job = NULL;
} else {
- worker_try_finish ();
+ worker_try_finish (data);
}
}
}
FEATUREFUL_RUNTIME_TEST = test-appdomain-unload
endif
-check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-cattr-type-load test-reflection-load-with-context test_platform \
+check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-multi-netmodule test-cattr-type-load test-reflection-load-with-context test_platform \
test-console-output test-messages test-env-options test-unhandled-exception-2 $(FEATUREFUL_RUNTIME_TEST) test-process-stress rm-empty-logs
check-full: test-sgen check-local
check-parallel: compile-tests check-full
bug-29585.cs \
priority.cs \
abort-cctor.cs \
- reference-loader.cs
+ namedmutex-destroy-race.cs
if INSTALL_MOBILE_STATIC
BASE_TEST_CS_SRC= \
# but that need to be compiled
PREREQ_IL_SRC=event-il.il module-cctor.il
PREREQ_CS_SRC=
-PREREQ_IL_DLL_SRC=
-PREREQ_CS_DLL_SRC=TestingReferenceAssembly.cs TestingReferenceReferenceAssembly.cs
+PREREQ_IL_DLL_SRC=event-il.il module-cctor.il
+PREREQ_CS_DLL_SRC=
-PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe) \
- $(PREREQ_IL_DLL_SRC:.il=.dll)
-PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe) \
- $(PREREQ_CS_DLL_SRC:.cs=.dll)
+PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe)
+PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe)
TESTSI_CS=$(TEST_CS_SRC:.cs=.exe)
TESTSI_IL=$(TEST_IL_SRC:.il=.exe)
TESTBS=$(BENCHSRC:.cs=.exe)
STRESS_TESTS=$(STRESS_TESTS_SRC:.cs=.exe)
-PREREQSI_IL_AOT=$(PREREQ_IL_SRC:.il=.exe$(PLATFORM_AOT_SUFFIX)) \
- $(PREREQ_IL_DLL_SRC:.il=.dll$(PLATFORM_AOT_SUFFIX))
-PREREQSI_CS_AOT=$(PREREQ_CS_SRC:.cs=.exe$(PLATFORM_AOT_SUFFIX)) \
- $(PREREQ_CS_DLL_SRC:.cs=.dll$(PLATFORM_AOT_SUFFIX))
+PREREQSI_IL_AOT=$(PREREQ_IL_SRC:.il=.exe$(PLATFORM_AOT_SUFFIX))
+PREREQSI_CS_AOT=$(PREREQ_CS_SRC:.cs=.exe$(PLATFORM_AOT_SUFFIX))
EXTRA_DIST=test-driver test-runner.cs $(TEST_CS_SRC_DIST) $(TEST_IL_SRC) \
$(BENCHSRC) $(STRESS_TESTS_SRC) stress-runner.pl $(PREREQ_IL_SRC) $(PREREQ_CS_SRC)
%.exe: %.cs $(TEST_DRIVER_DEPEND)
$(MCS) -r:System.dll -r:System.Xml.dll -r:System.Core.dll -r:TestDriver.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $<
-%.dll: %.cs
- $(MCS) -r:System.dll -target:library -out:$@ $<
-
-TestingReferenceReferenceAssembly.dll: TestingReferenceReferenceAssembly.cs TestingReferenceAssembly.dll
- $(MCS) -r:TestingReferenceAssembly.dll -target:library -out:$@ $<
-
%.exe$(PLATFORM_AOT_SUFFIX): %.exe
$(RUNTIME) $(AOT_BUILD_FLAGS) $<
@echo "Testing load-exception.exe..."
@$(RUNTIME) load-exceptions.exe > load-exceptions.exe.stdout 2> load-exceptions.exe.stderr
+EXTRA_DIST += test-multi-netmodule-1-netmodule.cs test-multi-netmodule-2-dll1.cs test-multi-netmodule-3-dll2.cs test-multi-netmodule-4-exe.cs
+test-multi-netmodule:
+ @$(MCS) -t:module test-multi-netmodule-1-netmodule.cs
+ @$(MCS) -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library test-multi-netmodule-2-dll1.cs
+ @$(MCS) -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library test-multi-netmodule-3-dll2.cs
+ @$(MCS) -r:test-multi-netmodule-2-dll1.dll test-multi-netmodule-4-exe.cs
+ $(RUNTIME) test-multi-netmodule-4-exe.exe > test-multi-netmodule-4-exe.exe.stdout 2> test-multi-netmodule-4-exe.exe.stderr
+
EXTRA_DIST += custom-attr-errors.cs custom-attr-errors-lib.cs
test-cattr-type-load: $(TEST_DRIVER_DEPEND) custom-attr-errors.cs custom-attr-errors-lib.cs
$(MCS) -D:WITH_MEMBERS /t:library $(srcdir)/custom-attr-errors-lib.cs
+++ /dev/null
-using System.Runtime.CompilerServices;
-
-[assembly: ReferenceAssemblyAttribute]
-
-public class X {
- public int Y;
-}
+++ /dev/null
-// An assembly that refereces the TestingReferenceAssembly
-
-class Z : X {
- public Z () {
- Y = 1;
- }
-}
--- /dev/null
+
+/* test for https://bugzilla.xamarin.com/show_bug.cgi?id=41914 */
+
+using System;
+using System.Threading;
+
+namespace Crasher
+{
+ class Program
+ {
+ public static void Main (string[] args)
+ {
+ Thread[] threads = new Thread[100];
+
+ DateTime start = DateTime.Now;
+
+ for (int i = 0; i < threads.Length; ++i) {
+ threads [i] = new Thread (() => {
+ var rnd = new Random();
+ do {
+ using (var mutex = new Mutex(false, "Global\\TEST")) {
+ var owner = false;
+ try {
+ owner = mutex.WaitOne(TimeSpan.FromMinutes(1));
+ } finally {
+ if (owner)
+ mutex.ReleaseMutex();
+ }
+ }
+ Thread.Sleep(rnd.Next(100, 1000));
+ } while ((DateTime.Now - start) < TimeSpan.FromSeconds (30));
+ });
+ }
+
+ for (int i = 0; i < threads.Length; ++i)
+ threads [i].Start ();
+
+ for (int i = 0; i < threads.Length; ++i)
+ threads [i].Join ();
+ }
+
+ private static void Crasher(){
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-//
-// reference-loader.cs:
-//
-// Test for reference assembly loading
-
-using System;
-using System.IO;
-using System.Reflection;
-
-public class Tests {
- public static int Main (string[] args)
- {
- return TestDriver.RunTests (typeof (Tests), args);
- }
-
- public static int test_0_loadFrom_reference ()
- {
- // Check that loading a reference assembly by filename for execution is an error
- try {
- var a = Assembly.LoadFrom ("./TestingReferenceAssembly.dll");
- } catch (BadImageFormatException exn) {
- // Console.Error.WriteLine ("exn was {0}", exn);
- return 0;
- }
- return 1;
- }
-
- public static int test_0_load_reference ()
- {
- // Check that loading a reference assembly for execution is an error
- try {
- var an = new AssemblyName ("TestingReferenceAssembly");
- var a = Assembly.Load (an);
- } catch (BadImageFormatException exn) {
- //Console.Error.WriteLine ("exn was {0}", exn);
- return 0;
- } catch (FileNotFoundException exn) {
- Console.Error.WriteLine ("incorrect exn was {0}", exn);
- return 2;
- }
- return 1;
- }
-
- public static int test_0_reflection_load_reference ()
- {
- // Check that reflection-only loading a reference assembly is okay
- var an = new AssemblyName ("TestingReferenceAssembly");
- var a = Assembly.ReflectionOnlyLoad (an.FullName);
- var t = a.GetType ("X");
- var f = t.GetField ("Y");
- if (f.FieldType.Equals (typeof (Int32)))
- return 0;
- return 1;
- }
-
- public static int test_0_load_reference_asm_via_reference ()
- {
- // Check that loading an assembly that references a reference assembly doesn't succeed.
- var an = new AssemblyName ("TestingReferenceReferenceAssembly");
- try {
- var a = Assembly.Load (an);
- var t = a.GetType ("Z");
- } catch (FileNotFoundException){
- return 0;
- }
- return 1;
- }
-
- public static int test_0_reflection_load_reference_asm_via_reference ()
- {
- // Check that reflection-only loading an assembly that
- // references a reference assembly is okay.
- var an = new AssemblyName ("TestingReferenceReferenceAssembly");
- var a = Assembly.ReflectionOnlyLoad (an.FullName);
- var t = a.GetType ("Z");
- var f = t.GetField ("Y");
- if (f.FieldType.Equals (typeof (Int32)))
- return 0;
- return 1;
- }
-
-
- public static int test_0_load_reference_bytes ()
- {
- // Check that loading a reference assembly from a byte array for execution is an error
- byte[] bs = File.ReadAllBytes ("./TestingReferenceAssembly.dll");
- try {
- var a = Assembly.Load (bs);
- } catch (BadImageFormatException) {
- return 0;
- } catch (FileNotFoundException exn) {
- Console.Error.WriteLine ("incorrect exn was {0}", exn);
- return 2;
- }
- return 1;
- }
-
- public static int test_0_reflection_load_reference_bytes ()
- {
- // Check that loading a reference assembly from a byte
- // array for reflection only is okay.
- byte[] bs = File.ReadAllBytes ("./TestingReferenceAssembly.dll");
- var a = Assembly.ReflectionOnlyLoad (bs);
- var t = a.GetType ("X");
- var f = t.GetField ("Y");
- if (f.FieldType.Equals (typeof (Int32)))
- return 0;
- return 1;
- }
-
-}
--- /dev/null
+// Compiler options: -t:module
+
+public class M1 {
+}
--- /dev/null
+// Compiler options: -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library
+
+public class M2 {
+ public M1 m1 = new M1();
+}
--- /dev/null
+// Compiler options: -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library
+
+public class M3 {
+ public M1 m1 = new M1();
+}
--- /dev/null
+// Compiler options: -r:test-multi-netmodule-2-dll1.dll
+
+using System;
+using System.Reflection;
+
+public class M4 {
+ public static int Main () {
+ M2 m2 = new M2();
+
+ // Expecting failure
+ try {
+ var DLL = Assembly.LoadFile(@"test-multi-netmodule-3-dll2.dll");
+ var m3Type = DLL.GetType("M3");
+ var m3 = Activator.CreateInstance(m3Type);
+ var m3m1Field = m3Type.GetField("m1");
+
+ Console.WriteLine("M3 assembly:" + m3Type.Assembly);
+ Console.WriteLine("M3.M1 assembly:" + m3m1Field.DeclaringType.Assembly);
+ } catch (System.TypeLoadException) {
+ return 0;
+ }
+
+ Console.WriteLine("M2 assembly:" + typeof (M2).Assembly);
+ Console.WriteLine("M2.M1 assembly:" + m2.m1.GetType().Assembly);
+
+ return 1;
+ }
+}
g_string_append_printf (bt, "\tat %s\n", names [i]);
}
- free (names);
+ g_free (names);
return g_string_free (bt, FALSE);
}
// For each queued image visit all directly referenced images
int inner_idx;
+ // 'files' and 'modules' semantically contain the same items but because of lazy loading we must check both
+ for (inner_idx = 0; !success && inner_idx < checking->file_count; inner_idx++)
+ {
+ CHECK_IMAGE_VISIT (checking->files[inner_idx]);
+ }
+
for (inner_idx = 0; !success && inner_idx < checking->module_count; inner_idx++)
{
CHECK_IMAGE_VISIT (checking->modules[inner_idx]);
for (inner_idx = 0; !success && inner_idx < checking->nreferences; inner_idx++)
{
- // References are lazy-loaded and thus allowed to be NULL.
- // If they are NULL, we don't care about them for this search, because they haven't impacted ref_count yet.
- if (checking->references[inner_idx])
- {
- CHECK_IMAGE_VISIT (checking->references[inner_idx]->image);
- }
+ CHECK_IMAGE_VISIT (checking->references[inner_idx]->image);
}
mono_image_unlock (checking);
/* The table where we keep pointers to blocks to be freed but that
have to wait because they're guarded by a hazard pointer. */
-static MonoLockFreeArrayQueue delayed_free_queue = MONO_LOCK_FREE_ARRAY_QUEUE_INIT (sizeof (DelayedFreeItem));
+static MonoLockFreeArrayQueue delayed_free_queue = MONO_LOCK_FREE_ARRAY_QUEUE_INIT (sizeof (DelayedFreeItem), MONO_MEM_ACCOUNT_HAZARD_POINTERS);
/* The table for small ID assignment */
static mono_mutex_t small_id_mutex;
if (hazard_table == NULL) {
hazard_table = (MonoThreadHazardPointers *volatile) mono_valloc (NULL,
sizeof (MonoThreadHazardPointers) * HAZARD_TABLE_MAX_SIZE,
- MONO_MMAP_NONE);
+ MONO_MMAP_NONE, MONO_MEM_ACCOUNT_HAZARD_POINTERS);
}
g_assert (hazard_table != NULL);
pagesize = mono_pagesize ();
sb_header = desc->block_size == pagesize ?
- mono_valloc (NULL, desc->block_size, prot_flags_for_activate (TRUE)) :
- mono_valloc_aligned (desc->block_size, desc->block_size, prot_flags_for_activate (TRUE));
+ mono_valloc (NULL, desc->block_size, prot_flags_for_activate (TRUE), desc->heap->account_type) :
+ mono_valloc_aligned (desc->block_size, desc->block_size, prot_flags_for_activate (TRUE), desc->heap->account_type);
g_assert (sb_header == sb_header_for_addr (sb_header, desc->block_size));
}
static void
-free_sb (gpointer sb, size_t block_size)
+free_sb (gpointer sb, size_t block_size, MonoMemAccountType type)
{
gpointer sb_header = sb_header_for_addr (sb, block_size);
g_assert ((char*)sb_header + LOCK_FREE_ALLOC_SB_HEADER_SIZE == sb);
- mono_vfree (sb_header, block_size);
+ mono_vfree (sb_header, block_size, type);
//g_print ("free sb %p\n", sb_header);
}
static Descriptor * volatile desc_avail;
static Descriptor*
-desc_alloc (void)
+desc_alloc (MonoMemAccountType type)
{
MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
Descriptor *desc;
Descriptor *d;
int i;
- desc = (Descriptor *) mono_valloc (NULL, desc_size * NUM_DESC_BATCH, prot_flags_for_activate (TRUE));
+ desc = (Descriptor *) mono_valloc (NULL, desc_size * NUM_DESC_BATCH, prot_flags_for_activate (TRUE), type);
/* Organize into linked list. */
d = desc;
success = (InterlockedCompareExchangePointer ((gpointer * volatile)&desc_avail, desc->next, NULL) == NULL);
if (!success)
- mono_vfree (desc, desc_size * NUM_DESC_BATCH);
+ mono_vfree (desc, desc_size * NUM_DESC_BATCH, type);
}
mono_hazard_pointer_clear (hp, 1);
g_assert (desc->anchor.data.state == STATE_EMPTY);
g_assert (desc->in_use);
desc->in_use = FALSE;
- free_sb (desc->sb, desc->block_size);
+ free_sb (desc->sb, desc->block_size, desc->heap->account_type);
mono_thread_hazardous_try_free (desc, desc_enqueue_avail);
}
#else
MonoLockFreeQueue available_descs;
static Descriptor*
-desc_alloc (void)
+desc_alloc (MonoMemAccountType type)
{
Descriptor *desc = (Descriptor*)mono_lock_free_queue_dequeue (&available_descs);
if (desc)
return desc;
- return calloc (1, sizeof (Descriptor));
+ return g_calloc (1, sizeof (Descriptor));
}
static void
desc_retire (Descriptor *desc)
{
- free_sb (desc->sb, desc->block_size);
+ free_sb (desc->sb, desc->block_size, desc->heap->account_type);
mono_lock_free_queue_enqueue (&available_descs, &desc->node);
}
#endif
alloc_from_new_sb (MonoLockFreeAllocator *heap)
{
unsigned int slot_size, block_size, count, i;
- Descriptor *desc = desc_alloc ();
+ Descriptor *desc = desc_alloc (heap->account_type);
slot_size = desc->slot_size = heap->sc->slot_size;
block_size = desc->block_size = heap->sc->block_size;
}
void
-mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator *heap, MonoLockFreeAllocSizeClass *sc)
+mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator *heap, MonoLockFreeAllocSizeClass *sc, MonoMemAccountType account_type)
{
heap->sc = sc;
heap->active = NULL;
+ heap->account_type = account_type;
}
typedef struct {
struct _MonoLockFreeAllocDescriptor *active;
MonoLockFreeAllocSizeClass *sc;
+ MonoMemAccountType account_type;
} MonoLockFreeAllocator;
#define LOCK_FREE_ALLOC_SB_MAX_SIZE 16384
-#define LOCK_FREE_ALLOC_SB_HEADER_SIZE (sizeof (MonoLockFreeAllocator))
+#define LOCK_FREE_ALLOC_SB_HEADER_SIZE (sizeof (gpointer))
#define LOCK_FREE_ALLOC_SB_USABLE_SIZE(block_size) ((block_size) - LOCK_FREE_ALLOC_SB_HEADER_SIZE)
MONO_API void mono_lock_free_allocator_init_size_class (MonoLockFreeAllocSizeClass *sc, unsigned int slot_size, unsigned int block_size);
-MONO_API void mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator *heap, MonoLockFreeAllocSizeClass *sc);
+MONO_API void mono_lock_free_allocator_init_allocator (MonoLockFreeAllocator *heap, MonoLockFreeAllocSizeClass *sc, MonoMemAccountType account_type);
MONO_API gpointer mono_lock_free_alloc (MonoLockFreeAllocator *heap);
MONO_API void mono_lock_free_free (gpointer ptr, size_t block_size);
{
int size = mono_pagesize ();
int num_entries = (size - (sizeof (Chunk) - arr->entry_size * MONO_ZERO_LEN_ARRAY)) / arr->entry_size;
- Chunk *chunk = (Chunk *) mono_valloc (NULL, size, MONO_MMAP_READ | MONO_MMAP_WRITE);
+ Chunk *chunk = (Chunk *) mono_valloc (NULL, size, MONO_MMAP_READ | MONO_MMAP_WRITE, arr->account_type);
g_assert (chunk);
chunk->num_entries = num_entries;
return chunk;
}
static void
-free_chunk (Chunk *chunk)
+free_chunk (Chunk *chunk, MonoMemAccountType type)
{
- mono_vfree (chunk, mono_pagesize ());
+ mono_vfree (chunk, mono_pagesize (), type);
}
gpointer
chunk = alloc_chunk (arr);
mono_memory_write_barrier ();
if (InterlockedCompareExchangePointer ((volatile gpointer *)&arr->chunk_list, chunk, NULL) != NULL)
- free_chunk (chunk);
+ free_chunk (chunk, arr->account_type);
}
chunk = arr->chunk_list;
next = alloc_chunk (arr);
mono_memory_write_barrier ();
if (InterlockedCompareExchangePointer ((volatile gpointer *) &chunk->next, next, NULL) != NULL) {
- free_chunk (next);
+ free_chunk (next, arr->account_type);
next = chunk->next;
g_assert (next);
}
arr->chunk_list = NULL;
while (chunk) {
Chunk *next = chunk->next;
- free_chunk (chunk);
+ free_chunk (chunk, arr->account_type);
chunk = next;
}
}
#include <glib.h>
#include <mono/utils/mono-compiler.h>
+#include <mono/utils/mono-mmap.h>
typedef struct _MonoLockFreeArrayChunk MonoLockFreeArrayChunk;
typedef struct {
size_t entry_size;
MonoLockFreeArrayChunk *chunk_list;
+ MonoMemAccountType account_type;
} MonoLockFreeArray;
typedef struct {
gint32 num_used_entries;
} MonoLockFreeArrayQueue;
-#define MONO_LOCK_FREE_ARRAY_INIT(entry_size) { (entry_size), NULL }
-#define MONO_LOCK_FREE_ARRAY_QUEUE_INIT(entry_size) { MONO_LOCK_FREE_ARRAY_INIT ((entry_size) + sizeof (gpointer)), 0 }
+#define MONO_LOCK_FREE_ARRAY_INIT(entry_size, account_type) { (entry_size), NULL, (account_type) }
+#define MONO_LOCK_FREE_ARRAY_QUEUE_INIT(entry_size, account_type) { MONO_LOCK_FREE_ARRAY_INIT ((entry_size) + sizeof (gpointer), (account_type)), 0 }
gpointer mono_lock_free_array_nth (MonoLockFreeArray *arr, int index);
freelist = g_slist_delete_link (freelist, freelist);
g_hash_table_insert (valloc_freelists, GUINT_TO_POINTER (size), freelist);
} else {
- ptr = mono_valloc (preferred, size, MONO_PROT_RWX | ARCH_MAP_FLAGS);
+ ptr = mono_valloc (preferred, size, MONO_PROT_RWX | ARCH_MAP_FLAGS, MONO_MEM_ACCOUNT_CODE);
if (!ptr && preferred)
- ptr = mono_valloc (NULL, size, MONO_PROT_RWX | ARCH_MAP_FLAGS);
+ ptr = mono_valloc (NULL, size, MONO_PROT_RWX | ARCH_MAP_FLAGS, MONO_MEM_ACCOUNT_CODE);
}
mono_os_mutex_unlock (&valloc_mutex);
return ptr;
freelist = g_slist_prepend (freelist, ptr);
g_hash_table_insert (valloc_freelists, GUINT_TO_POINTER (size), freelist);
} else {
- mono_vfree (ptr, size);
+ mono_vfree (ptr, size, MONO_MEM_ACCOUNT_CODE);
}
mono_os_mutex_unlock (&valloc_mutex);
}
GSList *l;
for (l = freelist; l; l = l->next) {
- mono_vfree (l->data, GPOINTER_TO_UINT (key));
+ mono_vfree (l->data, GPOINTER_TO_UINT (key), MONO_MEM_ACCOUNT_CODE);
}
g_slist_free (freelist);
}
dlfree (dead->data);
}
code_memory_used -= dead->size;
- free (dead);
+ g_free (dead);
}
}
{
free_chunklist (cman->full);
free_chunklist (cman->current);
- free (cman);
+ g_free (cman);
}
/**
#endif
}
- chunk = (CodeChunk *) malloc (sizeof (CodeChunk));
+ chunk = (CodeChunk *) g_malloc (sizeof (CodeChunk));
if (!chunk) {
if (flags == CODE_FLAG_MALLOC)
dlfree (ptr);
else
- mono_vfree (ptr, chunk_size);
+ mono_vfree (ptr, chunk_size, MONO_MEM_ACCOUNT_CODE);
return NULL;
}
chunk->next = NULL;
mono_os_mutex_init_recursive (&mutex->m);
}
-static inline gint
+static inline void
mono_coop_mutex_destroy (MonoCoopMutex *mutex)
{
- return mono_os_mutex_destroy (&mutex->m);
+ mono_os_mutex_destroy (&mutex->m);
}
static inline void
mono_os_cond_init (&cond->c);
}
-static inline gint
+static inline void
mono_coop_cond_destroy (MonoCoopCond *cond)
{
- return mono_os_cond_destroy (&cond->c);
+ mono_os_cond_destroy (&cond->c);
}
static inline void
}
}
- counter = (MonoCounter *) malloc (sizeof (MonoCounter));
+ counter = (MonoCounter *) g_malloc (sizeof (MonoCounter));
if (!counter) {
mono_os_mutex_unlock (&counters_mutex);
return;
return mono_process_get_data (GINT_TO_POINTER (mono_process_current_pid ()), MONO_PROCESS_FAULTS);
}
+
+// If cpu_load gets inlined on Windows then cpu_load_1min, cpu_load_5min and cpu_load_15min can be folded into a single function and that will
+// cause a failure when registering counters since the same function address will be used by all three functions. Preventing this method from being inlined
+// will make sure the registered callback functions remains unique.
+#ifdef _MSC_VER
+__declspec(noinline)
+#endif
static double
cpu_load (int kind)
{
while (counter) {
MonoCounter *tmp = counter;
counter = counter->next;
- free ((void*)tmp->name);
- free (tmp);
+ g_free ((void*)tmp->name);
+ g_free (tmp);
}
mono_os_mutex_unlock (&counters_mutex);
if (error_msg)
*error_msg = NULL;
- module = (MonoDl *) malloc (sizeof (MonoDl));
+ module = (MonoDl *) g_malloc (sizeof (MonoDl));
if (!module) {
if (error_msg)
*error_msg = g_strdup ("Out of memory");
const char *ext;
/* This platform does not support dlopen */
if (name == NULL) {
- free (module);
+ g_free (module);
return NULL;
}
if (error_msg) {
*error_msg = mono_dl_current_error_string ();
}
- free (module);
+ g_free (module);
return NULL;
}
}
} else {
#if MONO_DL_NEED_USCORE
{
- char *usname = malloc (strlen (name) + 2);
+ char *usname = g_malloc (strlen (name) + 2);
*usname = '_';
strcpy (usname + 1, name);
sym = mono_dl_lookup_symbol (module, usname);
- free (usname);
+ g_free (usname);
}
#else
sym = mono_dl_lookup_symbol (module, name);
} else
mono_dl_close_handle (module);
- free (module);
+ g_free (module);
}
/**
fflush(logFile);
- if (level == G_LOG_FLAG_FATAL)
+ if (level & G_LOG_LEVEL_ERROR)
abort();
}
{
syslog (mapSyslogLevel(level), "%s", message);
- if (level == G_LOG_FLAG_FATAL)
+ if (level & G_LOG_LEVEL_ERROR)
abort();
}
fflush(logFile);
- if (level == G_LOG_FLAG_FATAL)
+ if (level & G_LOG_LEVEL_ERROR)
abort();
}
#include "mono-mmap-internals.h"
#include "mono-proclib.h"
#include <mono/utils/mono-threads.h>
+#include <mono/utils/atomic.h>
+#include <mono/utils/mono-counters.h>
#define BEGIN_CRITICAL_SECTION do { \
return aligned;
}
+static volatile size_t allocation_count [MONO_MEM_ACCOUNT_MAX];
+
+static void
+account_mem (MonoMemAccountType type, ssize_t size)
+{
+#if SIZEOF_VOID_P == 4
+ InterlockedAdd ((volatile gint32*)&allocation_count [type], (gint32)size);
+#else
+ InterlockedAdd64 ((volatile gint64*)&allocation_count [type], (gint64)size);
+#endif
+}
+
+const char*
+mono_mem_account_type_name (MonoMemAccountType type)
+{
+ static const char *names[] = {
+ "code",
+ "hazard pointers",
+ "domain",
+ "SGen internal",
+ "SGen nursery",
+ "SGen LOS",
+ "SGen mark&sweep",
+ "SGen card table",
+ "SGen shadow card table",
+ "SGen debugging",
+ "SGen binary protocol",
+ "exceptions",
+ "profiler",
+ "other"
+ };
+
+ return names [type];
+}
+
+void
+mono_mem_account_register_counters (void)
+{
+ for (int i = 0; i < MONO_MEM_ACCOUNT_MAX; ++i) {
+ const char *prefix = "Valloc ";
+ const char *name = mono_mem_account_type_name (i);
+ char descr [128];
+ g_assert (strlen (prefix) + strlen (name) < sizeof (descr));
+ sprintf (descr, "%s%s", prefix, name);
+ mono_counters_register (descr, MONO_COUNTER_WORD | MONO_COUNTER_RUNTIME | MONO_COUNTER_BYTES | MONO_COUNTER_VARIABLE, (void*)&allocation_count [i]);
+ }
+}
+
#ifdef HOST_WIN32
int
}
void*
-mono_valloc (void *addr, size_t length, int flags)
+mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
{
void *ptr;
int mflags = MEM_RESERVE|MEM_COMMIT;
/* translate the flags */
ptr = VirtualAlloc (addr, length, mflags, prot);
+
+ account_mem (type, (ssize_t)length);
+
return ptr;
}
void*
-mono_valloc_aligned (size_t length, size_t alignment, int flags)
+mono_valloc_aligned (size_t length, size_t alignment, int flags, MonoMemAccountType type)
{
int prot = prot_from_flags (flags);
char *mem = VirtualAlloc (NULL, length + alignment, MEM_RESERVE, prot);
aligned = VirtualAlloc (aligned, length, MEM_COMMIT, prot);
g_assert (aligned);
+ account_mem (type, (ssize_t)length);
+
return aligned;
}
#define HAVE_VALLOC_ALIGNED
int
-mono_vfree (void *addr, size_t length)
+mono_vfree (void *addr, size_t length, MonoMemAccountType type)
{
MEMORY_BASIC_INFORMATION mbi;
SIZE_T query_result = VirtualQuery (addr, &mbi, sizeof (mbi));
g_assert (res);
+ account_mem (type, -(ssize_t)length);
+
return 0;
}
* Returns: NULL on failure, the address of the memory area otherwise
*/
void*
-mono_valloc (void *addr, size_t length, int flags)
+mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
{
void *ptr;
int mflags = 0;
if (ptr == MAP_FAILED)
return NULL;
+
+ account_mem (type, (ssize_t)length);
+
return ptr;
}
* Returns: 0 on success.
*/
int
-mono_vfree (void *addr, size_t length)
+mono_vfree (void *addr, size_t length, MonoMemAccountType type)
{
int res;
BEGIN_CRITICAL_SECTION;
res = munmap (addr, length);
END_CRITICAL_SECTION;
+
+ account_mem (type, -(ssize_t)length);
+
return res;
}
}
void*
-mono_valloc (void *addr, size_t length, int flags)
+mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
{
- return malloc (length);
+ return g_malloc (length);
}
void*
-mono_valloc_aligned (size_t length, size_t alignment, int flags)
+mono_valloc_aligned (size_t size, size_t alignment, int flags, MonoMemAccountType type)
{
g_assert_not_reached ();
}
#define HAVE_VALLOC_ALIGNED
int
-mono_vfree (void *addr, size_t length)
+mono_vfree (void *addr, size_t length, MonoMemAccountType type)
{
- free (addr);
+ g_free (addr);
return 0;
}
#ifndef HAVE_VALLOC_ALIGNED
void*
-mono_valloc_aligned (size_t size, size_t alignment, int flags)
+mono_valloc_aligned (size_t size, size_t alignment, int flags, MonoMemAccountType type)
{
/* Allocate twice the memory to be able to put the block on an aligned address */
- char *mem = (char *) mono_valloc (NULL, size + alignment, flags);
+ char *mem = (char *) mono_valloc (NULL, size + alignment, flags, type);
char *aligned;
if (!mem)
aligned = aligned_address (mem, size, alignment);
if (aligned > mem)
- mono_vfree (mem, aligned - mem);
+ mono_vfree (mem, aligned - mem, type);
if (aligned + size < mem + size + alignment)
- mono_vfree (aligned + size, (mem + size + alignment) - (aligned + size));
+ mono_vfree (aligned + size, (mem + size + alignment) - (aligned + size), type);
return aligned;
}
MONO_MMAP_32BIT = 1 << 8
};
+typedef enum {
+ MONO_MEM_ACCOUNT_CODE,
+ MONO_MEM_ACCOUNT_HAZARD_POINTERS,
+ MONO_MEM_ACCOUNT_DOMAIN,
+ MONO_MEM_ACCOUNT_SGEN_INTERNAL,
+ MONO_MEM_ACCOUNT_SGEN_NURSERY,
+ MONO_MEM_ACCOUNT_SGEN_LOS,
+ MONO_MEM_ACCOUNT_SGEN_MARKSWEEP,
+ MONO_MEM_ACCOUNT_SGEN_CARD_TABLE,
+ MONO_MEM_ACCOUNT_SGEN_SHADOW_CARD_TABLE,
+ MONO_MEM_ACCOUNT_SGEN_DEBUGGING,
+ MONO_MEM_ACCOUNT_SGEN_BINARY_PROTOCOL,
+ MONO_MEM_ACCOUNT_EXCEPTIONS,
+ MONO_MEM_ACCOUNT_PROFILER,
+ MONO_MEM_ACCOUNT_OTHER,
+ MONO_MEM_ACCOUNT_MAX
+} MonoMemAccountType;
+
/*
* A simple interface to fopen/fstat/fileno
*/
MONO_API int mono_file_map_close (MonoFileMap *fmap);
MONO_API int mono_pagesize (void);
-MONO_API void* mono_valloc (void *addr, size_t length, int flags);
-MONO_API void* mono_valloc_aligned (size_t length, size_t alignment, int flags);
-MONO_API int mono_vfree (void *addr, size_t length);
+MONO_API void* mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type);
+MONO_API void* mono_valloc_aligned (size_t length, size_t alignment, int flags, MonoMemAccountType type);
+MONO_API int mono_vfree (void *addr, size_t length, MonoMemAccountType type);
MONO_API void* mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle);
MONO_API int mono_file_unmap (void *addr, void *handle);
#ifndef HOST_WIN32
#endif
MONO_API int mono_mprotect (void *addr, size_t length, int flags);
+MONO_API const char* mono_mem_account_type_name (MonoMemAccountType type);
+MONO_API void mono_mem_account_register_counters (void);
+
MONO_API void* mono_shared_area (void);
MONO_API void mono_shared_area_remove (void);
MONO_API void* mono_shared_area_for_pid (void *pid);
g_error ("%s: pthread_mutexattr_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
}
-static inline int
+static inline void
mono_os_mutex_destroy (mono_mutex_t *mutex)
{
int res;
res = pthread_mutex_destroy (mutex);
- if (G_UNLIKELY (res != 0 && res != EBUSY))
+ if (G_UNLIKELY (res != 0))
g_error ("%s: pthread_mutex_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
-
- return res != 0 ? -1 : 0;
}
static inline void
g_error ("%s: pthread_cond_init failed with \"%s\" (%d)", __func__, g_strerror (res), res);
}
-static inline int
+static inline void
mono_os_cond_destroy (mono_cond_t *cond)
{
int res;
res = pthread_cond_destroy (cond);
- if (G_UNLIKELY (res != 0 && res != EBUSY))
+ if (G_UNLIKELY (res != 0))
g_error ("%s: pthread_cond_destroy failed with \"%s\" (%d)", __func__, g_strerror (res), res);
-
- return res != 0 ? -1 : 0;
}
static inline void
g_error ("%s: InitializeCriticalSectionEx failed with error %d", __func__, GetLastError ());
}
-static inline int
+static inline void
mono_os_mutex_destroy (mono_mutex_t *mutex)
{
DeleteCriticalSection (mutex);
- return 0;
}
static inline void
InitializeConditionVariable (cond);
}
-static inline int
+static inline void
mono_os_cond_destroy (mono_cond_t *cond)
{
/* Beauty of win32 API: do not destroy it */
- return 0;
}
static inline void
#ifdef KERN_PROC2
int mib [6];
size_t data_len = sizeof (struct kinfo_proc2) * 400;
- struct kinfo_proc2 *processes = malloc (data_len);
+ struct kinfo_proc2 *processes = g_malloc (data_len);
#else
int mib [4];
size_t data_len = sizeof (struct kinfo_proc) * 16;
res = sysctl (mib, 6, processes, &data_len, NULL, 0);
if (res < 0) {
- free (processes);
+ g_free (processes);
return NULL;
}
#else
res = sysctl (mib, 4, NULL, &data_len, NULL, 0);
if (res)
return NULL;
- processes = (struct kinfo_proc *) malloc (data_len);
+ processes = (struct kinfo_proc *) g_malloc (data_len);
res = sysctl (mib, 4, processes, &data_len, NULL, 0);
if (res < 0) {
- free (processes);
+ g_free (processes);
if (errno != ENOMEM)
return NULL;
limit --;
buf = (void **) g_realloc (buf, res * sizeof (void*));
for (i = 0; i < res; ++i)
buf [i] = GINT_TO_POINTER (processes [i].kinfo_pid_member);
- free (processes);
+ g_free (processes);
if (size)
*size = res;
return buf;
{
gpointer thread_handle;
- info->owned_mutexes = g_ptr_array_new ();
- info->priority = MONO_THREAD_PRIORITY_NORMAL;
-
thread_handle = mono_w32handle_new (MONO_W32HANDLE_THREAD, NULL);
if (thread_handle == INVALID_HANDLE_VALUE)
g_error ("%s: failed to create handle", __func__);
- /* We need to keep the handle alive, as long as the corresponding managed
- * thread object is alive. The handle is going to be unref when calling
- * the finalizer on the MonoThreadInternal object */
- mono_w32handle_ref (thread_handle);
-
g_assert (!info->handle);
info->handle = thread_handle;
}
{
pthread_attr_t attr;
pthread_t thread;
+ int policy;
+ struct sched_param param;
gint res;
res = pthread_attr_init (&attr);
g_assert (!res);
#endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */
+ memset (¶m, 0, sizeof (param));
+
+ res = pthread_attr_getschedpolicy (&attr, &policy);
+ if (res != 0)
+ g_error ("%s: pthread_attr_getschedpolicy failed, error: \"%s\" (%d)", g_strerror (res), res);
+
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ int max, min;
+
+ /* Necessary to get valid priority range */
+
+ min = sched_get_priority_min (policy);
+ max = sched_get_priority_max (policy);
+
+ if (max > 0 && min >= 0 && max > min)
+ param.sched_priority = (max - min) / 2 + min;
+ else
+#endif
+ {
+ switch (policy) {
+ case SCHED_FIFO:
+ case SCHED_RR:
+ param.sched_priority = 50;
+ break;
+#ifdef SCHED_BATCH
+ case SCHED_BATCH:
+#endif
+ case SCHED_OTHER:
+ param.sched_priority = 0;
+ break;
+ default:
+ g_error ("%s: unknown policy %d", __func__, policy);
+ }
+ }
+
+ res = pthread_attr_setschedparam (&attr, ¶m);
+ if (res != 0)
+ g_error ("%s: pthread_attr_setschedparam failed, error: \"%s\" (%d)", g_strerror (res), res);
+
/* Actually start the thread */
res = mono_gc_pthread_create (&thread, &attr, (gpointer (*)(gpointer)) thread_fn, thread_data);
if (res)
return (int)lim.rlim_max;
}
+gpointer
+mono_threads_platform_duplicate_handle (MonoThreadInfo *info)
+{
+ g_assert (info->handle);
+ mono_w32handle_ref (info->handle);
+ return info->handle;
+}
+
HANDLE
mono_threads_platform_open_thread_handle (HANDLE handle, MonoNativeThreadId tid)
{
void
mono_threads_platform_set_exited (MonoThreadInfo *info)
{
- gpointer mutex_handle;
- int i, thr_ret;
- pid_t pid;
- pthread_t tid;
+ int thr_ret;
g_assert (info->handle);
-
if (mono_w32handle_issignalled (info->handle))
g_error ("%s: handle %p thread %p has already exited, it's handle is signalled", __func__, info->handle, mono_thread_info_get_tid (info));
if (mono_w32handle_get_type (info->handle) == MONO_W32HANDLE_UNUSED)
g_error ("%s: handle %p thread %p has already exited, it's handle type is 'unused'", __func__, info->handle, mono_thread_info_get_tid (info));
- pid = wapi_getpid ();
- tid = pthread_self ();
-
- for (i = 0; i < info->owned_mutexes->len; i++) {
- mutex_handle = g_ptr_array_index (info->owned_mutexes, i);
- wapi_mutex_abandon (mutex_handle, pid, tid);
- mono_thread_info_disown_mutex (info, mutex_handle);
- }
-
- g_ptr_array_free (info->owned_mutexes, TRUE);
-
thr_ret = mono_w32handle_lock_handle (info->handle);
g_assert (thr_ret == 0);
info->handle = NULL;
}
-void
-mono_threads_platform_describe (MonoThreadInfo *info, GString *text)
-{
- int i;
-
- g_string_append_printf (text, "thread handle %p state : ", info->handle);
-
- mono_thread_info_describe_interrupt_token (info, text);
-
- g_string_append_printf (text, ", owns (");
- for (i = 0; i < info->owned_mutexes->len; i++)
- g_string_append_printf (text, i > 0 ? ", %p" : "%p", g_ptr_array_index (info->owned_mutexes, i));
- g_string_append_printf (text, ")");
-}
-
-void
-mono_threads_platform_own_mutex (MonoThreadInfo *info, gpointer mutex_handle)
-{
- mono_w32handle_ref (mutex_handle);
-
- g_ptr_array_add (info->owned_mutexes, mutex_handle);
-}
-
-void
-mono_threads_platform_disown_mutex (MonoThreadInfo *info, gpointer mutex_handle)
-{
- mono_w32handle_unref (mutex_handle);
-
- g_ptr_array_remove (info->owned_mutexes, mutex_handle);
-}
-
-MonoThreadPriority
-mono_threads_platform_get_priority (MonoThreadInfo *info)
-{
- return info->priority;
-}
-
-void
-mono_threads_platform_set_priority (MonoThreadInfo *info, MonoThreadPriority priority)
-{
- int policy;
- struct sched_param param;
- pthread_t tid;
- gint res;
-
- g_assert (priority >= MONO_THREAD_PRIORITY_LOWEST);
- g_assert (priority <= MONO_THREAD_PRIORITY_HIGHEST);
- g_assert (MONO_THREAD_PRIORITY_LOWEST < MONO_THREAD_PRIORITY_HIGHEST);
-
- tid = mono_thread_info_get_tid (info);
-
- res = pthread_getschedparam (tid, &policy, ¶m);
- if (res != 0)
- g_error ("%s: pthread_getschedparam failed, error: \"%s\" (%d)", g_strerror (res), res);
-
-#ifdef _POSIX_PRIORITY_SCHEDULING
- int max, min;
-
- /* Necessary to get valid priority range */
-
- min = sched_get_priority_min (policy);
- max = sched_get_priority_max (policy);
-
- if (max > 0 && min >= 0 && max > min) {
- double srange, drange, sposition, dposition;
- srange = MONO_THREAD_PRIORITY_HIGHEST - MONO_THREAD_PRIORITY_LOWEST;
- drange = max - min;
- sposition = priority - MONO_THREAD_PRIORITY_LOWEST;
- dposition = (sposition / srange) * drange;
- param.sched_priority = (int)(dposition + min);
- } else
-#endif
- {
- switch (policy) {
- case SCHED_FIFO:
- case SCHED_RR:
- param.sched_priority = 50;
- break;
-#ifdef SCHED_BATCH
- case SCHED_BATCH:
-#endif
- case SCHED_OTHER:
- param.sched_priority = 0;
- break;
- default:
- g_error ("%s: unknown policy %d", __func__, policy);
- }
- }
-
- res = pthread_setschedparam (tid, policy, ¶m);
- if (res != 0) {
- if (res == EPERM) {
- g_warning ("%s: pthread_setschedparam failed, error: \"%s\" (%d)", g_strerror (res), res);
- return;
- }
- g_error ("%s: pthread_setschedparam failed, error: \"%s\" (%d)", g_strerror (res), res);
- }
-
- info->priority = priority;
-}
-
static const gchar* thread_typename (void)
{
return "Thread";
return INT_MAX;
}
+gpointer
+mono_threads_platform_duplicate_handle (MonoThreadInfo *info)
+{
+ HANDLE thread_handle;
+
+ g_assert (info->handle);
+ DuplicateHandle (GetCurrentProcess (), info->handle, GetCurrentProcess (), &thread_handle, THREAD_ALL_ACCESS, TRUE, 0);
+
+ return thread_handle;
+}
+
HANDLE
mono_threads_platform_open_thread_handle (HANDLE handle, MonoNativeThreadId tid)
{
info->handle = NULL;
}
-void
-mono_threads_platform_describe (MonoThreadInfo *info, GString *text)
-{
- /* TODO */
-}
-
-void
-mono_threads_platform_own_mutex (MonoThreadInfo *info, gpointer mutex_handle)
-{
- g_assert_not_reached ();
-}
-
-void
-mono_threads_platform_disown_mutex (MonoThreadInfo *info, gpointer mutex_handle)
-{
- g_assert_not_reached ();
-}
-
-MonoThreadPriority
-mono_threads_platform_get_priority (MonoThreadInfo *info)
-{
- g_assert (info->handle);
- return GetThreadPriority (info->handle) + 2;
-}
-
-void
-mono_threads_platform_set_priority (MonoThreadInfo *info, MonoThreadPriority priority)
-{
- BOOL res;
-
- g_assert (info->handle);
-
- res = SetThreadPriority (info->handle, priority - 2);
- if (!res)
- g_error ("%s: SetThreadPriority failed, error %d", __func__, GetLastError ());
-}
-
void
mono_threads_platform_init (void)
{
gpointer start_routine_arg;
gint32 priority;
MonoCoopSem registered;
- MonoThreadInfo *info;
+ gpointer handle;
} CreateThreadData;
static gsize WINAPI
MonoThreadStart start_routine;
gpointer start_routine_arg;
guint32 start_routine_res;
- gint32 priority;
gsize dummy;
thread_data = (CreateThreadData*) data;
start_routine = thread_data->start_routine;
start_routine_arg = thread_data->start_routine_arg;
- priority = thread_data->priority;
-
info = mono_thread_info_attach (&dummy);
info->runtime_thread = TRUE;
- mono_threads_platform_set_priority (info, priority);
-
- thread_data->info = info;
+ thread_data->handle = mono_thread_info_duplicate_handle (info);
mono_coop_sem_post (&thread_data->registered);
* Returns: a windows or io-layer handle for the thread.
*/
HANDLE
-mono_threads_create_thread (MonoThreadStart start, gpointer arg, MonoThreadParm *tp, MonoNativeThreadId *out_tid)
+mono_threads_create_thread (MonoThreadStart start, gpointer arg, gsize stack_size, MonoNativeThreadId *out_tid)
{
CreateThreadData *thread_data;
- MonoThreadInfo *info;
gint res;
gpointer ret;
thread_data->ref = 2;
thread_data->start_routine = start;
thread_data->start_routine_arg = arg;
- thread_data->priority = tp->priority;
mono_coop_sem_init (&thread_data->registered, 0);
- res = mono_threads_platform_create_thread (inner_start_thread, (gpointer) thread_data, tp->stack_size, out_tid);
+ res = mono_threads_platform_create_thread (inner_start_thread, (gpointer) thread_data, stack_size, out_tid);
if (res != 0) {
/* ref is not going to be decremented in inner_start_thread */
InterlockedDecrement (&thread_data->ref);
res = mono_coop_sem_wait (&thread_data->registered, MONO_SEM_FLAGS_NONE);
g_assert (res == 0);
- info = thread_data->info;
- g_assert (info);
-
- ret = info->handle;
+ ret = thread_data->handle;
g_assert (ret);
done:
*alerted = FALSE;
if (ms != INFINITE)
- end = mono_100ns_ticks () + (ms * 1000 * 10);
+ end = mono_msec_ticks() + ms;
mono_lazy_initialize (&sleep_init, sleep_initialize);
for (;;) {
if (ms != INFINITE) {
- now = mono_100ns_ticks ();
- if (now > end)
+ now = mono_msec_ticks();
+ if (now >= end)
break;
}
}
if (ms != INFINITE)
- mono_coop_cond_timedwait (&sleep_cond, &sleep_mutex, (end - now) / 10 / 1000);
+ mono_coop_cond_timedwait (&sleep_cond, &sleep_mutex, end - now);
else
mono_coop_cond_wait (&sleep_cond, &sleep_mutex);
}
gpointer
-mono_thread_info_get_handle (THREAD_INFO_TYPE *info)
+mono_thread_info_duplicate_handle (MonoThreadInfo *info)
{
- g_assert (info->handle);
- return info->handle;
-}
-
-void
-mono_thread_info_describe (MonoThreadInfo *info, GString *text)
-{
- mono_threads_platform_describe (info, text);
-}
-
-void
-mono_thread_info_own_mutex (MonoThreadInfo *info, gpointer mutex_handle)
-{
- mono_threads_platform_own_mutex (info, mutex_handle);
-}
-
-void
-mono_thread_info_disown_mutex (MonoThreadInfo *info, gpointer mutex_handle)
-{
- mono_threads_platform_disown_mutex (info, mutex_handle);
-}
-
-MonoThreadPriority
-mono_thread_info_get_priority (MonoThreadInfo *info)
-{
- return mono_threads_platform_get_priority (info);
-}
-
-void
-mono_thread_info_set_priority (MonoThreadInfo *info, MonoThreadPriority priority)
-{
- mono_threads_platform_set_priority (info, priority);
+ g_assert (mono_thread_info_is_current (info));
+ return mono_threads_platform_duplicate_handle (info);
}
/* Stack mark for targets that explicitly require one */
gpointer stack_mark;
-
-#if defined(_POSIX_VERSION) || defined(__native_client__)
- /* This is the data that was stored in the w32 handle */
- GPtrArray *owned_mutexes;
- gint32 priority;
-#endif
} MonoThreadInfo;
typedef struct {
typedef SuspendThreadResult (*MonoSuspendThreadCallback) (THREAD_INFO_TYPE *info, gpointer user_data);
-/*
- * Parameters to pass for thread creation
- */
-typedef struct {
- int priority;
- guint32 creation_flags;
- guint32 stack_size;
-} MonoThreadParm;
-
-typedef enum {
- MONO_THREAD_PRIORITY_LOWEST = 0,
- MONO_THREAD_PRIORITY_BELOW_NORMAL = 1,
- MONO_THREAD_PRIORITY_NORMAL = 2,
- MONO_THREAD_PRIORITY_ABOVE_NORMAL = 3,
- MONO_THREAD_PRIORITY_HIGHEST = 4,
-} MonoThreadPriority;
-
static inline gboolean
mono_threads_filter_tools_threads (THREAD_INFO_TYPE *info)
{
mono_thread_info_is_live (THREAD_INFO_TYPE *info);
HANDLE
-mono_threads_create_thread (MonoThreadStart start, gpointer arg, MonoThreadParm *tp, MonoNativeThreadId *out_tid);
+mono_threads_create_thread (MonoThreadStart start, gpointer arg, gsize stack_size, MonoNativeThreadId *out_tid);
int
mono_threads_get_max_stack_size (void);
HANDLE mono_threads_platform_open_thread_handle (HANDLE handle, MonoNativeThreadId tid);
void mono_threads_platform_close_thread_handle (HANDLE handle);
void mono_threads_platform_set_exited (THREAD_INFO_TYPE *info);
-void mono_threads_platform_describe (THREAD_INFO_TYPE *info, GString *text);
-void mono_threads_platform_own_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);
-void mono_threads_platform_disown_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);
-MonoThreadPriority mono_threads_platform_get_priority (THREAD_INFO_TYPE *info);
-void mono_threads_platform_set_priority (THREAD_INFO_TYPE *info, MonoThreadPriority priority);
+gpointer mono_threads_platform_duplicate_handle (THREAD_INFO_TYPE *info);
void mono_threads_coop_begin_global_suspend (void);
void mono_threads_coop_end_global_suspend (void);
mono_thread_info_is_current (THREAD_INFO_TYPE *info);
gpointer
-mono_thread_info_get_handle (THREAD_INFO_TYPE *info);
-
-void
-mono_thread_info_describe (THREAD_INFO_TYPE *info, GString *text);
-
-void
-mono_thread_info_own_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);
-
-void
-mono_thread_info_disown_mutex (THREAD_INFO_TYPE *info, gpointer mutex_handle);
-
-MonoThreadPriority
-mono_thread_info_get_priority (THREAD_INFO_TYPE *info);
-
-void
-mono_thread_info_set_priority (THREAD_INFO_TYPE *info, MonoThreadPriority priority);
+mono_thread_info_duplicate_handle (THREAD_INFO_TYPE *info);
#endif /* __MONO_THREADS_H__ */
#if TEST
int main ()
{
- char *s = malloc (256);
+ char *s = g_malloc (256);
int i = 0;
s [255] = 0;
initialized = TRUE;
}
-static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_busy_handles);
-
void
mono_w32handle_cleanup (void)
{
gpointer handle = GINT_TO_POINTER (i*HANDLE_PER_SLOT+j);
for(k = handle_data->ref; k > 0; k--) {
- mono_w32handle_unref_full (handle, TRUE);
+ mono_w32handle_unref (handle);
}
}
}
static void mono_w32handle_init_handle (MonoW32HandleBase *handle,
MonoW32HandleType type, gpointer handle_specific)
{
+ g_assert (handle->ref == 0);
+
handle->type = type;
handle->signalled = FALSE;
handle->ref = 1;
g_assert (!shutting_down);
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Creating new handle of type %s", __func__,
- mono_w32handle_ops_typename (type));
-
g_assert(!type_is_fd(type));
mono_os_mutex_lock (&scan_mutex);
if (handle_idx == 0) {
/* We ran out of slots */
handle = INVALID_HANDLE_VALUE;
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to create %s handle", __func__, mono_w32handle_ops_typename (type));
goto done;
}
handle = GUINT_TO_POINTER (handle_idx);
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Allocated new handle %p", __func__, handle);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: create %s handle %p", __func__, mono_w32handle_ops_typename (type), handle);
done:
return(handle);
g_assert (!shutting_down);
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Creating new handle of type %s", __func__,
- mono_w32handle_ops_typename (type));
-
g_assert(type_is_fd(type));
if (fd >= mono_w32handle_fd_reserve) {
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: fd %d is too big", __func__, fd);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to create %s handle, fd is too big", __func__, mono_w32handle_ops_typename (type));
return(GUINT_TO_POINTER (INVALID_HANDLE_VALUE));
}
handle_data = &private_handles [fd_index][fd_offset];
if (handle_data->type != MONO_W32HANDLE_UNUSED) {
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: fd %d is already in use!", __func__, fd);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to create %s handle, fd is already in use", __func__, mono_w32handle_ops_typename (type));
/* FIXME: clean up this handle? We can't do anything
* with the fd, cos thats the new one
*/
+ return(GUINT_TO_POINTER (INVALID_HANDLE_VALUE));
}
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Assigning new fd handle %p", __func__, (gpointer)(gsize)fd);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: create %s handle %p", __func__, mono_w32handle_ops_typename (type), GUINT_TO_POINTER(fd));
mono_w32handle_init_handle (handle_data, type, handle_specific);
return(TRUE);
}
+static gboolean
+mono_w32handle_ref_core (gpointer handle, MonoW32HandleBase *handle_data);
+
+static gboolean
+mono_w32handle_unref_core (gpointer handle, MonoW32HandleBase *handle_data, guint minimum);
+
void
mono_w32handle_foreach (gboolean (*on_each)(gpointer handle, gpointer data, gpointer user_data), gpointer user_data)
{
- MonoW32HandleBase *handle_data = NULL;
- gpointer handle;
guint32 i, k;
mono_os_mutex_lock (&scan_mutex);
for (i = SLOT_INDEX (0); i < private_handles_slots_count; i++) {
- if (private_handles [i]) {
- for (k = SLOT_OFFSET (0); k < HANDLE_PER_SLOT; k++) {
- handle_data = &private_handles [i][k];
- if (handle_data->type == MONO_W32HANDLE_UNUSED)
- continue;
- handle = GUINT_TO_POINTER (i * HANDLE_PER_SLOT + k);
- if (on_each (handle, handle_data->specific, user_data) == TRUE)
- goto done;
+ if (!private_handles [i])
+ continue;
+ for (k = SLOT_OFFSET (0); k < HANDLE_PER_SLOT; k++) {
+ MonoW32HandleBase *handle_data = NULL;
+ gpointer handle;
+ gboolean destroy, finished;
+
+ handle_data = &private_handles [i][k];
+ if (handle_data->type == MONO_W32HANDLE_UNUSED)
+ continue;
+
+ handle = GUINT_TO_POINTER (i * HANDLE_PER_SLOT + k);
+
+ if (!mono_w32handle_ref_core (handle, handle_data)) {
+ /* we are racing with mono_w32handle_unref:
+ * the handle ref has been decremented, but it
+ * hasn't yet been destroyed. */
+ continue;
}
+
+ finished = on_each (handle, handle_data->specific, user_data);
+
+ /* we do not want to have to destroy the handle here,
+ * as it would means the ref/unref are unbalanced */
+ destroy = mono_w32handle_unref_core (handle, handle_data, 2);
+ g_assert (!destroy);
+
+ if (finished)
+ goto done;
}
}
mono_os_mutex_unlock (&scan_mutex);
}
+typedef struct {
+ MonoW32HandleType type;
+ gboolean (*search_user_callback)(gpointer handle, gpointer data);
+ gpointer search_user_data;
+ gpointer handle;
+ gpointer handle_specific;
+} SearchData;
+
+static gboolean
+search_callback (gpointer handle, gpointer handle_specific, gpointer user_data)
+{
+ SearchData *search_data = (SearchData*) user_data;
+
+ if (search_data->type != mono_w32handle_get_type (handle))
+ return FALSE;
+
+ if (!search_data->search_user_callback (handle, search_data->search_user_data))
+ return FALSE;
+
+ mono_w32handle_ref (handle);
+ search_data->handle = handle;
+ search_data->handle_specific = handle_specific;
+ return TRUE;
+}
+
/* This might list some shared handles twice if they are already
* opened by this process, and the check function returns FALSE the
* first time. Shared handles that are created during the search are
gpointer *handle_specific,
gboolean search_shared)
{
- MonoW32HandleBase *handle_data = NULL;
- gpointer ret = NULL;
- guint32 i, k;
- gboolean found = FALSE;
+ SearchData search_data;
- mono_os_mutex_lock (&scan_mutex);
+ memset (&search_data, 0, sizeof (search_data));
+ search_data.type = type;
+ search_data.search_user_callback = check;
+ search_data.search_user_data = user_data;
+ mono_w32handle_foreach (search_callback, &search_data);
+ if (handle_specific)
+ *handle_specific = search_data.handle_specific;
+ return search_data.handle;
+}
- for (i = SLOT_INDEX (0); !found && i < private_handles_slots_count; i++) {
- if (private_handles [i]) {
- for (k = SLOT_OFFSET (0); k < HANDLE_PER_SLOT; k++) {
- handle_data = &private_handles [i][k];
-
- if (handle_data->type == type) {
- ret = GUINT_TO_POINTER (i * HANDLE_PER_SLOT + k);
- if (check (ret, user_data) == TRUE) {
- mono_w32handle_ref (ret);
- found = TRUE;
- break;
- }
- }
- }
- }
- }
+static gboolean
+mono_w32handle_ref_core (gpointer handle, MonoW32HandleBase *handle_data)
+{
+ guint old, new;
- mono_os_mutex_unlock (&scan_mutex);
+ do {
+ old = handle_data->ref;
+ if (old == 0)
+ return FALSE;
- if (!found) {
- ret = NULL;
- goto done;
- }
+ new = old + 1;
+ } while (InterlockedCompareExchange ((gint32*) &handle_data->ref, new, old) != old);
- if(handle_specific != NULL) {
- *handle_specific = handle_data->specific;
- }
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: ref %s handle %p, ref: %d -> %d",
+ __func__, mono_w32handle_ops_typename (handle_data->type), handle, old, new);
-done:
- return(ret);
+ return TRUE;
+}
+
+static gboolean
+mono_w32handle_unref_core (gpointer handle, MonoW32HandleBase *handle_data, guint minimum)
+{
+ MonoW32HandleType type;
+ guint old, new;
+
+ type = handle_data->type;
+
+ do {
+ old = handle_data->ref;
+ if (!(old >= minimum))
+ g_error ("%s: handle %p has ref %d, it should be >= %d", __func__, handle, old, minimum);
+
+ new = old - 1;
+ } while (InterlockedCompareExchange ((gint32*) &handle_data->ref, new, old) != old);
+
+ /* handle_data might contain invalid data from now on, if
+ * another thread is unref'ing this handle at the same time */
+
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: unref %s handle %p, ref: %d -> %d destroy: %s",
+ __func__, mono_w32handle_ops_typename (type), handle, old, new, new == 0 ? "true" : "false");
+
+ return new == 0;
}
void mono_w32handle_ref (gpointer handle)
MonoW32HandleBase *handle_data;
if (!mono_w32handle_lookup_data (handle, &handle_data)) {
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Attempting to ref invalid private handle %p", __func__, handle);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to ref handle %p, unknown handle", __func__, handle);
return;
}
- InterlockedIncrement ((gint32 *)&handle_data->ref);
-
-#ifdef DEBUG_REFS
- g_message ("%s: %s handle %p ref now %d",
- __func__, mono_w32handle_ops_typename (handle_data->type), handle, handle_data->ref);
-#endif
+ if (!mono_w32handle_ref_core (handle, handle_data))
+ g_error ("%s: failed to ref handle %p", __func__, handle);
}
static void (*_wapi_handle_ops_get_close_func (MonoW32HandleType type))(gpointer, gpointer);
/* The handle must not be locked on entry to this function */
-static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_busy_handles)
+void
+mono_w32handle_unref (gpointer handle)
{
MonoW32HandleBase *handle_data;
- gboolean destroy = FALSE, early_exit = FALSE;
- int thr_ret;
+ gboolean destroy;
if (!mono_w32handle_lookup_data (handle, &handle_data)) {
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Attempting to unref invalid private handle %p",
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: failed to unref handle %p, unknown handle",
__func__, handle);
return;
}
- /* Possible race condition here if another thread refs the
- * handle between here and setting the type to UNUSED. I
- * could lock a mutex, but I'm not sure that allowing a handle
- * reference to reach 0 isn't an application bug anyway.
- */
- destroy = (InterlockedDecrement ((gint32 *)&handle_data->ref) ==0);
-
-#ifdef DEBUG_REFS
- g_message ("%s: %s handle %p ref now %d (destroy %s)",
- __func__, mono_w32handle_ops_typename (handle_data->type), handle, handle_data->ref, destroy?"TRUE":"FALSE");
-#endif
+ destroy = mono_w32handle_unref_core (handle, handle_data, 1);
- if(destroy==TRUE) {
+ if (destroy) {
/* Need to copy the handle info, reset the slot in the
* array, and _only then_ call the close function to
* avoid race conditions (eg file descriptors being
mono_os_mutex_lock (&scan_mutex);
- mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: Destroying handle %p", __func__, handle);
+ mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: destroy %s handle %p", __func__, mono_w32handle_ops_typename (type), handle);
- /* Destroy the mutex and cond var. We hope nobody
- * tried to grab them between the handle unlock and
- * now, but pthreads doesn't have a
- * "unlock_and_destroy" atomic function.
- */
- thr_ret = mono_os_mutex_destroy (&handle_data->signal_mutex);
- /*WARNING gross hack to make cleanup not crash when exiting without the whole runtime teardown.*/
- if (thr_ret == EBUSY && ignore_private_busy_handles) {
- early_exit = TRUE;
- } else {
- if (thr_ret != 0)
- g_error ("Error destroying handle %p mutex due to %d\n", handle, thr_ret);
-
- thr_ret = mono_os_cond_destroy (&handle_data->signal_cond);
- if (thr_ret == EBUSY && ignore_private_busy_handles)
- early_exit = TRUE;
- else if (thr_ret != 0)
- g_error ("Error destroying handle %p cond var due to %d\n", handle, thr_ret);
- }
+ mono_os_mutex_destroy (&handle_data->signal_mutex);
+ mono_os_cond_destroy (&handle_data->signal_cond);
memset (handle_data, 0, sizeof (MonoW32HandleBase));
mono_os_mutex_unlock (&scan_mutex);
- if (early_exit)
- return;
-
close_func = _wapi_handle_ops_get_close_func (type);
if (close_func != NULL) {
close_func (handle, handle_specific);
}
}
-void mono_w32handle_unref (gpointer handle)
-{
- mono_w32handle_unref_full (handle, FALSE);
-}
-
void
mono_w32handle_register_ops (MonoW32HandleType type, MonoW32HandleOps *ops)
{
}
}
-gboolean mono_w32handle_ops_own (gpointer handle)
+gboolean mono_w32handle_ops_own (gpointer handle, guint32 *statuscode)
{
MonoW32HandleBase *handle_data;
MonoW32HandleType type;
type = handle_data->type;
if (handle_ops[type] != NULL && handle_ops[type]->own_handle != NULL) {
- return(handle_ops[type]->own_handle (handle));
+ return(handle_ops[type]->own_handle (handle, statuscode));
} else {
return(FALSE);
}
return res;
}
-void mono_w32handle_dump (void)
+static gboolean
+dump_callback (gpointer handle, gpointer handle_specific, gpointer user_data)
{
MonoW32HandleBase *handle_data;
- guint32 i, k;
-
- mono_os_mutex_lock (&scan_mutex);
- for(i = SLOT_INDEX (0); i < private_handles_slots_count; i++) {
- if (private_handles [i]) {
- for (k = SLOT_OFFSET (0); k < HANDLE_PER_SLOT; k++) {
- handle_data = &private_handles [i][k];
+ if (!mono_w32handle_lookup_data (handle, &handle_data))
+ g_error ("cannot dump unknown handle %p", handle);
- if (handle_data->type == MONO_W32HANDLE_UNUSED) {
- continue;
- }
+ g_print ("%p [%7s] signalled: %5s ref: %3d ",
+ handle, mono_w32handle_ops_typename (handle_data->type), handle_data->signalled ? "true" : "false", handle_data->ref);
+ mono_w32handle_ops_details (handle_data->type, handle_data->specific);
+ g_print ("\n");
- g_print ("%3x [%7s] %s %d ",
- i * HANDLE_PER_SLOT + k,
- mono_w32handle_ops_typename (handle_data->type),
- handle_data->signalled?"Sg":"Un",
- handle_data->ref);
- mono_w32handle_ops_details (handle_data->type, handle_data->specific);
- g_print ("\n");
- }
- }
- }
+ return FALSE;
+}
- mono_os_mutex_unlock (&scan_mutex);
+void mono_w32handle_dump (void)
+{
+ mono_w32handle_foreach (dump_callback, NULL);
}
static gboolean
-own_if_signalled (gpointer handle)
+own_if_signalled (gpointer handle, guint32 *statuscode)
{
if (!mono_w32handle_issignalled (handle))
return FALSE;
- mono_w32handle_ops_own (handle);
+ *statuscode = WAIT_OBJECT_0;
+ mono_w32handle_ops_own (handle, statuscode);
return TRUE;
}
static gboolean
-own_if_owned( gpointer handle)
+own_if_owned( gpointer handle, guint32 *statuscode)
{
if (!mono_w32handle_ops_isowned (handle))
return FALSE;
- mono_w32handle_ops_own (handle);
+ *statuscode = WAIT_OBJECT_0;
+ mono_w32handle_ops_own (handle, statuscode);
return TRUE;
}
gboolean alerted;
gint64 start;
gint thr_ret;
+ guint32 statuscode = 0;
alerted = FALSE;
case WAIT_OBJECT_0:
ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
break;
+ case WAIT_ABANDONED_0:
+ ret = MONO_W32HANDLE_WAIT_RET_ABANDONED_0;
+ break;
case WAIT_IO_COMPLETION:
ret = MONO_W32HANDLE_WAIT_RET_ALERTED;
break;
g_assert (thr_ret == 0);
if (mono_w32handle_test_capabilities (handle, MONO_W32HANDLE_CAP_OWN)) {
- if (own_if_owned (handle)) {
+ if (own_if_owned (handle, &statuscode)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p already owned",
__func__, handle);
- ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+ ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
goto done;
}
}
for (;;) {
gint waited;
- if (own_if_signalled (handle)) {
+ if (own_if_signalled (handle, &statuscode)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p signalled",
__func__, handle);
- ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+ ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
goto done;
}
gint i, thr_ret;
gint64 start;
gpointer handles_sorted [MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS];
+ guint32 statuscodes [MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS] = {0};
if (nhandles == 0)
return MONO_W32HANDLE_WAIT_RET_FAILED;
if (signalled) {
for (i = 0; i < nhandles; i++)
- own_if_signalled (handles [i]);
+ own_if_signalled (handles [i], &statuscodes [i]);
}
mono_w32handle_unlock_handles (handles, nhandles);
if (signalled) {
ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + lowest;
+ for (i = lowest; i < nhandles; i++) {
+ if (statuscodes [i] == WAIT_ABANDONED_0) {
+ ret = MONO_W32HANDLE_WAIT_RET_ABANDONED_0 + lowest;
+ break;
+ }
+ }
goto done;
}
gint64 start;
gboolean alerted;
gint thr_ret;
+ guint32 statuscode = 0;
alerted = FALSE;
mono_w32handle_ops_signal (signal_handle);
if (mono_w32handle_test_capabilities (wait_handle, MONO_W32HANDLE_CAP_OWN)) {
- if (own_if_owned (wait_handle)) {
+ if (own_if_owned (wait_handle, &statuscode)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p already owned",
__func__, wait_handle);
- ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+ ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
goto done;
}
}
for (;;) {
gint waited;
- if (own_if_signalled (wait_handle)) {
+ if (own_if_signalled (wait_handle, &statuscode)) {
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_W32HANDLE, "%s: handle %p signalled",
__func__, wait_handle);
- ret = MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
+ ret = statuscode == WAIT_ABANDONED_0 ? MONO_W32HANDLE_WAIT_RET_ABANDONED_0 : MONO_W32HANDLE_WAIT_RET_SUCCESS_0;
goto done;
}
/* Called by WaitForSingleObject and WaitForMultipleObjects,
* with the handle locked (shared handles aren't locked.)
* Returns TRUE if ownership was established, false otherwise.
+ * If TRUE, *statuscode contains a status code such as
+ * WAIT_OBJECT_0 or WAIT_ABANDONED_0.
*/
- gboolean (*own_handle)(gpointer handle);
+ gboolean (*own_handle)(gpointer handle, guint32 *statuscode);
/* Called by WaitForSingleObject and WaitForMultipleObjects, if the
* handle in question is "ownable" (ie mutexes), to see if the current
mono_w32handle_ops_signal (gpointer handle);
gboolean
-mono_w32handle_ops_own (gpointer handle);
+mono_w32handle_ops_own (gpointer handle, guint32 *statuscode);
gboolean
mono_w32handle_ops_isowned (gpointer handle);
mono_w32handle_unlock_handle (gpointer handle);
typedef enum {
- MONO_W32HANDLE_WAIT_RET_SUCCESS_0 = 0,
- MONO_W32HANDLE_WAIT_RET_ALERTED = -1,
- MONO_W32HANDLE_WAIT_RET_TIMEOUT = -2,
- MONO_W32HANDLE_WAIT_RET_FAILED = -3,
+ MONO_W32HANDLE_WAIT_RET_SUCCESS_0 = 0,
+ MONO_W32HANDLE_WAIT_RET_ABANDONED_0 = MONO_W32HANDLE_WAIT_RET_SUCCESS_0 + MONO_W32HANDLE_MAXIMUM_WAIT_OBJECTS,
+ MONO_W32HANDLE_WAIT_RET_ALERTED = -1,
+ MONO_W32HANDLE_WAIT_RET_TIMEOUT = -2,
+ MONO_W32HANDLE_WAIT_RET_FAILED = -3,
} MonoW32HandleWaitRet;
MonoW32HandleWaitRet
<ClCompile Include="..\mono\metadata\class.c" />\r
<ClCompile Include="..\mono\metadata\cominterop.c" />\r
<ClCompile Include="..\mono\metadata\console-win32.c" />\r
+ <ClCompile Include="..\mono\metadata\w32mutex-win32.c" />\r
+ <ClCompile Include="..\mono\metadata\w32semaphore-win32.c" />\r
+ <ClCompile Include="..\mono\metadata\w32event-win32.c" />\r
<ClCompile Include="..\mono\metadata\coree.c" />\r
<ClCompile Include="..\mono\metadata\custom-attrs.c" />\r
<ClCompile Include="..\mono\metadata\debug-helpers.c" />\r
<ClCompile Include="..\mono\metadata\console-win32.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\mono\metadata\w32mutex-win32.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\mono\metadata\w32semaphore-win32.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\mono\metadata\w32event-win32.c">\r
+ <Filter>Source Files</Filter>\r
+ </ClCompile>\r
<ClCompile Include="..\mono\metadata\coree.c">\r
<Filter>Source Files</Filter>\r
</ClCompile>\r
mono_disasm_code_one
mono_dl_fallback_register
mono_dl_fallback_unregister
+mono_dl_open
mono_dllmap_insert
mono_domain_add_class_static_data
mono_domain_assembly_open
mono_ldtoken
mono_load_remote_field
mono_load_remote_field_new
+mono_loader_register_module
mono_lock_free_alloc
mono_lock_free_allocator_check_consistency
mono_lock_free_allocator_init_allocator
mono_disasm_code_one
mono_dl_fallback_register
mono_dl_fallback_unregister
+mono_dl_open
mono_dllmap_insert
mono_domain_add_class_static_data
mono_domain_assembly_open
mono_ldtoken
mono_load_remote_field
mono_load_remote_field_new
+mono_loader_register_module
mono_lock_free_alloc
mono_lock_free_allocator_check_consistency
mono_lock_free_allocator_init_allocator
<resources>System.Web.Http.WebHost.Properties.CommonWebApiResources,../../../external/aspnetwebstack/src/Common/CommonWebApiResources.resx System.Web.Http.WebHost.Properties.SRResources,../../../external/aspnetwebstack/src/System.Web.Http.WebHost/Properties/SRResources.resx</resources>
<response>System.Web.Http.WebHost.dll.sources</response>
</project>
- <project dir="class/Mono.Security.Providers.NewSystemSource" library="Mono.Security.Providers.NewSystemSource-net_4_x">
- <boot>false</boot>
- <flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll -debug -optimize /noconfig -d:SECURITY_DEP -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:MONO -d:FEATURE_PAL -d:MONO_FEATURE_NEW_TLS -d:MONO_FEATURE_NEW_SYSTEM_SOURCE -d:DISABLE_CAS_USE -d:MONO_SECURITY_ALIAS -r:./../../class/lib/net_4_x/System.dll -r:MonoSecurity=./../../class/lib/net_4_x/Mono.Security.dll</flags>
- <output>Mono.Security.Providers.NewSystemSource.dll</output>
- <built_sources></built_sources>
- <library_output>./../../class/lib/net_4_x/Mono.Security.Providers.NewSystemSource.dll</library_output>
- <fx_version>4.5</fx_version>
- <profile>net_4_x</profile>
- <resources></resources>
- <response>Mono.Security.Providers.NewSystemSource.dll.sources</response>
- </project>
- <project dir="class/Mono.Security.Providers.NewTls" library="Mono.Security.Providers.NewTls-net_4_x">
- <boot>false</boot>
- <flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll -debug -optimize /noconfig -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/Mono.Security.dll -r:NewSystemSource=./../../class/lib/net_4_x/Mono.Security.Providers.NewSystemSource.dll</flags>
- <output>Mono.Security.Providers.NewTls.dll</output>
- <built_sources></built_sources>
- <library_output>./../../class/lib/net_4_x/Mono.Security.Providers.NewTls.dll</library_output>
- <fx_version>4.5</fx_version>
- <profile>net_4_x</profile>
- <resources></resources>
- <response>Mono.Security.Providers.NewTls.dll.sources</response>
- </project>
<project dir="class/System.Runtime.InteropServices.RuntimeInformation" library="System.Runtime.InteropServices.RuntimeInformation-net_4_x">
<boot>false</boot>
<flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll -debug -optimize /noconfig -r:./../../class/lib/net_4_x/System.dll</flags>
<resources></resources>
<response>System.Xml.Serialization.dll.sources</response>
</project>
- <project dir="class/Mono.Security.Providers.DotNet" library="Mono.Security.Providers.DotNet-net_4_x">
- <boot>false</boot>
- <flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll -debug -optimize /noconfig -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/Mono.Security.dll</flags>
- <output>Mono.Security.Providers.DotNet.dll</output>
- <built_sources></built_sources>
- <library_output>./../../class/lib/net_4_x/Mono.Security.Providers.DotNet.dll</library_output>
- <fx_version>4.5</fx_version>
- <profile>net_4_x</profile>
- <resources></resources>
- <response>Mono.Security.Providers.DotNet.dll.sources</response>
- </project>
- <project dir="class/Mono.Security.Providers.OldTls" library="Mono.Security.Providers.OldTls-net_4_x">
- <boot>false</boot>
- <flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll -debug -optimize /noconfig -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -d:SECURITY_DEP -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/Mono.Security.dll</flags>
- <output>Mono.Security.Providers.OldTls.dll</output>
- <built_sources></built_sources>
- <library_output>./../../class/lib/net_4_x/Mono.Security.Providers.OldTls.dll</library_output>
- <fx_version>4.5</fx_version>
- <profile>net_4_x</profile>
- <resources></resources>
- <response>Mono.Security.Providers.OldTls.dll.sources</response>
- </project>
<project dir="class/System.DirectoryServices.Protocols" library="System.DirectoryServices.Protocols-net_4_x">
<boot>false</boot>
<flags>/codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll -debug -optimize /noconfig -r:./../../class/lib/net_4_x/System.dll -r:./../../class/lib/net_4_x/System.DirectoryServices.dll -r:./../../class/lib/net_4_x/System.Xml.dll</flags>
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Web.Http.WebHost-net_4_x", "mcs/class/System.Web.Http.WebHost/System.Web.Http.WebHost-net_4_x.csproj", "{2AF7E697-07BA-439E-89BF-076AEE4AE04C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Security.Providers.NewSystemSource-net_4_x", "mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource-net_4_x.csproj", "{0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Security.Providers.NewTls-net_4_x", "mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls-net_4_x.csproj", "{C8B8E524-BB3A-44E2-8C22-E3313E9F477C}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Build.Framework-net_4_x", "mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework-net_4_x.csproj", "{5E39A911-F4E6-4B4B-B8AC-111BB1DD80C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Build.Utilities-net_4_x", "mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities-net_4_x.csproj", "{8E5728E0-CEAF-431F-963E-EB1DEE15C506}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Xml.Serialization-net_4_x", "mcs/class/System.Xml.Serialization/System.Xml.Serialization-net_4_x.csproj", "{2210873E-99FC-48A2-A261-D650BAE33A1C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Security.Providers.DotNet-net_4_x", "mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet-net_4_x.csproj", "{391EDD2B-85AC-4FCA-B607-AAD6C51E6799}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Security.Providers.OldTls-net_4_x", "mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls-net_4_x.csproj", "{E485E885-59B1-4081-BC66-56AAAFD8771A}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices.Protocols-net_4_x", "mcs/class/System.DirectoryServices.Protocols/System.DirectoryServices.Protocols-net_4_x.csproj", "{EF08F249-31A1-4E62-8391-ECBA5227B686}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.VisualC-net_4_x", "mcs/class/Microsoft.VisualC/Microsoft.VisualC-net_4_x.csproj", "{ACA2694D-9F07-4AE2-9171-9AB5DD1A8C18}"
{2AF7E697-07BA-439E-89BF-076AEE4AE04C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AF7E697-07BA-439E-89BF-076AEE4AE04C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AF7E697-07BA-439E-89BF-076AEE4AE04C}.Release|Any CPU.Build.0 = Release|Any CPU
- {0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0BB4541F-9B1A-4CBC-BEB1-00B31B37F74E}.Release|Any CPU.Build.0 = Release|Any CPU
- {C8B8E524-BB3A-44E2-8C22-E3313E9F477C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C8B8E524-BB3A-44E2-8C22-E3313E9F477C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C8B8E524-BB3A-44E2-8C22-E3313E9F477C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {C8B8E524-BB3A-44E2-8C22-E3313E9F477C}.Release|Any CPU.Build.0 = Release|Any CPU
{5E39A911-F4E6-4B4B-B8AC-111BB1DD80C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E39A911-F4E6-4B4B-B8AC-111BB1DD80C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E39A911-F4E6-4B4B-B8AC-111BB1DD80C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2210873E-99FC-48A2-A261-D650BAE33A1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2210873E-99FC-48A2-A261-D650BAE33A1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2210873E-99FC-48A2-A261-D650BAE33A1C}.Release|Any CPU.Build.0 = Release|Any CPU
- {391EDD2B-85AC-4FCA-B607-AAD6C51E6799}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {391EDD2B-85AC-4FCA-B607-AAD6C51E6799}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {391EDD2B-85AC-4FCA-B607-AAD6C51E6799}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {391EDD2B-85AC-4FCA-B607-AAD6C51E6799}.Release|Any CPU.Build.0 = Release|Any CPU
- {E485E885-59B1-4081-BC66-56AAAFD8771A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E485E885-59B1-4081-BC66-56AAAFD8771A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E485E885-59B1-4081-BC66-56AAAFD8771A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E485E885-59B1-4081-BC66-56AAAFD8771A}.Release|Any CPU.Build.0 = Release|Any CPU
{EF08F249-31A1-4E62-8391-ECBA5227B686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF08F249-31A1-4E62-8391-ECBA5227B686}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF08F249-31A1-4E62-8391-ECBA5227B686}.Release|Any CPU.ActiveCfg = Release|Any CPU