Merge pull request #3600 from henricm/fix-win-network-info-tests
authorHenric Müller <henric.muller@gmail.com>
Thu, 22 Sep 2016 13:57:26 +0000 (15:57 +0200)
committerGitHub <noreply@github.com>
Thu, 22 Sep 2016 13:57:26 +0000 (15:57 +0200)
Fix NetworkInformation tests on Windows

376 files changed:
configure.ac
eglib/src/gfile-win32.c
eglib/src/glib.h
man/mcs.1
man/mkbundle.1
mcs/class/Facades/System.Net.Mail/TypeForwarders.cs
mcs/class/Facades/System.Reflection.Emit.Lightweight/DynamicMethod.cs [new file with mode: 0644]
mcs/class/Facades/System.Reflection.Emit.Lightweight/System.Reflection.Emit.Lightweight.dll.sources
mcs/class/Facades/System.Reflection.Emit.Lightweight/TypeForwarders.cs
mcs/class/Facades/subdirs.make
mcs/class/Makefile
mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/DynamicContext.cs
mcs/class/Mono.CSharp/mobile_static_Mono.CSharp.dll.sources
mcs/class/Mono.CSharp/monotouch.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft.dll.sources
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/LocalScope.cs [new file with mode: 0644]
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs
mcs/class/Mono.Debugger.Soft/Test/dtest.cs
mcs/class/Mono.Security.Providers.DotNet/Makefile [deleted file]
mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet-net_4_x.csproj [deleted file]
mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet.dll.sources [deleted file]
mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs [deleted file]
mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs [deleted file]
mcs/class/Mono.Security.Providers.DotNet/Properties/AssemblyInfo.cs [deleted file]
mcs/class/Mono.Security.Providers.DotNet/README.md [deleted file]
mcs/class/Mono.Security.Providers.NewSystemSource/Makefile [deleted file]
mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource-net_4_x.csproj [deleted file]
mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource.dll.sources [deleted file]
mcs/class/Mono.Security.Providers.NewSystemSource/Properties/AssemblyInfo.cs [deleted file]
mcs/class/Mono.Security.Providers.NewSystemSource/README.md [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Makefile [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls-net_4_x.csproj [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls.dll.sources [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsConfiguration.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsContext.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStream.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/NewTlsProvider.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsContextWrapper.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsProviderFactory.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/Properties/AssemblyInfo.cs [deleted file]
mcs/class/Mono.Security.Providers.NewTls/mobile_Mono.Security.Providers.NewTls.dll.sources [deleted file]
mcs/class/Mono.Security.Providers.NewTls/mobile_static_Mono.Security.Providers.NewTls.dll.sources [deleted file]
mcs/class/Mono.Security.Providers.OldTls/Makefile [deleted file]
mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls-net_4_x.csproj [deleted file]
mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls.dll.sources [deleted file]
mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs [deleted file]
mcs/class/Mono.Security.Providers.OldTls/Properties/AssemblyInfo.cs [deleted file]
mcs/class/Mono.Security/Assembly/AssemblyInfo.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsConnectionInfo.cs
mcs/class/System.Configuration/net_4_x_System.Configuration_test.dll.config [changed from symlink to file mode: 0644]
mcs/class/System.Core/System.IO.Pipes/AnonymousPipeServerStream.cs
mcs/class/System.Core/System.IO.Pipes/NamedPipeClientStream.cs
mcs/class/System.Core/System.IO.Pipes/NamedPipeServerStream.cs
mcs/class/System.Core/System.IO.Pipes/PipeStream.cs
mcs/class/System.Data/Test/System.Data/DataTableReadWriteXmlTest.cs [changed mode: 0644->0755]
mcs/class/System.Data/Test/System.Data/DataTableTest.cs [changed mode: 0644->0755]
mcs/class/System.Data/Test/System.Xml/XmlDataDocumentTest.cs [changed mode: 0644->0755]
mcs/class/System.Net.Http/System.Net.Http.Headers/HeaderInfo.cs
mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaderValueCollection.cs
mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaders.cs
mcs/class/System.Net.Http/Test/System.Net.Http.Headers/HttpHeaderValueCollection.cs
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs
mcs/class/System.Web/System.Web.Compilation/AppResourcesAssemblyBuilder.cs
mcs/class/System.Web/System.Web.dll.sources
mcs/class/System.Web/System.Web/HttpCookie.cs
mcs/class/System.Windows.Forms/System.Windows.Forms.dll.sources
mcs/class/System.Windows.Forms/System.Windows.Forms/Application.cs
mcs/class/System.XML/Test/System.Xml.Serialization/XmlReflectionImporterTests.cs [changed mode: 0644->0755]
mcs/class/System/Assembly/AssemblyInfo.cs
mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs
mcs/class/System/Microsoft.VisualBasic/VBCodeCompiler.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs
mcs/class/System/ReferenceSources/Internal.cs [deleted file]
mcs/class/System/ReferenceSources/SSPIConfiguration.cs [deleted file]
mcs/class/System/ReferenceSources/SSPISafeHandles.cs [deleted file]
mcs/class/System/ReferenceSources/SSPIWrapper.cs [deleted file]
mcs/class/System/ReferenceSources/SslStream.cs [deleted file]
mcs/class/System/ReferenceSources/_SecureChannel.cs [deleted file]
mcs/class/System/ReferenceSources/_SslState.cs [deleted file]
mcs/class/System/ReferenceSources/_SslStream.cs [deleted file]
mcs/class/System/System-bare-net_4_x.csproj
mcs/class/System/System-net_4_x.csproj
mcs/class/System/System.Diagnostics.CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs [deleted file]
mcs/class/System/System.Diagnostics/Win32EventLog.cs
mcs/class/System/System.Net.Sockets/Socket.cs
mcs/class/System/System.Net/HttpListenerResponse.cs
mcs/class/System/System.Net/ServicePointManager.cs
mcs/class/System/System.Net/WebConnection.cs
mcs/class/System/System.dll.sources
mcs/class/System/System/MonoExeLocator.cs [new file with mode: 0755]
mcs/class/System/Test/System.Diagnostics/EventLogTest.cs
mcs/class/System/Test/System.Diagnostics/ProcessTest.cs
mcs/class/System/Test/System.Net/DnsTest.cs
mcs/class/System/Test/System.Net/HttpListenerTest.cs
mcs/class/System/Test/System/UriTest.cs
mcs/class/System/mobile_System.dll.sources
mcs/class/corlib/Assembly/AssemblyInfo.cs
mcs/class/corlib/ReferenceSources/BinaryCompatibility.cs [new file with mode: 0644]
mcs/class/corlib/ReferenceSources/CompatibilitySwitches.cs
mcs/class/corlib/ReferenceSources/RuntimeType.cs
mcs/class/corlib/System.Diagnostics.Tracing/EventSource.cs
mcs/class/corlib/System.Diagnostics/StackTrace.cs
mcs/class/corlib/System.IO/Path.cs
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilderAccess.cs
mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/EnumBuilder.cs
mcs/class/corlib/System.Reflection.Emit/EnumBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/EventBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/FieldBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/GenericTypeParameterBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/ILGenerator.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/Label.cs
mcs/class/corlib/System.Reflection.Emit/LocalBuilder.cs
mcs/class/corlib/System.Reflection.Emit/MethodBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/ParameterBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/PropertyBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/SignatureHelper.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.pns.cs [new file with mode: 0644]
mcs/class/corlib/System.Reflection/Assembly.cs
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mcs/class/corlib/System.Runtime.Loader/AssemblyLoadContext.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
mcs/class/corlib/System.Security.AccessControl/NativeObjectSecurity.cs
mcs/class/corlib/System.Security.AccessControl/ObjectSecurity_T.cs
mcs/class/corlib/System.Security/PermissionSet.cs
mcs/class/corlib/System.Threading/Thread.cs
mcs/class/corlib/System/Console.cs
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/System/GC.cs [deleted file]
mcs/class/corlib/System/GCCollectionMode.cs [deleted file]
mcs/class/corlib/System/GCNotificationStatus.cs [deleted file]
mcs/class/corlib/System/TermInfoDriver.cs
mcs/class/corlib/System/TimeZoneInfo.Android.cs
mcs/class/corlib/System/TimeZoneInfo.cs
mcs/class/corlib/Test/System.Security.AccessControl/FileSecurityTest.cs
mcs/class/corlib/Test/System.Threading/MutexTest.cs
mcs/class/corlib/Test/System.Threading/WaitHandleTest.cs
mcs/class/corlib/Test/System/DateTimeTest.cs
mcs/class/corlib/Test/System/DecimalTest-Microsoft.cs
mcs/class/corlib/Test/System/DoubleTest.cs
mcs/class/corlib/Test/System/GCTest.cs [new file with mode: 0644]
mcs/class/corlib/Test/System/TimeZoneInfo.AdjustmentRuleTest.cs
mcs/class/corlib/Test/System/TimeZoneInfoTest.cs
mcs/class/corlib/Test/System/TimeZoneTest.cs
mcs/class/corlib/Test/System/TypeTest.cs
mcs/class/corlib/corlib.dll.sources
mcs/class/corlib/corlib_test.dll.sources
mcs/class/referencesource/System/net/System/Net/WebHeaderCollection.cs
mcs/class/referencesource/System/sys/system/windows/markup/ValueSerializerAttribute.cs
mcs/class/referencesource/mscorlib/system/boolean.cs
mcs/class/referencesource/mscorlib/system/collections/generic/list.cs
mcs/class/referencesource/mscorlib/system/convert.cs
mcs/class/referencesource/mscorlib/system/gc.cs
mcs/class/referencesource/mscorlib/system/globalization/charunicodeinfo.cs
mcs/class/referencesource/mscorlib/system/globalization/compareinfo.cs
mcs/class/referencesource/mscorlib/system/globalization/datetimeformatinfo.cs
mcs/class/referencesource/mscorlib/system/globalization/datetimeparse.cs
mcs/class/referencesource/mscorlib/system/globalization/japanesecalendar.cs
mcs/class/referencesource/mscorlib/system/globalization/sortversion.cs
mcs/class/referencesource/mscorlib/system/io/binaryreader.cs
mcs/class/referencesource/mscorlib/system/io/filesysteminfo.cs
mcs/class/referencesource/mscorlib/system/io/ioexception.cs
mcs/class/referencesource/mscorlib/system/io/streamwriter.cs
mcs/class/referencesource/mscorlib/system/resources/manifestbasedresourcegroveler.cs
mcs/class/referencesource/mscorlib/system/resources/resourcemanager.cs
mcs/class/referencesource/mscorlib/system/rttype.cs
mcs/class/referencesource/mscorlib/system/runtime/compilerservices/typedependencyattribute.cs
mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binarycommonclasses.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatterwriter.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binarymethodmessage.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryutilclasses.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/objectmanager.cs
mcs/class/referencesource/mscorlib/system/runtime/serialization/serializationeventscache.cs
mcs/class/referencesource/mscorlib/system/security/claims/ClaimsIdentity.cs
mcs/class/referencesource/mscorlib/system/security/cryptography/passwordderivebytes.cs
mcs/class/referencesource/mscorlib/system/security/cryptography/rfc2898derivebytes.cs
mcs/class/referencesource/mscorlib/system/security/cryptography/rsacryptoserviceprovider.cs
mcs/class/referencesource/mscorlib/system/text/stringbuilder.cs
mcs/class/referencesource/mscorlib/system/threading/CancellationTokenSource.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/Parallel.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/ParallelLoopState.cs
mcs/class/referencesource/mscorlib/system/threading/Tasks/TaskContinuation.cs
mcs/class/referencesource/mscorlib/system/threading/eventwaithandle.cs
mcs/class/referencesource/mscorlib/system/threading/threadpool.cs
mcs/class/referencesource/mscorlib/system/typedreference.cs
mcs/errors/cs0029-37.cs [new file with mode: 0644]
mcs/errors/cs0122-39.cs [new file with mode: 0644]
mcs/errors/cs0219-7.cs [new file with mode: 0644]
mcs/errors/cs0619-59.cs [new file with mode: 0644]
mcs/errors/cs1070-3.cs [new file with mode: 0644]
mcs/errors/cs1501-19.cs [new file with mode: 0644]
mcs/mcs/class.cs
mcs/mcs/constant.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/generic.cs
mcs/mcs/import.cs
mcs/mcs/membercache.cs
mcs/mcs/property.cs
mcs/mcs/settings.cs
mcs/mcs/statement.cs
mcs/mcs/typespec.cs
mcs/tests/gtest-638.cs [new file with mode: 0644]
mcs/tests/gtest-639.cs [new file with mode: 0644]
mcs/tests/test-254.cs
mcs/tests/test-940.cs [new file with mode: 0644]
mcs/tests/test-partial-35.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mcs/tools/corcompare/mono-api-info.cs
mcs/tools/gacutil/Makefile
mcs/tools/gacutil/driver.cs
mcs/tools/gacutil/gacutil.exe.sources
mcs/tools/mkbundle/mkbundle.cs
mcs/tools/mono-symbolicate/Makefile
mcs/tools/mono-symbolicate/mono-symbolicate.exe.sources
mono/dis/main.c
mono/io-layer/Makefile.am
mono/io-layer/event-private.h [deleted file]
mono/io-layer/events.c [deleted file]
mono/io-layer/events.h [deleted file]
mono/io-layer/io.c
mono/io-layer/mutex-private.h [deleted file]
mono/io-layer/mutexes.c [deleted file]
mono/io-layer/mutexes.h [deleted file]
mono/io-layer/processes.c
mono/io-layer/semaphore-private.h [deleted file]
mono/io-layer/semaphores.c [deleted file]
mono/io-layer/semaphores.h [deleted file]
mono/io-layer/shared.c [deleted file]
mono/io-layer/shared.h [deleted file]
mono/io-layer/wait.c
mono/io-layer/wapi-private.h
mono/io-layer/wapi-remap.h
mono/io-layer/wapi.c
mono/io-layer/wapi.h
mono/io-layer/wapi_glob.c
mono/metadata/Makefile.am
mono/metadata/appdomain.c
mono/metadata/assembly-internals.h [new file with mode: 0644]
mono/metadata/assembly.c
mono/metadata/assembly.h
mono/metadata/attach.c
mono/metadata/boehm-gc.c
mono/metadata/class-internals.h
mono/metadata/class.c
mono/metadata/domain-internals.h
mono/metadata/domain.c
mono/metadata/exception.c
mono/metadata/handle.h
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/image-internals.h
mono/metadata/image.c
mono/metadata/image.h
mono/metadata/loader.c
mono/metadata/loader.h
mono/metadata/locales.c
mono/metadata/marshal.c
mono/metadata/mempool.c
mono/metadata/metadata-internals.h
mono/metadata/monitor.c
mono/metadata/mono-route.c
mono/metadata/null-gc.c
mono/metadata/object-internals.h
mono/metadata/object-offsets.h
mono/metadata/object.c
mono/metadata/sgen-mono.c
mono/metadata/sgen-os-win32.c
mono/metadata/sre.c
mono/metadata/threadpool-ms.c
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/metadata/w32event-unix.c [new file with mode: 0644]
mono/metadata/w32event-win32.c [new file with mode: 0644]
mono/metadata/w32event.h [new file with mode: 0644]
mono/metadata/w32handle-namespace.c [new file with mode: 0644]
mono/metadata/w32handle-namespace.h [new file with mode: 0644]
mono/metadata/w32mutex-unix.c [new file with mode: 0644]
mono/metadata/w32mutex-win32.c [new file with mode: 0644]
mono/metadata/w32mutex.h [new file with mode: 0644]
mono/metadata/w32semaphore-unix.c [new file with mode: 0644]
mono/metadata/w32semaphore-win32.c [new file with mode: 0644]
mono/metadata/w32semaphore.h [new file with mode: 0644]
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/debugger-agent.c
mono/mini/driver.c
mono/mini/jit-icalls.c
mono/mini/main.c
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini-arm.c
mono/mini/mini-arm.h
mono/mini/mini-arm64.c
mono/mini/mini-arm64.h
mono/mini/mini-exceptions.c
mono/mini/mini-ia64.c
mono/mini/mini-ia64.h
mono/mini/mini-llvm.c
mono/mini/mini-mips.c
mono/mini/mini-mips.h
mono/mini/mini-ppc.c
mono/mini/mini-ppc.h
mono/mini/mini-runtime.c
mono/mini/mini-s390x.c
mono/mini/mini-sparc.c
mono/mini/mini-trampolines.c
mono/mini/mini-x86.c
mono/mini/mini-x86.h
mono/mini/mini.c
mono/mini/mini.h
mono/profiler/decode.c
mono/profiler/mono-profiler-vtune.c
mono/profiler/proflog.c
mono/profiler/utils.c
mono/sgen/sgen-cardtable.c
mono/sgen/sgen-debug.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-gray.c
mono/sgen/sgen-internal.c
mono/sgen/sgen-los.c
mono/sgen/sgen-marksweep.c
mono/sgen/sgen-memory-governor.c
mono/sgen/sgen-memory-governor.h
mono/sgen/sgen-protocol.c
mono/sgen/sgen-workers.c
mono/tests/Makefile.am
mono/tests/TestingReferenceAssembly.cs [deleted file]
mono/tests/TestingReferenceReferenceAssembly.cs [deleted file]
mono/tests/namedmutex-destroy-race.cs [new file with mode: 0644]
mono/tests/reference-loader.cs [deleted file]
mono/tests/test-multi-netmodule-1-netmodule.cs [new file with mode: 0644]
mono/tests/test-multi-netmodule-2-dll1.cs [new file with mode: 0644]
mono/tests/test-multi-netmodule-3-dll2.cs [new file with mode: 0644]
mono/tests/test-multi-netmodule-4-exe.cs [new file with mode: 0644]
mono/utils/checked-build.c
mono/utils/hazard-pointer.c
mono/utils/lock-free-alloc.c
mono/utils/lock-free-alloc.h
mono/utils/lock-free-array-queue.c
mono/utils/lock-free-array-queue.h
mono/utils/mono-codeman.c
mono/utils/mono-coop-mutex.h
mono/utils/mono-counters.c
mono/utils/mono-dl.c
mono/utils/mono-log-common.c
mono/utils/mono-log-posix.c
mono/utils/mono-log-windows.c
mono/utils/mono-mmap.c
mono/utils/mono-mmap.h
mono/utils/mono-os-mutex.h
mono/utils/mono-proclib.c
mono/utils/mono-threads-posix.c
mono/utils/mono-threads-windows.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h
mono/utils/mono-uri.c
mono/utils/w32handle.c
mono/utils/w32handle.h
msvc/libmonoruntime.vcxproj
msvc/libmonoruntime.vcxproj.filters
msvc/mono.def
msvc/monosgen.def
msvc/scripts/order.xml
net_4_x.sln

index 21db9420c474e44b3e974d7e4b150795ea41094e..9a10f6d4917d3143ac993bd5f0f59e26fdd941cf 100644 (file)
@@ -2,7 +2,7 @@
 #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])
index 2dde793dfeec7409333f5d7468a1278ae0cb5286..61e23cbe442856e8cabea65ed09ac4e6ec3d3c3c 100644 (file)
@@ -35,6 +35,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/types.h>
+#include <direct.h>
 
 #ifdef G_OS_WIN32
 #include <io.h>
@@ -68,6 +69,26 @@ int mkstemp (char *tmp_template)
        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
index 23781c168526edd95498a3260697cbd76af23ff6..d7173264c1b580ee1b65a47a21a7b8977f614005 100644 (file)
@@ -887,6 +887,12 @@ gboolean   g_file_test (const gchar *filename, GFileTest test);
 #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
  */
index ce7ff11c27aadf341a2ae73d3ddfdcb20ca329d3..377c445cb095c3479199002d4a1461bc3bdaf7d1 100644 (file)
--- a/man/mcs.1
+++ b/man/mcs.1
@@ -18,7 +18,8 @@ prepending the @ symbol to the response file name.
 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
@@ -163,7 +164,7 @@ The possible values are:
 .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.
@@ -183,6 +184,14 @@ Restrict the compiler to use only the features available in C# 3.0
 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
@@ -510,7 +519,7 @@ the MIT X11.  Please read the accompanying `COPYING' file for details.
 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
index 95861e0aeab8e58ebbaaf64c8758ffe813b0f818..305cfcc7f7224d787f72e728310c6a0e66c49d43 100644 (file)
@@ -159,10 +159,16 @@ flag to bundle all available encodings.
 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.
index 81e722e7d75a3f760188d4efed6d66f72ae8d360..a5009840f78876270fda7ca9a479dc9e786bbafe 100644 (file)
@@ -33,7 +33,9 @@
 [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))]
diff --git a/mcs/class/Facades/System.Reflection.Emit.Lightweight/DynamicMethod.cs b/mcs/class/Facades/System.Reflection.Emit.Lightweight/DynamicMethod.cs
new file mode 100644 (file)
index 0000000..25fa02f
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// 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
index 7cd359e90a0d8fcce5eb4df48242bc4d11378507..9fca03abafc330c36076aabe54e6c31614906bc0 100644 (file)
@@ -20,5 +20,6 @@
 // THE SOFTWARE.
 // 
 
+#if !FULL_AOT_RUNTIME
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Reflection.Emit.DynamicMethod))]
-
+#endif
index c980d70840d4d7c2def8ece1b62f4ce110d13c8c..7c6c5d092f1d91b07ff931bff7d8b335c1838cd7 100644 (file)
@@ -24,7 +24,7 @@ System.Security.Cryptography.Encryption.Aes System.Security.Cryptography.Encrypt
 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
@@ -34,8 +34,6 @@ common_DEPS_SUBDIRS = System.Security.Cryptography.X509Certificates System.Servi
 
 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)
 
@@ -43,10 +41,10 @@ mobile_static_SUBDIRS = $(monotouch_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)
index 8347d9f2d30e364ccbf759bc3a71e7916c62dd52..e170ff9c9964324fb67db81714d6468c3a330bec 100644 (file)
@@ -51,9 +51,6 @@ mobile_common_dirs := \
        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 \
@@ -108,6 +105,7 @@ xammac_4_5_dirs := \
        System.ServiceModel.Internals   \
        SMDiagnostics   \
        System.Numerics \
+       System.Numerics.Vectors         \
        Mono.Data.Tds   \
        System.Transactions     \
        System.EnterpriseServices       \
@@ -139,10 +137,6 @@ xammac_4_5_dirs := \
        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  \
@@ -231,8 +225,6 @@ net_4_x_dirs := \
        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
@@ -276,8 +268,6 @@ net_4_x_parallel_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               \
index 9c466c5ed9c9875b31f69f0f0ec9654075f3ac37..d03145e0df346c783650a15ff080a963e4ddcbda 100644 (file)
@@ -93,7 +93,8 @@ namespace Microsoft.CSharp.RuntimeBinder
                                module.SetDeclaringAssembly (temp);
 
                                var importer = new Compiler.ReflectionImporter (module, cc.BuiltinTypes) {
-                                       IgnorePrivateMembers = false
+                                       IgnorePrivateMembers = false,
+                                       IgnoreCompilerGeneratedField = false
                                };
 
                                // Import all currently loaded assemblies
index bd7397407ae304e5fd8aa32fdf5e7b533a8f9c7a..4c30fc6e1485b984dac425d97a47c9d1b938889a 100644 (file)
@@ -1,13 +1,4 @@
 #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
index a8260819907e8cef35ea7e90ed327970965f6c00..06feb3cc396d5ceddd3255f98dd2e0a839a880e6 100644 (file)
 
 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
@@ -528,230 +468,6 @@ namespace System.Reflection.Emit
                }
        }
 
-       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
@@ -1087,19 +803,6 @@ namespace System.Reflection.Emit
                }
        }
 
-       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)
@@ -1118,11 +821,4 @@ namespace System.Reflection.Emit
                }
        }
 
-       public class CustomAttributeBuilder
-       {
-               public CustomAttributeBuilder (params object[] args)
-               {
-                       throw new NotSupportedException ();
-               }
-       }
 }
\ No newline at end of file
index 9313227067d8d83dfe78389c285f6058e8a5c75b..3ea9e744843837ca6d031ee3362ae37393a1c97f 100644 (file)
@@ -40,6 +40,7 @@ Mono.Debugger.Soft/BreakpointEventRequest.cs
 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
index 05ea6bcdaf44aa4a2714b2c8758767164ffb0170..93e9a959eee4900912bf6f521a86a3acd01e9d31 100644 (file)
@@ -117,6 +117,8 @@ namespace Mono.Debugger.Soft
                public string[] names;
                public int[] live_range_start;
                public int[] live_range_end;
+               public int[] scopes_start;
+               public int[] scopes_end;
        }
 
        struct PropInfo {
@@ -418,7 +420,7 @@ namespace Mono.Debugger.Soft
                 * 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,
@@ -1910,6 +1912,19 @@ namespace Mono.Debugger.Soft
                        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)
diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/LocalScope.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/LocalScope.cs
new file mode 100644 (file)
index 0000000..52c58b2
--- /dev/null
@@ -0,0 +1,35 @@
+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;
+                       }
+               }
+       }
+}
+
index 88dd7277c20262752cb2ecaf7a21f8e5e48432cf..fb10f7117c30258350bad2e93053dac7cbb14cbe 100644 (file)
@@ -19,6 +19,7 @@ namespace Mono.Debugger.Soft
                ParameterInfoMirror[] param_info;
                ParameterInfoMirror ret_param;
                LocalVariable[] locals;
+               LocalScope[] scopes;
                IList<Location> locations;
                MethodBodyMirror body;
                MethodMirror gmd;
@@ -239,6 +240,12 @@ namespace Mono.Debugger.Soft
                        }
                }
 
+               public LocalScope [] GetScopes () {
+                       vm.CheckProtocolVersion (2, 43);
+                       GetLocals ();
+                       return scopes;
+               }
+
                public LocalVariable[] GetLocals () {
                        if (locals == null) {
                                LocalsInfo li = new LocalsInfo ();
@@ -258,6 +265,12 @@ namespace Mono.Debugger.Soft
 
                                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;
                }
index 018435051777ac312d0831c2d71682ef37c6bee6..581e90744aafe5ab50bcb89d996758ddc3f78113 100644 (file)
@@ -69,9 +69,17 @@ public class DebuggerTests
                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 });
@@ -1846,6 +1854,9 @@ public class DebuggerTests
                                Assert.Fail ();
                        }
                }
+
+               var scopes = frame.Method.GetScopes ();
+               Assert.AreEqual (2, scopes.Length);
        }
 
        Event step_once () {
diff --git a/mcs/class/Mono.Security.Providers.DotNet/Makefile b/mcs/class/Mono.Security.Providers.DotNet/Makefile
deleted file mode 100644 (file)
index a42b8c5..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-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
-
diff --git a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet-net_4_x.csproj b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet-net_4_x.csproj
deleted file mode 100644 (file)
index 115c3f2..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?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
-
diff --git a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet.dll.sources b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet.dll.sources
deleted file mode 100644 (file)
index 7afb9f3..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-./Properties/AssemblyInfo.cs
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-
-./Mono.Security.Providers.DotNet/DotNetTlsProvider.cs
-./Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs
diff --git a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetSslStreamImpl.cs
deleted file mode 100644 (file)
index c6be703..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-//
-// 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;
-                       }
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs b/mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs
deleted file mode 100644 (file)
index 3be685a..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-//
-// 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);
-               }
-
-       }
-}
-
diff --git a/mcs/class/Mono.Security.Providers.DotNet/Properties/AssemblyInfo.cs b/mcs/class/Mono.Security.Providers.DotNet/Properties/AssemblyInfo.cs
deleted file mode 100644 (file)
index cbbd002..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// 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")]
-
diff --git a/mcs/class/Mono.Security.Providers.DotNet/README.md b/mcs/class/Mono.Security.Providers.DotNet/README.md
deleted file mode 100644 (file)
index 4c47efd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-See mcs/class/Mono.Security.Providers.NewSystemSource/README.md for a detailed README.
diff --git a/mcs/class/Mono.Security.Providers.NewSystemSource/Makefile b/mcs/class/Mono.Security.Providers.NewSystemSource/Makefile
deleted file mode 100644 (file)
index 61beeb4..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-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
diff --git a/mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource-net_4_x.csproj b/mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource-net_4_x.csproj
deleted file mode 100644 (file)
index 771d99f..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-<?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
-
diff --git a/mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource.dll.sources b/mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource.dll.sources
deleted file mode 100644 (file)
index c0765d5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-./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
-
diff --git a/mcs/class/Mono.Security.Providers.NewSystemSource/Properties/AssemblyInfo.cs b/mcs/class/Mono.Security.Providers.NewSystemSource/Properties/AssemblyInfo.cs
deleted file mode 100644 (file)
index 23ba5bb..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// 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")]
diff --git a/mcs/class/Mono.Security.Providers.NewSystemSource/README.md b/mcs/class/Mono.Security.Providers.NewSystemSource/README.md
deleted file mode 100644 (file)
index 03447c0..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-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>
-
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Makefile b/mcs/class/Mono.Security.Providers.NewTls/Makefile
deleted file mode 100644 (file)
index 54270bc..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-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
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls-net_4_x.csproj b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls-net_4_x.csproj
deleted file mode 100644 (file)
index 158b095..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-<?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
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls.dll.sources b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls.dll.sources
deleted file mode 100644 (file)
index 12d8a20..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-./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
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsConfiguration.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsConfiguration.cs
deleted file mode 100644 (file)
index 401afd7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// 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;
-               }
-       }
-}
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsContext.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsContext.cs
deleted file mode 100644 (file)
index 0d69805..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// 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 ();
-       }
-}
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStream.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
deleted file mode 100644 (file)
index 6117f0f..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// 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; }
-               }
-       }
-}
-
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
deleted file mode 100644 (file)
index d39f1bb..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// 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;
-               }
-       }
-}
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/NewTlsProvider.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/NewTlsProvider.cs
deleted file mode 100644 (file)
index e2b347f..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-//
-// 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);
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsContextWrapper.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsContextWrapper.cs
deleted file mode 100644 (file)
index 389dd1a..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-//
-// 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 ();
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsProviderFactory.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsProviderFactory.cs
deleted file mode 100644 (file)
index 92d8ab0..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-//
-// 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 });
-               }
-       }
-}
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Properties/AssemblyInfo.cs b/mcs/class/Mono.Security.Providers.NewTls/Properties/AssemblyInfo.cs
deleted file mode 100644 (file)
index e369093..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-// 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")]
diff --git a/mcs/class/Mono.Security.Providers.NewTls/mobile_Mono.Security.Providers.NewTls.dll.sources b/mcs/class/Mono.Security.Providers.NewTls/mobile_Mono.Security.Providers.NewTls.dll.sources
deleted file mode 100644 (file)
index 7218dab..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-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
diff --git a/mcs/class/Mono.Security.Providers.NewTls/mobile_static_Mono.Security.Providers.NewTls.dll.sources b/mcs/class/Mono.Security.Providers.NewTls/mobile_static_Mono.Security.Providers.NewTls.dll.sources
deleted file mode 100644 (file)
index baded51..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include mobile_Mono.Security.Providers.NewTls.dll.sources
diff --git a/mcs/class/Mono.Security.Providers.OldTls/Makefile b/mcs/class/Mono.Security.Providers.OldTls/Makefile
deleted file mode 100644 (file)
index 5dc06c0..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-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
-
diff --git a/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls-net_4_x.csproj b/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls-net_4_x.csproj
deleted file mode 100644 (file)
index 32ceb30..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-<?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
-
diff --git a/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls.dll.sources b/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls.dll.sources
deleted file mode 100644 (file)
index 13653b8..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-./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
diff --git a/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs b/mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs
deleted file mode 100644 (file)
index 4532a17..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-//
-// 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 ();
-               }
-       }
-}
-
diff --git a/mcs/class/Mono.Security.Providers.OldTls/Properties/AssemblyInfo.cs b/mcs/class/Mono.Security.Providers.OldTls/Properties/AssemblyInfo.cs
deleted file mode 100644 (file)
index 923beca..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// 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")]
-
index 3e79d28a8fe09fc504f1cba2557b16b862df859c..eeccc251f7d6ed12f515024c5183ee374d19e6e4 100644 (file)
@@ -66,8 +66,3 @@ using System.Runtime.InteropServices;
 [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")]
index 4bc5f436f454b6bb8e2e7e1896524836ddcc728f..63003e366b9db64eae270edd87fba522a81fe5e3 100644 (file)
@@ -49,6 +49,10 @@ namespace Mono.Security.Interface
                        get; set;
                }
 
+               public string PeerDomainName {
+                       get; set;
+               }
+
                public override string ToString ()
                {
                        return string.Format ("[MonoTlsConnectionInfo: {0}:{1}]", ProtocolVersion, CipherSuiteCode);
deleted file mode 120000 (symlink)
index 6f31b34dcaa52c7157fab9560cc6a6b5e6f14c7c..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-Test/App.config
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..d07b4f882f8fea25edf772d4619e88847ae2cb95
--- /dev/null
@@ -0,0 +1,8 @@
+<?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>
index 97455f30cdab55d78766508ad566684a21674a3b..18c82aeac3123a789d24b4f03217d087ec1429bf 100644 (file)
@@ -70,13 +70,15 @@ namespace System.IO.Pipes
                }
 #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
@@ -84,8 +86,8 @@ namespace System.IO.Pipes
 
                        InitializeHandle (impl.Handle, false, false);
                        IsConnected = true;
-               }
 #endif
+               }
 
                [MonoTODO]
                public AnonymousPipeServerStream (PipeDirection direction, SafePipeHandle serverSafePipeHandle, SafePipeHandle clientSafePipeHandle)
index a5a9ebd3fbc698acd1801824f8ac2d37fc21ab3b..a823217957dcd384dd2f14db6d07cdbc1b06fa3d 100644 (file)
@@ -100,21 +100,23 @@ namespace System.IO.Pipes
 #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);
                }
@@ -163,6 +165,10 @@ namespace System.IO.Pipes
                        throw new NotImplementedException ();
                }
 
+               protected override internal void CheckPipePropertyOperations () {
+                       base.CheckPipePropertyOperations();
+               }
+
                public int NumberOfServerInstances {
                        get {
                                CheckPipePropertyOperations ();
index 3ffe89436727acf71c4a3be5afbd61aed7d9712f..e402a8a2620193f7b966b300ddb7cb2f219a431f 100644 (file)
@@ -83,7 +83,6 @@ namespace System.IO.Pipes
                }
 #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)
                {
@@ -100,7 +99,9 @@ namespace System.IO.Pipes
                {
                        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,
@@ -110,8 +111,8 @@ namespace System.IO.Pipes
                                                                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)
@@ -140,14 +141,12 @@ namespace System.IO.Pipes
                        impl.Disconnect ();
                }
 
-#if !MOBILE
                [MonoTODO]
                [SecurityPermission (SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)]
                public void RunAsClient (PipeStreamImpersonationWorker impersonationWorker)
                {
                        throw new NotImplementedException ();
                }
-#endif
 
                public void WaitForConnection ()
                {
@@ -173,7 +172,6 @@ namespace System.IO.Pipes
                        throw new NotImplementedException ();
                }
 
-#if !MOBILE
                // async operations
 
                Action wait_connect_delegate;
@@ -190,7 +188,6 @@ namespace System.IO.Pipes
                {
                        wait_connect_delegate.EndInvoke (asyncResult);
                }
-#endif
        }
 }
 
index 20b7e7ec09cb8fa3a7f17df609d7f240237f2434..8dea76a2cacf96b9ff3010364d82008dbf7e31dd 100644 (file)
@@ -57,7 +57,6 @@ namespace System.IO.Pipes
                        return new NotImplementedException ("ACL is not supported in Mono");
                }
 
-#if !MOBILE
                internal static PipeAccessRights ToAccessRights (PipeDirection direction)
                {
                        switch (direction) {
@@ -88,7 +87,6 @@ namespace System.IO.Pipes
                                        throw new ArgumentOutOfRangeException ();
                        }
                }
-#endif
 
                protected PipeStream (PipeDirection direction, int bufferSize)
                        : this (direction, PipeTransmissionMode.Byte, bufferSize)
@@ -144,9 +142,7 @@ namespace System.IO.Pipes
                        set { stream = value; }
                }
 
-#if !MOBILE
                protected bool IsHandleExposed { get; private set; }
-#endif
 
                [MonoTODO]
                public bool IsMessageComplete { get; private set; }
@@ -182,19 +178,7 @@ namespace System.IO.Pipes
                }
 
                // initialize/dispose/state check
-#if MOBILE
-               internal static void CheckPipePropertyOperations ()
-               {
-               }
-
-               static void CheckReadOperations ()
-               {
-               }
 
-               static void CheckWriteOperations ()
-               {
-               }
-#else
                [MonoTODO]
                protected internal virtual void CheckPipePropertyOperations ()
                {
@@ -224,7 +208,6 @@ namespace System.IO.Pipes
                        this.IsHandleExposed = isExposed;
                        this.IsAsync = isAsync;
                }
-#endif
 
                protected override void Dispose (bool disposing)
                {
@@ -253,23 +236,29 @@ namespace System.IO.Pipes
                        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
 
@@ -319,7 +308,6 @@ namespace System.IO.Pipes
 
                // async
 
-#if !MOBILE
                Func<byte [],int,int,int> read_delegate;
 
                [HostProtection (SecurityAction.LinkDemand, ExternalThreading = true)]
@@ -349,7 +337,6 @@ namespace System.IO.Pipes
                {
                        write_delegate.EndInvoke (asyncResult);
                }
-#endif
        }
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 1993e7f..4412990
@@ -35,7 +35,6 @@ namespace MonoTests.System.Data
     [TestFixture]
     public class DataTableReadWriteXmlTest
     {
-        public static readonly string EOL = Environment.NewLine;
 
         void StandardizeXmlFormat(ref string xml)
         {
@@ -126,11 +125,11 @@ namespace MonoTests.System.Data
             // 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);
@@ -188,11 +187,11 @@ namespace MonoTests.System.Data
             
             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);
old mode 100644 (file)
new mode 100755 (executable)
index 388f547..9d54c82
@@ -3236,7 +3236,6 @@ namespace MonoTests.System.Data
                        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");
old mode 100644 (file)
new mode 100755 (executable)
index 053ecdb..93b0cc6
@@ -174,9 +174,9 @@ namespace MonoTests.System.Data.Xml
                        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;
index 9ca277dbbcd3ed5f92ef9a04e09fa3b6b5cade31..3da8be8c435ac602e3b50011669eaf5eccdaa244 100644 (file)
@@ -70,14 +70,21 @@ namespace System.Net.Http.Headers
                                        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;
                        }
 
index 72c4299e64ad4c8eb85239f9d849037435a10de0..35f8556bdc557ee733c41bd455f570010f8cdedc 100644 (file)
@@ -36,6 +36,7 @@ namespace System.Net.Http.Headers
                readonly List<T> list;
                readonly HttpHeaders headers;
                readonly HeaderInfo headerInfo;
+               List<string> invalidValues;
 
                internal HttpHeaderValueCollection (HttpHeaders headers, HeaderInfo headerInfo)
                {
@@ -50,6 +51,12 @@ namespace System.Net.Http.Headers
                        }
                }
 
+               internal List<string> InvalidValues {
+                       get {
+                               return invalidValues;
+                       }
+               }
+
                public bool IsReadOnly {
                        get {
                                return false;
@@ -66,9 +73,18 @@ namespace System.Net.Http.Headers
                        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)
@@ -93,11 +109,12 @@ namespace System.Net.Http.Headers
 
                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)
index 05b5fe62681f3f981b067777d1cb7a7f9f32a03b..c22a6695593718e430899cf0ffd3dd20d11433a1 100644 (file)
@@ -481,23 +481,28 @@ namespace System.Net.Http.Headers
                                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)
index 50f8432f8ecb4ac99e1eb6ab1a7cd2c51bea74dc..0fd756037532eebca3f8ae890dbac52906503004 100644 (file)
@@ -91,5 +91,42 @@ namespace MonoTests.System.Net.Http.Headers
 
                        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");
+               }
        }
 }
index cab5d34208680ac5f12accbe69744d2238c513cc..2ca12fb601a69ce9e90cc073953f6e34ac86690c 100644 (file)
@@ -71,7 +71,12 @@ namespace System.Runtime.Remoting.Channels.Tcp
                                        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
@@ -259,6 +264,22 @@ namespace System.Runtime.Remoting.Channels.Tcp
                        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
index 895440d3a6a8ec33f843523b24777261e37e3014..15c0393412b8635cf4f59d61b10e3bd32799544e 100644 (file)
@@ -47,8 +47,6 @@ namespace System.Web.Compilation
 {
        class AppResourcesAssemblyBuilder
        {
-               static string framework_version = "4.5";
-               static string profile_path = "net_4_x";
                CompilationSection config;
                CompilerInfo ci;
                CodeDomProvider _provider;
@@ -233,36 +231,14 @@ namespace System.Web.Compilation
                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);
index 248b80f3537526f9501de642c6f69698a20bcf75..09a2639d7355a6ccf51210dff4d46f49aac5124d 100644 (file)
@@ -2,6 +2,7 @@ Assembly/AssemblyInfo.cs
 ../../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
index 2b4e68cf8ed8d8ad018ea72686d0fa9134cabaa0..a413f1140da720b97104bb309894793cbb9ac1cb 100644 (file)
@@ -3,6 +3,7 @@
 //
 // Author:
 //     Chris Toshok (toshok@novell.com)
+//     Katharina Bogad (bogad@cs.tum.edu)
 //
 
 //
@@ -31,6 +32,7 @@
 using System.Text;
 using System.Collections.Specialized;
 using System.Security.Permissions;
+using System.Web.Configuration;
 
 namespace System.Web
 {
@@ -66,6 +68,17 @@ 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)
index 90e91d144e12ba407ecd5e9c6ea1a357532dc3d0..c78f10bd89dde97a7d1d7d0fa0704ab550894125 100644 (file)
@@ -2,6 +2,7 @@
 ../../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
index e4f980e60df8a82c6a80b770f933bdea8f0f7be2..07353efcb7a4dca16fa76fec7e5c817fc8828c4a 100644 (file)
@@ -560,35 +560,7 @@ namespace System.Windows.Forms
                        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 ();
old mode 100644 (file)
new mode 100755 (executable)
index 98942e5..bec6232
@@ -2052,8 +2052,8 @@ namespace MonoTests.System.XmlSerialization
                                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.");
                        }
index 3388150cf10fba174c9be43736c3cc1f233e82a5..a80606ef6681ab5fb206f56beb846e816f5bc309 100644 (file)
@@ -74,10 +74,5 @@ using System.Runtime.InteropServices;
        [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")]
index 00424bd70f370d8cc10be4b2e2ddeec4ead96442..c41240fab9e280d5ace8c1e9527f4a5ab080254b 100644 (file)
@@ -48,54 +48,9 @@ namespace Mono.CSharp
        
        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
                //
@@ -177,14 +132,14 @@ namespace Mono.CSharp
 
                        // 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 ();
 /*                    
index bdb08db595adb849f3cea1b849b7b8a12fb9917a..907acebaa66f7ece769bbe4a359af68ba0a328dd 100644 (file)
@@ -48,38 +48,6 @@ namespace Microsoft.VisualBasic
 {
        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 });
@@ -248,10 +216,10 @@ namespace Microsoft.VisualBasic
                        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);
index e53b6eba4c8ee1c9e383102d0a4f548ee79ed983..3dc005344f3b50baf23a65d02938a18c479b4fa3 100644 (file)
@@ -104,21 +104,7 @@ namespace Mono.Net.Security
                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
@@ -131,7 +117,7 @@ namespace Mono.Net.Security
 
                #endregion
 
-#if SECURITY_DEP && !MONO_FEATURE_NEW_SYSTEM_SOURCE
+#if SECURITY_DEP
 
                static Dictionary<string,string> providerRegistration;
 
@@ -172,8 +158,6 @@ namespace Mono.Net.Security
                                        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");
diff --git a/mcs/class/System/ReferenceSources/Internal.cs b/mcs/class/System/ReferenceSources/Internal.cs
deleted file mode 100644 (file)
index 6c50450..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// 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;
-               }
-       }
-}
diff --git a/mcs/class/System/ReferenceSources/SSPIConfiguration.cs b/mcs/class/System/ReferenceSources/SSPIConfiguration.cs
deleted file mode 100644 (file)
index 3ab4138..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// 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
diff --git a/mcs/class/System/ReferenceSources/SSPISafeHandles.cs b/mcs/class/System/ReferenceSources/SSPISafeHandles.cs
deleted file mode 100644 (file)
index a12e395..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-//
-// 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
diff --git a/mcs/class/System/ReferenceSources/SSPIWrapper.cs b/mcs/class/System/ReferenceSources/SSPIWrapper.cs
deleted file mode 100644 (file)
index a0cb8d5..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-//
-// 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
diff --git a/mcs/class/System/ReferenceSources/SslStream.cs b/mcs/class/System/ReferenceSources/SslStream.cs
deleted file mode 100644 (file)
index fea8922..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-//
-// 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
diff --git a/mcs/class/System/ReferenceSources/_SecureChannel.cs b/mcs/class/System/ReferenceSources/_SecureChannel.cs
deleted file mode 100644 (file)
index f920353..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// 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
diff --git a/mcs/class/System/ReferenceSources/_SslState.cs b/mcs/class/System/ReferenceSources/_SslState.cs
deleted file mode 100644 (file)
index 8d5ae3f..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-//
-// 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
diff --git a/mcs/class/System/ReferenceSources/_SslStream.cs b/mcs/class/System/ReferenceSources/_SslStream.cs
deleted file mode 100644 (file)
index 591b74a..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-//
-// 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
index e748039ef2bb842653822fea1bbc110e9e04ed75..eae64de07b8d7281931d2d9f0adec20318741f6e 100644 (file)
     <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
index fbd51bbfd99f4a6fd2f5a0ffd49d191a29b2e70d..07dfdfa6fb3f05df163c9b8c046e7cf6b197215a 100644 (file)
     <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
diff --git a/mcs/class/System/System.Diagnostics.CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs b/mcs/class/System/System.Diagnostics.CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs
deleted file mode 100644 (file)
index 38371ca..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// 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 ()
-               {
-               }
-       }
-}
-
index 4002c3b7cdc4850dbe9490d4831005ed7024fc27..02e1e3d10009c8ba67b112e289c6f160184c1133 100644 (file)
@@ -7,7 +7,6 @@
 // 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,
@@ -48,7 +47,7 @@ namespace System.Diagnostics
                private IntPtr _readHandle;
                private Thread _notifyThread;
                private int _lastEntryWritten;
-               private bool _notifying;
+               private Object _eventLock = new object();
 
                public Win32EventLog (EventLog coreEventLog)
                        : base (coreEventLog)
@@ -68,9 +67,11 @@ namespace System.Diagnostics
 
                public override void Close ()
                {
-                       if (_readHandle != IntPtr.Zero) {
-                               CloseEventLog (_readHandle);
-                               _readHandle = IntPtr.Zero;
+                       lock (_eventLock) {
+                               if (_readHandle != IntPtr.Zero) {
+                                       CloseEventLog (_readHandle);
+                                       _readHandle = IntPtr.Zero;
+                               }
                        }
                }
 
@@ -703,45 +704,56 @@ namespace System.Diagnostics
 
                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;
@@ -752,9 +764,6 @@ namespace System.Diagnostics
                                                CoreEventLog.OnEntryWritten (entry);
                                        }
                                        _lastEntryWritten = last_entry;
-                               } finally {
-                                       lock (this)
-                                               _notifying = false;
                                }
                        }
                }
index 396b16f4c5416c06b77b6666e47c6404ea198e26..58d0899bf13325c69fe70745178f944d0750e54f 100644 (file)
@@ -230,7 +230,8 @@ namespace System.Net.Sockets
                                         * 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;
                                }
@@ -622,7 +623,6 @@ namespace System.Net.Sockets
                        set {
                                ThrowIfDisposedAndClosed ();
                                ThrowIfUdp ();
-
                                SetSocketOption (SocketOptionLevel.Tcp, SocketOptionName.NoDelay, value ? 1 : 0);
                        }
                }
index 329c4a2c19adba4900f992d213bca4ee7d55c2af..15ec5bb59dbf74ce6b8206c6acb1f2a0dc66eaad 100644 (file)
@@ -427,10 +427,10 @@ namespace System.Net {
 
                        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 ();
 
@@ -439,6 +439,24 @@ namespace System.Net {
                        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)
index b3c996044ef3eb1fb7c24fa0e5040ffec577ef3b..17308253af502c5f6d2c134ba11acb2a0e4be2c8 100644 (file)
@@ -132,7 +132,7 @@ namespace System.Net
                // Fields
                
                public const int DefaultNonPersistentConnectionLimit = 4;
-#if MONOTOUCH
+#if MOBILE
                public const int DefaultPersistentConnectionLimit = 10;
 #else
                public const int DefaultPersistentConnectionLimit = 2;
index d9d43bf40a735488f12a6daead4b954d790b5ac9..c1bd5271adf78ba7dbb25aac7638d8cb7a676378 100644 (file)
@@ -670,7 +670,7 @@ namespace System.Net
                                                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);
index abb1faf58183a6b9e62820befc3bc07cf497b3aa..92e3b3e84c0c38b65ed9cb2625ec93b911860d86 100644 (file)
@@ -162,8 +162,8 @@ System.Diagnostics/ThreadWaitReason.cs
 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
@@ -563,7 +563,6 @@ ReferenceSources/BinaryCompatibility.cs
 ReferenceSources/ConfigurationManagerInternalFactory.cs
 ReferenceSources/CAPI.cs
 ReferenceSources/EnvironmentHelpers.cs
-ReferenceSources/Internal.cs
 ReferenceSources/HttpApi.cs
 ReferenceSources/HttpSysSettings.cs
 ReferenceSources/LocalAppContextSwitches.cs
@@ -577,14 +576,6 @@ ReferenceSources/SR2.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
@@ -1092,6 +1083,8 @@ ReferenceSources/_SslStream.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
 
diff --git a/mcs/class/System/System/MonoExeLocator.cs b/mcs/class/System/System/MonoExeLocator.cs
new file mode 100755 (executable)
index 0000000..4ab1b33
--- /dev/null
@@ -0,0 +1,85 @@
+#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
index 706bfcdac0c6fa51f6b9a8017e213e59719b12e1..6e63058fed7d5ff90caac0148dcdd7a0b2c8652e 100644 (file)
@@ -165,7 +165,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -184,7 +184,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3488,7 +3488,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3509,7 +3509,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3634,7 +3634,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3683,7 +3683,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3735,7 +3735,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3793,7 +3793,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3814,7 +3814,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -3952,7 +3952,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4001,7 +4001,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4053,7 +4053,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4119,7 +4119,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4141,7 +4141,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4184,7 +4184,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4227,7 +4227,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4276,7 +4276,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4344,7 +4344,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4365,7 +4365,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4386,7 +4386,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4600,7 +4600,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4649,7 +4649,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4706,7 +4706,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4773,7 +4773,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4795,7 +4795,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4838,7 +4838,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4881,7 +4881,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -4930,7 +4930,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5006,7 +5006,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5028,7 +5028,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5050,7 +5050,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5264,7 +5264,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5313,7 +5313,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5365,7 +5365,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5432,7 +5432,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5454,7 +5454,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5477,7 +5477,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5585,7 +5585,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5629,7 +5629,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5679,7 +5679,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5757,7 +5757,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5779,7 +5779,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -5801,7 +5801,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6017,7 +6017,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6066,7 +6066,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6118,7 +6118,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6185,7 +6185,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6208,7 +6208,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6231,7 +6231,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6339,7 +6339,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6383,7 +6383,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6433,7 +6433,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6513,7 +6513,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6536,7 +6536,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6559,7 +6559,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6667,7 +6667,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6711,7 +6711,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6761,7 +6761,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6839,7 +6839,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6863,7 +6863,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6937,7 +6937,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -6987,7 +6987,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7037,7 +7037,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7061,7 +7061,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7109,7 +7109,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7189,7 +7189,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7240,7 +7240,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7289,7 +7289,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7313,7 +7313,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7379,7 +7379,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7434,7 +7434,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7485,7 +7485,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7509,7 +7509,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7557,7 +7557,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7627,7 +7627,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
@@ -7683,7 +7683,7 @@ namespace MonoTests.System.Diagnostics
                                        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");
index 277604287550fde13168d44d19ec29833961db90..20a93a732b6f1d1c3dc00368a5e0e0bc846db7c9 100644 (file)
@@ -284,7 +284,9 @@ namespace MonoTests.System.Diagnostics
                                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");
                        }
                }
 
@@ -440,7 +442,9 @@ namespace MonoTests.System.Diagnostics
                                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");
                        }
                }
 
@@ -892,8 +896,11 @@ namespace MonoTests.System.Diagnostics
                                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
 
@@ -1018,7 +1025,7 @@ namespace MonoTests.System.Diagnostics
 
                                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;
index dcc82f61678777cc202e1b94417d4b7a82c0d114..e06ca4bf5d6ae6e16ca43665f144953ba1d2b1c0 100644 (file)
@@ -32,28 +32,37 @@ namespace MonoTests.System.Net
                [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
@@ -61,10 +70,25 @@ namespace MonoTests.System.Net
                        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
@@ -73,7 +97,7 @@ namespace MonoTests.System.Net
                        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
@@ -91,7 +115,7 @@ namespace MonoTests.System.Net
                        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
@@ -108,7 +132,7 @@ namespace MonoTests.System.Net
                        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
@@ -122,10 +146,9 @@ namespace MonoTests.System.Net
                        }\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
@@ -317,7 +340,7 @@ namespace MonoTests.System.Net
                {\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
@@ -363,7 +386,7 @@ namespace MonoTests.System.Net
                        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
@@ -380,7 +403,7 @@ namespace MonoTests.System.Net
                        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
index 8620d1ce32a9b34bd6b98f40ea9ac0805791250a..70dcede89717281e238f732afa91b55935082777 100644 (file)
@@ -534,6 +534,33 @@ namespace MonoTests.System.Net {
 
                        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()
index 6ebd708ee02c0ea845f317e30f6d1f58230f7a20..52815f273a5d484798999909ad82cdd3e5e7e0dd 100644 (file)
@@ -1678,6 +1678,9 @@ namespace MonoTests.System
                [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");
                }
@@ -1686,6 +1689,9 @@ namespace MonoTests.System
                [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");
                }
@@ -1694,6 +1700,9 @@ namespace MonoTests.System
                [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");
 
@@ -1884,6 +1893,11 @@ namespace MonoTests.System
                [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;
 
@@ -2043,6 +2057,9 @@ namespace MonoTests.System
                [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));
index 1b4c33d5db27c04d48f883f9bcd5f22366b42b37..d246173c20400c0b9202d7e5da51a3a7b685ad74 100644 (file)
@@ -308,7 +308,6 @@ ReferenceSources/AssertWrapper.cs
 ReferenceSources/CAPI.cs
 ReferenceSources/EnvironmentHelpers.cs
 ReferenceSources/HttpApi.cs
-ReferenceSources/Internal.cs
 ReferenceSources/LocalAppContextSwitches.cs
 ReferenceSources/HttpSysSettings.cs
 ReferenceSources/Logging.cs
@@ -814,6 +813,8 @@ ReferenceSources/Win32Exception.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
@@ -824,6 +825,8 @@ ReferenceSources/Win32Exception.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
index 75828e154eb12f2fc6f7c21db9258888f7cd3c33..d315128745d2cf9d351027e6d2ace24674ff0a7c 100644 (file)
@@ -94,5 +94,4 @@ using System.Runtime.InteropServices;
 [assembly: InternalsVisibleTo ("Xamarin.Mac, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
 #endif
 
-[assembly: InternalsVisibleTo ("Xamarin.BoringTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000099dd12eda85767ae6f06023ee28e711c7e5a212462095c83868c29db75eddf6d8e296e03824c14fedd5f55553fed0b6173be3cc985a4b7f9fb7c83ccff8ba3938563b3d1f45a81122f12a1bcb73edcaad61a8456c7595a6da5184b4dd9d10f011b949ef1391fccfeab1ba62aa51c267ef8bd57ef1b6ba5a4c515d0badb81a78f")]
 [assembly: Guid ("BED7F4EA-1A96-11D2-8F08-00A0C9A6186D")]
diff --git a/mcs/class/corlib/ReferenceSources/BinaryCompatibility.cs b/mcs/class/corlib/ReferenceSources/BinaryCompatibility.cs
new file mode 100644 (file)
index 0000000..7735119
--- /dev/null
@@ -0,0 +1,8 @@
+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
index ba5dba8e652eb1008f7f6b1745c06f540135ff1f..24ee1ee00f249ad9e06c1520a66961ab55447a02 100644 (file)
@@ -30,7 +30,7 @@ namespace System
 {
        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
index 8a49451936e5fd80e95e17913a2a3025084c5f7d..d0b1473c7cd6d77edfae7bebbae07c837c7f9b7a 100644 (file)
@@ -140,15 +140,15 @@ namespace System
 
                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);
                }
index 312f0ccb166d6de88051a04b5670d7e828f0bb51..8397f4c2d2f4db3bcd383e583bf265b06d486137 100644 (file)
@@ -256,6 +256,7 @@ namespace System.Diagnostics.Tracing
                        WriteEvent (eventId, new object[] { arg1, arg2, arg3 } );
                }
 
+               [CLSCompliant (false)]
                protected unsafe void WriteEventCore (int eventId, int eventDataCount, EventData* data)
                {
                }
@@ -264,6 +265,7 @@ namespace System.Diagnostics.Tracing
                {
                }
 
+               [CLSCompliant (false)]
                protected unsafe void WriteEventWithRelatedActivityIdCore (int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data)
                {
                }
index b93808b89c4f6afa045a3f412642b90853dbb0e1..b528e4cdadcb5ff7e2aef43c0490a14e9fa7b16b 100644 (file)
@@ -59,9 +59,9 @@ namespace System.Diagnostics {
 
                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 ()
@@ -198,7 +198,6 @@ namespace System.Diagnostics {
 
                bool AddFrames (StringBuilder sb)
                {
-                       bool printOffset;
                        string debugInfo, indentation;
                        string unknown = Locale.GetText ("<unknown method>");
 
index 138163779f85793b7847b1fb3e82ff6333f28ece..5d63f271e607243398a6934082db61d9c17df0f8 100644 (file)
@@ -732,6 +732,7 @@ namespace System.IO {
                        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;
@@ -757,6 +758,7 @@ namespace System.IO {
                                                else
                                                        return current + ret;
                                        }
+#endif
                                } else {
                                        if (root != "" && ret.Length > 0 && ret [0] != '/')
                                                ret = root + ret;
@@ -876,11 +878,13 @@ namespace System.IO {
                                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 {
index c098713ca97467dc23de1347023907bcf6062a09..9c257cb9a80542fc882eb52ddfd9c05c58c0b2ee 100644 (file)
@@ -466,6 +466,11 @@ namespace System.Reflection.Emit
                        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);
diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs
new file mode 100644 (file)
index 0000000..e10784c
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// 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
index 3d1bdf152830e8d3618747e975b890c27de06c04..d9d588bdac8cb05966ca4f8046433022ba109ae3 100644 (file)
@@ -28,7 +28,6 @@
 // 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
@@ -44,4 +43,3 @@ namespace System.Reflection.Emit
                RunAndCollect = 9
   }
 }
-#endif
diff --git a/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/ConstructorBuilder.pns.cs
new file mode 100644 (file)
index 0000000..2432a64
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.pns.cs
new file mode 100644 (file)
index 0000000..fe74950
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// 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
index b5baac27ea0c69e17c2a6b18738bdd4e13b87e08..cba66c11840021f0404590a53fd2c5c2d81c6164 100644 (file)
@@ -162,6 +162,11 @@ namespace System.Reflection.Emit {
                        return res;
                }
 
+               public TypeInfo CreateTypeInfo()
+               {
+                       return _tb.CreateTypeInfo ();
+               }
+
                public override Type GetEnumUnderlyingType ()
                {
                        return _underlyingType;
diff --git a/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/EnumBuilder.pns.cs
new file mode 100644 (file)
index 0000000..e518bc4
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/EventBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/EventBuilder.pns.cs
new file mode 100644 (file)
index 0000000..159585c
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/FieldBuilder.pns.cs
new file mode 100644 (file)
index 0000000..c25a5e3
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/GenericTypeParameterBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/GenericTypeParameterBuilder.pns.cs
new file mode 100644 (file)
index 0000000..7729596
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/ILGenerator.pns.cs b/mcs/class/corlib/System.Reflection.Emit/ILGenerator.pns.cs
new file mode 100644 (file)
index 0000000..3be336f
--- /dev/null
@@ -0,0 +1,229 @@
+//
+// 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
index 427b93d98dbb2fe9b63cfc439e1df18e5b749a18..4834aa2cf2d837e8352424331589e1a66f5f7af9 100644 (file)
@@ -30,7 +30,6 @@
 // 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 {
@@ -73,4 +72,3 @@ namespace System.Reflection.Emit {
                }
        }
 }
-#endif
index 98c9addf5042a6b7e3e1c3de26954577bbfcc4b8..0c56edfb369ebfe7f56973b0d55eee044d7b76ad 100644 (file)
 // (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;
@@ -44,10 +42,16 @@ using System.Diagnostics.SymbolStore;
 
 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
@@ -108,7 +112,7 @@ namespace System.Reflection.Emit {
                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 ();
@@ -128,6 +132,6 @@ namespace System.Reflection.Emit {
                {
                        throw new NotImplementedException ();
                }
+#endif
        }
 }
-#endif
diff --git a/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/MethodBuilder.pns.cs
new file mode 100644 (file)
index 0000000..49ef26b
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.pns.cs
new file mode 100644 (file)
index 0000000..88d741d
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/ParameterBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/ParameterBuilder.pns.cs
new file mode 100644 (file)
index 0000000..d9b1bab
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/PropertyBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/PropertyBuilder.pns.cs
new file mode 100644 (file)
index 0000000..f0e709d
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/SignatureHelper.pns.cs b/mcs/class/corlib/System.Reflection.Emit/SignatureHelper.pns.cs
new file mode 100644 (file)
index 0000000..7aa0a27
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// 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
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.pns.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.pns.cs
new file mode 100644 (file)
index 0000000..ba97e01
--- /dev/null
@@ -0,0 +1,284 @@
+//
+// 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
index e9418c03393cd31d623a83f566b8f75ff06b945e..bce2832992eea36e25b13b86a689a62fa512fdb5 100644 (file)
@@ -58,12 +58,16 @@ namespace System.Reflection {
        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)
@@ -505,10 +509,14 @@ namespace System.Reflection {
                        // 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
index d7128abc33553234622f969754c0ffe932741ded..2def9ddba50828744ab6ae26d6e37d1870df033b 100644 (file)
@@ -1426,10 +1426,10 @@ namespace System.Runtime.InteropServices
                        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)?);
index 1839144bcbcbec96b07322b7330268ff29a1a466..3297ac2342a84dd961e621ae968f04260d124739 100644 (file)
@@ -100,8 +100,10 @@ namespace System.Runtime.Loader
                {               
                }
 
+#pragma warning disable 67
                public event Func<AssemblyLoadContext, System.Reflection.AssemblyName, System.Reflection.Assembly> Resolving;
                public event Action<AssemblyLoadContext> Unloading;
+#pragma warning restore
        }
 }
 
index 0b267eed10646f58dc1e530c79fba21f2bb65464..b0eef4e4c0e4a72bd38995c925c2c1baf9038df2 100644 (file)
@@ -437,7 +437,9 @@ namespace System.Runtime.Remoting.Messaging {
        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;
index b951a8141d5d38927a3798202cdfae98f9751474..ab14ac5a5eb4cd9cb0e1230e8feecc7f48f159f8 100644 (file)
@@ -38,7 +38,9 @@ namespace System.Security.AccessControl
        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,
@@ -47,7 +49,9 @@ namespace System.Security.AccessControl
                internal NativeObjectSecurity (CommonSecurityDescriptor securityDescriptor, ResourceType resourceType)
                        : base (securityDescriptor)
                {
+#if !MOBILE                    
                        resource_type = resourceType;
+#endif
                }
 
                protected NativeObjectSecurity (bool isContainer,
@@ -63,7 +67,9 @@ namespace System.Security.AccessControl
                        : base (isContainer)
                {
                        exception_from_error_code = exceptionFromErrorCode;
+#if !MOBILE                    
                        resource_type = resourceType;
+#endif
                }
                
                protected NativeObjectSecurity (bool isContainer,
@@ -416,12 +422,14 @@ namespace System.Security.AccessControl
                [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
        }
index 4bed60fc3b93acbda77c62ddc51f284fc284254c..93c4c2d451a93713bdd13c0579d95aaa8fc6a277 100644 (file)
@@ -166,7 +166,7 @@ namespace System.Security.AccessControl
                        SetAuditRule((AuditRule)rule);
                }
                
-               protected void Persist (SafeHandle handle)
+               protected new void Persist (SafeHandle handle)
                {
                        WriteLock ();
                        try {
index 54cc0c1b3607e186cd7fa80511c13b32f6fb082f..ce855e490521ca652be5b91b18338e50a8e354a5 100644 (file)
@@ -227,8 +227,10 @@ namespace System.Security {
                // - 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
index f3bec17722a2b9a496d06907a9358fddbcb3957e..b8c91df3940489eac573c9c2801590be6298de8d 100644 (file)
@@ -90,12 +90,20 @@ namespace System.Threading {
                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
 
@@ -116,7 +124,6 @@ namespace System.Threading {
                private InternalThread internal_thread;
                object m_ThreadStartArg;
                object pending_exception;
-               int priority = (int) ThreadPriority.Normal;
                #endregion
 #pragma warning restore 414
 
index 6a43f9cd8089fdb8cbb15eaf8569454e9877210c..c8afcf1ec60567a07a651d173cb5374147adde2e 100644 (file)
@@ -97,13 +97,10 @@ namespace System
                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 ());
index bbe43954a3b0f5d452c4f0eab50dce08280871ed..7b10091733fc45bc3ca209b9176aa842b5569925 100644 (file)
@@ -57,7 +57,7 @@ namespace System {
                 * 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)]
diff --git a/mcs/class/corlib/System/GC.cs b/mcs/class/corlib/System/GC.cs
deleted file mode 100644 (file)
index a673419..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-//
-// 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 ();
-       }
-}
diff --git a/mcs/class/corlib/System/GCCollectionMode.cs b/mcs/class/corlib/System/GCCollectionMode.cs
deleted file mode 100644 (file)
index 0134db6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// 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
-       }
-}
diff --git a/mcs/class/corlib/System/GCNotificationStatus.cs b/mcs/class/corlib/System/GCNotificationStatus.cs
deleted file mode 100644 (file)
index d48dab5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// 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
-       }
-}
index ff6cc88a8096815dc51967017dd6bd835d5a894e..d849b03f8d66dbb4a2106a95baaa950e044ef286 100644 (file)
@@ -1556,22 +1556,52 @@ namespace System {
                                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
index 45475e910b5caebc26b28d8ce92b16e5b026b2ef..fa9f73a4dc68eea801f8bd30ccb0a5cee801e8b6 100644 (file)
@@ -553,11 +553,10 @@ namespace System {
                                        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);
                                }
                        }
                        
index 592f1d2f300adcf2d98d8c8712f1448ee240705d..f8e54b7fb85cbcd14606b9bc3db77ce7ddbfed80 100644 (file)
@@ -105,10 +105,10 @@ namespace System
 
                        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;
                        }
@@ -811,9 +811,16 @@ namespace System
                                        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;
@@ -958,12 +965,17 @@ namespace System
                        } 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;
                                }
 
@@ -1172,16 +1184,27 @@ namespace System
                                        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;
                        }
index 0e5487efdd22228ca182d2520ef3fb1f0b203802..0723d17161109a03f0d53cf8cc7b7ff7a4527f79 100644 (file)
@@ -98,6 +98,13 @@ namespace MonoTests.System.Security.AccessControl
                                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);
                        }
index 5149ece6900f034409ae09a0ef9558d292894388..ee3e58860494f861de1c6acc820572100cd83c4c 100644 (file)
@@ -20,6 +20,7 @@ namespace MonoTests.System.Threading
                {\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
@@ -63,7 +64,12 @@ namespace MonoTests.System.Threading
 \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
@@ -137,7 +143,7 @@ namespace MonoTests.System.Threading
                }\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
@@ -148,9 +154,11 @@ namespace MonoTests.System.Threading
                        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
index 2fc0a6dd01d6963dfb8ae777ca494622d2dcee12..593edcf65c69780f331dae72e4e353651dbf87a2 100644 (file)
@@ -28,6 +28,7 @@
 
 
 using System;
+using System.Collections.Generic;
 using System.Threading;
 
 using NUnit.Framework;
@@ -395,6 +396,148 @@ namespace MonoTests.System.Threading {
                        }
                }
 
+               [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 ()
index a22b17ebb5b8d377d9314fbe848cc6434640dd2b..ae383e310dd76adc68a779e9969f1df4c7e0ffe5 100644 (file)
@@ -2646,7 +2646,7 @@ namespace MonoTests.System
                }
 
                [Test]
-               [Culture ("en-us")]
+               [SetCulture ("en-us")]
                public void ToUniversalTime_TimeZoneOffsetShouldNotOverflow ()
                {
                        var m = DateTime.MaxValue;
@@ -2662,7 +2662,7 @@ namespace MonoTests.System
                        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");
index 3ef265c7b4d82ac2d24fd7207a5d1b2141fcc518..261e9b5692537a0593711614e27b619b917e3637 100644 (file)
@@ -496,7 +496,7 @@ namespace MonoTests.System
                }
                
                [Test]
-               [Culture ("en")]
+               [SetCulture ("en")]
                public void TestParse()
                {
                    // Boolean Decimal.TryParse(String, NumberStyles, IFormatProvider, Decimal)
@@ -810,7 +810,7 @@ namespace MonoTests.System
                }
                
                [Test]
-               [Culture ("en")]
+               [SetCulture ("en")]
                public void TestToString()
                {
                    // String Decimal.ToString()
@@ -865,7 +865,7 @@ namespace MonoTests.System
                }
                
                [Test]
-               [Culture ("en")]
+               [SetCulture ("en")]
                public void TestNumberBufferLimit()
                {
                    Decimal dE = 1234567890123456789012345.6785m;
index 45d7ee110519c0c7a01f1d5e155b064f5f965eb0..81b2a5fdb2a45300da291b23c2e54d7a5714d113 100644 (file)
@@ -147,7 +147,7 @@ namespace MonoTests.System
                }
 
                [Test]
-               [Culture ("en-US")]
+               [SetCulture ("en-US")]
                public void Parse ()
                {
                        int i = 0;
diff --git a/mcs/class/corlib/Test/System/GCTest.cs b/mcs/class/corlib/Test/System/GCTest.cs
new file mode 100644 (file)
index 0000000..6ce65b4
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// 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
index 62ae67cfc814755576e69e8a862864bc5bc71e36..ed45adfb13775ec29015ce83e62cfed9d4503b36 100644 (file)
@@ -82,8 +82,6 @@ namespace MonoTests.System
                        [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);
index 5e3811bca0019d8a6964049b9387ea5943157eff..27c167f04862d3d763272eb03a92d4e8c2bf5fa8 100644 (file)
@@ -43,6 +43,39 @@ namespace MonoTests.System
                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) {
@@ -70,8 +103,6 @@ namespace MonoTests.System
                        [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);
@@ -262,8 +293,6 @@ namespace MonoTests.System
                        [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");
@@ -273,8 +302,6 @@ namespace MonoTests.System
                        [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);
@@ -315,12 +342,7 @@ namespace MonoTests.System
                        [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);
@@ -354,16 +376,87 @@ namespace MonoTests.System
                        [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);
@@ -415,8 +508,6 @@ namespace MonoTests.System
                        [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);  
                        }
                
@@ -438,8 +529,6 @@ namespace MonoTests.System
                        [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);
@@ -448,8 +537,6 @@ namespace MonoTests.System
                        [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);
@@ -475,8 +562,6 @@ namespace MonoTests.System
                        [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);        
                        }
                
@@ -507,8 +592,6 @@ namespace MonoTests.System
                        [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);
@@ -557,10 +640,7 @@ namespace MonoTests.System
                        [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]
@@ -607,11 +687,7 @@ namespace MonoTests.System
                        [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
@@ -650,19 +726,8 @@ namespace MonoTests.System
                        [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);
@@ -735,8 +800,6 @@ namespace MonoTests.System
                        [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)));
@@ -746,8 +809,6 @@ namespace MonoTests.System
                        [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)));
@@ -777,8 +838,6 @@ namespace MonoTests.System
                        [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");
@@ -787,11 +846,9 @@ namespace MonoTests.System
                        [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");
@@ -832,72 +889,56 @@ namespace MonoTests.System
                        [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));
                        }
 
@@ -967,9 +1008,7 @@ namespace MonoTests.System
                        [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);
                        }
@@ -977,9 +1016,7 @@ namespace MonoTests.System
                        [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);
@@ -1214,11 +1251,7 @@ namespace MonoTests.System
                        [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});
 
@@ -1227,6 +1260,18 @@ namespace MonoTests.System
                                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 ()
                        {
index 409e62066b5f4a5a9cbd133ddff09a8a535fe598..d93258fbe1562310156d9ef0bfb2ecf62760b9e6 100644 (file)
@@ -23,8 +23,8 @@ public class TimeZoneTest {
 
        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");
@@ -55,9 +55,8 @@ public class TimeZoneTest {
 
        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");
@@ -174,6 +173,7 @@ public class TimeZoneTest {
        {
                TimeZone t1 = TimeZone.CurrentTimeZone;
                switch (t1.StandardName) {
+                       case "W. Europe Standard Time":
                        case "CET":
                                CET (t1);
                                break;
@@ -320,9 +320,9 @@ public class TimeZoneTest {
                [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");
                }
 
index 1e38f069af2b809045fa4e4cb2b686d035553a3f..1f408618bee270e7bb5c65ea1ace8861b925449e 100644 (file)
@@ -266,6 +266,7 @@ namespace MonoTests.System
 #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 ()
@@ -1834,8 +1835,8 @@ namespace MonoTests.System
 
                        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");
index 6e253d6ff77128c7e034d704e67e2fde23434eb6..3808a5985572150b5f06eabd3f67149a42bc9401 100644 (file)
@@ -105,9 +105,6 @@ System/DomainManagerInitializationFlags.cs
 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
@@ -310,6 +307,20 @@ System.Reflection.Emit/StringToken.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
@@ -900,6 +911,7 @@ ReferenceSources/win32native.cs
 ReferenceSources/SharedStatics.cs
 ReferenceSources/SecurityContext.cs
 ReferenceSources/PathInternal.cs
+ReferenceSources/BinaryCompatibility.cs
 
 ../referencesource/mscorlib/system/__filters.cs
 ../referencesource/mscorlib/system/__hresults.cs
@@ -965,6 +977,7 @@ ReferenceSources/PathInternal.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
@@ -1557,7 +1570,6 @@ ReferenceSources/PathInternal.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
index bfa344cf598ae671dca5b6e25920aebe05be733e..bc43d92b9202a4dd44bdfb2a61ad24b4f04e4e2a 100644 (file)
@@ -22,6 +22,7 @@ System/CharCategoryTest.cs
 System/CharEnumeratorTest.cs
 System/CharTest.cs
 System/DelegateTest.cs
+System/GCTest.cs
 System/ModuleHandleTest.cs
 System/NullableTest.cs
 System/ObsoleteAttributeTest.cs
index 42743232cf72ab204be6f1ea18589b80d6eb29e1..49e6c040ee7e8e9ba4ea1fda118f3390c05e7d82 100644 (file)
@@ -247,7 +247,7 @@ namespace System.Net {
         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
index 2a0102e8c57e11c654e1996120fd29cb04c76fdb..37f19b3aa8e1d599f442232477d4cc73f86437be 100644 (file)
@@ -26,7 +26,9 @@ namespace System.Windows.Markup
     /// 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>
index 1f90f34978a6b874579766d3f57d652cd191885e..6050d716ac1b6f0d5d7ae341bd679b88dd2fce82 100644 (file)
@@ -27,11 +27,12 @@ namespace System {
         , IComparable<Boolean>,  IEquatable<Boolean>
 #endif
     {
-    
+#pragma warning disable 649    
       //
       // Member Variables
       //
       private bool m_value;
+#pragma warning disable
 
       // The true value. 
       // 
index a5bb9e9c06df9057b61c7715ceade349c4481be1..c1a043d04b09ab8f2bd994096ab494bd266ef807 100644 (file)
@@ -910,7 +910,9 @@ namespace System.Collections.Generic {
             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);
index ce8bafab2deef044445d927a8898f6424e28abe6..4767195da3cf472f95631b2e33ccce96be7ddf11 100644 (file)
@@ -2445,9 +2445,8 @@ namespace System {
             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.
index a4d5858e9ecddca1d47d729104352d351ceff953..dcc15f55ededabd0d03d75d548d3c77511076a8f 100644 (file)
@@ -65,6 +65,28 @@ namespace System {
 
     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)]
@@ -139,6 +161,7 @@ namespace System {
         [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) {
@@ -153,7 +176,11 @@ namespace System {
             }
             Contract.EndContractBlock();
 
+#if MONO
+            RecordPressure (bytesAllocated);
+#else
             _AddMemoryPressure((ulong)bytesAllocated);
+#endif
         }
 
         [System.Security.SecurityCritical]  // auto-generated_required
@@ -169,7 +196,11 @@ namespace System {
             }
             Contract.EndContractBlock();
 
+#if MONO
+            RecordPressure (-bytesAllocated);
+#else
             _RemoveMemoryPressure((ulong) bytesAllocated);
+#endif
         }
 
 
@@ -198,8 +229,12 @@ namespace System {
         //
         [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
@@ -248,7 +283,11 @@ namespace System {
                 iInternalModes |= (int)InternalGCCollectionMode.NonBlocking;
             }
 
+#if MONO
+            InternalCollect (generation);
+#else
             _Collect(generation, iInternalModes);
+#endif
         }
 
         [System.Security.SecuritySafeCritical]  // auto-generated
@@ -260,9 +299,15 @@ namespace System {
                 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)]
@@ -275,6 +320,7 @@ namespace System {
             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 
@@ -318,9 +364,16 @@ namespace System {
         //
         [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.
@@ -330,17 +383,23 @@ namespace System {
             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.
@@ -380,6 +439,31 @@ namespace System {
         // 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();
@@ -416,6 +500,7 @@ namespace System {
 
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         private static extern int _WaitForFullGCComplete(int millisecondsTimeout);
+#endif
 
         [SecurityCritical]
         public static void RegisterForFullGCNotification(int maxGenerationThreshold, int largeObjectHeapThreshold)
@@ -503,6 +588,9 @@ namespace System {
         [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", 
@@ -512,6 +600,7 @@ namespace System {
             else if (status == StartNoGCRegionStatus.NotEnoughMemory)
                 return false;
             return true;
+#endif
         }
 
         [SecurityCritical]
@@ -541,6 +630,9 @@ namespace System {
         [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");
@@ -550,6 +642,7 @@ namespace System {
                 throw new InvalidOperationException("Allocated memory exceeds specified memory for NoGCRegion mode");
 
             return EndNoGCRegionStatus.Succeeded;
+#endif
         }
 
         [SecurityCritical]
index c8e2ce17d893a329aa26dfa2e106735ede65d767..77d17717ffdf52f9a1d9ce97e34fad32b141b0ff 100644 (file)
@@ -46,7 +46,9 @@ namespace System.Globalization {
         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]
index 29c4cd43def3f451254fadfe32bc9b4d7cbb1dc4..147ef7382e1b349d631e9834a24caebff0d7bdb9 100644 (file)
@@ -103,11 +103,13 @@ namespace System.Globalization {
         [NonSerialized] 
         private String m_sortName; // The name that defines our behavior
 
+#if !MONO
         [NonSerialized]
         private IntPtr m_dataHandle;
 
         [NonSerialized]
         private IntPtr m_handleOrigin;
+#endif
 
         ////////////////////////////////////////////////////////////////////////
         //
@@ -258,8 +260,10 @@ namespace System.Globalization {
         // 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]
@@ -1143,12 +1147,17 @@ namespace System.Globalization {
             {
                 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";
             }
index cc6bc05d4d040352118265e0dea3270c9253a790..7c03df01a4c5f9072065355c954d3e1ae956b871 100644 (file)
@@ -398,6 +398,7 @@ namespace System.Globalization {
         [OptionalField(VersionAdded = 1)]
         private bool   m_useUserOverride;
 #if !FEATURE_CORECLR
+#pragma warning disable 169
         [OptionalField(VersionAdded = 1)]
         private bool bUseCalendarInfo;
         [OptionalField(VersionAdded = 1)]
@@ -406,6 +407,7 @@ namespace System.Globalization {
         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
@@ -1515,10 +1517,11 @@ namespace System.Globalization {
                 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 {
index da422367d637dc6a26c15d3e0a8941355ac41088..991ac5117029a5071717bee473bbd049bed9c4e9 100644 (file)
@@ -4001,8 +4001,10 @@ new DS[] { DS.ERROR, DS.TX_NNN,  DS.TX_NNN,  DS.TX_NNN,  DS.ERROR,   DS.ERROR,
             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') {
index 911106e2022ccdab471cef916f02829a62370063..de0dc9b78b8374eae639732a62e331c55558e586 100644 (file)
@@ -164,10 +164,13 @@ namespace System.Globalization {
         [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
@@ -249,9 +252,10 @@ namespace System.Globalization {
                     registryEraRanges[i].maxEraYear = registryEraRanges[i-1].yearOffset + 1 - registryEraRanges[i].yearOffset;
                 }
             }
-#endif
+
             // Return our ranges
             return registryEraRanges;
+#endif            
         }
 
         //
index 577047c3f87ca0565f40c270fad581880d565eb9..b9069bba54a5b6f507238c76ba76b445d72da845 100644 (file)
@@ -30,7 +30,9 @@ namespace System.Globalization {
             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);
index 3357589278655c7731f6f5c03311a88d15a26e31..bccfd3b510df28bd6b1779fbad2d36c9357d98de 100644 (file)
@@ -421,7 +421,7 @@ namespace System.IO {
             // put in InternalReadChars.   
             int charsRead = 0;
             int numBytes = 0;
-            long posSav = posSav = 0;
+            long posSav = 0;
             
             if (m_stream.CanSeek)
                 posSav = m_stream.Position;
index cf65efb2cf0e341e6f15f35d0b2f6dd804f88afd..aab4fe9497568f6ad79cd7d0ceb1a50f9d4f01e1 100644 (file)
@@ -97,7 +97,9 @@ namespace System.IO {
             [System.Security.SecuritySafeCritical]
             get 
             {
+#pragma warning disable 219
                 String demandDir;
+#pragma warning restore
                 if (this is DirectoryInfo)
                     demandDir = Directory.GetDemandDir(FullPath, true);
                 else
@@ -119,7 +121,9 @@ namespace System.IO {
             [System.Security.SecurityCritical]
             get
             {
+#pragma warning disable 219
                 String demandDir;
+#pragma warning restore
                 if (this is DirectoryInfo)
                     demandDir = Directory.GetDemandDir(FullPath, true);
                 else
index 699d4f7e76b50809826b31b0757c44337dbd318e..795ccabed01d42bd111e061f15b870270ec5352b 100644 (file)
@@ -32,8 +32,10 @@ namespace System.IO {
         // 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")) {
index f18a310acd80224e8e540dd7ca13ce167ad5fbf9..64f0dfcd349f7fcace0bfcd2fc6e6256883076d1 100644 (file)
@@ -240,9 +240,11 @@ namespace System.IO
                 // 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
index 6c65371dcd94feb4678c3f02a6b70b1148e720d1..df2870092b06d52b6e8283bfb1319c195fc2bdd0 100644 (file)
@@ -563,8 +563,9 @@ namespace System.Resources {
             // 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
index 2a66d2394195194499a05d015fcc2ea52fceddfc..3e10b394fb9cda09834a5413fef128e7aa16d9ed 100644 (file)
@@ -202,10 +202,12 @@ namespace System.Resources {
 
         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.
@@ -269,8 +271,9 @@ namespace System.Resources {
         // 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()
index b1b8e3e48f4f9b142298c47a377a88da38130a6c..d5d396481fa7330478470230d46e206b923708f2 100644 (file)
@@ -4619,15 +4619,14 @@ namespace System
                     #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
@@ -4660,7 +4659,9 @@ namespace System
             if (binder == null)
                 binder = DefaultBinder;
 
+#if !MONO
             bool bDefaultBinder = (binder == DefaultBinder);
+#endif
             #endregion
             
             #region Delegate to Activator.CreateInstance
index 747c0245e5b75f786e5bd49121d664942ada174e..db143c04f522a1c5a65815c32d05261e8f0e995a 100644 (file)
@@ -13,8 +13,9 @@ namespace System.Runtime.CompilerServices
     [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)        
         {
index dbb3f686c2fe185a215c610b8a0519e8c2c7fd09..2947f3877803657845293d4a296a558361472507 100644 (file)
@@ -32,11 +32,15 @@ namespace System.Runtime.ExceptionServices {
     {
         // 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)
         {
@@ -66,6 +70,7 @@ namespace System.Runtime.ExceptionServices {
 #endif
         }
 
+#if !MONO
         internal UIntPtr IPForWatsonBuckets
         {
             get
@@ -81,6 +86,7 @@ namespace System.Runtime.ExceptionServices {
                 return m_WatsonBuckets;   
             }
         }
+#endif
         
         internal object BinaryStackTraceArray
         {
@@ -90,6 +96,7 @@ namespace System.Runtime.ExceptionServices {
             }
         }
 
+#if !MONO
         internal object DynamicMethodArray
         {
             get
@@ -105,6 +112,7 @@ namespace System.Runtime.ExceptionServices {
                 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
index 396fe83d836a11f80f04a19e8cb743dc868d9523..852942e1bf743018df1c930f2981aa81dde27c87 100644 (file)
@@ -639,15 +639,23 @@ namespace System.Runtime.Serialization.Formatters.Binary{
 
     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;
@@ -657,14 +665,22 @@ namespace System.Runtime.Serialization.Formatters.Binary{
         // 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)
@@ -878,8 +894,10 @@ namespace System.Runtime.Serialization.Formatters.Binary{
                 {
                     if (callContext is String)
                         BinaryUtil.NVTraceI("callContext", (String)callContext);   
+#if FEATURE_REMOTING                        
                     else
                         BinaryUtil.NVTraceI("callContext", scallContext);   
+#endif
                 }
 
                 if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
@@ -900,10 +918,14 @@ namespace System.Runtime.Serialization.Formatters.Binary{
     {
         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;
@@ -928,9 +950,13 @@ namespace System.Runtime.Serialization.Formatters.Binary{
 
             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)
@@ -1159,8 +1185,10 @@ namespace System.Runtime.Serialization.Formatters.Binary{
                 {
                     if (callContext is String)
                         BinaryUtil.NVTraceI("callContext", (String)callContext);   
+#if FEATURE_REMOTING                        
                     else
                         BinaryUtil.NVTraceI("callContext", scallContext);   
+#endif
                 }
 
                 if (IOUtil.FlagTest(messageEnum, MessageEnum.ArgsInline))
index 28ef1f0810dac5a3ba328cc20085414c4e2d8dcf..2ae5aebb362803db1cd28bfb11606296a3ae4e4b 100644 (file)
@@ -319,7 +319,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         }
 
         internal BinaryObjectString binaryObjectString;
+#if !MONO
         internal BinaryCrossAppDomainString binaryCrossAppDomainString;
+#endif
 
         internal void WriteObjectString(int objectId, String value)
         {
@@ -397,7 +399,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         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];
@@ -689,7 +693,9 @@ if (!BitConverter.IsLittleEndian) {
 
 
         internal BinaryAssembly binaryAssembly;
+#if !MONO        
         internal BinaryCrossAppDomainAssembly crossAppDomainAssembly;
+#endif
 
         internal void WriteAssembly(Type type, String assemblyString, int assemId, bool isNew)
         {
index 53c04ba771b242ac86b05659a736cb4264efd257..c62b865c9cdd51c32c7b6df831786144c0974036 100644 (file)
@@ -15,7 +15,9 @@ namespace System.Runtime.Serialization.Formatters.Binary
     [Serializable]
     internal sealed class BinaryMethodCallMessage
     {
+#pragma warning disable 414
         Object[] _inargs = null;
+#pragma warning restore
         String _methodName = null;
         String _typeName = null;
         Object _methodSignature = null;
@@ -100,7 +102,9 @@ namespace System.Runtime.Serialization.Formatters.Binary
     [Serializable]
     internal class BinaryMethodReturnMessage
     {
+#pragma warning disable 414
         Object[] _outargs = null;
+#pragma warning restore
         Exception _exception = null;
         Object _returnValue = null;
 
index fd5131e8e061f7980638fe85c32d454853210bfb..0205e307d156e8142e6fe431fbf3333a03b8ef4a 100644 (file)
@@ -50,7 +50,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         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
@@ -669,7 +671,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         {
             SerTrace.Log( this, "ParseArray Entry");
 
+#if !MONO
             long genId = pr.PRobjectId;
+#endif
 
             if (pr.PRarrayTypeEnum == InternalArrayTypeE.Base64)
             {
@@ -1055,9 +1059,11 @@ namespace System.Runtime.Serialization.Formatters.Binary {
 
 
             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);
@@ -1523,7 +1529,9 @@ namespace System.Runtime.Serialization.Formatters.Binary {
                     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
index 569c1a38bdc5080a6f234a09f8806e3e2c0b91b9..3da9e497a834f502438bcd52aad12c6aabaf9ad2 100644 (file)
@@ -354,8 +354,8 @@ namespace System.Runtime.Serialization.Formatters.Binary
         {
             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
             }
index 8d53544a067c3226d3e56523efd38af48e0eeb47..8810cb8b1cab31e61b9b3beb2e252ea30f0e25e3 100644 (file)
@@ -44,7 +44,9 @@ namespace System.Runtime.Serialization {
         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) {
@@ -60,7 +62,9 @@ namespace System.Runtime.Serialization {
             m_objects = new ObjectHolder[DefaultInitialSize];
             m_selector = selector;
             m_context = context;
+#if !FEATURE_PAL            
             m_isCrossAppDomain = isCrossAppDomain;
+#endif
         }
 
     
@@ -341,7 +345,9 @@ namespace System.Runtime.Serialization {
             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");
index 194fc21f3b95696eb5f2dcbd68edb4d55d85b52b..1974926ac9a286bdcca8885e4c8f99a729823996 100644 (file)
@@ -36,7 +36,9 @@ using System.Diagnostics.Contracts;
             // 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                
@@ -97,7 +99,9 @@ using System.Diagnostics.Contracts;
             // Invoke all OnSerializingMethods
             if (m_OnSerializingMethods != null)
             {
+#if !MONO
                 Object[] p = new Object[] {context};
+#endif
                 SerializationEventHandler handler = null;
                 foreach(MethodInfo m in m_OnSerializingMethods)
                 {
@@ -116,7 +120,9 @@ using System.Diagnostics.Contracts;
             // Invoke all OnDeserializingMethods
             if (m_OnDeserializingMethods != null)
             {
+#if !MONO
                 Object[] p = new Object[] {context};
+#endif
                 SerializationEventHandler handler = null;
                 foreach(MethodInfo m in m_OnDeserializingMethods)
                 {
@@ -135,7 +141,9 @@ using System.Diagnostics.Contracts;
             // Invoke all OnDeserializingMethods
             if (m_OnDeserializedMethods != null)
             {
+#if !MONO
                 Object[] p = new Object[] {context};
+#endif
                 SerializationEventHandler handler = null;
                 foreach(MethodInfo m in m_OnDeserializedMethods)
                 {
index 5f3a25e79b72ee61df57ce06bf256a9e1dfc6ccb..68af0d6ef3f5691f82ce935adaa299861bfd3e8d 100644 (file)
@@ -1310,7 +1310,7 @@ namespace System.Security.Claims
                 switch (enumerator.Name)
                 {
                     case VersionKey:
-                        string version = info.GetString(VersionKey);
+                        info.GetString(VersionKey);
                         break;
 
                     case AuthenticationTypeKey:
index ba6b40ec0ef3f36d54b45b18e4d03bf402a13774..cb23f7bd7a91ad6dd1b17d35d2b6468ca46425c7 100644 (file)
@@ -31,8 +31,9 @@ namespace System.Security.Cryptography {
         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 {
@@ -83,7 +84,9 @@ namespace System.Security.Cryptography {
             this.Salt = salt;
             this.HashName = hashName;
             _password = password;
+#if !MONO
             _cspParams = cspParams;
+#endif
         }
 
         //
index 84d4a66edc37b5983b897a663213d58342c98c0e..804eeda9bdac32d93a1173972e7989b8989a6352 100644 (file)
@@ -30,7 +30,9 @@ namespace System.Security.Cryptography {
         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;
index 0954818455914214f4a21c807ed7d00eea61d89b..a1b0a7786981ae8a8efedf0f5106156a16c0571a 100644 (file)
@@ -24,6 +24,7 @@ namespace System.Security.Cryptography {
     using System.Security.Permissions;
     using System.Diagnostics.Contracts;
 
+#if !MONO
     // Object layout of the RSAParameters structure
     internal class RSACspObject {
         internal byte[] Exponent;
@@ -35,6 +36,7 @@ namespace System.Security.Cryptography {
         internal byte[] InverseQ;
         internal byte[] D;
     }
+#endif
 
     [System.Runtime.InteropServices.ComVisible(true)]
     public sealed partial class RSACryptoServiceProvider : RSA
index 46c377bdebae60fc7e70105d0cbd79f6cd76186b..c0fcae0e3d635a505539edb83a72d10b26e88ec5 100644 (file)
@@ -1338,8 +1338,10 @@ namespace System.Text {
             }
 
             while (true) {
+#if !MONO                
                 int p = pos;
                 int i = pos;
+#endif
                 while (pos < len) {
                     ch = format[pos];
 
@@ -1406,8 +1408,10 @@ namespace System.Text {
                 StringBuilder fmt = null;
                 if (ch == ':') {
                     pos++;
+#if !MONO
                     p = pos;
                     i = pos;
+#endif
                     while (true) {
                         if (pos == len) FormatError();
                         ch = format[pos];
@@ -1559,7 +1563,9 @@ namespace System.Text {
             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;
@@ -1597,7 +1603,9 @@ namespace System.Text {
                 {
                     // 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);
index 1a293330ac96feba2b9e58a6246db499fa2765db..3f2e5f608113287f596a479ec589ad0970155459 100644 (file)
@@ -1080,7 +1080,9 @@ namespace System.Threading
     /// <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>
@@ -1089,7 +1091,10 @@ namespace System.Threading
         /// <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
index 4168909f0dd17449e19e6aed3039bce3e82ce073..21ec1d7b8346d780a4a059738ca4bb8f908e7f5c 100644 (file)
@@ -858,7 +858,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //This is the original 4.0 behaviour
-                    var asyncResult = beginMethod(iar =>
+                    beginMethod(iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
@@ -995,7 +995,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //quirk for previous versions
-                    var asyncResult = beginMethod(arg1, iar =>
+                    beginMethod(arg1, iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
@@ -1141,7 +1141,7 @@ namespace System.Threading.Tasks
                 else
                 {
                     //quirk for previous versions
-                    var asyncResult = beginMethod(arg1, arg2, iar =>
+                    beginMethod(arg1, arg2, iar =>
                     {
                         FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
                     }, state);
@@ -1294,7 +1294,7 @@ namespace System.Threading.Tasks
                 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);
index 2b64b423d8e28a317807644569681db96f0c3521..89ae7f7d20e98d27c2f40234107dd5d469f715c5 100644 (file)
@@ -122,8 +122,10 @@ namespace System.Threading.Tasks
             get { return m_cancellationToken; }
             set
             {
+#if !MONO                
                 if (value == null)
                     throw new ArgumentNullException("CancellationToken");
+#endif
                 m_cancellationToken = value;
             }
         }
@@ -245,10 +247,11 @@ namespace System.Threading.Tasks
                 }
             }
 
+#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);
@@ -1095,10 +1098,11 @@ namespace System.Threading.Tasks
                 }, 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);
@@ -1418,10 +1422,11 @@ namespace System.Threading.Tasks
                 }, 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);
index 2ae0c8790457fb7f593ef9bdd4cc5f7bc0968664..d37a6e7c1b5c8162cb77167ebc2e76d7d8840bed 100644 (file)
@@ -412,7 +412,9 @@ namespace System.Threading.Tasks
     /// </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;
@@ -439,7 +441,9 @@ namespace System.Threading.Tasks
             {
                 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;
                 }
index 522db85b2f0833793dbe86928b6b0c5769c3196c..6b11de5616f16f1cd2dddb2d6a42ef84945bad69 100644 (file)
@@ -550,7 +550,9 @@ namespace System.Threading.Tasks
         /// <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>
index cf9bdf17b1b19f95123dc8b0e424c6d3c2aea8ce..2d602aac3439ccaa5b53eef75cbb317ae4008821 100644 (file)
@@ -122,8 +122,9 @@ namespace System.Threading
                 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) {
index 13e1e31a9767216974fb004458de09cd2d167fff..79ca731df46141499b85b059d03ae3ea729145e3 100644 (file)
@@ -579,7 +579,9 @@ namespace System.Threading
         // 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); //
 
index 8aad5bb3a61236af796230cbec40949294609e96..80bef5ab852b2b77947bdeca47d7f8ce38d1b0f0 100644 (file)
@@ -22,7 +22,9 @@ namespace System {
     public struct TypedReference
     {
 #if MONO
+#pragma warning disable 169
         RuntimeTypeHandle type;
+#pragma warning restore
 #endif
         private IntPtr Value;
         private IntPtr Type;
diff --git a/mcs/errors/cs0029-37.cs b/mcs/errors/cs0029-37.cs
new file mode 100644 (file)
index 0000000..80f8e8c
--- /dev/null
@@ -0,0 +1,24 @@
+// 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
diff --git a/mcs/errors/cs0122-39.cs b/mcs/errors/cs0122-39.cs
new file mode 100644 (file)
index 0000000..f7da1f9
--- /dev/null
@@ -0,0 +1,15 @@
+// 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
diff --git a/mcs/errors/cs0219-7.cs b/mcs/errors/cs0219-7.cs
new file mode 100644 (file)
index 0000000..ca40a59
--- /dev/null
@@ -0,0 +1,11 @@
+// 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
diff --git a/mcs/errors/cs0619-59.cs b/mcs/errors/cs0619-59.cs
new file mode 100644 (file)
index 0000000..b703b0e
--- /dev/null
@@ -0,0 +1,18 @@
+// 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;
+}
diff --git a/mcs/errors/cs1070-3.cs b/mcs/errors/cs1070-3.cs
new file mode 100644 (file)
index 0000000..18811dc
--- /dev/null
@@ -0,0 +1,11 @@
+// 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
diff --git a/mcs/errors/cs1501-19.cs b/mcs/errors/cs1501-19.cs
new file mode 100644 (file)
index 0000000..68095c1
--- /dev/null
@@ -0,0 +1,26 @@
+// 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);
+}
index 3bcaf26e36f5aac24a8d3bdb39599aef25370dcb..e5d0b1f173584fe1676d1379efa1df8a35346731 100644 (file)
@@ -297,6 +297,10 @@ namespace Mono.CSharp
                                                throw new InternalErrorException (tc, e);
                                        }
                                }
+
+                               if (PartialContainer != null && PartialContainer != this) {
+                                       containers = null;
+                               }
                        }
 
                        return true;
@@ -1661,6 +1665,8 @@ namespace Mono.CSharp
 
                public override void ExpandBaseInterfaces ()
                {
+                       DoResolveTypeParameters ();
+
                        if (!IsPartialPart)
                                DoExpandBaseInterfaces ();
 
@@ -1766,8 +1772,6 @@ namespace Mono.CSharp
                protected override void DoDefineContainer ()
                {
                        DefineBaseTypes ();
-
-                       DoResolveTypeParameters ();
                }
 
                //
index a0ae78cdf518e42737b571c830e08a99adf00747..acec3be3588b60665439f60a90ff92f2e45f933a 100644 (file)
@@ -2149,11 +2149,6 @@ namespace Mono.CSharp {
                        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 ();
@@ -2169,9 +2164,9 @@ namespace Mono.CSharp {
                                        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;
                        }
@@ -2197,20 +2192,9 @@ namespace Mono.CSharp {
                                        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);
                                }
 
                                //
index 42eba97ee475763eb15186ea8a25bbe36fc1fca9..edc860eca83b595e90b61975654147dbd691c4e9 100644 (file)
@@ -841,22 +841,29 @@ namespace Mono.CSharp {
                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)
@@ -901,15 +908,6 @@ namespace Mono.CSharp {
 
                                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);
                                        }
 
@@ -959,57 +957,6 @@ namespace Mono.CSharp {
                        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");
@@ -3701,6 +3648,11 @@ namespace Mono.CSharp {
                        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));
@@ -3776,7 +3728,7 @@ namespace Mono.CSharp {
                // 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
@@ -3805,27 +3757,9 @@ namespace Mono.CSharp {
                                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)
@@ -4226,6 +4160,17 @@ namespace Mono.CSharp {
                        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;
@@ -4233,9 +4178,19 @@ namespace Mono.CSharp {
 
                #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)
@@ -5632,7 +5587,7 @@ namespace Mono.CSharp {
                                                // 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
@@ -6196,6 +6151,11 @@ namespace Mono.CSharp {
                        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);
@@ -6425,6 +6385,11 @@ namespace Mono.CSharp {
                        return this;
                }
 
+               public override void ResolveNameOf (ResolveContext rc, ATypeNameExpression expr)
+               {
+                       spec.CheckObsoleteness (rc, expr.Location);
+               }
+
                public void SetFieldAssigned (FlowAnalysisContext fc)
                {
                        if (!IsInstance)
@@ -7195,6 +7160,14 @@ namespace Mono.CSharp {
                        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) {
@@ -7616,6 +7589,11 @@ namespace Mono.CSharp {
                        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);
index 2a9aa97fed0e62be46728b7c4dccb871de0ff0cc..2968ee08584f544f7869efba43e4007b9f259888 100644 (file)
@@ -3110,9 +3110,9 @@ namespace Mono.CSharp
                        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;
@@ -10952,9 +10952,18 @@ namespace Mono.CSharp
 
                #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)
@@ -12353,6 +12362,7 @@ namespace Mono.CSharp
                        int errors = ec.Report.Errors;
                        type.CreateContainer ();
                        type.DefineContainer ();
+                       type.ExpandBaseInterfaces ();
                        type.Define ();
                        if ((ec.Report.Errors - errors) == 0) {
                                parent.Module.AddAnonymousType (type);
index b34f2dc1ec56dfbadb8ff468da7940d1f49b3ca4..48d2dc01b96c28e35cd2981830306cdbef1d0302 100644 (file)
@@ -773,6 +773,7 @@ namespace Mono.CSharp {
                TypeSpec[] targs;
                TypeSpec[] ifaces_defined;
                TypeSpec effective_base;
+               MemberCache interface_cache;
 
                //
                // Creates type owned type parameter
@@ -882,6 +883,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public MemberCache InterfaceCache {
+                       get {
+                               return interface_cache;
+                       }
+               }
+
                //
                // Unexpanded interfaces list
                //
@@ -1351,13 +1358,27 @@ namespace Mono.CSharp {
                        // 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);
                                }
                        }
 
@@ -1370,8 +1391,14 @@ namespace Mono.CSharp {
                                        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);
                                                }
                                        }
                                }
index 60073b9f4c1338929c6098c9a28f861d36534132..9518427e1a17c1fe1499516410ea4c9fde28a893 100644 (file)
@@ -142,6 +142,7 @@ namespace Mono.CSharp
                        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
@@ -154,6 +155,8 @@ namespace Mono.CSharp
 
                public bool IgnorePrivateMembers { get; set; }
 
+               public bool IgnoreCompilerGeneratedField { get; set; }
+
                #endregion
 
                public abstract void AddCompiledType (TypeBuilder builder, TypeSpec spec);
@@ -179,8 +182,10 @@ namespace Mono.CSharp
                                        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;
index 8ada0a97071a327cd2c8433a09eb654d904633bd..27b7f586932c7d01e355f5bc2745512d5cb07a1a 100644 (file)
@@ -406,8 +406,13 @@ namespace Mono.CSharp {
 
                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--) {
@@ -438,6 +443,26 @@ namespace Mono.CSharp {
                                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;
                }
 
@@ -450,9 +475,9 @@ namespace Mono.CSharp {
                //
                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;
 
@@ -462,6 +487,17 @@ namespace Mono.CSharp {
                        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
                //
index 8036f2c1126a56319198464e021386325110ca10..6b1990e1f0983d87bd8b91d0f60dee7efe51129c 100644 (file)
@@ -1210,12 +1210,11 @@ namespace Mono.CSharp
 
                        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 ();
index 0c199017af9b1d4e3e19624afb3563ee9b7705ca..5a76b965889697d1462b92b3b08540348942ee71 100644 (file)
@@ -1228,6 +1228,8 @@ namespace Mono.CSharp {
                        case "/pdb":
                        case "/preferreduilang":
                        case "/publicsign":
+                       case "/publicsign+":
+                       case "/publicsign-":
                        case "/reportanalyzer":
                        case "/ruleset":
                        case "/sqmsessionguid":
index 7f54b33eeb599c16146c7adfcc0c2e12b3d5beaf..b644e126dc1cecfab235cb03d5bac052d7c0b74e 100644 (file)
@@ -2280,6 +2280,9 @@ namespace Mono.CSharp {
 
                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
                }
 
@@ -2438,6 +2441,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool IsUsed {
+                       get {
+                               return (flags & Flags.Used) != 0;
+                       }
+               }
+
                public bool IsFixed {
                        get {
                                return (flags & Flags.FixedVariable) != 0;
@@ -2527,8 +2536,10 @@ namespace Mono.CSharp {
 
                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);
                }
@@ -3258,6 +3269,7 @@ namespace Mono.CSharp {
                        //
                        storey.CreateContainer ();
                        storey.DefineContainer ();
+                       storey.ExpandBaseInterfaces ();
 
                        if (Original.Explicit.HasCapturedThis && Original.ParametersBlock.TopBlock.ThisReferencesFromChildrenBlock != null) {
 
index fb02370dbb32cd2317827d323637b370d01e0048..696bde556c820ad00f9d206bac897e80c10ee470 100644 (file)
@@ -109,7 +109,6 @@ namespace Mono.CSharp
                                        var imported = MemberDefinition as ImportedTypeDefinition;
                                        if (imported != null && Kind != MemberKind.MissingType)
                                                imported.DefineInterfaces (this);
-
                                }
 
                                return ifaces;
@@ -1603,6 +1602,12 @@ namespace Mono.CSharp
 
                public TypeSpec Element { get; private set; }
 
+               public override IList<TypeSpec> Interfaces {
+                       set {
+                               throw new NotSupportedException ();
+                       }
+               }
+
                bool ITypeDefinition.IsComImport {
                        get {
                                return false;
@@ -1777,13 +1782,19 @@ namespace Mono.CSharp
                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;
@@ -1926,7 +1937,6 @@ namespace Mono.CSharp
                        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);
                        }
@@ -1942,11 +1952,17 @@ namespace Mono.CSharp
 
        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) {
@@ -1977,6 +1993,12 @@ namespace Mono.CSharp
                        state &= ~StateFlags.CLSCompliant_Undetected;
                }
 
+               public override IList<TypeSpec> Interfaces {
+                       get {
+                               return null;
+                       }
+               }
+
                public override MetaType GetMetaInfo ()
                {
                        if (info == null) {
diff --git a/mcs/tests/gtest-638.cs b/mcs/tests/gtest-638.cs
new file mode 100644 (file)
index 0000000..cadf272
--- /dev/null
@@ -0,0 +1,17 @@
+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
diff --git a/mcs/tests/gtest-639.cs b/mcs/tests/gtest-639.cs
new file mode 100644 (file)
index 0000000..afc0b20
--- /dev/null
@@ -0,0 +1,47 @@
+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
index 1971d2f4e4812fa82feb8fbed1c666537ce0a723..36453ea86b397061250c48d9d7b086bc1dca1d8d 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using System.Reflection;
+using System.Runtime.CompilerServices;
 
 [assembly: Test]
 
@@ -130,7 +131,8 @@ public class ClassMain
                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);
@@ -139,7 +141,8 @@ public class ClassMain
                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);
@@ -148,7 +151,8 @@ public class ClassMain
                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);
@@ -159,7 +163,8 @@ public class ClassMain
                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;
        }
diff --git a/mcs/tests/test-940.cs b/mcs/tests/test-940.cs
new file mode 100644 (file)
index 0000000..d7c68f0
--- /dev/null
@@ -0,0 +1,31 @@
+// 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
diff --git a/mcs/tests/test-partial-35.cs b/mcs/tests/test-partial-35.cs
new file mode 100644 (file)
index 0000000..ba51245
--- /dev/null
@@ -0,0 +1,19 @@
+partial class A
+{
+}
+
+partial class A
+{
+       enum E
+       {
+               None = 0,
+               All = 1
+       }
+}
+
+class X
+{
+       public static void Main ()
+       {
+       }
+}
\ No newline at end of file
index 67147f16a7725c577a9bc49dba24b87f69d56296..df5884f7fe914d2177021945f3f5aebe91ca4cc1 100644 (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">
index 7636c2b204f4e6ed8cfc300f30bbe2ccca2e6268..c52c95f46cf42bc74740f9202061caba4e806504 100644 (file)
@@ -1155,11 +1155,14 @@ namespace CorCompare
                                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");
@@ -1538,17 +1541,6 @@ namespace CorCompare
 
                                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));
                        }
 
index f98314ecec7afb9db0957bb70edde80431c647b9..ff66d61364ca057147d7539772b5b7286c5628ea 100644 (file)
@@ -2,8 +2,8 @@ thisdir = tools/gacutil
 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
 
index 13f686e22c64ec5dadc09c136838db3ed7c74a43..47c4ac8df96bd44da12af6c98d5309da235cbc89 100644 (file)
@@ -14,7 +14,6 @@ using System;
 using System.IO;
 using System.Diagnostics;
 using System.Text;
-using System.Reflection;
 using System.Collections;
 using System.Globalization;
 using System.Runtime.InteropServices;
@@ -23,6 +22,8 @@ using System.Security.Cryptography;
 using Mono.Security;
 using Mono.Security.Cryptography;
 
+using IKVM.Reflection;
+
 namespace Mono.Tools {
 
        public class Driver {
@@ -48,6 +49,7 @@ namespace Mono.Tools {
 
                private static bool silent;
                static bool in_bootstrap;
+               private static Universe _universe;
 
                public static int Main (string [] args)
                {
@@ -244,7 +246,7 @@ namespace Mono.Tools {
                        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;
@@ -744,12 +746,27 @@ namespace Mono.Tools {
                        }
                }
 
+               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
@@ -763,12 +780,6 @@ namespace Mono.Tools {
                        } 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;
@@ -800,8 +811,8 @@ namespace Mono.Tools {
 
                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);
@@ -832,7 +843,7 @@ namespace Mono.Tools {
 
                        // 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)) {
@@ -899,20 +910,20 @@ namespace Mono.Tools {
                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");
index 911afaf9d8219cd369a76a6269e559c1429cd238..4772378b43cb3ad9898901b636de031cacd48cbc 100644 (file)
@@ -1,2 +1,9 @@
 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
index 702d74d16a7dd43ecab4b9be6f71f9017fe6f755..cc891536b8af26f751fb8fa1aebc08c5a5a42487 100755 (executable)
@@ -23,7 +23,6 @@ using System.Runtime.InteropServices;
 using System.Text;
 using IKVM.Reflection;
 using System.Linq;
-using System.Diagnostics;
 using System.Net;
 using System.Threading.Tasks;
 
@@ -31,6 +30,7 @@ class MakeBundle {
        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;
@@ -126,6 +126,33 @@ class MakeBundle {
                                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 (); 
@@ -289,7 +316,7 @@ class MakeBundle {
                                        return 1;
                                }
                                var env = args [++i];
-                               var p = env.IndexOf ('=');
+                               p = env.IndexOf ('=');
                                if (p == -1)
                                        environment.Add (env, "");
                                else
@@ -585,7 +612,7 @@ class MakeBundle {
                
                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"))
@@ -602,6 +629,11 @@ class MakeBundle {
                        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;
@@ -695,7 +727,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                        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)
@@ -854,7 +886,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                                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",
@@ -1007,7 +1039,27 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
        
        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);
@@ -1015,7 +1067,7 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                        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));
@@ -1100,40 +1152,42 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
        {
                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")]
index 884bea5a114ff7b5c0f82e9ff1f912cd0d0bce52..2913fe806d04da0f3a9591c61c0389d0aaf040b9 100644 (file)
@@ -5,9 +5,9 @@ include ../../build/rules.make
 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
 
index 6cb8042e9c528e3bbcb3dd6b6710452a9dce37df..57e354026a2d88afdc2b205dbd7e284da9575ba5 100644 (file)
@@ -5,3 +5,97 @@ StackFrameData.cs
 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
index 1af061c383ad8b58abc1d42a636c8b4de55d26b1..53de00ae71577c4a902472c6a2448a648608bf62 100644 (file)
@@ -32,6 +32,7 @@
 #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);
@@ -1963,9 +1964,16 @@ usage (void)
        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;
 
@@ -2016,6 +2024,15 @@ main (int argc, char *argv [])
        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);
 
index 0eb885e055e4a843868fbcc00a1f0600a99827a1..dfb60a16c827e5db876948193eef80196708b887 100644 (file)
@@ -14,17 +14,14 @@ OTHER_H = \
        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     \
@@ -41,9 +38,6 @@ OTHER_SRC = \
        context.h               \
        error.c                 \
        error.h                 \
-       events.c                \
-       events.h                \
-       event-private.h         \
        io.c                    \
        io.h                    \
        io-portability.c        \
@@ -54,20 +48,12 @@ OTHER_SRC = \
        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        \
diff --git a/mono/io-layer/event-private.h b/mono/io-layer/event-private.h
deleted file mode 100644 (file)
index 07b35e0..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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_ */
diff --git a/mono/io-layer/events.c b/mono/io-layer/events.c
deleted file mode 100644 (file)
index 8e3fa4a..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * 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;
-
-}
diff --git a/mono/io-layer/events.h b/mono/io-layer/events.h
deleted file mode 100644 (file)
index 577f57b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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_ */
index 496efa70bf2c349b406ddb0a722b5e6f5f57a18a..661067dc7b27b1461c9ee63858da5c519e0256f2 100644 (file)
  * 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
@@ -101,12 +92,10 @@ _wapi_handle_get_or_set_share (guint64 device, guint64 inode, guint32 new_sharem
        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;
 
@@ -115,23 +104,21 @@ _wapi_handle_get_or_set_share (guint64 device, guint64 inode, guint32 new_sharem
         * 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);
@@ -147,10 +134,7 @@ _wapi_handle_get_or_set_share (guint64 device, guint64 inode, guint32 new_sharem
                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);
 }
@@ -2038,7 +2022,7 @@ write_file (int src_fd, int dest_fd, struct stat *st_src, gboolean report_errors
        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);
@@ -2049,7 +2033,7 @@ write_file (int src_fd, int dest_fd, struct stat *st_src, gboolean report_errors
                        if (report_errors)
                                _wapi_set_last_error_from_errno ();
 
-                       free (buf);
+                       g_free (buf);
                        return FALSE;
                }
                if (remain == 0) {
@@ -2065,7 +2049,7 @@ write_file (int src_fd, int dest_fd, struct stat *st_src, gboolean report_errors
                                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;
                        }
 
@@ -2074,7 +2058,7 @@ write_file (int src_fd, int dest_fd, struct stat *st_src, gboolean report_errors
                }
        }
 
-       free (buf);
+       g_free (buf);
        return TRUE ;
 }
 
@@ -4435,6 +4419,7 @@ void
 _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);
@@ -4453,8 +4438,8 @@ _wapi_io_init (void)
 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);
-       }
 }
diff --git a/mono/io-layer/mutex-private.h b/mono/io-layer/mutex-private.h
deleted file mode 100644 (file)
index 50e5b14..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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_ */
diff --git a/mono/io-layer/mutexes.c b/mono/io-layer/mutexes.c
deleted file mode 100644 (file)
index dbfe8b1..0000000
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * 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;
-}
diff --git a/mono/io-layer/mutexes.h b/mono/io-layer/mutexes.h
deleted file mode 100644 (file)
index d1b7a68..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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_ */
index 654c43771ebd5b4ad8e3bb421b227e61cca5dba0..35cd67eb5c0d60435aad18ee1a774c2ee52f94b9 100644 (file)
@@ -1476,7 +1476,7 @@ static int load_modules_callback (struct dl_phdr_info *info, size_t size, void *
            + 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);
 
@@ -1512,7 +1512,7 @@ static GSList *load_modules (void)
                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);
@@ -1911,12 +1911,12 @@ get_process_name_from_proc (pid_t pid)
        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);
@@ -1925,7 +1925,7 @@ get_process_name_from_proc (pid_t pid)
        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__)
@@ -1938,12 +1938,12 @@ get_process_name_from_proc (pid_t pid)
                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);
@@ -1951,7 +1951,7 @@ get_process_name_from_proc (pid_t pid)
 
        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;
@@ -1966,7 +1966,7 @@ retry:
                return(ret);
        }
 
-       if ((pi = malloc(size)) == NULL)
+       if ((pi = g_malloc (size)) == NULL)
                return(ret);
 
        mib[5] = (int)(size / sizeof(struct kinfo_proc));
@@ -1974,7 +1974,7 @@ retry:
        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);
@@ -1983,7 +1983,7 @@ retry:
        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;
diff --git a/mono/io-layer/semaphore-private.h b/mono/io-layer/semaphore-private.h
deleted file mode 100644 (file)
index 3c27eef..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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_ */
diff --git a/mono/io-layer/semaphores.c b/mono/io-layer/semaphores.c
deleted file mode 100644 (file)
index c473f4d..0000000
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * 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;
-}
diff --git a/mono/io-layer/semaphores.h b/mono/io-layer/semaphores.h
deleted file mode 100644 (file)
index 1cdaee0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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_ */
diff --git a/mono/io-layer/shared.c b/mono/io-layer/shared.c
deleted file mode 100644 (file)
index 8fb0e27..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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;
-}
diff --git a/mono/io-layer/shared.h b/mono/io-layer/shared.h
deleted file mode 100644 (file)
index 204f506..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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_ */
index 448232dff9ca550e7c0f81a70e5b9b23dc2b1d55..aa58ea1614f76dde7cc51478b3cc0a73b7991b40 100644 (file)
@@ -42,6 +42,8 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout, gboolean alertab
        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)
@@ -96,6 +98,8 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
        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)
@@ -143,8 +147,10 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
        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)
index ee961002d9eec7152e3741e77299836cab989d14..8b82b609d1976be0cf356e0d13904f970aa8b585 100644 (file)
@@ -16,7 +16,6 @@
 
 #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>
@@ -46,13 +37,6 @@ struct _WapiHandle_shared_ref
        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
@@ -69,18 +53,4 @@ struct _WapiFileShare
 
 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_ */
index 8f8b4ff549d87ad0e142368bf773277c4e5351d7..935d257722557872189afa90b439e60a2d57ff99 100644 (file)
 #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
@@ -57,9 +52,6 @@
 #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 
@@ -80,9 +72,6 @@
 #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 
index a9f93692400dbc03c96557e20ef08fc86a7aa793..f1674179d9a194f0d2dcb4d992acbf5bb6926d3c 100644 (file)
@@ -1,13 +1,9 @@
 
 #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"
@@ -18,12 +14,8 @@ gboolean _wapi_has_shut_down = FALSE;
 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 ();
 }
 
@@ -57,82 +49,6 @@ wapi_getpid (void)
        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,
index 4e0a688063984ad671543a10f51a4bc2d27290c7..c56622ea91c003c548288148cf8c49f9998c22bd 100644 (file)
 #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>
index 88864821be44d394939dd5d19a9c87239eee38f7..013b778a86579d088ef71551af526cffb572b192 100644 (file)
@@ -267,11 +267,11 @@ globextend(const gchar *path, wapi_glob_t *pglob, size_t *limitp)
 
        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);
@@ -291,7 +291,7 @@ globextend(const gchar *path, wapi_glob_t *pglob, size_t *limitp)
        *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;
@@ -361,8 +361,8 @@ _wapi_globfree(wapi_glob_t *pglob)
                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;
        }
 }
index f49dde50193159d9d0525370300142fe2551b50c..3b8d92bb84dcb72359e34fdeece13d464bef01b4 100644 (file)
@@ -1,6 +1,9 @@
 if HOST_WIN32
 win32_sources = \
-       console-win32.c
+       console-win32.c \
+       w32mutex-win32.c \
+       w32semaphore-win32.c \
+       w32event-win32.c
 
 platform_sources = $(win32_sources)
 
@@ -23,7 +26,10 @@ else
 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
@@ -217,8 +223,13 @@ common_sources = \
        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 = \
index 79c8406d46f11f8706ebe024dfd451fcc5918e6f..13a545a67bb6b3f49605702a3fa52f135c822ee0 100644 (file)
@@ -58,6 +58,7 @@
 #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>
@@ -83,7 +84,7 @@
  * 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
 {
@@ -343,8 +344,14 @@ mono_check_corlib_version (void)
        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;
 }
 
 /**
@@ -1934,20 +1941,6 @@ mono_domain_assembly_search (MonoAssemblyName *aname,
        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)
 {
@@ -1956,40 +1949,37 @@ ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean re
        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;
 }
 
@@ -2024,11 +2014,6 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
                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);
@@ -2046,7 +2031,7 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,  MonoString *assRef,
        MonoAssembly *ass;
        MonoAssemblyName aname;
        MonoReflectionAssembly *refass = NULL;
-       gchar *name = NULL;
+       gchar *name;
        gboolean parsed;
 
        g_assert (assRef);
@@ -2055,13 +2040,16 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,  MonoString *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;
        }
@@ -2073,31 +2061,25 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,  MonoString *assRef,
                /* 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;
 }
 
@@ -2530,7 +2512,6 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
        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 ()); */
 
@@ -2587,10 +2568,7 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
         * 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;
 
@@ -2599,11 +2577,14 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc)
                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;
diff --git a/mono/metadata/assembly-internals.h b/mono/metadata/assembly-internals.h
new file mode 100644 (file)
index 0000000..5af7bd6
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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__ */
index 0744389c400bf4539c0d88f3e530df2a95436b6e..64d1000bbb63b8f896164af207e176969b6ece3c 100644 (file)
@@ -16,7 +16,9 @@
 #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>
@@ -1191,23 +1193,6 @@ mono_assembly_load_reference (MonoImage *image, int index)
                                   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 ();
@@ -1562,8 +1547,9 @@ mono_assembly_open_from_bundle (const char *filename, MonoImageOpenStatus *statu
 {
        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.
@@ -1572,11 +1558,13 @@ mono_assembly_open_from_bundle (const char *filename, MonoImageOpenStatus *statu
        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;
                }
@@ -1584,7 +1572,7 @@ mono_assembly_open_from_bundle (const char *filename, MonoImageOpenStatus *statu
        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;
        }
@@ -2355,11 +2343,11 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole
                        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;
                }
@@ -2379,11 +2367,11 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole
                        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;
                }
@@ -2411,11 +2399,11 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole
                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;
@@ -3447,9 +3435,19 @@ mono_assembly_close (MonoAssembly *assembly)
 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
index bdf3d75f62cad49400ac2545f601d00fbfdef79f..b414971e171dd40e479f0a4e7198fdf1691fbf0b 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _MONONET_METADATA_ASSEMBLY_H_ 
 #define _MONONET_METADATA_ASSEMBLY_H_
 
+#include <mono/utils/mono-error.h>
 #include <mono/metadata/image.h>
 
 MONO_BEGIN_DECLS
@@ -32,7 +33,7 @@ MONO_API MonoAssembly* mono_assembly_loaded_full (MonoAssemblyName *aname, mono_
 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);
index 4372397aa5740f6fae868ffabf4ce2ce6bea96de..ea7fa289a3899b91b7917f21311f394b2726788f 100644 (file)
@@ -475,17 +475,12 @@ transport_send (int fd, guint8 *data, int len)
 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);
 }
 
index d3153d29967deb995f5d80da007197e6f7575475..d22f162085b376b1a0d7a64412e82acd8454b588 100644 (file)
@@ -58,6 +58,8 @@ boehm_thread_register (MonoThreadInfo* info, void *baseptr);
 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
@@ -236,6 +238,7 @@ mono_gc_base_init (void)
        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));
@@ -406,6 +409,13 @@ boehm_thread_unregister (MonoThreadInfo *p)
                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)
 {
index de54bd07a4d97ebde27235f64988583de477ac8b..b62d6155f91e3bd40e6c204c16bfd1b4eb94143b 100644 (file)
@@ -771,7 +771,7 @@ typedef struct {
        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;
index 7ec6ee9186e119598af72817dfe7df1bfd7e203f..6218589a88e3c47b96ecacfff2701e05e5035e7a 100644 (file)
@@ -18,7 +18,9 @@
 #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>
@@ -216,7 +218,7 @@ mono_class_from_typeref_checked (MonoImage *image, guint32 type_token, MonoError
                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;
@@ -5591,7 +5593,6 @@ mono_class_setup_parent (MonoClass *klass, MonoClass *parent)
                        /* 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;
@@ -7814,7 +7815,7 @@ search_modules (MonoImage *image, const char *name_space, const char *name, Mono
                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))
@@ -7910,7 +7911,7 @@ mono_class_from_name_checked_aux (MonoImage *image, const char* name_space, cons
 
                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);
index 500a87da63c77a146a2c5afd63e62a8d600ace00..1f555ed4e324daf757f982df42c12e13733d4ac2 100644 (file)
@@ -383,16 +383,13 @@ struct _MonoDomain {
        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;
index 6cfd0dbbb9ea31c1a6ff8ba24d0db0e423381f01..bb40725ac1f401e085deccb0dc901a0b083a6ecd 100644 (file)
@@ -40,6 +40,9 @@
 #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>
@@ -179,7 +182,7 @@ lock_free_mempool_free (LockFreeMempool *mp)
        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);
@@ -197,7 +200,7 @@ lock_free_mempool_chunk_new (LockFreeMempool *mp, int len)
        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;
@@ -526,9 +529,14 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
 
 #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
@@ -808,16 +816,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
 
        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;
 }
 
@@ -1250,10 +1248,6 @@ mono_domain_free (MonoDomain *domain, gboolean force)
                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;
index 09b498ab559bdeabe7fa97e88f6c76634f203809..02b738556c597c72fbc7ed9fe76a5acead5d97eb 100644 (file)
@@ -991,7 +991,7 @@ mono_exception_get_native_backtrace (MonoException *exc)
                }
        }
 
-       free (messages);
+       g_free (messages);
        return g_string_free (text, FALSE);
 #else
        return g_strdup ("");
index 76495a807d56109ecdb674f9158324052ee91916..102f9f4da7244fbb8aac1b0909d239bd1a49b190 100644 (file)
@@ -79,7 +79,7 @@ void mono_handle_stack_free (HandleStack *handlestack);
 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;
@@ -87,7 +87,7 @@ mono_stack_mark_init (MonoThreadInfo *info, HandleStackMark *stackmark)
        stackmark->chunk = handles->top;
 }
 
-static void
+static inline void
 mono_stack_mark_pop (MonoThreadInfo *info, HandleStackMark *stackmark)
 {
        HandleStack *handles = (HandleStack *)info->handle_stack;
index 7c71dc55064e6cb13c8cfc7a79dd08640f67d0bd..66e0d4ba8957498188f7aa19890bff97535238fb 100644 (file)
@@ -287,16 +287,16 @@ HANDLES(ICALL(ENV_19, "internalGetHome", ves_icall_System_Environment_InternalGe
 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)
 
index b331969129c56a55224645737b08f9170aabb97f..526ff5e075eb9d89ef3e46b5012820ca671fb064 100644 (file)
@@ -43,7 +43,9 @@
 #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>
@@ -83,6 +85,9 @@
 #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>
@@ -981,11 +986,6 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStac
        /* 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)
@@ -4827,8 +4827,8 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
                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
@@ -5028,7 +5028,9 @@ ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly
                        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));
@@ -5552,7 +5554,9 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        /* 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;
@@ -6940,7 +6944,7 @@ ves_icall_System_Text_EncodingHelper_InternalCodePage (gint32 *int_code_page)
        
        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);
index 959575f6a0a4a8c8996720693fd4a39d412b0c4a..6281e3b241c35eb37cbb5d1ead242c7ab41ccb16 100644 (file)
 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__ */
index 50eaded2e37279442560273998901d1e3cbb82ea..ae1b204ca26f65b5573719d0dd3604664f4f5f7c 100644 (file)
@@ -66,18 +66,43 @@ enum {
 };
 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)
@@ -632,13 +657,13 @@ load_modules (MonoImage *image)
 }
 
 /**
- * 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;
@@ -648,6 +673,8 @@ mono_image_load_module (MonoImage *image, int idx)
        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])
@@ -683,10 +710,18 @@ mono_image_load_module (MonoImage *image, int idx)
                }
                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]);
@@ -705,6 +740,15 @@ mono_image_load_module (MonoImage *image, int idx)
        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)
 {
@@ -1653,6 +1697,17 @@ mono_wrapper_caches_free (MonoWrapperCaches *cache)
        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
@@ -1773,7 +1828,6 @@ mono_image_close_except_pools (MonoImage *image)
                g_free (image->name);
                g_free (image->guid);
                g_free (image->version);
-               g_free (image->files);
        }
 
        if (image->method_cache)
@@ -1852,12 +1906,8 @@ mono_image_close_except_pools (MonoImage *image)
                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);
 
@@ -1876,6 +1926,17 @@ mono_image_close_except_pools (MonoImage *image)
        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)
 {
@@ -1891,12 +1952,8 @@ 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);
@@ -2153,8 +2210,9 @@ mono_image_get_resource (MonoImage *image, guint32 offset, guint32 *size)
        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;
@@ -2162,6 +2220,8 @@ mono_image_load_file_for_image (MonoImage *image, int fileidx)
        const char *fname;
        guint32 fname_id;
 
+       mono_error_init (error);
+
        if (fileidx < 1 || fileidx > t->rows)
                return NULL;
 
@@ -2189,14 +2249,21 @@ mono_image_load_file_for_image (MonoImage *image, int fileidx)
        } 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 */
@@ -2212,6 +2279,15 @@ done:
        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
index c3ad58b3431c00e04a95676339e5f07ea2e3291f..b158ec26834acc9962eb16361ee9cb94ba8dd243 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <stdio.h>
 #include <mono/utils/mono-publib.h>
+#include <mono/utils/mono-error.h>
 
 MONO_BEGIN_DECLS
 
@@ -50,9 +51,9 @@ MONO_API int           mono_image_ensure_section_idx (MonoImage *image,
 
 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);
index 4f36ba3c82c11fd5f55a5e8e10866928fdf0a9a5..70e371aa66eadc61ccab56a8fc0e7f17b847c786 100644 (file)
@@ -1123,6 +1123,14 @@ cached_module_load (const char *name, int flags, char **err)
        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
@@ -2224,7 +2232,7 @@ mono_stack_walk_async_safe (MonoStackWalkAsyncSafe func, void *initial_sig_conte
        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
index a2c6d349ddf15fcc186278750843b8289e4a6c96..6382c774ae3fd431d61f741df0456253a4847d44 100644 (file)
@@ -4,6 +4,7 @@
 #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
 
@@ -63,6 +64,8 @@ mono_lookup_internal_call (MonoMethod *method);
 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);
index bcb0dc3c0146748719a55c6a9002fc609a2c61b4..783b528339c41d84657ab7ae50fcd0b0eb5831b9 100644 (file)
@@ -434,7 +434,7 @@ get_darwin_locale (void)
                                        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] = '-';
@@ -454,9 +454,9 @@ get_darwin_locale (void)
 
                        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;
index 5b290e74947ff5143a963c5a2e891c4d7d71fc3f..b457211c83da5d2ffd2116bae62c9acb98e4e408 100644 (file)
@@ -778,7 +778,7 @@ mono_free_lparray (MonoArray *array, gpointer* nativeArray)
        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
 }
index 6bf3410d818ec7115921f01c4e9c45dd27109e80..214c9e2128fd5349d51d9d9f46c6e542e9751db3 100644 (file)
@@ -215,7 +215,7 @@ mono_backtrace (int size)
         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);
 }
 
index a1b9eb841781775dcf0fdc3cc5d768ddcfde08e8..a529a3f3642e559dd4a16463e6ce6e930018c871 100644 (file)
@@ -175,10 +175,12 @@ typedef struct {
 
 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;
 
@@ -258,16 +260,16 @@ struct _MonoImage {
        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;
 
index ef01f3d5305c7d40fd2194627280ea832f174698..8b7418e9659e139dd21ba614910f4b2a9aea97e6 100644 (file)
@@ -26,6 +26,7 @@
 #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>
@@ -877,7 +878,25 @@ retry_contended:
 #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
@@ -886,7 +905,8 @@ retry_contended:
        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
@@ -996,11 +1016,35 @@ mono_monitor_try_enter_internal (MonoObject *obj, guint32 ms, gboolean allow_int
 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 
@@ -1083,18 +1127,22 @@ void
 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);
@@ -1199,7 +1247,7 @@ ves_icall_System_Threading_Monitor_Monitor_pulse (MonoObject *obj)
        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);
        }
 }
@@ -1230,7 +1278,7 @@ ves_icall_System_Threading_Monitor_Monitor_pulse_all (MonoObject *obj)
        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);
        }
 }
@@ -1265,7 +1313,7 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
        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;
index d651b0e5b08387b9b4829e0ce74b612e1fc3cc54..5f3ecb93ea65582aaadb6081e7cfa9e1f2f0c7dc 100644 (file)
@@ -53,7 +53,7 @@ extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope
                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
@@ -102,7 +102,7 @@ extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope
                mono_array_setref (*gw_addr_list, gwnum, addr_string);
                gwnum++;
        }
-       free(buf);
+       g_free (buf);
        return TRUE;
 }
 
index 47d7dc5b1decdcde5b5cec33b24527f639ddc41d..1ab1e0ebb2d3279e98a411d2151779e1bdfc1062 100644 (file)
@@ -191,7 +191,7 @@ mono_gc_free_fixed (void* addr)
 void *
 mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
 {
-       MonoObject *obj = calloc (1, size);
+       MonoObject *obj = g_calloc (1, size);
 
        obj->vtable = vtable;
 
@@ -201,7 +201,7 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
 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;
@@ -212,7 +212,7 @@ mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t 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;
@@ -226,7 +226,7 @@ mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uint
 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;
index 06d558d60db8eaf4658ff279733a406abd67b117..b420ff75543492180fccb50bcbd5fe7e349d2b36 100644 (file)
@@ -380,6 +380,8 @@ struct _MonoInternalThread {
        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.
@@ -388,6 +390,12 @@ struct _MonoInternalThread {
         */
        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 {
@@ -395,7 +403,6 @@ struct _MonoThread {
        struct _MonoInternalThread *internal_thread;
        MonoObject *start_obj;
        MonoException *pending_exception;
-       gint32 priority;
 };
 
 typedef struct {
@@ -1517,14 +1524,14 @@ struct _MonoIMTCheckItem {
        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);
@@ -1538,7 +1545,7 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
                                                                                        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,
index 0085528adb4891ab77d4b0dce98b45e6015a1fbc..e4965a512a758da60f6db8a0512e36588a3b3bce 100644 (file)
@@ -92,6 +92,7 @@ DECL_OFFSET(MonoDelegate, extra_arg)
 DECL_OFFSET(MonoInternalThread, tid)
 DECL_OFFSET(MonoInternalThread, small_id)
 DECL_OFFSET(MonoInternalThread, static_data)
+DECL_OFFSET(MonoInternalThread, last)
 
 DECL_OFFSET(MonoMulticastDelegate, delegates)
 
index 0aede5fbb2092feb2ec7ad9c1b53ddfce4a1e903..9db69581fbcc77704b0230f94bf300466255d509 100644 (file)
@@ -41,6 +41,7 @@
 #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>
@@ -571,8 +572,8 @@ default_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
 }
 
 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"
@@ -605,14 +606,15 @@ mono_install_delegate_trampoline (MonoDelegateTrampoline func)
 }
 
 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;
 }
 
 /**
@@ -1206,7 +1208,7 @@ mono_method_get_imt_slot (MonoMethod *method)
                break;
        }
        
-       free (hashes_start);
+       g_free (hashes_start);
        /* Report the result */
        return c % MONO_IMT_SIZE;
 }
@@ -1334,7 +1336,7 @@ imt_sort_slot_entries (MonoImtBuilderEntry *entries) {
 
        imt_emit_ir (sorted_array, 0, number_of_entries, result);
 
-       free (sorted_array);
+       g_free (sorted_array);
        return result;
 }
 
@@ -1344,15 +1346,15 @@ initialize_imt_slot (MonoVTable *vtable, MonoDomain *domain, MonoImtBuilderEntry
        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));
@@ -1474,12 +1476,12 @@ build_imt_slots (MonoClass *klass, MonoVTable *vt, MonoDomain *domain, gpointer*
 
                        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));
@@ -1514,7 +1516,7 @@ build_imt_slots (MonoClass *klass, MonoVTable *vt, MonoDomain *domain, gpointer*
                        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;
 }
@@ -1532,7 +1534,7 @@ build_imt (MonoClass *klass, MonoVTable *vt, MonoDomain *domain, gpointer* imt,
  * @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.
@@ -1560,167 +1562,35 @@ mono_vtable_build_imt_slot (MonoVTable* vtable, int imt_slot)
        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 {
@@ -1784,7 +1654,7 @@ get_generic_virtual_entries (MonoDomain *domain, gpointer *vtable_slot)
  * 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,
@@ -1795,6 +1665,7 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
 
        static gboolean inited = FALSE;
        static int num_added = 0;
+       static int num_freed = 0;
 
        GenericVirtualCase *gvc, *list;
        MonoImtBuilderEntry *entries;
@@ -1805,6 +1676,12 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
        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;
@@ -1824,10 +1701,6 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
 
                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++;
        }
 
@@ -1840,7 +1713,7 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
                        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 {
@@ -1850,8 +1723,8 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
 
                        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;
@@ -1862,14 +1735,10 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
                        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);
@@ -7568,7 +7437,7 @@ ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResult
                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)
index c4feb7fa150a82831e45d81a6abd870d995ad25c..fdbc46a2cfbf6d0d72f7957a7a1bdec60f9a9733 100644 (file)
@@ -968,11 +968,11 @@ void*
 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;
@@ -982,7 +982,7 @@ void
 mono_gc_free_fixed (void* addr)
 {
        mono_gc_deregister_root ((char *)addr);
-       free (addr);
+       g_free (addr);
 }
 
 /*
@@ -2208,12 +2208,9 @@ sgen_client_thread_register (SgenThreadInfo* info, void *stack_bottom_fallback)
        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;
@@ -2301,7 +2298,7 @@ sgen_thread_detach (SgenThreadInfo *p)
         * 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 ());
 }
 
index 8b78616129a9da8ed7a593fab28349e1143bd791..d78be35069def5fb17d4524afe7d82987cf4e250 100644 (file)
@@ -21,7 +21,7 @@ sgen_resume_thread (SgenThreadInfo *info)
 
        CloseHandle (handle);
 
-       return result != (DWORD)-1;
+       return result != (DWORD)-1 && result > 0;
 }
 
 gboolean
index 50d7635ca41d5259200c67f8db6118e5d8e5b1dc..c15bd42b74aabd2b63709a831bcd20cc338e128d 100644 (file)
@@ -42,8 +42,6 @@ mono_sre_generic_param_table_entry_free (GenericParamTableEntry *entry)
        g_free (entry);
 }
 
-
-
 static GENERATE_GET_CLASS_WITH_CACHE (marshal_as_attribute, System.Runtime.InteropServices, MarshalAsAttribute);
 
 #ifndef DISABLE_REFLECTION_EMIT
@@ -75,8 +73,6 @@ static guint32 mono_image_get_methodspec_token (MonoDynamicImage *assembly, Mono
 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);
@@ -200,30 +196,12 @@ string_heap_insert (MonoDynamicStream *sh, const char *str)
        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).
  */
@@ -279,56 +257,6 @@ swap_with_size (char *dest, const char* val, int len, int nelem) {
 #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)
 {
@@ -3563,53 +3491,6 @@ methodbuilder_to_mono_method (MonoClass *klass, MonoReflectionMethodBuilder* mb,
        }
        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
index 0821d28ae320db0a1803d763c32e629414118aba..7849d4554f5646220aa302bcc00ae013dfcd837d 100644 (file)
@@ -33,6 +33,7 @@
 #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>
@@ -159,6 +160,11 @@ typedef struct {
        gboolean suspended;
 } ThreadPool;
 
+typedef struct {
+       gint32 ref;
+       MonoCoopCond cond;
+} ThreadPoolDomainCleanupSemaphore;
+
 typedef enum {
        TRANSITION_WARMUP,
        TRANSITION_INITIALIZING,
@@ -430,8 +436,13 @@ domain_get (MonoDomain *domain, gboolean create)
        }
 
        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;
@@ -684,13 +695,23 @@ worker_thread (gpointer data)
                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;
                }
@@ -1407,7 +1428,7 @@ mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, Mono
                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)) {
@@ -1433,9 +1454,10 @@ mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, Mono
 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);
@@ -1466,31 +1488,47 @@ mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout)
        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
index e27e89bb6f088f3df2316861be72abb028de114e..a7fd76f1f1c435ef6cc7888fdf1153f2a9ff6df8 100644 (file)
@@ -42,6 +42,14 @@ typedef enum {
        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
@@ -75,17 +83,6 @@ MonoObject* ves_icall_System_Threading_Thread_GetCachedCurrentCulture (MonoInter
 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);
@@ -198,6 +195,7 @@ gboolean mono_thread_current_check_pending_interrupt (void);
 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);
@@ -262,4 +260,13 @@ void mono_threads_begin_abort_protected_block (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_ */
index 4c3ca385941daa308a8c4c1a04d5b34284ac81af..7a2379628800309be9e35819f64e5e1fedf07a40 100644 (file)
 #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>
@@ -548,7 +551,6 @@ new_thread_with_internal (MonoDomain *domain, MonoInternalThread *internal)
        MonoThread *thread;
 
        thread = create_thread_object (domain);
-       thread->priority = MONO_THREAD_PRIORITY_NORMAL;
 
        MONO_OBJECT_SETREF (thread, internal_thread, internal);
 
@@ -577,9 +579,84 @@ create_internal_thread (void)
                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, &param);
+       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, &param);
+       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);
 
@@ -595,7 +672,7 @@ mono_thread_attach_internal (MonoThread *thread, gboolean force_attach, gboolean
        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;
@@ -706,6 +783,8 @@ static guint32 WINAPI start_wrapper_internal(StartInfo *start_info, gsize *stack
                return 0;
        }
 
+       mono_thread_internal_set_priority (internal, internal->priority);
+
        tid = internal->tid;
 
        start_delegate = start_info->start_delegate;
@@ -796,20 +875,10 @@ static guint32 WINAPI start_wrapper_internal(StartInfo *start_info, gsize *stack
         * 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);
 }
 
@@ -836,7 +905,6 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta
        StartInfo *start_info = NULL;
        HANDLE thread_handle;
        MonoNativeThreadId tid;
-       MonoThreadParm tp;
        gboolean ret;
 
        if (start_delegate)
@@ -881,11 +949,7 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta
        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 */
@@ -910,6 +974,8 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta
 
        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;
@@ -955,20 +1021,17 @@ mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gb
        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;
 }
@@ -1003,7 +1066,7 @@ mono_thread_attach_full (MonoDomain *domain, gboolean force_attach)
        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 */
@@ -1055,6 +1118,10 @@ mono_thread_detach_internal (MonoInternalThread *thread)
 
        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);
@@ -1096,6 +1163,18 @@ mono_thread_detach_if_exiting (void)
        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)
 {
@@ -1103,13 +1182,12 @@ 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 ();
 }
 
@@ -1408,11 +1486,9 @@ ves_icall_System_Threading_Thread_GetPriority (MonoThread *this_obj)
        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;
 }
 
@@ -1429,9 +1505,9 @@ ves_icall_System_Threading_Thread_SetPriority (MonoThread *this_obj, int priorit
        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);
 }
 
@@ -1690,19 +1766,9 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
        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)
@@ -1753,123 +1819,6 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, H
        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);
@@ -2114,7 +2063,7 @@ ves_icall_System_Threading_Thread_ClrState (MonoInternalThread* this_obj, guint3
                 * be notified, since it has to rebuild the list of threads to
                 * wait for.
                 */
-               SetEvent (background_change_event);
+               mono_w32event_set (background_change_event);
        }
 }
 
@@ -2128,7 +2077,7 @@ ves_icall_System_Threading_Thread_SetState (MonoInternalThread* this_obj, guint3
                 * be notified, since it has to rebuild the list of threads to
                 * wait for.
                 */
-               SetEvent (background_change_event);
+               mono_w32event_set (background_change_event);
        }
 }
 
@@ -2879,7 +2828,7 @@ void mono_thread_init (MonoThreadStartCB start_cb,
        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);
@@ -3179,8 +3128,8 @@ mono_threads_set_shutting_down (void)
                        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 ();
@@ -3191,7 +3140,7 @@ mono_threads_set_shutting_down (void)
                 * 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 ();
        }
@@ -3224,7 +3173,7 @@ void mono_thread_manage (void)
                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);
@@ -3440,7 +3389,7 @@ get_thread_dump (MonoThreadInfo *info, gpointer ud)
 #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
 
@@ -4643,6 +4592,29 @@ mono_thread_set_state (MonoInternalThread *thread, MonoThreadState state)
        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)
 {
@@ -5168,4 +5140,53 @@ mono_thread_try_resume_interruption (void)
                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));
+}
diff --git a/mono/metadata/w32event-unix.c b/mono/metadata/w32event-unix.c
new file mode 100644 (file)
index 0000000..5644ce7
--- /dev/null
@@ -0,0 +1,412 @@
+/*
+ * 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;
+}
diff --git a/mono/metadata/w32event-win32.c b/mono/metadata/w32event-win32.c
new file mode 100644 (file)
index 0000000..8659021
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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;
+}
diff --git a/mono/metadata/w32event.h b/mono/metadata/w32event.h
new file mode 100644 (file)
index 0000000..1f41b1a
--- /dev/null
@@ -0,0 +1,43 @@
+
+#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_ */
diff --git a/mono/metadata/w32handle-namespace.c b/mono/metadata/w32handle-namespace.c
new file mode 100644 (file)
index 0000000..1ca4e1d
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * 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
diff --git a/mono/metadata/w32handle-namespace.h b/mono/metadata/w32handle-namespace.h
new file mode 100644 (file)
index 0000000..5a25477
--- /dev/null
@@ -0,0 +1,28 @@
+
+#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
diff --git a/mono/metadata/w32mutex-unix.c b/mono/metadata/w32mutex-unix.c
new file mode 100644 (file)
index 0000000..a995eeb
--- /dev/null
@@ -0,0 +1,547 @@
+/*
+ * 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;
+}
diff --git a/mono/metadata/w32mutex-win32.c b/mono/metadata/w32mutex-win32.c
new file mode 100644 (file)
index 0000000..6f967e8
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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;
+}
diff --git a/mono/metadata/w32mutex.h b/mono/metadata/w32mutex.h
new file mode 100644 (file)
index 0000000..917b36f
--- /dev/null
@@ -0,0 +1,33 @@
+
+#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_ */
diff --git a/mono/metadata/w32semaphore-unix.c b/mono/metadata/w32semaphore-unix.c
new file mode 100644 (file)
index 0000000..1f99d8f
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+ * 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;
+}
diff --git a/mono/metadata/w32semaphore-win32.c b/mono/metadata/w32semaphore-win32.c
new file mode 100644 (file)
index 0000000..d7c6b62
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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
diff --git a/mono/metadata/w32semaphore.h b/mono/metadata/w32semaphore.h
new file mode 100644 (file)
index 0000000..789dfbe
--- /dev/null
@@ -0,0 +1,28 @@
+
+#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_ */
index 34614773907bd8c6818564cc7b2d2aead45f5cf3..3ad4c53b921a65b03ba65022f3af609fc8234614 100644 (file)
@@ -1145,7 +1145,7 @@ arm64_emit_specific_trampoline_pages (MonoAotCompile *acfg)
        /* 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);
@@ -1177,7 +1177,7 @@ arm64_emit_specific_trampoline_pages (MonoAotCompile *acfg)
        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);
 }
@@ -1215,7 +1215,7 @@ arm64_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp
 }
 
 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];
@@ -1758,7 +1758,7 @@ arch_emit_specific_trampoline_pages (MonoAotCompile *acfg)
 
        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 */
@@ -2133,9 +2133,9 @@ arch_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp_
 }      
 
 /*
- * 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 
@@ -2144,7 +2144,7 @@ arch_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp_
  * 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;
@@ -2333,7 +2333,7 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
 
        *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];
@@ -4327,13 +4327,19 @@ gboolean mono_aot_mode_is_full (MonoAotOptions *opts)
        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);
@@ -6704,7 +6710,7 @@ emit_trampolines (MonoAotCompile *acfg)
                 * 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
@@ -6740,8 +6746,8 @@ emit_trampolines (MonoAotCompile *acfg)
                        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");
@@ -6772,8 +6778,8 @@ emit_trampolines (MonoAotCompile *acfg)
                                        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:
@@ -8363,7 +8369,7 @@ emit_code (MonoAotCompile *acfg)
                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);
@@ -8445,11 +8451,7 @@ emit_code (MonoAotCompile *acfg)
                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);
                }
@@ -8478,7 +8480,7 @@ emit_code (MonoAotCompile *acfg)
 
                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);
@@ -8508,7 +8510,7 @@ emit_code (MonoAotCompile *acfg)
 
                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;
 
@@ -8685,7 +8687,7 @@ mono_aot_method_hash (MonoMethod *method)
                break;
        }
        
-       free (hashes_start);
+       g_free (hashes_start);
        
        return c;
 }
@@ -9468,7 +9470,7 @@ emit_aot_file_info (MonoAotCompile *acfg, MonoAotFileInfo *info)
        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;
@@ -9775,7 +9777,6 @@ compile_methods (MonoAotCompile *acfg)
                HANDLE handle;
                gpointer *user_data;
                MonoMethod **methods;
-               MonoThreadParm tp;
 
                methods_len = acfg->methods->len;
 
@@ -9806,16 +9807,14 @@ compile_methods (MonoAotCompile *acfg)
                        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;
@@ -10440,7 +10439,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        }
 
 #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;
        }
@@ -10536,7 +10535,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 #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;
index e1849862a847f604f88fb5d933a2637796ee209c..9a4d566c754d088e31d81b3679ad2617c3fd6532 100644 (file)
@@ -2151,7 +2151,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        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"))
@@ -5186,7 +5186,7 @@ read_page_trampoline_uwinfo (MonoTrampInfo *info, int tramp_type, gboolean is_ge
                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");
@@ -5234,7 +5234,7 @@ get_new_trampoline_from_page (int tramp_type)
                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");
@@ -5362,7 +5362,7 @@ get_new_imt_trampoline_from_page (gpointer arg)
        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;
@@ -5615,13 +5615,13 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
 }
 
 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;
@@ -5630,7 +5630,7 @@ mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem
        MonoAotModule *amodule;
 
        if (mono_llvm_only)
-               return no_imt_thunk;
+               return no_imt_trampoline;
 
        real_count = 0;
        for (i = 0; i < count; ++i) {
@@ -5667,7 +5667,7 @@ mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem
        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;
        }
@@ -5948,7 +5948,7 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
 }
 
 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;
index 22f063c59640e9253d58be382839db3c838575e7..7aa562c591db78c8118002b5f80503112154414c 100644 (file)
@@ -271,7 +271,7 @@ typedef struct {
 #define HEADER_LENGTH 11
 
 #define MAJOR_VERSION 2
-#define MINOR_VERSION 42
+#define MINOR_VERSION 43
 
 typedef enum {
        CMD_SET_VM = 1,
@@ -1627,12 +1627,7 @@ stop_debugger_thread (void)
 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);
 }
 
@@ -8627,6 +8622,12 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
 
                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) {
@@ -8644,6 +8645,17 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
                                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);
 
index bd6e19fc4f50a07f60071c1ecd484b9cd3db2a60..a6d2bd117b1f75181421b9e0b65ddb23265e5fd7 100644 (file)
@@ -1748,6 +1748,7 @@ mono_main (int argc, char* argv[])
                } 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) {
index f8a328375b90de9bdc0344ff7e26192e50b46dc0..bb9c73c0400956edce182fcea82cc2887e726cd9 100644 (file)
@@ -1715,7 +1715,7 @@ mono_resolve_generic_virtual_call (MonoVTable *vt, int slot, MonoMethod *generic
 
        /*
         * 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);
@@ -1765,7 +1765,7 @@ mono_resolve_generic_virtual_iface_call (MonoVTable *vt, int imt_slot, MonoMetho
 
        /*
         * 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);
index 8d2f5bd17121d78ef98c4fba3c8e1f427d4b86da..6149ca75fa0996be2da5c08a5ed076fd8685a539 100644 (file)
@@ -1,8 +1,24 @@
+/*
+ * 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
@@ -29,6 +45,51 @@ mono_main_with_options (int argc, char *argv [])
        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))
 
@@ -64,6 +125,60 @@ load_from_region (int fd, uint64_t offset, uint64_t size)
        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 [])
 {
@@ -150,13 +265,15 @@ 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++)
index 6769d9c5f85fd622df4f250c8e865e678eef8fb8..1b55991ff0290da9607e57336770694cab92c4db 100644 (file)
@@ -154,8 +154,7 @@ emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSig
 /* 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)
@@ -364,7 +363,7 @@ mono_create_helper_signatures (void)
 {
        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
@@ -5679,7 +5678,7 @@ emit_array_generic_access (MonoCompile *cfg, MonoMethodSignature *fsig, MonoInst
        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);
@@ -7809,7 +7808,7 @@ emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSig
                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);
        }
@@ -7852,7 +7851,7 @@ emit_llvmonly_virtual_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSig
                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
@@ -9629,7 +9628,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                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);
index f9a0d5adc8bdfa90c778cbc613c58ecf6d0f4fc0..4ed38f2b58312bd22f6697f0ad9bd2d72be8e261 100644 (file)
@@ -473,13 +473,13 @@ allocate_register_for_valuetype_win64 (ArgInfo *arg_info, ArgumentClass arg_clas
        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);
@@ -7989,7 +7989,7 @@ imt_branch_distance (MonoIMTCheckItem **imt_entries, int start, int target)
  * 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;
@@ -8043,7 +8043,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                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;
@@ -8134,7 +8134,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        }
 
        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);
index 22e7413a6f531cb207b974d0cefdfff2605a12e9..8ac16a17176d26319836dee254922c1c16dc1632 100644 (file)
@@ -386,7 +386,7 @@ typedef struct {
 #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
index 7b2e1fa7b48e2438c7e85deeb87108be375a6936..82795e5b8e87e2e46c65bcc40e55190c19b4b338 100644 (file)
@@ -836,8 +836,8 @@ mono_arch_init (void)
                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);
        }
 
@@ -6922,7 +6922,7 @@ mini_dump_bad_imt (int input_imt, int compared_imt, int pc)
 #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;
@@ -6974,7 +6974,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                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;
@@ -6982,7 +6982,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        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);
@@ -7148,7 +7148,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
 
        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);
 
index bc23a423d29a1f576c26f969c33e26ffd9d7a180..cb31a6e8b24f64f192e21cb32e1075805fbe0a8d 100644 (file)
@@ -316,7 +316,7 @@ typedef struct MonoCompileArch {
 
 #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
index 688594d96602b50770485925c92a521726edeea7..bc1b5021a01789137c35ed9956bea63247af10ba 100644 (file)
@@ -839,6 +839,7 @@ emit_thunk (guint8 *code, gconstpointer target)
        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;
@@ -1776,7 +1777,33 @@ mono_arch_flush_icache (guint8 *code, gint size)
 #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
 }
@@ -4951,14 +4978,14 @@ mono_arch_get_patch_offset (guint8 *code)
 }
 
 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);
@@ -4993,7 +5020,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        }
 
        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;
@@ -5081,8 +5108,8 @@ mono_arch_get_trampolines (gboolean aot)
 #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;
index e3e90eb6ea59bd350346001e0c5c22a065e4349e..8af5ca7f7d72bcc37f8677c28aceaab3fe4bcef2 100644 (file)
@@ -130,7 +130,7 @@ typedef struct {
 #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
index 2a437730a73b5d0e4057ec4f461a1bdefe98de4b..fa24b73f186132b30eb3d4b358664d3f59e2d4f6 100644 (file)
@@ -2060,13 +2060,13 @@ mono_setup_altstack (MonoJitTlsData *tls)
 
        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);
@@ -2092,9 +2092,9 @@ mono_free_altstack (MonoJitTlsData *tls)
        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);
 }
@@ -2389,7 +2389,7 @@ mono_handle_native_sigsegv (int signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *i
        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 */
 
@@ -2504,7 +2504,7 @@ mono_print_thread_dump_internal (void *sigctx, MonoContext *start_ctx)
                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
index 357e260799833ed8d4a1bf415c148853bf610e39..4cd9b377e3e2c933f1a7354396eef49194c34f3e 100644 (file)
@@ -4532,8 +4532,8 @@ mono_arch_free_jit_tls_data (MonoJitTlsData *tls)
  * 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;
@@ -4613,7 +4613,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
 
        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);
index bcb30ead561a6eca9a86a91aacca174989697d5c..bfee9d5c5480a3f0b0fb876524f6952cf2a5ef79 100644 (file)
@@ -109,6 +109,6 @@ unw_dyn_region_info_t* mono_ia64_create_unwind_region (Ia64CodegenState *code);
 
 #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__ */  
index 3ca1bca04c16a83087b5b01bf5c6eba63f020576..2ae3051b52074b80362733162ba2fcfa9fb5dc37 100644 (file)
@@ -4154,7 +4154,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                         * 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);
@@ -8610,7 +8611,7 @@ emit_aot_file_info (MonoLLVMModule *module)
        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);
index 783896f15681743acb6001dad302705db271bee9..8af84338759ecf8629b8b541dfb679058df08b2e 100644 (file)
@@ -714,8 +714,8 @@ mono_arch_init (void)
 {
        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);
 }
 
@@ -5889,8 +5889,8 @@ mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
  * 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;
@@ -5928,7 +5928,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        /* 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);
        }
@@ -6016,7 +6016,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        }
 
        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);
 
index 73d0ad3272062fad992e68c42e33ca075b703a07..06c533aee46cffa33e738dfd1b665dd6685f85e9 100644 (file)
@@ -264,7 +264,7 @@ typedef struct MonoCompileArch {
 #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
index 7d2c0d8b8cfda73cacd3b6847b37f7c5dd523da4..656ba1ed916e58c7eec2c00d683cea8fb106d1e6 100644 (file)
@@ -627,8 +627,8 @@ mono_arch_init (void)
 
        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);
@@ -5824,8 +5824,8 @@ mono_arch_free_jit_tls_data (MonoJitTlsData *tls)
  * 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;
@@ -5862,7 +5862,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        /* 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);
        }
@@ -5955,7 +5955,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        }
 
        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);
 
index b0d4654de83ef98cbbb778de7b877fa6a16d860b..2ea49cc45689839ed2262a3a372731b8fa5a69b6 100644 (file)
@@ -221,7 +221,7 @@ typedef struct MonoCompileArch {
 #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
 
index f4f30c69e6ba02fb18ddc33d4b0c2e580d4d541b..a9c87011153b35ba64bf2d25f057801ea21ee03a 100644 (file)
@@ -2562,34 +2562,34 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
 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);
@@ -2597,11 +2597,11 @@ mini_llvmonly_initial_imt_thunk (gpointer *arg, MonoMethod *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]);
@@ -2609,16 +2609,16 @@ mono_llvmonly_imt_thunk (gpointer *arg, MonoMethod *imt_method)
        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)
@@ -2628,7 +2628,7 @@ mono_llvmonly_imt_thunk_2 (gpointer *arg, MonoMethod *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)
@@ -2640,14 +2640,14 @@ mono_llvmonly_imt_thunk_3 (gpointer *arg, MonoMethod *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;
 
@@ -2660,7 +2660,7 @@ mono_llvmonly_fallback_imt_thunk (gpointer *arg, MonoMethod *imt_method)
 }
 
 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;
@@ -2668,7 +2668,7 @@ mono_llvmonly_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTChec
        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.
         */
 
@@ -2723,20 +2723,20 @@ mono_llvmonly_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTChec
        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;
@@ -2958,13 +2958,13 @@ mini_get_vtable_trampoline (MonoVTable *vt, int slot_index)
 
        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;
@@ -3663,12 +3663,12 @@ mini_init (const char *filename, const char *runtime_version)
        }
 
        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*/
@@ -3715,6 +3715,8 @@ mini_init (const char *filename, const char *runtime_version)
                 */
                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);
@@ -4032,7 +4034,7 @@ print_jit_stats (void)
                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);
index a1094afa173fbe0baeb75c2ff221e0e9b73ae7e9..420a7b1a3bf6e0ce0c8dc951b45fa71049e34eb9 100644 (file)
@@ -237,7 +237,7 @@ if (ins->inst_target_bb->native_offset) {                                   \
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
 /*
- * imt thunking size values
+ * imt trampoline size values
  */
 #define CMP_SIZE       24
 #define LOADCON_SIZE   20
@@ -1328,8 +1328,8 @@ mono_arch_init (void)
        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;
@@ -1354,9 +1354,9 @@ void
 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);
 }
 
@@ -6662,16 +6662,16 @@ mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod
 
 /*------------------------------------------------------------------*/
 /*                                                                  */
-/* 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;
@@ -6710,7 +6710,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain,
        }
 
        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);
 
@@ -6793,11 +6793,11 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain,
        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);
index 5003bfe025403fa2d02c9709b18d04fa2e26b491..e43410353d1928e5b6ba332a678ca45426c7047b 100644 (file)
@@ -2256,8 +2256,8 @@ mono_sparc_is_virtual_call (guint32 *code)
  * 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;
@@ -2285,7 +2285,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                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;
@@ -2352,7 +2352,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
 
        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);
index 8c1fe23297bffd8ba8b6ce8c9a6f43e62fff2b78..77775169fd7d0d5a615fdd69e4b2dd761566f948 100644 (file)
@@ -564,7 +564,7 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, MonoVTable *
                        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) {
index 288af652434bf9ffc25e4ad0893d5087409de286..bcd050b24f64ce11327d9d3d368dece51e36a3ce 100644 (file)
@@ -5613,7 +5613,7 @@ imt_branch_distance (MonoIMTCheckItem **imt_entries, int start, int target)
  * 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;
@@ -5645,7 +5645,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                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;
@@ -5715,7 +5715,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
        }
 
        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
@@ -5730,7 +5730,7 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
                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);
        }
index b70d836c2aa07fd9758bf632c62cb5cd404582a1..be98276e63f2ae26e8fe3f70dd2816901932562c 100644 (file)
@@ -207,7 +207,7 @@ typedef struct {
 #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
index 750410441af8afda4ad292c84405f3e195b47c24..0dd4af7a71ede59872342fd943775750d3a50d52 100644 (file)
@@ -3136,8 +3136,8 @@ init_backend (MonoBackend *backend)
 #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;
index 845162f76f7349228657010d253c8dbfbae09b4f..d3a550946013f217c8c53ccb20b118d2d844badf 100644 (file)
@@ -179,7 +179,7 @@ enum {
 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;
@@ -254,7 +254,7 @@ typedef struct MonoAotFileInfo
        /* 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;
@@ -1484,7 +1484,7 @@ typedef struct {
        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;
@@ -2501,7 +2501,7 @@ gpointer mono_aot_get_trampoline_full       (const char *name, MonoTrampInfo **o
 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);
@@ -2790,7 +2790,7 @@ gpointer mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, M
 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);
index b213528caaa35b55a02a43f0c8b2329a40eeab75..338150494dd0315582003170457d0172b9294b31 100644 (file)
@@ -633,7 +633,7 @@ add_class (intptr_t klass, const char *name)
        /* 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;
        }
@@ -699,7 +699,7 @@ add_method (intptr_t method, const char *name, intptr_t code, int len)
                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;
        }
@@ -1099,7 +1099,7 @@ add_heap_class_rev (HeapClassDesc *from, HeapClassDesc *to)
                                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);
@@ -1217,7 +1217,7 @@ add_heap_shot_class (HeapShot *hs, ClassDesc *klass, uint64_t size)
                                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;
@@ -1269,7 +1269,7 @@ heap_shot_obj_add_refs (HeapShot *hs, uintptr_t objaddr, uintptr_t num, uintptr_
                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;
        }
@@ -1319,7 +1319,7 @@ add_heap_shot_obj (HeapShot *hs, HeapObjectDesc *obj)
                                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);
@@ -1413,7 +1413,7 @@ heap_shot_mark_objects (HeapShot *hs)
                }
        }
        fprintf (outfile, "Total unmarked: %zd/%zd\n", num_unmarked, hs->objects_count);
-       free (marks);
+       g_free (marks);
 }
 
 static void
@@ -1423,10 +1423,10 @@ heap_shot_free_objects (HeapShot *hs)
        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;
@@ -1726,7 +1726,7 @@ add_trace_bt (BackTrace *bt, TraceDesc *trace, uint64_t value)
                                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);
@@ -2371,7 +2371,7 @@ decode_buffer (ProfContext *ctx)
                                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;
@@ -2402,7 +2402,7 @@ decode_buffer (ProfContext *ctx)
                                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)
@@ -2543,7 +2543,7 @@ decode_buffer (ProfContext *ctx)
                                        tracked_creation (OBJ_ADDR (objdiff), cd, len, bt, time_base);
                        }
                        if (frames != sframes)
-                               free (frames);
+                               g_free (frames);
                        break;
                }
                case TYPE_METHOD: {
@@ -2666,9 +2666,9 @@ decode_buffer (ProfContext *ctx)
                                                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;
@@ -2753,7 +2753,7 @@ decode_buffer (ProfContext *ctx)
                        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: {
@@ -2799,7 +2799,7 @@ decode_buffer (ProfContext *ctx)
                                                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));
                        }
@@ -3698,9 +3698,9 @@ heap_shot_summary (HeapShot *hs, int hs_num, HeapShot *last_hs)
                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
@@ -4216,7 +4216,7 @@ main (int argc, char *argv[])
                        *top++ = 0;
                        from_secs = atof (val);
                        to_secs = atof (top);
-                       free (val);
+                       g_free (val);
                        if (from_secs > to_secs) {
                                usage ();
                                return 1;
index 3f071a108798834e9b64cbc978a537336940bb8b..78de58aaa08de08e66e16439a294f494979335c5 100644 (file)
@@ -109,7 +109,7 @@ method_jit_result (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, i
                                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;
@@ -126,9 +126,9 @@ method_jit_result (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, i
                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);
index 38fe00625682e73bf5a2d32403c4807e69dddfd5..17f43836afdee6caccfd37e4889a97851a61b939 100644 (file)
@@ -1939,7 +1939,7 @@ class_loaded (MonoProfiler *prof, MonoClass *klass, int result)
        if (runtime_inited)
                mono_free (name);
        else
-               free (name);
+               g_free (name);
 
        send_if_needed (prof);
 
@@ -1983,7 +1983,7 @@ class_unloaded (MonoProfiler *prof, MonoClass *klass)
        if (runtime_inited)
                mono_free (name);
        else
-               free (name);
+               g_free (name);
 
        send_if_needed (prof);
 
@@ -2562,7 +2562,7 @@ add_code_pointer (uintptr_t ip)
                                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);
@@ -2742,7 +2742,7 @@ elf_dl_callback (struct dl_phdr_info *info, size_t size, void *data)
                        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;
@@ -2816,7 +2816,7 @@ symbol_for (uintptr_t code)
                names = backtrace_symbols (&ip, 1);
                if (names) {
                        const char* p = names [0];
-                       free (names);
+                       g_free (names);
                        return p;
                }
                */
@@ -3143,13 +3143,13 @@ setup_perf_event (void)
        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;
 }
@@ -3187,7 +3187,7 @@ counters_add_agent (MonoCounter *counter)
                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);
@@ -3316,7 +3316,7 @@ counters_sample (MonoProfiler *profiler, uint64_t timestamp)
        counters_emit (profiler);
 
        buffer_size = 8;
-       buffer = calloc (1, buffer_size);
+       buffer = g_calloc (1, buffer_size);
 
        mono_os_mutex_lock (&counters_mutex);
 
@@ -3352,7 +3352,7 @@ counters_sample (MonoProfiler *profiler, uint64_t timestamp)
                        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);
@@ -3363,7 +3363,7 @@ counters_sample (MonoProfiler *profiler, uint64_t timestamp)
                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) {
@@ -3413,14 +3413,14 @@ counters_sample (MonoProfiler *profiler, uint64_t timestamp)
                }
 
                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);
 
@@ -4350,8 +4350,8 @@ log_shutdown (MonoProfiler *prof)
 
        PROF_TLS_FREE ();
 
-       free (prof->args);
-       free (prof);
+       g_free (prof->args);
+       g_free (prof);
 }
 
 static char*
@@ -4660,7 +4660,7 @@ handle_writer_queue_entry (MonoProfiler *prof)
                        mono_free (name);
 
                free_info:
-                       free (info);
+                       g_free (info);
                }
 
                g_ptr_array_free (entry->methods, TRUE);
@@ -4889,7 +4889,7 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
                        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;
                }
        }
@@ -4935,7 +4935,7 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
 
        // 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);
 
@@ -4952,7 +4952,7 @@ create_profiler (const char *args, const char *filename, GPtrArray *filters)
 
        // 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);
@@ -5074,7 +5074,7 @@ set_sample_mode (char* val, int allow_empty)
        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++) {
@@ -5097,7 +5097,7 @@ set_sample_mode (char* val, int allow_empty)
        } else {
                sample_freq = 100;
        }
-       free (val);
+       g_free (val);
 }
 
 static void
@@ -5109,7 +5109,7 @@ set_hsmode (char* val, int allow_empty)
                return;
        if (strcmp (val, "ondemand") == 0) {
                hs_mode_ondemand = 1;
-               free (val);
+               g_free (val);
                return;
        }
        count = strtoul (val, &end, 10);
@@ -5121,7 +5121,7 @@ set_hsmode (char* val, int allow_empty)
                hs_mode_gc = count;
        else
                usage (1);
-       free (val);
+       g_free (val);
 }
 
 /*
@@ -5206,7 +5206,7 @@ mono_profiler_startup (const char *desc)
                                fast_time = 2;
                        else
                                usage (1);
-                       free (val);
+                       g_free (val);
                        continue;
                }
                if ((opt = match_option (p, "report", NULL)) != p) {
@@ -5256,7 +5256,7 @@ mono_profiler_startup (const char *desc)
                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) {
@@ -5264,7 +5264,7 @@ mono_profiler_startup (const char *desc)
                        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;
                }
@@ -5273,13 +5273,13 @@ mono_profiler_startup (const char *desc)
                        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) {
index c3e14e4af89065ae8683cd821e6d155251eab515..cfa7589a6b2bd0edaf550bea60c8250e680bc536 100644 (file)
@@ -26,7 +26,7 @@
 #include <pthread.h>
 #include <sched.h>
 #endif
-
+#include <glib.h>
 
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
@@ -61,7 +61,7 @@ typedef struct {
 
 #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;
@@ -69,7 +69,7 @@ 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
 
index 50369b0a783f22a7314279f70f0416c6a3ab84aa..af9fd1e33d525a20df807957f744911e64deb73a 100644 (file)
@@ -573,10 +573,10 @@ sgen_card_tables_collect_stats (gboolean begin)
 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
index f073dc740648154853db6016d8a4564f7f137fe0..04de0ac5876ea17087fb04e4cdf546437044444a 100644 (file)
@@ -216,7 +216,7 @@ is_major_or_los_object_marked (GCObject *obj)
 #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))); \
@@ -243,8 +243,6 @@ check_mod_union_callback (GCObject *obj, size_t size, void *dummy)
        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"
 }
 
@@ -253,7 +251,7 @@ sgen_check_mod_union_consistency (void)
 {
        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);
 
@@ -326,7 +324,7 @@ static void
 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);
 }
@@ -445,7 +443,7 @@ verify_object_pointers_callback (GCObject *obj, size_t size, void *data)
 {
        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"
 }
index 842144e56f4aed079bbed1dd86e77c6b57ee5920..f83cffc919e0364ae1aae42c0513fba6699f66c7 100644 (file)
@@ -1169,7 +1169,6 @@ finish_gray_stack (int generation, ScanCopyContext ctx)
 
        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);
 }
 
@@ -1461,7 +1460,7 @@ enqueue_scan_from_roots_jobs (SgenGrayQueue *gc_thread_gray_queue, char *heap_st
  * 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;
@@ -1529,11 +1528,6 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
 
        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 */
@@ -1552,6 +1546,11 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
        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));
@@ -1697,7 +1696,7 @@ major_copy_or_mark_from_roots (SgenGrayQueue *gc_thread_gray_queue, size_t *old_
        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);
@@ -1786,13 +1785,6 @@ major_copy_or_mark_from_roots (SgenGrayQueue *gc_thread_gray_queue, size_t *old_
        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));
@@ -1975,9 +1967,6 @@ major_finish_collection (SgenGrayQueue *gc_thread_gray_queue, const char *reason
        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.
@@ -2257,7 +2246,7 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
                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";
                }
@@ -2267,7 +2256,7 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
        } 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)) {
@@ -2285,7 +2274,7 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
                 */
 
                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);
 
@@ -3259,7 +3248,7 @@ sgen_check_whole_heap_stw (void)
 {
        sgen_stop_world (0);
        sgen_clear_nursery_fragments ();
-       sgen_check_whole_heap (FALSE);
+       sgen_check_whole_heap (TRUE);
        sgen_restart_world (0);
 }
 
index f67a15cd74aac377e7eded4aecf705bf60fcd789..aefb07f23c5b6a99b9f3510a43d90c353f7a829d 100644 (file)
@@ -599,7 +599,6 @@ typedef enum {
        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
@@ -654,7 +653,7 @@ struct _SgenMajorCollector {
        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);
index 9b5f92a19547916049f9129c7ed8a1fd360497c8..f8f04c145807db19fb27a7676f73d36f77555a05 100644 (file)
@@ -49,8 +49,6 @@ sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue)
 {
        GrayQueueSection *section;
 
-       HEAVY_STAT (stat_gray_queue_section_alloc ++);
-
        if (queue->alloc_prepare_func)
                queue->alloc_prepare_func (queue);
 
@@ -60,6 +58,8 @@ sgen_gray_object_alloc_queue_section (SgenGrayQueue *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);
index 12ace19a3e904e4782f5bdc8febd21709cb3e78d..ca30670b71ab4e712d39639fc1c7e6bd2e2ba307 100644 (file)
@@ -23,13 +23,13 @@ static const int allocator_sizes [] = {
           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))
@@ -158,7 +158,7 @@ sgen_alloc_internal_dynamic (size_t size, int type, gboolean assert_on_failure)
        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 {
@@ -183,7 +183,7 @@ sgen_free_internal_dynamic (void *addr, size_t size, int type)
                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));
 }
@@ -260,7 +260,7 @@ sgen_init_internal_allocator (void)
        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) {
index c032d1946f41c18b3dcf1df001b2f1b976025253..454cb89fda70eb88ce31bd6277b148fb323acf64 100644 (file)
@@ -251,7 +251,7 @@ get_los_section_memory (size_t size)
        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;
@@ -323,13 +323,13 @@ sgen_los_free_object (LOSObject *obj)
        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 {
@@ -379,7 +379,7 @@ sgen_los_alloc_large_inner (GCVTable vtable, size_t size)
        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) {
@@ -387,7 +387,7 @@ sgen_los_alloc_large_inner (GCVTable vtable, size_t size)
                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);
@@ -479,7 +479,7 @@ sgen_los_sweep (void)
                                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;
index a215c44502c12b226359ff45fddafe511f569374..8ae553c23b3d90687ef6ac7720a4e0d68127b155 100644 (file)
@@ -240,12 +240,10 @@ static guint64 stat_major_blocks_alloced = 0;
 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;
@@ -297,9 +295,9 @@ major_alloc_heap (mword nursery_size, mword nursery_align, int the_nursery_bits)
 {
        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;
 }
@@ -331,7 +329,7 @@ ms_get_empty_block (void)
                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;
@@ -872,6 +870,7 @@ major_iterate_objects (IterateObjectsFlags flags, IterateObjectCallbackFunc call
        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;
@@ -881,26 +880,13 @@ major_iterate_objects (IterateObjectsFlags flags, IterateObjectCallbackFunc call
                        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);
                }
@@ -1953,7 +1939,6 @@ major_finish_major_collection (ScannedObjectCounts *counts)
 #endif
 }
 
-#if SIZEOF_VOID_P != 8
 static int
 compare_pointers (const void *va, const void *vb) {
        char *a = *(char**)va, *b = *(char**)vb;
@@ -1963,17 +1948,13 @@ compare_pointers (const void *va, const void *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
@@ -1984,7 +1965,6 @@ major_free_swept_blocks (size_t allowance)
                return;
 #endif
 
-#if SIZEOF_VOID_P != 8
        {
                int i, num_empty_blocks_orig, num_blocks, arr_length;
                void *block;
@@ -2057,7 +2037,7 @@ major_free_swept_blocks (size_t allowance)
                                         * 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;
@@ -2104,11 +2084,10 @@ major_free_swept_blocks (size_t allowance)
         */
        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
@@ -2117,9 +2096,7 @@ major_free_swept_blocks (size_t allowance)
                --num_empty_blocks;
 
                ++stat_major_blocks_freed;
-#if SIZEOF_VOID_P != 8
                ++stat_major_blocks_freed_individual;
-#endif
        }
 }
 
@@ -2608,12 +2585,10 @@ sgen_marksweep_init_internal (SgenMajorCollector *collector, gboolean is_concurr
        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;
 
index e7de362976055377c0a67e6da9e4874d0c3b2db5..dc69381547f60bfb192de3cbec934092f20022c3 100644 (file)
@@ -111,7 +111,7 @@ sgen_memgov_calculate_minor_collection_allowance (void)
 
        /* 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;
 
@@ -384,13 +384,13 @@ sgen_assert_memory_alloc (void *ptr, size_t requested_size, const char *assert_d
  * 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);
@@ -400,14 +400,15 @@ sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_desc
 }
 
 /* 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);
@@ -420,11 +421,11 @@ sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags
  * 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);
 }
@@ -476,8 +477,8 @@ sgen_memgov_init (size_t max_heap, size_t soft_limit, gboolean debug_allowance,
        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);
 
index d669e4730d18a058c44a026e9ae7dd48446c71a5..585fbe9a8388af909098645da5304d8a7ff2e121 100644 (file)
@@ -54,9 +54,9 @@ typedef struct {
 } 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);
index ce504201f62d7ce42f8c0f5d64df086f7ed9d786..8b9c432961fee581d76dc597dd08f7179617c72e 100644 (file)
@@ -231,7 +231,7 @@ binary_protocol_flush_buffer (BinaryProtocolBuffer *buffer)
 
        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
@@ -315,12 +315,12 @@ binary_protocol_get_buffer (int length)
        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;
        }
 
index dfdff8c9062f2a7e25f8b5d5591ebc1b1b598187..76eebdd86edfe066f5bfbdf1c6c51d6ad562372e 100644 (file)
@@ -97,7 +97,7 @@ sgen_workers_ensure_awake (void)
 }
 
 static void
-worker_try_finish (void)
+worker_try_finish (WorkerData *data)
 {
        State old_state;
 
@@ -115,6 +115,8 @@ worker_try_finish (void)
        } 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
@@ -226,7 +228,7 @@ marker_idle_func (void *data_untyped)
                        sgen_thread_pool_job_enqueue (job);
                        preclean_job = NULL;
                } else {
-                       worker_try_finish ();
+                       worker_try_finish (data);
                }
        }
 }
index 41e4a9b9a4c918db35c8df0c01968b8dec3eb3e3..36e5c9a5ef011089ec301d63461b37cf7fa6b52a 100644 (file)
@@ -6,7 +6,7 @@ else
 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
@@ -468,7 +468,7 @@ BASE_TEST_CS_SRC_UNIVERSAL=         \
        bug-29585.cs    \
        priority.cs     \
        abort-cctor.cs  \
-       reference-loader.cs
+       namedmutex-destroy-race.cs
 
 if INSTALL_MOBILE_STATIC
 BASE_TEST_CS_SRC= \
@@ -801,22 +801,18 @@ endif
 # 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)
@@ -837,12 +833,6 @@ endif
 %.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) $<
 
@@ -1076,6 +1066,14 @@ test-type-load: $(TEST_DRIVER_DEPEND)
        @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
diff --git a/mono/tests/TestingReferenceAssembly.cs b/mono/tests/TestingReferenceAssembly.cs
deleted file mode 100644 (file)
index e68a2c8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-using System.Runtime.CompilerServices;
-
-[assembly: ReferenceAssemblyAttribute]
-
-public class X {
-       public int Y;
-}
diff --git a/mono/tests/TestingReferenceReferenceAssembly.cs b/mono/tests/TestingReferenceReferenceAssembly.cs
deleted file mode 100644 (file)
index 0acb6f1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// An assembly that refereces the TestingReferenceAssembly
-
-class Z : X {
-       public Z () {
-               Y = 1;
-       }
-}
diff --git a/mono/tests/namedmutex-destroy-race.cs b/mono/tests/namedmutex-destroy-race.cs
new file mode 100644 (file)
index 0000000..265f146
--- /dev/null
@@ -0,0 +1,45 @@
+
+/* 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
diff --git a/mono/tests/reference-loader.cs b/mono/tests/reference-loader.cs
deleted file mode 100644 (file)
index 9cdda7a..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-//
-// 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;
-       }
-
-}
diff --git a/mono/tests/test-multi-netmodule-1-netmodule.cs b/mono/tests/test-multi-netmodule-1-netmodule.cs
new file mode 100644 (file)
index 0000000..2abdc39
--- /dev/null
@@ -0,0 +1,4 @@
+// Compiler options: -t:module
+
+public class M1 {
+}
diff --git a/mono/tests/test-multi-netmodule-2-dll1.cs b/mono/tests/test-multi-netmodule-2-dll1.cs
new file mode 100644 (file)
index 0000000..018db84
--- /dev/null
@@ -0,0 +1,5 @@
+// Compiler options: -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library
+
+public class M2 {
+       public M1 m1 = new M1();
+}
diff --git a/mono/tests/test-multi-netmodule-3-dll2.cs b/mono/tests/test-multi-netmodule-3-dll2.cs
new file mode 100644 (file)
index 0000000..4229b80
--- /dev/null
@@ -0,0 +1,5 @@
+// Compiler options: -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library
+
+public class M3 {
+       public M1 m1 = new M1();
+}
diff --git a/mono/tests/test-multi-netmodule-4-exe.cs b/mono/tests/test-multi-netmodule-4-exe.cs
new file mode 100644 (file)
index 0000000..03cd242
--- /dev/null
@@ -0,0 +1,28 @@
+// 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;
+       }
+}
index 6f5606bdb80919b7890bd9bed1da15997a77757d..82ce187e9c874058f1d4c5c732764d5c8fb7b3e1 100644 (file)
@@ -146,7 +146,7 @@ translate_backtrace (gpointer native_trace[], int size)
                        g_string_append_printf (bt, "\tat %s\n", names [i]);
        }
 
-       free (names);
+       g_free (names);
        return g_string_free (bt, FALSE);
 }
 
@@ -473,6 +473,12 @@ check_image_may_reference_image(MonoImage *from, MonoImage *to)
                        // 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]);
@@ -480,12 +486,7 @@ check_image_may_reference_image(MonoImage *from, MonoImage *to)
 
                        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);
index cddcd1c63b037edc4192e7e2fb0c969372f350bc..cc00f5c8eba8b3d44318745c735ec03ce4abae32 100644 (file)
@@ -52,7 +52,7 @@ static volatile gint32 overflow_busy [HAZARD_TABLE_OVERFLOW];
 
 /* 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;
@@ -112,7 +112,7 @@ mono_thread_small_id_alloc (void)
                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);
index d5da3896343906457b70d185db3f4df793f9828e..08b4deff37c0379b92524ce00ee5788e717b57b0 100644 (file)
@@ -138,8 +138,8 @@ alloc_sb (Descriptor *desc)
                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));
 
@@ -150,11 +150,11 @@ alloc_sb (Descriptor *desc)
 }
 
 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);
 }
 
@@ -162,7 +162,7 @@ free_sb (gpointer sb, size_t block_size)
 static Descriptor * volatile desc_avail;
 
 static Descriptor*
-desc_alloc (void)
+desc_alloc (MonoMemAccountType type)
 {
        MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
        Descriptor *desc;
@@ -179,7 +179,7 @@ desc_alloc (void)
                        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;
@@ -195,7 +195,7 @@ desc_alloc (void)
                        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);
@@ -232,27 +232,27 @@ desc_retire (Descriptor *desc)
        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
@@ -390,7 +390,7 @@ static gpointer
 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;
@@ -611,8 +611,9 @@ mono_lock_free_allocator_init_size_class (MonoLockFreeAllocSizeClass *sc, unsign
 }
 
 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;
 }
index f0420b492ec1bc39ee043f826f85bd933996ea0f..70d550d95c239b6b6d5ce5d868f31633a590c7d1 100644 (file)
@@ -41,14 +41,15 @@ struct _MonoLockFreeAllocDescriptor;
 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);
index b0d0a9a1dfe593ab67005f1cb52e960b0d89447b..5e48558a0d94c438b9afd9db4994ce8c538b7002 100644 (file)
@@ -45,16 +45,16 @@ alloc_chunk (MonoLockFreeArray *arr)
 {
        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
@@ -68,7 +68,7 @@ mono_lock_free_array_nth (MonoLockFreeArray *arr, int index)
                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;
@@ -80,7 +80,7 @@ mono_lock_free_array_nth (MonoLockFreeArray *arr, int index)
                        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);
                        }
@@ -116,7 +116,7 @@ mono_lock_free_array_cleanup (MonoLockFreeArray *arr)
        arr->chunk_list = NULL;
        while (chunk) {
                Chunk *next = chunk->next;
-               free_chunk (chunk);
+               free_chunk (chunk, arr->account_type);
                chunk = next;
        }
 }
index fc924a7639ab011bf567d6f44db039d9648ee899..8e198e9227df62230c3e31cf092401d66c117c15 100644 (file)
 
 #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 {
@@ -23,8 +25,8 @@ 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);
 
index 83c2bdcc690dcf1847789d4491897350cf6dea90..56948bdd901da23ae66edd34b6e7d19cf218c902 100644 (file)
@@ -115,9 +115,9 @@ codechunk_valloc (void *preferred, guint32 size)
                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;
@@ -134,7 +134,7 @@ codechunk_vfree (void *ptr, guint32 size)
                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);
 }              
@@ -153,7 +153,7 @@ codechunk_cleanup (void)
                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);
        }
@@ -234,7 +234,7 @@ free_chunklist (CodeChunk *chunk)
                        dlfree (dead->data);
                }
                code_memory_used -= dead->size;
-               free (dead);
+               g_free (dead);
        }
 }
 
@@ -249,7 +249,7 @@ mono_code_manager_destroy (MonoCodeManager *cman)
 {
        free_chunklist (cman->full);
        free_chunklist (cman->current);
-       free (cman);
+       g_free (cman);
 }
 
 /**
@@ -398,12 +398,12 @@ new_codechunk (CodeChunk *last, int dynamic, int size)
 #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;
index 1bd0a646054f2e7e7586ad1e8b46b4ce2c215969..cf631d04ffd1ffbab5ad389a20239da3fa6acf4a 100644 (file)
@@ -35,10 +35,10 @@ mono_coop_mutex_init_recursive (MonoCoopMutex *mutex)
        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
@@ -73,10 +73,10 @@ mono_coop_cond_init (MonoCoopCond *cond)
        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
index 2ca19a8b3d645fca66230e58f15d4b0e2b9cccf2..f867960803ba46f7c81f828b8a4e56fc614fd382 100644 (file)
@@ -166,7 +166,7 @@ register_internal (const char *name, int type, void *addr, int size)
                }
        }
 
-       counter = (MonoCounter *) malloc (sizeof (MonoCounter));
+       counter = (MonoCounter *) g_malloc (sizeof (MonoCounter));
        if (!counter) {
                mono_os_mutex_unlock (&counters_mutex);
                return;
@@ -347,6 +347,13 @@ page_faults (void)
        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)
 {
@@ -648,8 +655,8 @@ mono_counters_cleanup (void)
        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);
index 43116130309eec7195e24a87f8d39e10e544dbce..6c0f582cf6d1ddc170d86bf4f6fb40374138525a 100644 (file)
@@ -140,7 +140,7 @@ mono_dl_open (const char *name, int flags, char **error_msg)
        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");
@@ -174,7 +174,7 @@ mono_dl_open (const char *name, int flags, char **error_msg)
                const char *ext;
                /* This platform does not support dlopen */
                if (name == NULL) {
-                       free (module);
+                       g_free (module);
                        return NULL;
                }
                
@@ -193,7 +193,7 @@ mono_dl_open (const char *name, int flags, char **error_msg)
                        if (error_msg) {
                                *error_msg = mono_dl_current_error_string ();
                        }
-                       free (module);
+                       g_free (module);
                        return NULL;
                }
        }
@@ -224,11 +224,11 @@ mono_dl_symbol (MonoDl *module, const char *name, void **symbol)
        } 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);
@@ -264,7 +264,7 @@ mono_dl_close (MonoDl *module)
        } else
                mono_dl_close_handle (module);
        
-       free (module);
+       g_free (module);
 }
 
 /**
index cf73d9acbb84cbcafc5328dc5fb6b3b6f9975e50..4948b91b80fbd84435428d56098e47d751d3b2a0 100644 (file)
@@ -132,7 +132,7 @@ mono_log_write_logfile (const char *log_domain, GLogLevelFlags level, mono_bool
 
        fflush(logFile);
 
-       if (level == G_LOG_FLAG_FATAL)
+       if (level & G_LOG_LEVEL_ERROR)
                abort();
 }
 
index 388fd26202f6c5f4b2b936b6bf81592d6ed0d049..6d25d3a6117b7cc4237bc10c8c6ef9e1e67cec3d 100644 (file)
@@ -84,7 +84,7 @@ mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, c
 {
        syslog (mapSyslogLevel(level), "%s", message);
 
-       if (level == G_LOG_FLAG_FATAL)
+       if (level & G_LOG_LEVEL_ERROR)
                abort();
 }
 
index d0ee01994371e00665dcea0f29e18634b377a66d..f6cd987fbba85c31ebda11b966b220ef3067f7ac 100644 (file)
@@ -104,7 +104,7 @@ mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, c
 
        fflush(logFile);
 
-       if (level == G_LOG_FLAG_FATAL)
+       if (level & G_LOG_LEVEL_ERROR)
                abort();
 }
 
index 7fa483ce593747f586e4842fed1a720ffeff2dee..491318465faf804a0767d46b45b838d8020814b5 100644 (file)
@@ -35,6 +35,8 @@
 #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 { \
@@ -84,6 +86,54 @@ aligned_address (char *mem, size_t size, size_t alignment)
        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
@@ -118,7 +168,7 @@ prot_from_flags (int flags)
 }
 
 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;
@@ -126,11 +176,14 @@ mono_valloc (void *addr, size_t length, int flags)
        /* 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);
@@ -144,13 +197,15 @@ mono_valloc_aligned (size_t length, size_t alignment, int flags)
        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));
@@ -162,6 +217,8 @@ mono_vfree (void *addr, size_t length)
 
        g_assert (res);
 
+       account_mem (type, -(ssize_t)length);
+
        return 0;
 }
 
@@ -307,7 +364,7 @@ prot_from_flags (int flags)
  * 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;
@@ -334,6 +391,9 @@ mono_valloc (void *addr, size_t length, int flags)
 
        if (ptr == MAP_FAILED)
                return NULL;
+
+       account_mem (type, (ssize_t)length);
+
        return ptr;
 }
 
@@ -347,12 +407,15 @@ mono_valloc (void *addr, size_t length, int flags)
  * 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;
 }
 
@@ -482,13 +545,13 @@ mono_pagesize (void)
 }
 
 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 ();
 }
@@ -496,9 +559,9 @@ mono_valloc_aligned (size_t length, size_t alignment, int flags)
 #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;
 }
 
@@ -747,10 +810,10 @@ mono_shared_area_instances (void **array, int count)
 
 #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)
@@ -759,9 +822,9 @@ mono_valloc_aligned (size_t size, size_t alignment, int flags)
        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;
 }
index 017bbcec5bb6aab1b023661caa5b2102b17469b7..d441751c802da5bb60f36c29d638377b7f426c26 100644 (file)
@@ -20,6 +20,24 @@ enum {
        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
  */
@@ -31,9 +49,9 @@ MONO_API int          mono_file_map_fd    (MonoFileMap *fmap);
 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
@@ -42,6 +60,9 @@ MONO_API int   mono_file_unmap_fileio (void *addr, void *handle);
 #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);
index 52cef09d84bcb8f84b3ed15d22b179ea516a94ef..cd33375894c1db0f95fdf61ae054c50043a18f2d 100644 (file)
@@ -76,16 +76,14 @@ mono_os_mutex_init_recursive (mono_mutex_t *mutex)
                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
@@ -130,16 +128,14 @@ mono_os_cond_init (mono_cond_t *cond)
                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
@@ -296,11 +292,10 @@ mono_os_mutex_init_recursive (mono_mutex_t *mutex)
                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
@@ -327,11 +322,10 @@ mono_os_cond_init (mono_cond_t *cond)
        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
index 7a589314f1f43b5032ec78182bd4a377e00ba22e..79da32b45118f4e6f992207c723ce14f880477c0 100644 (file)
@@ -80,7 +80,7 @@ mono_process_list (int *size)
 #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;
@@ -105,7 +105,7 @@ mono_process_list (int *size)
 
        res = sysctl (mib, 6, processes, &data_len, NULL, 0);
        if (res < 0) {
-               free (processes);
+               g_free (processes);
                return NULL;
        }
 #else
@@ -119,10 +119,10 @@ mono_process_list (int *size)
                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 --;
@@ -140,7 +140,7 @@ mono_process_list (int *size)
        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;
index 67b470467b96339e10e560a26f99a1f2ee644b07..a8a5b53274e95a0041f8ca6cbed2510df8229c40 100644 (file)
@@ -45,18 +45,10 @@ mono_threads_platform_register (MonoThreadInfo *info)
 {
        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;
 }
@@ -66,6 +58,8 @@ mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_
 {
        pthread_attr_t attr;
        pthread_t thread;
+       int policy;
+       struct sched_param param;
        gint res;
 
        res = pthread_attr_init (&attr);
@@ -92,6 +86,45 @@ mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_
        g_assert (!res);
 #endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */
 
+       memset (&param, 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, &param);
+       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)
@@ -141,6 +174,14 @@ mono_threads_get_max_stack_size (void)
        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)
 {
@@ -246,29 +287,14 @@ mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
 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);
 
@@ -283,107 +309,6 @@ mono_threads_platform_set_exited (MonoThreadInfo *info)
        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, &param);
-       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, &param);
-       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";
index 4f8495054334310bb2f7289e8778e657915e59f2..e2b489ecc1064f6eea5fc9c1bd76818232ef1941 100644 (file)
@@ -253,6 +253,17 @@ mono_threads_get_max_stack_size (void)
        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)
 {
@@ -306,43 +317,6 @@ mono_threads_platform_set_exited (MonoThreadInfo *info)
        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)
 {
index 22eea19051cb75bd82a0003e0d0214a9dd406d06..ccb9121d0b6245a5558c099246ae535bbafe3eea 100644 (file)
@@ -1138,7 +1138,7 @@ typedef struct {
        gpointer start_routine_arg;
        gint32 priority;
        MonoCoopSem registered;
-       MonoThreadInfo *info;
+       gpointer handle;
 } CreateThreadData;
 
 static gsize WINAPI
@@ -1149,7 +1149,6 @@ inner_start_thread (gpointer data)
        MonoThreadStart start_routine;
        gpointer start_routine_arg;
        guint32 start_routine_res;
-       gint32 priority;
        gsize dummy;
 
        thread_data = (CreateThreadData*) data;
@@ -1158,14 +1157,10 @@ inner_start_thread (gpointer 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);
 
@@ -1192,10 +1187,9 @@ inner_start_thread (gpointer data)
  * 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;
 
@@ -1203,10 +1197,9 @@ mono_threads_create_thread (MonoThreadStart start, gpointer arg, MonoThreadParm
        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);
@@ -1217,10 +1210,7 @@ mono_threads_create_thread (MonoThreadStart start, gpointer arg, MonoThreadParm
        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:
@@ -1288,7 +1278,7 @@ sleep_interruptable (guint32 ms, gboolean *alerted)
        *alerted = FALSE;
 
        if (ms != INFINITE)
-               end = mono_100ns_ticks () + (ms * 1000 * 10);
+               end = mono_msec_ticks() + ms;
 
        mono_lazy_initialize (&sleep_init, sleep_initialize);
 
@@ -1296,8 +1286,8 @@ sleep_interruptable (guint32 ms, gboolean *alerted)
 
        for (;;) {
                if (ms != INFINITE) {
-                       now = mono_100ns_ticks ();
-                       if (now > end)
+                       now = mono_msec_ticks();
+                       if (now >= end)
                                break;
                }
 
@@ -1308,7 +1298,7 @@ sleep_interruptable (guint32 ms, gboolean *alerted)
                }
 
                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);
 
@@ -1666,38 +1656,8 @@ mono_thread_info_set_exited (THREAD_INFO_TYPE *info)
 }
 
 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);
 }
index 5aafac7d7c28cad1ff71a1500dc066f03e945766..db4bdab73b73dee37082ed8fbdf610a64c4902b7 100644 (file)
@@ -241,12 +241,6 @@ typedef struct {
 
        /* 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 {
@@ -285,23 +279,6 @@ typedef enum {
 
 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)
 {
@@ -466,7 +443,7 @@ gboolean
 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);
@@ -546,11 +523,7 @@ void mono_threads_platform_exit (int exit_code);
 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);
@@ -666,21 +639,6 @@ gboolean
 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__ */
index 7a2c4ac8100ebd9afec9607a8b7b0640c498f3a5..8ebc25a69b303019f66ecd117a2e9f7a5843a0c1 100644 (file)
@@ -36,7 +36,7 @@ mono_escape_uri_string (const gchar *string)
 #if TEST
 int main ()
 {
-       char *s = malloc (256);
+       char *s = g_malloc (256);
        int i = 0;
        
        s [255] = 0;
index 5fd01a3db23a1edd6ca2804ec731a61c409919bb..d9957cef896a9e8faa99a2b3607113d7631c4b9e 100644 (file)
@@ -322,8 +322,6 @@ mono_w32handle_init (void)
        initialized = TRUE;
 }
 
-static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_busy_handles);
-
 void
 mono_w32handle_cleanup (void)
 {
@@ -345,7 +343,7 @@ 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);
                        }
                }
        }
@@ -357,6 +355,8 @@ mono_w32handle_cleanup (void)
 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;
@@ -432,9 +432,6 @@ mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific)
 
        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);
@@ -457,6 +454,7 @@ mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific)
        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;
        }
 
@@ -465,7 +463,7 @@ mono_w32handle_new (MonoW32HandleType type, gpointer handle_specific)
 
        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);
@@ -479,13 +477,10 @@ gpointer mono_w32handle_new_fd (MonoW32HandleType type, int fd,
 
        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));
        }
@@ -506,13 +501,14 @@ gpointer mono_w32handle_new_fd (MonoW32HandleType type, int fd,
        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);
 
@@ -540,25 +536,49 @@ mono_w32handle_lookup (gpointer handle, MonoW32HandleType type,
        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;
                }
        }
 
@@ -566,6 +586,31 @@ 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
@@ -580,43 +625,60 @@ gpointer mono_w32handle_search (MonoW32HandleType type,
                              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)
@@ -624,46 +686,32 @@ 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
@@ -679,35 +727,15 @@ static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_
 
                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);
@@ -717,11 +745,6 @@ static void mono_w32handle_unref_full (gpointer handle, gboolean ignore_private_
        }
 }
 
-void mono_w32handle_unref (gpointer handle)
-{
-       mono_w32handle_unref_full (handle, FALSE);
-}
-
 void
 mono_w32handle_register_ops (MonoW32HandleType type, MonoW32HandleOps *ops)
 {
@@ -817,7 +840,7 @@ void mono_w32handle_ops_signal (gpointer handle)
        }
 }
 
-gboolean mono_w32handle_ops_own (gpointer handle)
+gboolean mono_w32handle_ops_own (gpointer handle, guint32 *statuscode)
 {
        MonoW32HandleBase *handle_data;
        MonoW32HandleType type;
@@ -829,7 +852,7 @@ gboolean mono_w32handle_ops_own (gpointer handle)
        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);
        }
@@ -1101,53 +1124,46 @@ mono_w32handle_timedwait_signal_handle (gpointer handle, guint32 timeout, gboole
        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;
 }
 
@@ -1158,6 +1174,7 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
        gboolean alerted;
        gint64 start;
        gint thr_ret;
+       guint32 statuscode = 0;
 
        alerted = FALSE;
 
@@ -1169,6 +1186,9 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
                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;
@@ -1199,11 +1219,11 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
        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;
                }
        }
@@ -1214,11 +1234,11 @@ mono_w32handle_wait_one (gpointer handle, guint32 timeout, gboolean alertable)
        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;
                }
 
@@ -1264,6 +1284,7 @@ mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waital
        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;
@@ -1346,13 +1367,19 @@ mono_w32handle_wait_multiple (gpointer *handles, gsize nhandles, gboolean waital
 
                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;
                }
 
@@ -1439,6 +1466,7 @@ mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, gu
        gint64 start;
        gboolean alerted;
        gint thr_ret;
+       guint32 statuscode = 0;
 
        alerted = FALSE;
 
@@ -1458,11 +1486,11 @@ mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, gu
        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;
                }
        }
@@ -1473,11 +1501,11 @@ mono_w32handle_signal_and_wait (gpointer signal_handle, gpointer wait_handle, gu
        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;
                }
 
index 27c403ce39dde47cb9563be14b0d5d58ecc5bdb0..de65da19e9fb9c106f45097e5a1ff1ebf6042cf3 100644 (file)
@@ -39,8 +39,10 @@ typedef struct
        /* 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
@@ -129,7 +131,7 @@ void
 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);
@@ -165,10 +167,11 @@ int
 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
index 41f6439154b8065c50523f175f48f0c55c97835b..78517bc7c3aece3e8f2b96fc3d519c791872fe43 100644 (file)
@@ -26,6 +26,9 @@
     <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
index 13f50fb2be4cdd5171a246f051f07b3b60db1da9..ba4d25f1ba94d8e9c6028b819c66bbfb4f414532 100644 (file)
     <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
index 2251543e666491a794934617bde33931d99d5dfd..f5a0e9ab98ae02180157b09927d2fccd54f239a3 100644 (file)
@@ -241,6 +241,7 @@ mono_disasm_code
 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
@@ -495,6 +496,7 @@ mono_ldstr
 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
index 1f82284e7c29e944108087ebb05d2fa117fdac27..1722591c2f397fcd574413a75dd699b8602dcec5 100644 (file)
@@ -241,6 +241,7 @@ mono_disasm_code
 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
@@ -497,6 +498,7 @@ mono_ldstr
 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
index d2424feca659f855fe33bd575d5348dc83ffd53b..e958929f8e2f12ed3059b7ed98adbd07be2ab915 100644 (file)
       <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>
index ba17c5e4e215857005ff74c9b74f17746742998a..97642ca158a70e2e16d7b747fe3516f163d25cb0 100644 (file)
@@ -181,10 +181,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Web.Http.SelfHost-ne
 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}"
@@ -287,10 +283,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows-net_4_x", "m
 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}"
@@ -1041,14 +1033,6 @@ Global
                {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
@@ -1253,14 +1237,6 @@ Global
                {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