Merge pull request #5014 from vkargov/vk-kasha
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Fri, 16 Jun 2017 18:42:20 +0000 (14:42 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Jun 2017 18:42:20 +0000 (14:42 -0400)
[jit] Always cache the latest image set in case of a cache miss.

586 files changed:
.gitmodules
Makefile.am
configure.ac
eglib/src/eglib-config.h.in
eglib/src/gfile-posix.c
external/api-snapshot
external/bockbuild
external/buildtools [deleted submodule]
external/cecil
external/corefx
external/corert
external/ikdasm
external/ikvm
external/xunit-binaries
man/mono.1
mcs/AUTHORS
mcs/COPYING
mcs/CodingStyle
mcs/INSTALL.txt
mcs/Makefile
mcs/README
mcs/build/build.proj [deleted file]
mcs/build/common/basic-profile-check.cs
mcs/build/msbuild/.gitattributes [deleted file]
mcs/build/msbuild/Mono.Common.targets [deleted file]
mcs/build/msbuild/Mono.Default.targets [deleted file]
mcs/build/profiles/basic.make
mcs/build/profiles/build.make
mcs/build/tests.make
mcs/class/Facades/System.Data.Common/AssemblyInfo.cs
mcs/class/Facades/System.Data.Common/TypeForwarders.cs
mcs/class/Facades/System.Diagnostics.StackTrace/AssemblyInfo.cs
mcs/class/Facades/System.Diagnostics.StackTrace/TypeForwarders.cs
mcs/class/Facades/System.Diagnostics.Tracing/AssemblyInfo.cs
mcs/class/Facades/System.Globalization.Extensions/AssemblyInfo.cs
mcs/class/Facades/System.Net.Ping/AssemblyInfo.cs
mcs/class/Facades/System.Net.Sockets/AssemblyInfo.cs
mcs/class/Facades/System.Net.Sockets/TypeForwarders.cs
mcs/class/Facades/System.Runtime.InteropServices.RuntimeInformation/Assembly/AssemblyInfo.cs
mcs/class/Facades/System.Runtime.InteropServices.RuntimeInformation/Facades_System.Runtime.InteropServices.RuntimeInformation-net_4_x.csproj
mcs/class/Facades/System.Runtime.InteropServices.RuntimeInformation/Makefile
mcs/class/Facades/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices/RuntimeInformation.cs
mcs/class/Facades/System.Runtime.Serialization.Primitives/AssemblyInfo.cs
mcs/class/Facades/System.Runtime.Serialization.Primitives/TypeForwarders.cs
mcs/class/Facades/System.Security.Cryptography.Algorithms/AssemblyInfo.cs
mcs/class/Facades/System.Security.Cryptography.Algorithms/TypeForwarders.cs
mcs/class/Facades/System.Security.SecureString/AssemblyInfo.cs
mcs/class/Facades/System.Threading.Overlapped/AssemblyInfo.cs
mcs/class/Facades/System.Threading.Overlapped/TypeForwarders.cs
mcs/class/Facades/System.ValueTuple/AssemblyInfo.cs
mcs/class/Facades/System.Xml.XPath.XDocument/AssemblyInfo.cs
mcs/class/LICENSE
mcs/class/Makefile
mcs/class/Microsoft.CSharp/Microsoft.CSharp-net_4_x.csproj
mcs/class/Microsoft.CSharp/Microsoft.CSharp.dll.sources
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ILInterpreter.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/MethodMirror.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/StackFrame.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs
mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs
mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
mcs/class/Mono.Debugger.Soft/Test/dtest.cs
mcs/class/Mono.Options/Test/Mono.Options/CommandSetTest.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionContextTest.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionSetTest.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionTest.cs
mcs/class/Mono.Posix/Assembly/AssemblyInfo.cs
mcs/class/Mono.Posix/Mono.Posix.NETStandard-netstandard_2_0.csproj [new file with mode: 0644]
mcs/class/Mono.Posix/Mono.Unix.Native/Stdlib.cs
mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs
mcs/class/Mono.Posix/Mono.Unix/UnixEncoding.cs
mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs
mcs/class/Mono.Posix/Test/Mono.Unix.Native/StdlibTest.cs
mcs/class/Mono.Security/Mono.Security.Interface/IMonoSslStream.cs
mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs
mcs/class/Mono.Security/Mono.Security_test.dll.sources
mcs/class/Mono.Security/Test/Mono.Security.Interface/TestProvider.cs [new file with mode: 0644]
mcs/class/README
mcs/class/System.Drawing/Makefile
mcs/class/System.Drawing/System.Drawing-net_4_x.csproj
mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs
mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs
mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/PathGradientBrush.cs
mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PageSettings.cs
mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrinterSettings.cs
mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServices.cs
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesUnix.cs
mcs/class/System.Drawing/System.Drawing.Printing/PrintingServicesWin32.cs
mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs [deleted file]
mcs/class/System.Drawing/System.Drawing.dll.sources
mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/Brush.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/ExternDll.cs [new file with mode: 0644]
mcs/class/System.Drawing/System.Drawing/Font.cs
mcs/class/System.Drawing/System.Drawing/FontFamily.cs
mcs/class/System.Drawing/System.Drawing/FontStyle.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/Graphics.cs
mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/Image.cs
mcs/class/System.Drawing/System.Drawing/Pen.cs
mcs/class/System.Drawing/System.Drawing/Region.cs
mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/SR.cs [new file with mode: 0644]
mcs/class/System.Drawing/System.Drawing/SolidBrush.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/StringAligment.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/StringFormat.cs
mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/StringTrimming.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/StringUnit.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs [deleted file]
mcs/class/System.Drawing/System.Drawing/TextureBrush.cs [deleted file]
mcs/class/System.Drawing/System.Drawing_test.dll.sources
mcs/class/System.Drawing/corefx/SR.cs [new file with mode: 0644]
mcs/class/System.Numerics/Makefile
mcs/class/System.Numerics/System.Numerics_xtest.dll.sources
mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs
mcs/class/System/Mono.AppleTls/AppleCertificateHelper.cs
mcs/class/System/Mono.AppleTls/AppleTlsContext.cs
mcs/class/System/Mono.AppleTls/AppleTlsStream.cs
mcs/class/System/Mono.AppleTls/ImportExport.cs
mcs/class/System/Mono.Btls/MonoBtlsContext.cs
mcs/class/System/Mono.Btls/MonoBtlsObject.cs
mcs/class/System/Mono.Btls/MonoBtlsSsl.cs
mcs/class/System/Mono.Btls/MonoBtlsStream.cs
mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs
mcs/class/System/Mono.Net.Security/LegacySslStream.cs
mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs
mcs/class/System/Mono.Net.Security/MobileTlsContext.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs
mcs/class/System/ReferenceSources/SR2.cs
mcs/class/System/ReferenceSources/Win32Exception.cs
mcs/class/System/System.Net.Configuration/DefaultProxySection.cs
mcs/class/System/System.Net.Configuration/ProxyElement.cs
mcs/class/System/System.Net.NetworkInformation/Ping.cs
mcs/class/System/System.Net.Security/SslStream.cs
mcs/class/System/System.Net.Security/SslStream.platformnotsupported.cs
mcs/class/System/System.Net.Sockets/Socket.cs
mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
mcs/class/System/System.Net.WebSockets/HttpListenerWebSocketContext.platformnotsupported.cs [new file with mode: 0644]
mcs/class/System/common.sources
mcs/class/System/common_networking.sources
mcs/class/System/monotouch_watch_System.dll.sources
mcs/class/System/net_4_x_System.dll.sources
mcs/class/Xunit.NetCore.Extensions/Makefile [deleted file]
mcs/class/Xunit.NetCore.Extensions/Microsoft.Xunit.Performance/BenchmarkAttribute.cs [deleted file]
mcs/class/Xunit.NetCore.Extensions/Microsoft.Xunit.Performance/BenchmarkDiscover.cs [deleted file]
mcs/class/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.dll.sources [deleted file]
mcs/class/aot-compiler/Makefile
mcs/class/build-rx-dll-sources.sh [deleted file]
mcs/class/corlib/Assembly/AssemblyInfo.cs
mcs/class/corlib/Mono/RuntimeStructs.cs
mcs/class/corlib/System.Diagnostics.Tracing/EventListener.cs
mcs/class/corlib/System.IO/FileStream.cs
mcs/class/corlib/System.Reflection.Emit/FieldBuilder.cs
mcs/class/corlib/System.Runtime.InteropServices/CALLCONV.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/DISPPARAMS.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/ELEMDESC.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/EXCEPINFO.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/FUNCDESC.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/FUNCFLAGS.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/FUNCKIND.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/IDLDESC.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/IDLFLAG.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/IMPLTYPEFLAGS.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/INVOKEKIND.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/PARAMDESC.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/PARAMFLAG.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/TYPEATTR.cs [deleted file]
mcs/class/corlib/System.Runtime.InteropServices/TYPEDESC.cs [deleted file]
mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
mcs/class/corlib/System.Security.AccessControl/AceType.cs
mcs/class/corlib/System.Security.Policy/PolicyException.cs
mcs/class/corlib/System/TimeZoneInfo.cs
mcs/class/corlib/Test/System.IO/FileTest.cs
mcs/class/corlib/Test/System.Reflection.Emit/TypeBuilderTest.cs
mcs/class/corlib/Test/System.Threading/WaitHandleTest.cs
mcs/class/corlib/Test/System/DecimalTest-Microsoft.cs
mcs/class/corlib/corert/Debug.cs
mcs/class/corlib/corlib-net_4_x.csproj
mcs/class/corlib/corlib.dll.sources
mcs/class/monodoc/Test/README.md [new file with mode: 0644]
mcs/class/project_template_android.txt [deleted file]
mcs/class/project_template_ios.txt [deleted file]
mcs/class/referencesource/mscorlib/system/io/filesystemenumerable.cs
mcs/class/referencesource/mscorlib/system/runtime/interopservices/ucomitypeinfo.cs
mcs/errors/cs0019-72.cs [new file with mode: 0644]
mcs/errors/cs0128-3.cs [new file with mode: 0644]
mcs/errors/cs0128-4.cs [new file with mode: 0644]
mcs/errors/cs0136-20.cs [new file with mode: 0644]
mcs/errors/cs0155-5.cs [new file with mode: 0644]
mcs/errors/cs0162-21.cs [new file with mode: 0644]
mcs/errors/cs0165-56.cs [new file with mode: 0644]
mcs/errors/cs0173-6.cs [new file with mode: 0644]
mcs/errors/cs0208-19.cs [new file with mode: 0644]
mcs/errors/cs0411-25.cs [new file with mode: 0644]
mcs/errors/cs0535-7.cs [new file with mode: 0644]
mcs/errors/cs0535-8.cs [new file with mode: 0644]
mcs/errors/cs0815-7.cs [deleted file]
mcs/errors/cs1031-3.cs [new file with mode: 0644]
mcs/errors/cs1043.cs
mcs/errors/cs1061-15.cs
mcs/errors/cs1503-17.cs [deleted file]
mcs/errors/cs1617.cs
mcs/errors/cs1644-47.cs
mcs/errors/cs1644-51.cs [new file with mode: 0644]
mcs/errors/cs1644-52.cs [new file with mode: 0644]
mcs/errors/cs8046.cs [deleted file]
mcs/errors/cs8047.cs [deleted file]
mcs/errors/cs8116.cs [new file with mode: 0644]
mcs/errors/cs8117.cs [new file with mode: 0644]
mcs/errors/cs8122.cs [new file with mode: 0644]
mcs/errors/cs8188.cs [new file with mode: 0644]
mcs/errors/cs8196-2.cs [new file with mode: 0644]
mcs/errors/cs8196.cs [new file with mode: 0644]
mcs/errors/cs8197.cs [new file with mode: 0644]
mcs/errors/cs8198.cs [new file with mode: 0644]
mcs/errors/cs8200-2.cs [new file with mode: 0644]
mcs/errors/cs8200-3.cs [new file with mode: 0644]
mcs/errors/cs8200-4.cs [new file with mode: 0644]
mcs/errors/cs8200-5.cs [new file with mode: 0644]
mcs/errors/cs8200-6.cs [new file with mode: 0644]
mcs/errors/cs8200.cs [new file with mode: 0644]
mcs/errors/cs8201.cs [new file with mode: 0644]
mcs/errors/cs8208.cs [new file with mode: 0644]
mcs/mcs/anonymous.cs
mcs/mcs/argument.cs
mcs/mcs/assign.cs
mcs/mcs/async.cs
mcs/mcs/cfold.cs
mcs/mcs/class.cs
mcs/mcs/context.cs
mcs/mcs/convert.cs
mcs/mcs/cs-parser.jay
mcs/mcs/cs-tokenizer.cs
mcs/mcs/decl.cs
mcs/mcs/driver.cs
mcs/mcs/dynamic.cs
mcs/mcs/ecore.cs
mcs/mcs/eval.cs
mcs/mcs/expression.cs
mcs/mcs/generic.cs
mcs/mcs/import.cs
mcs/mcs/linq.cs
mcs/mcs/location.cs
mcs/mcs/namespace.cs
mcs/mcs/nullable.cs
mcs/mcs/parameter.cs
mcs/mcs/pending.cs
mcs/mcs/property.cs
mcs/mcs/report.cs
mcs/mcs/settings.cs
mcs/mcs/statement.cs
mcs/mcs/support.cs
mcs/mcs/typespec.cs
mcs/tests/gtest-409.cs
mcs/tests/gtest-646-lib.cs [new file with mode: 0644]
mcs/tests/gtest-646.cs [new file with mode: 0644]
mcs/tests/known-issues-net_4_x
mcs/tests/test-943.cs [new file with mode: 0644]
mcs/tests/test-944-lib.cs [new file with mode: 0644]
mcs/tests/test-944.cs [new file with mode: 0644]
mcs/tests/test-945.cs [new file with mode: 0644]
mcs/tests/test-946.cs [new file with mode: 0644]
mcs/tests/test-99.cs
mcs/tests/test-async-92.cs [new file with mode: 0644]
mcs/tests/test-async-93.cs [new file with mode: 0644]
mcs/tests/test-decl-expr-01.cs
mcs/tests/test-decl-expr-02.cs
mcs/tests/test-decl-expr-03.cs [new file with mode: 0644]
mcs/tests/test-decl-expr-04.cs [new file with mode: 0644]
mcs/tests/test-expression-bodied-03.cs [new file with mode: 0644]
mcs/tests/test-pattern-01.cs
mcs/tests/test-pattern-02.cs
mcs/tests/test-static-using-13.cs [new file with mode: 0644]
mcs/tests/test-throw-expr-01.cs [new file with mode: 0644]
mcs/tests/test-throw-expr-02.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mcs/tools/Makefile
mcs/tools/assemblies.xml [deleted file]
mcs/tools/linker/monolinker-net_4_x.csproj
mcs/tools/mkbundle/mkbundle.cs
mcs/tools/mono-win32-setup-dark.bmp [deleted file]
mcs/tools/mono-win32-setup-light.bmp [deleted file]
mcs/tools/mono-win32-setup.nsi [deleted file]
mcs/tools/scan-tests.pl [deleted file]
mcs/tools/security/security.proj [deleted file]
mcs/tools/tinderbox/smtp.c [deleted file]
mcs/tools/tinderbox/tinderbox.sh [deleted file]
mcs/winexe.in [deleted file]
mono/btls/btls-bio.c
mono/btls/btls-ssl.c
mono/btls/btls-ssl.h
mono/dis/Makefile.am
mono/dis/dump.c
mono/dis/get.c
mono/dis/main.c
mono/dis/monodis.1
mono/metadata/Makefile.am
mono/metadata/appdomain.c
mono/metadata/assembly.c
mono/metadata/boehm-gc.c
mono/metadata/class.c
mono/metadata/cominterop.c
mono/metadata/console-unix.c
mono/metadata/domain-internals.h
mono/metadata/domain.c
mono/metadata/dynamic-image.c
mono/metadata/gc.c
mono/metadata/handle.c
mono/metadata/handle.h
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/jit-info.c
mono/metadata/marshal.c
mono/metadata/marshal.h
mono/metadata/mempool-internals.h
mono/metadata/metadata-internals.h
mono/metadata/method-builder.c
mono/metadata/method-builder.h
mono/metadata/mono-conc-hash.c [new file with mode: 0644]
mono/metadata/mono-conc-hash.h [new file with mode: 0644]
mono/metadata/mono-config.c
mono/metadata/nacl-stub.c [deleted file]
mono/metadata/object-internals.h
mono/metadata/object-offsets.h
mono/metadata/object.c
mono/metadata/reflection-cache.h
mono/metadata/reflection.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/sgen-stw.c
mono/metadata/sre.c
mono/metadata/threads.c
mono/metadata/w32error-unix.c
mono/metadata/w32error.h
mono/metadata/w32event-unix.c
mono/metadata/w32event-win32.c
mono/metadata/w32event.h
mono/metadata/w32file-unix.c
mono/metadata/w32handle-namespace.c
mono/metadata/w32handle-namespace.h
mono/metadata/w32handle.c
mono/metadata/w32handle.h
mono/metadata/w32mutex-unix.c
mono/metadata/w32mutex-win32.c
mono/metadata/w32mutex.h
mono/metadata/w32semaphore-unix.c
mono/metadata/w32socket-unix.c
mono/metadata/w32socket-win32.c
mono/metadata/w32socket.c
mono/metadata/w32socket.h
mono/mini/Makefile.am.in
mono/mini/MemoryIntrinsics.il [new file with mode: 0644]
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/branch-opts.c
mono/mini/debugger-agent.c
mono/mini/decompose.c
mono/mini/driver.c
mono/mini/exceptions.cs
mono/mini/genmdesc.c
mono/mini/helpers.c
mono/mini/image-writer.c
mono/mini/interp/interp-internals.h
mono/mini/interp/interp-stubs.c [new file with mode: 0644]
mono/mini/interp/interp.c
mono/mini/interp/interp.h
mono/mini/interp/mintops.c
mono/mini/interp/mintops.def
mono/mini/interp/transform.c
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/jit.h
mono/mini/memory-access.c
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-arm.c
mono/mini/mini-arm.h
mono/mini/mini-arm64.c
mono/mini/mini-cross-helpers.c
mono/mini/mini-exceptions.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-mips.h
mono/mini/mini-posix.c
mono/mini/mini-ppc.h
mono/mini/mini-runtime.c
mono/mini/mini-x86.h
mono/mini/mini.c
mono/mini/mini.h
mono/mini/regalloc.h
mono/mini/tramp-arm.c
mono/mini/tramp-arm64.c
mono/mini/tramp-ppc.c
mono/mini/tramp-x86.c
mono/mini/unaligned.cs [new file with mode: 0644]
mono/profiler/Makefile.am
mono/profiler/aot.c [new file with mode: 0644]
mono/profiler/aot.h [new file with mode: 0644]
mono/profiler/iomap.c [new file with mode: 0644]
mono/profiler/log-args.c [new file with mode: 0644]
mono/profiler/log.c [new file with mode: 0644]
mono/profiler/log.h [new file with mode: 0644]
mono/profiler/mono-profiler-aot.c [deleted file]
mono/profiler/mono-profiler-aot.h [deleted file]
mono/profiler/mono-profiler-iomap.c [deleted file]
mono/profiler/mono-profiler-log.c [deleted file]
mono/profiler/mono-profiler-log.h [deleted file]
mono/profiler/mono-profiler-vtune.c [deleted file]
mono/profiler/mprof-report.c
mono/profiler/ptestrunner.pl
mono/profiler/vtune.c [new file with mode: 0644]
mono/sgen/sgen-conf.h
mono/sgen/sgen-gc.c
mono/sgen/sgen-workers.c
mono/tests/Makefile.am
mono/tests/appdomain-unload-asmload.cs [new file with mode: 0644]
mono/tests/bug-45841-fpstack-exceptions.il
mono/tests/cominterop.cs
mono/tests/libtest.c
mono/tests/marshal2.cs
mono/tests/testing_gac/Makefile.am
mono/tests/testing_gac/app-both.cs [new file with mode: 0644]
mono/tests/testing_gac/v1/gactestlib.cs
mono/tests/testing_gac/v2/gactestlib.cs
mono/unit-tests/Makefile.am
mono/utils/dlmalloc.c
mono/utils/mono-context.c
mono/utils/mono-context.h
mono/utils/mono-dl.h
mono/utils/mono-mmap.c
mono/utils/mono-proclib.c
mono/utils/mono-rand.c
mono/utils/mono-threads-posix-signals.c
mono/utils/mono-threads-posix.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h
mono/utils/monobitset.c
msvc/libmono-static.vcxproj
msvc/libmono-static.vcxproj.filters
msvc/libmonoruntime.vcxproj
msvc/libmonoruntime.vcxproj.filters
nacl/README [deleted file]
nacl/common.sh [deleted file]
nacl/config-nacl-runtime.cache [deleted file]
nacl/config-nacl-runtime64.cache [deleted file]
nacl/nacl-runtime-mono.sh [deleted file]
nacl/nacl_interp_loader_sdk.sh [deleted file]
net_4_x.sln
packaging/.gitignore [new file with mode: 0644]
packaging/MacSDK/libgdiplus.py
packaging/MacSDK/mono.py
packaging/MacSDK/msbuild.py
packaging/MacSDK/nuget.py
packaging/MacSDK/xamarin-gtk-theme.py
packaging/MacSDKRelease/mono-extensions.py
packaging/Windows/.gitattributes [new file with mode: 0644]
packaging/Windows/defs/gtksharp [new file with mode: 0755]
packaging/Windows/defs/managed-components [new file with mode: 0755]
packaging/Windows/defs/mono [new file with mode: 0755]
packaging/Windows/defs/mono64 [new file with mode: 0755]
packaging/Windows/mono-MDK-windows [new file with mode: 0755]
packaging/Windows/mono-MDK-windows-x64 [new file with mode: 0755]
packaging/Windows/resources/MonoForWindows.wixproj [new file with mode: 0644]
packaging/Windows/resources/Product.wxs [new file with mode: 0644]
packaging/Windows/resources/bat/setmonopath.bat [new file with mode: 0644]
packaging/Windows/resources/build.bat [new file with mode: 0755]
packaging/Windows/resources/build64.bat [new file with mode: 0755]
packaging/Windows/resources/pkgconfig/glade-sharp-2.0.pc [new file with mode: 0644]
packaging/Windows/resources/pkgconfig/glib-sharp-2.0.pc [new file with mode: 0644]
packaging/Windows/resources/pkgconfig/gtk-sharp-2.0.pc [new file with mode: 0644]
packaging/Windows/resources/setup-files/app.ico [new file with mode: 0644]
packaging/Windows/resources/setup-files/banner.bmp [new file with mode: 0644]
packaging/Windows/resources/setup-files/dialog.bmp [new file with mode: 0644]
packaging/Windows/resources/setup-files/license.rtf [new file with mode: 0644]
packaging/Windows/resources/wrapper.bat [new file with mode: 0755]
runtime/Makefile.am
runtime/mono-wrapper.in
scripts/ci/run-jenkins.sh
scripts/ci/run-test-acceptance-tests.sh
scripts/ci/run-test-default.sh
tools/offsets-tool/MonoAotOffsetsDumper.cs

index 73d55a0a9b903a2f261f9a60b0dfee03b66f0a3c..4e968d7a066307ccc1089bbbfdf715a8fc923e2c 100644 (file)
@@ -26,9 +26,6 @@
 [submodule "external/nuget-buildtasks"]
        path = external/nuget-buildtasks
        url = git://github.com/mono/NuGet.BuildTasks
-[submodule "external/buildtools"]
-       path = external/buildtools
-       url = git://github.com/mono/buildtools.git
 [submodule "external/cecil-legacy"]
        path = external/cecil-legacy
        url = git://github.com/mono/cecil.git
index ede769564985d5b87cdf226a5ee99e9783381c44..031ef3a11684161955ad17c3367c1e7e7b676989 100644 (file)
@@ -50,14 +50,9 @@ noinst_DATA = mono-uninstalled.pc
 DISTCLEANFILES= mono-uninstalled.pc
 
 # building with monolite
-mcslib = $(mcs_topdir)/class/lib
-monolite_url = https://download.mono-project.com/monolite/monolite-$(MONO_CORLIB_VERSION)-latest.tar.gz
 .PHONY: get-monolite-latest 
 get-monolite-latest:
-       -rm -fr $(mcslib)/monolite/$(MONO_CORLIB_VERSION)
-       -mkdir -p $(mcslib)/monolite
-       cd $(mcslib) && { (wget -O- $(monolite_url) || curl -L $(monolite_url)) | gzip -d | tar xf - ; }
-       cd $(mcslib) && mv -f monolite-* monolite/$(MONO_CORLIB_VERSION)
+       $(MAKE) -C $(mcs_topdir)/class get-monolite-latest
 
 if BITCODE
 BITCODE_CHECK=yes
index 86a2354b389338d03914c8895349d15b7ba3c0db..d0e93384fddb6e095b2508cd85fc6efa6120eb5d 100644 (file)
@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 #AC_PREREQ([2.62])
 
-AC_INIT(mono, [5.3.0],
+AC_INIT(mono, [5.5.0],
         [http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
 
 AC_CONFIG_SRCDIR([README.md])
@@ -40,7 +40,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
 # This can be reset to 0 when Mono's version number is bumped
 # since it's part of the corlib version (the prefix '1' in the full
 # version number is to ensure the number isn't treated as octal in C)
-MONO_CORLIB_COUNTER=1
+MONO_CORLIB_COUNTER=2
 MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR $MONO_VERSION_BUILD $MONO_CORLIB_COUNTER`
 
 AC_DEFINE_UNQUOTED(MONO_CORLIB_VERSION,$MONO_CORLIB_VERSION,[Version of the corlib-runtime interface])
@@ -264,17 +264,8 @@ case "$host" in
                with_sgen_default_concurrent=yes
                ;;
        *-*-nacl*)
-               CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
-               if test "x$disable_munmap" != "xyes"; then
-                       CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
-               fi
-               libmono_cflags="-D_REENTRANT"
-               libdl=
-               libgc_threads=pthreads
-               use_sigposix=yes
-               ikvm_native=no
-               AC_DEFINE(DISABLE_SOCKETS,1,[Disable sockets support])
-               AC_DEFINE(DISABLE_ATTACH, 1, [Disable agent attach support])
+               echo "nacl no longer supported."
+               exit 1
                ;;
        *-*-hpux*)
                CPPFLAGS="$CPPFLAGS -DGC_HPUX_THREADS -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT"
@@ -743,10 +734,6 @@ fi
 
 AM_CONDITIONAL(DISABLE_LIBRARIES, test x$enable_libraries = xno)
 
-case $host in
-*nacl* ) with_shared_mono=yes;;
-esac
-
 if test "x$host_win32" = "xyes"; then
    # Boehm GC requires the runtime to be in its own dll
    with_static_mono=no
@@ -1371,8 +1358,6 @@ AC_TRY_COMPILE([
        AC_DEFINE_UNQUOTED(MONO_ZERO_LEN_ARRAY, 1, [Length of zero length arrays])
 ])
 
-AC_CHECK_HEADERS(nacl/nacl_dyncode.h)
-
 dnl ***********************************
 dnl *** Checks for signals
 dnl ***********************************
@@ -2220,13 +2205,11 @@ if test x$host_win32 = xno; then
        dnl **********************************
        dnl *** epoll                      ***
        dnl **********************************
-       if test "x$ac_cv_header_nacl_nacl_dyncode_h" = "xno"; then
-               AC_CHECK_HEADERS(sys/epoll.h)
-               haveepoll=no
-               AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
-               if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes"; then
-                       AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
-               fi
+       AC_CHECK_HEADERS(sys/epoll.h)
+       haveepoll=no
+       AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
+       if test "x$haveepoll" = "xyes" -a "x$ac_cv_header_sys_epoll_h" = "xyes"; then
+               AC_DEFINE(HAVE_EPOLL, 1, [epoll supported])
        fi
 
        havekqueue=no
@@ -2859,40 +2842,6 @@ fi
 AM_CONDITIONAL(ENABLE_DTRACE, [test x$enable_dtrace = xyes])
 AM_CONDITIONAL(DTRACE_G_REQUIRED, [test x$dtrace_g = xyes])
 
-dnl **************
-dnl ***  NaCl  ***
-dnl **************
-
-AC_ARG_ENABLE(nacl_codegen, [  --enable-nacl-codegen      Enable Native Client code generation], enable_nacl_codegen=$enableval, enable_nacl_codegen=no)
-AC_ARG_ENABLE(nacl_gc, [  --enable-nacl-gc           Enable Native Client garbage collection], enable_nacl_gc=$enableval, enable_nacl_gc=no)
-
-AM_CONDITIONAL(NACL_CODEGEN, test x$enable_nacl_codegen != xno)
-
-dnl
-dnl Hack to use system mono for operations in build/install not allowed in NaCl.
-dnl
-nacl_self_host=""
-if test "x$ac_cv_header_nacl_nacl_dyncode_h" = "xyes"; then
-   nacl_self_host="nacl_self_host"
-fi
-AC_SUBST(nacl_self_host)
-
-if test "x$enable_nacl_codegen" = "xyes"; then
-   MONO_NACL_ALIGN_MASK_OFF=1
-   AC_DEFINE(TARGET_NACL, 1, [...])
-   AC_DEFINE(__native_client_codegen__, 1, [...])
-fi
-if test "x$enable_nacl_gc" = "xyes"; then
-   if test "x$TARGET" = "xAMD64" -o "x$TARGET" = "xX86"; then
-      INSTRUMENT_CFLAG="-finstrument-for-thread-suspension"
-   else
-      # Not yet implemented
-      INSTRUMENT_CFLAG=""
-   fi
-   CPPFLAGS="$CPPFLAGS $INSTRUMENT_CFLAG -D__native_client_gc__"
-fi
-AC_SUBST(MONO_NACL_ALIGN_MASK_OFF)
-
 dnl **************************
 dnl *** AOT cross offsets  ***
 dnl **************************
@@ -3155,12 +3104,6 @@ case "$host" in
                  mingw*)
                        ;;
                esac
-               case "$host" in
-                       x86_64-*-nacl*)
-                               AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
-                               sizeof_register=8
-                               ;;
-               esac
                ;;
        sparc*-*-*)
                if test "x$ac_cv_sizeof_void_p" = "x8"; then
@@ -3241,13 +3184,6 @@ case "$host" in
                ACCESS_UNALIGNED="no"
                CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
                ;;
-# TODO: make proper support for NaCl host.
-#        arm*-*nacl)
-#              TARGET=ARM;
-#              arch_target=arm;
-#              ACCESS_UNALIGNED="no"
-#              AOT_SUPPORTED="no"
-#              ;;
        aarch64-*)
                # https://lkml.org/lkml/2012/7/15/133
                TARGET=ARM64
@@ -3308,38 +3244,6 @@ if test "x$host" != "x$target"; then
                sizeof_register=8
                target_byte_order=G_BIG_ENDIAN
                ;;
-   x86_64-*-nacl)
-               TARGET=AMD64
-               arch_target=amd64
-               AC_DEFINE(TARGET_AMD64, 1, [...])
-               AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
-               sizeof_register=8
-               ;;
-# TODO: make proper support for NaCl target.
-#   arm*-*nacl)
-#              TARGET=ARM
-#              arch_target=arm
-#              AC_DEFINE(TARGET_ARM, 1, [...])
-#              ACCESS_UNALIGNED="no"
-#              sizeof_register=4
-#               CPPFLAGS="$CPPFLAGS \
-#                    -D__ARM_EABI__ \
-#                    -D__arm__ \
-#                    -D__portable_native_client__ \
-#                    -Dtimezone=_timezone \
-#                    -DDISABLE_SOCKETS \
-#                    -DDISABLE_ATTACH \
-#                    -DUSE_NEWLIB"
-               # Can't use tls, since it depends on the runtime detection of tls offsets
-               # in mono-compiler.h
-#              with_tls=pthread
-#              ;;
-   i686-*-nacl)
-               TARGET=X86
-               arch_target=x86
-               AC_DEFINE(TARGET_X86, 1, [...])
-               sizeof_register=4
-               ;;
    arm*-linux-*)
                TARGET=ARM;
                arch_target=arm;
@@ -3630,7 +3534,6 @@ fi
 
 AM_CONDITIONAL(ENABLE_INTERPRETER, [test x$enable_interpreter = xyes])
 
-
 dnl 
 dnl Simple Generational checks (sgen)
 dnl
index ae7b6d45337183fb48d52b2593f26b7d0c0de28f..71797575e685c1107665e4eb14481f1fcb3a796f 100644 (file)
@@ -32,7 +32,7 @@ typedef signed   @GSIZE@ gssize;
 #define G_HAVE_ISO_VARARGS
 #endif
 
-#if defined (__native_client__) || defined (HOST_WATCHOS)
+#if defined (HOST_WATCHOS)
 #undef G_BREAKPOINT
 #define G_BREAKPOINT()
 #endif
index 49ee58a142fdee1c3e723bcac104c9a8174e4450..48a9192ab69fad8ea0d2ce2d195549af6442982e 100644 (file)
@@ -154,15 +154,6 @@ g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error)
 gchar *
 g_get_current_dir (void)
 {
-#ifdef __native_client__
-       char *buffer;
-       if ((buffer = g_getenv("NACL_PWD"))) {
-               buffer = g_strdup(buffer);
-       } else {
-               buffer = g_strdup(".");
-       }
-       return buffer;
-#else
        int s = 32;
        char *buffer = NULL, *r;
        gboolean fail;
@@ -181,5 +172,4 @@ g_get_current_dir (void)
         * so we return the buffer here since it has a pointer to the valid string
         */
        return buffer;
-#endif
 }
index 52e1c331cf5e7ba26b49d1f2fabae14f202895a9..e4ba4f2f10ea12d022853594fc7ff055590a684d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 52e1c331cf5e7ba26b49d1f2fabae14f202895a9
+Subproject commit e4ba4f2f10ea12d022853594fc7ff055590a684d
index f7af29b16bd2ce1a9faef3e08bf11db7eb36c087..58bf3183031479747adcceceb622aea3aa076e38 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f7af29b16bd2ce1a9faef3e08bf11db7eb36c087
+Subproject commit 58bf3183031479747adcceceb622aea3aa076e38
diff --git a/external/buildtools b/external/buildtools
deleted file mode 160000 (submodule)
index b5cc6e6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit b5cc6e6ab5f71f6c0be7b730058b426e92528479
index 0b523fa7e0f2f83cc67e4c19f1f769e68d717562..f64903c0e069224aaac7de243fa0a3b17684b4dd 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 0b523fa7e0f2f83cc67e4c19f1f769e68d717562
+Subproject commit f64903c0e069224aaac7de243fa0a3b17684b4dd
index 5b7e0d739fa65bb7b1c2230df875d37a55b74d10..66465f7b9147ebbcb0fec50f4b538188627c2867 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5b7e0d739fa65bb7b1c2230df875d37a55b74d10
+Subproject commit 66465f7b9147ebbcb0fec50f4b538188627c2867
index 814f76de6a972c5c3dd3ec6b10dc900fd73d08d2..48dba73801e804e89f00311da99d873f9c550278 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 814f76de6a972c5c3dd3ec6b10dc900fd73d08d2
+Subproject commit 48dba73801e804e89f00311da99d873f9c550278
index 88b67c42ca8b7d58141c176b46749819bfcef166..1d7d43603791e0236b56d076578657bee44fef6b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 88b67c42ca8b7d58141c176b46749819bfcef166
+Subproject commit 1d7d43603791e0236b56d076578657bee44fef6b
index 7c1e61bec8c069b2cc9e214c3094b147d76bbf82..847e05fced5c9a41ff0f24f1f9d40d5a8a5772c1 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 7c1e61bec8c069b2cc9e214c3094b147d76bbf82
+Subproject commit 847e05fced5c9a41ff0f24f1f9d40d5a8a5772c1
index b8e20d265b368dd6252703d5afd038d0b028e388..d4433b0972f40cb3efaa3fbba52869bde5df8fa8 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b8e20d265b368dd6252703d5afd038d0b028e388
+Subproject commit d4433b0972f40cb3efaa3fbba52869bde5df8fa8
index b23581535c583425416b8a9dc3fdf8ae78451a89..89a051e250618a0df87ccdda255d69d6c35ebbc6 100644 (file)
@@ -181,6 +181,16 @@ Gives the path for the temporary LLVM bitcode file created during AOT.
 .I info
 Print the architecture the AOT in this copy of Mono targets and quit.
 .TP
+.I interp
+Generates all required wrappers, so that it is possible to run --interpreter without
+any code generation at runtime.  This option only makes sense with \fBmscorlib.dll\fR.
+Embedders can set
+
+.nf
+mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP);
+.fi
+.ne
+.TP
 .I ld-flags
 Additional flags to pass to the C linker (if the current AOT mode calls for invoking it).
 .TP
@@ -1091,11 +1101,6 @@ code generation backend.   For example \fBLLVM_COUNT=10\fR would only
 compile 10 methods with LLVM and then switch to the Mono JIT engine.
 \fBLLVM_COUNT=0\fR would disable the LLVM engine altogether.
 .TP
-\fBMONO_AOT_CACHE\fR
-If set, this variable will instruct Mono to ahead-of-time compile new
-assemblies on demand and store the result into a cache in
-~/.mono/aot-cache. 
-.TP
 \fBMONO_ASPNET_INHIBIT_SETTINGSMAP\fR
 Mono contains a feature which allows modifying settings in the .config files shipped
 with Mono by using config section mappers. The mappers and the mapping rules are
@@ -1304,10 +1309,19 @@ first generation (of two).  A larger nursery will usually speed up the
 program but will obviously use more memory.  The default nursery size
 4 MB.
 .TP
-\fBmajor=\fIcollector\fR Specifies which major collector to use.
-Options are `marksweep' for the Mark&Sweep collector, and
-`marksweep-conc' for concurrent Mark&Sweep.  The non-concurrent
-Mark&Sweep collector is the default.
+\fBmajor=\fIcollector\fR
+Specifies which major collector to use.
+Options are `marksweep' for the Mark&Sweep collector, `marksweep-conc'
+for concurrent Mark&Sweep and `marksweep-conc-par' for parallel and
+concurrent Mark&Sweep.  The concurrent Mark&Sweep collector is the default.
+.TP
+\fBmode=balanced|throughput|pause\fR[:\fImax-pause\fR]
+Specifies what should be the garbage collector's target. The `throughput'
+mode aims to reduce time spent in the garbage collector and improve
+application speed, the `pause' mode aims to keep pause times to a minimum
+and it receives the argument \fImax-pause\fR which specifies the maximum
+pause time in milliseconds that is acceptable and the `balanced' mode
+which is a general purpose optimal mode.
 .TP
 \fBsoft-heap-limit=\fIsize\fR
 Once the heap size gets larger than this size, ignore what the default
@@ -1370,9 +1384,11 @@ more memory when it reaches a stable size.
 This option is EXPERIMENTAL, so it might disappear in later versions of mono.
 .TP
 \fBminor=\fIminor-collector\fR
-Specifies which minor collector to use. Options are 'simple' which
-promotes all objects from the nursery directly to the old generation
-and 'split' which lets object stay longer on the nursery before promoting.
+Specifies which minor collector to use. Options are `simple' which
+promotes all objects from the nursery directly to the old generation,
+`simple-par' which has same promotion behavior as `simple' but using
+multiple workers and `split' which lets objects stay longer on the nursery
+before promoting.
 .TP
 \fBalloc-ratio=\fIratio\fR
 Specifies the ratio of memory from the nursery to be use by the alloc space.
index bfc855692e4d319ea04f3236a3f583e5fa50e781..416c39e3a0b877bbc10b6a45e17f8b9886ee56db 100644 (file)
@@ -1,7 +1,5 @@
 This list of authors is outdated.   For a full list of contributors
-see:
-
-       http://www.go-mono.com/archive/mono-1.0.html
+check out the git history.
 
 C# Compiler:
        Miguel de Icaza (miguel@ximian.com)
index d60c31a97a544b53039088d14fe9114583c0efc3..fd336eb81764406f72cc0092b8a94895d14927d3 100644 (file)
@@ -1,340 +1 @@
-                   GNU GENERAL PUBLIC LICENSE
-                      Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                           Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-\f
-                   GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-\f
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-\f
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-\f
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-                           NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-                    END OF TERMS AND CONDITIONS
-\f
-           How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year  name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+See LICENSE file in the project root for full license information.
index 54aa55d1545c99752cfe3e7e1de9bc181fafd8fc..8c0ac1e65e1b989757c9545c6710c31cab93fee5 100644 (file)
@@ -1,477 +1 @@
-* Coding Style for the Mono C# source code.
-
-* Class Libraries and Assembly Layout
-
-       The class libraries are grouped together in the assemblies
-       they belong.
-       
-       Each directory here represents an assembly, and inside each
-       directory we divide the code based on the namespace they
-       implement.
-       
-       In addition, each assembly directory contains a Test directory
-       that holds the NUnit tests for that assembly.
-       
-       We use a new build system which is described by various README
-       files in mcs/build
-       
-       The build process typically builds an assembly, but in some
-       cases it also builds special versions of the assemblies
-       intended to be used for testing.
-
-* Missing implementation bits
-
-       If you implement a class and you are missing implementation bits,
-       please use the attribute [MonoTODO].  This attribute can be used
-       to programatically generate our status web pages:
-
-       [MonoTODO("My Function is not available on Mono")]
-       int MyFunction ()
-       {
-               throw new NotImplementedException ();
-       }
-
-       Ideally, write a human description of the reason why there is
-       a MonoTODO, this will be useful in the future for our
-       automated tools that can assist in developers porting their code.
-
-* Tagging buggy code
-
-       If there is a bug in your implementation tag the problem by using
-       the word "FIXME" in the code, together with a description of the 
-       problem.
-
-       Do not use XXX or obscure descriptions, because otherwise people
-       will not be able to understand what you mean.
-
-* Tagging Problematic specs.
-
-       If the documentation and the Microsoft implementation do
-       differ (you wrote a test case to prove this), I suggest that you edit
-       the file `mcs/class/doc/API-notes' so we can keep track of these problems
-       and submit our comments to ECMA or Microsoft and seek clarification.
-
-       Sometimes the documentation might be buggy, and sometimes the implementation
-       might be buggy.  Lets try to identify and pinpoint which one
-       is the correct one.
-
-       Sometimes the specification will be lame (consider Version.ToString (fieldCount)
-       where there is no way of knowing how many fields are available, making the API
-       not only stupid, but leading to unreliable code).
-
-       In those cases, use the keyword "LAMESPEC".
-       
-
-* Coding considerations and style.
-
-       In order to keep the code consistent, please use the following
-       conventions.  From here on `good' and `bad' are used to attribute
-       things that would make the coding style match, or not match.  It is not
-       a judgement call on your coding abilities, but more of a style and 
-       look call.  Please try to follow these guidelines to ensure prettiness.
-
-       Use 8 space tabs for writing your code (hopefully we can keep
-       this consistent).  If you are modifying someone else's code, try
-       to keep the coding style similar.
-
-       Since we are using 8-space tabs, you might want to consider the Linus
-       Torvals trick to reduce code nesting.  Many times in a loop, you will
-       find yourself doing a test, and if the test is true, you will nest.
-       Many times this can be changed.  Example:
-
-
-               for (i = 0; i < 10; i++) {
-                       if (something (i)) {
-                               do_more ();
-                       }
-               }
-
-       This take precious space, instead write it like this:
-
-               for (i = 0; i < 10; i++) {
-                       if (!something (i))
-                               continue;
-                       do_more ();
-               }
-
-* Performance and readability
-
-       It is more important to be correct than to be fast.
-
-       It is more important to be maintainable than to be fast.
-
-       Fast code that is difficult to maintain is likely going to
-       be looked down upon.
-
-* Style Guidelines
-
-               * Use a space before an opening parenthesis when calling
-                 functions, or indexing, like this:
-
-                       method (a);
-                       b [10];
-
-               * Do not put a space after the opening parenthesis and the 
-                 closing one, ie:
-
-                       good: method (a);       array [10];
-
-                       bad:  method ( a );     array[ 10 ];
-
-               * Inside a code block, put the opening brace on the same line
-                 as the statement:
-
-                       good:
-                               if (a) {
-                                       code ();
-                                       code ();
-                               }
-
-                       bad:
-                               if (a) 
-                               {
-                                       code ();
-                                       code ();
-                               }
-
-               * Avoid using unnecessary open/close braces, vertical space
-                 is usually limited:
-
-                       good:
-                               if (a)
-                                       code ();
-
-                       bad:
-                               if (a) {
-                                       code ();
-                               }
-
-               * When defining a method, use the C style for brace placement, 
-                 that means, use a new line for the brace, like this:
-
-                       good:
-                               void Method ()
-                               {
-                               }
-
-                       bad:
-                               void Method () {
-                               }
-
-               * Properties and indexers are an exception, keep the
-                 brace on the same line as the property declaration.
-                 Rationale: this makes it visually
-                 simple to distinguish them.
-
-                       good:
-                               int Property {
-                                       get {
-                                               return value;
-                                       }
-                               }
-
-                       bad:
-                               int Property 
-                               {
-                                       get {
-                                               return value;
-                                       }
-                               }
-
-                 Notice how the accessor "get" also keeps its brace on the same
-                 line.
-
-                 For very small properties, you can compress things:
-
-                       ok:
-                               int Property {
-                                       get { return value; }
-                                       set { x = value; }
-                               }
-
-               * Use white space in expressions liberally, except in the presence
-                 of parenthesis:
-
-                       good:
-
-                               if (a + 5 > method (blah () + 4))
-
-                       bad:
-                               if (a+5>method(blah()+4))
-
-               * For any new files, please use a descriptive introduction, like
-                 this:
-
-                       //
-                       // System.Comment.cs: Handles comments in System files.
-                       //
-                       // Author:
-                       //   Juan Perez (juan@address.com)
-                       //
-                       // (C) 2002 Address, Inc (http://www.address.com)
-                       //
-
-               * If you are modyfing someone else's code, and your contribution
-                 is significant, please add yourself to the Authors list.
-
-               * Switch statements have the case at the same indentation as the
-                 switch:
-
-                       switch (x) {
-                       case 'a':
-                               ...
-                       case 'b':
-                               ...
-                       }
-
-               * Argument names should use the camel casing for
-                 identifiers, like this:
-
-                       good:
-                               void Method (string myArgument)
-
-                       bad:
-                               void Method (string lpstrArgument)
-                               void Method (string my_string)
-
-               * Empty methods: They should have the body of code using two    
-                 lines, in consistency with the rest:
-
-                       good:
-                               void EmptyMethod ()
-                               {
-                               }
-
-                       bad:
-                               void EmptyMethod () {}
-
-                               void EmptyMethod () 
-                               {}
-               
-               * Line length: The line length for C# source code is 134 columns.
-
-
-                 If your function declaration arguments go beyond
-                 this point, please align your arguments to match the
-                 opening brace, like this:
-
-                       void Function (int arg, string argb,
-                                      int argc)
-                       {
-                       }
-        
-                 When invoking functions, the rule is different, the
-                 arguments are not aligned with the previous
-                 argument, instead they begin at the tabbed position,
-                 like this:
-         
-                       void M ()
-                       {
-                               MethodCall ("Very long string that will force",
-                                       "Next argument on the 8-tab pos",
-                                       "Just like this one")
-               
-                       }
-
-               * Variable declaration indentation.
-
-                 Sometimes it is convenient to indent the variables to make the code
-                 look pretier, but do not add gratuitous space, try to use the minimally
-                 necessary space, for example:
-
-                 Good:
-
-                       void Method ()
-                       {
-                               string b;
-                               int    a;
-                               byte   c;
-                       }
-
-                 Bad:
-
-                       void Method ()
-                       {
-                               string          b;
-                               int             a;
-                               byte            c;
-                       }
-
-               * Braces and the `else' clause
-
-                 If there are braces closing or opening next to the else clause,
-                 they go on the same line as the word `else', for example:
-
-                 Good:
-
-                       if (..) {
-
-                       } else {
-               
-                       }
-       
-                 Bad:
-
-                       if (..) {
-
-                       } 
-                       else {
-               
-                       }
-
-                 Bad:
-
-                       if (..) {
-
-                       } else 
-                       {               
-                       }
-
-                 Bad:
-
-                       if (..) {
-
-                       } 
-                       else 
-                       {
-               
-                       }
-
-* RCS and CVS tags
-
-       Some users like to use the special RCS/CVS tags in their
-       source code: $id$, $log$ and so on.  
-
-       The use of these is not permitted on the Mono source code
-       repository.   This metadata belongs on a ChangeLog or in the
-       SVN metadata. 
-
-* File formats
-
-       Historically our repository has used a mix of line-endings,
-       this is a mistake that we are trying hard to fix.
-
-       For existing files, please make sure that you do not convert 
-       the file, as that causes us to loose precious history (the
-       full file is commited).
-
-       For new files that you create, please make sure that you use
-       Subversion's support for mapping the line endings
-       automatically, after adding your file:
-
-               $ svn add file.cs
-
-       Execute this command:
-
-               $ svn propset svn:eol-style native file.cs
-
-       Which will make the file automatically receive the proper
-       treatment from that point on.
-
-       Please verify before commiting that your changes wont loose
-       history, you can do this by running:
-
-               $ svn diff
-
-       And examining the output.
-
-* Warnings
-
-       Avoid commiting code with warnings to the repository, the use
-       of #pragmas to disable warnings is strongly discouraged, but
-       can be used on unique cases.  Please justify the use of the
-       warning ignore clause on a comment.
-
-       Do not commit changes to the Makefiles that removes warnings,
-       if anything warnings should be eliminated one at a time, and
-       if not possible, they must be flagged.
-
-
-* Examples:
-
-class X : Y {
-
-       bool Method (int argument_1, int argument_2)
-       {
-               if (argument_1 == argument_2)
-                       throw new Exception (Locale.GetText ("They are equal!");
-
-               if (argument_1 < argument_2) {
-                       if (argument_1 * 3 > 4)
-                               return true;
-                       else
-                               return false;
-               }
-
-               //
-               // This sample helps keep your sanity while using 8-spaces for tabs
-               // 
-               VeryLongIdentifierWhichTakesManyArguments (
-                       Argument1, Argument2, Argument3,
-                       NestedCallHere (
-                               MoreNested));
-       }
-
-       bool MyProperty {
-               get {
-                       return x;
-               }
-
-               set {
-                       x = value;
-               }
-       }
-
-       void AnotherMethod () 
-       {
-               if ((a + 5) != 4) {
-               }
-
-               while (blah) {
-                       if (a)
-                               continue;
-                       b++;
-               }
-       }
-}
-
-* Conditional compilation
-
-       Ideally we would not need conditional compilation, and the use
-       of #ifdef is strongly discouraged.  But due to our support for
-       old C# 1.0 compilers we have to use it in a few places.
-
-       Try to avoid negative tests that have an else clause, for
-       example:
-
-           #if !NET_2_0
-               CODE_FOR_1_0
-            #else
-               CODE_FOR_2_0
-           #endif
-
-        Instead use:
-
-           #if NET_2_0
-               CODE_FOR_2_0
-           #else
-               CODE_FOR_1_0
-            #endif
-
-       When a major feature differs across compilation targets, try
-       to factor out the code into a separate class, a helper class
-       or a separate file, and include that in your profile while
-       surrounding that helper file/class with the ifdefs to reduce
-       the amount of ifdefs in the code.
-
-       For instance, this is used for some parts of Grasshopper where
-       the code is ifdefed out, when large parts of a file would have
-       been ifdefed out, we moved the code into a MyOtherFile.jvm.cs
-
-       For 2.0 classes, this is even simpler as code can be trivially
-       factored out into 
-
-                MyHelperClass.cli.cs
-                MyHelperClass.jvm.cs
-
-       By using partial classes.
+Please see http://www.mono-project.com/community/contributing/coding-guidelines/ for latest guidelines.
index 2b59d588ba3b029982d950d69de74cd90d231faa..3e7c06fad829f5a3c75d83e43d66dcf320ff87ca 100644 (file)
@@ -23,7 +23,7 @@ compilers and tools.
 *                                                                   *
 *********************************************************************
 
-If you only want to build a snapshot or a fresh CVS checkout of the
+If you only want to build a snapshot or a fresh checkout of the
 sources, you should go into the `mono' sibling directory and issue the
 make command, like this:
 
@@ -35,72 +35,6 @@ make command, like this:
 The compilation is bundled with the build due to dependencies on the
 class libraries on the runtime.
 
-Build Features for Developers of Mono.
-======================================
-
-These instructions apply to both Linux and Windows. To build this
-package, you must already have a C# compiler installed.  This means
-that to build on Linux, you need to get a distribution of the MCS
-binaries; these are called monocharges. They can be found at
-www.go-mono.com/daily. On Windows, you can just use the
-Microsoft compiler. You also need GNU make to build the software (on
-Windows, you will need for example the Cygwin environment setup).
-
-You can customize your MCS configuration by using:
-
-    ./configure [--prefix=PREFIX] [--profile=PROFILE] 
-
-If you do not run the above, the defaults are /usr/local for the
-prefix, and `default' for the profile.
-
-To build the compiler and class libraries, run:
-
-    make
-
-The libraries will be placed in the directory class/lib/ and the mcs
-compiler executable in mcs/.
-
-To install them, run the following:
-
-    make install
-
-If you get "corlib out of sync" errors, try
-
-    make PROFILE="atomic"
-
-A better alternative would be to fire off a 'make' from a sibling or
-parent 'mono/' tree.
-
-Troubleshooting
-===============
-
-We try to maintain the CVS tree such that it is bootstrapable from the
-latest released version of mono and mcs.  Occasionally, something in the
-compiler or runtime changes enough that an existing installation cannot
-complete a bootstrap from cvs.  In this case, go to
-http://go-mono.com/daily and download a monocharge or monolite tarball.
-Unpack and copy the .dlls to $prefix/lib and .exes to $prefix/bin/.
-Then you should be able to complete the build normally (i.e. using make
-bootstrap).
-
-       wget http://go-mono.com/daily/monolite-20040505.tar.gz
-       tar -zxvf monolite-20040505.tar.gz
-       cd monolite-20040505
-       env prefix=/usr/local sh recharge.sh
-
-Monocharges
-===========
-
-If you are tracking Mono's development, you may sometimes need to share
-the compiled libraries with others, you can do:
-
-    make monocharge
-
-Or a light version, which contains only the essential libraries and
-results in a much smaller file:
-
-    make monocharge-lite
-
 Configuration
 =============
 
@@ -110,48 +44,15 @@ place your configuration options in build/config.make
 A list of variables that control the build are listed in the file
 build/config-default.make.
 
-Build profiles? What?
-======================
-
-Don't worry about them too much. If you're wondering which to use:
-use the default if you can (that's why it's the default!) and use
-the atomic if you have to.
-
-The default profile uses the C# compiler and class libaries as they
-are built. This lets you build MCS without needing to have already 
-installed it, but can fail if the libraries change significantly.
-(This is the source of the dreaded "corlib out of sync" warning, most
-of the time.)
-
-The atomic profile tries to use the system compiler and preexisting
-MCS libraries. New libaries are built against this constant reference 
-point, so if a newly built library has a binary incompatibility, the
-rest of your build can proceed.
-
-If you want to always use the atomic profile, run this command:
-
-       ./configure --profile=atomic
-
 More About the Build System
 ===========================
 
 More information is found in build/README.*. Here's a quick rundown
 of the features:
 
-        * Unified build system for Windows and Linux. Windows is still
-         fairly untested, but "should work." Unfortunately I don't
-         have a Windows machine to test on, but Gonzalo can get
-         corlib to build I think and that's about as complicated as
-         it gets.
-
         * Profile support. 'make PROFILE=profilename' or 'export
          PROFILE=profilename ; make' will work. Profiles are defined
-         in build/profiles/profilename.make ; right now there isn't
-         too much going on. The 'bootstrap' profile will build the
-         way makefile.gnu did on Linux, by setting MONO_PATH and
-         using mcs/mcs.exe; the default profile will build against
-         the existing system libraries and compile with 'mcs', which
-         should reduce a lot of 'corlib out of sync' warnings.
+         in build/profiles/profilename.make ;
 
         * Important variables are shared among makefiles now; you can
          edit build/config.make (see build/config-default.make for a
@@ -164,16 +65,11 @@ of the features:
 
         * Test libraries now live in class/Library/Library_test.dll,
          not class/Library/Test. 'make test' will build the test DLL,
-         'make run-test' will actually run the nunit tests. Set the
-         variable TEST_HARNESS to run with a program other than
-         nunit-console (for example, nunit-gtk).
+         'make run-test' will actually run the nunit tests.
 
         * Standardized recursive targets: all, clean, install, test,
          run-test.  Read build/README.makefiles for definitions of
          what they should do
 
         * (Relatively) sane 'make dist' target; 'make distcheck'
-         support; cute 'make monocharge' and 'make monocharge-lite'
-         targets. They're made possible because 'make install' now
-         supports DESTDIR a la automake, which I'm sure someone cares
-         about.
+         support;
index 72382ce0d0b23a11aea60ef6ca331bbc92bd4bbc..d04525bd34fc2a4b5a4425082b6f53cf7258cfc2 100644 (file)
@@ -95,8 +95,7 @@ DISTFILES = \
        mkinstalldirs           \
        MonoIcon.png            \
        README                  \
-       ScalableMonoIcon.svg    \
-       winexe.in
+       ScalableMonoIcon.svg
 
 dist-local: dist-default
 
@@ -138,34 +137,12 @@ distcheck: dist-tarball
        rm -f before.list after.list distdist.list ; \
        rm -rf $(package) InstallTest
 
-monocharge:
-       chargedir=monocharge-`date -u +%Y%m%d` ; \
-       mkdir "$$chargedir" ; \
-       DESTDIR=`cd "$$chargedir" && pwd` ; \
-       $(MAKE) install DESTDIR="$$DESTDIR" || exit 1 ; \
-       tar cvjf "$$chargedir".tar.bz2 "$$chargedir" ; \
-       rm -rf "$$chargedir"
-
-# A bare-bones monocharge.
-
-monocharge-lite:
-       chargedir=monocharge-lite-`date -u +%Y%m%d` ; \
-       mkdir "$$chargedir" ; \
-       DESTDIR=`cd "$$chargedir" && pwd` ; \
-       $(MAKE) -C mcs install DESTDIR="$$DESTDIR" || exit 1; \
-       $(MAKE) -C class/corlib install DESTDIR="$$DESTDIR" || exit 1; \
-       $(MAKE) -C class/System install DESTDIR="$$DESTDIR" || exit 1; \
-       $(MAKE) -C class/System.XML install DESTDIR="$$DESTDIR" || exit 1; \
-       $(MAKE) -C class/Mono.CSharp.Debugger install DESTDIR="$$DESTDIR" || exit 1; \
-       tar cvjf "$$chargedir".tar.bz2 "$$chargedir" ; \
-       rm -rf "$$chargedir"
-
 # Targets for creating API diffs of the framework
 
 MONO_API_SNAPSHOT_PATH := $(topdir)../external/api-snapshot/
 GENAPI := $(MONO_API_SNAPSHOT_PATH)tools/genapi/GenAPI.exe
 MONO_API_SNAPSHOT_PROFILE_PATH := $(MONO_API_SNAPSHOT_PATH)profiles/$(PROFILE)/
-MONO_API_ASSEMBLIES_IGNORED := $(addprefix $(topdir)class/lib/$(PROFILE)/, SystemWebTestShim.dll standalone-runner-support.dll nunit.core.dll nunit.core.extensions.dll nunit.core.interfaces.dll nunit.framework.dll nunit.framework.extensions.dll nunit.mocks.dll nunit.util.dll nunit-console-runner.dll nunitlite.dll)
+MONO_API_ASSEMBLIES_IGNORED := $(addprefix $(topdir)class/lib/$(PROFILE)/, Mono.CSharp.dll SystemWebTestShim.dll standalone-runner-support.dll nunit.core.dll nunit.core.extensions.dll nunit.core.interfaces.dll nunit.framework.dll nunit.framework.extensions.dll nunit.mocks.dll nunit.util.dll nunit-console-runner.dll nunitlite.dll)
 MONO_API_ASSEMBLIES := $(filter-out $(MONO_API_ASSEMBLIES_IGNORED), $(wildcard $(topdir)class/lib/$(PROFILE)/*.dll)) $(wildcard $(topdir)class/lib/$(PROFILE)/Facades/*.dll)
 MONO_API_ASSEMBLIES_CS := $(MONO_API_ASSEMBLIES:$(topdir)class/lib/$(PROFILE)/%.dll=$(MONO_API_SNAPSHOT_PROFILE_PATH)%.cs)
 
index f23a12d69bfe078c688a21ac954522a7a7fe3ece..c670f181f19609fd716a8e484c1db9d46c8c99d2 100644 (file)
@@ -19,31 +19,34 @@ package module which drives the compilation of this directory.
        class/
                The class libraries.
 
+       docs/
+               Some notes on the compiler and the class libraries.
+
        errors/
                Sample programs that should generate errors by the C# compiler.
 
+       ilasm/
+               The IL assembler.
+
        jay/
                Yacc-based parser generator.
 
        mcs/
                The Mono C# compiler
 
-       tests/
-               Regression test suite for the C# compiler
+       nunit24/
+               An old copy of the NUnit 2.4 library that we ship for historical reasons.
 
-       docs/
-               Some notes on the compiler and the class libraries.
+       packages/
+               Integrates some packages from NuGet (like Roslyn) into the build system.
 
-       nant/
-               A copy of nant source code, used during the build process
-               on Windows.
+       tests/
+               Regression test suite for the C# compiler
 
        tools/
                Various small development tools: CorCompare used to compare
-               two assemblies for differences in the API;   TypeReflector is 
-               a tool used to introspect types from assemblies from the 
-               command line;  MonoStyle helps you keep your code indendented
-               with the Mono programming style.
+               two assemblies for differences in the API; csharp is a C# REPL;
+               cil-strip trims IL from assemblies.
 
 * Building Individual Directories
 =================================
@@ -51,14 +54,14 @@ package module which drives the compilation of this directory.
 You can build individual components in the hierarchy by running the command
 "make", and to install it use "make install".
 
-By default, the 2.x profile is built, if you want to build the net 1.1 profile,
+By default, the 4.x profile is built, if you want to build other profiles,
 use the following command:
 
-       make PROFILE=net_1_1
+       make PROFILE=<profilename>
 
 And to install:
 
-       make PROFILE=net_1_1 install
+       make PROFILE=<profilename> install
 
 To turn on verbose mode in the build (for example to diagnose a
 problem), you can use the V=1 flag, like this:
@@ -68,16 +71,14 @@ problem), you can use the V=1 flag, like this:
 * Running Unit tests
 ====================
 
-You can run unit tests in individual components by running the command
-"make run-test".  If you want to run tests for a different profile (say
-'net_1_1')
+You can run unit tests in individual components by running the command:
 
-       make run-test PROFILE=net_1_1
+       make run-test
 
 If you want to only run the tests in a single fixture (say
 'MonoTests.System.TypeTest'), you can use
 
-       make run-test TEST_HARNESS_FLAGS=/fixture:MonoTests.System.TypeTest
+       make run-test TEST_FIXTURE=System.TypeTest
 
 * Acknowledgements
 ==================
diff --git a/mcs/build/build.proj b/mcs/build/build.proj
deleted file mode 100644 (file)
index 725fcd0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>\r
-  <Target Name="Build">\r
-   <Copy SourceFiles="common\Consts.cs.in" DestinationFiles="common\Consts.cs"/>\r
-   <MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace" RegexPattern="@MONO_VERSION@" Replacement="2.7.0.0" Files="common\Consts.cs"/>\r
-  </Target>\r
-</Project>
\ No newline at end of file
index 88f326271ce40200bafed49515d3a719a33cbed0..307d85dee44c15b73b07decadfa2ed5d53b606db 100644 (file)
@@ -40,7 +40,14 @@ class X {
                if (!Version.TryParse (field.GetValue (null) as string, out version))
                        return 4;
 
-               if (version < new Version (4, 9))
+               Version min_mono_version;
+#if __MonoCS__
+               min_mono_version = new Version (5, 4);
+#else
+               min_mono_version = new Version (4, 9);
+#endif
+
+               if (version < min_mono_version)
                        return 5;
 
                return 0;
diff --git a/mcs/build/msbuild/.gitattributes b/mcs/build/msbuild/.gitattributes
deleted file mode 100644 (file)
index 1238039..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/Mono.Common.targets -crlf
-/Mono.Default.targets -crlf
diff --git a/mcs/build/msbuild/Mono.Common.targets b/mcs/build/msbuild/Mono.Common.targets
deleted file mode 100644 (file)
index e4211cb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>\r
-  <PropertyGroup  Condition=" '$(USE_MONO_COMPILER)' == '1' ">\r
-    <CscToolExe>gmcs.bat</CscToolExe>\r
-    <CscToolPath>C:\MonoExperimental2.5.0\bin</CscToolPath>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition=" ('$(Configuration)' == 'basic' Or '$(Configuration)' == 'basic_XML_DEP') ">\r
-    <OutputPath Condition=" '$(OutputPath)' == '' ">$(MSBuildProjectDirectory)\..\lib\basic\</OutputPath>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition=" '$(Configuration)' == 'net_2_0_bootstrap' ">\r
-    <OutputPath Condition=" '$(OutputPath)' == '' ">$(MSBuildProjectDirectory)\..\lib\net_2_0_bootstrap\</OutputPath>\r
-  </PropertyGroup>\r
-  <PropertyGroup>\r
-    <OutputPath Condition=" '$(OutputPath)' == '' ">$(MSBuildProjectDirectory)\..\lib\$(Configuration)\</OutputPath>\r
-  </PropertyGroup>\r
-  <Target Name="SetupProject">\r
-    <Copy SourceFiles="$(ResponseFile)" DestinationFiles="$(ResponseFile).msbuild"/>\r
-         <MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace" RegexPattern="/" Replacement="\" Files="$(ResponseFile).msbuild"/>\r
-         <MakeDir Directories="$(OutputDirectory)"/>\r
-  </Target>\r
-  <PropertyGroup Condition=" '$(ResponseFile)' == '' ">\r
-    <ResponseFile>$(MSBuildProjectName).dll.sources</ResponseFile>\r
-  </PropertyGroup>\r
-  <PropertyGroup>\r
-    <CompilerResponseFile>$(ResponseFile).msbuild</CompilerResponseFile>\r
-  </PropertyGroup>\r
-</Project>
\ No newline at end of file
diff --git a/mcs/build/msbuild/Mono.Default.targets b/mcs/build/msbuild/Mono.Default.targets
deleted file mode 100644 (file)
index 43eda68..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <PropertyGroup>\r
-    <Configuration Condition="'$(Configuration)' == ''">net_2_0</Configuration>\r
-    <Platform Condition="'$(Platform)' == ''">AnyCPU</Platform>\r
-  </PropertyGroup>\r
-</Project>
\ No newline at end of file
index 1e5edbca35512ba2fd936643af62208350906153..ef393d92d0309bb5ebd7b36944b07d07d804ab76 100644 (file)
@@ -1,6 +1,6 @@
 # -*- makefile -*-
 
-monolite_path := $(topdir)/class/lib/monolite/$(MONO_CORLIB_VERSION)
+monolite_path := $(topdir)/class/lib/monolite-$(BUILD_PLATFORM)/$(MONO_CORLIB_VERSION)
 
 with_mono_path_monolite = MONO_PATH="$(monolite_path)$(PLATFORM_PATH_SEPARATOR)$(monolite_path)/Facades$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH"
 
@@ -90,7 +90,7 @@ ifdef use_monolite
 do-get-monolite:
 
 do-profile-check-monolite:
-       @echo "*** The contents of your 'monolite/$(MONO_CORLIB_VERSION)' directory may be out-of-date" 1>&2
+       @echo "*** The contents of your 'monolite-$(BUILD_PLATFORM)/$(MONO_CORLIB_VERSION)' directory may be out-of-date" 1>&2
        @echo "*** You may want to try 'make get-monolite-latest'" 1>&2
        rm -f $(monolite_flag)
        exit 1
@@ -98,12 +98,12 @@ do-profile-check-monolite:
 else
 
 do-get-monolite:
-       @echo "*** Downloading bootstrap required 'monolite/$(MONO_CORLIB_VERSION)'" 1>&2
-       $(MAKE) $(MAKE_Q) -C $(mono_build_root) get-monolite-latest
+       @echo "*** Downloading bootstrap required 'monolite-$(BUILD_PLATFORM)/$(MONO_CORLIB_VERSION)'" 1>&2
+       $(MAKE) $(MAKE_Q) -C $(topdir)/class get-monolite-latest
 
 do-profile-check-monolite: $(depsdir)/.stamp
        @echo "*** The runtime '$(PROFILE_RUNTIME)' doesn't appear to be usable." 1>&2
-       @echo "*** Trying the 'monolite/$(MONO_CORLIB_VERSION)' directory." 1>&2
+       @echo "*** Trying the 'monolite-$(BUILD_PLATFORM)/$(MONO_CORLIB_VERSION)' directory." 1>&2
        @echo dummy > $(monolite_flag)
        $(MAKE) do-profile-check
 
index 8acb248d669de1674e924290707cc41603d2ba84..17d550e0f22c7d3d8ab9ba4af05476d6b8e8240c 100644 (file)
@@ -6,12 +6,14 @@ BUILD_TOOLS_PROFILE = basic
 BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_CSC)
 MCS = $(BOOTSTRAP_MCS)
 
+PLATFORMS = darwin linux win32
+
 # nuttzing!
 
 profile-check:
        @:
 
-DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll
+DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/mscorlib.dll
 PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES)
 
 NO_SIGN_ASSEMBLY = yes
index 0d01b5429ce4239f7bdfa0f5d4573c674fa73acc..8874b32326aa3f87550a5ff3a863a1e5d5fd6b04 100644 (file)
@@ -20,9 +20,10 @@ TEST_RUNTIME_WRAPPERS_PATH = $(shell dirname $(RUNTIME))/_tmpinst/bin
 ifndef NO_TEST
 
 test_nunit_lib = nunitlite.dll
-xunit_core := xunit.core xunit.abstractions xunit.assert
+xunit_core := xunit.core xunit.abstractions xunit.assert Xunit.NetCore.Extensions
 xunit_deps := System.Runtime
-xunit_class_deps := Xunit.NetCore.Extensions
+xunit_src  := $(patsubst %,$(topdir)/../external/xunit-binaries/%,BenchmarkAttribute.cs BenchmarkDiscover.cs)
+xunit_class_deps := 
 
 xunit_libs_ref = $(patsubst %,-r:$(topdir)/../external/xunit-binaries/%.dll,$(xunit_core))
 xunit_libs_ref += $(patsubst %,-r:$(topdir)/class/lib/$(PROFILE)/Facades/%.dll,$(xunit_deps))
@@ -89,9 +90,6 @@ endif
 
 tests_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
 
-$(topdir)/class/lib/$(PROFILE)/$(PARENT_PROFILE)Xunit.NetCore.Extensions.dll:
-       $(MAKE) -C $(topdir)/class/Xunit.NetCore.Extensions
-
 endif
 
 test_assemblies :=
@@ -222,8 +220,8 @@ run-xunit-test-lib: xunit-test-local
        $$ok
        @rm -f xunit.execution.desktop.dll
 
-$(xunit_test_lib): $(the_assembly) $(xtest_response) $(xunit_libs_dep)
-       $(TEST_COMPILE) $(LIBRARY_FLAGS) $(XTEST_LIB_FLAGS) -target:library -out:$@ $(xtest_flags) @$(xtest_response)
+$(xunit_test_lib): $(the_assembly) $(xtest_response) $(xunit_libs_dep) $(xunit_src)
+       $(TEST_COMPILE) $(LIBRARY_FLAGS) $(XTEST_LIB_FLAGS) -target:library -out:$@ $(xtest_flags) @$(xtest_response) $(xunit_src)
 
 xtest_response_preprocessed = $(xtest_response)_preprocessed
 
index 452d0c245ffcb61bd4b9278053ea76e500e71f3f..07a4d102d1796837984158e38f331253c2827e0c 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.1.0.0")]
+[assembly: AssemblyVersion ("4.2.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 24bd6ae8da7ded5bbc574655d7723359812e3522..feba11981fe6b86171b1669c1558c3419f8796c8 100644 (file)
 // 
 
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.DBNull))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.AcceptRejectRule))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.CommandBehavior))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.CommandType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.CatalogLocation))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DataAdapter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DataColumnMapping))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DataColumnMappingCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DataTableMapping))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DataTableMappingCollection))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbColumn))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbCommand))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbCommandBuilder))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbConnection))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbConnectionStringBuilder))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataAdapter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataReader))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataReaderExtensions))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataRecord))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbDataSourceEnumerator))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbEnumerator))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbMetaDataCollectionNames))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbMetaDataColumnNames))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbParameter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbParameterCollection))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbProviderFactory))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbProviderSpecificTypePropertyAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.DbTransaction))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.GroupByBehavior))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.IDbColumnSchemaGenerator))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.IdentifierCase))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.RowUpdatedEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.RowUpdatingEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.SchemaTableColumn))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.SchemaTableOptionalColumn))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Common.SupportedJoinOperators))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ConflictOption))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ConnectionState))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Constraint))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ConstraintCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ConstraintException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DBConcurrencyException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataColumn))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataColumnChangeEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataColumnChangeEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataColumnCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRelation))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRelationCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRow))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowAction))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowBuilder))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowChangeEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowChangeEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowState))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowVersion))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataRowView))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataSet))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataSetDateTime))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataSysDescriptionAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTable))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTableClearEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTableClearEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTableCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTableNewRowEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTableNewRowEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataTableReader))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataView))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataViewManager))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataViewRowState))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataViewSetting))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DataViewSettingCollection))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DbType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DeletedRowInaccessibleException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.DuplicateNameException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.EvaluateException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.FillErrorEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.FillErrorEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ForeignKeyConstraint))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IColumnMapping))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IColumnMappingCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataAdapter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataParameter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataParameterCollection))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataReader))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDataRecord))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbCommand))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbConnection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbDataAdapter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbDataParameter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IDbTransaction))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ITableMapping))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ITableMappingCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.InRowChangingEventException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.InternalDataCollectionBase))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.InvalidConstraintException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.InvalidExpressionException))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.IsolationLevel))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.KeyRestrictionBehavior))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.LoadOption))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.MappingType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.MergeFailedEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.MergeFailedEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.MissingMappingAction))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.MissingPrimaryKeyException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.MissingSchemaAction))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.NoNullAllowedException))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ParameterDirection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.PropertyCollection))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.ReadOnlyException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.RowNotInTableException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.Rule))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SchemaSerializationMode))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SchemaType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SerializationFormat))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlDbType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.INullable))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlAlreadyFilledException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlBinary))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlBoolean))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlByte))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlBytes))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlChars))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlCompareOptions))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlDateTime))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlDecimal))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlDouble))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlGuid))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlInt16))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlInt32))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlInt64))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlMoney))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlNotFilledException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlNullValueException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlSingle))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlString))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlTruncateException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlTypeException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.SqlXml))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SqlTypes.StorageState))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StateChangeEventArgs))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StateChangeEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StatementCompletedEventArgs))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StatementCompletedEventHandler))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StatementType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.StrongTypingException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.SyntaxErrorException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.UniqueConstraint))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.UpdateRowSource))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.UpdateStatus))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.VersionNotFoundException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.XmlReadMode))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Data.XmlWriteMode))]
 
 
index 74545a8a222a372e587cfe45912e1c0ab9b3de88..23257c24867cb35d7e9f2aa1fe161cd3fd9873c4 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.2.0")]
+[assembly: AssemblyVersion ("4.1.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 3643429a219efa4bb5011e6c17bbd9b5b76d4a58..b68327ecf21613f0c5729a34510107b4d648d139 100644 (file)
 
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.StackFrame))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.StackTrace))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolBinder))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolBinder1))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolDocument))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolDocumentWriter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolMethod))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolNamespace))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolReader))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolScope))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolVariable))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.ISymbolWriter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.SymAddressKind))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.SymDocumentType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.SymLanguageType))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.SymLanguageVendor))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.SymbolStore.SymbolToken))]
 
index a6d882dd4ffd3e234b3ad64d13d2ad36285037e0..8cecf7a0b4986ac653609e0b773b09adcb9494c5 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.1.0.0")]
+[assembly: AssemblyVersion ("4.2.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index ab67b29b11b4457d3c005b3b0668b4855452c68d..c58e46ad97cd03eec0191076f9b3b7c6882de677 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.1.0")]
+[assembly: AssemblyVersion ("4.1.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 00d2b6bddb2fe7371f93ed0258940b0dcbb22139..2e1f8f16a6a41d60889e8963aa2766fe786cafc9 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.0.0")]
+[assembly: AssemblyVersion ("4.0.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index b81cf3cf99abac106e5c922123fe7d11147c762c..1f3248cdf39d82cfb661a82dfd907eec8d7b2608 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.1.0.0")]
+[assembly: AssemblyVersion ("4.2.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 7fd2f2898cdbcfd89116ffd99c280713c1d756c5..ed555c0a82988cd5fa52a27d8e910f3df120b62a 100644 (file)
@@ -27,6 +27,7 @@
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.LingerOption))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.MulticastOption))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.NetworkStream))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.ProtocolFamily))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.ProtocolType))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.SelectMode))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Sockets.SendPacketsElement))]
index c0542a288f6a3711f878485bbb17934a5ea7b8fc..e354927ba507725ab8d869277536fa1f93c48ced 100644 (file)
@@ -39,7 +39,7 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.1.0")]
+[assembly: AssemblyVersion ("4.0.3.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
 
index 2c8edb8b0c8bec9c4eb5e03af8549938ddc0c483..c281126d6a5a393d28f7aa678ea0824b0e79c329 100644 (file)
@@ -8,7 +8,7 @@
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectGuid>{71D02788-3AD8-4C43-BDEB-1A3D277496BA}</ProjectGuid>\r
     <OutputType>Library</OutputType>\r
-    <NoWarn>1699,1616,1699</NoWarn>\r
+    <NoWarn>1699,1616,1699,436</NoWarn>\r
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Windows_NT'">win32</HostPlatform>\r
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix' and $([System.IO.File]::Exists('/usr/lib/libc.dylib'))">darwin</HostPlatform>\r
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix'">linux</HostPlatform>\r
@@ -36,7 +36,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
     <DebugSymbols>true</DebugSymbols>\r
     <DebugType>full</DebugType>\r
-    <NoWarn>1699,1616,1699</NoWarn>\r
+    <NoWarn>1699,1616,1699,436</NoWarn>\r
     <Optimize>false</Optimize>\r
     <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS</DefineConstants>\r
     <ErrorReport>prompt</ErrorReport>\r
@@ -44,7 +44,7 @@
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
     <DebugType>pdbonly</DebugType>\r
-    <NoWarn>1699,1616,1699</NoWarn>\r
+    <NoWarn>1699,1616,1699,436</NoWarn>\r
     <Optimize>true</Optimize>\r
     <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS</DefineConstants>\r
     <ErrorReport>prompt</ErrorReport>\r
index c3005ea20a0baa87fa2e422659b82ba7dc5de0b1..fe76e860baae4b28b3d64e4d1af2e7a2eb99b108 100644 (file)
@@ -12,7 +12,7 @@ LIBRARY = System.Runtime.InteropServices.RuntimeInformation.dll
 RESX_RESOURCE_STRING = ../../../../external/corefx/src/System.Runtime.InteropServices.RuntimeInformation/src/Resources/Strings.resx
 
 KEY_FILE = ../../msfinal.pub
-SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699
+SIGN_FLAGS = /delaysign /keyfile:$(KEY_FILE) /nowarn:1616,1699,436
 LIB_REFS = System
 LIB_MCS_FLAGS = $(SIGN_FLAGS) /unsafe
 
index d775167495ea166dcb5719a25ea83b3e87cd3577..4a515083c48f827fc1a950eb1d6a52b018daa0b3 100644 (file)
@@ -35,12 +35,9 @@ namespace System.Runtime.InteropServices
 {
        public static class RuntimeInformation
        {
-               [DllImport ("__Internal")]
-               extern static string mono_get_runtime_build_info ();
-
                public static string FrameworkDescription {
                        get {
-                               return mono_get_runtime_build_info ();
+                               return "Mono " + Mono.Runtime.GetDisplayName ();
                        }
                }
 
index 44acc9076159aac7fec5134bccb4d7ade50dc871..9ae9343c470cf1cadd05ea070de42e3981d8ed83 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.1.1.0")]
+[assembly: AssemblyVersion ("4.2.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 57b2d4db09ccb3689b3f37c1bf4f47cfcb634ab4..ea71c80449cbc24b0d332ebaaa2b06a3928fb11b 100644 (file)
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.DataContractAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.DataMemberAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.EnumMemberAttribute))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.ExportOptions))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.ExtensionDataObject))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.IExtensibleDataObject))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.IgnoreDataMemberAttribute))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.InvalidDataContractException))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.KnownTypeAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.OnDeserializedAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.OnDeserializingAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.OnSerializingAttribute))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.SerializationException))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.StreamingContext))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.InvalidDataContractException))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.StreamingContextStates))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.XmlSerializableServices))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.XPathQueryGenerator))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.XsdDataContractExporter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.IFragmentCapableXmlDictionaryWriter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.IStreamProvider))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.IXmlBinaryReaderInitializer))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.IXmlBinaryWriterInitializer))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.IXmlTextReaderInitializer))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Xml.IXmlTextWriterInitializer))]
index c41572f45bf7c5ee4ac35cbc46e16cb41b7861e1..3e0e376278743f2bb215ea7e98ff666907de1734 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.2.0.0")]
+[assembly: AssemblyVersion ("4.3.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index ff615bbfdac7d82fd5326235874360d984396fc8..2a7c09f471414c43021bbe3c9442a31b403cf066 100644 (file)
 // 
 
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.Aes))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.AesManaged))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.AsymmetricKeyExchangeDeformatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.AsymmetricKeyExchangeFormatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.AsymmetricSignatureDeformatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.AsymmetricSignatureFormatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.CryptoConfig))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.DeriveBytes))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.DES))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.DSA))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.DSAParameters))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.DSASignatureDeformatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.DSASignatureFormatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECCurve))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECDiffieHellmanPublicKey))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECDsa))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECParameters))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECPoint))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACMD5))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA1))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA256))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA384))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA512))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.MaskGenerationMethod))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.MD5))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.PKCS1MaskGenerationMethod))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RandomNumberGenerator))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RC2))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.Rfc2898DeriveBytes))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.Rijndael))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RijndaelManaged))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSA))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAEncryptionPadding))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAEncryptionPaddingMode))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAOAEPKeyExchangeFormatter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAParameters))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAPKCS1SignatureDeformatter))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSAPKCS1SignatureFormatter))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSASignaturePadding))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.RSASignaturePaddingMode))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA1))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA1Managed))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA256))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA256Managed))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA384))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA384Managed))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA512))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SHA512Managed))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.SignatureDescription))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.TripleDES))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECCurve))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECParameters))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.ECPoint))]
index 72ee369b0447cc2719c42207db0355f7b680a9d3..47dba143f04fae46a969f90676facd1854f1ddfa 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.0.0")]
+[assembly: AssemblyVersion ("4.1.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 84dca4216ad47ba8403ae53d48c06b865e0e49c4..3566d5fbcb33f7bebe32ddb9c0cd17a8a9157d32 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.1.0")]
+[assembly: AssemblyVersion ("4.1.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 6610d8849e04c02e163be58b2ebd58daf1215f05..70d43c05ae383e81e0fdb95a47abc8f80f180ca9 100644 (file)
@@ -22,5 +22,6 @@
 
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Threading.IOCompletionCallback))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Threading.NativeOverlapped))]
+[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Threading.Overlapped))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Threading.PreAllocatedOverlapped))]
 [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Threading.ThreadPoolBoundHandle))]
index fda0d3b249e56454dfded6370b77d28df2ad9099..a0747feed57e5794be6d1effca4facefae981a65 100644 (file)
@@ -30,6 +30,6 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.1.0")]
+[assembly: AssemblyVersion ("4.0.3.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
index 00626f58ee46f56355ee28425b68be5541218ce6..f2e8ea4a59d60d5aac7d5c77734260c7266c261e 100644 (file)
@@ -30,7 +30,7 @@ using System.Runtime.CompilerServices;
 [assembly: AssemblyCompany ("Xamarin, Inc.")]
 [assembly: AssemblyProduct ("Mono Common Language Infrastructure")]
 [assembly: AssemblyCopyright ("Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com)")]
-[assembly: AssemblyVersion ("4.0.1.0")]
+[assembly: AssemblyVersion ("4.1.1.0")]
 [assembly: AssemblyInformationalVersion ("4.0.0.0")]
 [assembly: AssemblyFileVersion ("4.0.0.0")]
 
index 97d46c50274e317ed2ce44b50d95c96fde32a24b..fd336eb81764406f72cc0092b8a94895d14927d3 100644 (file)
@@ -1,25 +1 @@
-The MIT X11 License covers most of the class libraries in the Mono
-project.  Some third party libraries come from different projects, and
-are licensed under their own terms.
-
-
-Copyright (c) 2001, 2002, 2003 The Mono Project
-
-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.
+See LICENSE file in the project root for full license information.
index a9610f239c370c8fce0ce666b39e40cec19a8c08..eb3b7b09ce2ca22311f0524732326e4cff6deb7a 100644 (file)
@@ -381,8 +381,7 @@ DISTFILES = \
        MicrosoftAjaxLibrary/License.htm        \
        test-helpers/NetworkHelpers.cs  \
        test-helpers/SocketResponder.cs \
-       lib/$(monolite_dir)/mcs.exe   \
-       $(monolite_files)
+       $(foreach HOST_PLATFORM,darwin linux win32,lib/$(monolite_dir)/mcs.exe $(monolite_files))
 
 .PHONY: all-local $(STD_TARGETS:=-local)
 all-local $(STD_TARGETS:=-local):
@@ -390,7 +389,7 @@ all-local $(STD_TARGETS:=-local):
 
 all-local-aot:
 
-monolite_dir := monolite/$(MONO_CORLIB_VERSION)
+monolite_dir = monolite-$(HOST_PLATFORM)/$(MONO_CORLIB_VERSION)
 
 # Files needed to bootstrap C# compiler
 build_files = mscorlib.dll System.dll System.Xml.dll Mono.Security.dll System.Core.dll System.Security.dll System.Configuration.dll \
@@ -413,24 +412,42 @@ lib/$(monolite_dir)/Facades:
 
 $(monolite_files): | lib/$(monolite_dir)
 $(monolite_files): | lib/$(monolite_dir)/Facades
-$(monolite_files): lib/$(monolite_dir)/%: lib/build/%
+$(monolite_files): lib/$(monolite_dir)/%: lib/build-$(HOST_PLATFORM)/%
        cp -p $< $@
 
 lib/$(monolite_dir)/mcs.exe:
        $(MAKE) -C ../mcs PROFILE=build
-       cp -p lib/build/mcs.exe lib/$(monolite_dir)
+       cp -p lib/build-$(HOST_PLATFORM)/mcs.exe lib/$(monolite_dir)
 
-$(build_files:%=lib/build/%):
+$(build_files:%=lib/build-$(HOST_PLATFORM)/%):
        cd $(topdir) && $(MAKE) profile-do--build--all NO_DIR_CHECK=1 SKIP_AOT=1
 
 dist-monolite: $(monolite_files) lib/$(monolite_dir)/mcs.exe
 
+dist-monolite-all-platforms:
+       $(MAKE) dist-monolite HOST_PLATFORM=darwin
+       $(MAKE) dist-monolite HOST_PLATFORM=linux
+       $(MAKE) dist-monolite HOST_PLATFORM=win32
+
 package-monolite-latest:
-       MONOLITE=monolite-$(MONO_CORLIB_VERSION)-latest; \
+       MONOLITE=monolite-$(HOST_PLATFORM)-$(MONO_CORLIB_VERSION)-latest; \
        $(MAKE) dist-monolite monolite_dir=$$MONOLITE; \
        tar zcvpf $$MONOLITE.tar.gz --directory=lib $$MONOLITE/
 
-dist-default: dist-monolite
+package-monolite-latest-all-platforms:
+       $(MAKE) package-monolite-latest HOST_PLATFORM=darwin
+       $(MAKE) package-monolite-latest HOST_PLATFORM=linux
+       $(MAKE) package-monolite-latest HOST_PLATFORM=win32
+
+monolite_url = https://download.mono-project.com/monolite/monolite-$(BUILD_PLATFORM)-$(MONO_CORLIB_VERSION)-latest.tar.gz
+
+get-monolite-latest:
+       -rm -fr lib/monolite-$(BUILD_PLATFORM)/$(MONO_CORLIB_VERSION)
+       -mkdir -p lib/monolite-$(BUILD_PLATFORM)
+       cd lib && { (wget -O- $(monolite_url) || curl -L $(monolite_url)) | gzip -d | tar xf - ; }
+       cd lib && mv -f monolite-$(BUILD_PLATFORM)-$(MONO_CORLIB_VERSION)-latest monolite-$(BUILD_PLATFORM)/$(MONO_CORLIB_VERSION)
+
+dist-default: dist-monolite-all-platforms
 
 dist-local: dist-default
 
index 9294c1b350a694d67e566d215298dd24acda09fc..23ae9a50b56611c2076368a4504fef0d1d233ecd 100644 (file)
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Conversions.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\COperators.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Declarations\AggregateDeclaration.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Declarations\Declaration.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Declarations\GlobalAttributeDeclaration.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Declarations\NamespaceDeclaration.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\ExplicitConversion.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\ExpressionBinder.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\ExpressionKind.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\EventSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\FieldSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\IndexerSymbol.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\LabelSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\LocalVariableSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\MethodOrPropertySymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\MethodSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\SymbolTable.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\SymFactory.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\SymFactoryBase.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\TransparentIdentifierMemberSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\TypeParameterSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\UnresolvedAggregateSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Symbols\VariableSymbol.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\ArrayIndex.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\ArrayInitialization.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\ArrayLength.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Assignment.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\BinaryOperator.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Block.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Class.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\CompoundOperator.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Concatenate.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\ConditionalOperator.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Constant.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\Event.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\Microsoft.CSharp\src\Microsoft\CSharp\RuntimeBinder\Semantics\Tree\EXPR.cs" />\r
index 76f1c417a02f400a9c9318712cda76b030df122c..c8779956f39ef8786d805eb0ebab2c94922c5076 100644 (file)
@@ -58,9 +58,6 @@ corefx/SR.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversions.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/COperators.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Declarations/AggregateDeclaration.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Declarations/Declaration.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Declarations/GlobalAttributeDeclaration.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Declarations/NamespaceDeclaration.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExplicitConversion.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionKind.cs
@@ -91,7 +88,6 @@ corefx/SR.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/EventSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/FieldSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/IndexerSymbol.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/LabelSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/LocalVariableSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/MethodOrPropertySymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/MethodSymbol.cs
@@ -109,13 +105,11 @@ corefx/SR.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymbolTable.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymFactory.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/SymFactoryBase.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/TransparentIdentifierMemberSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/TypeParameterSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/UnresolvedAggregateSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/VariableSymbol.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayIndex.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayInitialization.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ArrayLength.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Assignment.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/BinaryOperator.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Block.cs
@@ -125,7 +119,6 @@ corefx/SR.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Class.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/CompoundOperator.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Concatenate.cs
-../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ConditionalOperator.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Constant.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Event.cs
 ../../../external/corefx/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/EXPR.cs
index af3e1716ca42f92e05e6976a0d5dffb9ea8dc5fa..602c827091dedaa8314bd015dae6c2689616b4b7 100644 (file)
@@ -2214,7 +2214,7 @@ namespace Mono.Debugger.Soft
                internal ValueImpl[] Type_GetValues (long id, long[] fields, long thread_id) {
                        int len = fields.Length;
                        PacketReader r;
-                       if (thread_id != 0)
+                       if (thread_id != 0 && Version.AtLeast(2, 3))
                                r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_VALUES_2, new PacketWriter ().WriteId (id).WriteId (thread_id).WriteInt (len).WriteIds (fields));
                        else
                                r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_VALUES, new PacketWriter ().WriteId (id).WriteInt (len).WriteIds (fields));
index 8a2a3ef939cd868cb699f932dbb10a0c59108efe..4c2b33ee99e039ba22da084d91cccee9f0d0c775 100644 (file)
@@ -30,6 +30,11 @@ namespace Mono.Debugger.Soft
                        if (args != null && args.Length != 0)
                                throw new NotSupportedException ();
 
+                       //If method is virtual we can't optimize(execute IL) because it's maybe
+                       //overriden... call runtime to invoke overriden version...
+                       if (method.IsVirtual)
+                               throw new NotSupportedException ();
+
                        if (method.IsStatic || method.DeclaringType.IsValueType || this_val == null || !(this_val is ObjectMirror))
                                throw new NotSupportedException ();
 
@@ -350,6 +355,12 @@ namespace Mono.Debugger.Soft
                                                        } catch {
                                                                throw new NotSupportedException ();
                                                        }
+                                               } else if (method.ReturnType.IsEnum && primitive != null) {
+                                                       try {
+                                                               res = method.VirtualMachine.CreateEnumMirror (method.ReturnType, primitive);
+                                                       } catch {
+                                                               throw new NotSupportedException ();
+                                                       }
                                                }
 
                                                return res;
index fb10f7117c30258350bad2e93053dac7cbb14cbe..24c247285cd63cf003566247e1a579610424c176 100644 (file)
@@ -59,7 +59,7 @@ namespace Mono.Debugger.Soft
                                sb.Append (ReturnType.Name);
                                sb.Append (' ');
                                if (type_namespace != String.Empty)
-                                       sb.Append (type_namespace + ".");
+                                       sb.Append (type_namespace).Append (".");
                                sb.Append(type_name);
                                sb.Append(":");
                                sb.Append(Name);
index c92f2240ef8036b0d2a162a82846dba70c082bfb..2b9ab2a51e79c51f59c12a21402542e9e938e940 100644 (file)
@@ -102,6 +102,18 @@ namespace Mono.Debugger.Soft
                        }
                }
 
+               public int EndLineNumber {
+                       get {
+                               return Location.EndLineNumber;
+                       }
+               }
+
+               public int EndColumnNumber {
+                       get {
+                               return Location.EndColumnNumber;
+                       }
+               }
+
                public bool IsDebuggerInvoke {
                        get {
                                return (flags & StackFrameFlags.DEBUGGER_INVOKE) != 0;
index 5dbe5eb1fb55ca07d0d30e5f8a4bd57d399dd1bf..938a4ca8a8c1fae638066bc7d0f5808545c4b71a 100644 (file)
@@ -13,6 +13,8 @@ namespace Mono.Debugger.Soft
                ManualResetEvent fetchingEvent = new ManualResetEvent (false);
                ThreadInfo info;
                StackFrame[] frames;
+               bool threadStateInvalid = true;
+               ThreadState threadState;
 
                internal ThreadMirror (VirtualMachine vm, long id) : base (vm, id) {
                }
@@ -30,6 +32,7 @@ namespace Mono.Debugger.Soft
 
                internal void InvalidateFrames () {
                        cacheInvalid = true;
+                       threadStateInvalid = true;
                }
 
                internal void FetchFrames (bool mustFetch = false) {
@@ -91,7 +94,11 @@ namespace Mono.Debugger.Soft
 
                public ThreadState ThreadState {
                        get {
-                               return (ThreadState)vm.conn.Thread_GetState (id);
+                               if (threadStateInvalid) {
+                                       threadState = (ThreadState) vm.conn.Thread_GetState (id);
+                                       threadStateInvalid = false;
+                               }
+                               return threadState;
                        }
                }
 
index 9d7c9881ab93ce178ef1a308fd7bb2d92c58c4d7..1eaaac8ec9d4c165c76c5fe8d54094197434f36d 100644 (file)
@@ -665,7 +665,7 @@ namespace Mono.Debugger.Soft
                        return res;
                }
 
-               internal ValueImpl EncodeValue (Value v) {
+               internal ValueImpl EncodeValue (Value v, List<Value> duplicates = null) {
                        if (v is PrimitiveValue) {
                                object val = (v as PrimitiveValue).Value;
                                if (val == null)
@@ -675,16 +675,22 @@ namespace Mono.Debugger.Soft
                        } else if (v is ObjectMirror) {
                                return new ValueImpl { Type = ElementType.Object, Objid = (v as ObjectMirror).Id };
                        } else if (v is StructMirror) {
-                               return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeValues ((v as StructMirror).Fields) };
+                               if (duplicates == null)
+                                       duplicates = new List<Value> ();
+                               if (duplicates.Contains (v))
+                                       return new ValueImpl { Type = (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL, Objid = 0 };
+                               duplicates.Add (v);
+
+                               return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeValues ((v as StructMirror).Fields, duplicates) };
                        } else {
                                throw new NotSupportedException ();
                        }
                }
 
-               internal ValueImpl[] EncodeValues (IList<Value> values) {
+               internal ValueImpl[] EncodeValues (IList<Value> values, List<Value> duplicates = null) {
                        ValueImpl[] res = new ValueImpl [values.Count];
                        for (int i = 0; i < values.Count; ++i)
-                               res [i] = EncodeValue (values [i]);
+                               res [i] = EncodeValue (values [i], duplicates);
                        return res;
                }
 
@@ -724,6 +730,7 @@ namespace Mono.Debugger.Soft
                                        l.Add (new ThreadStartEvent (vm, req_id, id));
                                        break;
                                case EventType.ThreadDeath:
+                                       vm.GetThread (id).InvalidateFrames ();
                                        vm.InvalidateThreadCache ();
                                        l.Add (new ThreadDeathEvent (vm, req_id, id));
                                        break;
index 211a0df302b8f18abb0a3d679d92bb789403ff55..27a4e0e55f03951e8e1d15e1c8fa63c8b00ef374 100644 (file)
@@ -5,6 +5,7 @@ using System.IO;
 using System.Net;
 using System.Net.Sockets;
 using System.Runtime.Remoting.Messaging;
+using System.Text;
 
 namespace Mono.Debugger.Soft
 {
@@ -95,6 +96,12 @@ namespace Mono.Debugger.Soft
                                info.FileName = "valgrind";
                        info.UseShellExecute = false;
 
+                       if (info.RedirectStandardError)
+                               info.StandardErrorEncoding = Encoding.UTF8;
+
+                       if (info.RedirectStandardOutput)
+                               info.StandardOutputEncoding = Encoding.UTF8;
+
                        ITargetProcess p;
                        if (options != null && options.CustomProcessLauncher != null)
                                p = new ProcessWrapper (options.CustomProcessLauncher (info));
index 400b43ce34f599f808362bdbeaaac26778451e68..d2b408a68eddb940fcbbcb85275ba88d2336bb1e 100644 (file)
@@ -1165,10 +1165,18 @@ public class Tests : TestsBase, ITest2
                return 42;
        }
 
+       public int invoke_pass_nullable (int? i) {
+               return (int)i;
+       }
+
        public int? invoke_return_nullable_null () {
                return null;
        }
 
+       public int invoke_pass_nullable_null (int? i) {
+               return i.HasValue ? 1 : 2;
+       }
+
        public void invoke_type_load () {
                new Class3 ();
        }
index 631b5985db1ff7129d11b1443984be1b7c2fabcb..8d22ac808b2282d92cd8c3787030eb0ba147f14b 100644 (file)
@@ -2617,6 +2617,11 @@ public class DebuggerTests
                m = s.Type.GetMethod ("ToString");
                v = s.InvokeMethod (e.Thread, m, null);
 
+               // pass nullable as argument
+               m = t.GetMethod ("invoke_pass_nullable");
+               v = this_obj.InvokeMethod (e.Thread, m, new Value [] { s });
+               AssertValue (42, v);
+
                // return nullable null
                m = t.GetMethod ("invoke_return_nullable_null");
                v = this_obj.InvokeMethod (e.Thread, m, null);
@@ -2630,6 +2635,24 @@ public class DebuggerTests
                m = s.Type.GetMethod ("ToString");
                v = s.InvokeMethod (e.Thread, m, null);
 
+               // pass nullable null as argument
+               m = t.GetMethod ("invoke_pass_nullable_null");
+               v = this_obj.InvokeMethod (e.Thread, m, new Value [] { s });
+               AssertValue (2, v);
+
+               return;
+
+               // string constructor
+               var stringType = vm.RootDomain.Corlib.GetType ("System.String");
+               var stringConstructor = stringType.GetMethods ().Single (c=>
+                       c.Name == ".ctor" &&
+                       c.GetParameters ().Length == 2 &&
+                       c.GetParameters ()[0].ParameterType.Name == "Char" &&
+                       c.GetParameters ()[1].ParameterType.Name == "Int32");
+               var str = stringType.NewInstance (e.Thread, stringConstructor,  new Value [] { vm.CreateValue ('a'), vm.CreateValue (3)});
+
+               AssertValue("aaa", str);
+
                // pass primitive
                m = t.GetMethod ("invoke_pass_primitive");
                Value[] args = new Value [] {
index a195e43a80fece366f07955f14f5d4df52af17a4..d5a86615513a363f3e5a8ab6fe3f7f8f91401831 100644 (file)
@@ -228,7 +228,7 @@ namespace MonoTests.Mono.Options
                        e.Run = (args) => e.CommandSet.Out.WriteLine (string.Join (" ", args));
 
                        var o = new StringWriter ();
-                       var c = new CommandSet ("set", output:o) {
+                       var c = new CommandSet ("set", output:o, error: Console.Error) {
                                e,
                        };
                        Assert.AreEqual (0, c.Run (new [] { "help", "echo" }));
index 09ffecbc1e9452af353bced8dd640e144be987cb..362d3ea61a1742e9b08d8654829d0b6b228fb248 100644 (file)
@@ -56,7 +56,7 @@ namespace MonoTests.Mono.Options
                                        c, v => { string ignore = v.OptionValues [0]; });
                        c.Option = p [0];
                        Utils.AssertException (typeof(ArgumentOutOfRangeException),
-                                       "Specified argument was out of the range of valid values.\nParameter name: index",
+                                       $"Specified argument was out of the range of valid values.{Environment.NewLine}Parameter name: index",
                                        c, v => { string ignore = v.OptionValues [2]; });
                        c.OptionName = "-a";
                        Utils.AssertException (typeof(OptionException),
index 572223ebd667110f30f7aa6dd013693c351b4180..790d55dea2d44fe103ff237b95e6e8bbf9c46568 100644 (file)
@@ -374,10 +374,10 @@ namespace MonoTests.Mono.Options
                                        p, v => { v.Parse (_("-a", "-b")); });
                        Assert.AreEqual (a, "-b");
                        Utils.AssertException (typeof(ArgumentNullException),
-                                       "Value cannot be null.\nParameter name: option",
+                                       $"Value cannot be null.{Environment.NewLine}Parameter name: option",
                                        p, v => { v.Add ((Option) null); });
                        Utils.AssertException (typeof(ArgumentNullException),
-                                       "Value cannot be null.\nParameter name: header",
+                                       $"Value cannot be null.{Environment.NewLine}Parameter name: header",
                                        p, v => { v.Add ((string) null); });
 
                        // bad type
@@ -394,10 +394,10 @@ namespace MonoTests.Mono.Options
                                        p, v => { v.Parse (_("-cz", "extra")); });
 
                        Utils.AssertException (typeof(ArgumentNullException), 
-                                       "Value cannot be null.\nParameter name: action",
+                                       $"Value cannot be null.{Environment.NewLine}Parameter name: action",
                                        p, v => { v.Add ("foo", (Action<string>) null); });
                        Utils.AssertException (typeof(ArgumentException), 
-                                       "Cannot provide maxValueCount of 2 for OptionValueType.None.\nParameter name: maxValueCount",
+                                       $"Cannot provide maxValueCount of 2 for OptionValueType.None.{Environment.NewLine}Parameter name: maxValueCount",
                                        p, v => { v.Add ("foo", (k, val) => {/* ignore */}); });
                }
 
@@ -772,7 +772,7 @@ namespace MonoTests.Mono.Options
                        Utils.AssertException (typeof(ArgumentException), "prototypes must be null!",
                                        p, v => { v.Add ("N|NUM=", (int n) => {}); });
                        Utils.AssertException (typeof(ArgumentNullException),
-                                       "Value cannot be null.\nParameter name: option",
+                                       $"Value cannot be null.{Environment.NewLine}Parameter name: option",
                                        p, v => { v.GetOptionForName (null); });
                }
 
index 999e6f45b61241e66b737c7561a0ecb6482683f0..42a998ea55cdbe33193a8d0c4cd3d9b918da0045 100644 (file)
@@ -66,60 +66,60 @@ namespace MonoTests.Mono.Options
                {
                        object p = null;
                        Utils.AssertException (typeof(ArgumentNullException), 
-                                       "Value cannot be null.\nParameter name: prototype", 
+                                       $"Value cannot be null.{Environment.NewLine}Parameter name: prototype", 
                                        p, v => { new DefaultOption (null, null); });
                        Utils.AssertException (typeof(ArgumentException), 
-                                       "Cannot be the empty string.\nParameter name: prototype",
+                                       $"Cannot be the empty string.{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Empty option names are not supported.\nParameter name: prototype",
+                                       $"Empty option names are not supported.{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("a|b||c=", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Conflicting option types: '=' vs. ':'.\nParameter name: prototype",
+                                       $"Conflicting option types: '=' vs. ':'.{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("a=|b:", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "The default option handler '<>' cannot require values.\nParameter name: prototype",
+                                       $"The default option handler '<>' cannot require values.{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("<>=", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "The default option handler '<>' cannot require values.\nParameter name: prototype",
+                                       $"The default option handler '<>' cannot require values.{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("<>:", null); });
                        Utils.AssertException (null, null,
                                        p, v => { new DefaultOption ("t|<>=", null, 1); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "The default option handler '<>' cannot require values.\nParameter name: prototype",
+                                       $"The default option handler '<>' cannot require values.{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("t|<>=", null, 2); });
                        Utils.AssertException (null, null,
                                        p, v => { new DefaultOption ("a|b=", null, 2); });
                        Utils.AssertException (typeof(ArgumentOutOfRangeException),
-                                       "Specified argument was out of the range of valid values.\nParameter name: maxValueCount",
+                                       $"Specified argument was out of the range of valid values.{Environment.NewLine}Parameter name: maxValueCount",
                                        p, v => { new DefaultOption ("a", null, -1); });
                        Utils.AssertException (typeof(ArgumentException),
                                        "Cannot provide maxValueCount of 0 for OptionValueType.Required or " +
-                                               "OptionValueType.Optional.\nParameter name: maxValueCount",
+                                               $"OptionValueType.Optional.{Environment.NewLine}Parameter name: maxValueCount",
                                        p, v => { new DefaultOption ("a=", null, 0); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Ill-formed name/value separator found in \"a={\".\nParameter name: prototype",
+                                       "Ill-formed name/value separator found in \"a={\"." + Environment.NewLine + "Parameter name: prototype",
                                        p, v => { new DefaultOption ("a={", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Ill-formed name/value separator found in \"a=}\".\nParameter name: prototype",
+                                       "Ill-formed name/value separator found in \"a=}\"." + Environment.NewLine + "Parameter name: prototype",
                                        p, v => { new DefaultOption ("a=}", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Ill-formed name/value separator found in \"a={{}}\".\nParameter name: prototype",
+                                       "Ill-formed name/value separator found in \"a={{}}\"." + Environment.NewLine + "Parameter name: prototype",
                                        p, v => { new DefaultOption ("a={{}}", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Ill-formed name/value separator found in \"a={}}\".\nParameter name: prototype",
+                                       "Ill-formed name/value separator found in \"a={}}\"." + Environment.NewLine + "Parameter name: prototype",
                                        p, v => { new DefaultOption ("a={}}", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Ill-formed name/value separator found in \"a={}{\".\nParameter name: prototype",
+                                       "Ill-formed name/value separator found in \"a={}{\"." + Environment.NewLine + "Parameter name: prototype",
                                        p, v => { new DefaultOption ("a={}{", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Cannot provide key/value separators for Options taking 1 value(s).\nParameter name: prototype",
+                                       $"Cannot provide key/value separators for Options taking 1 value(s).{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("a==", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Cannot provide key/value separators for Options taking 1 value(s).\nParameter name: prototype",
+                                       $"Cannot provide key/value separators for Options taking 1 value(s).{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("a={}", null); });
                        Utils.AssertException (typeof(ArgumentException),
-                                       "Cannot provide key/value separators for Options taking 1 value(s).\nParameter name: prototype",
+                                       $"Cannot provide key/value separators for Options taking 1 value(s).{Environment.NewLine}Parameter name: prototype",
                                        p, v => { new DefaultOption ("a=+-*/", null); });
                        Utils.AssertException (null, null,
                                        p, v => { new DefaultOption ("a", null, 0); });
index e26c50b01cde1b892035effbd81e3348ff5379c5..ce6b749678d9c5c296dcef1ea33bf45f7021dfe3 100644 (file)
@@ -34,9 +34,16 @@ using System.Reflection;
 using System.Runtime.InteropServices;
 using System.Security.Permissions;
 
-[assembly: AssemblyVersion (Consts.FxVersion)]
 
+
+#if MONO_POSIX_NETSTANDARD_BUILD
+[assembly: AssemblyVersion ("1.0.0.0")]
+[assembly: AssemblyTitle("Mono.Posix.NETStandard.dll")]
+#else
+[assembly: AssemblyVersion (Consts.FxVersion)]
 [assembly: AssemblyTitle("Mono.Posix.dll")]
+#endif
+
 [assembly: AssemblyDescription("Unix Integration Classes")]
 
 [assembly: CLSCompliant (true)]
@@ -48,9 +55,11 @@ using System.Security.Permissions;
 
 */
 
+#if !MONO_POSIX_NETSTANDARD_BUILD
+// We are using ../Open.snk for MONO_POSIX_NETSTANDARD_BUILD
 [assembly: AssemblyDelaySign (true)]
 [assembly: AssemblyKeyFile ("../mono.pub")]
-
+#endif
 /*
  * TODO:
  * 
diff --git a/mcs/class/Mono.Posix/Mono.Posix.NETStandard-netstandard_2_0.csproj b/mcs/class/Mono.Posix/Mono.Posix.NETStandard-netstandard_2_0.csproj
new file mode 100644 (file)
index 0000000..8563586
--- /dev/null
@@ -0,0 +1,35 @@
+<Project Sdk="Microsoft.NET.Sdk">\r
+\r
+  <PropertyGroup>\r
+    <TargetFramework>netstandard2.0</TargetFramework>\r
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+    <AssemblyName>Mono.Posix.NETStandard</AssemblyName>\r
+    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>\r
+    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>\r
+    <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>\r
+    <EnableDefaultItems>false</EnableDefaultItems>\r
+    <SignAssembly>true</SignAssembly>\r
+    <DelaySign>true</DelaySign>\r
+    <AssemblyOriginatorKeyFile>..\Open.snk</AssemblyOriginatorKeyFile>\r
+    <!--<BaseIntermediateOutputPath>obj-netstandard2.0</BaseIntermediateOutputPath>\r
+    <IntermediateOutputPath>obj-netstandard2.0</IntermediateOutputPath>-->\r
+  </PropertyGroup>\r
+\r
+  <PropertyGroup>\r
+    <DefineConstants>$(DefineConstants);MONO_POSIX_NETSTANDARD_BUILD</DefineConstants>\r
+  </PropertyGroup>\r
+\r
+  <PropertyGroup Condition="'$(ForceUseLibC)' == 'true'">\r
+    <DefineConstants>$(DefineConstants);FORCE_USE_LIBC_NOT_MSVC</DefineConstants>\r
+  </PropertyGroup>\r
+\r
+  <ItemGroup>\r
+    <Compile Include=".\Assembly\**\*.cs" />\r
+    <Compile Include=".\Mono.Posix\**\*.cs" />\r
+    <Compile Include=".\Mono.Unix\**\*.cs" />\r
+    <Compile Include=".\Mono.Unix.Native\**\*.cs" />\r
+    <Compile Include="..\..\build\common\Locale.cs" />\r
+    <Compile Remove=".\Mono.Unix.Native\CdeclFunction.cs" />\r
+  </ItemGroup>\r
+\r
+</Project>\r
index dbabb29c7f1b70c9544914abb197388d7af0a1ab..59b66ca26fb29dc0e61bfc05ece530bffe03bf18 100644 (file)
@@ -309,6 +309,7 @@ namespace Mono.Unix.Native {
        public delegate void SignalHandler (int signal);
 
 
+#if !NETSTANDARD2_0
        internal class XPrintfFunctions
        {
                internal delegate object XPrintf (object[] parameters);
@@ -335,6 +336,7 @@ namespace Mono.Unix.Native {
                        syslog = new XPrintf (_syslog.Invoke);
                }
        }
+#endif
 
        //
        // Convention: Functions that are part of the C standard library go here.
@@ -378,7 +380,11 @@ namespace Mono.Unix.Native {
        //
        public class Stdlib
        {
+#if FORCE_USE_LIBC_NOT_MSVC
+               internal const string LIBC = "c";
+#else
                internal const string LIBC = "msvcrt";
+#endif
                internal const string MPH  = "MonoPosixHelper";
 
                // It is possible for Mono.Posix and MonoPosixHelper to get out of sync,
@@ -771,6 +777,7 @@ namespace Mono.Unix.Native {
                        return sys_fprintf (stream, "%s", message);
                }
 
+#if !NETSTANDARD2_0
                [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
                                "Use fprintf (IntPtr, string) instead.")]
                public static int fprintf (IntPtr stream, string format, params object[] parameters)
@@ -781,6 +788,7 @@ namespace Mono.Unix.Native {
                        Array.Copy (parameters, 0, _parameters, 2, parameters.Length);
                        return (int) XPrintfFunctions.fprintf (_parameters);
                }
+#endif
 
                /* SKIP: fscanf(3) */
 
@@ -793,6 +801,7 @@ namespace Mono.Unix.Native {
                        return sys_printf ("%s", message);
                }
 
+#if !NETSTANDARD2_0
                [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
                                "Use printf (string) instead.")]
                public static int printf (string format, params object[] parameters)
@@ -802,6 +811,7 @@ namespace Mono.Unix.Native {
                        Array.Copy (parameters, 0, _parameters, 1, parameters.Length);
                        return (int) XPrintfFunctions.printf (_parameters);
                }
+#endif
 
                /* SKIP: scanf(3) */
 
@@ -823,6 +833,7 @@ namespace Mono.Unix.Native {
                        return sys_snprintf (s, (ulong) s.Capacity, "%s", message);
                }
 
+#if !NETSTANDARD2_0
                [CLSCompliant (false)]
                [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
                                "Use snprintf (StringBuilder, string) instead.")]
@@ -853,6 +864,7 @@ namespace Mono.Unix.Native {
                        Array.Copy (parameters, 0, _parameters, 3, parameters.Length);
                        return (int) XPrintfFunctions.snprintf (_parameters);
                }
+#endif
 
                /*
                 * SKIP:
index 4ae330d5b46f74420f5ed35603c04f4f6cae15fc..c750e5fa86b353b625f01b0f5d1227c6a43c4dc4 100644 (file)
@@ -4387,6 +4387,7 @@ namespace Mono.Unix.Native {
                        return UnixMarshal.EscapeFormatString (message, new char[]{'m'});
                }
 
+#if !NETSTANDARD2_0
                [Obsolete ("Not necessarily portable due to cdecl restrictions.\n" +
                                "Use syslog(SyslogFacility, SyslogLevel, string) instead.")]
                public static int syslog (SyslogFacility facility, SyslogLevel level, 
@@ -4415,6 +4416,7 @@ namespace Mono.Unix.Native {
                        Array.Copy (parameters, 0, _parameters, 2, parameters.Length);
                        return (int) XPrintfFunctions.syslog (_parameters);
                }
+#endif
 
                [DllImport (MPH, SetLastError=true,
                                EntryPoint="Mono_Posix_Syscall_closelog")]
index 1d8e40ca45cf5ac5e4fcec6e97eaa6f754790c51..d869b1b90c68bb7d8a4dc47142c597d70c0f5835 100644 (file)
@@ -300,17 +300,35 @@ public class UnixEncoding : Encoding
                        throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
                }
 
+               unsafe {
+                       fixed (char* p = s) {
+                               fixed (byte* b = bytes) {
+                                       return GetBytes (p + charIndex, charCount, b + byteIndex, bytes.Length - byteIndex);
+                               }
+                       }
+               }
+       }
+
+       public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
+       {
+               if (bytes == null || chars == null)
+                       throw new ArgumentNullException (bytes == null ? "bytes" : "chars");
+
+               if (charCount < 0 || byteCount < 0)
+                       throw new ArgumentOutOfRangeException (charCount < 0 ? "charCount" : "byteCount");
+                       
                // Convert the characters into bytes.
                char ch;
-               int length = bytes.Length;
+               int length = byteCount;
                uint pair;
-               int posn = byteIndex;
+               int posn = 0;
+               int charIndex = 0;
                while (charCount > 0) {
                        // Fetch the next UTF-16 character pair value.
-                       ch = s[charIndex++];
+                       ch = chars [charIndex++];
                        if (ch >= '\uD800' && ch <= '\uDBFF' && charCount > 1) {
                                // This may be the start of a surrogate pair.
-                               pair = (uint)(s[charIndex]);
+                               pair = (uint)(chars[charIndex]);
                                if (pair >= (uint)0xDC00 && pair <= (uint)0xDFFF) {
                                        pair = (pair - (uint)0xDC00) +
                                                   ((((uint)ch) - (uint)0xD800) << 10) +
@@ -326,7 +344,7 @@ public class UnixEncoding : Encoding
                                }
                                charCount -= 2;
                                if (charCount >= 0) {
-                                       bytes[posn++] = (byte) s [charIndex++];
+                                       bytes[posn++] = (byte)chars [charIndex++];
                                }
                                continue;
                        } else {
@@ -365,7 +383,7 @@ public class UnixEncoding : Encoding
                }
 
                // Return the final count to the caller.
-               return posn - byteIndex;
+               return posn;
        }
 
        // Internal version of "GetCharCount" which can handle a rolling
@@ -394,7 +412,7 @@ public class UnixEncoding : Encoding
                uint leftSoFar = (leftOverCount & (uint)0x0F);
                uint leftSize = ((leftOverCount >> 4) & (uint)0x0F);
                while (count > 0) {
-                       ch = (uint)(bytes[index++]);
+                       ch = (uint)(bytes [index++]);
                        ++next_raw;
                        --count;
                        if (leftSize == 0) {
index 334b6f2a49b42c089ea2b1492109021cbc75628a..0b01eb19ad40fc1592cd78c2ed3aa74f6a1c6a7e 100644 (file)
@@ -325,27 +325,42 @@ namespace Mono.Unix {
                        if (encoding == null)
                                throw new ArgumentNullException ("encoding");
 
-                       int min_byte_count = encoding.GetMaxByteCount(1);
-                       char[] copy = s.ToCharArray (index, count);
-                       byte[] marshal = new byte [encoding.GetByteCount (copy) + min_byte_count];
+                       if (index < 0 || count < 0)
+                               throw new ArgumentOutOfRangeException ((index < 0 ? "index" : "count"),
+                                        "Non - negative number required.");
 
-                       int bytes_copied = encoding.GetBytes (copy, 0, copy.Length, marshal, 0);
+                       if (s.Length - index < count)
+                               throw new ArgumentOutOfRangeException ("s", "Index and count must refer to a location within the string.");
 
-                       if (bytes_copied != (marshal.Length-min_byte_count))
-                               throw new NotSupportedException ("encoding.GetBytes() doesn't equal encoding.GetByteCount()!");
+                       int null_terminator_count = encoding.GetMaxByteCount (1);
+                       int length_without_null = encoding.GetByteCount (s);
+                       int marshalLength = checked (length_without_null + null_terminator_count);
 
-                       IntPtr mem = AllocHeap (marshal.Length);
+                       IntPtr mem = AllocHeap (marshalLength);
                        if (mem == IntPtr.Zero)
                                throw new UnixIOException (Native.Errno.ENOMEM);
 
-                       bool copied = false;
-                       try {
-                               Marshal.Copy (marshal, 0, mem, marshal.Length);
-                               copied = true;
-                       }
-                       finally {
-                               if (!copied)
-                                       FreeHeap (mem);
+                       unsafe {
+                               fixed (char* p = s) {
+                                       byte* marshal = (byte*)mem;
+                                       int bytes_copied;
+
+                                       try {
+                                               bytes_copied = encoding.GetBytes (p + index, count, marshal, marshalLength);
+                                       } catch {
+                                               FreeHeap (mem);
+                                               throw;
+                                       }
+
+                                       if (bytes_copied != length_without_null) {
+                                               FreeHeap (mem);
+                                               throw new NotSupportedException ("encoding.GetBytes() doesn't equal encoding.GetByteCount()!");
+                                       }
+
+                                       marshal += length_without_null;
+                                       for (int i = 0; i < null_terminator_count; ++i)
+                                               marshal[i] = 0;
+                               }
                        }
 
                        return mem;
index aa0c06b76c61b87b2f76f222457d2069badf59ac..e429af7f726cc3ade48060848ba35b91604988a5 100644 (file)
@@ -56,7 +56,7 @@ namespace MonoTests.Mono.Unix.Native {
                        Assert.IsFalse (NativeConvert.ToSignum (st.signalReceived) == Signum.SIGURG,
                                        "#IH: Signal Handler invoked when it should have been removed!");
                }
-
+#if !NETCOREAPP2_0
                [Test]
                // MSVCRT.DLL doesn't export snprintf(3).
                [Category ("NotDotNet")]
@@ -92,6 +92,7 @@ namespace MonoTests.Mono.Unix.Native {
                        Assert.AreEqual (s.ToString(), expected,
                                        "#SNPF: printf of many builtin types failed");
                }
+#endif
        }
 }
 
index 4982e8044770054d00257db4ad577db6263b326a..00556863db9c5c4397e41d6ee370cc827979d4f8 100644 (file)
@@ -86,6 +86,8 @@ namespace Mono.Security.Interface
 
                void EndWrite (IAsyncResult asyncResult);
 
+               Task ShutdownAsync ();
+
                TransportContext TransportContext {
                        get;
                }
index 01e6ffd67a812f6178c8ac6b006abd8d333f14f7..d5b5c809634ab377648bad9ee6be28c736d7a91b 100644 (file)
@@ -387,7 +387,7 @@ namespace Mono.Security.X509 {
                                        byte[] nullPassword = {0, 0};
                                        calculatedMac = MAC(nullPassword, macSalt.Value, _iterations, authSafeData);
                                        if (!Compare (macValue, calculatedMac))
-                                               throw new CryptographicException ("Invalid MAC - file may have been tampe red!");
+                                               throw new CryptographicException ("Invalid MAC - file may have been tampered with!");
                                        _password = nullPassword;
                                }
                        }
index 9d5ac35f66a98d80bdbb38d92bb63566bca9a5a1..c9e33efc77003eb666e15a8a88f87631bfb371b6 100644 (file)
@@ -27,6 +27,7 @@ Mono.Security.Cryptography/PKCS8Test.cs
 Mono.Security.Cryptography/RSAManagedTest.cs
 Mono.Security.Cryptography/SHA224ManagedTest.cs
 Mono.Security.Cryptography/SHA224Test.cs
+Mono.Security.Interface/TestProvider.cs
 Mono.Security.Protocol.Ntlm/ChallengeResponseTest.cs
 Mono.Security.Protocol.Ntlm/MessageBaseTest.cs
 Mono.Security.Protocol.Ntlm/Type1MessageTest.cs
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Interface/TestProvider.cs b/mcs/class/Mono.Security/Test/Mono.Security.Interface/TestProvider.cs
new file mode 100644 (file)
index 0000000..4a2b34a
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// TestProvider.cs
+//
+// Author:
+//       Martin Baulig <mabaul@microsoft.com>
+//
+// Copyright (c) 2017 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.Security.Cryptography;
+using System.Text;
+
+using Mono.Security;
+using Mono.Security.Interface;
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Security
+{
+       [TestFixture]
+       public class TestProvider
+       {
+               [Test]
+               public void GetProvider ()
+               {
+                       var provider = MonoTlsProviderFactory.GetProvider ();
+                       Assert.IsNotNull (provider, "TLS Provider");
+               }
+       }
+}
index 421c04da2bfd3b360a1fd5f2c9b17adfde0b221e..b2692bf692724cbc3ff567cbf467e26cb8424e81 100644 (file)
@@ -35,15 +35,6 @@ testing.
        of comments in the source code for that purpose, and if the
        problem requires to be followed up on, file a bug.
 
-* Supporting .NET 1.2, .NET 1.1 and .NET 1.0 builds
-
-       The defines NET_1_1 and NET_2_0 are used to include
-       features.   When NET_2_0 is defined, it also implies that the
-       NET_1_1 is defined.
-
-       To have code which is only available in an old version, use ONLY_1_0,
-       ONLY_1_1
-
 * Tagging buggy code
 
        If there is a bug in your implementation tag the problem by using
@@ -69,255 +60,8 @@ testing.
        not only stupid, but leading to unreliable code).
 
        In those cases, use the keyword "LAMESPEC".
-       
 
 * Coding considerations and style.
 
        In order to keep the code consistent, please use the following
-       conventions.  From here on `good' and `bad' are used to attribute
-       things that would make the coding style match, or not match.  It is not
-       a judgement call on your coding abilities, but more of a style and 
-       look call.  Please try to follow these guidelines to ensure prettiness.
-
-       Use 8 space tabs for writing your code (hopefully we can keep
-       this consistent).  If you are modifying someone else's code, try
-       to keep the coding style similar.
-
-       Since we are using 8-space tabs, you might want to consider the Linus
-       Torvals trick to reduce code nesting.  Many times in a loop, you will
-       find yourself doing a test, and if the test is true, you will nest.
-       Many times this can be changed.  Example:
-
-
-               for (i = 0; i < 10; i++) {
-                       if (something (i)) {
-                               do_more ();
-                       }
-               }
-
-       This take precious space, instead write it like this:
-
-               for (i = 0; i < 10; i++) {
-                       if (!something (i))
-                               continue;
-                       do_more ();
-               }
-
-       A few guidelines:
-
-               * Use a space before an opening parenthesis when calling
-                 functions, or indexing, like this:
-
-                       method (a);
-                       b [10];
-
-               * Do not put a space after the opening parenthesis and the 
-                 closing one, ie:
-
-                       good: method (a);       array [10];
-
-                       bad:  method ( a );     array[ 10 ];
-
-               * Inside a code block, put the opening brace on the same line
-                 as the statement:
-
-                       good:
-                               if (a) {
-                                       code ();
-                                       code ();
-                               }
-
-                       bad:
-                               if (a) 
-                               {
-                                       code ();
-                                       code ();
-                               }
-
-               * Avoid using unnecessary open/close braces, vertical space
-                 is usually limited:
-
-                       good:
-                               if (a)
-                                       code ();
-
-                       bad:
-                               if (a) {
-                                       code ();
-                               }
-
-               * When defining a method, use the C style for brace placement, 
-                 that means, use a new line for the brace, like this:
-
-                       good:
-                               void Method ()
-                               {
-                               }
-
-                       bad:
-                               void Method () {
-                               }
-
-               * Properties and indexers are an exception, keep the
-                 brace on the same line as the property declaration.
-                 Rationale: this makes it visually
-                 simple to distinguish them.
-
-                       good:
-                               int Property {
-                                       get {
-                                               return value;
-                                       }
-                               }
-
-                       bad:
-                               int Property 
-                               {
-                                       get {
-                                               return value;
-                                       }
-                               }
-
-                 Notice how the accessor "get" also keeps its brace on the same
-                 line.
-
-                 For very small properties, you can compress things:
-
-                       ok:
-                               int Property {
-                                       get { return value; }
-                                       set { x = value; }
-                               }
-
-               * Use white space in expressions liberally, except in the presence
-                 of parenthesis:
-
-                       good:
-
-                               if (a + 5 > method (blah () + 4))
-
-                       bad:
-                               if (a+5>method(blah()+4))
-
-               * For any new files, please use a descriptive introduction, like
-                 this:
-
-                       //
-                       // System.Comment.cs: Handles comments in System files.
-                       //
-                       // Author:
-                       //   Juan Perez (juan@address.com)
-                       //
-                       // (C) 2002 Address, Inc (http://www.address.com)
-                       //
-
-               * If you are modyfing someone else's code, and your contribution
-                 is significant, please add yourself to the Authors list.
-
-               * Switch statements have the case at the same indentation as the
-                 switch:
-
-                       switch (x) {
-                       case 'a':
-                               ...
-                       case 'b':
-                               ...
-                       }
-
-               * Argument names should use the camel casing for
-                 identifiers, like this:
-
-                       good:
-                               void Method (string myArgument)
-
-                       bad:
-                               void Method (string lpstrArgument)
-                               void Method (string my_string)
-
-               * Empty methods: They should have the body of code using two    
-                 lines, in consistency with the rest:
-
-                       good:
-                               void EmptyMethod ()
-                               {
-                               }
-
-                       bad:
-                               void EmptyMethod () {}
-
-                               void EmptyMethod () 
-                               {}
-               
-               * Line length: The line length for C# source code is 134 columns.
-
-
-                 If your function declaration arguments go beyond
-                 this point, please align your arguments to match the
-                 opening brace, like this:
-
-                       void Function (int arg, string argb,
-                                      int argc)
-                       {
-                       }
-        
-                 When invoking functions, the rule is different, the
-                 arguments are not aligned with the previous
-                 argument, instead they begin at the tabbed position,
-                 like this:
-         
-                       void M ()
-                       {
-                               MethodCall ("Very long string that will force",
-                                       "Next argument on the 8-tab pos",
-                                       "Just like this one")
-               
-                       }
-               
-       Here are a couple of examples:
-
-class X : Y {
-
-       bool Method (int argument_1, int argument_2)
-       {
-               if (argument_1 == argument_2)
-                       throw new Exception (Locale.GetText ("They are equal!");
-
-               if (argument_1 < argument_2) {
-                       if (argument_1 * 3 > 4)
-                               return true;
-                       else
-                               return false;
-               }
-
-               //
-               // This sample helps keep your sanity while using 8-spaces for tabs
-               // 
-               VeryLongIdentifierWhichTakesManyArguments (
-                       Argument1, Argument2, Argument3,
-                       NestedCallHere (
-                               MoreNested));
-       }
-
-       bool MyProperty {
-               get {
-                       return x;
-               }
-
-               set {
-                       x = value;
-               }
-       }
-
-       void AnotherMethod () 
-       {
-               if ((a + 5) != 4) {
-               }
-
-               while (blah) {
-                       if (a)
-                               continue;
-                       b++;
-               }
-       }
-}
-       
+       conventions: http://www.mono-project.com/community/contributing/coding-guidelines/
index 1e704b38be4e06651a3031edc44667554e391f5f..19d734e166c75d5b4a14b3d347e205a5b5dac8d9 100644 (file)
@@ -10,6 +10,8 @@ LIB_MCS_FLAGS = /unsafe \
        -resource:Assembly/Error.ico,Error.ico -resource:Assembly/Warning.ico,Warning.ico \
        -resource:Assembly/Question.ico,Question.ico -resource:Assembly/Shield.ico,Shield.ico
 
+RESX_RESOURCE_STRING = ../../../external/corefx/src/System.Drawing.Common/src/Resources/Strings.resx
+
 ifeq (winaot, $(PROFILE))
 LIB_MCS_FLAGS += /keyfile:../msfinal.pub
 else ifeq (orbis, $(PROFILE))
index 6ca551e32246bd5a85e3ffa1a3df2315a23bb669..a28c0f3c3f75e37a6a1453ab0f1d0590c2d73209 100644 (file)
   </PropertyGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <ItemGroup>\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\AssemblyRef.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\misc\ClientUtils.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\misc\HandleCollector.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\BitmapSuffixInSameAssemblyAttribute.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\BitmapSuffixInSatelliteAssemblyAttribute.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Brush.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\DashCap.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\CategoryNameCollection.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\IPropertyValueUIService.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\IToolboxItemProvider.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\IToolboxService.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\IToolboxUser.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\PaintValueEventArgs.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\PropertyValueUIHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\PropertyValueUIItem.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\PropertyValueUIItemInvokeHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\ToolboxComponentsCreatedEventArgs.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\ToolboxComponentsCreatedEventHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\ToolboxComponentsCreatingEventArgs.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\ToolboxComponentsCreatingEventHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\ToolboxItemCollection.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\ToolboxItemCreatorCallback.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\UITypeEditor.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Design\UITypeEditorEditStyle.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\AdjustableArrowCap.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\Blend.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\BrushType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\ColorBlend.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\CombineMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\CompositingMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\CompositingQuality.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\CoordinateSpace.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\CustomLineCap.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\CustomLineCapType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\DashStyle.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\FillMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\FlushIntention.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\GraphicsPathIterator.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\GraphicsState.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\HatchBrush.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\HatchStyle.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\InterpolationMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\LinearGradientMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\LineCap.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\LineJoin.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\MatrixOrder.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\PathData.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\PathPointType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\PenAlignment.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\PenType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\PixelOffsetMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\QualityMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\RegionData.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\SafeCustomLineCapHandle.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\SmoothingMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\WarpMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Drawing2D\WrapMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\FontStyle.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Gdiplus.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\IDeviceContext.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorAdjustType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorChannelFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorMap.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorMapType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorMatrix.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorMatrixFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ColorPalette.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EmfPlusFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EmfPlusRecordType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EmfType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\Encoder.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EncoderParameter.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EncoderParameters.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EncoderParameterValueType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\EncoderValue.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\FrameDimension.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ImageAttributes.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ImageCodecFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ImageCodecInfo.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ImageCodecInfoPrivate.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ImageFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\ImageLockMode.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\MetafileFrameUnit.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\MetafileHeaderEmf.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\MetafileHeaderWmf.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\MetafileType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\PaletteFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\PixelFormat.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\PlayRecordCallback.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\PropertyItem.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Imaging\WmfPlaceableFileHeader.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Internal\GPPOINT.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Internal\GPPOINTF.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Internal\GPRECT.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Internal\GPRECTF.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Internal\ISystemEventTracker.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\NativeMethods.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\Duplex.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\InvalidPrinterException.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\Margins.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PaperKinds.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PaperSize.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PaperSource.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PaperSourceKind.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PreviewPageInfo.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintAction.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterResolution.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterResolutionKind.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterUnit.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrinterUnitConvert.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintEventHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintingPermission.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintingPermissionAttribute.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintingPermissionLevel.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintPageEventHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\PrintRange.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\QueryPageSettingsEventArgs.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Printing\QueryPageSettingsEventHandler.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\PropertyItemInternal.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\RotateFlipType.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\SolidBrush.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\StringAlignment.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\StringDigitSubstitute.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\StringFormatFlags.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\StringTrimming.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\StringUnit.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\SystemBrushes.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Text\FontCollection.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Text\GenericFontFamilies.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Text\HotkeyPrefix.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Text\InstalledFontCollection.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\Text\TextRenderingHint.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\TextureBrush.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Drawing.Common\src\System\Drawing\UnsafeNativeMethods.cs" />\r
     <Compile Include="..\..\build\common\Consts.cs" />\r
     <Compile Include="..\..\build\common\Locale.cs" />\r
     <Compile Include="..\..\build\common\MonoTODOAttribute.cs" />\r
     <Compile Include="Assembly\AssemblyInfo.cs" />\r
-    <Compile Include="System.Drawing.Design\CategoryNameCollection.cs" />\r
-    <Compile Include="System.Drawing.Design\IPropertyValueUIService.cs" />\r
-    <Compile Include="System.Drawing.Design\IToolboxItemProvider.cs" />\r
-    <Compile Include="System.Drawing.Design\IToolboxService.cs" />\r
-    <Compile Include="System.Drawing.Design\IToolboxUser.cs" />\r
-    <Compile Include="System.Drawing.Design\PaintValueEventArgs.cs" />\r
-    <Compile Include="System.Drawing.Design\PropertyValueItem.cs" />\r
-    <Compile Include="System.Drawing.Design\PropertyValueUIHandler.cs" />\r
-    <Compile Include="System.Drawing.Design\PropertyValueUIItemInvokeHandler.cs" />\r
-    <Compile Include="System.Drawing.Design\ToolboxComponentsCreatedEventArgs.cs" />\r
-    <Compile Include="System.Drawing.Design\ToolboxComponentsCreatedEventHandler.cs" />\r
-    <Compile Include="System.Drawing.Design\ToolboxComponentsCreatingEventArgs.cs" />\r
-    <Compile Include="System.Drawing.Design\ToolboxComponentsCreatingEventHandler.cs" />\r
+    <Compile Include="corefx\SR.cs" />\r
     <Compile Include="System.Drawing.Design\ToolboxItem.cs" />\r
-    <Compile Include="System.Drawing.Design\ToolboxItemCollection.cs" />\r
-    <Compile Include="System.Drawing.Design\ToolboxItemCreatorCallback.cs" />\r
-    <Compile Include="System.Drawing.Design\UITypeEditor.cs" />\r
-    <Compile Include="System.Drawing.Design\UITypeEditorEditStyle.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\AdjustableArrowCap.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\Blend.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\ColorBlend.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\CombineMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\CompostingMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\CompostingQuality.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\CoordinateSpace.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\CustomLineCap.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\DashCap.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\DashStyle.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\FillMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\FlushIntention.cs" />\r
     <Compile Include="System.Drawing.Drawing2D\GraphicsContainer.cs" />\r
     <Compile Include="System.Drawing.Drawing2D\GraphicsPath.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\GraphicsPathIterator.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\GraphicsState.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\HatchBrush.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\HatchStyle.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\InterpolationMode.cs" />\r
     <Compile Include="System.Drawing.Drawing2D\LinearGradientBrush.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\LinearGradientMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\LineCap.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\LineJoin.cs" />\r
     <Compile Include="System.Drawing.Drawing2D\Matrix.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\MatrixOrder.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\PathData.cs" />\r
     <Compile Include="System.Drawing.Drawing2D\PathGradientBrush.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\PathPointType.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\PenAlignment.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\PenType.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\PixelOffsetMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\QualityMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\RegionData.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\SmoothingMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\WarpMode.cs" />\r
-    <Compile Include="System.Drawing.Drawing2D\WrapMode.cs" />\r
     <Compile Include="System.Drawing.Imaging\BitmapData.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorAdjustType.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorChannelFlag.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorMap.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorMapType.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorMatrix.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorMatrixFlag.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorMode.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ColorPalette.cs" />\r
-    <Compile Include="System.Drawing.Imaging\EmfPlusRecordType.cs" />\r
-    <Compile Include="System.Drawing.Imaging\EmfType.cs" />\r
-    <Compile Include="System.Drawing.Imaging\Encoder.cs" />\r
-    <Compile Include="System.Drawing.Imaging\EncoderParameter.cs" />\r
-    <Compile Include="System.Drawing.Imaging\EncoderParameters.cs" />\r
-    <Compile Include="System.Drawing.Imaging\EncoderParameterValueType.cs" />\r
-    <Compile Include="System.Drawing.Imaging\EncoderValue.cs" />\r
-    <Compile Include="System.Drawing.Imaging\FrameDimension.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ImageAttributes.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ImageCodecFlags.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ImageCodecInfo.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ImageFlags.cs" />\r
     <Compile Include="System.Drawing.Imaging\ImageFormat.cs" />\r
-    <Compile Include="System.Drawing.Imaging\ImageLockMode.cs" />\r
     <Compile Include="System.Drawing.Imaging\Metafile.cs" />\r
-    <Compile Include="System.Drawing.Imaging\MetafileFrameUnit.cs" />\r
     <Compile Include="System.Drawing.Imaging\MetafileHeader.cs" />\r
-    <Compile Include="System.Drawing.Imaging\MetafileType.cs" />\r
     <Compile Include="System.Drawing.Imaging\MetaHeader.cs" />\r
-    <Compile Include="System.Drawing.Imaging\PaletteFlags.cs" />\r
-    <Compile Include="System.Drawing.Imaging\PixelFormat.cs" />\r
-    <Compile Include="System.Drawing.Imaging\PlayRecordCallback.cs" />\r
-    <Compile Include="System.Drawing.Imaging\PropertyItem.cs" />\r
-    <Compile Include="System.Drawing.Imaging\WmfPlaceableFileHeader.cs" />\r
-    <Compile Include="System.Drawing.Printing\Duplex.cs" />\r
-    <Compile Include="System.Drawing.Printing\InvalidPrinterException.cs" />\r
-    <Compile Include="System.Drawing.Printing\Margins.cs" />\r
     <Compile Include="System.Drawing.Printing\MarginsConverter.cs" />\r
     <Compile Include="System.Drawing.Printing\PageSettings.cs" />\r
-    <Compile Include="System.Drawing.Printing\PaperKind.cs" />\r
-    <Compile Include="System.Drawing.Printing\PaperSize.cs" />\r
-    <Compile Include="System.Drawing.Printing\PaperSource.cs" />\r
-    <Compile Include="System.Drawing.Printing\PaperSourceKind.cs" />\r
-    <Compile Include="System.Drawing.Printing\PreviewPageInfo.cs" />\r
     <Compile Include="System.Drawing.Printing\PreviewPrintController.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintAction.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintController.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintDocument.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrinterResolution.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrinterResolutionKind.cs" />\r
     <Compile Include="System.Drawing.Printing\PrinterSettings.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrinterUnit.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrinterUnitConvert.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintEventArgs.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintEventHandler.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintingPermission.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintingPermissionAttribute.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintingPermissionLevel.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintingServices.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintingServicesUnix.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintingServicesWin32.cs" />\r
     <Compile Include="System.Drawing.Printing\PrintPageEventArgs.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintPageEventHandler.cs" />\r
-    <Compile Include="System.Drawing.Printing\PrintRange.cs" />\r
-    <Compile Include="System.Drawing.Printing\QueryPageSettingsEventArgs.cs" />\r
-    <Compile Include="System.Drawing.Printing\QueryPageSettingsEventHandler.cs" />\r
     <Compile Include="System.Drawing.Printing\StandardPrintController.cs" />\r
-    <Compile Include="System.Drawing.Text\FontCollection.cs" />\r
-    <Compile Include="System.Drawing.Text\GenericFontFamilies.cs" />\r
-    <Compile Include="System.Drawing.Text\HotkeyPrefix.cs" />\r
-    <Compile Include="System.Drawing.Text\InstalledFontCollection.cs" />\r
     <Compile Include="System.Drawing.Text\PrivateFontCollection.cs" />\r
-    <Compile Include="System.Drawing.Text\TextRenderingHint.cs" />\r
     <Compile Include="System.Drawing\Bitmap.cs" />\r
-    <Compile Include="System.Drawing\BitmapSuffixInSameAssemblyAttribute.cs" />\r
-    <Compile Include="System.Drawing\BitmapSuffixInSatelliteAssemblyAttribute.cs" />\r
-    <Compile Include="System.Drawing\Brush.cs" />\r
     <Compile Include="System.Drawing\Brushes.cs" />\r
     <Compile Include="System.Drawing\BufferedGraphics.cs" />\r
     <Compile Include="System.Drawing\BufferedGraphicsContext.cs" />\r
     <Compile Include="System.Drawing\ComIStreamWrapper.cs" />\r
     <Compile Include="System.Drawing\ContentAlignment.cs" />\r
     <Compile Include="System.Drawing\CopyPixelOperation.cs" />\r
+    <Compile Include="System.Drawing\ExternDll.cs" />\r
     <Compile Include="System.Drawing\Font.cs" />\r
     <Compile Include="System.Drawing\FontConverter.cs" />\r
     <Compile Include="System.Drawing\FontFamily.cs" />\r
-    <Compile Include="System.Drawing\FontStyle.cs" />\r
     <Compile Include="System.Drawing\gdipEnums.cs" />\r
     <Compile Include="System.Drawing\gdipFunctions.cs" />\r
     <Compile Include="System.Drawing\gdipStructs.cs" />\r
     <Compile Include="System.Drawing\GraphicsUnit.cs" />\r
     <Compile Include="System.Drawing\Icon.cs" />\r
     <Compile Include="System.Drawing\IconConverter.cs" />\r
-    <Compile Include="System.Drawing\IDeviceContext.cs" />\r
     <Compile Include="System.Drawing\Image.cs" />\r
     <Compile Include="System.Drawing\ImageAnimator.cs" />\r
     <Compile Include="System.Drawing\ImageConverter.cs" />\r
     <Compile Include="System.Drawing\RectangleConverter.cs" />\r
     <Compile Include="System.Drawing\RectangleF.cs" />\r
     <Compile Include="System.Drawing\Region.cs" />\r
-    <Compile Include="System.Drawing\RotateFlipType.cs" />\r
     <Compile Include="System.Drawing\Size.cs" />\r
     <Compile Include="System.Drawing\SizeConverter.cs" />\r
     <Compile Include="System.Drawing\SizeF.cs" />\r
     <Compile Include="System.Drawing\SizeFConverter.cs" />\r
-    <Compile Include="System.Drawing\SolidBrush.cs" />\r
+    <Compile Include="System.Drawing\SR.cs" />\r
     <Compile Include="System.Drawing\SRDescriptionAttribute.cs" />\r
-    <Compile Include="System.Drawing\StringAligment.cs" />\r
-    <Compile Include="System.Drawing\StringDigitSubstitute.cs" />\r
     <Compile Include="System.Drawing\StringFormat.cs" />\r
-    <Compile Include="System.Drawing\StringFormatFlags.cs" />\r
-    <Compile Include="System.Drawing\StringTrimming.cs" />\r
-    <Compile Include="System.Drawing\StringUnit.cs" />\r
-    <Compile Include="System.Drawing\SystemBrushes.cs" />\r
     <Compile Include="System.Drawing\SystemColors.cs" />\r
     <Compile Include="System.Drawing\SystemFonts.cs" />\r
     <Compile Include="System.Drawing\SystemIcons.cs" />\r
     <Compile Include="System.Drawing\SystemPens.cs" />\r
-    <Compile Include="System.Drawing\TextureBrush.cs" />\r
     <Compile Include="System.Drawing\ToolboxBitmapAttribute.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
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs b/mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.cs
deleted file mode 100644 (file)
index 7a0abfa..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// System.Drawing.Design.CategoryNameCollection.cs
-//
-// Authors:
-//     Alejandro Sánchez Acosta
-//  Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) Alejandro Sánchez Acosta
-// (C) 2003 Andreas Nahr
-// 
-
-//
-// Copyright (C) 2004-2005 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;
-
-namespace System.Drawing.Design
-{
-       public sealed class CategoryNameCollection : ReadOnlyCollectionBase
-       {
-               
-               public CategoryNameCollection (CategoryNameCollection value)
-               {
-                       if (value == null)
-                               throw new ArgumentNullException ("value");
-                       InnerList.AddRange (value);
-               }
-
-               public CategoryNameCollection (string[] value)
-               {
-                       if (value == null)
-                               throw new ArgumentNullException ("value");
-                       InnerList.AddRange (value);
-               }
-
-               public string this[int index] {
-                       get {
-                               return (string) InnerList[index];
-                       }
-               }
-
-               public bool Contains (string value)
-               {
-                       return InnerList.Contains (value);
-               }
-               
-               public void CopyTo (string[] array, int index)
-               {
-                       InnerList.CopyTo (array, index);
-               }
-               
-               public int IndexOf (string value)
-               {
-                       return InnerList.IndexOf (value);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs b/mcs/class/System.Drawing/System.Drawing.Design/IPropertyValueUIService.cs
deleted file mode 100644 (file)
index dc3ba64..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// System.Drawing.Design.IPropertyValueUIService.cs
-//
-// Author:
-//     Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-//     
-// (C) Alejandro Sánchez Acosta
-// 
-
-//
-// 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.Drawing;
-using System.ComponentModel;
-
-namespace System.Drawing.Design
-{
-       public interface IPropertyValueUIService
-       {
-               
-               #region Methods         
-               void AddPropertyValueUIHandler (PropertyValueUIHandler newHandler);
-               PropertyValueUIItem[] GetPropertyUIValueItems (ITypeDescriptorContext context, PropertyDescriptor propDesc);
-
-               void NotifyPropertyValueUIItemsChanged ();
-
-               void RemovePropertyValueUIHandler (PropertyValueUIHandler newHandler);
-               #endregion Methods
-
-               #region Events
-               event EventHandler PropertyUIValueItemsChanged;
-               #endregion Events
-       }
-}
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxItemProvider.cs
deleted file mode 100644 (file)
index c057880..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright (C) 2005 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.
-//
-// Authors:
-//
-//   Jordi Mas i Hernandez <jordimash@gmail.com>
-//
-//
-
-
-namespace System.Drawing.Design
-{
-       public interface IToolboxItemProvider
-       {
-               ToolboxItemCollection Items { get; }
-       }
-}
-
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs
deleted file mode 100644 (file)
index 532119a..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-//
-// System.Drawing.Design.IToolboxService.cs
-//
-// Authors:
-//     Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-//  Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) Alejandro Sánchez Acosta
-// (C) 2003 Andreas Nahr
-// Copyright (C) 2004, 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,
-// 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;
-using System.ComponentModel.Design;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Design {
-
-       [ComImport]
-       [Guid("4BACD258-DE64-4048-BC4E-FEDBEF9ACB76"),
-       InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
-       public interface IToolboxService
-       {
-               CategoryNameCollection CategoryNames {get;}
-
-               string SelectedCategory {get; set;}
-
-               void AddCreator (ToolboxItemCreatorCallback creator, string format);
-
-               void AddCreator (ToolboxItemCreatorCallback creator, string format, IDesignerHost host);
-
-               void AddLinkedToolboxItem (ToolboxItem toolboxItem, IDesignerHost host);
-
-               void AddLinkedToolboxItem (ToolboxItem toolboxItem, string category, IDesignerHost host);
-
-               void AddToolboxItem (ToolboxItem toolboxItem, String category);
-
-               void AddToolboxItem (ToolboxItem toolboxItem);
-
-               ToolboxItem DeserializeToolboxItem (object serializedObject);
-
-               ToolboxItem DeserializeToolboxItem (object serializedObject, IDesignerHost host);
-
-               ToolboxItem GetSelectedToolboxItem ();
-
-               ToolboxItem GetSelectedToolboxItem (IDesignerHost host);
-
-               ToolboxItemCollection GetToolboxItems ();
-
-               ToolboxItemCollection GetToolboxItems (IDesignerHost host);
-
-               ToolboxItemCollection GetToolboxItems (String category);
-
-               ToolboxItemCollection GetToolboxItems (String category, IDesignerHost host);
-
-               bool IsSupported (object serializedObject, ICollection filterAttributes);
-
-               bool IsSupported (object serializedObject, IDesignerHost host);
-
-               bool IsToolboxItem (object serializedObject);
-
-               bool IsToolboxItem (object serializedObject, IDesignerHost host);
-
-               void Refresh();
-
-               void RemoveCreator (string format);
-
-               void RemoveCreator (string format, IDesignerHost host);
-
-               void RemoveToolboxItem (ToolboxItem toolboxItem);
-
-               void RemoveToolboxItem (ToolboxItem toolboxItem, string category);
-
-               void SelectedToolboxItemUsed ();
-
-               object SerializeToolboxItem (ToolboxItem toolboxItem);
-
-               bool SetCursor ();
-
-               void SetSelectedToolboxItem (ToolboxItem toolboxItem);
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs b/mcs/class/System.Drawing/System.Drawing.Design/IToolboxUser.cs
deleted file mode 100644 (file)
index 20362f8..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// System.Drawing.Design.IToolboxUser.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// 
-
-//
-// 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.
-//
-
-namespace System.Drawing.Design
-{
-       public interface IToolboxUser
-       {
-               bool GetToolSupported (ToolboxItem tool);
-
-               void ToolPicked (ToolboxItem tool);
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Design/PaintValueEventArgs.cs
deleted file mode 100644 (file)
index 837f39b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-// System.Drawing.Design.PaintvalueEventArgs.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// 
-
-//
-// Copyright (C) 2004-2005 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.ComponentModel;
-
-namespace System.Drawing.Design
-{
-       public class PaintValueEventArgs : EventArgs
-       {
-               private ITypeDescriptorContext context;
-               private object value;
-               private Graphics graphics;
-               private Rectangle bounds;
-               
-               public PaintValueEventArgs(ITypeDescriptorContext context, object value, Graphics graphics, Rectangle bounds) 
-               {
-                       if (graphics == null)
-                               throw new ArgumentNullException ("graphics");
-                       this.context = context;
-                       this.value = value;
-                       this.graphics = graphics;
-                       this.bounds = bounds;
-               }
-
-               public Rectangle Bounds 
-               {
-                       get {
-                               return bounds;
-                       }
-               }
-
-               public ITypeDescriptorContext Context 
-               {
-                       get {
-                               return context;
-                       }
-               }
-
-               public Graphics Graphics 
-               {
-                       get {
-                               return graphics;
-                       }                               
-               }
-
-               public object Value 
-               {
-                       get {
-                               return value;
-                       }
-               }
-       }
-}
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs
deleted file mode 100644 (file)
index 422728a..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// System.Drawing.Design.PropertyValueItem.cs
-// 
-// Authors:
-//  Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-//  Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-// 
-// (C) Alejandro Sánchez Acosta
-// (C) 2003 Andreas Nahr
-// 
-
-//
-// Copyright (C) 2004-2005 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.
-//
-
-namespace System.Drawing.Design
-{
-       public class PropertyValueUIItem
-       {
-
-               private Image uiItemImage;
-               private PropertyValueUIItemInvokeHandler handler;
-               private string tooltip;
-
-               public PropertyValueUIItem (Image uiItemImage,
-                       PropertyValueUIItemInvokeHandler handler, string tooltip)
-               {
-                       if (uiItemImage == null)
-                               throw new ArgumentNullException ("uiItemImage");
-                       if (handler == null)
-                               throw new ArgumentNullException ("handler");
-                       this.uiItemImage = uiItemImage;
-                       this.handler = handler;
-                       this.tooltip = tooltip;
-               }
-
-               public virtual Image Image 
-               {
-                       get
-                       {
-                               return uiItemImage;
-                       }
-               }
-
-               public virtual PropertyValueUIItemInvokeHandler InvokeHandler
-               {
-                       get
-                       {
-                               return handler;
-                       }
-               }
-
-               public virtual string ToolTip 
-               {
-                       get
-                       {
-                               return tooltip;
-                       }
-               }
-
-               public virtual void Reset()
-               {
-                       // To be overriden in child classes
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIHandler.cs
deleted file mode 100644 (file)
index 28fba43..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// System.Drawing.Design.PropertyValueUIHandler.cs
-//
-// Author:
-//     Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-//
-// (C) Alejandro Sánchez Acosta
-// Copyright (C) 2004,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,
-// 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;
-using System.ComponentModel;
-
-namespace System.Drawing.Design {
-
-       public delegate void PropertyValueUIHandler (ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList);
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs
deleted file mode 100644 (file)
index ff0293b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// System.Drawing.Design.PropertyValueUIItemInvokeHandler.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// Copyright (C) 2004,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,
-// 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.ComponentModel;
-
-namespace System.Drawing.Design {
-
-       public delegate void PropertyValueUIItemInvokeHandler (
-                                  ITypeDescriptorContext context,
-                                  PropertyDescriptor descriptor,
-                                  PropertyValueUIItem invokedItem);
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs
deleted file mode 100644 (file)
index f7969b9..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// System.Drawing.Design.ToolboxComponentsCreatedEventArgs.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// 
-//
-
-//
-// Copyright (C) 2004-2005 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.ComponentModel;
-
-namespace System.Drawing.Design
-{
-       public class ToolboxComponentsCreatedEventArgs : EventArgs
-       {
-               private IComponent[] components;
-               
-               public ToolboxComponentsCreatedEventArgs (IComponent[] components) {
-                       this.components = components;
-               }
-
-               public IComponent[] Components {
-                       get {
-                               return components;
-                       }
-               }       
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs
deleted file mode 100644 (file)
index 52a35ad..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// System.Drawing.Design.IDesignerHost.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Design {
-
-       public delegate void ToolboxComponentsCreatedEventHandler (object sender, ToolboxComponentsCreatedEventArgs e);
-}
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs
deleted file mode 100644 (file)
index fde3cb3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// System.Drawing.Design.ToolboxComponentsCreatingEventArgs.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// 
-
-//
-// Copyright (C) 2004-2005 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.ComponentModel.Design;
-using System.Security.Permissions;
-
-namespace System.Drawing.Design
-{
-       [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
-       [PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
-       public class ToolboxComponentsCreatingEventArgs : EventArgs
-       {
-               private IDesignerHost host;
-               
-               public ToolboxComponentsCreatingEventArgs (IDesignerHost host)
-               {
-                       this.host = host;
-               }
-
-               public IDesignerHost DesignerHost {
-                       get {
-                               return host;                            
-                       }
-               }
-       }       
-}
-
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs
deleted file mode 100644 (file)
index 7cab3df..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// System.Drawing.Design.ToolboxComponentsCreatingEventHandler.cs
-// 
-// Author:
-//     Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Design {
-
-       public delegate void ToolboxComponentsCreatingEventHandler (object sender, ToolboxComponentsCreatingEventArgs e);
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.cs
deleted file mode 100644 (file)
index dc76d7a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// System.Drawing.Design.ToolboxItemCollection.cs
-//
-// Authors:
-//  Martin Willemoes Hansen (mwh@sysrq.dk)
-//  Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) 2003 Martin Willemoes Hansen
-// (C) 2003 Andreas Nahr
-//
-
-//
-// Copyright (C) 2004-2005 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;
-using System.Security.Permissions;
-
-namespace System.Drawing.Design
-{
-       [PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
-       public sealed class ToolboxItemCollection : ReadOnlyCollectionBase
-       {
-
-               public ToolboxItemCollection (ToolboxItem[] value) : base()
-               {
-                       InnerList.AddRange (value);
-               }
-
-               public ToolboxItemCollection (ToolboxItemCollection value) : base()
-               {
-                       InnerList.AddRange (value);
-               }
-
-               public ToolboxItem this [int index] {
-                       get { return (ToolboxItem) InnerList[index]; }
-               }
-
-               public bool Contains (ToolboxItem value)
-               {
-                       return InnerList.Contains (value);
-               }
-
-               public void CopyTo (ToolboxItem[] array, int index)
-               {
-                       InnerList.CopyTo (array, index);
-               }
-
-               public int IndexOf (ToolboxItem value)
-               {
-                       return InnerList.IndexOf (value);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs b/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCreatorCallback.cs
deleted file mode 100644 (file)
index 4df4cd6..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// System.Drawing.Design.ToolboxItemCreatorCallback.cs
-// 
-// Author:
-//      Alejandro Sánchez Acosta  <raciel@es.gnu.org>
-// 
-// (C) Alejandro Sánchez Acosta
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Design {
-
-       public delegate ToolboxItem ToolboxItemCreatorCallback(
-                                  object serializedObject,
-                                  string format);
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs b/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs
deleted file mode 100644 (file)
index 31f736a..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// System.Drawing.Design.UITypeEditor.cs
-// 
-// Authors:
-//  Alan Tam Siu Lung <Tam@SiuLung.com>
-//  Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-// 
-// (C) 2003 Alan Tam Siu Lung <Tam@SiuLung.com>
-// (C) 2003 Andreas Nahr
-// Copyright (C) 2004-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,
-// 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.ComponentModel;
-using System.Collections;
-
-namespace System.Drawing.Design
-{
-       public class UITypeEditor {
-
-               static UITypeEditor ()
-               {
-                       Hashtable editors = new Hashtable ();
-                       editors [typeof (Array)] = "System.ComponentModel.Design.ArrayEditor, " + Consts.AssemblySystem_Design;
-                       editors [typeof (byte [])] = "System.ComponentModel.Design.BinaryEditor, " + Consts.AssemblySystem_Design;
-                       editors [typeof (DateTime)] = "System.ComponentModel.Design.DateTimeEditor, " + Consts.AssemblySystem_Design;
-                       editors [typeof (IList)] = "System.ComponentModel.Design.CollectionEditor, " + Consts.AssemblySystem_Design;
-                       editors [typeof (ICollection)] = "System.ComponentModel.Design.CollectionEditor, " + Consts.AssemblySystem_Design;
-                       editors [typeof (string[])] = "System.Windows.Forms.Design.StringArrayEditor, " + Consts.AssemblySystem_Design;
-#if !MOBILE
-                       TypeDescriptor.AddEditorTable (typeof (UITypeEditor), editors);
-#endif
-               }
-               
-               public UITypeEditor()
-               {
-               }
-
-               public virtual object EditValue (ITypeDescriptorContext context,
-                       IServiceProvider provider, object value)
-               {
-                       // We already stated that we can't edit ;)
-                       return value;
-               }
-
-               public object EditValue (IServiceProvider provider, object value)
-               {
-                       return EditValue (null, provider, value);
-               }
-
-               public virtual UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
-               {
-                       return UITypeEditorEditStyle.None;
-               }
-
-               public UITypeEditorEditStyle GetEditStyle ()
-               {
-                       return GetEditStyle (null);
-               }
-
-               public bool GetPaintValueSupported ()
-               {
-                       return GetPaintValueSupported (null);
-               }
-
-               public virtual bool GetPaintValueSupported (ITypeDescriptorContext context)
-               {
-                       return false;
-               }
-               public void PaintValue (object value, Graphics canvas, Rectangle rectangle)
-               {
-                       PaintValue (new PaintValueEventArgs (null, value, canvas, rectangle));
-               }
-
-               public virtual void PaintValue (PaintValueEventArgs e)
-               {
-                       // LAMESPEC: Did not find info in the docs if this should do something here.
-                       // Usually you would expect, that this class gets inherited and this overridden, 
-                       // but on the other hand the class is not abstract. Could never observe it did paint anything
-                       return;
-               }
-               public virtual bool IsDropDownResizable {
-                       get { return false; }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs b/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.cs
deleted file mode 100644 (file)
index 97c4807..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// System.Drawing.Design.UITypeEditorEditStyle.cs
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Author: Dennis Hayes (dennish@raytek.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;
-namespace System.Drawing.Design
-{
-       public enum  UITypeEditorEditStyle{
-                       DropDown=3,
-                       Modal=2,
-                       None=1
-       }
-}
\ No newline at end of file
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/AdjustableArrowCap.cs
deleted file mode 100644 (file)
index 497b578..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-//
-// System.Drawing.Drawing2D.AdjustableArrowCap.cs
-//
-// Authors:
-//     Dennis Hayes (dennish@Raytek.com)
-//     Ravindra (rkumar@novell.com)
-//
-// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc. http://www.novell.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;
-
-namespace System.Drawing.Drawing2D
-{
-       /// <summary>
-       /// Summary description for AdjustableArrowCap.
-       /// </summary>
-       public sealed class AdjustableArrowCap : CustomLineCap
-       {
-               // Constructors
-
-               internal AdjustableArrowCap (IntPtr ptr) : base (ptr)
-               {
-               }
-
-               public AdjustableArrowCap (float width, float height) : this (width, height, true)
-               {
-               }
-
-               public AdjustableArrowCap (float width, float height, bool isFilled)
-               {
-                       Status status = GDIPlus.GdipCreateAdjustableArrowCap (height, width, isFilled, out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               // Public Properities
-
-               public bool Filled {
-                       get {
-                               bool isFilled;
-                               Status status = GDIPlus.GdipGetAdjustableArrowCapFillState (nativeObject, out isFilled);
-                               GDIPlus.CheckStatus (status);
-
-                               return isFilled;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetAdjustableArrowCapFillState (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public float Width {
-                       get {
-                               float width;
-                               Status status = GDIPlus.GdipGetAdjustableArrowCapWidth (nativeObject, out width);
-                               GDIPlus.CheckStatus (status);
-
-                               return width;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetAdjustableArrowCapWidth (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public float Height {
-                       get {
-                               float height;
-                               Status status = GDIPlus.GdipGetAdjustableArrowCapHeight (nativeObject, out height);
-                               GDIPlus.CheckStatus (status);
-
-                               return height;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetAdjustableArrowCapHeight (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public float MiddleInset {
-                       get {
-                               float middleInset;
-                               Status status = GDIPlus.GdipGetAdjustableArrowCapMiddleInset (nativeObject, out middleInset);
-                               GDIPlus.CheckStatus (status);
-
-                               return middleInset;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetAdjustableArrowCapMiddleInset (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs
deleted file mode 100644 (file)
index 7629ddc..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// System.Drawing.Drawing2D.Blend.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) 2002/3 Ximian, Inc. http://www.ximian.com
-// (C) 2004 Novell, Inc. http://www.novell.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;
-
-namespace System.Drawing.Drawing2D
-{
-       /// <summary>
-       /// Summary description for Blend.
-       /// </summary>
-       public sealed class Blend
-       {
-               private float [] positions;
-               private float [] factors;
-
-               public Blend ()
-               {
-                       positions = new float [1];
-                       factors = new float [1];
-               }
-
-               public Blend (int count)
-               {
-                       positions = new float [count];
-                       factors = new float [count];
-               }
-
-               public float [] Factors {
-                       get {
-                               return factors;
-                       }
-
-                       set {
-                               factors = value;
-                       }
-               }
-
-               public float [] Positions {
-                       get {
-                               return positions;
-                       }
-
-                       set {
-                               positions = value;
-                       }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ColorBlend.cs
deleted file mode 100644 (file)
index a34d99e..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// System.Drawing.Drawing2D.ColorBlend.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) 2002/3 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004, 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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D
-{
-       public sealed class ColorBlend
-       {
-               private float [] positions;
-               private Color [] colors;
-
-               public ColorBlend ()
-               {
-                       positions = new float [1];
-                       colors = new Color [1];
-               }
-
-               public ColorBlend (int count)
-               {
-                       positions = new float [count];
-                       colors = new Color [count];
-               }
-
-               public Color [] Colors {
-                       get {
-                               return colors;
-                       }
-
-                       set {
-                               colors = value;
-                       }
-               }
-
-               public float [] Positions {
-                       get {
-                               return positions;
-                       }
-
-                       set {
-                               positions = value;                              
-                       }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CombineMode.cs
deleted file mode 100644 (file)
index f5c358e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Drawing2D.CombineMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum CombineMode {
-               Complement = 5,
-               Exclude = 4,
-               Intersect = 1,
-               Replace = 0,
-               Union = 2,
-               Xor = 3
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingMode.cs
deleted file mode 100644 (file)
index 48c42a4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.Drawing2D.CompostingMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum CompositingMode {
-               SourceCopy = 1,
-               SourceOver = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CompostingQuality.cs
deleted file mode 100644 (file)
index a1dfe67..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Drawing2D.CompostingQuality.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum CompositingQuality {
-               AssumeLinear = 4,
-               Default = 0,
-               GammaCorrected = 3,
-               HighQuality = 2,
-               HighSpeed = 1,
-               Invalid = -1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CoordinateSpace.cs
deleted file mode 100644 (file)
index e7a964f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// System.Drawing.Drawing2D.CoordinateSpace.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum CoordinateSpace {
-               Device = 2,
-               Page = 1,
-               World = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/CustomLineCap.cs
deleted file mode 100644 (file)
index 4f98318..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-//
-// System.Drawing.Drawing2D.CustomLineCap.cs
-//
-// Authors:
-//     Dennis Hayes (dennish@Raytek.com)
-//     Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//     Ravindra (rkumar@novell.com)
-//
-// Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
-       {
-               private bool disposed;
-               internal IntPtr nativeObject;
-
-               // Constructors
-
-               internal CustomLineCap ()
-               {
-               }
-
-               internal CustomLineCap (IntPtr ptr)
-               {
-                       nativeObject = ptr;
-               }
-
-               public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath) : this (fillPath, strokePath, LineCap.Flat, 0)
-               {
-               }
-
-               public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap) : this (fillPath, strokePath, baseCap, 0)
-               {
-               }
-
-               public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
-               {
-                       IntPtr fill = IntPtr.Zero;
-                       IntPtr stroke = IntPtr.Zero;
-
-                       if (fillPath != null)
-                               fill = fillPath.nativePath;
-                       if (strokePath != null)
-                               stroke = strokePath.nativePath;
-
-                       Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public LineCap BaseCap {
-                       get {
-                               LineCap baseCap;
-                               Status status = GDIPlus.GdipGetCustomLineCapBaseCap (nativeObject, out baseCap);
-                               GDIPlus.CheckStatus (status);
-
-                               return baseCap;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetCustomLineCapBaseCap (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public LineJoin StrokeJoin {
-                       get {
-                               LineJoin strokeJoin;
-                               Status status = GDIPlus.GdipGetCustomLineCapStrokeJoin (nativeObject, out strokeJoin);
-                               GDIPlus.CheckStatus (status);
-
-                               return strokeJoin;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetCustomLineCapStrokeJoin (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public float BaseInset {
-                       get {
-                               float baseInset;
-                               Status status = GDIPlus.GdipGetCustomLineCapBaseInset (nativeObject, out baseInset);
-                               GDIPlus.CheckStatus (status);
-
-                               return baseInset;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetCustomLineCapBaseInset (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public float WidthScale {
-                       get {
-                               float widthScale;
-                               Status status = GDIPlus.GdipGetCustomLineCapWidthScale (nativeObject, out widthScale);
-                               GDIPlus.CheckStatus (status);
-
-                               return widthScale;
-                       }
-
-                       set {
-                               Status status = GDIPlus.GdipSetCustomLineCapWidthScale (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               // Public Methods
-
-               public object Clone ()
-               {
-                       IntPtr clonePtr;
-                       Status status = GDIPlus.GdipCloneCustomLineCap (nativeObject, out clonePtr);
-                       GDIPlus.CheckStatus (status);
-
-                       return new CustomLineCap (clonePtr);
-               }
-               
-               public void Dispose ()
-               {
-                       Dispose (true);
-                       System.GC.SuppressFinalize (this);
-               }
-
-               protected virtual void Dispose (bool disposing)
-               {
-                       if (! disposed) {
-                               Status status = GDIPlus.GdipDeleteCustomLineCap (nativeObject);
-                               GDIPlus.CheckStatus (status);
-                               disposed = true;
-                               nativeObject = IntPtr.Zero;
-                       }
-               }
-               
-               ~CustomLineCap ()
-               {
-                       Dispose (false);
-               }
-
-               public void GetStrokeCaps (out LineCap startCap, out LineCap endCap)
-               {
-                       Status status = GDIPlus.GdipGetCustomLineCapStrokeCaps (nativeObject, out startCap, out endCap);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void SetStrokeCaps(LineCap startCap, LineCap endCap)
-               {
-                       Status status = GDIPlus.GdipSetCustomLineCapStrokeCaps (nativeObject, startCap, endCap);
-                       GDIPlus.CheckStatus (status);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashCap.cs
deleted file mode 100644 (file)
index 356b2b7..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// System.Drawing.Drawing2D.DashCap.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum DashCap {
-               Flat,
-               Round = 2,
-               Triangle = 3
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/DashStyle.cs
deleted file mode 100644 (file)
index 726dc08..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Drawing.Drawing2D.DashStyle.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum DashStyle {
-               Custom = 5,
-               Dash = 1,
-               DashDot = 3,
-               DashDotDot = 4,
-               Dot = 2,
-               Solid = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/FillMode.cs
deleted file mode 100644 (file)
index 1744ec0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.Drawing2D.FillMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum FillMode {
-               Alternate = 0,
-               Winding = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/FlushIntention.cs
deleted file mode 100644 (file)
index e2f2c42..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.Drawing2D.FlushIntention.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum FlushIntention {
-               Flush = 0,
-               Sync = 1
-       }
-}
index dc747fdfb588a297efdc715fa96d313f22c7c209..ee539c548f02a184dc940a4561a70bbeea27ab0b 100644 (file)
@@ -630,7 +630,7 @@ namespace System.Drawing.Drawing2D
 
                        IntPtr sformat = (format == null) ? IntPtr.Zero : format.NativeObject;
                        // note: the NullReferenceException on s.Length is the expected (MS) exception
-                       Status status = GDIPlus.GdipAddPathStringI (nativePath, s, s.Length, family.NativeObject, style, emSize, ref layoutRect, sformat);
+                       Status status = GDIPlus.GdipAddPathStringI (nativePath, s, s.Length, family.NativeFamily, style, emSize, ref layoutRect, sformat);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -642,7 +642,7 @@ namespace System.Drawing.Drawing2D
 
                        IntPtr sformat = (format == null) ? IntPtr.Zero : format.NativeObject;
                        // note: the NullReferenceException on s.Length is the expected (MS) exception
-                       Status status = GDIPlus.GdipAddPathString (nativePath, s, s.Length, family.NativeObject, style, emSize, ref layoutRect, sformat);
+                       Status status = GDIPlus.GdipAddPathString (nativePath, s, s.Length, family.NativeFamily, style, emSize, ref layoutRect, sformat);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -699,7 +699,7 @@ namespace System.Drawing.Drawing2D
                 {
                         RectangleF retval;
                         IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
-                        IntPtr p = (pen == null) ? IntPtr.Zero : pen.nativeObject;
+                        IntPtr p = (pen == null) ? IntPtr.Zero : pen.NativePen;
                         
                         Status s = GDIPlus.GdipGetPathWorldBounds (nativePath, out retval, m, p);
 
@@ -746,7 +746,7 @@ namespace System.Drawing.Drawing2D
                         bool result;
                         IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
                         
-                       Status s = GDIPlus.GdipIsOutlineVisiblePathPointI (nativePath, x, y, pen.nativeObject, g, out result);
+                       Status s = GDIPlus.GdipIsOutlineVisiblePathPointI (nativePath, x, y, pen.NativePen, g, out result);
                         GDIPlus.CheckStatus (s);
 
                         return result;
@@ -760,7 +760,7 @@ namespace System.Drawing.Drawing2D
                         bool result;
                         IntPtr g = (graphics == null) ? IntPtr.Zero : graphics.nativeObject;
                         
-                       Status s = GDIPlus.GdipIsOutlineVisiblePathPoint (nativePath, x, y, pen.nativeObject, g, out result);
+                       Status s = GDIPlus.GdipIsOutlineVisiblePathPoint (nativePath, x, y, pen.NativePen, g, out result);
                         GDIPlus.CheckStatus (s);
 
                         return result;
@@ -889,7 +889,7 @@ namespace System.Drawing.Drawing2D
                                return;
                        IntPtr m = (matrix == null) ? IntPtr.Zero : matrix.nativeMatrix;
 
-                       Status s = GDIPlus.GdipWidenPath (nativePath, pen.nativeObject, m, flatness);
+                       Status s = GDIPlus.GdipWidenPath (nativePath, pen.NativePen, m, flatness);
                        GDIPlus.CheckStatus (s);
                 } 
         }
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPathIterator.cs
deleted file mode 100644 (file)
index 3de4e21..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-//
-// System.Drawing.Drawing2D.GraphicsPathIterator.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Duncan Mak (duncan@ximian.com)
-//   Ravindra (rkumar@novell.com)
-//
-// Copyright (C) 2002/3 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;
-using System.Drawing;
-
-namespace System.Drawing.Drawing2D
-{
-       public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
-       {
-               private IntPtr nativeObject = IntPtr.Zero;
-
-               // Constructors
-               internal GraphicsPathIterator (IntPtr native)
-               {
-                       this.nativeObject = native;
-               }
-
-               public GraphicsPathIterator (GraphicsPath path)
-               {
-                       if (path != null) {
-                               Status status = GDIPlus.GdipCreatePathIter (out nativeObject, path.NativeObject);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               internal IntPtr NativeObject {
-                       get {
-                               return nativeObject;
-                       }
-                       set {
-                               nativeObject = value;
-                       }
-               }
-
-               // Public Properites
-
-               public int Count {
-                       get {
-                               if (nativeObject == IntPtr.Zero)
-                                       return 0;
-                               int count;
-                               Status status = GDIPlus.GdipPathIterGetCount (nativeObject, out count);
-                               GDIPlus.CheckStatus (status);
-
-                               return count;
-                       }
-               }
-
-               public int SubpathCount {
-                       get {
-                               int count;
-                               Status status = GDIPlus.GdipPathIterGetSubpathCount (nativeObject, out count);
-                               GDIPlus.CheckStatus (status);
-
-                               return count;
-                       }
-               }
-
-               internal void Dispose (bool disposing)
-               {
-                       Status status;
-                       if (nativeObject != IntPtr.Zero) {
-                               status = GDIPlus.GdipDeletePathIter (nativeObject);
-                               GDIPlus.CheckStatus (status);
-
-                               nativeObject = IntPtr.Zero;
-                       }
-               }
-
-               // Public Methods.
-
-               public int CopyData (ref PointF [] points, ref byte [] types, int startIndex, int endIndex)
-               {
-                       Status status;
-                       int resultCount;
-
-                       // no null checks, MS throws a NullReferenceException here
-                       if (points.Length != types.Length)
-                               throw new ArgumentException ("Invalid arguments passed. Both arrays should have the same length.");
-
-                       status = GDIPlus.GdipPathIterCopyData (nativeObject, out resultCount, points, types, startIndex, endIndex);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public void Dispose ()
-               {
-                       Dispose (true);
-                       System.GC.SuppressFinalize (this);
-               }
-
-               ~GraphicsPathIterator ()
-               {
-                       Dispose (false);
-               }
-
-               public int Enumerate (ref PointF [] points, ref byte [] types)
-               {
-                       Status status;
-                       int resultCount;
-                       // no null checks, MS throws a NullReferenceException here
-                       int count = points.Length;
-                       if (count != types.Length)
-                               throw new ArgumentException ("Invalid arguments passed. Both arrays should have the same length.");
-
-                       status = GDIPlus.GdipPathIterEnumerate (nativeObject, out resultCount, points, types, count);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public bool HasCurve ()
-               {
-                       bool curve;
-                       Status status = GDIPlus.GdipPathIterHasCurve (nativeObject, out curve);
-                       GDIPlus.CheckStatus (status);
-
-                       return curve;
-               }
-
-               public int NextMarker (GraphicsPath path)
-               {
-                       int resultCount;
-                       IntPtr ptr = (path == null) ? IntPtr.Zero : path.NativeObject;
-                       Status status = GDIPlus.GdipPathIterNextMarkerPath (nativeObject, out resultCount, ptr);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public int NextMarker (out int startIndex, out int endIndex)
-               {
-                       Status status;
-                       int resultCount;
-                       status = GDIPlus.GdipPathIterNextMarker (nativeObject, out resultCount, out startIndex, out endIndex);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public int NextPathType (out byte pathType, out int startIndex, out int endIndex)
-               {
-                       Status status;
-                       int resultCount;
-                       status = GDIPlus.GdipPathIterNextPathType (nativeObject, out resultCount, out pathType, out startIndex, out endIndex);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public int NextSubpath (GraphicsPath path, out bool isClosed)
-               {
-                       int resultCount;
-                       IntPtr ptr = (path == null) ? IntPtr.Zero : path.NativeObject;
-                       Status status = GDIPlus.GdipPathIterNextSubpathPath (nativeObject, out resultCount, ptr, out isClosed);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public int NextSubpath (out int startIndex, out int endIndex, out bool isClosed)
-               {
-                       Status status;
-                       int resultCount;
-                       status = GDIPlus.GdipPathIterNextSubpath (nativeObject, out resultCount, out startIndex, out endIndex, out isClosed);
-                       GDIPlus.CheckStatus (status);
-
-                       return resultCount;
-               }
-
-               public void Rewind ()
-               {
-                       Status status = GDIPlus.GdipPathIterRewind (nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsState.cs
deleted file mode 100644 (file)
index 266780b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-//
-// System.Drawing.Drawing2D.GraphicsState.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Drawing2D {
-       /// <summary>
-       /// Summary description for GraphicsState.
-       /// </summary>
-       public sealed class GraphicsState : MarshalByRefObject
-       {
-               // All members inherited                
-               internal uint nativeState;
-               
-               // Constructor
-               internal GraphicsState()
-               {
-                       // Nothing to be done here
-               }
-
-               
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchBrush.cs
deleted file mode 100644 (file)
index 9c92b91..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-//
-// System.Drawing.Drawing2D.HatchBrush.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) 2002/3 Ximian, Inc
-// (C) 2004  Novell, Inc.
-//
-
-//
-// 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;
-
-namespace System.Drawing.Drawing2D 
-{
-       /// <summary>
-       /// Summary description for HatchBrush.
-       /// </summary>
-       public sealed class HatchBrush : Brush 
-       {
-
-               internal HatchBrush (IntPtr ptr) : base (ptr)
-               {
-               }
-
-               public HatchBrush (HatchStyle hatchstyle, Color foreColor)
-                                       : this (hatchstyle, foreColor, Color.Black)
-               {
-               }
-
-               public HatchBrush(HatchStyle hatchstyle, Color foreColor, Color backColor)
-               {
-                       Status status = GDIPlus.GdipCreateHatchBrush (hatchstyle, foreColor.ToArgb (), backColor.ToArgb (), out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public Color BackgroundColor {
-                       get {
-                               int argb;
-                               Status status = GDIPlus.GdipGetHatchBackgroundColor (nativeObject, out argb);
-                               GDIPlus.CheckStatus (status);
-                               return Color.FromArgb (argb);
-                       }
-               }
-
-               public Color ForegroundColor {
-                       get {
-                               int argb;
-                               Status status = GDIPlus.GdipGetHatchForegroundColor (nativeObject, out argb);
-                               GDIPlus.CheckStatus (status);
-                               return Color.FromArgb (argb);
-                       }
-               }
-
-               public HatchStyle HatchStyle {
-                       get {
-                               HatchStyle hatchStyle;
-                               Status status = GDIPlus.GdipGetHatchStyle (nativeObject, out hatchStyle);
-                               GDIPlus.CheckStatus (status);
-                               return hatchStyle;
-                       }
-               }
-
-               public override object Clone ()
-               {
-                       IntPtr clonePtr;
-                       Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
-                       GDIPlus.CheckStatus (status);
-
-                       HatchBrush clone = new HatchBrush (clonePtr);
-                       return clone;
-               }
-
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/HatchStyle.cs
deleted file mode 100644 (file)
index d030868..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// System.Drawing.Drawing2D.HatchStyle.cs
-//
-// Authors:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) 2002/3 Ximian, Inc.
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum HatchStyle {
-               BackwardDiagonal = 3,
-               Cross = LargeGrid,
-               DarkDownwardDiagonal = 20,
-               DarkHorizontal = 29,
-               DarkUpwardDiagonal = 21,
-               DarkVertical = 28,
-               DashedDownwardDiagonal = 30,
-               DashedHorizontal = 32,
-               DashedUpwardDiagonal = 31,
-               DashedVertical = 33,
-               DiagonalBrick = 38,
-               DiagonalCross = 5,
-               Divot = 42,
-               DottedDiamond = 44,
-               DottedGrid = 43,
-               ForwardDiagonal = 2,
-               Horizontal = 0,
-               HorizontalBrick = 39,
-               LargeCheckerBoard = 50,
-               LargeConfetti = 35,
-               LargeGrid = 4,
-               LightDownwardDiagonal = 18,
-               LightHorizontal = 25,
-               LightUpwardDiagonal = 19,
-               LightVertical = 24,
-               Max = 4,
-               Min = 0,
-               NarrowHorizontal = 27,
-               NarrowVertical = 26,
-               OutlinedDiamond = 51,
-               Percent05 = 6,
-               Percent10 = 7,
-               Percent20 = 8,
-               Percent25 = 9,
-               Percent30 = 10,
-               Percent40 = 11,
-               Percent50 = 12,
-               Percent60 = 13,
-               Percent70 = 14,
-               Percent75 = 15,
-               Percent80 = 16,
-               Percent90 = 17,
-               Plaid = 41,
-               Shingle = 45,
-               SmallCheckerBoard = 49,
-               SmallConfetti = 34,
-               SmallGrid = 48,
-               SolidDiamond = 52,
-               Sphere = 47,
-               Trellis = 46,
-               Vertical = 1,
-               Wave = 37,
-               Weave = 40,
-               WideDownwardDiagonal = 22,
-               WideUpwardDiagonal = 23,
-               ZigZag = 36
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/InterpolationMode.cs
deleted file mode 100644 (file)
index 06f335a..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// System.Drawing.Drawing2D.InterpolationMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum InterpolationMode {
-               Bicubic = 4,
-               Bilinear = 3,
-               Default = 0,
-               High = 2,
-               HighQualityBicubic = 7,
-               HighQualityBilinear = 6,
-               Invalid = -1,
-               Low = 1,
-               NearestNeighbor = 5
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineCap.cs
deleted file mode 100644 (file)
index fb59d8e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// System.Drawing.Drawing2D.LineCap.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum LineCap {
-               AnchorMask = 240,
-               ArrowAnchor = 20,
-               Custom = 255,
-               DiamondAnchor = 19,
-               Flat = 0,
-               NoAnchor = 16,
-               Round = 2,
-               RoundAnchor = 18,
-               Square = 1,
-               SquareAnchor = 17,
-               Triangle = 3
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LineJoin.cs
deleted file mode 100644 (file)
index 9588f0f..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.Drawing2D.LineJoin.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum LineJoin {
-               Bevel = 1,
-               Miter = 0,
-               MiterClipped = 3,
-               Round = 2
-       }
-}
index aa8fcf55e0b3fc6f3885aaa9b0897ae3e22a6e76..3b006fd5c9684a4356f5ef5808b6683e39655277 100644 (file)
@@ -36,16 +36,19 @@ namespace System.Drawing.Drawing2D {
        {
                RectangleF rectangle;
                
-               internal LinearGradientBrush (IntPtr native) : base (native)
+               internal LinearGradientBrush (IntPtr native)
                {
                        Status status = GDIPlus.GdipGetLineRect (native, out rectangle);
+                       SetNativeBrush (native);
                        GDIPlus.CheckStatus (status);
                }
 
                public LinearGradientBrush (Point point1, Point point2, Color color1, Color color2)
                {
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreateLineBrushI (ref point1, ref point2, color1.ToArgb (), color2.ToArgb (), WrapMode.Tile, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
 
                        status = GDIPlus.GdipGetLineRect (nativeObject, out rectangle);
                        GDIPlus.CheckStatus (status);
@@ -53,8 +56,10 @@ namespace System.Drawing.Drawing2D {
 
                public LinearGradientBrush (PointF point1, PointF point2, Color color1, Color color2)
                {
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreateLineBrush (ref point1, ref point2, color1.ToArgb (), color2.ToArgb (), WrapMode.Tile, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
 
                        status = GDIPlus.GdipGetLineRect (nativeObject, out rectangle);
                        GDIPlus.CheckStatus (status);
@@ -62,8 +67,10 @@ namespace System.Drawing.Drawing2D {
 
                public LinearGradientBrush (Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
                {
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreateLineBrushFromRectI (ref rect, color1.ToArgb (), color2.ToArgb (), linearGradientMode, WrapMode.Tile, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
 
                        rectangle = (RectangleF) rect;
                }
@@ -74,8 +81,10 @@ namespace System.Drawing.Drawing2D {
 
                public LinearGradientBrush (RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
                {
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreateLineBrushFromRect (ref rect, color1.ToArgb (), color2.ToArgb (), linearGradientMode, WrapMode.Tile, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
 
                        rectangle = rect;
                }
@@ -86,16 +95,20 @@ namespace System.Drawing.Drawing2D {
 
                public LinearGradientBrush (Rectangle rect, Color color1, Color color2, float angle, bool isAngleScaleable)
                {
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreateLineBrushFromRectWithAngleI (ref rect, color1.ToArgb (), color2.ToArgb (), angle, isAngleScaleable, WrapMode.Tile, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
 
                        rectangle = (RectangleF) rect;
                }
 
                public LinearGradientBrush (RectangleF rect, Color color1, Color color2, float angle, bool isAngleScaleable)
                {
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreateLineBrushFromRectWithAngle (ref rect, color1.ToArgb (), color2.ToArgb (), angle, isAngleScaleable, WrapMode.Tile, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
 
                        rectangle = rect;
                }
@@ -105,11 +118,11 @@ namespace System.Drawing.Drawing2D {
                public Blend Blend {
                        get {
                                int count;
-                               Status status = GDIPlus.GdipGetLineBlendCount (nativeObject, out count);
+                               Status status = GDIPlus.GdipGetLineBlendCount (NativeBrush, out count);
                                GDIPlus.CheckStatus (status);
                                float [] factors = new float [count];
                                float [] positions = new float [count];
-                               status = GDIPlus.GdipGetLineBlend (nativeObject, factors, positions, count);
+                               status = GDIPlus.GdipGetLineBlend (NativeBrush, factors, positions, count);
                                GDIPlus.CheckStatus (status);
 
                                Blend blend = new Blend ();
@@ -137,7 +150,7 @@ namespace System.Drawing.Drawing2D {
                                if (positions [count - 1] != 1.0F)
                                        throw new ArgumentException ("Invalid Blend object. The positions array must have 1.0 as its last element.");
 
-                               Status status = GDIPlus.GdipSetLineBlend (nativeObject, factors, positions, count);
+                               Status status = GDIPlus.GdipSetLineBlend (NativeBrush, factors, positions, count);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -146,12 +159,12 @@ namespace System.Drawing.Drawing2D {
                public bool GammaCorrection {
                        get {
                                bool gammaCorrection;
-                               Status status = GDIPlus.GdipGetLineGammaCorrection (nativeObject, out gammaCorrection);
+                               Status status = GDIPlus.GdipGetLineGammaCorrection (NativeBrush, out gammaCorrection);
                                GDIPlus.CheckStatus (status);
                                return gammaCorrection;
                        }
                        set {
-                               Status status = GDIPlus.GdipSetLineGammaCorrection (nativeObject, value);
+                               Status status = GDIPlus.GdipSetLineGammaCorrection (NativeBrush, value);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -159,11 +172,11 @@ namespace System.Drawing.Drawing2D {
                public ColorBlend InterpolationColors {
                        get {
                                int count;
-                               Status status = GDIPlus.GdipGetLinePresetBlendCount (nativeObject, out count);
+                               Status status = GDIPlus.GdipGetLinePresetBlendCount (NativeBrush, out count);
                                GDIPlus.CheckStatus (status);
                                int [] intcolors = new int [count];
                                float [] positions = new float [count];
-                               status = GDIPlus.GdipGetLinePresetBlend (nativeObject, intcolors, positions, count);
+                               status = GDIPlus.GdipGetLinePresetBlend (NativeBrush, intcolors, positions, count);
                                GDIPlus.CheckStatus (status);
 
                                ColorBlend interpolationColors = new ColorBlend ();
@@ -199,7 +212,7 @@ namespace System.Drawing.Drawing2D {
                                for (int i = 0; i < colors.Length; i++)
                                        blend [i] = colors [i].ToArgb ();
 
-                               Status status = GDIPlus.GdipSetLinePresetBlend (nativeObject, blend, positions, count);
+                               Status status = GDIPlus.GdipSetLinePresetBlend (NativeBrush, blend, positions, count);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -207,7 +220,7 @@ namespace System.Drawing.Drawing2D {
                public Color [] LinearColors {
                        get {
                                int [] colors = new int [2];
-                               Status status = GDIPlus.GdipGetLineColors (nativeObject, colors);
+                               Status status = GDIPlus.GdipGetLineColors (NativeBrush, colors);
                                GDIPlus.CheckStatus (status);
                                Color [] linearColors = new Color [2];
                                linearColors [0] = Color.FromArgb (colors [0]);
@@ -217,7 +230,7 @@ namespace System.Drawing.Drawing2D {
                        }
                        set {
                                // no null check, MS throws a NullReferenceException here
-                               Status status = GDIPlus.GdipSetLineColors (nativeObject, value [0].ToArgb (), value [1].ToArgb ());
+                               Status status = GDIPlus.GdipSetLineColors (NativeBrush, value [0].ToArgb (), value [1].ToArgb ());
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -231,7 +244,7 @@ namespace System.Drawing.Drawing2D {
                public Matrix Transform {
                        get {
                                Matrix matrix = new Matrix ();
-                               Status status = GDIPlus.GdipGetLineTransform (nativeObject, matrix.nativeMatrix);
+                               Status status = GDIPlus.GdipGetLineTransform (NativeBrush, matrix.nativeMatrix);
                                GDIPlus.CheckStatus (status);
 
                                return matrix;
@@ -240,7 +253,7 @@ namespace System.Drawing.Drawing2D {
                                if (value == null)
                                        throw new ArgumentNullException ("Transform");
 
-                               Status status = GDIPlus.GdipSetLineTransform (nativeObject, value.nativeMatrix);
+                               Status status = GDIPlus.GdipSetLineTransform (NativeBrush, value.nativeMatrix);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -248,7 +261,7 @@ namespace System.Drawing.Drawing2D {
                public WrapMode WrapMode {
                        get {
                                WrapMode wrapMode;
-                               Status status = GDIPlus.GdipGetLineWrapMode (nativeObject, out wrapMode);
+                               Status status = GDIPlus.GdipGetLineWrapMode (NativeBrush, out wrapMode);
                                GDIPlus.CheckStatus (status);
 
                                return wrapMode;
@@ -258,7 +271,7 @@ namespace System.Drawing.Drawing2D {
                                if ((value < WrapMode.Tile) || (value > WrapMode.Clamp))
                                        throw new InvalidEnumArgumentException ("WrapMode");
 
-                               Status status = GDIPlus.GdipSetLineWrapMode (nativeObject, value);
+                               Status status = GDIPlus.GdipSetLineWrapMode (NativeBrush, value);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -275,13 +288,13 @@ namespace System.Drawing.Drawing2D {
                        if (matrix == null)
                                throw new ArgumentNullException ("matrix");
 
-                       Status status = GDIPlus.GdipMultiplyLineTransform (nativeObject, matrix.nativeMatrix, order);
+                       Status status = GDIPlus.GdipMultiplyLineTransform (NativeBrush, matrix.nativeMatrix, order);
                        GDIPlus.CheckStatus (status);
                }
 
                public void ResetTransform ()
                {
-                       Status status = GDIPlus.GdipResetLineTransform (nativeObject);
+                       Status status = GDIPlus.GdipResetLineTransform (NativeBrush);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -292,7 +305,7 @@ namespace System.Drawing.Drawing2D {
 
                public void RotateTransform (float angle, MatrixOrder order)
                {
-                       Status status = GDIPlus.GdipRotateLineTransform (nativeObject, angle, order);
+                       Status status = GDIPlus.GdipRotateLineTransform (NativeBrush, angle, order);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -303,7 +316,7 @@ namespace System.Drawing.Drawing2D {
 
                public void ScaleTransform (float sx, float sy, MatrixOrder order)
                {
-                       Status status = GDIPlus.GdipScaleLineTransform (nativeObject, sx, sy, order);
+                       Status status = GDIPlus.GdipScaleLineTransform (NativeBrush, sx, sy, order);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -317,7 +330,7 @@ namespace System.Drawing.Drawing2D {
                        if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
                                throw new ArgumentException ("Invalid parameter passed.");
 
-                       Status status = GDIPlus.GdipSetLineLinearBlend (nativeObject, focus, scale);
+                       Status status = GDIPlus.GdipSetLineLinearBlend (NativeBrush, focus, scale);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -331,7 +344,7 @@ namespace System.Drawing.Drawing2D {
                        if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
                                throw new ArgumentException ("Invalid parameter passed.");
 
-                       Status status = GDIPlus.GdipSetLineSigmaBlend (nativeObject, focus, scale);
+                       Status status = GDIPlus.GdipSetLineSigmaBlend (NativeBrush, focus, scale);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -342,14 +355,14 @@ namespace System.Drawing.Drawing2D {
 
                public void TranslateTransform (float dx, float dy, MatrixOrder order)
                {
-                       Status status = GDIPlus.GdipTranslateLineTransform (nativeObject, dx, dy, order);
+                       Status status = GDIPlus.GdipTranslateLineTransform (NativeBrush, dx, dy, order);
                        GDIPlus.CheckStatus (status);
                }
 
                public override object Clone ()
                {
                        IntPtr clonePtr;
-                       Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+                       Status status = GDIPlus.GdipCloneBrush (NativeBrush, out clonePtr);
                        GDIPlus.CheckStatus (status);
 
                        return new LinearGradientBrush (clonePtr);
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientMode.cs
deleted file mode 100644 (file)
index 7e38c7a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.Drawing2D.LinearGradientMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum LinearGradientMode {
-               BackwardDiagonal = 3,
-               ForwardDiagonal = 2,
-               Horizontal = 0,
-               Vertical = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/MatrixOrder.cs
deleted file mode 100644 (file)
index fb2984c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.Drawing2D.MatrixOrder.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum MatrixOrder {
-               Append = 1,
-               Prepend = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathData.cs
deleted file mode 100644 (file)
index 9114be0..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// System.Drawing.Drawing2D.PathData.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//   Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D
-{
-       public sealed class PathData
-       {
-               private PointF[] points;
-               private byte[] types;
-
-               public PathData ()
-               {
-               }
-
-               public PointF[] Points {
-                       get { return points; }
-                       set { points = value; }
-               }
-
-               public byte[] Types {
-                       get { return types; }
-                       set { types = value; }
-               }
-       }
-}
index 72aa010af3a272fd36b96d0453848a5b45ecdd7d..addf2366b9277767f2422b551c25870ed6c8360a 100644 (file)
@@ -36,8 +36,9 @@ namespace System.Drawing.Drawing2D {
        [MonoTODO ("libgdiplus/cairo doesn't support path gradients - unless it can be mapped to a radial gradient")]
        public sealed class PathGradientBrush : Brush {
 
-               internal PathGradientBrush (IntPtr native) : base (native)
+               internal PathGradientBrush (IntPtr native)
                {
+                       SetNativeBrush (native);
                }
 
                public PathGradientBrush (GraphicsPath path)
@@ -45,8 +46,10 @@ namespace System.Drawing.Drawing2D {
                        if (path == null)
                                throw new ArgumentNullException ("path");
 
-                       Status status = GDIPlus.GdipCreatePathGradientFromPath (path.NativeObject, out nativeObject);
+                       IntPtr nativeObject;
+                       Status status = GDIPlus.GdipCreatePathGradientFromPath (path.nativePath, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
                }
 
                public PathGradientBrush (Point [] points) : this (points, WrapMode.Clamp)
@@ -64,8 +67,10 @@ namespace System.Drawing.Drawing2D {
                        if ((wrapMode < WrapMode.Tile) || (wrapMode > WrapMode.Clamp))
                                throw new InvalidEnumArgumentException ("WrapMode");
 
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreatePathGradientI (points, points.Length, wrapMode, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
                }
 
                public PathGradientBrush (PointF [] points, WrapMode wrapMode)
@@ -75,8 +80,10 @@ namespace System.Drawing.Drawing2D {
                        if ((wrapMode < WrapMode.Tile) || (wrapMode > WrapMode.Clamp))
                                throw new InvalidEnumArgumentException ("WrapMode");
 
+                       IntPtr nativeObject;
                        Status status = GDIPlus.GdipCreatePathGradient (points, points.Length, wrapMode, out nativeObject);
                        GDIPlus.CheckStatus (status);
+                       SetNativeBrush (nativeObject);
                }
 
                // Properties
@@ -84,11 +91,11 @@ namespace System.Drawing.Drawing2D {
                public Blend Blend {
                        get {
                                int count;
-                               Status status = GDIPlus.GdipGetPathGradientBlendCount (nativeObject, out count);
+                               Status status = GDIPlus.GdipGetPathGradientBlendCount (NativeBrush, out count);
                                GDIPlus.CheckStatus (status);
                                float [] factors = new float [count];
                                float [] positions = new float [count];
-                               status = GDIPlus.GdipGetPathGradientBlend (nativeObject, factors, positions, count);
+                               status = GDIPlus.GdipGetPathGradientBlend (NativeBrush, factors, positions, count);
                                GDIPlus.CheckStatus (status);
 
                                Blend blend = new Blend ();
@@ -116,7 +123,7 @@ namespace System.Drawing.Drawing2D {
                                if (positions [count - 1] != 1.0F)
                                        throw new ArgumentException ("Invalid Blend object. The positions array must have 1.0 as its last element.");
 
-                               Status status = GDIPlus.GdipSetPathGradientBlend (nativeObject, factors, positions, count);
+                               Status status = GDIPlus.GdipSetPathGradientBlend (NativeBrush, factors, positions, count);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -124,12 +131,12 @@ namespace System.Drawing.Drawing2D {
                public Color CenterColor {
                        get {
                                int centerColor;
-                               Status status = GDIPlus.GdipGetPathGradientCenterColor (nativeObject, out centerColor);
+                               Status status = GDIPlus.GdipGetPathGradientCenterColor (NativeBrush, out centerColor);
                                GDIPlus.CheckStatus (status);
                                return Color.FromArgb (centerColor);
                        }
                        set {
-                               Status status = GDIPlus.GdipSetPathGradientCenterColor (nativeObject, value.ToArgb ());
+                               Status status = GDIPlus.GdipSetPathGradientCenterColor (NativeBrush, value.ToArgb ());
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -137,14 +144,14 @@ namespace System.Drawing.Drawing2D {
                public PointF CenterPoint {
                        get {
                                PointF center;
-                               Status status = GDIPlus.GdipGetPathGradientCenterPoint (nativeObject, out center);
+                               Status status = GDIPlus.GdipGetPathGradientCenterPoint (NativeBrush, out center);
                                GDIPlus.CheckStatus (status);
 
                                return center;
                        }
                        set {
                                PointF center = value;
-                               Status status = GDIPlus.GdipSetPathGradientCenterPoint (nativeObject, ref center);
+                               Status status = GDIPlus.GdipSetPathGradientCenterPoint (NativeBrush, ref center);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -153,13 +160,13 @@ namespace System.Drawing.Drawing2D {
                        get {
                                float xScale;
                                float yScale;
-                               Status status = GDIPlus.GdipGetPathGradientFocusScales (nativeObject, out xScale, out yScale);
+                               Status status = GDIPlus.GdipGetPathGradientFocusScales (NativeBrush, out xScale, out yScale);
                                GDIPlus.CheckStatus (status);
 
                                return new PointF (xScale, yScale);
                        }
                        set {
-                               Status status = GDIPlus.GdipSetPathGradientFocusScales (nativeObject, value.X, value.Y);
+                               Status status = GDIPlus.GdipSetPathGradientFocusScales (NativeBrush, value.X, value.Y);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -167,7 +174,7 @@ namespace System.Drawing.Drawing2D {
                public ColorBlend InterpolationColors {
                        get {
                                int count;
-                               Status status = GDIPlus.GdipGetPathGradientPresetBlendCount (nativeObject, out count);
+                               Status status = GDIPlus.GdipGetPathGradientPresetBlendCount (NativeBrush, out count);
                                GDIPlus.CheckStatus (status);
                                // if no failure, then the "managed" minimum is 1
                                if (count < 1)
@@ -177,7 +184,7 @@ namespace System.Drawing.Drawing2D {
                                float [] positions = new float [count];
                                // status would fail if we ask points or types with a < 2 count
                                if (count > 1) {
-                                       status = GDIPlus.GdipGetPathGradientPresetBlend (nativeObject, intcolors, positions, count);
+                                       status = GDIPlus.GdipGetPathGradientPresetBlend (NativeBrush, intcolors, positions, count);
                                        GDIPlus.CheckStatus (status);
                                }
 
@@ -213,7 +220,7 @@ namespace System.Drawing.Drawing2D {
                                for (int i = 0; i < colors.Length; i++)
                                        blend [i] = colors [i].ToArgb ();
 
-                               Status status = GDIPlus.GdipSetPathGradientPresetBlend (nativeObject, blend, positions, count);
+                               Status status = GDIPlus.GdipSetPathGradientPresetBlend (NativeBrush, blend, positions, count);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -221,7 +228,7 @@ namespace System.Drawing.Drawing2D {
                public RectangleF Rectangle {
                        get {
                                RectangleF rect;
-                               Status status = GDIPlus.GdipGetPathGradientRect (nativeObject, out rect);
+                               Status status = GDIPlus.GdipGetPathGradientRect (NativeBrush, out rect);
                                GDIPlus.CheckStatus (status);
 
                                return rect;
@@ -231,11 +238,11 @@ namespace System.Drawing.Drawing2D {
                public Color [] SurroundColors {
                        get {
                                int count;
-                               Status status = GDIPlus.GdipGetPathGradientSurroundColorCount (nativeObject, out count);
+                               Status status = GDIPlus.GdipGetPathGradientSurroundColorCount (NativeBrush, out count);
                                GDIPlus.CheckStatus (status);
 
                                int [] intcolors = new int [count];
-                               status = GDIPlus.GdipGetPathGradientSurroundColorsWithCount (nativeObject, intcolors, ref count);
+                               status = GDIPlus.GdipGetPathGradientSurroundColorsWithCount (NativeBrush, intcolors, ref count);
                                GDIPlus.CheckStatus (status);
 
                                Color [] colors = new Color [count];
@@ -251,7 +258,7 @@ namespace System.Drawing.Drawing2D {
                                for (int i = 0; i < count; i++)
                                        colors [i] = value [i].ToArgb ();
 
-                               Status status = GDIPlus.GdipSetPathGradientSurroundColorsWithCount (nativeObject, colors, ref count);
+                               Status status = GDIPlus.GdipSetPathGradientSurroundColorsWithCount (NativeBrush, colors, ref count);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -259,7 +266,7 @@ namespace System.Drawing.Drawing2D {
                public Matrix Transform {
                        get {
                                Matrix matrix = new Matrix ();
-                               Status status = GDIPlus.GdipGetPathGradientTransform (nativeObject, matrix.nativeMatrix);
+                               Status status = GDIPlus.GdipGetPathGradientTransform (NativeBrush, matrix.nativeMatrix);
                                GDIPlus.CheckStatus (status);
 
                                return matrix;
@@ -268,7 +275,7 @@ namespace System.Drawing.Drawing2D {
                                if (value == null)
                                        throw new ArgumentNullException ("Transform");
 
-                               Status status = GDIPlus.GdipSetPathGradientTransform (nativeObject, value.nativeMatrix);
+                               Status status = GDIPlus.GdipSetPathGradientTransform (NativeBrush, value.nativeMatrix);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -276,7 +283,7 @@ namespace System.Drawing.Drawing2D {
                public WrapMode WrapMode {
                        get {
                                WrapMode wrapMode;
-                               Status status = GDIPlus.GdipGetPathGradientWrapMode (nativeObject, out wrapMode);
+                               Status status = GDIPlus.GdipGetPathGradientWrapMode (NativeBrush, out wrapMode);
                                GDIPlus.CheckStatus (status);
 
                                return wrapMode;
@@ -285,7 +292,7 @@ namespace System.Drawing.Drawing2D {
                                if ((value < WrapMode.Tile) || (value > WrapMode.Clamp))
                                        throw new InvalidEnumArgumentException ("WrapMode");
 
-                               Status status = GDIPlus.GdipSetPathGradientWrapMode (nativeObject, value);
+                               Status status = GDIPlus.GdipSetPathGradientWrapMode (NativeBrush, value);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -302,13 +309,13 @@ namespace System.Drawing.Drawing2D {
                        if (matrix == null)
                                throw new ArgumentNullException ("matrix");
 
-                       Status status = GDIPlus.GdipMultiplyPathGradientTransform (nativeObject, matrix.nativeMatrix, order);
+                       Status status = GDIPlus.GdipMultiplyPathGradientTransform (NativeBrush, matrix.nativeMatrix, order);
                        GDIPlus.CheckStatus (status);
                }
 
                public void ResetTransform ()
                {
-                       Status status = GDIPlus.GdipResetPathGradientTransform (nativeObject);
+                       Status status = GDIPlus.GdipResetPathGradientTransform (NativeBrush);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -319,7 +326,7 @@ namespace System.Drawing.Drawing2D {
 
                public void RotateTransform (float angle, MatrixOrder order)
                {
-                       Status status = GDIPlus.GdipRotatePathGradientTransform (nativeObject, angle, order);
+                       Status status = GDIPlus.GdipRotatePathGradientTransform (NativeBrush, angle, order);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -330,7 +337,7 @@ namespace System.Drawing.Drawing2D {
 
                public void ScaleTransform (float sx, float sy, MatrixOrder order)
                {
-                       Status status = GDIPlus.GdipScalePathGradientTransform (nativeObject, sx, sy, order);
+                       Status status = GDIPlus.GdipScalePathGradientTransform (NativeBrush, sx, sy, order);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -344,7 +351,7 @@ namespace System.Drawing.Drawing2D {
                        if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
                                throw new ArgumentException ("Invalid parameter passed.");
 
-                       Status status = GDIPlus.GdipSetPathGradientLinearBlend (nativeObject, focus, scale);
+                       Status status = GDIPlus.GdipSetPathGradientLinearBlend (NativeBrush, focus, scale);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -358,7 +365,7 @@ namespace System.Drawing.Drawing2D {
                        if (focus < 0 || focus > 1 || scale < 0 || scale > 1)
                                throw new ArgumentException ("Invalid parameter passed.");
 
-                       Status status = GDIPlus.GdipSetPathGradientSigmaBlend (nativeObject, focus, scale);
+                       Status status = GDIPlus.GdipSetPathGradientSigmaBlend (NativeBrush, focus, scale);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -369,14 +376,14 @@ namespace System.Drawing.Drawing2D {
 
                public void TranslateTransform (float dx, float dy, MatrixOrder order)
                {
-                       Status status = GDIPlus.GdipTranslatePathGradientTransform (nativeObject, dx, dy, order);
+                       Status status = GDIPlus.GdipTranslatePathGradientTransform (NativeBrush, dx, dy, order);
                        GDIPlus.CheckStatus (status);
                }
 
                public override object Clone ()
                {
                        IntPtr clonePtr;
-                       Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
+                       Status status = GDIPlus.GdipCloneBrush (NativeBrush, out clonePtr);
                        GDIPlus.CheckStatus (status);
 
                        PathGradientBrush clone = new PathGradientBrush (clonePtr);
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PathPointType.cs
deleted file mode 100644 (file)
index d826a0b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// System.Drawing.Drawing2D.PathPointType.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum PathPointType {
-               Bezier = 3,
-               Bezier3 = 3,
-               CloseSubpath = 128,
-               DashMode = 16,
-               Line = 1,
-               PathMarker = 32,
-               PathTypeMask = 7,
-               Start = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenAlignment.cs
deleted file mode 100644 (file)
index 3912bcd..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Drawing.Drawing2D.PenAlignment.cs
-//
-// Author:
-//   Miguel de Icaza (miguel@ximian.com)
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum PenAlignment {
-               Center = 0,
-               Inset = 1,
-               Outset = 2,
-               Left = 3,
-               Right =4
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PenType.cs
deleted file mode 100644 (file)
index c511539..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.Drawing2D.PenType.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum PenType {
-               HatchFill = 1,
-               LinearGradient = 4,
-               PathGradient = 3,
-               SolidColor = 0,
-               TextureFill = 2
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/PixelOffsetMode.cs
deleted file mode 100644 (file)
index c36f27e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// System.Drawing.Drawing2D.PixelOffsetMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum PixelOffsetMode {
-               Default = 0,
-               Half = 4,
-               HighQuality = 2,
-               HighSpeed = 1,
-               Invalid = -1,
-               None = 3
-       }
-}
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/QualityMode.cs
deleted file mode 100644 (file)
index f24fa5f..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.Drawing2D.QualityMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum QualityMode {
-               Default = 0,
-               High = 2,
-               Invalid = -1,
-               Low = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/RegionData.cs
deleted file mode 100644 (file)
index 8483f4b..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// System.Drawing.Drawing2D.RegionData.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) 2002/3 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Drawing2D
-{
-       /// <summary>
-       /// Summary description for RegionData.
-       /// </summary>
-       public sealed class RegionData
-       {
-               private byte[] data;
-
-               internal RegionData () { }
-
-               public byte[] Data {
-                       get {return data;} 
-                       set {data = value;}
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/SmoothingMode.cs
deleted file mode 100644 (file)
index 644461f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Drawing2D.SmoothingMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002/3 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum SmoothingMode {
-               AntiAlias = 4,
-               Default = 0,
-               HighQuality = 2,
-               HighSpeed = 1,
-               Invalid = -1,
-               None = 3
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/WarpMode.cs
deleted file mode 100644 (file)
index 33be6de..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.WarpMode.cs
-//
-// Author:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002 Ximian, Inc
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum WarpMode {
-               Bilinear = 1,
-               Perspective = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/WrapMode.cs
deleted file mode 100644 (file)
index 1eedc36..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Drawing2D.WrapMode.cs
-//
-// Authors:
-//   Stefan Maierhofer <sm@cg.tuwien.ac.at>
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) 2002/3 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Drawing2D {
-
-       public enum WrapMode {
-               Tile,
-               TileFlipX,
-               TileFlipY,
-               TileFlipXY,
-               Clamp
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorAdjustType.cs
deleted file mode 100644 (file)
index 6056818..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Drawing.Imaging.ColorAdjustType.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum ColorAdjustType {
-               Any = 6,
-               Bitmap = 1,
-               Brush = 2,
-               Count = 5,
-               Default = 0,
-               Pen = 3,
-               Text = 4
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorChannelFlag.cs
deleted file mode 100644 (file)
index 0582d6c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// System.Drawing.Imaging.ColorChannelFlag.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum ColorChannelFlag {
-               ColorChannelC = 0,
-               ColorChannelK = 3,
-               ColorChannelLast = 4,
-               ColorChannelM = 1,
-               ColorChannelY = 2
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMap.cs
deleted file mode 100644 (file)
index 88584b2..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// System.Drawing.Imaging.ColorMap.cs
-//
-// Authors:
-//   Everaldo Canuto (everaldo.canuto@bol.com.br)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//   Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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;
-using System.IO;
-using System.Reflection;
-
-namespace System.Drawing.Imaging {
-       public sealed class ColorMap {
-
-               private Color newColor;
-               private Color oldColor;
-
-               // constructors
-               public ColorMap() {
-               }
-
-               // properties
-               public Color NewColor {
-                       get { return newColor; }
-                       set { newColor = value; }
-               }
-
-               public Color OldColor {
-                       get { return oldColor; }
-                       set { oldColor = value; }
-               }
-       }
-
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMapType.cs
deleted file mode 100644 (file)
index 7789cff..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// System.Drawing.Imaging.ColorMapType.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum  ColorMapType {
-               Brush = 1,
-               Default = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrix.cs
deleted file mode 100644 (file)
index 515362c..0000000
+++ /dev/null
@@ -1,383 +0,0 @@
-//
-// Copyright 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004-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,
-// 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.
-//
-//
-// Authors:
-//   Jordi Mas i Hernandez (jordi@ximian.com)
-// 
-// Partially based on work by:
-//     
-//   Everaldo Canuto (everaldo.canuto@bol.com.br)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//   Dennis Hayes (dennish@raytek.com)
-//   
-
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
-       [StructLayout (LayoutKind.Sequential)]
-       public sealed class ColorMatrix
-       {
-               private float color00;
-               private float color01;
-               private float color02;
-               private float color03;
-               private float color04;
-               private float color10;
-               private float color11;
-               private float color12;
-               private float color13;
-               private float color14;
-               private float color20;
-               private float color21;
-               private float color22;
-               private float color23;
-               private float color24;
-               private float color30;
-               private float color31;
-               private float color32;
-               private float color33;
-               private float color34;
-               private float color40;
-               private float color41;
-               private float color42;
-               private float color43;
-               private float color44;
-
-               // constructors
-               public ColorMatrix ()
-               {
-                       color01 = color02 = color03 = color04 = 0;
-                       color10 = color12 = color13 = color14 = 0;
-                       color20 = color21 = color23 = color24 = 0;
-                       color30 = color31 = color32 = color34 = 0;
-                       color40 = color41 = color42 = color43 = 0;
-                       color00 = color11 = color22 = color33 = color44 = 1;
-               }
-
-               [CLSCompliant(false)]
-               public ColorMatrix (float[][] newColorMatrix)
-               {                       
-                       color00 = newColorMatrix [0][0];
-                       color01 = newColorMatrix [0][1];
-                       color02 = newColorMatrix [0][2];
-                       color03 = newColorMatrix [0][3];
-                       color04 = newColorMatrix [0][4];
-                       color10 = newColorMatrix [1][0];
-                       color11 = newColorMatrix [1][1];
-                       color12 = newColorMatrix [1][2];
-                       color13 = newColorMatrix [1][3];
-                       color14 = newColorMatrix [1][4];
-                       color20 = newColorMatrix [2][0];
-                       color21 = newColorMatrix [2][1];
-                       color22 = newColorMatrix [2][2];
-                       color23 = newColorMatrix [2][3];
-                       color24 = newColorMatrix [2][4];
-                       color30 = newColorMatrix [3][0];
-                       color31 = newColorMatrix [3][1];
-                       color32 = newColorMatrix [3][2];
-                       color33 = newColorMatrix [3][3];
-                       color34 = newColorMatrix [3][4];
-                       color40 = newColorMatrix [4][0];
-                       color41 = newColorMatrix [4][1];
-                       color42 = newColorMatrix [4][2];
-                       color43 = newColorMatrix [4][3];
-                       color44 = newColorMatrix [4][4];                                                
-               }
-
-               // properties
-               public float this[int row, int column] {
-                       get {  
-                               switch (row) {
-                               case 0: {
-                                       switch (column) {
-                                       case 0: return color00;
-                                       case 1: return color01;
-                                       case 2: return color02;
-                                       case 3: return color03;
-                                       case 4: return color04;
-                                       default: break;
-                                       }
-                                       break;
-                               }
-                               case 1: {
-                                       switch (column) {
-                                       case 0: return color10;
-                                       case 1: return color11;
-                                       case 2: return color12;
-                                       case 3: return color13;
-                                       case 4: return color14;
-                                       default: break;                                         
-                                       }
-                                       break;
-                               }
-                               case 2: {
-                                       switch (column) {
-                                       case 0: return color20;
-                                       case 1: return color21;
-                                       case 2: return color22;
-                                       case 3: return color23;
-                                       case 4: return color24;
-                                       default: break;                                         
-                                       }
-                                       break;
-                               }
-                               case 3: {
-                                       switch (column) {
-                                       case 0: return color30;
-                                       case 1: return color31;
-                                       case 2: return color32;
-                                       case 3: return color33;
-                                       case 4: return color34;
-                                       default: break;         
-                                       }
-                                       break;
-                               }
-                               case 4: {
-                                       switch (column) {
-                                       case 0: return color40;
-                                       case 1: return color41;
-                                       case 2: return color42;
-                                       case 3: return color43;
-                                       case 4: return color44;
-                                       default: break;                                                 
-                                       }
-                                       break;
-                               }
-                               default:
-                                       break;
-                               }
-                       
-                               throw new IndexOutOfRangeException ("Index was outside the bounds of the array");
-                       }
-                       
-                       set {  
-                               switch (row) {
-                               case 0: {
-                                       switch (column) {
-                                       case 0: color00 = value; return;
-                                       case 1: color01 = value; return;
-                                       case 2: color02 = value; return;
-                                       case 3: color03 = value; return;
-                                       case 4: color04 = value; return;
-                                       default: break;
-                                       }
-                                       break;
-                               }
-                               case 1: {
-                                       switch (column) {
-                                       case 0: color10 = value; return;
-                                       case 1: color11 = value; return;
-                                       case 2: color12 = value; return;
-                                       case 3: color13 = value; return;
-                                       case 4: color14 = value; return;
-                                       default: break;                                         
-                                       }
-                                       break;
-                               }
-                               case 2: {
-                                       switch (column) {
-                                       case 0: color20 = value; return;
-                                       case 1: color21 = value; return;
-                                       case 2: color22 = value; return;
-                                       case 3: color23 = value; return;
-                                       case 4: color24 = value; return;
-                                       default: break;                                         
-                                       }
-                                       break;
-                               }
-                               case 3: {
-                                       switch (column) {
-                                       case 0: color30 = value; return;
-                                       case 1: color31 = value; return;
-                                       case 2: color32 = value; return;
-                                       case 3: color33 = value; return;
-                                       case 4: color34 = value; return;
-                                       default: break;         
-                                       }
-                                       break;
-                               }
-                               case 4: {
-                                       switch (column) {
-                                       case 0: color40 = value; return;
-                                       case 1: color41 = value; return;
-                                       case 2: color42 = value; return;
-                                       case 3: color43 = value; return;
-                                       case 4: color44 = value; return;
-                                       default: break;                                                 
-                                       }
-                                       break;
-                               }
-                               default:
-                                       break;
-                               }
-                       
-                               throw new IndexOutOfRangeException ("Index was outside the bounds of the array");
-                       }                       
-               }
-
-
-               public float Matrix00 {
-                       get { return color00; }
-                       set { color00 = value; }
-               }
-
-               public float Matrix01 {
-                       get { return color01; }
-                       set { color01 = value; }
-               }
-
-               public float Matrix02 {
-                       get { return color02; }
-                       set { color02 = value; }
-               }
-
-               public float Matrix03 {
-                       get { return color03; }
-                       set { color03 = value; }
-               }
-
-               public float Matrix04 {
-                       get { return color04; }
-                       set { color04 = value; }
-               }
-
-               public float Matrix10 {
-                       get { return color10; }
-                       set { color10 = value; }
-               }
-
-               public float Matrix11 {
-                       get { return color11; }
-                       set { color11 = value; }
-               }
-
-               public float Matrix12 {
-                       get { return color12; }
-                       set { color12 = value; }
-               }
-
-               public float Matrix13 {
-                       get { return color13; }
-                       set { color13 = value; }
-               }
-
-               public float Matrix14 {
-                       get { return color14; }
-                       set { color14 = value; }
-               }
-
-               public float Matrix20 {
-                       get { return color20; }
-                       set { color20 = value; }
-               }
-
-               public float Matrix21 {
-                       get { return color21; }
-                       set { color21 = value; }
-               }
-
-               public float Matrix22 {
-                       get { return color22; }
-                       set { color22 = value; }
-               }
-
-               public float Matrix23 {
-                       get { return color23; }
-                       set { color23 = value; }
-               }
-
-               public float Matrix24 {
-                       get { return color24; }
-                       set { color24 = value; }
-               }
-
-               public float Matrix30 {
-                       get { return color30; }
-                       set { color30 = value; }
-               }
-
-               public float Matrix31 {
-                       get { return color31; }
-                       set { color31 = value; }
-               }
-
-               public float Matrix32 {
-                       get { return color32; }
-                       set { color32 = value; }
-               }
-
-               public float Matrix33 {
-                       get { return color33; }
-                       set { color33 = value; }
-               }
-
-               public float Matrix34 {
-                       get { return color34; }
-                       set { color34 = value; }
-               }
-
-               public float Matrix40 {
-                       get { return color40; }
-                       set { color40 = value; }
-               }
-
-               public float Matrix41 {
-                       get { return color41; }
-                       set { color41 = value; }
-               }
-
-               public float Matrix42 {
-                       get { return color42; }
-                       set { color42 = value; }
-               }
-
-               public float Matrix43 {
-                       get { return color43; }
-                       set { color43 = value; }
-               }
-
-               public float Matrix44 {
-                       get { return color44; }
-                       set { color44 = value; }
-               }
-
-
-               static internal IntPtr Alloc (ColorMatrix cm)
-               {
-                       if (cm == null)
-                               return IntPtr.Zero;
-
-                       IntPtr result = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (ColorMatrix)));
-                       Marshal.StructureToPtr (cm, result, false);
-                       return result;
-               }
-
-               static internal void Free (IntPtr cm)
-               {
-                       if (cm != IntPtr.Zero)
-                               Marshal.FreeHGlobal (cm);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMatrixFlag.cs
deleted file mode 100644 (file)
index 95182df..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// System.Drawing.Imaging.ColorMatrixFlag.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum  ColorMatrixFlag{
-               AltGrays = 2,
-               Default = 0,
-               SkipGrays = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorMode.cs
deleted file mode 100644 (file)
index fdc4582..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// System.Drawing.Imaging.ColorMode.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum ColorMode {
-               Argb32Mode = 0,
-               Argb64Mode = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ColorPalette.cs
deleted file mode 100644 (file)
index 28599a7..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// System.Drawing.Imaging.ColorPalette.cs
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-//
-// Author:
-//   Miguel de Icaza (miguel@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;
-using System.Drawing;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
-       public sealed class ColorPalette {
-               // 0x1: the color values in the array contain alpha information
-               // 0x2: the color values are grayscale values.
-               // 0x4: the colors in the array are halftone values.
-
-               private int flags;
-               private Color [] entries;
-
-               //
-               // There is no public constructor, this will be used somewhere in the
-               // drawing code
-               //
-               internal ColorPalette ()
-               {
-                       entries = new Color [0];
-               }
-
-               internal ColorPalette (int flags, Color[] colors) {
-                       this.flags = flags;
-                       entries = colors;
-               }
-
-               public Color [] Entries {
-                       get {
-                               return entries;
-                       }
-               }
-
-               public int Flags {
-                       get {
-                               return flags;
-                       }
-               }
-               /* Caller should call FreeHGlobal*/
-               internal IntPtr getGDIPalette() 
-               {
-                       GdiColorPalette palette = new GdiColorPalette ();                       
-                       Color[] entries = Entries;
-                       int entry = 0;                  
-                       int size = Marshal.SizeOf (palette) + (Marshal.SizeOf (entry) * entries.Length);                        
-                       IntPtr lfBuffer = Marshal.AllocHGlobal(size);                   
-                       
-                       palette.Flags = Flags;
-                       palette.Count = entries.Length;
-                                               
-                       int[] values = new int[palette.Count];
-                       
-                       for (int i = 0; i < values.Length; i++) {
-                               values[i] = entries[i].ToArgb();                                
-                       }                       
-                       
-                       Marshal.StructureToPtr (palette, lfBuffer, false);      
-                       Marshal.Copy (values, 0, (IntPtr) (lfBuffer.ToInt64() + Marshal.SizeOf (palette)), values.Length);
-                       
-                       return lfBuffer;
-               }
-                       
-               internal void setFromGDIPalette (IntPtr palette)
-               {
-                       IntPtr ptr = palette;
-                       int cnt, color;
-                       int offset;
-
-                       flags = Marshal.ReadInt32 (ptr); ptr = (IntPtr) (ptr.ToInt64() + 4);
-                       cnt = Marshal.ReadInt32 (ptr); ptr = (IntPtr) (ptr.ToInt64() + 4);
-                                               
-                       entries = new Color [cnt];                      
-                                               
-                       offset = 0;
-                       for (int i = 0; i < cnt; i++) {
-                               color = Marshal.ReadInt32 (ptr, offset);
-                               entries[i] = Color.FromArgb (color);
-                               offset += 4;
-                       }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfPlusRecordType.cs
deleted file mode 100644 (file)
index ea8c562..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-//
-// System.Drawing.Imaging.EmfPlusRecordType.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum EmfPlusRecordType {
-               BeginContainer = 16423,
-               BeginContainerNoParams = 16424,
-               Clear = 16393,
-               Comment = 16387,
-               DrawArc = 16402,
-               DrawBeziers = 16409,
-               DrawClosedCurve = 16407,
-               DrawCurve = 16408,
-               DrawDriverString = 16438,
-               DrawEllipse = 16399,
-               DrawImage = 16410,
-               DrawImagePoints = 16411,
-               DrawLines = 16397,
-               DrawPath = 16405,
-               DrawPie = 16401,
-               DrawRects = 16395,
-               DrawString = 16412,
-               EmfAbortPath = 68,
-               EmfAlphaBlend = 114,
-               EmfAngleArc = 41,
-               EmfArcTo = 55,
-               EmfBeginPath = 59,
-               EmfBitBlt = 76,
-               EmfChord = 46,
-               EmfCloseFigure = 61,
-               EmfColorCorrectPalette = 111,
-               EmfColorMatchToTargetW = 121,
-               EmfCreateBrushIndirect = 39,
-               EmfCreateColorSpace = 99,
-               EmfCreateColorSpaceW = 122,
-               EmfCreateDibPatternBrushPt = 94,
-               EmfCreateMonoBrush = 93,
-               EmfCreatePalette = 49,
-               EmfCreatePen = 38,
-               EmfDeleteColorSpace = 101,
-               EmfDeleteObject = 40,
-               EmfDrawEscape = 105,
-               EmfEllipse = 42,
-               EmfEndPath = 60,
-               EmfEof = 14,
-               EmfExcludeClipRect = 29,
-               EmfExtCreateFontIndirect = 82,
-               EmfExtCreatePen = 95,
-               EmfExtEscape = 106,
-               EmfExtFloodFill = 53,
-               EmfExtSelectClipRgn = 75,
-               EmfExtTextOutA = 83,
-               EmfExtTextOutW = 84,
-               EmfFillPath = 62,
-               EmfFillRgn = 71,
-               EmfFlattenPath = 65,
-               EmfForceUfiMapping = 109,
-               EmfFrameRgn = 72,
-               EmfGdiComment = 70,
-               EmfGlsBoundedRecord = 103,
-               EmfGlsRecord = 102,
-               EmfGradientFill = 118,
-               EmfHeader = 1,
-               EmfIntersectClipRect = 30,
-               EmfInvertRgn = 73,
-               EmfLineTo = 54,
-               EmfMaskBlt = 78,
-               EmfMax = 122,
-               EmfMin = 1,
-               EmfModifyWorldTransform = 36,
-               EmfMoveToEx = 27,
-               EmfNamedEscpae = 110,
-               EmfOffsetClipRgn = 26,
-               EmfPaintRgn = 74,
-               EmfPie = 47,
-               EmfPixelFormat = 104,
-               EmfPlgBlt = 79,
-               EmfPlusRecordBase = 16384,
-               EmfPolyBezier = 2,
-               EmfPolyBezier16 = 85,
-               EmfPolyBezierTo = 5,
-               EmfPolyBezierTo16 = 88,
-               EmfPolyDraw = 56,
-               EmfPolyDraw16 = 92,
-               EmfPolygon = 3,
-               EmfPolygon16 = 86,
-               EmfPolyline = 4,
-               EmfPolyPolygon16 = 91,
-               EmfPolyPolyline = 7,
-               EmfPolyline16 = 87,
-               EmfPolyPolygon = 8,
-               EmfPolyPolyline16 = 90,
-               EmfPolyTextOutA = 96,
-               EmfPolyTextOutW = 97,
-               EmfRealizePalette = 52,
-               EmfRectangle = 43,
-               EmfReserved069 = 69,
-               EmfReserved117 = 117,
-               EmfResizePalette = 51,
-               EmfRestoreDC = 34,
-               EmfRoundArc = 45,
-               EmfRoundRect = 44,
-               EmfSaveDC = 33,
-               EmfScaleViewportExtEx = 31,
-               EmfScaleWindowExtEx = 32,
-               EmfSelectClipPath = 67,
-               EmfSelectObject = 37,
-               EmfSelectPalette = 48,
-               EmfSetArcDirection = 57,
-               EmfSetBkColor = 25,
-               EmfSetBkMode = 18,
-               EmfSetBrushOrgEx = 13,
-               EmfSetColorAdjustment = 23,
-               EmfSetColorSpace = 100,
-               EmfSetDIBitsToDevice = 80,
-               EmfSetIcmMode = 98,
-               EmfSetIcmProfileA = 112,
-               EmfSetIcmProfileW = 113,
-               EmfSetLayout = 115,
-               EmfSetLinkedUfis = 119,
-               EmfSetMapMode = 17,
-               EmfSetMapperFlags = 16,
-               EmfSetMetaRgn = 28,
-               EmfSetMiterLimit = 58,
-               EmfSetPaletteEntries = 50,
-               EmfSetPixelV = 15,
-               EmfSetPolyFillMode = 19,
-               EmfSetROP2 = 20,
-               EmfSetStretchBltMode = 21,
-               EmfSetTextAlign = 22,
-               EmfSetTextColor = 24,
-               EmfSetTextJustification =120 ,
-               EmfSetViewportExtEx = 11,
-               EmfSetViewportOrgEx = 12,
-               EmfSetWindowExtEx = 9,
-               EmfSetWindowOrgEx = 10,
-               EmfSetWorldTransform = 35,
-               EmfSmallTextOut = 108,
-               EmfStartDoc = 107,
-               EmfStretchBlt = 77,
-               EmfStretchDIBits = 81,
-               EmfStrokeAndFillPath = 63,
-               EmfStrokePath = 64,
-               EmfTransparentBlt = 116,
-               EmfWidenPath = 66,
-               EndContainer = 16425,
-               EndOfFile = 16386,
-               FillClosedCurve = 16406,
-               FillEllipse = 16398,
-               FillPath = 16404,
-               FillPie = 16400,
-               FillPolygon = 16396,
-               FillRects = 16394,
-               FillRegion = 16403,
-               GetDC = 16388,
-               Header = 16385,
-               Invalid = 16384,
-               Max = 16438,
-               Min = 16385,
-               MultiFormatEnd = 16391,
-               MultiFormatSection = 16390,
-               MultiFormatStart = 16389,
-               MultiplyWorldTransform = 16428,
-               Object = 16392,
-               OffsetClip = 16437,
-               ResetClip = 16433,
-               ResetWorldTransform = 16427,
-               Restore = 16422,
-               RotateWorldTransform = 16431,
-               Save = 16421,
-               ScaleWorldTransform = 16430,
-               SetAntiAliasMode = 16414,
-               SetClipPath = 16435,
-               SetClipRect = 16434,
-               SetClipRegion = 16436,
-               SetCompositingMode = 16419,
-               SetCompositingQuality = 16420,
-               SetInterpolationMode = 16417,
-               SetPageTransform = 16432,
-               SetPixelOffsetMode = 16418,
-               SetRenderingOrigin = 16413,
-               SetTextContrast = 16416,
-               SetTextRenderingHint = 16415,
-               SetWorldTransform = 16426,
-               Total = 16439,
-               TranslateWorldTransform = 16429,
-               WmfAnimatePalette = 66614,
-               WmfArc = 67607,
-               WmfBitBlt = 67874,
-               WmfChord = 67632,
-               WmfCreateBrushIndirect = 66300,
-               WmfCreateFontIndirect = 66299,
-               WmfCreatePalette = 65783,
-               WmfCreatePatternBrush = 66041,
-               WmfCreatePenIndirect = 66298,
-               WmfCreateRegion = 67327,
-               WmfDeleteObject = 66032,
-               WmfDibBitBlt = 67904,
-               WmfDibCreatePatternBrush = 65858,
-               WmfFillRegion = 66088,
-               WmfFloodFill = 66585,
-               WmfFrameRegion = 66601,
-               WmfIntersectClipRect = 66582,
-               WmfInvertRegion = 65834,
-               WmfLineTo = 66067,
-               WmfMoveTo = 66068,
-               WmfOffsetCilpRgn = 66080,
-               WmfOffsetViewportOrg = 66065,
-               WmfOffsetWindowOrg = 66063,
-               WmfPaintRegion = 65835,
-               WmfPatBlt = 67101,
-               WmfPie = 67610,
-               WmfPolygon = 66340,
-               WmfPolyline = 66341,
-               WmfPolyPolygon = 66872,
-               WmfRealizePalette = 65589,
-               WmfRecordBase = 65536,
-               WmfRectangle = 66587,
-               WmfResizePalette = 65849,
-               WmfRestoreDC = 65831,
-               WmfRoundRect = 67100,
-               WmfSaveDC = 65566,
-               WmfScaleViewportExt = 66578,
-               WmfScaleWindowExt = 66576,
-               WmfSelectClipRegion = 65836,
-               WmfSelectObject = 65837,
-               WmfSelectPalette = 66100,
-               WmfSetBkColor = 66049,
-               WmfSetBkMode = 65794,
-               WmfSetDibToDev = 68915,
-               WmfSetLayout = 65865,
-               WmfSetMapMode = 65795,
-               WmfSetMapperFlags = 66097,
-               WmfSetPalEntries = 65591,
-               WmfSetPixel = 66591,
-               WmfSetPolyFillMode = 65798,
-               WmfSetRelAbs = 65797,
-               WmfSetROP2 = 65796,
-               WmfSetStretchBltMode = 65799,
-               WmfSetTextAlign = 65838,
-               WmfSetTextCharExtra = 65800,
-               WmfSetTextColor = 66057,
-               WmfSetTextJustification = 66058,
-               WmfSetViewportExt = 66062,
-               WmfSetViewportOrg = 66061,
-               WmfSetWindowExt = 66060,
-               WmfSetWindowOrg = 66059,
-               WmfStretchBlt = 68387,
-               WmfStretchDib = 69443,
-               WmfTextOut = 66849,
-               EmfPolyLineTo = 6,
-               EmfPolylineTo16 = 89,
-               WmfDibStretchBlt = 68417,
-               WmfEllipse = 66584,
-               WmfEscape = 67110,
-               WmfExcludeClipRect = 66581,
-               WmfExtFloodFill = 66888,
-               WmfExtTextOut = 68146
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EmfType.cs
deleted file mode 100644 (file)
index d96a32d..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// System.Drawing.Imaging.EmfType.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum EmfType {
-               EmfOnly = 3,
-               EmfPlusDual = 5,
-               EmfPlusOnly = 4
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/Encoder.cs
deleted file mode 100644 (file)
index e085b6c..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// System.Drawing.Imaging.Encoder.cs
-//
-// (C) 2004 Novell, Inc.  http://www.novell.com
-// Author: Ravindra (rkumar@novell.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;
-
-namespace System.Drawing.Imaging 
-{
-       public sealed class Encoder
-       {
-               private Guid guid;
-
-               public static readonly Encoder ChrominanceTable;
-               public static readonly Encoder ColorDepth;
-               public static readonly Encoder Compression;
-               public static readonly Encoder LuminanceTable;
-               public static readonly Encoder Quality;
-               public static readonly Encoder RenderMethod;
-               public static readonly Encoder SaveFlag;
-               public static readonly Encoder ScanMethod;
-               public static readonly Encoder Transformation;
-               public static readonly Encoder Version;
-
-               static Encoder ()
-               {
-                       // GUID values are taken from my windows machine.
-                       ChrominanceTable = new Encoder ("f2e455dc-09b3-4316-8260-676ada32481c");
-                       ColorDepth = new Encoder ("66087055-ad66-4c7c-9a18-38a2310b8337");
-                       Compression = new Encoder ("e09d739d-ccd4-44ee-8eba-3fbf8be4fc58");
-                       LuminanceTable = new Encoder ("edb33bce-0266-4a77-b904-27216099e717");
-                       Quality = new Encoder ("1d5be4b5-fa4a-452d-9cdd-5db35105e7eb");
-                       RenderMethod = new Encoder ("6d42c53a-229a-4825-8bb7-5c99e2b9a8b8");
-                       SaveFlag = new Encoder ("292266fc-ac40-47bf-8cfc-a85b89a655de");
-                       ScanMethod = new Encoder ("3a4e2661-3109-4e56-8536-42c156e7dcfa");
-                       Transformation = new Encoder ("8d0eb2d1-a58e-4ea8-aa14-108074b7b6f9");
-                       Version = new Encoder ("24d18c76-814a-41a4-bf53-1c219cccf797");
-               }
-               
-               internal Encoder (String guid) {
-                       this.guid = new Guid (guid);
-               }
-
-               public Encoder (Guid guid) {
-                       this.guid = guid;
-               }
-
-               public Guid Guid {
-                       get {
-                               return guid;
-                       }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameter.cs
deleted file mode 100644 (file)
index 8f19320..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-//
-// System.Drawing.Imaging.EncoderParameter.cs
-//
-// Author: 
-//     Ravindra (rkumar@novell.com)
-//  Vladimir Vukicevic (vladimir@pobox.com)
-//
-// (C) 2004 Novell, Inc.  http://www.novell.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;
-using System.Text;
-
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging {
-
-       [StructLayout(LayoutKind.Sequential)]
-       public sealed class EncoderParameter : IDisposable {
-
-               private Encoder encoder;
-               private int valuesCount;
-               private EncoderParameterValueType type;
-               private IntPtr valuePtr;
-
-               internal EncoderParameter ()
-               {
-               }
-
-               public EncoderParameter (Encoder encoder, byte value)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       this.type = EncoderParameterValueType.ValueTypeByte;
-                       this.valuePtr = Marshal.AllocHGlobal (1);
-                       Marshal.WriteByte (this.valuePtr, value);
-               }
-
-               public EncoderParameter (Encoder encoder, byte[] value)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = value.Length;
-                       this.type = EncoderParameterValueType.ValueTypeByte;
-                       this.valuePtr = Marshal.AllocHGlobal (1 * valuesCount);
-                       Marshal.Copy (value, 0, this.valuePtr, valuesCount);
-               }
-
-               public EncoderParameter (Encoder encoder, short value)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       this.type = EncoderParameterValueType.ValueTypeShort;
-                       this.valuePtr = Marshal.AllocHGlobal (2);
-                       Marshal.WriteInt16 (this.valuePtr, value);
-               }
-
-               public EncoderParameter (Encoder encoder, short[] value)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = value.Length;
-                       this.type = EncoderParameterValueType.ValueTypeShort;
-                       this.valuePtr = Marshal.AllocHGlobal (2 * valuesCount);
-                       Marshal.Copy (value, 0, this.valuePtr, valuesCount);
-               }
-
-
-               public EncoderParameter (Encoder encoder, long value)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       this.type = EncoderParameterValueType.ValueTypeLong;
-                       this.valuePtr = Marshal.AllocHGlobal (4);
-                       Marshal.WriteInt32 (this.valuePtr, (int) value);
-               }
-
-               public EncoderParameter (Encoder encoder, long[] value)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = value.Length;
-                       this.type = EncoderParameterValueType.ValueTypeLong;
-                       this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount);
-                       int [] ivals = new int[value.Length];
-                       for (int i = 0; i < value.Length; i++) ivals[i] = (int) value[i];
-                       Marshal.Copy (ivals, 0, this.valuePtr, valuesCount);
-               }
-
-               public EncoderParameter (Encoder encoder, string value)
-               {
-                       this.encoder = encoder;
-
-                       ASCIIEncoding ascii = new ASCIIEncoding ();
-                       int asciiByteCount = ascii.GetByteCount (value);
-                       byte[] bytes = new byte [asciiByteCount];
-                       ascii.GetBytes (value, 0, value.Length, bytes, 0);
-
-                       this.valuesCount = bytes.Length;
-                       this.type = EncoderParameterValueType.ValueTypeAscii;
-                       this.valuePtr = Marshal.AllocHGlobal (valuesCount);
-                       Marshal.Copy (bytes, 0, this.valuePtr, valuesCount);
-               }
-
-               public EncoderParameter (Encoder encoder, byte value, bool undefined)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       if (undefined)
-                               this.type = EncoderParameterValueType.ValueTypeUndefined;
-                       else
-                               this.type = EncoderParameterValueType.ValueTypeByte;
-                       this.valuePtr = Marshal.AllocHGlobal (1);
-                       Marshal.WriteByte (this.valuePtr, value);
-               }
-
-               public EncoderParameter (Encoder encoder, byte[] value, bool undefined)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = value.Length;
-                       if (undefined)
-                               this.type = EncoderParameterValueType.ValueTypeUndefined;
-                       else
-                               this.type = EncoderParameterValueType.ValueTypeByte;
-                       this.valuePtr = Marshal.AllocHGlobal (valuesCount);
-                       Marshal.Copy (value, 0, this.valuePtr, valuesCount);
-               }
-
-               public EncoderParameter (Encoder encoder, int numerator, int denominator)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       this.type = EncoderParameterValueType.ValueTypeRational;
-                       this.valuePtr = Marshal.AllocHGlobal (8);
-                       int [] valuearray = { numerator, denominator };
-                       Marshal.Copy (valuearray, 0, this.valuePtr, valuearray.Length);
-               }
-
-               public EncoderParameter (Encoder encoder, int[] numerator, int[] denominator)
-               {
-                       if (numerator.Length != denominator.Length)
-                               throw new ArgumentException ("Invalid parameter used.");
-
-                       this.encoder = encoder;
-                       this.valuesCount = numerator.Length;
-                       this.type = EncoderParameterValueType.ValueTypeRational;
-                       this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount * 2);
-                       for (int i = 0; i < valuesCount; i++) {
-                               Marshal.WriteInt32 (valuePtr, i * 4, (int) numerator[i]);
-                               Marshal.WriteInt32 (valuePtr, (i + 1) * 4, (int) denominator[i]);
-                       }
-               }
-
-               public EncoderParameter (Encoder encoder, long rangebegin, long rangeend)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       this.type = EncoderParameterValueType.ValueTypeLongRange;
-                       this.valuePtr = Marshal.AllocHGlobal (8);
-                       int [] valuearray = { (int) rangebegin, (int) rangeend };
-                       Marshal.Copy (valuearray, 0, this.valuePtr, valuearray.Length);
-               }
-
-               public EncoderParameter (Encoder encoder, long[] rangebegin, long[] rangeend)
-               {
-                       if (rangebegin.Length != rangeend.Length)
-                               throw new ArgumentException ("Invalid parameter used.");
-
-                       this.encoder = encoder;
-                       this.valuesCount = rangebegin.Length;
-                       this.type = EncoderParameterValueType.ValueTypeLongRange;
-
-                       this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount * 2);
-                       IntPtr dest = this.valuePtr;
-                       for (int i = 0; i < valuesCount; i++) {
-                               Marshal.WriteInt32 (dest, i * 4, (int) rangebegin[i]);
-                               Marshal.WriteInt32 (dest, (i + 1) * 4, (int) rangeend[i]);
-                       }
-               }
-
-               public EncoderParameter (Encoder encoder, int NumberOfValues, int Type, int Value)
-               {
-                       this.encoder = encoder;
-                       this.valuePtr = (IntPtr) Value;
-                       this.valuesCount = NumberOfValues;
-                       this.type = (EncoderParameterValueType) Type;
-               }
-
-               public EncoderParameter (Encoder encoder, int numerator1, int demoninator1, int numerator2, int demoninator2)
-               {
-                       this.encoder = encoder;
-                       this.valuesCount = 1;
-                       this.type = EncoderParameterValueType.ValueTypeRationalRange;
-                       this.valuePtr = Marshal.AllocHGlobal (4 * 4);
-                       int [] valuearray = { numerator1, demoninator1, numerator2, demoninator2 };
-                       Marshal.Copy (valuearray, 0, this.valuePtr, 4);
-               }
-
-               public EncoderParameter (Encoder encoder, int[] numerator1, int[] denominator1, int[] numerator2, int[] denominator2)
-               {
-                       if (numerator1.Length != denominator1.Length ||
-                           numerator2.Length != denominator2.Length ||
-                           numerator1.Length != numerator2.Length)
-                               throw new ArgumentException ("Invalid parameter used.");
-
-                       this.encoder = encoder;
-                       this.valuesCount = numerator1.Length;
-                       this.type = EncoderParameterValueType.ValueTypeRationalRange;
-
-                       this.valuePtr = Marshal.AllocHGlobal (4 * valuesCount * 4);
-                       IntPtr dest = this.valuePtr;
-                       for (int i = 0; i < valuesCount; i++) {
-                               Marshal.WriteInt32 (dest, i * 4, numerator1[i]);
-                               Marshal.WriteInt32 (dest, (i + 1) * 4, denominator1[i]);
-                               Marshal.WriteInt32 (dest, (i + 2) * 4, numerator2[i]);
-                               Marshal.WriteInt32 (dest, (i + 3) * 4, denominator2[i]);
-                       }
-               }
-
-               public Encoder Encoder {
-                       get {
-                               return encoder;
-                       }
-
-                       set {
-                               encoder = value;
-                       }
-               }
-
-               public int NumberOfValues {
-                       get {
-                               return valuesCount;
-                       }
-               }
-
-               public EncoderParameterValueType Type {
-                       get {
-                               return type;
-                       }
-               }
-
-               public EncoderParameterValueType ValueType {
-                       get {
-                               return type;
-                       }
-               }
-
-               void Dispose (bool disposing) {
-                       if (valuePtr != IntPtr.Zero) {
-                               Marshal.FreeHGlobal (valuePtr);
-                               valuePtr = IntPtr.Zero;
-                       }
-               }
-
-               public void Dispose () {
-                       Dispose (true);         
-                       GC.SuppressFinalize(this);
-               }
-
-               ~EncoderParameter () {
-                       Dispose (false);
-               }
-
-               internal static int NativeSize () {
-                       return Marshal.SizeOf (typeof(GdipEncoderParameter));
-               }
-
-               internal void ToNativePtr (IntPtr epPtr) {
-                       GdipEncoderParameter ep = new GdipEncoderParameter ();
-                       ep.guid = this.encoder.Guid;
-                       ep.numberOfValues = (uint) this.valuesCount;
-                       ep.type = this.type;
-                       ep.value = this.valuePtr;
-                       Marshal.StructureToPtr (ep, epPtr, false);
-               }
-
-               internal static EncoderParameter FromNativePtr (IntPtr epPtr) {
-                       GdipEncoderParameter ep;
-                       ep = (GdipEncoderParameter) Marshal.PtrToStructure (epPtr, typeof(GdipEncoderParameter));
-
-                       Type valType;
-                       uint valCount;
-
-                       switch (ep.type) {
-                       case EncoderParameterValueType.ValueTypeAscii:
-                       case EncoderParameterValueType.ValueTypeByte:
-                       case EncoderParameterValueType.ValueTypeUndefined:
-                               valType = typeof(byte);
-                               valCount = ep.numberOfValues;
-                               break;
-                       case EncoderParameterValueType.ValueTypeShort:
-                               valType = typeof(short);
-                               valCount = ep.numberOfValues;
-                               break;
-                       case EncoderParameterValueType.ValueTypeLong:
-                               valType = typeof(int);
-                               valCount = ep.numberOfValues;
-                               break;
-                       case EncoderParameterValueType.ValueTypeLongRange:
-                       case EncoderParameterValueType.ValueTypeRational:
-                               valType = typeof(int);
-                               valCount = ep.numberOfValues * 2;
-                               break;
-                       case EncoderParameterValueType.ValueTypeRationalRange:
-                               valType = typeof(int);
-                               valCount = ep.numberOfValues * 4;
-                               break;
-                       default:
-                               return null;
-                       }
-
-                       EncoderParameter eparam = new EncoderParameter();
-                       eparam.encoder = new Encoder(ep.guid);
-                       eparam.valuesCount = (int) ep.numberOfValues;
-                       eparam.type = ep.type;
-                       eparam.valuePtr = Marshal.AllocHGlobal ((int)(valCount * Marshal.SizeOf(valType)));
-
-                       /* There's nothing in Marshal to do a memcpy() between two IntPtrs.  This sucks. */
-                       unsafe {
-                               byte *s = (byte *) ep.value;
-                               byte *d = (byte *) eparam.valuePtr;
-                               for (int i = 0; i < valCount * Marshal.SizeOf(valType); i++)
-                                       *d++ = *s++;
-                       }
-
-                       return eparam;
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameterValueType.cs
deleted file mode 100644 (file)
index a0a147f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Imaging.EncoderParameterValueType.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum EncoderParameterValueType {
-               ValueTypeAscii = 2,
-               ValueTypeByte = 1,
-               ValueTypeLong = 4,
-               ValueTypeLongRange = 6,
-               ValueTypeRational = 5,
-               ValueTypeRationalRange = 8,
-               ValueTypeShort = 3,
-               ValueTypeUndefined = 7
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderParameters.cs
deleted file mode 100644 (file)
index 2a5b25c..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-//
-// System.Drawing.Imaging.EncoderParameters.cs
-//
-// Author: 
-//     Ravindra (rkumar@novell.com)
-//  Vladimir Vukicevic (vladimir@pobox.com)
-//
-// Copyright (C) 2004, 2008 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;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging 
-{
-       public sealed class EncoderParameters : IDisposable
-       {
-               private EncoderParameter[] parameters;
-
-               public EncoderParameters () {
-                       parameters = new EncoderParameter[1];
-               }
-
-               public EncoderParameters (int count) {
-                       parameters = new EncoderParameter[count];
-               }
-
-               public EncoderParameter[] Param {
-                       get {
-                               return parameters;
-                       }
-
-                       set {
-                               parameters = value;
-                       }
-               }
-
-               public void Dispose () {
-                       // Nothing
-                       GC.SuppressFinalize(this);
-               }
-               internal IntPtr ToNativePtr () {
-                       IntPtr result;
-                       IntPtr ptr;
-
-                       // 4 is the initial int32 "count" value
-                       result = Marshal.AllocHGlobal (4 + parameters.Length * EncoderParameter.NativeSize());
-
-                       ptr = result;
-                       Marshal.WriteInt32 (ptr, parameters.Length);
-
-                       ptr = (IntPtr) (ptr.ToInt64() + 4);
-                       for (int i = 0; i < parameters.Length; i++) {
-                               parameters[i].ToNativePtr (ptr);
-                               ptr = (IntPtr) (ptr.ToInt64 () + EncoderParameter.NativeSize ());
-                       }
-
-                       return result;
-               }
-
-               /* The IntPtr passed in here is a blob returned from
-                * GdipImageGetEncoderParameterList.  Its internal pointers
-                * (i.e. the Value pointers in the EncoderParameter entries)
-                * point to areas within this block of memeory; this means
-                * that we need to free it as a whole, and also means that
-                * we can't Marshal.PtrToStruct our way to victory.
-                */
-               internal static EncoderParameters FromNativePtr (IntPtr epPtr) {
-                       if (epPtr == IntPtr.Zero)
-                               return null;
-
-                       IntPtr ptr = epPtr;
-
-                       int count = Marshal.ReadInt32 (ptr);
-                       ptr = (IntPtr) (ptr.ToInt64() + 4);
-
-                       if (count == 0)
-                               return null;
-
-                       EncoderParameters result = new EncoderParameters (count);
-
-                       for (int i = 0; i < count; i++) {
-                               result.parameters[i] = EncoderParameter.FromNativePtr (ptr);
-                               ptr = (IntPtr) (ptr.ToInt64 () + EncoderParameter.NativeSize ());
-                       }
-
-                       return result;
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/EncoderValue.cs
deleted file mode 100644 (file)
index 9bdaad1..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// System.Drawing.Imaging.EncoderValue.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum EncoderValue {
-               ColorTypeCMYK = 0,
-               ColorTypeYCCK = 1,
-               CompressionCCITT3 = 3,
-               CompressionCCITT4 = 4,
-               CompressionLZW = 2,
-               CompressionNone = 6,
-               CompressionRle = 5,
-               Flush = 20,
-               FrameDimensionPage = 23,
-               FrameDimensionResolution = 22,
-               FrameDimensionTime = 21,
-               LastFrame = 19,
-               MultiFrame = 18,
-               RenderNonProgressive = 12,
-               RenderProgressive = 11,
-               ScanMethodInterlaced = 7,
-               ScanMethodNonInterlaced = 8,
-               TransformFlipHorizontal = 16,
-               TransformFlipVertical = 17,
-               TransformRotate180 = 14,
-               TransformRotate270 = 15,
-               TransformRotate90 = 13,
-               VersionGif87 = 9,
-               VersionGif89 = 10
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/FrameDimension.cs
deleted file mode 100644 (file)
index 3e8546c..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-// created on 21.02.2002 at 17:06
-//
-// FrameDimension.cs
-//
-// Author: Christian Meyer
-// eMail: Christian.Meyer@cs.tum.edu
-// Dennis Hayes (dennish@raytek.com)
-// Sanjay Gupta <gsanjay@novell.com>
-// Jordi Mas i Hernanez (jordi@ximian.com)
-
-//
-// Copyright (C) 2004, 2008 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.Drawing.Imaging {
-
-       public sealed class FrameDimension {
-
-               private Guid guid;
-               private string name;
-
-               static FrameDimension page;
-               static FrameDimension resolution;
-               static FrameDimension time;
-
-
-               public FrameDimension (Guid guid) 
-               {
-                       this.guid = guid;
-               }
-
-               internal FrameDimension (Guid guid, string name)
-               {
-                       this.guid = guid;
-                       this.name = name;
-               }
-
-               public Guid Guid {
-                       get { return guid; }
-               }
-
-               public static FrameDimension Page {
-                       get {
-                               if (page == null)
-                                       page = new FrameDimension (new Guid ("7462dc86-6180-4c7e-8e3f-ee7333a7a483"), "Page");
-                               return page;
-                       }
-               }
-       
-               public static FrameDimension Resolution {
-                       get {
-                               if (resolution == null) {
-                                       resolution = new FrameDimension (new Guid ("84236f7b-3bd3-428f-8dab-4ea1439ca315"), 
-                                               "Resolution");
-                               }
-                               return resolution;
-                       }
-               }
-       
-               public static FrameDimension Time {
-                       get {
-                               if (time == null)
-                                       time = new FrameDimension (new Guid ("6aedbd6d-3fb5-418a-83a6-7f45229dc872"), "Time");
-                               return time;
-                       }
-               }
-
-               public override bool Equals (object o) 
-               {
-                       FrameDimension fd = (o as FrameDimension);
-                       if (fd == null)
-                               return false;           
-               
-                       return (guid == fd.guid);                       
-               }
-       
-               public override int GetHashCode () 
-               {
-                       return guid.GetHashCode ();
-               }
-       
-               public override string ToString ()
-               {
-                       if (name == null)
-                               name = String.Format ("[FrameDimension: {0}]", guid);
-                       return name;
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageAttributes.cs
deleted file mode 100644 (file)
index dbbf98d..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-//
-// System.Drawing.Imaging.ImageAttributes.cs
-//
-// Authors:
-//     Dennis Hayes (dennish@raytek.com) (stubbed out)
-//     Jordi Mas i Hernàndez (jmas@softcatala.org)
-//     Sanjay Gupta (gsanjay@novell.com)
-//     Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002-4 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004, 2006-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.
-//
-
-using System.Drawing.Drawing2D;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging {
-
-       [StructLayout(LayoutKind.Sequential)]
-       public sealed class ImageAttributes : ICloneable, IDisposable {
-               
-               private IntPtr nativeImageAttr;
-               
-               internal IntPtr NativeObject {
-                       get {
-                               return nativeImageAttr;
-                       }
-               }
-               
-               internal ImageAttributes (IntPtr native)
-               {
-                       nativeImageAttr = native;
-               }
-               
-               public ImageAttributes ()
-               {
-                       Status status = GDIPlus.GdipCreateImageAttributes (out nativeImageAttr);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearBrushRemapTable ()
-               {
-                       ClearRemapTable (ColorAdjustType.Brush);
-               }
-
-               //Clears the color keys for all GDI+ objects
-               public void ClearColorKey () 
-               {
-                       ClearColorKey (ColorAdjustType.Default);
-               }
-
-               public void ClearColorKey (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesColorKeys (nativeImageAttr, type, false, 0, 0);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearColorMatrix ()
-               {
-                       ClearColorMatrix (ColorAdjustType.Default);
-               }
-               
-               public void ClearColorMatrix (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr, type, false, 
-                               IntPtr.Zero, IntPtr.Zero, ColorMatrixFlag.Default);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearGamma ()
-               {
-                       ClearGamma (ColorAdjustType.Default);
-               }
-
-               public void ClearGamma (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesGamma (nativeImageAttr, type, false, 0);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearNoOp ()
-               {
-                       ClearNoOp (ColorAdjustType.Default);
-               }
-
-               public void ClearNoOp (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesNoOp (nativeImageAttr, type, false);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearOutputChannel ()
-               {
-                       ClearOutputChannel (ColorAdjustType.Default);
-               }
-
-               public void ClearOutputChannel (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesOutputChannel (nativeImageAttr, type, false, 
-                               ColorChannelFlag.ColorChannelLast);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearOutputChannelColorProfile ()
-               {
-                       ClearOutputChannelColorProfile (ColorAdjustType.Default);
-               }
-
-               public void ClearOutputChannelColorProfile (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesOutputChannelColorProfile (nativeImageAttr, type, false, 
-                               null);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearRemapTable ()
-               {
-                       ClearRemapTable (ColorAdjustType.Default);
-               }
-
-               public void ClearRemapTable (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr, type, false, 0, IntPtr.Zero);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ClearThreshold ()
-               {
-                       ClearThreshold (ColorAdjustType.Default);
-               }
-
-               public void ClearThreshold (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesThreshold (nativeImageAttr, type, false, 0);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               //Sets the color keys for all GDI+ objects
-               public void SetColorKey (Color colorLow, Color colorHigh)
-               {
-                       SetColorKey (colorLow, colorHigh, ColorAdjustType.Default);
-               }
-
-               public void SetColorMatrix (ColorMatrix newColorMatrix)
-               {
-                       SetColorMatrix (newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
-               }
-
-               public void SetColorMatrix (ColorMatrix newColorMatrix, ColorMatrixFlag flags)
-               {
-                       SetColorMatrix (newColorMatrix, flags, ColorAdjustType.Default);
-               }
-
-               public void SetColorMatrix (ColorMatrix newColorMatrix, ColorMatrixFlag mode, ColorAdjustType type)
-               {
-                       IntPtr cm = ColorMatrix.Alloc (newColorMatrix);
-                       try {
-                               Status status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr, 
-                                       type, true, cm, IntPtr.Zero, mode);
-                               GDIPlus.CheckStatus (status);
-                       }
-                       finally {
-                               ColorMatrix.Free (cm);
-                       }
-               }
-
-               public void Dispose ()
-               {
-                       if (nativeImageAttr != IntPtr.Zero) {
-                               Status status = GDIPlus.GdipDisposeImageAttributes (nativeImageAttr);
-                               nativeImageAttr = IntPtr.Zero;
-                               GDIPlus.CheckStatus (status);
-                       }
-                       System.GC.SuppressFinalize (this);
-               }
-
-               ~ImageAttributes ()
-               {
-                       Dispose ();
-               }
-               
-               public object Clone ()
-               {
-                       IntPtr imgclone;
-
-                       Status status = GDIPlus.GdipCloneImageAttributes (nativeImageAttr, out imgclone);
-                       GDIPlus.CheckStatus (status);
-
-                       return new ImageAttributes (imgclone);
-               }
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void GetAdjustedPalette (ColorPalette palette, ColorAdjustType type)
-               {
-                       IntPtr colorPalette = palette.getGDIPalette ();
-                       try {
-                               Status status = GDIPlus.GdipGetImageAttributesAdjustedPalette (nativeImageAttr, colorPalette, type);
-                               GDIPlus.CheckStatus (status);
-                               palette.setFromGDIPalette (colorPalette);
-                       } finally {
-                               if (colorPalette != IntPtr.Zero)
-                                       Marshal.FreeHGlobal (colorPalette);
-                       }
-               }
-
-               public void SetBrushRemapTable (ColorMap[] map)
-               {
-                       GdiColorMap gdiclr = new GdiColorMap ();                                                
-                       IntPtr clrmap, lpPointer;
-                       int mapsize = Marshal.SizeOf (gdiclr); 
-                       int size =  mapsize * map.Length;                       
-                       clrmap = lpPointer =  Marshal.AllocHGlobal (size);      
-                       try {
-                               for (int i=0; i < map.Length; i++) {
-                                       gdiclr.from = map[i].OldColor.ToArgb();
-                                       gdiclr.to = map[i].NewColor.ToArgb();
-                               
-                                       Marshal.StructureToPtr (gdiclr, lpPointer, false);
-                                       lpPointer = (IntPtr) (lpPointer.ToInt64() + mapsize);                                           
-                               }
-                       
-                               Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr, 
-                                       ColorAdjustType.Brush, true, (uint) map.Length, clrmap);
-                               GDIPlus.CheckStatus (status);
-                       }
-                       finally {               
-                               Marshal.FreeHGlobal (clrmap);   
-                       }
-               }
-
-               public void SetColorKey (Color colorLow, Color colorHigh, ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesColorKeys (nativeImageAttr, type, true, 
-                               colorLow.ToArgb (), colorHigh.ToArgb ());
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void SetColorMatrices (ColorMatrix newColorMatrix, ColorMatrix grayMatrix)
-               {
-                       SetColorMatrices (newColorMatrix, grayMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
-               }               
-               
-               public void SetColorMatrices (ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags)
-               {
-                       SetColorMatrices (newColorMatrix, grayMatrix, flags, ColorAdjustType.Default);
-               }
-               
-               public void SetColorMatrices (ColorMatrix newColorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag mode, ColorAdjustType type)
-               {
-                       Status status;
-                       IntPtr cm = ColorMatrix.Alloc (newColorMatrix);
-                       try {
-                               if (grayMatrix == null) {
-                                       status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr, type, true, cm,
-                                               IntPtr.Zero, mode);
-                               } else {
-                                       IntPtr gm = ColorMatrix.Alloc (grayMatrix);
-                                       try {
-                                               status = GDIPlus.GdipSetImageAttributesColorMatrix (nativeImageAttr, type, true,
-                                                       cm, gm, mode);
-                                       }
-                                       finally {
-                                               ColorMatrix.Free (gm);
-                                       }
-                               }
-                       }
-                       finally {
-                               ColorMatrix.Free (cm);
-                       }
-                       GDIPlus.CheckStatus (status);
-               }               
-
-               public void SetGamma (float gamma)
-               {
-                       SetGamma (gamma, ColorAdjustType.Default);
-               }
-
-               public void SetGamma (float gamma, ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesGamma (nativeImageAttr, type, true, gamma);
-                       GDIPlus.CheckStatus (status);                                           
-               }       
-               
-               public void SetNoOp ()
-               {
-                       SetNoOp (ColorAdjustType.Default);                                              
-               }                       
-               
-               public void SetNoOp (ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesNoOp (nativeImageAttr, type, true);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void SetOutputChannel (ColorChannelFlag flags)
-               {
-                       SetOutputChannel (flags, ColorAdjustType.Default);
-               }
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void SetOutputChannel (ColorChannelFlag flags, ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesOutputChannel (nativeImageAttr, type, true, flags);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void SetOutputChannelColorProfile (string colorProfileFilename)
-               {
-                       SetOutputChannelColorProfile (colorProfileFilename, ColorAdjustType.Default);
-               }
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void SetOutputChannelColorProfile (string colorProfileFilename, ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesOutputChannelColorProfile (nativeImageAttr, 
-                               type, true, colorProfileFilename);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void SetRemapTable (ColorMap[] map)
-               {
-                       SetRemapTable (map, ColorAdjustType.Default);
-               }
-
-               public void SetRemapTable (ColorMap[] map, ColorAdjustType type)
-               {
-                       GdiColorMap gdiclr = new GdiColorMap ();                                                
-                       IntPtr clrmap, lpPointer;
-                       int mapsize = Marshal.SizeOf (gdiclr); 
-                       int size =  mapsize * map.Length;                       
-                       clrmap = lpPointer =  Marshal.AllocHGlobal (size);      
-                       try {
-                               for (int i=0; i < map.Length; i++) {
-                                       gdiclr.from = map[i].OldColor.ToArgb();
-                                       gdiclr.to = map[i].NewColor.ToArgb();
-                               
-                                       Marshal.StructureToPtr (gdiclr, lpPointer, false);
-                                       lpPointer = (IntPtr) (lpPointer.ToInt64() + mapsize);                                           
-                               }
-                       
-                               Status status = GDIPlus.GdipSetImageAttributesRemapTable (nativeImageAttr, 
-                                       type, true, (uint) map.Length, clrmap);
-                               GDIPlus.CheckStatus (status);
-                       }
-                       finally {
-                               Marshal.FreeHGlobal (clrmap);
-                       }
-               }               
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void SetThreshold (float threshold)
-               {
-                       SetThreshold (threshold, ColorAdjustType.Default);
-               }
-
-               [MonoTODO ("Not supported by libgdiplus")]
-               public void SetThreshold (float threshold, ColorAdjustType type)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesThreshold (nativeImageAttr, type, true, 0);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void SetWrapMode (WrapMode mode)
-               {
-                       SetWrapMode (mode, Color.Black);
-               }
-               
-               public void SetWrapMode (WrapMode mode, Color color)
-               {
-                       SetWrapMode (mode, color, false);
-               }
-
-               public void SetWrapMode (WrapMode mode, Color color, bool clamp)
-               {
-                       Status status = GDIPlus.GdipSetImageAttributesWrapMode (nativeImageAttr, mode, color.ToArgb (), clamp);
-                       GDIPlus.CheckStatus (status);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecFlags.cs
deleted file mode 100644 (file)
index 3035c5c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// System.Drawing.Imaging.ImageCodecFlags.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       [Flags]
-       public enum ImageCodecFlags {
-               BlockingDecode = 32,
-               Builtin = 65536,
-               Decoder = 2,
-               Encoder = 1,
-               SeekableEncode = 16,
-               SupportBitmap = 4,
-               SupportVector = 8,
-               System = 131072,
-               User = 262144
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageCodecInfo.cs
deleted file mode 100644 (file)
index bf78fba..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-//
-// System.Drawing.Imaging.ImageCodecInfo.cs
-//
-// Authors:
-//   Everaldo Canuto (everaldo.canuto@bol.com.br)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//   Dennis Hayes (dennish@raytek.com)
-//   Jordi Mas i Hernandez (jordi@ximian.com)
-//   Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,2006,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.
-//
-
-using System.Runtime.InteropServices;
-using System.Collections;
-using System.IO;
-
-namespace System.Drawing.Imaging {
-
-       public sealed class ImageCodecInfo {
-               private Guid clsid;
-               private string codecName;
-               private string dllName;
-               private string filenameExtension;
-               private ImageCodecFlags flags;
-               private string formatDescription;
-               private Guid formatID;
-               private string  mimeType;
-               private byte[][] signatureMasks;
-               private byte[][] signaturePatterns;
-               private int version;
-               
-               internal ImageCodecInfo()
-               {
-               }
-
-               // methods              
-               public static ImageCodecInfo[] GetImageDecoders() 
-               {                       
-                       int decoderNums, arraySize, decoder_size;
-                       IntPtr decoders, decoder_ptr;
-                       ImageCodecInfo[] result;
-                       GdipImageCodecInfo gdipdecoder = new GdipImageCodecInfo();
-                       Status status;
-                       
-                       status = GDIPlus.GdipGetImageDecodersSize (out decoderNums, out arraySize);
-                       GDIPlus.CheckStatus (status);
-                       
-                       result =  new ImageCodecInfo [decoderNums];                     
-                       
-                       if (decoderNums == 0)
-                               return result;                  
-                       
-                       /* Get decoders list*/
-                       decoders = Marshal.AllocHGlobal (arraySize);
-                       try {
-                               status = GDIPlus.GdipGetImageDecoders (decoderNums,  arraySize, decoders);
-                               GDIPlus.CheckStatus (status);
-                       
-                               decoder_size = Marshal.SizeOf (gdipdecoder);
-                               decoder_ptr = decoders;
-                       
-                               for (int i = 0; i < decoderNums; i++, decoder_ptr = new IntPtr (decoder_ptr.ToInt64 () + decoder_size)) {
-                                       gdipdecoder = (GdipImageCodecInfo) Marshal.PtrToStructure (decoder_ptr, typeof (GdipImageCodecInfo));
-                                       result[i] = new ImageCodecInfo ();
-                                       GdipImageCodecInfo.MarshalTo (gdipdecoder, result[i]);
-                               }
-                       }
-                       finally {
-                               Marshal.FreeHGlobal (decoders);
-                       }
-                       return result;
-               }
-               
-               
-               public static ImageCodecInfo[] GetImageEncoders() 
-               {
-                       int encoderNums, arraySize, encoder_size;
-                       IntPtr encoders, encoder_ptr;
-                       ImageCodecInfo[] result;
-                       GdipImageCodecInfo gdipencoder = new GdipImageCodecInfo();
-                       Status status;
-                       
-                       status = GDIPlus.GdipGetImageEncodersSize (out encoderNums, out arraySize);
-                       GDIPlus.CheckStatus (status);
-                       
-                       result =  new ImageCodecInfo [encoderNums];                     
-                       
-                       if (encoderNums == 0)
-                               return result;                  
-                       
-                       /* Get encoders list*/
-                       encoders = Marshal.AllocHGlobal (arraySize);
-                       try {
-                               status = GDIPlus.GdipGetImageEncoders (encoderNums,  arraySize, encoders);
-                               GDIPlus.CheckStatus (status);
-                       
-                               encoder_size = Marshal.SizeOf (gdipencoder);
-                               encoder_ptr = encoders;
-                       
-                               for (int i = 0; i < encoderNums; i++, encoder_ptr = new IntPtr (encoder_ptr.ToInt64 () + encoder_size)) {
-                                       gdipencoder = (GdipImageCodecInfo) Marshal.PtrToStructure (encoder_ptr, typeof (GdipImageCodecInfo));
-                                       result[i] = new ImageCodecInfo ();
-                                       GdipImageCodecInfo.MarshalTo (gdipencoder, result[i]);
-                               }
-                       }
-                       finally {
-                               Marshal.FreeHGlobal (encoders);
-                       }
-                       return result;
-               }
-
-               // properties
-               
-               public Guid Clsid 
-               {
-                       get { return clsid; }
-                       set { clsid = value; }
-               }
-
-               
-               public string CodecName 
-               {
-                       get { return codecName; }
-                       set { codecName = value; }
-               }
-
-               
-               public string DllName 
-               {
-                       get { return dllName; }
-                       set { dllName = value; }
-               }
-
-               
-               public string FilenameExtension 
-               {
-                       get { return filenameExtension; }
-                       set { filenameExtension = value; }
-               }
-
-               
-               public ImageCodecFlags Flags 
-               {
-                       get { return flags; }
-                       set { flags = value; }
-               }
-               
-               public string FormatDescription 
-               {
-                       get { return formatDescription; }
-                       set { formatDescription = value; }
-               }
-               
-               public Guid FormatID 
-               {
-                       get { return formatID; }
-                       set { formatID = value; }
-               }
-
-               
-               public string MimeType 
-               {
-                       get { return mimeType; }
-                       set { mimeType = value; }
-               }
-
-               
-               [CLSCompliant(false)]
-               public byte[][] SignatureMasks 
-               {
-                       get { return signatureMasks; }
-                       set { signatureMasks = value; }
-               }
-
-               [CLSCompliant(false)]
-               public byte[][] SignaturePatterns 
-               {
-                       get { return signaturePatterns; }
-                       set { signaturePatterns = value; }
-               }
-               
-               public int Version 
-               {
-                       get { return version; }
-                       set { version = value; }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageFlags.cs
deleted file mode 100644 (file)
index aaa4e66..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// System.Drawing.Imaging.ImageFlags.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       [Flags]
-       public enum ImageFlags {
-               Caching = 131072,
-               ColorSpaceCmyk = 32,
-               ColorSpaceGray = 64,
-               ColorSpaceRgb = 16,
-               ColorSpaceYcbcr = 128,
-               ColorSpaceYcck = 256,
-               HasAlpha = 2,
-               HasRealDpi = 4096,
-               HasRealPixelSize = 8192,
-               HasTranslucent = 4,
-               None = 0,
-               PartiallyScalable = 8,
-               ReadOnly = 65536,
-               Scalable = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/ImageLockMode.cs
deleted file mode 100644 (file)
index e7e091a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.Imaging.ImageLockMode.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum ImageLockMode {
-               ReadOnly = 1,
-               ReadWrite = 3,
-               UserInputBuffer = 4,
-               WriteOnly = 2
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileFrameUnit.cs
deleted file mode 100644 (file)
index 46e5a99..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.Imaging.MetafileFrameUnit.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum MetafileFrameUnit {
-               Document = 5,
-               GdiCompatible = 7,
-               Inch = 4,
-               Millimeter = 6,
-               Pixel = 2,
-               Point = 3
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/MetafileType.cs
deleted file mode 100644 (file)
index 87f447e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Imaging.MetafileType
-//
-// Authors:
-//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//
-// (C) 2002 Ximian, Inc (http://www.ximian.com)
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum MetafileType {
-               Invalid = 0,
-               Wmf = 1,
-               WmfPlaceable = 2,
-               Emf = 3,
-               EmfPlusOnly = 4,
-               EmfPlusDual = 5
-       }
-}
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PaletteFlags.cs
deleted file mode 100644 (file)
index 4448608..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.Imaging.PaletteFlags.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004, 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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       [Flags]
-       public enum PaletteFlags {
-               GrayScale = 2,
-               Halftone = 4,
-               HasAlpha = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PixelFormat.cs
deleted file mode 100644 (file)
index 3b2ec55..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-// created on 20.02.2002 at 21:18
-// 
-// Image.cs
-//
-// Author: Christian Meyer
-// eMail: Christian.Meyer@cs.tum.edu
-//             Dennis Hayes
-//             dennish@raytek.com
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public enum PixelFormat {
-               Alpha = 262144,
-               Canonical = 2097152,
-               DontCare = 0,
-               Extended = 1048576,
-               Format16bppArgb1555 = 397319,
-               Format16bppGrayScale = 1052676,
-               Format16bppRgb555 = 135173,
-               Format16bppRgb565 = 135174,
-               Format1bppIndexed = 196865,
-               Format24bppRgb = 137224,
-               Format32bppArgb = 2498570,
-               Format32bppPArgb = 925707,
-               Format32bppRgb = 139273,
-               Format48bppRgb = 1060876, 
-               Format4bppIndexed = 197634,
-               Format64bppArgb = 3424269,
-               Format64bppPArgb = 1851406,
-               Format8bppIndexed = 198659,
-               Gdi = 131072,
-               Indexed = 65536,
-               Max = 15,
-               PAlpha = 524288,
-               Undefined = 0 //shows up in enumcheck as second "dontcare".
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PlayRecordCallback.cs
deleted file mode 100644 (file)
index 2bb3759..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// System.Drawing.Imaging.PlayRecordCallback.cs
-//
-// Author: Everaldo Canuto
-// eMail: everaldo.canuto@bol.com.br
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Imaging {
-
-       public delegate void PlayRecordCallback(
-               EmfPlusRecordType recordType,
-               int flags,
-               int dataSize,
-               IntPtr recordData
-       );
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/PropertyItem.cs
deleted file mode 100644 (file)
index 46b6ac5..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// System.Drawing.Imaging.PropertyItem.cs
-//
-// Authors:
-//   Everaldo Canuto (everaldo.canuto@bol.com.br)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//   Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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;
-
-namespace System.Drawing.Imaging {
-
-       public sealed class PropertyItem 
-       {
-
-               private int id;
-               private int len;
-               private short type;
-               private byte[] value;
-
-               //constructor
-               internal PropertyItem()
-               {
-                       //Nothing to be done here
-               }
-
-
-               // properties
-               public int Id {
-                       get { return id; }
-                       set { id = value; }
-               }
-
-               public int Len {
-                       get { return len; }
-                       set { len = value; }
-               }
-
-               public short Type {
-                       get { return type; }
-                       set { type = value; }
-               }
-
-               public byte[] Value {
-                       get { return this.value; }
-                       set { this.value = value; }
-               }
-
-       }
-
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs b/mcs/class/System.Drawing/System.Drawing.Imaging/WmfPlaceableFileHeader.cs
deleted file mode 100644 (file)
index f342c59..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// System.Drawing.Imaging.WmfPlaceableFileHeader.cs
-//
-// Authors:
-//     Everaldo Canuto  <everaldo.canuto@bol.com.br>
-//     Dennis Hayes (dennish@raytek.com)
-//     Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004, 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,
-// 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;
-
-namespace System.Drawing.Imaging {
-
-       [StructLayout (LayoutKind.Sequential, Pack=2)]
-       public sealed class WmfPlaceableFileHeader {
-
-               // field order match: http://wvware.sourceforge.net/caolan/ora-wmf.html
-               // for PLACEABLEMETAHEADER structure
-               private int key;
-               private short handle;
-               private short left;
-               private short top;
-               private short right;
-               private short bottom;
-               private short inch;
-               private int reserved;
-               private short checksum;
-
-
-               public WmfPlaceableFileHeader ()
-               {
-                       // header magic number
-                       key = unchecked ((int) 0x9AC6CDD7);
-               }
-
-
-               public short BboxBottom {
-                       get { return bottom; }
-                       set { bottom = value; }
-               }
-               
-               public short BboxLeft {
-                       get { return left; }
-                       set { left = value; }
-               }
-               
-               public short BboxRight {
-                       get { return right; }
-                       set { right = value; }
-               }
-               
-               public short BboxTop {
-                       get { return top; }
-                       set { top = value; }
-               }
-               
-               public short Checksum {
-                       get { return checksum; }
-                       set { checksum = value; }
-               }
-               
-               public short Hmf {
-                       get { return handle; }
-                       set { handle = value; }
-               }
-               
-               public short Inch {
-                       get { return inch; }
-                       set { inch = value; }
-               }
-               
-               public int Key {
-                       get { return key; }
-                       set { key = value; }
-               }
-               
-               public int Reserved {
-                       get { return reserved; }
-                       set { reserved = value; }
-               }                               
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs b/mcs/class/System.Drawing/System.Drawing.Printing/Duplex.cs
deleted file mode 100644 (file)
index bf54ea6..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//\r
-// System.Drawing.Duplex.cs\r
-//\r
-// (C) 2001 Ximian, Inc.  http://www.ximian.com\r
-// Author: Dennis Hayes (dennish@raytek.com)\r
-//\r
-
-//
-// 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;\r
-namespace System.Drawing.Printing \r
-{
-       [Serializable]
-       public enum Duplex {\r
-               Default = -1,\r
-               Horizontal = 3,\r
-               Simplex = 1,\r
-               Vertical = 2\r
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs b/mcs/class/System.Drawing/System.Drawing.Printing/InvalidPrinterException.cs
deleted file mode 100644 (file)
index 7fd127c..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// System.Drawing.InvalidPrinterExecption.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002 Ximian, Inc
-//
-
-//
-// Copyright (C) 2004-2005 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.Serialization;
-
-namespace System.Drawing.Printing {
-
-       [Serializable]
-       public class InvalidPrinterException : SystemException {
-
-//             private PrinterSettings settings;
-
-               public InvalidPrinterException (PrinterSettings settings): base(InvalidPrinterException.GetMessage(settings))
-               {
-//                     this.settings = settings;
-               }
-
-#if !NETSTANDARD1_6
-               protected InvalidPrinterException (SerializationInfo info, StreamingContext context)
-                       : base (info, context)
-               {
-               }
-
-               public override void GetObjectData (SerializationInfo info, StreamingContext context)
-               {
-                       if (info == null)
-                               throw new ArgumentNullException ("info");
-
-                       base.GetObjectData (info, context);
-               }
-#endif
-
-               private static string GetMessage(PrinterSettings settings)
-               {
-                       if (settings.PrinterName == null || settings.PrinterName == String.Empty)
-                               return "No Printers Installed";
-                       return String.Format("Tried to access printer '{0}' with invalid settings.", settings.PrinterName);                             
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs b/mcs/class/System.Drawing/System.Drawing.Printing/Margins.cs
deleted file mode 100644 (file)
index c5bc069..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-//
-// System.Drawing.Margins.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//   Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002 Ximian, Inc
-// Copyright (C) 2004, 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.
-//
-
-using System.ComponentModel;
-
-namespace System.Drawing.Printing
-{
-       [Serializable]
-       [TypeConverter (typeof (MarginsConverter))]
-       public class Margins : ICloneable {
-               int left;
-               int right;
-               int top;
-               int bottom;
-
-               public Margins ()
-               {
-                       left = 100;
-                       right = 100;
-                       top = 100;
-                       bottom = 100;
-               }
-
-               public Margins (int left, int right, int top, int bottom)
-               {
-                       Left = left;
-                       Right = right;
-                       Top = top;
-                       Bottom = bottom;
-               }
-
-               public int Left {
-                       get {
-                               return left;
-                       }
-                       set {
-                               if (value < 0)
-                                       InvalidMargin ("left");
-                               left = value;
-                       }
-               }
-
-               public int Right {
-                       get {
-                               return right;
-                       }
-                       set {
-                               if (value < 0)
-                                       InvalidMargin ("right");
-                               right = value;
-                       }
-               }
-
-               public int Top {
-                       get {
-                               return top;
-                       }
-                       set {
-                               if (value < 0)
-                                       InvalidMargin ("top");
-                               top = value;
-                       }
-               }
-
-               public int Bottom {
-                       get {
-                               return bottom;
-                       }
-                       set {
-                               if (value < 0)
-                                       InvalidMargin ("bottom");
-                               bottom = value;
-                       }
-               }
-
-               private void InvalidMargin (string property)
-               {
-                       string msg = Locale.GetText ("All Margins must be greater than 0");
-                       throw new System.ArgumentException (msg, property);
-               }
-               
-               public object Clone ()
-               {
-                       return new Margins (left, right, top, bottom);
-               }
-
-               public override bool Equals (object obj)
-               {       
-                       return Equals (obj as Margins);
-               }
-
-               private bool Equals (Margins m)
-               {
-                       // avoid recursion with == operator
-                       if ((object)m == null)
-                               return false;
-                       return ((m.Left == left) && (m.Right == right) && (m.Top == top) && (m.Bottom == bottom));
-               }
-
-               public override int GetHashCode ()
-               {
-                       return left | (right << 8) | (right >> 24) | (top << 16) | (top >> 16) | (bottom << 24) | (bottom >> 8);
-               }
-               
-               public override string ToString ()
-               {
-                       string ret = "[Margins Left={0} Right={1} Top={2} Bottom={3}]";
-                       return String.Format (ret, left, right, top, bottom);
-               }
-
-               public static bool operator == (Margins m1, Margins m2)
-               {
-                       // avoid recursion with == operator
-                       if ((object)m1 == null)
-                               return ((object)m2 == null);
-                       return m1.Equals (m2);
-               }
-
-               public static bool operator != (Margins m1, Margins m2)
-               {
-                       // avoid recursion with == operator
-                       if ((object)m1 == null)
-                               return ((object)m2 != null);
-                       return !m1.Equals (m2);
-               }
-       }
-}
index 00bb942e78b70b724d9ae7c5e2bb9e8dbccff6fc..330ba62a2d8e2053cf1b03aaa959f9e4236b595a 100644 (file)
@@ -199,10 +199,10 @@ namespace System.Drawing.Printing
                public object Clone ()
                {
                        // We do a deep copy
-                       PrinterResolution pres = new PrinterResolution (this.printerResolution.X, this.printerResolution.Y, this.printerResolution.Kind);
-                       PaperSource psource = new PaperSource (this.paperSource.SourceName, this.paperSource.Kind);
+                       PrinterResolution pres = new PrinterResolution (this.printerResolution.Kind, this.printerResolution.X, this.printerResolution.Y);
+                       PaperSource psource = new PaperSource (this.paperSource.Kind, this.paperSource.SourceName);
                        PaperSize psize = new PaperSize (this.paperSize.PaperName, this.paperSize.Width, this.paperSize.Height);
-                       psize.SetKind (this.paperSize.Kind);
+                       psize.RawKind = (int)this.paperSize.Kind;
 
                        PageSettings ps = new PageSettings (this.printerSettings, this.color, this.landscape,
                                        psize, psource, pres);
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperKind.cs
deleted file mode 100644 (file)
index d9fb602..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-//\r
-// System.Drawing.PaperKind.cs\r
-//\r
-// (C) 2002 Ximian, Inc.  http://www.ximian.com\r
-// Author: Dennis Hayes (dennish@raytek.com)\r
-//\r
-\r
-//\r
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-using System;\r
-\r
-namespace System.Drawing.Printing \r
-{\r
-       [Serializable]\r
-       public enum PaperKind\r
-       {\r
-               A2 = 66,\r
-               A3 = 8,\r
-               A3Extra = 63,\r
-               A3ExtraTransverse = 68,\r
-               A3Rotated = 76,\r
-               A3Transverse = 67,\r
-               A4 = 9,\r
-               A4Extra = 53,\r
-               A4Plus = 60,\r
-               A4Rotated = 77,\r
-               A4Small = 10,\r
-               A4Transverse = 55,\r
-               A5 = 11,\r
-               A5Extra = 64,\r
-               A5Rotated = 78,\r
-               A5Transverse = 61,\r
-               A6 = 70,\r
-               A6Rotated = 83,\r
-               APlus = 57,\r
-               B4 = 12,\r
-               B4Envelope = 33,\r
-               B4JisRotated = 79,\r
-               B5 = 13,\r
-               B5Envelope = 34,\r
-               B5Extra = 65,\r
-               B5JisRotated = 80,\r
-               B5Transverse = 62,\r
-               B6Envelope = 35,\r
-               B6Jis = 88,\r
-               B6JisRotated = 89,\r
-               BPlus = 58,\r
-               C3Envelope = 29,\r
-               C4Envelope = 30,\r
-               C5Envelope = 28,\r
-               C65Envelope = 32,\r
-               C6Envelope = 31,\r
-               CSheet = 24,\r
-               Custom = 0,\r
-               DLEnvelope = 27,\r
-               DSheet = 25,\r
-               ESheet = 26,\r
-               Executive = 7,\r
-               Folio = 14,\r
-               GermanLegalFanfold = 41,\r
-               GermanStandardFanfold = 40,\r
-               InviteEnvelope = 47,\r
-               IsoB4 = 42,\r
-               ItalyEnvelope = 36,\r
-               JapaneseDoublePostcard = 69,\r
-               JapaneseDoublePostcardRotated = 82,\r
-               JapaneseEnvelopeChouNumber3 = 73,\r
-               JapaneseEnvelopeChouNumber3Rotated = 86,\r
-               JapaneseEnvelopeChouNumber4 = 74,\r
-               JapaneseEnvelopeChouNumber4Rotated = 87,\r
-               JapaneseEnvelopeKakuNumber2 = 71,\r
-               JapaneseEnvelopeKakuNumber2Rotated = 84,\r
-               JapaneseEnvelopeKakuNumber3 = 72,\r
-               JapaneseEnvelopeKakuNumber3Rotated = 85,\r
-               JapaneseEnvelopeYouNumber4 = 91,\r
-               JapaneseEnvelopeYouNumber4Rotated = 92,\r
-               JapanesePostcard = 43,\r
-               JapanesePostcardRotated = 81,\r
-               Ledger = 4,\r
-               Legal = 5,\r
-               LegalExtra = 51,\r
-               Letter = 1,\r
-               LetterExtra = 50,\r
-               LetterExtraTransverse = 56,\r
-               LetterPlus = 59,\r
-               LetterRotated = 75,\r
-               LetterSmall = 2,\r
-               LetterTransverse = 54,\r
-               MonarchEnvelope = 37,\r
-               Note = 18,\r
-               Number10Envelope = 20,\r
-               Number11Envelope = 21,\r
-               Number12Envelope = 22,\r
-               Number14Envelope = 23,\r
-               Number9Envelope = 19,\r
-               PersonalEnvelope = 38,\r
-               Prc16K = 93,\r
-               Prc16KRotated = 106,\r
-               Prc32K = 94,\r
-               Prc32KBig = 95,\r
-               Prc32KBigRotated = 108,\r
-               Prc32KRotated = 107,\r
-               PrcEnvelopeNumber1 = 96,\r
-               PrcEnvelopeNumber10 = 105,\r
-               PrcEnvelopeNumber10Rotated = 118,\r
-               PrcEnvelopeNumber1Rotated = 109,\r
-               PrcEnvelopeNumber2 = 97,\r
-               PrcEnvelopeNumber2Rotated = 110,\r
-               PrcEnvelopeNumber3 = 98,\r
-               PrcEnvelopeNumber3Rotated = 111,\r
-               PrcEnvelopeNumber4 = 99,\r
-               PrcEnvelopeNumber4Rotated = 112,\r
-               PrcEnvelopeNumber5 = 100,\r
-               PrcEnvelopeNumber5Rotated = 113,\r
-               PrcEnvelopeNumber6 = 101,\r
-               PrcEnvelopeNumber6Rotated = 114,\r
-               PrcEnvelopeNumber7 = 102,\r
-               PrcEnvelopeNumber7Rotated = 115,\r
-               PrcEnvelopeNumber8 = 103,\r
-               PrcEnvelopeNumber8Rotated = 116,\r
-               PrcEnvelopeNumber9 = 104,\r
-               PrcEnvelopeNumber9Rotated = 117,\r
-               Quarto = 15,\r
-               Standard10x11 = 45,\r
-               Standard10x14 = 16,\r
-               Standard11x17 = 17,\r
-               Standard12x11 = 90,\r
-               Standard15x11 = 46,\r
-               Standard9x11 = 44,\r
-               Statement = 6,\r
-               Tabloid = 3,\r
-               TabloidExtra = 52,\r
-               USStandardFanfold = 39\r
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSize.cs
deleted file mode 100644 (file)
index d7d48e1..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-//
-// System.Drawing.PaperSize.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Herve Poussineau (hpoussineau@fr.st)
-//
-// (C) 2002 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Printing
-{
-       /// <summary>
-       /// Summary description for PaperSize.
-       /// </summary>
-       [Serializable]
-       public class PaperSize
-       {
-               string name;
-               int width;
-               int height;
-               PaperKind kind;
-               internal bool is_default;
-               
-               public PaperSize ()
-               {
-
-               }
-               public PaperSize(string name, int width, int height)
-               {
-                       this.width = width;
-                       this.height = height;
-                       this.name = name;
-               }
-
-               internal PaperSize(string name, int width, int height, PaperKind kind, bool isDefault)
-               {
-                       this.width = width;
-                       this.height = height;
-                       this.name = name;
-                       this.is_default = isDefault;
-               }
-
-               public int Width{
-                       get{
-                               return width;
-                       }set
-                        {
-                               if (kind != PaperKind.Custom)
-                                       throw new ArgumentException();
-                                width = value;
-                        }
-               }
-               public int Height{
-                       get{
-                               return height;
-                       }set
-                        {
-                               if (kind != PaperKind.Custom)
-                                       throw new ArgumentException();
-                                height = value;
-                        }
-               }
-
-               public string PaperName{
-                       get{
-                               return name;
-                       }
-                       set{
-                               if (kind != PaperKind.Custom)
-                                       throw new ArgumentException();
-                                name = value;
-                        }
-               }
-       
-               public PaperKind Kind{
-                       get{
-                               // .net ignores the values that are less than 0
-                               // the value returned is not used internally, however.
-                               if (kind > PaperKind.PrcEnvelopeNumber10Rotated)
-                                       return PaperKind.Custom;
-
-                               return kind;
-                       }
-               }
-               public int RawKind {
-                       get {
-                               return (int)kind;
-                       }
-                       set {
-                               kind = (PaperKind)value;
-                       }
-               }
-
-       
-               internal bool IsDefault {
-                       get { return this.is_default; }
-                       set { this.is_default = value; }
-               }
-
-
-               internal void SetKind (PaperKind k) {kind = k;}
-
-               public override string ToString(){
-                       string ret = "[PaperSize {0} Kind={1} Height={2} Width={3}]";
-                       return String.Format(ret, this.PaperName, this.Kind, this.Height, this.Width);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSource.cs
deleted file mode 100644 (file)
index a8db379..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// System.Drawing.PaperSource.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Herve Poussineau (hpoussineau@fr.st)
-//
-// (C) 2002 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Printing
-{
-       /// <summary>
-       /// Summary description for PaperSource.
-       /// </summary>
-       [Serializable]
-       public class PaperSource
-       {
-               private PaperSourceKind kind;
-               private string source_name;
-               internal bool is_default;
-               
-               public PaperSource ()
-               {
-                       
-               }
-
-               internal PaperSource(string sourceName, PaperSourceKind kind)
-               {
-                       this.source_name = sourceName;
-                       this.kind = kind;
-               }
-
-               internal PaperSource(string sourceName, PaperSourceKind kind, bool isDefault)
-               {
-                       this.source_name = sourceName;
-                       this.kind = kind;
-                       this.is_default = IsDefault;
-               }
-
-               public PaperSourceKind Kind{
-                       get {
-                               // Exactly at 256 (as opposed to Custom, which is 257 and the max value of PaperSourceKind),
-                               // we must return Custom always.
-                               if ((int)kind >= 256)
-                                       return PaperSourceKind.Custom;
-
-                               return this.kind; 
-                       }
-               }
-               public string SourceName{
-                       get {
-                               return this.source_name;
-                       }
-               set {
-                               this.source_name = value;
-                       }
-               }
-               
-               public int RawKind {
-                       get {
-                               return (int)kind;
-                       }
-                       set {
-                               kind = (PaperSourceKind)value;
-                       }
-               }                 
-
-               internal bool IsDefault {
-                       get { return is_default;}
-                       set { is_default = value;}
-               }
-
-               public override string ToString(){
-                       string ret = "[PaperSource {0} Kind={1}]";
-                       return String.Format(ret, this.SourceName, this.Kind);
-               }
-               
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PaperSourceKind.cs
deleted file mode 100644 (file)
index 911ae62..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-//\r
-// System.Drawing.PaperSourceKind.cs\r
-//\r
-// (C) 2002 Ximian, Inc.  http://www.ximian.com\r
-// Author: Dennis Hayes (dennish@raytek.com)\r
-//\r
-
-//
-// 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;\r
-namespace System.Drawing.Printing\r
-{\r
-       [Serializable]
-       public enum PaperSourceKind {\r
-               AutomaticFeed = 7,\r
-               Cassette = 14,\r
-               Custom = 257,\r
-               Envelope = 5,\r
-               FormSource = 15,\r
-               LargeCapacity = 11,\r
-               LargeFormat = 10,\r
-               Lower = 2,\r
-               Manual = 4,\r
-               ManualFeed = 6,\r
-               Middle = 3,\r
-               SmallFormat = 9,\r
-               TractorFeed = 8,\r
-               Upper = 1\r
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PreviewPageInfo.cs
deleted file mode 100644 (file)
index 4242b05..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// System.Drawing.PreviewPageInfo.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Printing
-{
-       /// <summary>
-       /// Summary description for PreviewPageInfo.
-       /// </summary>
-       public sealed class PreviewPageInfo {
-               Image image;
-               Size physicalSize;
-               public PreviewPageInfo(Image image, Size physicalSize) {
-                       this.image = image;
-                       this.physicalSize = physicalSize;
-               }
-               public Image Image {
-                       get{
-                               return image;
-                       }
-               }
-               public Size PhysicalSize{
-                       get{
-                               return physicalSize;
-                       }
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintAction.cs
deleted file mode 100644 (file)
index f401dda..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Copyright (C) 2005 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.
-//
-// Authors:
-//
-//   Jordi Mas i Hernandez <jordimash@gmail.com>
-//
-//
-
-
-using System;
-
-namespace System.Drawing.Printing
-{
-       public enum PrintAction
-       {
-               PrintToFile     = 0,
-               PrintToPreview  = 1,
-               PrintToPrinter  = 2
-       }
-
-}
-
-
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintEventHandler.cs
deleted file mode 100644 (file)
index 2cff92b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Drawing.PrintEventHandler.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Printing
-{
-       /// <summary>
-       /// Summary description for PrintEventHandler.
-       /// </summary>
-       public delegate void PrintEventHandler(object sender, PrintEventArgs e);
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintPageEventHandler.cs
deleted file mode 100644 (file)
index e60998d..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//\r
-// System.Drawing.PrintPageEventHandler.cs\r
-//\r
-// Author:\r
-//   Dennis Hayes (dennish@Raytek.com)\r
-//\r
-// (C) 2002 Ximian, Inc\r
-//\r
-
-//
-// 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;\r
-\r
-namespace System.Drawing.Printing\r
-{\r
-       /// <summary>\r
-       /// Summary description for PrintPageEventHandler.\r
-       /// </summary>\r
-       public delegate void PrintPageEventHandler(object sender, PrintPageEventArgs e);\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintRange.cs
deleted file mode 100644 (file)
index 4998732..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//\r
-// System.Drawing.PrintRange.cs\r
-//\r
-// (C) 2002 Ximian, Inc.  http://www.ximian.com\r
-// Author: Dennis Hayes (dennish@raytek.com)\r
-//\r
-
-//
-// 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;\r
-namespace System.Drawing.Printing \r
-{
-       [Serializable]
-       public enum PrintRange {\r
-               AllPages = 0,\r
-               Selection = 1,\r
-               SomePages = 2,
-               CurrentPage = 0x400000
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolution.cs
deleted file mode 100644 (file)
index 5f101cd..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-//\r
-// System.Drawing.Printing.PrinterResolution.cs\r
-//\r
-// Author:\r
-//   Dennis Hayes (dennish@Raytek.com)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)\r
-//\r
-// (C) 2002 Ximian, Inc
-// (C) 2003 Andreas Nahr\r
-//\r
-
-//
-// 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;\r
-\r
-namespace System.Drawing.Printing 
-{\r
-
-       [Serializable]
-       public class PrinterResolution 
-       {\r
-               private PrinterResolutionKind kind = PrinterResolutionKind.Custom;\r
-               private int x;\r
-               private int y;
-               
-               public PrinterResolution ()
-               {
-               }
-       
-               internal PrinterResolution (int x, int y, PrinterResolutionKind kind)
-               {
-                       this.x = x;
-                       this.y = y;
-                       this.kind = kind;
-               }
-\r
-               public int X {\r
-                       get {\r
-                               return x;\r
-                       }
-                       set {
-                               x = value;
-                       }
-               }
-\r
-               public int Y {\r
-                       get {\r
-                               return y;\r
-                       }
-                       set {
-                               y = value;
-                       }
-               }
-\r
-               public PrinterResolutionKind Kind {\r
-                       get {\r
-                               return kind;\r
-                       }
-                       set {
-                               kind = value;
-                       }
-               }
-
-               public override string ToString ()
-               {
-                       if (kind != PrinterResolutionKind.Custom)
-                               return "[PrinterResolution " + kind.ToString () +  "]";
-                       
-                       return "[PrinterResolution X=" + x + " Y=" + y + "]";
-               }\r
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterResolutionKind.cs
deleted file mode 100644 (file)
index 167df84..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//\r
-// System.Drawing.PrinterResolutionKind.cs\r
-//\r
-// (C) 2002 Ximian, Inc.  http://www.ximian.com\r
-// Author: Dennis Hayes (dennish@raytek.com)\r
-//\r
-
-//
-// 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;\r
-namespace System.Drawing.Printing \r
-{
-       [Serializable]
-       public enum PrinterResolutionKind {\r
-               Custom = 0,\r
-               Draft = -1,\r
-               High = -4,\r
-               Low = -2,\r
-               Medium = -3\r
-       }\r
-}\r
index 2f8c27de2eccfda7fbf83eaff9595231e2cc2547..2184fc2050ec4b243858667ae124f00846b3cc0e 100644 (file)
@@ -116,11 +116,11 @@ namespace System.Drawing.Printing
                                if (default_pagesettings == null) {
                                        default_pagesettings = new PageSettings (this,
                                                SupportsColor,
-                                               false,  
-                                               // Real defaults are set by LoadPrinterSettings                         
-                                               new PaperSize("A4", 827, 1169),                                         
-                                               new PaperSource("Tray", PaperSourceKind.FormSource),                                            
-                                               new PrinterResolution(200, 200, PrinterResolutionKind.Medium));
+                                               false,
+                                               // Real defaults are set by LoadPrinterSettings
+                                               new PaperSize("A4", 827, 1169),
+                                               new PaperSource(PaperSourceKind.FormSource, "Tray"),
+                                               new PrinterResolution(PrinterResolutionKind.Medium, 200, 200));
                                }
                                
                                return default_pagesettings;
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnit.cs
deleted file mode 100644 (file)
index ff9264c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//\r
-// System.Drawing.PrinterUnit.cs\r
-//\r
-// (C) 2002 Ximian, Inc.  http://www.ximian.com\r
-// Author: Dennis Hayes (dennish@raytek.com)\r
-//\r
-
-//
-// 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;\r
-namespace System.Drawing.Printing \r
-{\r
-       public enum PrinterUnit {\r
-               Display = 0,\r
-               HundredthsOfAMillimeter = 2,\r
-               TenthsOfAMillimeter = 3,\r
-               ThousandthsOfAnInch = 1\r
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrinterUnitConvert.cs
deleted file mode 100644 (file)
index 0045206..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-// System.Drawing.Printing.PrinterUnitConvert.cs
-//
-// Authors:
-//   Martin Willemoes Hansen (mwh@sysrq.dk)
-//   Herve Poussineau (hpoussineau@fr.st)
-//
-// (C) 2003 Martin Willemoes Hansen
-//
-
-//
-// 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.
-//
-
-namespace System.Drawing.Printing
-{
-       public sealed class PrinterUnitConvert
-       {
-               private PrinterUnitConvert ()
-               {
-               }
-
-               public static double Convert (double value,
-                                             PrinterUnit fromUnit,
-                                             PrinterUnit toUnit)
-               {
-                       switch (fromUnit)
-                       {
-                               case PrinterUnit.Display:
-                                       switch (toUnit)
-                                       {
-                                               case PrinterUnit.Display: return value;
-                                               case PrinterUnit.ThousandthsOfAnInch: return value * 10;
-                                               case PrinterUnit.HundredthsOfAMillimeter: return value * 25.4;
-                                               case PrinterUnit.TenthsOfAMillimeter: return value * 2.54;
-                                       }
-                                       break;
-                               case PrinterUnit.ThousandthsOfAnInch:
-                                       switch (toUnit)
-                                       {
-                                               case PrinterUnit.Display: return value / 10;
-                                               case PrinterUnit.ThousandthsOfAnInch: return value;
-                                               case PrinterUnit.HundredthsOfAMillimeter: return value * 2.54;
-                                               case PrinterUnit.TenthsOfAMillimeter: return value * 0.254;
-                                       }
-                                       break;
-                               case PrinterUnit.HundredthsOfAMillimeter:
-                                       switch (toUnit)
-                                       {
-                                               case PrinterUnit.Display: return value / 25.4;
-                                               case PrinterUnit.ThousandthsOfAnInch: return value / 2.54;
-                                               case PrinterUnit.HundredthsOfAMillimeter: return value;
-                                               case PrinterUnit.TenthsOfAMillimeter: return value / 10;
-                                       }
-                                       break;
-                               case PrinterUnit.TenthsOfAMillimeter:
-                                       switch (toUnit)
-                                       {
-                                               case PrinterUnit.Display: return value / 2.54;
-                                               case PrinterUnit.ThousandthsOfAnInch: return value / 0.254;
-                                               case PrinterUnit.HundredthsOfAMillimeter: return value * 10;
-                                               case PrinterUnit.TenthsOfAMillimeter: return value;
-                                       }
-                                       break;
-                       }
-                       // should never happen
-                       throw new NotImplementedException();
-               }
-
-               public static int Convert (int value,
-                                          PrinterUnit fromUnit,
-                                          PrinterUnit toUnit)
-               {
-                       double rslt;
-                       rslt = Convert ((double) value, fromUnit, toUnit);
-                       return (int) Math.Round (rslt);                 
-
-               }
-
-               public static Margins Convert (Margins value,
-                                              PrinterUnit fromUnit,
-                                              PrinterUnit toUnit)
-               {
-                       return new Margins(
-                               Convert(value.Left, fromUnit, toUnit),
-                               Convert(value.Right, fromUnit, toUnit),
-                               Convert(value.Top, fromUnit, toUnit),
-                               Convert(value.Bottom, fromUnit, toUnit));
-               }
-
-               public static Point Convert (Point value,
-                                            PrinterUnit fromUnit,
-                                            PrinterUnit toUnit)
-               {
-                       return new Point(
-                               Convert(value.X, fromUnit, toUnit),
-                               Convert(value.Y, fromUnit, toUnit));
-               }
-
-               public static Rectangle Convert (Rectangle value,
-                                                PrinterUnit fromUnit,
-                                                PrinterUnit toUnit)
-               {
-                       return new Rectangle(
-                               Convert(value.X, fromUnit, toUnit),
-                               Convert(value.Y, fromUnit, toUnit),
-                               Convert(value.Width, fromUnit, toUnit),
-                               Convert(value.Height, fromUnit, toUnit));
-               }
-
-               public static Size Convert (Size value,
-                                           PrinterUnit fromUnit,
-                                           PrinterUnit toUnit)
-               {
-                       return new Size(
-                               Convert(value.Width, fromUnit, toUnit),
-                               Convert(value.Height, fromUnit, toUnit));
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermission.cs
deleted file mode 100644 (file)
index 44e2171..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-//
-// System.Drawing.PrintingPermission.cs
-//
-// Authors:
-//     Dennis Hayes (dennish@Raytek.com)
-//     Herve Poussineau (hpoussineau@fr.st)
-//     Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002 Ximian, Inc
-// 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.Globalization;
-using System.Security;
-using System.Security.Permissions;
-
-namespace System.Drawing.Printing {
-
-       [Serializable]
-       public sealed class PrintingPermission : CodeAccessPermission, IUnrestrictedPermission {
-
-               private const int version = 1;
-
-               private PrintingPermissionLevel _Level;
-               
-               public PrintingPermission (PermissionState state) 
-               {
-                       if (CheckPermissionState (state, true) == PermissionState.Unrestricted)
-                               _Level = PrintingPermissionLevel.AllPrinting;
-               }
-
-               public PrintingPermission (PrintingPermissionLevel printingLevel) 
-               {
-                       Level = printingLevel;
-               }
-               
-               // properties
-
-               public PrintingPermissionLevel Level{
-                       get { return _Level; }
-                       set {
-                               if (!Enum.IsDefined (typeof (PrintingPermissionLevel), value)) {
-                                       string msg = Locale.GetText ("Invalid enum {0}");
-                                       throw new ArgumentException (String.Format (msg, value), "Level");
-                               }
-                                _Level = value;
-                       }
-               }
-
-               // methods
-
-               public override IPermission Copy ()
-               {
-                       return new PrintingPermission (this.Level);
-               }
-               
-               public override void FromXml (SecurityElement esd)
-               {
-                       CheckSecurityElement (esd, "esd", version, version);
-                       // Note: we do not (yet) care about the return value 
-                       // as we only accept version 1 (min/max values)
-
-                       if (IsUnrestricted (esd))
-                               _Level = PrintingPermissionLevel.AllPrinting;
-                       else {
-                               string level = esd.Attribute ("Level");
-                               if (level != null) {
-                                       _Level = (PrintingPermissionLevel) Enum.Parse (
-                                               typeof (PrintingPermissionLevel), level);
-                               }
-                               else
-                                       _Level = PrintingPermissionLevel.NoPrinting;
-                       }
-               }
-               
-               public override IPermission Intersect (IPermission target)
-               {
-                       PrintingPermission pp = Cast (target);
-                       if ((pp == null) || IsEmpty () || pp.IsEmpty ())
-                               return null;
-
-                       PrintingPermissionLevel level = (_Level <= pp.Level) ? _Level : pp.Level;
-                       return new PrintingPermission (level);
-               }
-               
-               public override bool IsSubsetOf (IPermission target)
-               {
-                       PrintingPermission pp = Cast (target);
-                       if (pp == null)
-                               return IsEmpty ();
-                       
-                       return (_Level <= pp.Level);
-               }
-               
-               public bool IsUnrestricted ()
-               {
-                       return (_Level == PrintingPermissionLevel.AllPrinting);
-               }
-               
-               public override SecurityElement ToXml ()
-               {
-                       SecurityElement se = Element (version);
-                       if (IsUnrestricted ())
-                               se.AddAttribute ("Unrestricted", "true");
-                       else
-                               se.AddAttribute ("Level", _Level.ToString ());
-                       return se;
-               }
-               
-               public override IPermission Union (IPermission target)
-               {
-                       PrintingPermission pp = Cast (target);
-                       if (pp == null)
-                               return new PrintingPermission (_Level);
-                       if (IsUnrestricted () || pp.IsUnrestricted ())
-                               return new PrintingPermission (PermissionState.Unrestricted);
-                       if (IsEmpty () && pp.IsEmpty ())
-                               return null;
-
-                       PrintingPermissionLevel level = (_Level > pp.Level) ? _Level : pp.Level;
-                       return new PrintingPermission (level);
-               }
-
-               // Internal helpers methods
-
-               private bool IsEmpty ()
-               {
-                       return (_Level == PrintingPermissionLevel.NoPrinting);
-               }
-
-               private PrintingPermission Cast (IPermission target)
-               {
-                       if (target == null)
-                               return null;
-
-                       PrintingPermission pp = (target as PrintingPermission);
-                       if (pp == null) {
-                               ThrowInvalidPermission (target, typeof (PrintingPermission));
-                       }
-
-                       return pp;
-               }
-
-               // NOTE: The following static methods should be moved out to a (static?) class 
-               // if (ever) System.Drawing.dll gets more than one permission in it's assembly.
-
-               // snippet moved from FileIOPermission (nickd) to be reused in all derived classes
-               internal SecurityElement Element (int version) 
-               {
-                       SecurityElement se = new SecurityElement ("IPermission");
-                       Type type = this.GetType ();
-                       se.AddAttribute ("class", type.FullName + ", " + type.Assembly.ToString ().Replace ('\"', '\''));
-                       se.AddAttribute ("version", version.ToString ());
-                       return se;
-               }
-
-               internal static PermissionState CheckPermissionState (PermissionState state, bool allowUnrestricted)
-               {
-                       string msg;
-                       switch (state) {
-                       case PermissionState.None:
-                               break;
-                       case PermissionState.Unrestricted:
-                               if (!allowUnrestricted) {
-                                       msg = Locale.GetText ("Unrestricted isn't not allowed for identity permissions.");
-                                       throw new ArgumentException (msg, "state");
-                               }
-                               break;
-                       default:
-                               msg = String.Format (Locale.GetText ("Invalid enum {0}"), state);
-                               throw new ArgumentException (msg, "state");
-                       }
-                       return state;
-               }
-
-               // logic isn't identical to CodeAccessPermission.CheckSecurityElement - see unit tests
-               internal static int CheckSecurityElement (SecurityElement se, string parameterName, int minimumVersion, int maximumVersion) 
-               {
-                       if (se == null)
-                               throw new ArgumentNullException (parameterName);
-
-                       string c = se.Attribute ("class");
-                       if (c == null) {
-                               string msg = Locale.GetText ("Missing 'class' attribute.");
-                               throw new ArgumentException (msg, parameterName);
-                       }
-                       // we assume minimum version if no version number is supplied
-                       int version = minimumVersion;
-                       string v = se.Attribute ("version");
-                       if (v != null) {
-                               try {
-                                       version = Int32.Parse (v);
-                               }
-                               catch (Exception e) {
-                                       string msg = Locale.GetText ("Couldn't parse version from '{0}'.");
-                                       msg = String.Format (msg, v);
-                                       throw new ArgumentException (msg, parameterName, e);
-                               }
-                       }
-
-                       if ((version < minimumVersion) || (version > maximumVersion)) {
-                               string msg = Locale.GetText ("Unknown version '{0}', expected versions between ['{1}','{2}'].");
-                               msg = String.Format (msg, version, minimumVersion, maximumVersion);
-                               throw new ArgumentException (msg, parameterName);
-                       }
-                       return version;
-               }
-
-               // must be called after CheckSecurityElement (i.e. se != null)
-               internal static bool IsUnrestricted (SecurityElement se) 
-               {
-                       string value = se.Attribute ("Unrestricted");
-                       if (value == null)
-                               return false;
-                       return (String.Compare (value, Boolean.TrueString, true, CultureInfo.InvariantCulture) == 0);
-               }
-
-               internal static void ThrowInvalidPermission (IPermission target, Type expected) 
-               {
-                       string msg = Locale.GetText ("Invalid permission type '{0}', expected type '{1}'.");
-                       msg = String.Format (msg, target.GetType (), expected);
-                       throw new ArgumentException (msg, "target");
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionAttribute.cs
deleted file mode 100644 (file)
index 35ecd54..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// System.Drawing.PrintingPermissionAttribute.cs
-//
-// Authors:
-//     Dennis Hayes (dennish@Raytek.com)
-//     Herve Poussineau (hpoussineau@fr.st)
-//     Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002 Ximian, Inc
-// 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.Security;
-using System.Security.Permissions;
-
-namespace System.Drawing.Printing {
-
-       [AttributeUsage (AttributeTargets.All, AllowMultiple=true)]
-       // strangely this class isn't [Serializable] like other permission classes
-       public sealed class PrintingPermissionAttribute : CodeAccessSecurityAttribute {
-
-               private PrintingPermissionLevel _level;
-               
-               public PrintingPermissionAttribute (SecurityAction action)
-                       : base (action)
-               {
-                       // seems to always assign PrintingPermissionLevel.NoPrinting ...
-               }
-               
-               public PrintingPermissionLevel Level {
-                       get { return _level; }
-                       set {
-                               if (!Enum.IsDefined (typeof (PrintingPermissionLevel), value)) {
-                                       string msg = Locale.GetText ("Invalid enum {0}");
-                                       throw new ArgumentException (String.Format (msg, value), "Level");
-                               }
-                               _level = value;
-                       }
-               }
-               
-               public override IPermission CreatePermission ()
-               {
-                       if (base.Unrestricted)
-                               return new PrintingPermission (PermissionState.Unrestricted);
-                       else
-                               return new PrintingPermission (_level);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs b/mcs/class/System.Drawing/System.Drawing.Printing/PrintingPermissionLevel.cs
deleted file mode 100644 (file)
index 6e663d4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//\r
-// System.Drawing.PrintingPermissionLevel.cs\r
-//\r
-// Author:
-//     Dennis Hayes (dennish@raytek.com)\r
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com\r
-// 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.
-//
-
-namespace System.Drawing.Printing {
-
-       [Serializable]
-       public enum PrintingPermissionLevel {\r
-               AllPrinting = 3,\r
-               DefaultPrinting = 2,\r
-               NoPrinting = 0,\r
-               SafePrinting = 1\r
-       }\r
-}\r
index 5eb31d5e1f0b985f11a110804173bbaab3af5203..762792395a313c83765324e971d203b0c674393d 100644 (file)
@@ -54,10 +54,10 @@ namespace System.Drawing.Printing
                
                internal void LoadDefaultResolutions (PrinterSettings.PrinterResolutionCollection col)
                {
-                       col.Add (new PrinterResolution ((int) PrinterResolutionKind.High, -1, PrinterResolutionKind.High));
-                       col.Add (new PrinterResolution ((int) PrinterResolutionKind.Medium, -1, PrinterResolutionKind.Medium));
-                       col.Add (new PrinterResolution ((int) PrinterResolutionKind.Low, -1, PrinterResolutionKind.Low));
-                       col.Add (new PrinterResolution ((int) PrinterResolutionKind.Draft, -1, PrinterResolutionKind.Draft));
+                       col.Add (new PrinterResolution (PrinterResolutionKind.High, (int) PrinterResolutionKind.High, -1));
+                       col.Add (new PrinterResolution (PrinterResolutionKind.Medium, (int) PrinterResolutionKind.Medium, -1));
+                       col.Add (new PrinterResolution (PrinterResolutionKind.Low, (int) PrinterResolutionKind.Low, -1));
+                       col.Add (new PrinterResolution (PrinterResolutionKind.Draft, (int) PrinterResolutionKind.Draft, -1));
                }
                #endregion
        }
index 3386004199ab9f792f69a9357c0d9020317beda5..859f726e7b4d2ee2f4197b49b964532faa11720a 100644 (file)
@@ -433,7 +433,7 @@ namespace System.Drawing.Printing
                                return null;
                        }
 
-                       return new PrinterResolution (x_resolution, y_resolution, PrinterResolutionKind.Custom);
+                       return new PrinterResolution (PrinterResolutionKind.Custom, x_resolution, y_resolution);
                }
 
                /// <summary>
@@ -452,7 +452,7 @@ namespace System.Drawing.Printing
                        PPD_SIZE size;
                        PaperSize ps;
 
-                       PaperSize defsize = new PaperSize ("A4", 827, 1169, GetPaperKind (827, 1169), true);
+                       PaperSize defsize = new PaperSize (GetPaperKind (827, 1169), "A4", 827, 1169);
                        ppd = (PPD_FILE) Marshal.PtrToStructure (ppd_handle, typeof (PPD_FILE));
                        ptr = ppd.sizes;
                        float w, h;
@@ -462,8 +462,8 @@ namespace System.Drawing.Printing
                                w = size.width * 100 / 72;
                                h = size.length * 100 / 72;
                                PaperKind kind = GetPaperKind ((int) w, (int) h);
-                               ps = new PaperSize (real_name, (int) w, (int) h, kind, def_size == kind.ToString ());
-                               ps.SetKind (kind);
+                               ps = new PaperSize (kind, real_name, (int) w, (int) h);
+                               ps.RawKind = (int)kind;
                                if (def_size == ps.Kind.ToString ())
                                        defsize = ps;
                                settings.paper_sizes.Add (ps);
@@ -507,7 +507,7 @@ namespace System.Drawing.Printing
                                                kind = PaperSourceKind.Custom;
                                                break;
                                }
-                               settings.paper_sources.Add (new PaperSource (paper_sources[source], kind, def_source == source));
+                               settings.paper_sources.Add (new PaperSource (kind, paper_sources[source]));
                                if (def_source == source)
                                        defsource = settings.paper_sources[settings.paper_sources.Count-1];
                        }
index 66c3a58e18e61ca508d93831be1d5b3d5af558ef..c070eb675995794fbefde7d3098ff256cb2f10ad 100644 (file)
@@ -139,7 +139,7 @@ namespace System.Drawing.Printing
                                        y = Marshal.ReadInt32 (ptr);
                                        ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (y));
                                        settings.PrinterResolutions.Add (new PrinterResolution
-                                               (x,y, PrinterResolutionKind.Custom));
+                                               (PrinterResolutionKind.Custom, x, y));
                                }
                        }
                        Marshal.FreeHGlobal (buff);
@@ -197,7 +197,7 @@ namespace System.Drawing.Printing
                                        ptr_sizes_enum = new IntPtr (ptr_sizes_enum.ToInt64 () + 2);
 
                                        ps = new PaperSize (name, x,y);
-                                       ps.SetKind (kind);
+                                       ps.RawKind = (int)kind;
                                        settings.PaperSizes.Add (ps);
                                }
                        }
@@ -261,7 +261,7 @@ namespace System.Drawing.Printing
                                for (int i = 0; i < ret; i++) {
                                        name  = Marshal.PtrToStringUni (ptr_names);
                                        kind = (PaperSourceKind) Marshal.ReadInt16 (ptr_bins);
-                                       settings.PaperSources.Add (new PaperSource (name, kind));
+                                       settings.PaperSources.Add (new PaperSource (kind, name));
 
                                        ptr_names = new IntPtr (ptr_names.ToInt64 () + 24 * 2);
                                        ptr_bins = new IntPtr (ptr_bins.ToInt64 () + 2);
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs b/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventArgs.cs
deleted file mode 100644 (file)
index 2e92150..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//\r
-// System.Drawing.QueryPageSettingsEventArgs.cs\r
-//\r
-// Author:\r
-//   Dennis Hayes (dennish@Raytek.com)\r
-//\r
-// (C) 2002 Ximian, Inc\r
-//\r
-
-//
-// 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;\r
-\r
-namespace System.Drawing.Printing\r
-{\r
-       /// <summary>\r
-       /// Summary description for QueryPageSettingEventArgs.\r
-       /// </summary>\r
-       public class QueryPageSettingsEventArgs : PrintEventArgs\r
-       {\r
-               private PageSettings pageSettings;\r
-\r
-               public QueryPageSettingsEventArgs(PageSettings pageSettings)\r
-               {\r
-                       this.pageSettings = pageSettings;\r
-               }\r
-               public PageSettings PageSettings {\r
-                       get{\r
-                       return pageSettings;\r
-               }\r
-                       set{\r
-                               pageSettings = value;\r
-                       }\r
-               }\r
-\r
-       }\r
-}\r
diff --git a/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs b/mcs/class/System.Drawing/System.Drawing.Printing/QueryPageSettingsEventHandler.cs
deleted file mode 100644 (file)
index 373eeb8..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Drawing.QueryPageSettingsEventHandler.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//
-// (C) 2002 Ximian, Inc
-//
-
-//
-// 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;
-
-namespace System.Drawing.Printing
-{
-       /// <summary>
-       /// Summary description for QueryPageSettingsEventHandler.
-       /// </summary>
-       public delegate void QueryPageSettingsEventHandler(object sender, QueryPageSettingsEventArgs e);
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs b/mcs/class/System.Drawing/System.Drawing.Text/FontCollection.cs
deleted file mode 100644 (file)
index 3b3b15d..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// System.Drawing.Text.FontCollection.cs
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Author: Everaldo Canuto everaldo.canuto@bol.com.br
-//             Sanjay Gupta (gsanjay@novell.com)
-//             Peter Dennis Bartok (pbartok@novell.com)
-//
-//
-// Copyright (C) 2004 - 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,
-// 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.
-//
-
-namespace System.Drawing.Text {
-
-       public abstract class FontCollection : IDisposable {
-               
-               internal IntPtr nativeFontCollection = IntPtr.Zero;
-                               
-               internal FontCollection ()
-               {
-               }
-        
-               // methods
-               public void Dispose()
-               {
-                       Dispose (true);
-                       GC.SuppressFinalize (true);
-               }
-
-               protected virtual void Dispose (bool disposing)
-               {
-                       // DO NOT FREE FROM HERE
-                       // FIXME: InstalledFontCollection cannot be freed safely and will leak one time 
-                       // (inside libgdiplus). MS has a similar behaviour (but probably doesn't leak)
-               }
-
-               // properties
-               public FontFamily[] Families
-               {
-                       get { 
-                               int found;
-                               int returned = 0;
-                               Status status;
-                               FontFamily[] families;
-                               IntPtr[] result;
-
-                               // MS doesn't throw ObjectDisposedException in this case
-                               if (nativeFontCollection == IntPtr.Zero)
-                                       throw new ArgumentException (Locale.GetText ("Collection was disposed."));
-                               
-                               status = GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
-                               GDIPlus.CheckStatus (status);
-                               if (found == 0)
-                                       return new FontFamily [0];
-
-                               result = new IntPtr[found];
-                               status = GDIPlus.GdipGetFontCollectionFamilyList (nativeFontCollection, found, result, out returned);
-                                  
-                               families = new FontFamily [returned];
-                               for ( int i = 0; i < returned ; i++) {
-                                       families[i] = new FontFamily(result[i]);
-                               }
-           
-                               return families;               
-                       }
-               }
-
-               ~FontCollection()
-               {
-                       Dispose (false);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs b/mcs/class/System.Drawing/System.Drawing.Text/GenericFontFamilies.cs
deleted file mode 100644 (file)
index 4423097..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// System.Drawing.GenericFontFamilies.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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.
-//
-
-namespace System.Drawing.Text {
-
-       public enum GenericFontFamilies {
-               Monospace = 2,
-               SansSerif = 1,
-               Serif = 0
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs b/mcs/class/System.Drawing/System.Drawing.Text/HotkeyPrefix.cs
deleted file mode 100644 (file)
index 19a7cbe..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// System.Drawing.HotkeyPrefix.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing.Text {
-
-       public enum HotkeyPrefix {
-               Hide = 2,
-               None = 0,
-               Show = 1
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs b/mcs/class/System.Drawing/System.Drawing.Text/InstalledFontCollection.cs
deleted file mode 100644 (file)
index 92f82f0..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.Text.InstalledFontCollection.cs
-//
-// (C) 2002 Ximian, Inc.  http://www.ximian.com
-// Author: Everaldo Canuto everaldo.canuto@bol.com.br
-//         Alexandre Pigolkine ( pigolkine@gmx.de)
-//                     Sanjay Gupta (gsanjay@novell.com)
-//
-// Copyright (C) 2004, 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,
-// 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.
-//
-
-namespace System.Drawing.Text {
-
-       public sealed class InstalledFontCollection : FontCollection {
-
-               public InstalledFontCollection ()
-               {
-                       Status status = GDIPlus.GdipNewInstalledFontCollection (out nativeFontCollection);                                              
-                       GDIPlus.CheckStatus (status);                   
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs b/mcs/class/System.Drawing/System.Drawing.Text/TextRenderingHint.cs
deleted file mode 100644 (file)
index 02af56c..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.TextRenderingHint.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2002 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.
-//
-
-namespace System.Drawing.Text {
-
-       public enum TextRenderingHint {
-               AntiAlias = 4,
-               AntiAliasGridFit = 3,
-               ClearTypeGridFit = 5,
-               SingleBitPerPixel = 2,
-               SingleBitPerPixelGridFit = 1,
-               SystemDefault = 0
-       }
-}
index 4ead07ffd3361ca799fdc9f5b2562223b6c35b4d..097b6cabc982f3ce751de57e7f27406802fc4a89 100755 (executable)
@@ -1,10 +1,23 @@
+corefx/SR.cs
+System.Drawing/SR.cs
 Assembly/AssemblyInfo.cs
 ../../build/common/Consts.cs
 ../../build/common/Locale.cs
+../../../external/corefx/src/System.Drawing.Common/src/misc/ClientUtils.cs
+../../../external/corefx/src/System.Drawing.Common/src/misc/HandleCollector.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Gdiplus.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/UnsafeNativeMethods.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPPOINT.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPPOINTF.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPRECT.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPRECTF.cs
+../../../external/corefx/src/System.Drawing.Common/src/AssemblyRef.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/ISystemEventTracker.cs
 System.Drawing/Bitmap.cs
-System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs
-System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
-System.Drawing/Brush.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSameAssemblyAttribute.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Brush.cs
 System.Drawing/Brushes.cs
 System.Drawing/BufferedGraphics.cs
 System.Drawing/BufferedGraphicsManager.cs
@@ -18,10 +31,11 @@ System.Drawing/ComIStreamMarshaler.cs
 System.Drawing/ComIStreamWrapper.cs
 System.Drawing/ContentAlignment.cs
 System.Drawing/CopyPixelOperation.cs
+System.Drawing/ExternDll.cs
 System.Drawing/Font.cs
 System.Drawing/FontConverter.cs
 System.Drawing/FontFamily.cs
-System.Drawing/FontStyle.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/FontStyle.cs
 System.Drawing/Graphics.cs
 System.Drawing/GraphicsUnit.cs
 System.Drawing/gdipEnums.cs
@@ -31,7 +45,7 @@ System.Drawing/KnownColor.cs
 System.Drawing/KnownColors.cs
 System.Drawing/IconConverter.cs
 System.Drawing/Icon.cs
-System.Drawing/IDeviceContext.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/IDeviceContext.cs
 System.Drawing/ImageAnimator.cs
 System.Drawing/ImageConverter.cs
 System.Drawing/Image.cs
@@ -45,151 +59,160 @@ System.Drawing/RectangleConverter.cs
 System.Drawing/Rectangle.cs
 System.Drawing/RectangleF.cs
 System.Drawing/Region.cs
-System.Drawing/RotateFlipType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/RotateFlipType.cs
 System.Drawing/SizeConverter.cs
 System.Drawing/Size.cs
 System.Drawing/SizeF.cs
 System.Drawing/SizeFConverter.cs
-System.Drawing/SolidBrush.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/SolidBrush.cs
 System.Drawing/SRDescriptionAttribute.cs
-System.Drawing/StringAligment.cs
-System.Drawing/StringDigitSubstitute.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/StringAlignment.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/StringDigitSubstitute.cs
 System.Drawing/StringFormat.cs
-System.Drawing/StringFormatFlags.cs
-System.Drawing/StringTrimming.cs
-System.Drawing/StringUnit.cs
-System.Drawing/SystemBrushes.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/StringFormatFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/StringTrimming.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/StringUnit.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs
 System.Drawing/SystemColors.cs
 System.Drawing/SystemFonts.cs
 System.Drawing/SystemIcons.cs
 System.Drawing/SystemPens.cs
-System.Drawing/TextureBrush.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/TextureBrush.cs
 System.Drawing/ToolboxBitmapAttribute.cs
-System.Drawing.Design/UITypeEditorEditStyle.cs
-System.Drawing.Design/IPropertyValueUIService.cs
-System.Drawing.Design/IToolboxItemProvider.cs
-System.Drawing.Design/PropertyValueItem.cs
-System.Drawing.Design/PropertyValueUIHandler.cs
-System.Drawing.Design/PropertyValueUIItemInvokeHandler.cs
-System.Drawing.Design/CategoryNameCollection.cs
-System.Drawing.Design/IToolboxService.cs
-System.Drawing.Design/IToolboxUser.cs 
-System.Drawing.Design/PaintValueEventArgs.cs
-System.Drawing.Design/ToolboxComponentsCreatedEventArgs.cs
-System.Drawing.Design/ToolboxComponentsCreatedEventHandler.cs
-System.Drawing.Design/ToolboxComponentsCreatingEventArgs.cs
-System.Drawing.Design/ToolboxComponentsCreatingEventHandler.cs
-System.Drawing.Design/ToolboxItemCreatorCallback.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/UITypeEditorEditStyle.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/IPropertyValueUIService.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/IToolboxItemProvider.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/PropertyValueUIItem.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/PropertyValueUIHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/PropertyValueUIItemInvokeHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/CategoryNameCollection.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/IToolboxService.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/IToolboxUser.cs 
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/PaintValueEventArgs.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/ToolboxComponentsCreatedEventArgs.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/ToolboxComponentsCreatedEventHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/ToolboxComponentsCreatingEventArgs.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/ToolboxComponentsCreatingEventHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/ToolboxItemCreatorCallback.cs
 System.Drawing.Design/ToolboxItem.cs
-System.Drawing.Design/UITypeEditor.cs
-System.Drawing.Design/ToolboxItemCollection.cs
-System.Drawing.Drawing2D/AdjustableArrowCap.cs
-System.Drawing.Drawing2D/Blend.cs
-System.Drawing.Drawing2D/ColorBlend.cs
-System.Drawing.Drawing2D/CombineMode.cs
-System.Drawing.Drawing2D/CompostingMode.cs
-System.Drawing.Drawing2D/CompostingQuality.cs
-System.Drawing.Drawing2D/CoordinateSpace.cs
-System.Drawing.Drawing2D/CustomLineCap.cs
-System.Drawing.Drawing2D/DashCap.cs
-System.Drawing.Drawing2D/DashStyle.cs
-System.Drawing.Drawing2D/FillMode.cs
-System.Drawing.Drawing2D/FlushIntention.cs
+       ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/UITypeEditor.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/ToolboxItemCollection.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/AdjustableArrowCap.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/Blend.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/BrushType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/ColorBlend.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CombineMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingQuality.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CoordinateSpace.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCapType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/DashCap.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/DashStyle.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/FillMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/FlushIntention.cs
 System.Drawing.Drawing2D/GraphicsContainer.cs
 System.Drawing.Drawing2D/GraphicsPath.cs
-System.Drawing.Drawing2D/GraphicsPathIterator.cs
-System.Drawing.Drawing2D/GraphicsState.cs
-System.Drawing.Drawing2D/HatchBrush.cs
-System.Drawing.Drawing2D/HatchStyle.cs
-System.Drawing.Drawing2D/InterpolationMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPathIterator.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsState.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchBrush.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchStyle.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/InterpolationMode.cs
 System.Drawing.Drawing2D/LinearGradientBrush.cs
-System.Drawing.Drawing2D/LinearGradientMode.cs
-System.Drawing.Drawing2D/LineCap.cs
-System.Drawing.Drawing2D/LineJoin.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LineCap.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/LineJoin.cs
 System.Drawing.Drawing2D/Matrix.cs
-System.Drawing.Drawing2D/MatrixOrder.cs
-System.Drawing.Drawing2D/PathData.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/MatrixOrder.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/PathData.cs
 System.Drawing.Drawing2D/PathGradientBrush.cs
-System.Drawing.Drawing2D/PathPointType.cs
-System.Drawing.Drawing2D/PenAlignment.cs
-System.Drawing.Drawing2D/PenType.cs
-System.Drawing.Drawing2D/PixelOffsetMode.cs
-System.Drawing.Drawing2D/QualityMode.cs
-System.Drawing.Drawing2D/RegionData.cs
-System.Drawing.Drawing2D/SmoothingMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/PathPointType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/InterpolationMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/PenAlignment.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/PenType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/PixelOffsetMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/QualityMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/RegionData.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/SmoothingMode.cs
 ../../build/common/MonoTODOAttribute.cs
-System.Drawing.Drawing2D/WarpMode.cs
-System.Drawing.Drawing2D/WrapMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/WrapMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/WarpMode.cs
 System.Drawing.Imaging/BitmapData.cs
-System.Drawing.Imaging/ColorAdjustType.cs
-System.Drawing.Imaging/ColorChannelFlag.cs
-System.Drawing.Imaging/ColorMap.cs
-System.Drawing.Imaging/ColorMapType.cs
-System.Drawing.Imaging/ColorMatrix.cs
-System.Drawing.Imaging/ColorMatrixFlag.cs
-System.Drawing.Imaging/ColorMode.cs
-System.Drawing.Imaging/ColorPalette.cs
-System.Drawing.Imaging/EmfPlusRecordType.cs
-System.Drawing.Imaging/EmfType.cs
-System.Drawing.Imaging/Encoder.cs
-System.Drawing.Imaging/EncoderParameter.cs
-System.Drawing.Imaging/EncoderParameters.cs
-System.Drawing.Imaging/EncoderParameterValueType.cs
-System.Drawing.Imaging/EncoderValue.cs
-System.Drawing.Imaging/FrameDimension.cs
-System.Drawing.Imaging/ImageAttributes.cs
-System.Drawing.Imaging/ImageCodecFlags.cs
-System.Drawing.Imaging/ImageCodecInfo.cs
-System.Drawing.Imaging/ImageFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorAdjustType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorChannelFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorMap.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorMapType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrixFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusRecordType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EmfType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterValueType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EncoderValue.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfo.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfoPrivate.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageFlags.cs
 System.Drawing.Imaging/ImageFormat.cs
-System.Drawing.Imaging/ImageLockMode.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/ImageLockMode.cs
 System.Drawing.Imaging/Metafile.cs
-System.Drawing.Imaging/MetafileFrameUnit.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileFrameUnit.cs
 System.Drawing.Imaging/MetafileHeader.cs
-System.Drawing.Imaging/MetafileType.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileType.cs
 System.Drawing.Imaging/MetaHeader.cs
-System.Drawing.Imaging/PaletteFlags.cs
-System.Drawing.Imaging/PixelFormat.cs
-System.Drawing.Imaging/PlayRecordCallback.cs
-System.Drawing.Imaging/PropertyItem.cs
-System.Drawing.Imaging/WmfPlaceableFileHeader.cs
-System.Drawing.Printing/Duplex.cs
-System.Drawing.Printing/InvalidPrinterException.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteFlags.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/PixelFormat.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/PlayRecordCallback.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/PropertyItem.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/Duplex.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.cs
 System.Drawing.Printing/MarginsConverter.cs
-System.Drawing.Printing/Margins.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/Margins.cs
 System.Drawing.Printing/PrintingServices.cs
 System.Drawing.Printing/PrintingServicesWin32.cs
 System.Drawing.Printing/PrintingServicesUnix.cs
 System.Drawing.Printing/PageSettings.cs
-System.Drawing.Printing/PaperKind.cs
-System.Drawing.Printing/PaperSize.cs
-System.Drawing.Printing/PaperSource.cs
-System.Drawing.Printing/PaperSourceKind.cs
-System.Drawing.Printing/PreviewPageInfo.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PaperKinds.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PaperSourceKind.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PreviewPageInfo.cs
 System.Drawing.Printing/PreviewPrintController.cs
 System.Drawing.Printing/PrintController.cs
 System.Drawing.Printing/PrintDocument.cs
-System.Drawing.Printing/PrinterResolution.cs
-System.Drawing.Printing/PrinterResolutionKind.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolutionKind.cs
 System.Drawing.Printing/PrinterSettings.cs
-System.Drawing.Printing/PrinterUnit.cs
-System.Drawing.Printing/PrinterUnitConvert.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnit.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnitConvert.cs
 System.Drawing.Printing/PrintEventArgs.cs
-System.Drawing.Printing/PrintEventHandler.cs
-System.Drawing.Printing/PrintingPermissionAttribute.cs
-System.Drawing.Printing/PrintingPermission.cs
-System.Drawing.Printing/PrintingPermissionLevel.cs
-System.Drawing.Printing/PrintAction.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintEventHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintingPermission.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintingPermissionAttribute.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintingPermissionLevel.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintAction.cs
 System.Drawing.Printing/PrintPageEventArgs.cs
-System.Drawing.Printing/PrintPageEventHandler.cs
-System.Drawing.Printing/PrintRange.cs
-System.Drawing.Printing/QueryPageSettingsEventArgs.cs
-System.Drawing.Printing/QueryPageSettingsEventHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventHandler.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintRange.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventArgs.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventHandler.cs
 System.Drawing.Printing/StandardPrintController.cs
-System.Drawing.Text/FontCollection.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Text/FontCollection.cs
 System.Drawing.Text/PrivateFontCollection.cs
-System.Drawing.Text/GenericFontFamilies.cs
-System.Drawing.Text/HotkeyPrefix.cs
-System.Drawing.Text/InstalledFontCollection.cs
-System.Drawing.Text/TextRenderingHint.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Text/GenericFontFamilies.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Text/HotkeyPrefix.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Text/InstalledFontCollection.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Text/TextRenderingHint.cs
 
diff --git a/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs b/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs
deleted file mode 100644 (file)
index a76f9d7..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// System.Drawing.BitmapSuffixInSameAssemblyAttribute.cs
-//
-// Authors:
-//   Andrés G. Aragoneses (knocte@gmail.com)
-//
-// Copyright (C) 2016 Andrés G. Aragoneses
-//
-// 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.ComponentModel;
-
-namespace System.Drawing
-{
-       [AttributeUsage (AttributeTargets.Assembly)]
-       public class BitmapSuffixInSameAssemblyAttribute : Attribute {
-
-               public BitmapSuffixInSameAssemblyAttribute ()
-                       : base ()
-               {
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs b/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
deleted file mode 100644 (file)
index 3c18cb1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// System.Drawing.BitmapSuffixInSatelliteAssemblyAttribute.cs
-//
-// Authors:
-//   Andrés G. Aragoneses (knocte@gmail.com)
-//
-// Copyright (C) 2016 Andrés G. Aragoneses
-//
-// 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.ComponentModel;
-
-namespace System.Drawing
-{
-       [AttributeUsage (AttributeTargets.Assembly)]
-       public class BitmapSuffixInSatelliteAssemblyAttribute : Attribute {
-
-               public BitmapSuffixInSatelliteAssemblyAttribute ()
-                       : base ()
-               {
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/Brush.cs b/mcs/class/System.Drawing/System.Drawing/Brush.cs
deleted file mode 100644 (file)
index 14612ff..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// System.Drawing.Brush.cs
-//
-// Authors:
-//   Miguel de Icaza (miguel@ximian.com)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,2006-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.
-//
-
-namespace System.Drawing {
-
-       public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable {
-
-               internal IntPtr nativeObject;
-
-               abstract public object Clone ();
-
-               internal Brush (IntPtr ptr)
-               {
-                        nativeObject = ptr;
-               }
-               
-               internal IntPtr NativeObject {
-                       get {
-                               return nativeObject;
-                       }
-                       set {
-                               nativeObject = value;
-                       }
-               }
-
-               protected Brush ()
-               {
-               }               
-
-               protected internal void SetNativeBrush (IntPtr brush)
-               {
-                       nativeObject = brush;
-               }
-
-               public void Dispose ()
-               {
-                       Dispose (true);
-                       System.GC.SuppressFinalize (this);
-               }
-
-               protected virtual void Dispose (bool disposing)
-               {
-                       // NOTE: this has been known to fail in the past (cairo)
-                       // but it's the only way to reclaim brush related memory
-                       if (nativeObject != IntPtr.Zero) {
-                               Status status = GDIPlus.GdipDeleteBrush (nativeObject);
-                               nativeObject = IntPtr.Zero;
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               ~Brush ()
-               {
-                       Dispose (false);
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/ExternDll.cs b/mcs/class/System.Drawing/System.Drawing/ExternDll.cs
new file mode 100644 (file)
index 0000000..2dd8f98
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// ExternDll.cs
+//
+// Author:
+//   Frederik Carlier (frederik.carlier@quamotion.mobi)
+//
+// Copyright (C) 2017 Quamotion bvba http://quamotion.mobi
+//
+
+//
+// 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.
+//
+
+namespace System.Drawing
+{
+       internal class ExternDll
+       { 
+               public const string Gdiplus = "gdiplus";                
+               public const string User32 = "user32";          
+               public const string Gdi32 = "gdi32";            
+               public const string Kernel32 = "kernel32";              
+               public const string Winspool = "winspool.drv";          
+               public const string Comdlg32 = "comdlg32.dll";          
+               public const string Comctl32 = "comctl32.dll";          
+               public const string Shell32 = "shell32.dll";            
+               public const string Oleaut32 = "oleaut32.dll";          
+       }
+}
index 31861d5123845aa92525989d58a76a31d2fa9a07..29d1192204c29fc1d25091ff9d85f30217be3999 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Drawing
                        }
 
                        setProperties (family, emSize, style, unit, charSet, isVertical);           
-                       Status status = GDIPlus.GdipCreateFont (family.NativeObject, emSize,  style, unit, out fontObject);
+                       Status status = GDIPlus.GdipCreateFont (family.NativeFamily, emSize,  style, unit, out fontObject);
                        
                        if (status == Status.FontStyleNotFound)
                                throw new ArgumentException (Locale.GetText ("Style {0} isn't supported by font {1}.", style.ToString (), familyName));
@@ -114,6 +114,11 @@ namespace System.Drawing
                        }
                }
 
+               internal void SetSystemFontName (string newSystemFontName)
+               {
+                       systemFontName = newSystemFontName;
+               }
+
                internal void unitConversion (GraphicsUnit fromUnit, GraphicsUnit toUnit, float nSrc, out float nTrg)
                {
                        float inchs = 0;
@@ -295,7 +300,7 @@ namespace System.Drawing
                        // no null checks, MS throws a NullReferenceException if original is null
                        setProperties (prototype.FontFamily, prototype.Size, newStyle, prototype.Unit, prototype.GdiCharSet, prototype.GdiVerticalFont);
                                
-                       Status status = GDIPlus.GdipCreateFont (_fontFamily.NativeObject, Size, Style, Unit, out fontObject);
+                       Status status = GDIPlus.GdipCreateFont (_fontFamily.NativeFamily, Size, Style, Unit, out fontObject);
                        GDIPlus.CheckStatus (status);                   
                }
 
@@ -337,7 +342,7 @@ namespace System.Drawing
 
                        Status status;
                        setProperties (family, emSize, style, unit, gdiCharSet,  gdiVerticalFont );             
-                       status = GDIPlus.GdipCreateFont (family.NativeObject, emSize,  style,   unit,  out fontObject);
+                       status = GDIPlus.GdipCreateFont (family.NativeFamily, emSize,  style,   unit,  out fontObject);
                        GDIPlus.CheckStatus (status);
                }
 
index fc56f466d91ec043b94bad258af0d3e7f5915d53..04f8c087e025ee757b8d13644f666063ff3cdf22 100644 (file)
@@ -75,6 +75,15 @@ namespace System.Drawing {
                        }
                }
 
+               // For CoreFX compatibility
+               internal IntPtr NativeFamily
+               {            
+                       get     
+                       {
+                               return nativeFontFamily;
+                       }
+               }
+
                public FontFamily (GenericFontFamilies genericFamily) 
                {
                        Status status;
diff --git a/mcs/class/System.Drawing/System.Drawing/FontStyle.cs b/mcs/class/System.Drawing/System.Drawing/FontStyle.cs
deleted file mode 100644 (file)
index 8c5f9c7..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.FontStyle.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       [Flags]
-       public enum FontStyle {
-               Regular   = 0,
-               Bold      = 1,
-               Italic    = 2,
-               Underline = 4,
-               Strikeout = 8
-       }
-}
index 9c002db4162f54a2d1b5456965123bec4d358ede..15df9cd343c0327ef095c725dd2519a92ea08cae 100644 (file)
@@ -91,6 +91,13 @@ namespace System.Drawing
                        }
                }
 
+               // For CoreFX compatibility
+               internal IntPtr NativeGraphics {
+                       get {
+                               return nativeObject;
+                       }
+               }
+
                internal IntPtr NativeObject {
                        get {
                                return nativeObject;
@@ -315,7 +322,7 @@ namespace System.Drawing
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
                        
-                       status = GDIPlus.GdipDrawArc (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawArc (nativeObject, pen.NativePen,
                                         x, y, width, height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
@@ -328,7 +335,7 @@ namespace System.Drawing
                        Status status;
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       status = GDIPlus.GdipDrawArcI (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawArcI (nativeObject, pen.NativePen,
                                                x, y, width, height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
@@ -338,7 +345,7 @@ namespace System.Drawing
                        Status status;
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawBezier (nativeObject, pen.NativePen,
                                                        pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
                                                        pt3.Y, pt4.X, pt4.Y);
                        GDIPlus.CheckStatus (status);
@@ -349,7 +356,7 @@ namespace System.Drawing
                        Status status;
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       status = GDIPlus.GdipDrawBezierI (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawBezierI (nativeObject, pen.NativePen,
                                                        pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X,
                                                        pt3.Y, pt4.X, pt4.Y);
                        GDIPlus.CheckStatus (status);
@@ -360,7 +367,7 @@ namespace System.Drawing
                        Status status;
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       status = GDIPlus.GdipDrawBezier (nativeObject, pen.nativeObject, x1,
+                       status = GDIPlus.GdipDrawBezier (nativeObject, pen.NativePen, x1,
                                                        y1, x2, y2, x3, y3, x4, y4);
                        GDIPlus.CheckStatus (status);
                }
@@ -385,7 +392,7 @@ namespace System.Drawing
                                 Point p4 = points [i + 3];
 
                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
-                                                       pen.nativeObject,
+                                                       pen.NativePen,
                                                         p1.X, p1.Y, p2.X, p2.Y, 
                                                         p3.X, p3.Y, p4.X, p4.Y);
                                GDIPlus.CheckStatus (status);
@@ -412,7 +419,7 @@ namespace System.Drawing
                                 PointF p4 = points [i + 3];
 
                                 status = GDIPlus.GdipDrawBezier (nativeObject, 
-                                                       pen.nativeObject,
+                                                       pen.NativePen,
                                                         p1.X, p1.Y, p2.X, p2.Y, 
                                                         p3.X, p3.Y, p4.X, p4.Y);
                                GDIPlus.CheckStatus (status);
@@ -428,7 +435,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.nativeObject, points, points.Length);
+                       status = GDIPlus.GdipDrawClosedCurve (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -440,7 +447,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.nativeObject, points, points.Length);
+                       status = GDIPlus.GdipDrawClosedCurveI (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
                        
@@ -454,7 +461,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);
+                       status = GDIPlus.GdipDrawClosedCurve2I (nativeObject, pen.NativePen, points, points.Length, tension);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -468,7 +475,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
+                       status = GDIPlus.GdipDrawClosedCurve2 (nativeObject, pen.NativePen, points, points.Length, tension);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -480,7 +487,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurveI (nativeObject, pen.nativeObject, points, points.Length);
+                       status = GDIPlus.GdipDrawCurveI (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -492,7 +499,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurve (nativeObject, pen.nativeObject, points, points.Length);
+                       status = GDIPlus.GdipDrawCurve (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -504,7 +511,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.nativeObject, points, points.Length, tension);
+                       status = GDIPlus.GdipDrawCurve2 (nativeObject, pen.NativePen, points, points.Length, tension);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -516,7 +523,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.nativeObject, points, points.Length, tension);              
+                       status = GDIPlus.GdipDrawCurve2I (nativeObject, pen.NativePen, points, points.Length, tension);         
                        GDIPlus.CheckStatus (status);
                }
                
@@ -528,7 +535,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.NativePen,
                                                        points, points.Length, offset,
                                                        numberOfSegments, 0.5f);
                        GDIPlus.CheckStatus (status);
@@ -542,7 +549,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawCurve3I (nativeObject, pen.NativePen,
                                                        points, points.Length, offset,
                                                        numberOfSegments, tension);
                        GDIPlus.CheckStatus (status);
@@ -556,7 +563,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("points");
                        
                        Status status;
-                       status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.nativeObject,
+                       status = GDIPlus.GdipDrawCurve3 (nativeObject, pen.NativePen,
                                                        points, points.Length, offset,
                                                        numberOfSegments, tension);
                        GDIPlus.CheckStatus (status);
@@ -582,7 +589,7 @@ namespace System.Drawing
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
                        Status status;
-                       status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.nativeObject, x, y, width, height);
+                       status = GDIPlus.GdipDrawEllipseI (nativeObject, pen.NativePen, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -590,7 +597,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.nativeObject, x, y, width, height);
+                       Status status = GDIPlus.GdipDrawEllipse (nativeObject, pen.NativePen, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -747,7 +754,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
                                destPoints, destPoints.Length , srcRect.X, srcRect.Y,
                                srcRect.Width, srcRect.Height, srcUnit,
-                               imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+                               imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -770,7 +777,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
                                destPoints, destPoints.Length , srcRect.X, srcRect.Y,
                                srcRect.Width, srcRect.Height, srcUnit, 
-                               imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+                               imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -807,7 +814,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
                                destPoints, destPoints.Length , srcRect.X, srcRect.Y,
                                srcRect.Width, srcRect.Height, srcUnit, 
-                               imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
+                               imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -821,7 +828,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
                                destPoints, destPoints.Length , srcRect.X, srcRect.Y,
                                srcRect.Width, srcRect.Height, srcUnit, 
-                               imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, IntPtr.Zero);
+                               imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -835,7 +842,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImagePointsRectI (nativeObject, image.NativeObject,
                                destPoints, destPoints.Length , srcRect.X, srcRect.Y, 
                                srcRect.Width, srcRect.Height, srcUnit, 
-                               imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
+                               imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, (IntPtr) callbackData);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -847,7 +854,7 @@ namespace System.Drawing
                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
                                        srcX, srcY, srcWidth, srcHeight, srcUnit, IntPtr.Zero, 
                                        null, IntPtr.Zero);
-                       GDIPlus.CheckStatus (status);                                   
+                       GDIPlus.CheckStatus (status);
                }
                
                public void DrawImage (Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
@@ -855,7 +862,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
                                destPoints, destPoints.Length , srcRect.X, srcRect.Y,
                                srcRect.Width, srcRect.Height, srcUnit, 
-                               imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
+                               imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback, (IntPtr) callbackData);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -877,7 +884,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
                                 destRect.X, destRect.Y, destRect.Width, destRect.Height,
                                        srcX, srcY, srcWidth, srcHeight, srcUnit,
-                               imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+                               imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -888,7 +895,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
                                         destRect.X, destRect.Y, destRect.Width, 
                                        destRect.Height, srcX, srcY, srcWidth, srcHeight,
-                                       srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, null, IntPtr.Zero);
+                                       srcUnit, imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, null, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -899,7 +906,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImageRectRectI (nativeObject, image.NativeObject, 
                                         destRect.X, destRect.Y, destRect.Width, 
                                        destRect.Height, srcX, srcY, srcWidth, srcHeight,
-                                       srcUnit, imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback,
+                                       srcUnit, imageAttr != null ? imageAttr.nativeImageAttributes : IntPtr.Zero, callback,
                                        IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
@@ -911,7 +918,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
                                         destRect.X, destRect.Y, destRect.Width, 
                                        destRect.Height, srcX, srcY, srcWidth, srcHeight,
-                                       srcUnit, imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, 
+                                       srcUnit, imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, 
                                        callback, IntPtr.Zero);
                        GDIPlus.CheckStatus (status);
                }
@@ -923,7 +930,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
                                destRect.X, destRect.Y, destRect.Width, destRect.Height,
                                srcX, srcY, srcWidth, srcHeight, srcUnit, 
-                               imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, callback, callbackData);
+                               imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, callback, callbackData);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -934,7 +941,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject, 
                                        destRect.X, destRect.Y, destRect.Width, destRect.Height,
                                srcX, srcY, srcWidth, srcHeight, srcUnit,
-                               imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, callback, callbackData);
+                               imageAttrs != null ? imageAttrs.nativeImageAttributes : IntPtr.Zero, callback, callbackData);
                        GDIPlus.CheckStatus (status);
                }               
                
@@ -987,7 +994,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                        Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject,
+                        Status status = GDIPlus.GdipDrawLine (nativeObject, pen.NativePen,
                                                pt1.X, pt1.Y, pt2.X, pt2.Y);
                        GDIPlus.CheckStatus (status);
                }
@@ -996,7 +1003,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                        Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject,
+                        Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.NativePen,
                                                pt1.X, pt1.Y, pt2.X, pt2.Y);
                        GDIPlus.CheckStatus (status);
                }
@@ -1005,7 +1012,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.nativeObject, x1, y1, x2, y2);
+                       Status status = GDIPlus.GdipDrawLineI (nativeObject, pen.NativePen, x1, y1, x2, y2);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1015,7 +1022,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("pen");
                        if (!float.IsNaN(x1) && !float.IsNaN(y1) &&
                            !float.IsNaN(x2) && !float.IsNaN(y2)) {
-                               Status status = GDIPlus.GdipDrawLine (nativeObject, pen.nativeObject, x1, y1, x2, y2);
+                               Status status = GDIPlus.GdipDrawLine (nativeObject, pen.NativePen, x1, y1, x2, y2);
                                GDIPlus.CheckStatus (status);
                        }
                }
@@ -1026,7 +1033,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("pen");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipDrawLines (nativeObject, pen.nativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipDrawLines (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1036,7 +1043,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("pen");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.nativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipDrawLinesI (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1046,7 +1053,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("pen");
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                       Status status = GDIPlus.GdipDrawPath (nativeObject, pen.nativeObject, path.nativePath);
+                       Status status = GDIPlus.GdipDrawPath (nativeObject, pen.NativePen, path.nativePath);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -1068,7 +1075,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       Status status = GDIPlus.GdipDrawPie (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
+                       Status status = GDIPlus.GdipDrawPie (nativeObject, pen.NativePen, x, y, width, height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -1079,7 +1086,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.nativeObject, x, y, width, height, startAngle, sweepAngle);
+                       Status status = GDIPlus.GdipDrawPieI (nativeObject, pen.NativePen, x, y, width, height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1089,7 +1096,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("pen");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.nativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipDrawPolygonI (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1099,7 +1106,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("pen");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.nativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipDrawPolygon (nativeObject, pen.NativePen, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1114,7 +1121,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.nativeObject, x, y, width, height);
+                       Status status = GDIPlus.GdipDrawRectangle (nativeObject, pen.NativePen, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1122,7 +1129,7 @@ namespace System.Drawing
                {
                        if (pen == null)
                                throw new ArgumentNullException ("pen");
-                       Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.nativeObject, x, y, width, height);
+                       Status status = GDIPlus.GdipDrawRectangleI (nativeObject, pen.NativePen, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1132,7 +1139,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("image");
                        if (rects == null)
                                throw new ArgumentNullException ("rects");
-                       Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.nativeObject, rects, rects.Length);
+                       Status status = GDIPlus.GdipDrawRectangles (nativeObject, pen.NativePen, rects, rects.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1142,7 +1149,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("image");
                        if (rects == null)
                                throw new ArgumentNullException ("rects");
-                       Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.nativeObject, rects, rects.Length);
+                       Status status = GDIPlus.GdipDrawRectanglesI (nativeObject, pen.NativePen, rects, rects.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1180,7 +1187,7 @@ namespace System.Drawing
                        if (s == null || s.Length == 0)
                                return;
 
-                       Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.nativeObject);
+                       Status status = GDIPlus.GdipDrawString (nativeObject, s, s.Length, font.NativeObject, ref layoutRectangle, format != null ? format.NativeObject : IntPtr.Zero, brush.NativeBrush);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1431,7 +1438,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipFillClosedCurve (nativeObject, brush.NativeBrush, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
                
@@ -1441,7 +1448,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipFillClosedCurveI (nativeObject, brush.NativeBrush, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1470,7 +1477,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
+                       Status status = GDIPlus.GdipFillClosedCurve2 (nativeObject, brush.NativeBrush, points, points.Length, tension, fillmode);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1480,7 +1487,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeObject, points, points.Length, tension, fillmode);
+                       Status status = GDIPlus.GdipFillClosedCurve2I (nativeObject, brush.NativeBrush, points, points.Length, tension, fillmode);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1502,7 +1509,7 @@ namespace System.Drawing
                {
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
-                        Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.nativeObject, x, y, width, height);
+                        Status status = GDIPlus.GdipFillEllipse (nativeObject, brush.NativeBrush, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1510,7 +1517,7 @@ namespace System.Drawing
                {
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
-                       Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.nativeObject, x, y, width, height);
+                       Status status = GDIPlus.GdipFillEllipseI (nativeObject, brush.NativeBrush, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1520,7 +1527,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                       Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeObject,  path.NativeObject);
+                       Status status = GDIPlus.GdipFillPath (nativeObject, brush.NativeBrush,  path.nativePath);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1528,7 +1535,7 @@ namespace System.Drawing
                {
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
-                       Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
+                       Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeBrush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1536,7 +1543,7 @@ namespace System.Drawing
                {
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
-                       Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
+                       Status status = GDIPlus.GdipFillPieI (nativeObject, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1544,7 +1551,7 @@ namespace System.Drawing
                {
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
-                       Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeObject, x, y, width, height, startAngle, sweepAngle);
+                       Status status = GDIPlus.GdipFillPie (nativeObject, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1554,7 +1561,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.nativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipFillPolygon2 (nativeObject, brush.NativeBrush, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1564,7 +1571,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.nativeObject, points, points.Length);
+                       Status status = GDIPlus.GdipFillPolygon2I (nativeObject, brush.NativeBrush, points, points.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1574,7 +1581,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.nativeObject, points, points.Length, fillMode);
+                       Status status = GDIPlus.GdipFillPolygonI (nativeObject, brush.NativeBrush, points, points.Length, fillMode);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1584,7 +1591,7 @@ namespace System.Drawing
                                throw new ArgumentNullException ("brush");
                        if (points == null)
                                throw new ArgumentNullException ("points");
-                       Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.nativeObject, points, points.Length, fillMode);
+                       Status status = GDIPlus.GdipFillPolygon (nativeObject, brush.NativeBrush, points, points.Length, fillMode);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1607,7 +1614,7 @@ namespace System.Drawing
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
                        
-                       Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.nativeObject, x, y, width, height);
+                       Status status = GDIPlus.GdipFillRectangleI (nativeObject, brush.NativeBrush, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1616,7 +1623,7 @@ namespace System.Drawing
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
                        
-                       Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.nativeObject, x, y, width, height);
+                       Status status = GDIPlus.GdipFillRectangle (nativeObject, brush.NativeBrush, x, y, width, height);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1627,7 +1634,7 @@ namespace System.Drawing
                        if (rects == null)
                                throw new ArgumentNullException ("rects");
 
-                       Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.nativeObject, rects, rects.Length);
+                       Status status = GDIPlus.GdipFillRectanglesI (nativeObject, brush.NativeBrush, rects, rects.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1638,7 +1645,7 @@ namespace System.Drawing
                        if (rects == null)
                                throw new ArgumentNullException ("rects");
 
-                       Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.nativeObject, rects, rects.Length);
+                       Status status = GDIPlus.GdipFillRectangles (nativeObject, brush.NativeBrush, rects, rects.Length);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -1650,7 +1657,7 @@ namespace System.Drawing
                        if (region == null)
                                throw new ArgumentNullException ("region");
                        
-                       Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeObject, region.NativeObject);                  
+                       Status status = GDIPlus.GdipFillRegion (nativeObject, brush.NativeBrush, region.NativeObject);                  
                         GDIPlus.CheckStatus(status);
                }
 
@@ -2049,7 +2056,7 @@ namespace System.Drawing
                public void Restore (GraphicsState gstate)
                {                       
                        // the possible NRE thrown by gstate.nativeState match MS behaviour
-                       Status status = GDIPlus.GdipRestoreGraphics (nativeObject, gstate.nativeState);
+                       Status status = GDIPlus.GdipRestoreGraphics (nativeObject, (uint)gstate.nativeState);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -2070,8 +2077,7 @@ namespace System.Drawing
                        Status status = GDIPlus.GdipSaveGraphics (nativeObject, out saveState);
                        GDIPlus.CheckStatus (status);
 
-                       GraphicsState state = new GraphicsState ();
-                       state.nativeState = saveState;
+                       GraphicsState state = new GraphicsState ((int)saveState);
                        return state;
                }
 
@@ -2148,7 +2154,7 @@ namespace System.Drawing
                {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                       Status status = GDIPlus.GdipSetClipPath (nativeObject, path.NativeObject, combineMode);
+                       Status status = GDIPlus.GdipSetClipPath (nativeObject, path.nativePath, combineMode);
                        GDIPlus.CheckStatus (status);
                }
 
diff --git a/mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs b/mcs/class/System.Drawing/System.Drawing/IDeviceContext.cs
deleted file mode 100644 (file)
index 795d703..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Copyright (C) 2005 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.
-//
-// Authors:
-//
-//   Jordi Mas i Hernandez <jordimash@gmail.com>
-//
-//
-
-
-using System.ComponentModel;
-
-namespace System.Drawing
-{
-       public interface IDeviceContext : IDisposable
-       {
-               IntPtr GetHdc ();
-               void ReleaseHdc ();             
-       }
-}
-
-
index 6bd89918dd66815ca07baedfa7a8a3762c54c53f..30ae8311b27c42a181ebda13387b4b387c9ed27d 100644 (file)
@@ -10,6 +10,7 @@
 //
 // Copyright (C) 2002 Ximian, Inc.  http://www.ximian.com
 // Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2013 Kristof Ralovich, changes are available under the terms of the MIT X11 license
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -168,6 +169,12 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                return img;
        }
 
+       // For compatiblity with CoreFX sources
+       internal static Image CreateImageObject (IntPtr nativeImage)
+       {
+               return CreateFromHandle (nativeImage);
+       }
+
        internal static Image CreateFromHandle (IntPtr handle)
        {
                ImageType type;
@@ -324,7 +331,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
 
                try {
                        status = GDIPlus.GdipGetEncoderParameterList (nativeObject, ref encoder, sz, rawEPList);
-                       eps = EncoderParameters.FromNativePtr (rawEPList);
+                       eps = EncoderParameters.ConvertFromMemory (rawEPList);
                        GDIPlus.CheckStatus (status);
                }
                finally {
@@ -450,7 +457,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                if (encoderParams == null) {
                        st = GDIPlus.GdipSaveImageToFile (nativeObject, filename, ref guid, IntPtr.Zero);
                } else {
-                       IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
+                       IntPtr nativeEncoderParams = encoderParams.ConvertToMemory ();
                        st = GDIPlus.GdipSaveImageToFile (nativeObject, filename, ref guid, nativeEncoderParams);
                        Marshal.FreeHGlobal (nativeEncoderParams);
                }
@@ -477,7 +484,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                if (encoderParams == null)
                        nativeEncoderParams = IntPtr.Zero;
                else
-                       nativeEncoderParams = encoderParams.ToNativePtr ();
+                       nativeEncoderParams = encoderParams.ConvertToMemory ();
 
                try {
                        if (GDIPlus.RunningOnUnix ()) {
@@ -501,7 +508,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
        {
                Status st;
                
-               IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
+               IntPtr nativeEncoderParams = encoderParams.ConvertToMemory ();
                st = GDIPlus.GdipSaveAdd (nativeObject, nativeEncoderParams);
                Marshal.FreeHGlobal (nativeEncoderParams);
                GDIPlus.CheckStatus (st);
@@ -511,7 +518,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
        {
                Status st;
                
-               IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
+               IntPtr nativeEncoderParams = encoderParams.ConvertToMemory ();
                st = GDIPlus.GdipSaveAddImage (nativeObject, image.NativeObject, nativeEncoderParams);
                Marshal.FreeHGlobal (nativeEncoderParams);
                GDIPlus.CheckStatus (st);
@@ -529,16 +536,30 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
 
        public void SetPropertyItem(PropertyItem propitem)
        {
-               throw new NotImplementedException ();
-/*
-               GdipPropertyItem pi = new GdipPropertyItem ();
-               GdipPropertyItem.MarshalTo (pi, propitem);
-               unsafe {
-                       Status status = GDIPlus.GdipSetPropertyItem (nativeObject, &pi);
+               if (propitem == null)
+                       throw new ArgumentNullException ("propitem");
+
+               int nItemSize =  Marshal.SizeOf (propitem.Value[0]);
+               int size = nItemSize * propitem.Value.Length;
+               IntPtr dest = Marshal.AllocHGlobal (size);
+               try {
+                       GdipPropertyItem pi = new GdipPropertyItem ();
+                       pi.id    = propitem.Id;
+                       pi.len   = propitem.Len;
+                       pi.type  = propitem.Type;
+
+                       Marshal.Copy (propitem.Value, 0, dest, size);
+                       pi.value = dest;
+
+                       unsafe {
+                               Status status = GDIPlus.GdipSetPropertyItem (nativeObject, &pi);
                        
-                       GDIPlus.CheckStatus (status);
+                               GDIPlus.CheckStatus (status);
+                       }
+               }
+               finally {
+                       Marshal.FreeHGlobal (dest);
                }
-*/
        }
 
        // properties   
@@ -611,7 +632,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                try {
                        st = GDIPlus.GdipGetImagePalette (nativeObject, palette_data, bytes);
                        GDIPlus.CheckStatus (st);
-                       ret.setFromGDIPalette (palette_data);
+                       ret.ConvertFromMemory (palette_data);
                        return ret;
                }
 
@@ -625,7 +646,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                if (palette == null) {
                        throw new ArgumentNullException("palette");
                }
-               IntPtr palette_data = palette.getGDIPalette();
+               IntPtr palette_data = palette.ConvertToMemory ();
                if (palette_data == IntPtr.Zero) {
                        return;
                }
@@ -776,6 +797,13 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
                        nativeObject = value;
                }
        }
+
+       // For compatiblity with CoreFX sources
+       internal IntPtr nativeImage {
+               get {
+                       return nativeObject;
+               }
+       }
        
        public void Dispose ()
        {
index 42b54b1dc813d379be9737c5f3e0f4e5c28dbc85..d5e0eb8fc5be5911297ff7a22b47a335a163afd6 100644 (file)
@@ -62,7 +62,7 @@ namespace System.Drawing
                        if (brush == null)
                                throw new ArgumentNullException ("brush");
 
-                       Status status = GDIPlus.GdipCreatePen2 (brush.nativeObject, width, GraphicsUnit.World, out nativeObject);
+                       Status status = GDIPlus.GdipCreatePen2 (brush.NativeBrush, width, GraphicsUnit.World, out nativeObject);
                        GDIPlus.CheckStatus (status);
                        color = Color.Empty;
                }
@@ -112,7 +112,7 @@ namespace System.Drawing
                                if (!isModifiable)
                                        throw new ArgumentException (Locale.GetText ("This Pen object can't be modified."));
 
-                               Status status = GDIPlus.GdipSetPenBrushFill (nativeObject, value.nativeObject);
+                               Status status = GDIPlus.GdipSetPenBrushFill (nativeObject, value.NativeBrush);
                                GDIPlus.CheckStatus (status);
                                color = Color.Empty;
                        }
@@ -175,7 +175,7 @@ namespace System.Drawing
 
                        set {
                                if (isModifiable) {
-                                       Status status = GDIPlus.GdipSetPenCustomEndCap (nativeObject, value.nativeObject);
+                                       Status status = GDIPlus.GdipSetPenCustomEndCap (nativeObject, value.nativeCap);
                                        GDIPlus.CheckStatus (status);
                                        endCap = value;
                                } else
@@ -190,7 +190,7 @@ namespace System.Drawing
 
                        set {
                                if (isModifiable) {
-                                       Status status = GDIPlus.GdipSetPenCustomStartCap (nativeObject, value.nativeObject);
+                                       Status status = GDIPlus.GdipSetPenCustomStartCap (nativeObject, value.nativeCap);
                                        GDIPlus.CheckStatus (status);
                                        startCap = value;
                                } else
@@ -425,6 +425,12 @@ namespace System.Drawing
                        }
                }
 
+               internal IntPtr NativePen {
+                       get {
+                               return nativeObject;
+                       }
+               }
+
                public object Clone ()
                {
                         IntPtr ptr;
index 0e3a550886ddc1a490b50acf0c336f1323eda9d9..ba84501da38cc33c473ff872f2a271125f927d46 100644 (file)
@@ -52,7 +52,7 @@ namespace System.Drawing
                {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                       Status status = GDIPlus.GdipCreateRegionPath (path.NativeObject, out nativeRegion);
+                       Status status = GDIPlus.GdipCreateRegionPath (path.nativePath, out nativeRegion);
                        GDIPlus.CheckStatus (status);
                }
 
@@ -87,7 +87,7 @@ namespace System.Drawing
                {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                       Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Union);
+                       Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.nativePath, CombineMode.Union);
                         GDIPlus.CheckStatus (status);                        
                }
 
@@ -120,7 +120,7 @@ namespace System.Drawing
                 {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Intersect);
+                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.nativePath, CombineMode.Intersect);
                         GDIPlus.CheckStatus (status);  
                }
 
@@ -151,7 +151,7 @@ namespace System.Drawing
                {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Complement);
+                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.nativePath, CombineMode.Complement);
                         GDIPlus.CheckStatus (status);  
                }
 
@@ -182,7 +182,7 @@ namespace System.Drawing
                {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Exclude);
+                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.nativePath, CombineMode.Exclude);
                         GDIPlus.CheckStatus (status);                                                   
                }
 
@@ -213,7 +213,7 @@ namespace System.Drawing
                {
                        if (path == null)
                                throw new ArgumentNullException ("path");
-                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.NativeObject, CombineMode.Xor);
+                        Status status = GDIPlus.GdipCombineRegionPath (nativeRegion, path.nativePath, CombineMode.Xor);
                         GDIPlus.CheckStatus (status);  
                }
 
@@ -554,8 +554,7 @@ namespace System.Drawing
                        status = GDIPlus.GdipGetRegionData (nativeRegion, buff, size, out filled);
                        GDIPlus.CheckStatus (status);                      
                        
-                       RegionData rgndata = new RegionData();
-                       rgndata.Data = buff;
+                       RegionData rgndata = new RegionData (buff);
                        
                        return rgndata;
                }
diff --git a/mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs b/mcs/class/System.Drawing/System.Drawing/RotateFlipType.cs
deleted file mode 100644 (file)
index e0afb64..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// System.Drawing.RotateFlipType .cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       public enum RotateFlipType {
-               RotateNoneFlipNone = 0,
-               Rotate180FlipXY    = 0,
-               Rotate90FlipNone   = 1,
-               Rotate270FlipXY    = 1,
-               Rotate180FlipNone  = 2,
-               RotateNoneFlipXY   = 2,
-               Rotate270FlipNone  = 3,
-               Rotate90FlipXY     = 3,
-               RotateNoneFlipX    = 4,
-               Rotate180FlipY     = 4,
-               Rotate90FlipX      = 5,
-               Rotate270FlipY     = 5,
-               Rotate180FlipX     = 6,
-               RotateNoneFlipY    = 6,
-               Rotate270FlipX     = 7,
-               Rotate90FlipY      = 7,
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/SR.cs b/mcs/class/System.Drawing/System.Drawing/SR.cs
new file mode 100644 (file)
index 0000000..c7d6bc6
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// SR.cs
+//
+// Author:
+//   Frederik Carlier (frederik.carlier@quamotion.mobi)
+//
+// Copyright (C) 2017 Quamotion bvba http://quamotion.mobi
+//
+
+//
+// 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.
+//
+
+partial class SR
+{
+       public static string Format (string format, params object[] args)
+       {
+               return string.Format (format, args);
+       } 
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs b/mcs/class/System.Drawing/System.Drawing/SolidBrush.cs
deleted file mode 100644 (file)
index f356be3..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-//
-// System.Drawing.SolidBrush.cs
-//
-// Author:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Alexandre Pigolkine(pigolkine@gmx.de)
-//   Ravindra (rkumar@novell.com)
-//
-// (C) 2002 Ximian, Inc.
-// Copyright (C) 2004, 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.
-//
-
-namespace System.Drawing {
-
-       public sealed class SolidBrush : Brush {
-               
-               internal bool isModifiable = true;
-               // we keep this cached because calling GdipGetSolidFillColor 
-               // wouldn't return a "named" color like SD is expected to do
-               private Color color;
-
-                internal SolidBrush (IntPtr ptr)
-                        : base (ptr)
-                {
-                       int val;
-                       Status status = GDIPlus.GdipGetSolidFillColor (ptr, out val);
-                       GDIPlus.CheckStatus (status);
-                       color = Color.FromArgb (val);
-                }
-
-               public SolidBrush (Color color)
-                {
-                       this.color = color;
-                       Status status = GDIPlus.GdipCreateSolidFill (color.ToArgb (), out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public Color Color {
-                       get {
-                               return color;
-                       }
-                       set {
-                               if (isModifiable) {
-                                       color = value;
-                                       Status status = GDIPlus.GdipSetSolidFillColor (nativeObject, value.ToArgb ());
-                                       GDIPlus.CheckStatus (status);
-                               }
-                               else
-                                       throw new ArgumentException (Locale.GetText ("This SolidBrush object can't be modified."));
-                       }
-               }
-               
-               public override object Clone ()
-               {
-                       IntPtr clonePtr;
-                       Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
-                       GDIPlus.CheckStatus (status);
-                       // we loose the named color in this case (but so does MS SD)
-                       return new SolidBrush (clonePtr);
-               }
-               
-               protected override void Dispose (bool disposing)
-               {
-                       if (disposing && !isModifiable)
-                               throw new ArgumentException (Locale.GetText ("This SolidBrush object can't be modified."));
-
-                       base.Dispose (disposing); 
-               }
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringAligment.cs b/mcs/class/System.Drawing/System.Drawing/StringAligment.cs
deleted file mode 100644 (file)
index 6b2080c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// System.Drawing.StringAligment.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       public enum StringAlignment {
-               Near = 0,
-               Center = 1,
-               Far = 2 
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs b/mcs/class/System.Drawing/System.Drawing/StringDigitSubstitute.cs
deleted file mode 100644 (file)
index ab15c27..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// System.Drawing.StringDigitSubstitute.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       public enum StringDigitSubstitute {
-               User        = 0,
-               None        = 1,
-               National    = 2,
-               Traditional = 3
-       }
-}
index 7e9a218f990f33eb2f2679bbd78d771566b8bf0d..9a130c67523a611d912fe7019306d5a9940a0177 100644 (file)
@@ -261,6 +261,14 @@ namespace System.Drawing {
                        }
                }
 
+               // For CoreFX compat
+               internal IntPtr nativeFormat
+                {            
+                       get{
+                               return nativeStrFmt;
+                       }
+               }
+
                 public void SetTabStops(float firstTabOffset, float[] tabStops)
                 {
                        Status status = GDIPlus.GdipSetStringFormatTabStops(nativeStrFmt, firstTabOffset, tabStops.Length, tabStops);
diff --git a/mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs b/mcs/class/System.Drawing/System.Drawing/StringFormatFlags.cs
deleted file mode 100644 (file)
index 7b025a2..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// System.Drawing.StringFormatFlags.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       [Flags]
-       public enum StringFormatFlags {
-               DirectionRightToLeft  = 0x0001,
-               DirectionVertical     = 0x0002,
-               FitBlackBox           = 0x0004,
-               DisplayFormatControl  = 0x0020,
-               NoFontFallback        = 0x0400,
-               MeasureTrailingSpaces = 0x0800,
-               NoWrap                = 0x1000,
-               LineLimit             = 0x2000,
-               NoClip                = 0x4000
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringTrimming.cs b/mcs/class/System.Drawing/System.Drawing/StringTrimming.cs
deleted file mode 100644 (file)
index 0b76d72..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// System.Drawing.StringTrimming.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       public enum  StringTrimming {
-               None              = 0,
-               Character         = 1,
-               Word              = 2,
-               EllipsisCharacter = 3,
-               EllipsisWord      = 4,
-               EllipsisPath      = 5
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/StringUnit.cs b/mcs/class/System.Drawing/System.Drawing/StringUnit.cs
deleted file mode 100644 (file)
index c9bbf98..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// System.Drawing.StringUnit.cs
-//
-// Author: Dennis Hayes (dennish@raytek.com)
-//
-// (C) 2001 Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004,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,
-// 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.
-//
-
-namespace System.Drawing {
-
-       public enum  StringUnit{
-               World      = 0x00,
-               Display    = 0x01,
-               Pixel      = 0x02,
-               Point      = 0x03,
-               Inch       = 0x04,
-               Document   = 0x05,
-               Millimeter = 0x06,
-               Em         = 0x20
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs b/mcs/class/System.Drawing/System.Drawing/SystemBrushes.cs
deleted file mode 100644 (file)
index abb365a..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-//
-// System.Drawing.SystemBrushes.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//   Jordi Mas i Hernandez <jordimash@gmail.com>
-//
-// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc. http://www.novell.com
-//
-
-//
-// Copyright (C) 2004-2005 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.Drawing
-{
-       /// <summary>
-       /// Summary description for SystemBrushes.
-       /// </summary>
-       public sealed class SystemBrushes
-       {
-               static SolidBrush active_border;
-               static SolidBrush active_caption;
-               static SolidBrush active_caption_text;
-               static SolidBrush app_workspace;
-               static SolidBrush control;
-               static SolidBrush control_dark;
-               static SolidBrush control_dark_dark;
-               static SolidBrush control_light;
-               static SolidBrush control_light_light;
-               static SolidBrush control_text;
-               static SolidBrush desktop;
-               static SolidBrush highlight;
-               static SolidBrush highlight_text;
-               static SolidBrush hot_track;
-               static SolidBrush inactive_border;
-               static SolidBrush inactive_caption;
-               static SolidBrush info;
-               static SolidBrush menu;
-               static SolidBrush scroll_bar;
-               static SolidBrush window;
-               static SolidBrush window_text;
-               static SolidBrush button_face;
-               static SolidBrush button_highlight;
-               static SolidBrush button_shadow;
-               static SolidBrush gradient_activecaption;
-               static SolidBrush gradient_inactivecaption;
-               static SolidBrush graytext;
-               static SolidBrush inactive_captiontext;
-               static SolidBrush infotext;
-               static SolidBrush menubar;
-               static SolidBrush menu_highlight;
-               static SolidBrush menu_text;            
-               static SolidBrush window_fame;
-               private SystemBrushes() { }
-
-               public static Brush ActiveBorder
-               {       
-                       get {
-                               if (active_border == null) {
-                                       active_border = new SolidBrush (SystemColors.ActiveBorder);
-                                       active_border.isModifiable = false;
-                               }
-
-                               return active_border;
-                       }
-               }
-
-               public static Brush ActiveCaption
-               {       
-                       get {
-                               if (active_caption == null) {
-                                       active_caption = new SolidBrush (SystemColors.ActiveCaption);
-                                       active_caption.isModifiable = false;
-                               }
-
-                               return active_caption;
-                       }
-               }
-
-               public static Brush ActiveCaptionText
-               {       
-                       get {
-                               if (active_caption_text == null) {
-                                       active_caption_text = new SolidBrush (SystemColors.ActiveCaptionText);
-                                       active_caption_text.isModifiable = false;
-                               }
-
-                               return active_caption_text;
-                       }
-               }
-
-               public static Brush AppWorkspace
-               {       
-                       get {
-                               if (app_workspace == null) {
-                                       app_workspace = new SolidBrush (SystemColors.AppWorkspace);
-                                       app_workspace.isModifiable = false;
-                               }
-
-                               return app_workspace;
-                       }
-               }
-
-               public static Brush Control {
-                       get {
-                               if (control == null) {
-                                       control = new SolidBrush (SystemColors.Control);
-                                       control.isModifiable = false;
-                               }
-
-                               return control;
-                       }
-               }
-               
-               public static Brush ControlLight {
-                       get {
-                               if (control_light == null) {
-                                       control_light = new SolidBrush (SystemColors.ControlLight);
-                                       control_light.isModifiable = false;
-                               }
-
-                               return control_light;
-                       }
-               }
-               
-               public static Brush ControlLightLight {
-                       get {
-                               if (control_light_light == null) {
-                                       control_light_light = new SolidBrush (SystemColors.ControlLightLight);
-                                       control_light_light.isModifiable = false;
-                               }
-
-                               return control_light_light;
-                       }
-               }
-
-               public static Brush ControlDark {
-                       get {
-                               if (control_dark == null) {
-                                       control_dark = new SolidBrush (SystemColors.ControlDark);
-                                       control_dark.isModifiable = false;
-                               }
-
-                               return control_dark;
-                       }
-               }
-               
-               public static Brush ControlDarkDark {
-                       get {
-                               if (control_dark_dark == null) {
-                                       control_dark_dark = new SolidBrush (SystemColors.ControlDarkDark);
-                                       control_dark_dark.isModifiable = false;
-                               }
-
-                               return control_dark_dark;
-                       }
-               }
-
-               public static Brush ControlText {
-                       get {
-                               if (control_text == null) {
-                                       control_text = new SolidBrush (SystemColors.ControlText);
-                                       control_text.isModifiable = false;
-                               }
-
-                               return control_text;
-                       }
-               }
-
-               public static Brush Highlight {
-                       get {
-                               if (highlight == null) {
-                                       highlight = new SolidBrush (SystemColors.Highlight);
-                                       highlight.isModifiable = false;
-                               }
-
-                               return highlight;
-                       }
-               }
-
-               public static Brush HighlightText {
-                       get {
-                               if (highlight_text == null) {
-                                       highlight_text = new SolidBrush (SystemColors.HighlightText);
-                                       highlight_text.isModifiable = false;
-                               }
-
-                               return highlight_text;
-                       }
-               }
-
-               public static Brush Window {
-                       get {
-                               if (window == null) {
-                                       window = new SolidBrush (SystemColors.Window);
-                                       window.isModifiable = false;
-                               }
-
-                               return window;
-                       }
-               }
-               public static Brush WindowText {
-                       get {
-                               if (window_text == null) {
-                                       window_text = new SolidBrush (SystemColors.WindowText);
-                                       window_text.isModifiable = false;
-                               }
-
-                               return window_text;
-                       }
-               }
-
-               public static Brush InactiveBorder {
-                       get {
-                               if (inactive_border == null) {
-                                       inactive_border = new SolidBrush (SystemColors.InactiveBorder);
-                                       inactive_border.isModifiable = false;
-                               }
-
-                               return inactive_border;
-                       }
-               }
-
-               public static Brush Desktop {
-                       get {
-                               if (desktop == null) {
-                                       desktop = new SolidBrush (SystemColors.Desktop);
-                                       desktop.isModifiable = false;
-                               }
-
-                               return desktop;
-                       }
-               }
-
-               public static Brush HotTrack {
-                       get {
-                               if (hot_track == null) {
-                                       hot_track = new SolidBrush (SystemColors.HotTrack);
-                                       hot_track.isModifiable = false;
-                               }
-
-                               return hot_track;
-                       }
-               }
-
-               public static Brush InactiveCaption {
-                       get {
-                               if (inactive_caption == null) {
-                                       inactive_caption = new SolidBrush (SystemColors.InactiveCaption);
-                                       inactive_caption.isModifiable = false;
-                               }
-
-                               return inactive_caption;
-                       }
-               }
-               
-               public static Brush Info {
-                       get {
-                               if (info == null) {
-                                       info = new SolidBrush (SystemColors.Info);
-                                       info.isModifiable = false;
-                               }
-
-                               return info;
-                       }
-               }
-               
-               public static Brush Menu {
-                       get {
-                               if (menu == null) {
-                                       menu = new SolidBrush (SystemColors.Menu);
-                                       menu.isModifiable = false;
-                               }
-
-                               return menu;
-                       }
-               }
-               
-               public static Brush ScrollBar {
-                       get {
-                               if (scroll_bar == null) {
-                                       scroll_bar = new SolidBrush (SystemColors.ScrollBar);
-                                       scroll_bar.isModifiable = false;
-                               }
-
-                               return scroll_bar;
-                       }
-               }
-
-               public static Brush FromSystemColor (Color c) 
-               {
-                       if (c.IsSystemColor) {
-                               SolidBrush newBrush = new SolidBrush (c);
-                               newBrush.isModifiable = false;
-                               return newBrush;
-                       }
-
-                       String message = String.Format ("The color {0} is not a system color.", c);
-                       throw new ArgumentException (message);
-               }
-
-               public static Brush ButtonFace {
-                       get {
-                               if (button_face == null) {
-                                       button_face = new SolidBrush (SystemColors.ButtonFace);
-                                       button_face.isModifiable = false;
-                               }
-
-                               return button_face;
-                       }
-               }
-
-               public static Brush ButtonHighlight {
-                       get {
-                               if (button_highlight == null) {
-                                       button_highlight = new SolidBrush (SystemColors.ButtonHighlight);
-                                       button_highlight.isModifiable = false;
-                               }
-
-                               return button_highlight;
-                       }
-               }
-
-               public static Brush ButtonShadow {
-                       get {
-                               if (button_shadow == null) {
-                                       button_shadow = new SolidBrush (SystemColors.ButtonShadow);
-                                       button_shadow.isModifiable = false;
-                               }
-
-                               return button_shadow;
-                       }
-               }
-
-               public static Brush GradientActiveCaption {
-                       get {
-                               if (gradient_activecaption == null) {
-                                       gradient_activecaption = new SolidBrush (SystemColors.GradientActiveCaption);
-                                       gradient_activecaption.isModifiable = false;
-                               }
-
-                               return gradient_activecaption;
-                       }
-               }
-
-               public static Brush GradientInactiveCaption {
-                       get {
-                               if (gradient_inactivecaption == null) {
-                                       gradient_inactivecaption = new SolidBrush (SystemColors.GradientInactiveCaption);
-                                       gradient_inactivecaption.isModifiable = false;
-                               }
-
-                               return gradient_inactivecaption;
-                       }
-               }
-
-               public static Brush GrayText {
-                       get {
-                               if (graytext == null) {
-                                       graytext = new SolidBrush (SystemColors.GrayText);
-                                       graytext.isModifiable = false;
-                               }
-
-                               return graytext;
-                       }
-               }
-
-               public static Brush InactiveCaptionText {
-                       get {
-                               if (inactive_captiontext == null) {
-                                       inactive_captiontext = new SolidBrush (SystemColors.InactiveCaptionText);
-                                       inactive_captiontext.isModifiable = false;
-                               }
-
-                               return inactive_captiontext;
-                       }
-               }
-
-               public static Brush InfoText {
-                       get {
-                               if (infotext == null) {
-                                       infotext = new SolidBrush (SystemColors.InfoText);
-                                       infotext.isModifiable = false;
-                               }
-
-                               return infotext;
-                       }
-               }
-
-               public static Brush MenuBar {
-                       get {
-                               if (menubar == null) {
-                                       menubar = new SolidBrush (SystemColors.MenuBar);
-                                       menubar.isModifiable = false;
-                               }
-
-                               return menubar;
-                       }
-               }
-
-               public static Brush MenuHighlight {
-                       get {
-                               if (menu_highlight == null) {
-                                       menu_highlight = new SolidBrush (SystemColors.MenuHighlight);
-                                       menu_highlight.isModifiable = false;
-                               }
-
-                               return menu_highlight;
-                       }
-               }
-
-               public static Brush MenuText {
-                       get {
-                               if (menu_text == null) {
-                                       menu_text = new SolidBrush (SystemColors.MenuText);
-                                       menu_text.isModifiable = false;
-                               }
-
-                               return menu_text;
-                       }
-               }
-
-               public static Brush WindowFrame {
-                       get {
-                               if (window_fame == null) {
-                                       window_fame = new SolidBrush (SystemColors.WindowFrame);
-                                       window_fame.isModifiable = false;
-                               }
-
-                               return window_fame;
-                       }
-               }
-
-       }
-}
diff --git a/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs b/mcs/class/System.Drawing/System.Drawing/TextureBrush.cs
deleted file mode 100644 (file)
index 3982e57..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-//
-// System.Drawing.TextureBrush.cs
-//
-// Authors:
-//   Dennis Hayes (dennish@Raytek.com)
-//   Ravindra (rkumar@novell.com)
-//   Sebastien Pouliot  <sebastien@ximian.com>
-//
-// (C) 2002 Ximian, Inc
-// Copyright (C) 2004,2006-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.
-//
-
-using System.ComponentModel;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-
-namespace System.Drawing {
-
-       public sealed class TextureBrush : Brush {
-
-               internal TextureBrush (IntPtr ptr) :
-                       base (ptr)
-               {
-               }
-
-               public TextureBrush (Image bitmap) :
-                       this (bitmap, WrapMode.Tile)
-               {
-               }
-
-               public TextureBrush (Image image, Rectangle dstRect) :
-                       this (image, WrapMode.Tile, dstRect)
-               {
-               }
-
-               public TextureBrush (Image image, RectangleF dstRect) :
-                       this (image, WrapMode.Tile, dstRect)
-               {
-               }
-
-               public TextureBrush (Image image, WrapMode wrapMode)
-               {
-                       if (image == null)
-                               throw new ArgumentNullException ("image");
-                       if ((wrapMode < WrapMode.Tile) || (wrapMode > WrapMode.Clamp))
-                               throw new InvalidEnumArgumentException ("WrapMode");
-
-                       Status status = GDIPlus.GdipCreateTexture (image.nativeObject, wrapMode, out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               [MonoLimitation ("ImageAttributes are ignored when using libgdiplus")]
-               public TextureBrush (Image image, Rectangle dstRect, ImageAttributes imageAttr)
-               {
-                       if (image == null)
-                               throw new ArgumentNullException ("image");
-
-                       IntPtr attr = imageAttr == null ? IntPtr.Zero : imageAttr.NativeObject;
-                       Status status = GDIPlus.GdipCreateTextureIAI (image.nativeObject, attr, dstRect.X, dstRect.Y, 
-                               dstRect.Width, dstRect.Height, out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               [MonoLimitation ("ImageAttributes are ignored when using libgdiplus")]
-               public TextureBrush (Image image, RectangleF dstRect, ImageAttributes imageAttr)
-               {       
-                       if (image == null)
-                               throw new ArgumentNullException ("image");
-
-                       IntPtr attr = imageAttr == null ? IntPtr.Zero : imageAttr.NativeObject;
-                       Status status = GDIPlus.GdipCreateTextureIA (image.nativeObject, attr, dstRect.X, dstRect.Y, 
-                               dstRect.Width, dstRect.Height, out nativeObject);
-                       GDIPlus.CheckStatus (status);                   
-               }
-
-               public TextureBrush (Image image, WrapMode wrapMode, Rectangle dstRect)
-               {
-                       if (image == null)
-                               throw new ArgumentNullException ("image");
-                       if ((wrapMode < WrapMode.Tile) || (wrapMode > WrapMode.Clamp))
-                               throw new InvalidEnumArgumentException ("WrapMode");
-
-                       Status status = GDIPlus.GdipCreateTexture2I (image.nativeObject, wrapMode, dstRect.X, dstRect.Y, 
-                               dstRect.Width, dstRect.Height, out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public TextureBrush (Image image, WrapMode wrapMode, RectangleF dstRect)
-               {
-                       if (image == null)
-                               throw new ArgumentNullException ("image");
-                       if ((wrapMode < WrapMode.Tile) || (wrapMode > WrapMode.Clamp))
-                               throw new InvalidEnumArgumentException ("WrapMode");
-
-                       Status status = GDIPlus.GdipCreateTexture2 (image.nativeObject, wrapMode, dstRect.X, dstRect.Y, 
-                               dstRect.Width, dstRect.Height, out nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               // properties
-
-               public Image Image {
-                       get {
-                               // this check is required here as GDI+ doesn't check for it 
-                               if (nativeObject == IntPtr.Zero)
-                                       throw new ArgumentException ("Object was disposed");
-
-                               IntPtr img;
-                               Status status = GDIPlus.GdipGetTextureImage (nativeObject, out img);
-                               GDIPlus.CheckStatus (status);
-                               return new Bitmap (img);
-                       }
-               }
-
-               public Matrix Transform {
-                       get {
-                               Matrix matrix = new Matrix ();
-                               Status status = GDIPlus.GdipGetTextureTransform (nativeObject, matrix.nativeMatrix);
-                               GDIPlus.CheckStatus (status);
-
-                               return matrix;
-                       }
-                       set {
-                               if (value == null)
-                                       throw new ArgumentNullException ("Transform");
-
-                               Status status = GDIPlus.GdipSetTextureTransform (nativeObject, value.nativeMatrix);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               public WrapMode WrapMode {
-                       get {
-                               WrapMode mode;
-                               Status status = GDIPlus.GdipGetTextureWrapMode (nativeObject, out mode);
-                               GDIPlus.CheckStatus (status);
-                               return mode;
-                       }
-                       set {
-                               if ((value < WrapMode.Tile) || (value > WrapMode.Clamp))
-                                       throw new InvalidEnumArgumentException ("WrapMode");
-
-                               Status status = GDIPlus.GdipSetTextureWrapMode (nativeObject, value);
-                               GDIPlus.CheckStatus (status);
-                       }
-               }
-
-               // public methods
-
-               public override object Clone ()
-               {
-                       IntPtr clonePtr;
-                       Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
-                       GDIPlus.CheckStatus (status);
-
-                       return new TextureBrush (clonePtr);
-               }
-
-               public void MultiplyTransform (Matrix matrix)
-               {
-                       MultiplyTransform (matrix, MatrixOrder.Prepend);
-               }
-
-               public void MultiplyTransform (Matrix matrix, MatrixOrder order)
-               {
-                       if (matrix == null)
-                               throw new ArgumentNullException ("matrix");
-
-                       Status status = GDIPlus.GdipMultiplyTextureTransform (nativeObject, matrix.nativeMatrix, order);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ResetTransform ()
-               {
-                       Status status = GDIPlus.GdipResetTextureTransform (nativeObject);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void RotateTransform (float angle)
-               {
-                       RotateTransform (angle, MatrixOrder.Prepend);
-               }
-
-               public void RotateTransform (float angle, MatrixOrder order)
-               {
-                       Status status = GDIPlus.GdipRotateTextureTransform (nativeObject, angle, order);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void ScaleTransform (float sx, float sy)
-               {
-                       ScaleTransform (sx, sy, MatrixOrder.Prepend);
-               }
-
-               public void ScaleTransform (float sx, float sy, MatrixOrder order)
-               {
-                       Status status = GDIPlus.GdipScaleTextureTransform (nativeObject, sx, sy, order);
-                       GDIPlus.CheckStatus (status);
-               }
-
-               public void TranslateTransform (float dx, float dy)
-               {
-                       TranslateTransform (dx, dy, MatrixOrder.Prepend);
-               }
-
-               public void TranslateTransform (float dx, float dy, MatrixOrder order)
-               {
-                       Status status = GDIPlus.GdipTranslateTextureTransform (nativeObject, dx, dy, order);
-                       GDIPlus.CheckStatus (status);
-               }
-       }
-}
index 4b7cf62280f8cf5ee961798a8d2ddc8f541ff3a8..bbde755ab8ad0612d194bbe436e7dee7d649a5c7 100644 (file)
@@ -1,5 +1,22 @@
 ../../test-helpers/NunitHelpers.cs
 ../../../build/common/Locale.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Gdiplus.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/NativeMethods.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/UnsafeNativeMethods.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPPOINT.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPPOINTF.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPRECT.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Internal/GPRECTF.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCapType.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/PropertyItem.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
+../../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusFlags.cs
+../../../../external/corefx/src/System.Drawing.Common/src/misc/HandleCollector.cs
+../corefx/SR.cs
+../System.Drawing/SR.cs
+../System.Drawing/ExternDll.cs
 ../System.Drawing/gdipEnums.cs    
 ../System.Drawing/gdipFunctions.cs
 ../System.Drawing/gdipStructs.cs
diff --git a/mcs/class/System.Drawing/corefx/SR.cs b/mcs/class/System.Drawing/corefx/SR.cs
new file mode 100644 (file)
index 0000000..9575948
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// This file was generated by resx2sr tool
+//
+
+partial class SR
+{
+       public const string CantTellPrinterName = "(printer name protected due to security restrictions)";
+       public const string CantChangeImmutableObjects = "Changes cannot be made to {0} because permissions are not valid.";
+       public const string CantMakeIconTransparent = "Bitmaps that are icons cannot be made transparent. Icons natively support transparency. Use the Icon constructor to create an icon.";
+       public const string ColorNotSystemColor = "The color {0} is not a system color.";
+       public const string DotNET_ComponentType = ".NET Component";
+       public const string GdiplusAborted = "Function was ended.";
+       public const string GdiplusAccessDenied = "File access is denied.";
+       public const string GdiplusCannotCreateGraphicsFromIndexedPixelFormat = "A Graphics object cannot be created from an image that has an indexed pixel format.";
+       public const string GdiplusCannotSetPixelFromIndexedPixelFormat = "SetPixel is not supported for images with indexed pixel formats.";
+       public const string GdiplusDestPointsInvalidParallelogram = "Destination points define a parallelogram which must have a length of 3. These points will represent the upper-left, upper-right, and lower-left coordinates (defined in that order).";
+       public const string GdiplusDestPointsInvalidLength = "Destination points must be an array with a length of 3 or 4. A length of 3 defines a parallelogram with the upper-left, upper-right, and lower-left corners. A length of 4 defines a quadrilateral with the fourth element of the array specifying the lower-right coordinate.";
+       public const string GdiplusFileNotFound = "File not found.";
+       public const string GdiplusFontFamilyNotFound = "Font '{0}' cannot be found.";
+       public const string GdiplusFontStyleNotFound = "Font '{0}' does not support style '{1}'.";
+       public const string GdiplusGenericError = "A generic error occurred in GDI+.";
+       public const string GdiplusInsufficientBuffer = "Buffer is too small (internal GDI+ error).";
+       public const string GdiplusInvalidParameter = "Parameter is not valid.";
+       public const string GdiplusInvalidRectangle = "Rectangle '{0}' cannot have a width or height equal to 0.";
+       public const string GdiplusInvalidSize = "Operation requires a transformation of the image from GDI+ to GDI. GDI does not support images with a width or height greater than 32767.";
+       public const string GdiplusOutOfMemory = "Out of memory.";
+       public const string GdiplusNotImplemented = "Not implemented.";
+       public const string GdiplusNotInitialized = "GDI+ is not properly initialized (internal GDI+ error).";
+       public const string GdiplusNotTrueTypeFont = "Only TrueType fonts are supported. '{0}' is not a TrueType font.";
+       public const string GdiplusNotTrueTypeFont_NoName = "Only TrueType fonts are supported. This is not a TrueType font.";
+       public const string GdiplusObjectBusy = "Object is currently in use elsewhere.";
+       public const string GdiplusOverflow = "Overflow error.";
+       public const string GdiplusPropertyNotFoundError = "Property cannot be found.";
+       public const string GdiplusPropertyNotSupportedError = "Property is not supported.";
+       public const string GdiplusUnknown = "Unknown GDI+ error occurred.";
+       public const string GdiplusUnknownImageFormat = "Image format is unknown.";
+       public const string GdiplusUnsupportedGdiplusVersion = "Current version of GDI+ does not support this feature.";
+       public const string GdiplusWrongState = "Bitmap region is already locked.";
+       public const string GlobalAssemblyCache = " (Global Assembly Cache)";
+       public const string GraphicsBufferCurrentlyBusy = "BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.";
+       public const string GraphicsBufferQueryFail = "Screen-compatible bitmap cannot be created. The screen bitmap format cannot be determined.";
+       public const string ToolboxItemLocked = "Toolbox item cannot be modified.";
+       public const string ToolboxItemInvalidPropertyType = "Property {0} requires an argument of type {1}.";
+       public const string ToolboxItemValueNotSerializable = "Data type {0} is not serializable. Items added to a property dictionary must be serializable.";
+       public const string ToolboxItemInvalidKey = "Argument should be a non-empty string.";
+       public const string IllegalState = "Internal state of the {0} class is invalid.";
+       public const string InterpolationColorsColorBlendNotSet = "Property must be set to a valid ColorBlend object to use interpolation colors.";
+       public const string InterpolationColorsCommon = "{0}{1} ColorBlend objects must be constructed with the same number of positions and color values. Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array.";
+       public const string InterpolationColorsInvalidColorBlendObject = "ColorBlend object that was set is not valid.";
+       public const string InterpolationColorsInvalidStartPosition = "Position's first element must be equal to 0.";
+       public const string InterpolationColorsInvalidEndPosition = "Position's last element must be equal to 1.0.";
+       public const string InterpolationColorsLength = "Array of colors and positions must contain at least two elements.";
+       public const string InterpolationColorsLengthsDiffer = "Colors and positions do not have the same number of elements.";
+       public const string InvalidArgument = "Value of '{1}' is not valid for '{0}'.";
+       public const string InvalidBoundArgument = "Value of '{1}' is not valid for '{0}'. '{0}' should be greater than {2} and less than or equal to {3}.";
+       public const string InvalidClassName = "Class name is not valid.";
+       public const string InvalidColor = "Color '{0}' is not valid.";
+       public const string InvalidDashPattern = "DashPattern value is not valid.";
+       public const string InvalidEx2BoundArgument = "Value of '{1}' is not valid for '{0}'. '{0}' should be greater than or equal to {2} and less than or equal to {3}.";
+       public const string InvalidFrame = "Frame is not valid. Frame must be between 0 and FrameCount.";
+       public const string InvalidGDIHandle = "Win32 handle that was passed to {0} is not valid or is the wrong type.";
+       public const string InvalidImage = "Image type is unknown.";
+       public const string InvalidLowBoundArgumentEx = "Value of '{1}' is not valid for '{0}'. '{0}' must be greater than or equal to {2}.";
+       public const string InvalidPermissionLevel = "Permission level is not valid.";
+       public const string InvalidPermissionState = "Permission state is not valid.";
+       public const string InvalidPictureType = "Argument '{0}' must be a picture that can be used as a {1}.";
+       public const string InvalidPrinterException_InvalidPrinter = "Settings to access printer '{0}' are not valid.";
+       public const string InvalidPrinterException_NoDefaultPrinter = "No printers are installed.";
+       public const string InvalidPrinterHandle = "Handle {0} is not valid.";
+       public const string ValidRangeX = "Parameter must be positive and < Width.";
+       public const string ValidRangeY = "Parameter must be positive and < Height.";
+       public const string NativeHandle0 = "Native handle is 0.";
+       public const string NoDefaultPrinter = "Default printer is not set.";
+       public const string NotImplemented = "Not implemented.";
+       public const string PDOCbeginPrintDescr = "Occurs when the document is about to be printed.";
+       public const string PDOCdocumentNameDescr = "The name of the document shown to the user.";
+       public const string PDOCdocumentPageSettingsDescr = "The page settings of the page currently being printed.";
+       public const string PDOCendPrintDescr = "Occurs after the document has been printed.";
+       public const string PDOCoriginAtMarginsDescr = "Indicates that the graphics origin is located at the user-specified page margins.";
+       public const string PDOCprintControllerDescr = "Retrieves the print controller for this document.";
+       public const string PDOCprintPageDescr = "Occurs once for each page to be printed.";
+       public const string PDOCprinterSettingsDescr = "Retrieves the settings for the printer the document is currently being printed to.";
+       public const string PDOCqueryPageSettingsDescr = "Occurs before each page is printed.  Useful for changing PageSettings for a particular page.";
+       public const string PrintDocumentDesc = "Defines an object that sends output to a printer.";
+       public const string PrintingPermissionBadXml = "XML is not valid.";
+       public const string PrintingPermissionAttributeInvalidPermissionLevel = "Permission level must be between PrintingPermissionLevel.NoPrinting and PrintingPermissionLevel.AllPrinting.";
+       public const string PropertyValueInvalidEntry = "IDictionary parameter contains at least one entry that is not valid. Ensure all values are consistent with the object's properties.";
+       public const string PSizeNotCustom = "PaperSize cannot be changed unless the Kind property is set to Custom.";
+       public const string ResourceNotFound = "Resource '{1}' cannot be found in class '{0}'.";
+       public const string TargetNotPrintingPermission = "Target does not have permission to print.";
+       public const string TextParseFailedFormat = "Text \"{0}\" cannot be parsed. The expected text format is \"{1}\".";
+       public const string TriStateCompareError = "TriState.Default cannot be converted into a Boolean.";
+       public const string toStringIcon = "(Icon)";
+       public const string toStringNone = "(none)";
+       public const string DCTypeInvalid = "GetObjectType on this dc returned an invalid value.";
+       public const string InvalidEnumArgument = "The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.";
+       public const string ConvertInvalidPrimitive = "{0} is not a valid value for {1}.";
+}
index f13e64122ace5db53316040604935379b3f4c7c7..1e05c08cfebc4e65d6d910e50613ac59a086b5a0 100644 (file)
@@ -6,7 +6,7 @@ LIBRARY = System.Numerics.dll
 LIB_REFS = System
 LIB_MCS_FLAGS = /unsafe
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
-XTEST_LIB_REFS = System Facades/System.Threading.Tasks System.Runtime.InteropServices.RuntimeInformation System.Core System.Numerics.Vectors Microsoft.CSharp
+XTEST_LIB_REFS = System Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation System.Core System.Numerics.Vectors Microsoft.CSharp
 XTEST_LIB_FLAGS = -unsafe
 
 RESX_RESOURCE_STRING = \
index a012a0c1a8eff95274c3f6bbce9d4003fd3b2804..2ef111be9161a9cece92a570ca6f2de20145f72f 100644 (file)
@@ -1,3 +1,4 @@
+../../../external/corefx/src/Common/tests/System/AssertExtensions.cs
 ../../../external/corefx/src/Common/tests/System/PlatformDetection.cs
 
 # ../../../external/corefx/src/System.Runtime.Numerics/tests/*.cs
index 8f9aff4d0fd2e580e76bead3e6496dc6434d17e6..85942d311a41401ea76c73d6ac30d9fde70dd1c4 100644 (file)
@@ -174,7 +174,11 @@ namespace System.Web.Configuration
                {
                        string fullPath = (string) hostInitConfigurationParams [1];
                        map = (WebConfigurationFileMap) hostInitConfigurationParams [0];
-                       bool inAnotherApp = (bool) hostInitConfigurationParams [7];
+                       bool inAnotherApp = false;
+
+                       if ((hostInitConfigurationParams.Length > 7)
+                               && (hostInitConfigurationParams[7] is bool))
+                               inAnotherApp = (bool) hostInitConfigurationParams[7];
 
                        if (inAnotherApp)
                                appVirtualPath = fullPath;
index 3c8cb8372cda57b61f33069a5bb648ab17250b04..d3b29fa2721179ad4337eff51a0b33239b3a3801 100644 (file)
@@ -36,7 +36,11 @@ namespace Mono.AppleTls
                         */
                        var certificate2 = certificate as X509Certificate2;
                        if (certificate2 != null)
+#if MONOTOUCH
+                               return SecIdentity.Import (certificate2);
+#else
                                return SecImportExport.ItemImport (certificate2);
+#endif
 
                        /*
                         * Reading Certificates from the Mac Keychain
index 6a57babab4e274b994407f3426bc31c2c4796fbb..4fa1730df2a10ffc33fc7d9a5a792259737b8db6 100644 (file)
@@ -848,12 +848,12 @@ namespace Mono.AppleTls
                [DllImport (SecurityLibrary)]
                extern static /* OSStatus */ SslStatus SSLClose (/* SSLContextRef */ IntPtr context);
 
-               public override void Close ()
+               public override void Shutdown ()
                {
                        if (Interlocked.Exchange (ref pendingIO, 1) == 1)
                                throw new InvalidOperationException ();
 
-                       Debug ("Close");
+                       Debug ("Shutdown");
 
                        lastException = null;
 
@@ -862,7 +862,7 @@ namespace Mono.AppleTls
                                        return;
 
                                var status = SSLClose (Handle);
-                               Debug ("Close done: {0}", status);
+                               Debug ("Shutdown done: {0}", status);
                                CheckStatusAndThrow (status);
                        } finally {
                                closed = true;
index e3b9fa85933912d704580bbb9374cf43d822c188..412b4da1f105b7d9f158bdb7e52c1fa490b34f32 100644 (file)
@@ -38,12 +38,12 @@ namespace Mono.AppleTls
                }
 
                protected override MNS.MobileTlsContext CreateContext (
-                       MNS.MobileAuthenticatedStream parent, bool serverMode, string targetHost,
-                       SslProtocols enabledProtocols, X509Certificate serverCertificate,
-                       X509CertificateCollection clientCertificates, bool askForClientCert)
+                       bool serverMode, string targetHost, SslProtocols enabledProtocols,
+                       X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
+                       bool askForClientCert)
                {
                        return new AppleTlsContext (
-                               parent, serverMode, targetHost,
+                               this, serverMode, targetHost,
                                enabledProtocols, serverCertificate,
                                clientCertificates, askForClientCert);
                }
index 0e41e14d0d435b026bc824ec1bb64ecff1faf647..dae101bc6b478f42a1631e4dd0620e680cbcbefc 100644 (file)
@@ -67,6 +67,7 @@ namespace Mono.AppleTls {
                        return code;
                }
 
+#if !MONOTOUCH
                [DllImport (AppleTlsContext.SecurityLibrary)]
                extern static SecStatusCode SecItemImport (
                        /* CFDataRef */ IntPtr importedData,
@@ -217,6 +218,7 @@ namespace Mono.AppleTls {
                        IntPtr keyUsage;
                        IntPtr keyAttributes;
                }
+#endif
        }
 }
 #endif
index 841daa270fa12ac1cd20b9f959a73c47c14f1dbb..08c2678a2276f6554da8f4b50d6127550b7b84bc 100644 (file)
@@ -316,6 +316,9 @@ namespace Mono.Btls
                                if (status == MonoBtlsSslError.WantRead) {
                                        wantMore = true;
                                        return 0;
+                               } else if (status == MonoBtlsSslError.ZeroReturn) {
+                                       wantMore = false;
+                                       return size;
                                } else if (status != MonoBtlsSslError.None) {
                                        throw GetException (status);
                                }
@@ -358,26 +361,11 @@ namespace Mono.Btls
                        }
                }
 
-               public override void Close ()
+               public override void Shutdown ()
                {
-                       Debug ("Close!");
-
-                       if (ssl != null) {
-                               ssl.Dispose ();
-                               ssl = null;
-                       }
-                       if (ctx != null) {
-                               ctx.Dispose ();
-                               ctx = null;
-                       }
-                       if (bio != null) {
-                               bio.Dispose ();
-                               bio = null;
-                       }
-                       if (errbio != null) {
-                               errbio.Dispose ();
-                               errbio = null;
-                       }
+                       Debug ("Shutdown!");
+//                     ssl.SetQuietShutdown ();
+                       ssl.Shutdown ();
                }
 
                void Dispose<T> (ref T disposable)
@@ -397,12 +385,12 @@ namespace Mono.Btls
                {
                        try {
                                if (disposing) {
+                                       Dispose (ref ssl);
+                                       Dispose (ref ctx);
                                        Dispose (ref remoteCertificate);
                                        Dispose (ref nativeServerCertificate);
                                        Dispose (ref nativeClientCertificate);
                                        Dispose (ref clientCertificate);
-                                       Dispose (ref ctx);
-                                       Dispose (ref ssl);
                                        Dispose (ref bio);
                                        Dispose (ref errbio);
                                }
index 4264411bd90fea0fce98dc86ea7d681c02d7b992..19e72cbda640bea62ad6a05aac647e17fc6432b0 100644 (file)
@@ -102,6 +102,20 @@ namespace Mono.Btls
                        CheckError (ret == 1, callerName);
                }
 
+               protected internal void CheckLastError ([CallerMemberName] string callerName = null)
+               {
+                       var error = Interlocked.Exchange (ref lastError, null);
+                       if (error == null)
+                               return;
+
+                       string message;
+                       if (callerName != null)
+                               message = string.Format ("Caught unhandled exception in {0}.{1}.", GetType ().Name, callerName);
+                       else
+                               message = string.Format ("Caught unhandled exception.");
+                       throw new MonoBtlsException (message, error);
+               }
+
                [DllImport (BTLS_DYLIB)]
                extern static void mono_btls_free (IntPtr data);
 
index 09e171485f6ca659199d70ab9f0f07a4f8d48bd3..e5fac698c0e18c35c32040e2d4d2679a4ed6c130 100644 (file)
@@ -47,6 +47,7 @@ namespace Mono.Btls
                        protected override bool ReleaseHandle ()
                        {
                                mono_btls_ssl_destroy (handle);
+                               handle = IntPtr.Zero;
                                return true;
                        }
                }
@@ -78,6 +79,12 @@ namespace Mono.Btls
                [DllImport (BTLS_DYLIB)]
                extern static void mono_btls_ssl_close (IntPtr handle);
 
+               [DllImport (BTLS_DYLIB)]
+               extern static int mono_btls_ssl_shutdown (IntPtr handle);
+
+               [DllImport (BTLS_DYLIB)]
+               extern static void mono_btls_ssl_set_quiet_shutdown (IntPtr handle, int mode);
+
                [DllImport (BTLS_DYLIB)]
                extern static void mono_btls_ssl_set_bio (IntPtr handle, IntPtr bio);
 
@@ -131,6 +138,7 @@ namespace Mono.Btls
                        return new BoringSslHandle (handle);
                }
 
+               MonoBtlsBio bio;
                PrintErrorsCallbackFunc printErrorsFunc;
                IntPtr printErrorsFuncPtr;
 
@@ -148,6 +156,7 @@ namespace Mono.Btls
                public void SetBio (MonoBtlsBio bio)
                {
                        CheckThrow ();
+                       this.bio = bio;
                        mono_btls_ssl_set_bio (
                                Handle.DangerousGetHandle (),
                                bio.Handle.DangerousGetHandle ());
@@ -164,18 +173,17 @@ namespace Mono.Btls
                                errors = null;
                        }
 
-                       if (errors != null) {
-                               Console.Error.WriteLine ("ERROR: {0} failed: {1}", callerName, errors);
+                       if (errors != null)
                                throw new MonoBtlsException ("{0} failed: {1}.", callerName, errors);
-                       } else {
-                               Console.Error.WriteLine ("ERROR: {0} failed.", callerName);
+                       else
                                throw new MonoBtlsException ("{0} failed.", callerName);
-                       }
                }
 
                MonoBtlsSslError GetError (int ret_code)
                {
                        CheckThrow ();
+                       bio.CheckLastError ();
+
                        var error = mono_btls_ssl_get_error (
                                Handle.DangerousGetHandle (), ret_code);
                        return (MonoBtlsSslError)error;
@@ -287,15 +295,20 @@ namespace Mono.Btls
                        var ret = mono_btls_ssl_read (
                                Handle.DangerousGetHandle (), data, dataSize);
 
-                       if (ret >= 0) {
+                       if (ret > 0) {
                                dataSize = ret;
                                return MonoBtlsSslError.None;
                        }
 
-                       var error = mono_btls_ssl_get_error (
-                               Handle.DangerousGetHandle (), ret);
+                       var error = GetError (ret);
+                       if (ret == 0 && error == MonoBtlsSslError.Syscall) {
+                               // End-of-stream
+                               dataSize = 0;
+                               return MonoBtlsSslError.None;
+                       }
+
                        dataSize = 0;
-                       return (MonoBtlsSslError)error;
+                       return error;
                }
 
                public MonoBtlsSslError Write (IntPtr data, ref int dataSize)
@@ -416,9 +429,24 @@ namespace Mono.Btls
                        return Marshal.PtrToStringAnsi (namePtr);
                }
 
+               public void Shutdown ()
+               {
+                       CheckThrow ();
+                       var ret = mono_btls_ssl_shutdown (Handle.DangerousGetHandle ());
+                       if (ret < 0)
+                               throw ThrowError ();
+               }
+
+               public void SetQuietShutdown ()
+               {
+                       CheckThrow ();
+                       mono_btls_ssl_set_quiet_shutdown (Handle.DangerousGetHandle (), 1);
+               }
+
                protected override void Close ()
                {
-                       mono_btls_ssl_close (Handle.DangerousGetHandle ());
+                       if (!Handle.IsInvalid)
+                               mono_btls_ssl_close (Handle.DangerousGetHandle ());
                }
        }
 }
index e941fcd1c0c132674b6fa6d2f61871b4bfadf9bb..b3bb65f9b8eb8023265be0ce8bdf5a47d1301bc4 100644 (file)
@@ -53,12 +53,12 @@ namespace Mono.Btls
                }
 
                protected override MNS.MobileTlsContext CreateContext (
-                       MNS.MobileAuthenticatedStream parent, bool serverMode, string targetHost,
-                       SslProtocols enabledProtocols, X509Certificate serverCertificate,
-                       X509CertificateCollection clientCertificates, bool askForClientCert)
+                       bool serverMode, string targetHost, SslProtocols enabledProtocols,
+                       X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
+                       bool askForClientCert)
                {
                        return new MonoBtlsContext (
-                               parent, serverMode, targetHost,
+                               this, serverMode, targetHost,
                                enabledProtocols, serverCertificate,
                                clientCertificates, askForClientCert);
                }
index 5f90ffe2b82241f4390b9c112c0c36c0e0abaeb9..3c537a7e42798b46ee80b02477db30759666c7fa 100644 (file)
@@ -11,14 +11,14 @@ using System;
 using System.IO;
 using System.Net;
 using System.Net.Security;
+using System.Security.Authentication;
 using SD = System.Diagnostics;
 using System.Threading;
 using System.Threading.Tasks;
+using System.Runtime.ExceptionServices;
 
 namespace Mono.Net.Security
 {
-       delegate AsyncOperationStatus AsyncOperation (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status);
-
        class BufferOffsetSize
        {
                public byte[] Buffer;
@@ -37,6 +37,13 @@ namespace Mono.Net.Security
 
                public BufferOffsetSize (byte[] buffer, int offset, int size)
                {
+                       if (buffer == null)
+                               throw new ArgumentNullException (nameof (buffer));
+                       if (offset < 0)
+                               throw new ArgumentOutOfRangeException (nameof (offset));
+                       if (size < 0 || offset + size > buffer.Length)
+                               throw new ArgumentOutOfRangeException (nameof (size));
+
                        Buffer = buffer;
                        Offset = offset;
                        Size = size;
@@ -54,7 +61,7 @@ namespace Mono.Net.Security
                public readonly int InitialSize;
 
                public BufferOffsetSize2 (int size)
-                       : base (new byte [size], 0, 0)
+                       : base (new byte[size], 0, 0)
                {
                        InitialSize = size;
                }
@@ -63,7 +70,7 @@ namespace Mono.Net.Security
                {
                        Offset = Size = 0;
                        TotalBytes = 0;
-                       Buffer = new byte [InitialSize];
+                       Buffer = new byte[InitialSize];
                        Complete = false;
                }
 
@@ -74,11 +81,11 @@ namespace Mono.Net.Security
 
                        int missing = size - Remaining;
                        if (Offset == 0 && Size == 0) {
-                               Buffer = new byte [size];
+                               Buffer = new byte[size];
                                return;
                        }
 
-                       var buffer = new byte [Buffer.Length + missing];
+                       var buffer = new byte[Buffer.Length + missing];
                        Buffer.CopyTo (buffer, 0);
                        Buffer = buffer;
                }
@@ -91,201 +98,296 @@ namespace Mono.Net.Security
                }
        }
 
-       enum AsyncOperationStatus {
-               NotStarted,
+       enum AsyncOperationStatus
+       {
                Initialize,
                Continue,
-               Running,
-               Complete,
-               WantRead,
-               WantWrite,
                ReadDone,
-               FinishWrite
+               Complete
        }
 
-       class AsyncProtocolRequest
+       class AsyncProtocolResult
        {
-               public readonly MobileAuthenticatedStream Parent;
-               public readonly BufferOffsetSize UserBuffer;
+               public int UserResult {
+                       get;
+               }
+               public ExceptionDispatchInfo Error {
+                       get;
+               }
 
-               int RequestedSize;
-               public int CurrentSize;
-               public int UserResult;
+               public AsyncProtocolResult (int result)
+               {
+                       UserResult = result;
+               }
 
-               AsyncOperation Operation;
-               int Status;
+               public AsyncProtocolResult (ExceptionDispatchInfo error)
+               {
+                       Error = error;
+               }
+       }
 
-               public readonly int ID = ++next_id;
-               static int next_id;
+       abstract class AsyncProtocolRequest
+       {
+               public MobileAuthenticatedStream Parent {
+                       get;
+               }
 
-               public readonly LazyAsyncResult UserAsyncResult;
+               public bool RunSynchronously {
+                       get;
+               }
 
-               public AsyncProtocolRequest (MobileAuthenticatedStream parent, LazyAsyncResult lazyResult, BufferOffsetSize userBuffer = null)
-               {
-                       Parent = parent;
-                       UserAsyncResult = lazyResult;
-                       UserBuffer = userBuffer;
+               public int ID => ++next_id;
+
+               public string Name => GetType ().Name;
+
+               public int UserResult {
+                       get;
+                       protected set;
                }
 
-               public bool CompleteWithError (Exception ex)
+               int Started;
+               int RequestedSize;
+               int WriteRequested;
+               readonly object locker = new object ();
+
+               static int next_id;
+
+               public AsyncProtocolRequest (MobileAuthenticatedStream parent, bool sync)
                {
-                       Status = (int)AsyncOperationStatus.Complete;
-                       if (UserAsyncResult == null)
-                               return true;
-                       if (!UserAsyncResult.InternalPeekCompleted)
-                               UserAsyncResult.InvokeCallback (ex);
-                       return false;
+                       Parent = parent;
+                       RunSynchronously = sync;
                }
 
                [SD.Conditional ("MARTIN_DEBUG")]
                protected void Debug (string message, params object[] args)
                {
-                       Parent.Debug ("AsyncProtocolRequest({0}:{1}): {2}", Parent.ID, ID, string.Format (message, args));
+                       Parent.Debug ("{0}({1}:{2}): {3}", Name, Parent.ID, ID, string.Format (message, args));
                }
 
                internal void RequestRead (int size)
                {
-                       var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.WantRead, (int)AsyncOperationStatus.Running);
-                       Debug ("RequestRead: {0} {1}", oldStatus, size);
-                       if (oldStatus == AsyncOperationStatus.Running)
-                               RequestedSize = size;
-                       else if (oldStatus == AsyncOperationStatus.WantRead)
+                       lock (locker) {
                                RequestedSize += size;
-                       else if (oldStatus != AsyncOperationStatus.WantWrite)
-                               throw new InvalidOperationException ();
+                               Debug ("RequestRead: {0}", size);
+                       }
                }
 
-               internal void ResetRead ()
+               internal void RequestWrite ()
                {
-                       var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.Complete, (int)AsyncOperationStatus.WantRead);
-                       Debug ("ResetRead: {0} {1}", oldStatus, Status);
+                       WriteRequested = 1;
                }
 
-               internal void ResetWrite ()
+               internal async Task<AsyncProtocolResult> StartOperation (CancellationToken cancellationToken)
                {
-                       var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.Complete, (int)AsyncOperationStatus.WantWrite);
-                       Debug ("ResetWrite: {0} {1}", oldStatus, Status);
+                       Debug ("Start Operation: {0}", this);
+                       if (Interlocked.CompareExchange (ref Started, 1, 0) != 0)
+                               throw new InvalidOperationException ();
+
+                       try {
+                               await ProcessOperation (cancellationToken).ConfigureAwait (false);
+                               return new AsyncProtocolResult (UserResult);
+                       } catch (Exception ex) {
+                               var info = Parent.SetException (MobileAuthenticatedStream.GetSSPIException (ex));
+                               return new AsyncProtocolResult (info);
+                       }
                }
 
-               internal void RequestWrite ()
+               async Task ProcessOperation (CancellationToken cancellationToken)
                {
-                       var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.WantWrite, (int)AsyncOperationStatus.Running);
-                       Debug ("RequestWrite: {0} {1}", oldStatus, Status);
-                       if (oldStatus == AsyncOperationStatus.Running)
-                               return;
-                       else if (oldStatus != AsyncOperationStatus.WantRead && oldStatus != AsyncOperationStatus.WantWrite)
-                               throw new InvalidOperationException ();
+                       var status = AsyncOperationStatus.Initialize;
+                       while (status != AsyncOperationStatus.Complete) {
+                               cancellationToken.ThrowIfCancellationRequested ();
+                               Debug ("ProcessOperation: {0}", status);
+
+                               var ret = await InnerRead (cancellationToken).ConfigureAwait (false);
+                               if (ret != null) {
+                                       if (ret == 0) {
+                                               // End-of-stream
+                                               Debug ("END OF STREAM!");
+                                               status = AsyncOperationStatus.ReadDone;
+                                       } else if (ret < 0) {
+                                               // remote prematurely closed connection.
+                                               throw new IOException ("Remote prematurely closed connection.");
+                                       }
+                               }
+
+                               Debug ("ProcessOperation run: {0}", status);
+
+                               AsyncOperationStatus newStatus;
+                               switch (status) {
+                               case AsyncOperationStatus.Initialize:
+                               case AsyncOperationStatus.Continue:
+                               case AsyncOperationStatus.ReadDone:
+                                       newStatus = Run (status);
+                                       break;
+                               default:
+                                       throw new InvalidOperationException ();
+                               }
+
+                               if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
+                                       // Flush the write queue.
+                                       await Parent.InnerWrite (RunSynchronously, cancellationToken);
+                               }
+
+                               Debug ("ProcessOperation done: {0} -> {1}", status, newStatus);
+
+                               status = newStatus;
+                       }
                }
 
-               internal void StartOperation (AsyncOperation operation)
+               async Task<int?> InnerRead (CancellationToken cancellationToken)
                {
-                       Debug ("Start Operation: {0} {1}", Status, operation);
-                       if (Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.Initialize, (int)AsyncOperationStatus.NotStarted) != (int)AsyncOperationStatus.NotStarted)
-                               throw new InvalidOperationException ();
+                       int? totalRead = null;
+                       var requestedSize = Interlocked.Exchange (ref RequestedSize, 0);
+                       while (requestedSize > 0) {
+                               Debug ("ProcessOperation - read inner: {0}", requestedSize);
 
-                       Operation = operation;
+                               var ret = await Parent.InnerRead (RunSynchronously, requestedSize, cancellationToken).ConfigureAwait (false);
+                               Debug ("ProcessOperation - read inner done: {0} - {1}", requestedSize, ret);
 
-                       if (UserAsyncResult == null) {
-                               StartOperation ();
-                               return;
+                               if (ret <= 0)
+                                       return ret;
+                               if (ret > requestedSize)
+                                       throw new InvalidOperationException ();
+
+                               totalRead += ret;
+                               requestedSize -= ret;
+                               var newRequestedSize = Interlocked.Exchange (ref RequestedSize, 0);
+                               requestedSize += newRequestedSize;
                        }
 
-                       ThreadPool.QueueUserWorkItem (_ => StartOperation ());
+                       return totalRead;
                }
 
-               void StartOperation ()
+               /*
+                * This will operate on the internal buffers and never block.
+                */
+               protected abstract AsyncOperationStatus Run (AsyncOperationStatus status);
+
+               public override string ToString ()
                {
-                       try {
-                               ProcessOperation ();
-                               if (UserAsyncResult != null && !UserAsyncResult.InternalPeekCompleted)
-                                       UserAsyncResult.InvokeCallback (UserResult);
-                       } catch (Exception ex) {
-                               if (UserAsyncResult == null)
-                                       throw;
-                               if (!UserAsyncResult.InternalPeekCompleted)
-                                       UserAsyncResult.InvokeCallback (ex);
-                       }
+                       return string.Format ("[{0}]", Name);
                }
+       }
 
-               void ProcessOperation ()
+       class AsyncHandshakeRequest : AsyncProtocolRequest
+       {
+               public AsyncHandshakeRequest (MobileAuthenticatedStream parent, bool sync)
+                       : base (parent, sync)
                {
-                       AsyncOperationStatus status;
-                       do {
-                               status = (AsyncOperationStatus)Interlocked.Exchange (ref Status, (int)AsyncOperationStatus.Running);
+               }
 
-                               Debug ("ProcessOperation: {0}", status);
+               protected override AsyncOperationStatus Run (AsyncOperationStatus status)
+               {
+                       return Parent.ProcessHandshake (status);
+               }
+       }
 
-                               status = ProcessOperation (status);
+       abstract class AsyncReadOrWriteRequest : AsyncProtocolRequest
+       {
+               protected BufferOffsetSize UserBuffer {
+                       get;
+               }
 
-                               Debug ("ProcessOperation done: {0}", status);
+               protected int CurrentSize {
+                       get; set;
+               }
 
-                               AsyncOperationStatus oldStatus;
-                               if (status == AsyncOperationStatus.Complete) {
-                                       oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.FinishWrite, (int)AsyncOperationStatus.WantWrite);
-                                       if (oldStatus == AsyncOperationStatus.WantWrite) {
-                                               // We are done, but still need to flush the write queue.
-                                               status = AsyncOperationStatus.FinishWrite;
-                                               continue;
-                                       }
-                               }
+               public AsyncReadOrWriteRequest (MobileAuthenticatedStream parent, bool sync, byte[] buffer, int offset, int size)
+                       : base (parent, sync)
+               {
+                       UserBuffer = new BufferOffsetSize (buffer, offset, size);
+               }
 
-                               oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)status, (int)AsyncOperationStatus.Running);
-                               Debug ("ProcessOperation done: {0} -> {1}", oldStatus, status);
+               public override string ToString ()
+               {
+                       return string.Format ("[{0}: {1}]", Name, UserBuffer);
+               }
+       }
 
-                               if (oldStatus != AsyncOperationStatus.Running) {
-                                       if (status == oldStatus || status == AsyncOperationStatus.Continue || status == AsyncOperationStatus.Complete)
-                                               status = oldStatus;
-                                       else
-                                               throw new InvalidOperationException ();
-                               }
-                       } while (status != AsyncOperationStatus.Complete);
+       class AsyncReadRequest : AsyncReadOrWriteRequest
+       {
+               public AsyncReadRequest (MobileAuthenticatedStream parent, bool sync, byte[] buffer, int offset, int size)
+                       : base (parent, sync, buffer, offset, size)
+               {
                }
 
-               AsyncOperationStatus ProcessOperation (AsyncOperationStatus status)
+               protected override AsyncOperationStatus Run (AsyncOperationStatus status)
                {
-                       if (status == AsyncOperationStatus.WantRead) {
-                               if (RequestedSize < 0)
-                                       throw new InvalidOperationException ();
-                               else if (RequestedSize == 0)
-                                       return AsyncOperationStatus.Continue;
-
-                               Debug ("ProcessOperation - read inner: {0}", RequestedSize);
-                               var ret = Parent.InnerRead (RequestedSize);
-                               Debug ("ProcessOperation - read inner done: {0} - {1}", RequestedSize, ret);
-
-                               if (ret < 0)
-                                       return AsyncOperationStatus.ReadDone;
-
-                               RequestedSize -= ret;
-
-                               if (ret == 0 || RequestedSize == 0)
-                                       return AsyncOperationStatus.Continue;
-                               else
-                                       return AsyncOperationStatus.WantRead;
-                       } else if (status == AsyncOperationStatus.WantWrite) {
-                               Debug ("ProcessOperation - want write");
-                               Parent.InnerWrite ();
-                               Debug ("ProcessOperation - want write done");
+                       Debug ("ProcessRead - read user: {0} {1}", this, status);
+
+                       var (ret, wantMore) = Parent.ProcessRead (UserBuffer);
+
+                       Debug ("ProcessRead - read user done: {0} - {1} {2}", this, ret, wantMore);
+
+                       if (ret < 0) {
+                               UserResult = -1;
+                               return AsyncOperationStatus.Complete;
+                       }
+
+                       CurrentSize += ret;
+                       UserBuffer.Offset += ret;
+                       UserBuffer.Size -= ret;
+
+                       Debug ("Process Read - read user done #1: {0} - {1} {2}", this, CurrentSize, wantMore);
+
+                       if (wantMore && CurrentSize == 0)
                                return AsyncOperationStatus.Continue;
-                       } else if (status == AsyncOperationStatus.Initialize || status == AsyncOperationStatus.Continue) {
-                               Debug ("ProcessOperation - continue");
-                               status = Operation (this, status);
-                               Debug ("ProcessOperation - continue done: {0}", status);
-                               return status;
-                       } else if (status == AsyncOperationStatus.ReadDone) {
-                               Debug ("ProcessOperation - read done");
-                               status = Operation (this, status);
-                               Debug ("ProcessOperation - read done: {0}", status);
-                               return status;
-                       } else if (status == AsyncOperationStatus.FinishWrite) {
-                               Debug ("ProcessOperation - finish write");
-                               Parent.InnerWrite ();
-                               Debug ("ProcessOperation - finish write done");
+
+                       UserResult = CurrentSize;
+                       return AsyncOperationStatus.Complete;
+               }
+       }
+
+       class AsyncWriteRequest : AsyncReadOrWriteRequest
+       {
+               public AsyncWriteRequest (MobileAuthenticatedStream parent, bool sync, byte[] buffer, int offset, int size)
+                       : base (parent, sync, buffer, offset, size)
+               {
+               }
+
+               protected override AsyncOperationStatus Run (AsyncOperationStatus status)
+               {
+                       Debug ("ProcessWrite - write user: {0} {1}", this, status);
+
+                       if (UserBuffer.Size == 0) {
+                               UserResult = CurrentSize;
+                               return AsyncOperationStatus.Complete;
+                       }
+
+                       var (ret, wantMore) = Parent.ProcessWrite (UserBuffer);
+
+                       Debug ("ProcessWrite - write user done: {0} - {1} {2}", this, ret, wantMore);
+
+                       if (ret < 0) {
+                               UserResult = -1;
                                return AsyncOperationStatus.Complete;
                        }
 
-                       throw new InvalidOperationException ();
+                       CurrentSize += ret;
+                       UserBuffer.Offset += ret;
+                       UserBuffer.Size -= ret;
+
+                       if (wantMore)
+                               return AsyncOperationStatus.Continue;
+
+                       UserResult = CurrentSize;
+                       return AsyncOperationStatus.Complete;
+               }
+       }
+
+       class AsyncShutdownRequest : AsyncProtocolRequest
+       {
+               public AsyncShutdownRequest (MobileAuthenticatedStream parent)
+                       : base (parent, false)
+               {
+               }
+
+               protected override AsyncOperationStatus Run (AsyncOperationStatus status)
+               {
+                       return Parent.ProcessShutdown (status);
                }
        }
+
 }
 #endif
index a5572addc13c4583642104a84fd321feadbd07d9..e4032496da167517db3ff54076a60e184a6ba167 100644 (file)
@@ -575,6 +575,11 @@ namespace Mono.Net.Security.Private
 
                #region IMonoSslStream
 
+               Task IMonoSslStream.ShutdownAsync ()
+               {
+                       return Task.CompletedTask;
+               }
+
                AuthenticatedStream IMonoSslStream.AuthenticatedStream {
                        get { return this; }
                }
index 1e57c67341597cd191bf27b21a245ee276972b7d..2b380a1ae6c2ca3f9d5ffb5f94d4cf2de72cac19 100644 (file)
@@ -23,6 +23,7 @@ using System.IO;
 using System.Net;
 using System.Net.Security;
 using System.Globalization;
+using System.Security.Authentication;
 using System.Runtime.ExceptionServices;
 using System.Threading;
 using System.Threading.Tasks;
@@ -36,8 +37,13 @@ namespace Mono.Net.Security
 {
        abstract class MobileAuthenticatedStream : AuthenticatedStream, MSI.IMonoSslStream
        {
+               /*
+                * This is intentionally called `xobileTlsContext'.  It is a "dangerous" object
+                * that must not be touched outside the `ioLock' and we need to be very careful
+                * where we access it.
+                */
                MobileTlsContext xobileTlsContext;
-               Exception lastException;
+               ExceptionDispatchInfo lastException;
 
                AsyncProtocolRequest asyncHandshakeRequest;
                AsyncProtocolRequest asyncReadRequest;
@@ -47,11 +53,12 @@ namespace Mono.Net.Security
 
                object ioLock = new object ();
                int closeRequested;
+               bool shutdown;
 
                static int uniqueNameInteger = 123;
 
                public MobileAuthenticatedStream (Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
-                                                 MSI.MonoTlsSettings settings, MSI.MonoTlsProvider provider)
+                                                 MSI.MonoTlsSettings settings, MSI.MonoTlsProvider provider)
                        : base (innerStream, leaveInnerStreamOpen)
                {
                        SslStream = owner;
@@ -78,42 +85,47 @@ namespace Mono.Net.Security
                        get { return xobileTlsContext != null; }
                }
 
-               internal MobileTlsContext Context {
-                       get {
-                               CheckThrow (true);
-                               return xobileTlsContext;
-                       }
-               }
-
-               internal void CheckThrow (bool authSuccessCheck)
+               internal void CheckThrow (bool authSuccessCheck, bool shutdownCheck = false)
                {
-                       if (closeRequested != 0)
-                               throw new InvalidOperationException ("Stream is closed.");
                        if (lastException != null)
-                               throw lastException;
+                               lastException.Throw ();
                        if (authSuccessCheck && !IsAuthenticated)
-                               throw new InvalidOperationException ("Must be authenticated.");
+                               throw new InvalidOperationException (SR.net_auth_noauth);
+                       if (shutdownCheck && shutdown)
+                               throw new InvalidOperationException (SR.net_ssl_io_already_shutdown);
                }
 
-               Exception SetException (Exception e)
+               internal static Exception GetSSPIException (Exception e)
                {
-                       e = SetException_internal (e);
-                       if (e != null && xobileTlsContext != null)
-                               xobileTlsContext.Dispose ();
-                       return e;
+                       if (e is OperationCanceledException || e is IOException || e is ObjectDisposedException || e is AuthenticationException)
+                               return e;
+                       return new AuthenticationException (SR.net_auth_SSPI, e);
                }
 
-               Exception SetException_internal (Exception e)
+               internal static Exception GetIOException (Exception e, string message)
                {
-                       if (lastException == null)
-                               lastException = e;
-                       return lastException;
+                       if (e is OperationCanceledException || e is IOException || e is ObjectDisposedException || e is AuthenticationException)
+                               return e;
+                       return new IOException (message, e);
+               }
+
+               internal ExceptionDispatchInfo SetException (Exception e)
+               {
+                       var info = ExceptionDispatchInfo.Capture (e);
+                       var old = Interlocked.CompareExchange (ref lastException, info, null);
+                       return old ?? info;
                }
 
                SslProtocols DefaultProtocols {
                        get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
                }
 
+               enum OperationType {
+                       Read,
+                       Write,
+                       Shutdown
+               }
+
                public void AuthenticateAsClient (string targetHost)
                {
                        AuthenticateAsClient (targetHost, new X509CertificateCollection (), DefaultProtocols, false);
@@ -121,8 +133,8 @@ namespace Mono.Net.Security
 
                public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
                {
-                       ValidateCreateContext (false, targetHost, enabledSslProtocols, null, clientCertificates, false);
-                       ProcessAuthentication (null);
+                       var task = ProcessAuthentication (true, false, targetHost, enabledSslProtocols, null, clientCertificates, false);
+                       task.Wait ();
                }
 
                public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
@@ -132,15 +144,13 @@ namespace Mono.Net.Security
 
                public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
                {
-                       ValidateCreateContext (false, targetHost, enabledSslProtocols, null, clientCertificates, false);
-                       var result = new LazyAsyncResult (this, asyncState, asyncCallback);
-                       ProcessAuthentication (result);
-                       return result;
+                       var task = ProcessAuthentication (false, false, targetHost, enabledSslProtocols, null, clientCertificates, false);
+                       return TaskToApm.Begin (task, asyncCallback, asyncState);
                }
 
                public void EndAuthenticateAsClient (IAsyncResult asyncResult)
                {
-                       EndProcessAuthentication (asyncResult);
+                       TaskToApm.End (asyncResult);
                }
 
                public void AuthenticateAsServer (X509Certificate serverCertificate)
@@ -150,8 +160,8 @@ namespace Mono.Net.Security
 
                public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
                {
-                       ValidateCreateContext (true, string.Empty, enabledSslProtocols, serverCertificate, null, clientCertificateRequired);
-                       ProcessAuthentication (null);
+                       var task = ProcessAuthentication (true, true, string.Empty, enabledSslProtocols, serverCertificate, null, clientCertificateRequired);
+                       task.Wait ();
                }
 
                public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
@@ -161,218 +171,214 @@ namespace Mono.Net.Security
 
                public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
                {
-                       ValidateCreateContext (true, string.Empty, enabledSslProtocols, serverCertificate, null, clientCertificateRequired);
-                       var result = new LazyAsyncResult (this, asyncState, asyncCallback);
-                       ProcessAuthentication (result);
-                       return result;
+                       var task = ProcessAuthentication (false, true, string.Empty, enabledSslProtocols, serverCertificate, null, clientCertificateRequired);
+                       return TaskToApm.Begin (task, asyncCallback, asyncState);
                }
 
                public void EndAuthenticateAsServer (IAsyncResult asyncResult)
                {
-                       EndProcessAuthentication (asyncResult);
+                       TaskToApm.End (asyncResult);
                }
 
                public Task AuthenticateAsClientAsync (string targetHost)
                {
-                       return Task.Factory.FromAsync (BeginAuthenticateAsClient, EndAuthenticateAsClient, targetHost, null);
+                       return ProcessAuthentication (false, false, targetHost, DefaultProtocols, null, null, false);
                }
 
                public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
                {
-                       return Task.Factory.FromAsync ((callback, state) => BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, callback, state), EndAuthenticateAsClient, null);
+                       return ProcessAuthentication (false, false, targetHost, enabledSslProtocols, null, clientCertificates, false);
                }
 
                public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
                {
-                       return Task.Factory.FromAsync (BeginAuthenticateAsServer, EndAuthenticateAsServer, serverCertificate, null);
+                       return AuthenticateAsServerAsync (serverCertificate, false, DefaultProtocols, false);
                }
 
                public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
                {
-                       return Task.Factory.FromAsync ((callback, state) => BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, callback, state), EndAuthenticateAsServer, null);
+                       return ProcessAuthentication (false, true, string.Empty, enabledSslProtocols, serverCertificate, null, clientCertificateRequired);
+               }
+
+               public Task ShutdownAsync ()
+               {
+                       Debug ("ShutdownAsync");
+
+                       /*
+                        * SSLClose() is a little bit tricky as it might attempt to send a close_notify alert
+                        * and thus call our write callback.
+                        *
+                        * It is also not thread-safe with SSLRead() or SSLWrite(), so we need to take the I/O lock here.
+                        */
+                       var asyncRequest = new AsyncShutdownRequest (this);
+                       var task = StartOperation (OperationType.Shutdown, asyncRequest, CancellationToken.None);
+                       return task;
                }
 
                public AuthenticatedStream AuthenticatedStream {
                        get { return this; }
                }
 
-               internal void ProcessAuthentication (LazyAsyncResult lazyResult)
+               async Task ProcessAuthentication (
+                       bool runSynchronously, bool serverMode, string targetHost, SslProtocols enabledProtocols,
+                       X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool clientCertRequired)
                {
-                       var asyncRequest = new AsyncProtocolRequest (this, lazyResult);
+                       if (serverMode) {
+                               if (serverCertificate == null)
+                                       throw new ArgumentException (nameof (serverCertificate));
+                       } else {
+                               if (targetHost == null)
+                                       throw new ArgumentException (nameof (targetHost));
+                               if (targetHost.Length == 0)
+                                       targetHost = "?" + Interlocked.Increment (ref uniqueNameInteger).ToString (NumberFormatInfo.InvariantInfo);
+                       }
+
+                       if (lastException != null)
+                               lastException.Throw ();
+
+                       var asyncRequest = new AsyncHandshakeRequest (this, runSynchronously);
                        if (Interlocked.CompareExchange (ref asyncHandshakeRequest, asyncRequest, null) != null)
                                throw new InvalidOperationException ("Invalid nested call.");
+                       // Make sure no other async requests can be started during the handshake.
+                       if (Interlocked.CompareExchange (ref asyncReadRequest, asyncRequest, null) != null)
+                               throw new InvalidOperationException ("Invalid nested call.");
+                       if (Interlocked.CompareExchange (ref asyncWriteRequest, asyncRequest, null) != null)
+                               throw new InvalidOperationException ("Invalid nested call.");
+
+                       AsyncProtocolResult result;
 
                        try {
-                               if (lastException != null)
-                                       throw lastException;
-                               if (xobileTlsContext == null)
-                                       throw new InvalidOperationException ();
+                               lock (ioLock) {
+                                       if (xobileTlsContext != null)
+                                               throw new InvalidOperationException ();
+                                       readBuffer.Reset ();
+                                       writeBuffer.Reset ();
 
-                               readBuffer.Reset ();
-                               writeBuffer.Reset ();
+                                       xobileTlsContext = CreateContext (
+                                               serverMode, targetHost, enabledProtocols, serverCertificate,
+                                               clientCertificates, clientCertRequired);
+                               }
 
                                try {
-                                       asyncRequest.StartOperation (ProcessHandshake);
+                                       result = await asyncRequest.StartOperation (CancellationToken.None).ConfigureAwait (false);
                                } catch (Exception ex) {
-                                       ExceptionDispatchInfo.Capture (SetException (ex)).Throw ();
+                                       result = new AsyncProtocolResult (SetException (GetSSPIException (ex)));
                                }
                        } finally {
-                               if (lazyResult == null || lastException != null) {
+                               lock (ioLock) {
                                        readBuffer.Reset ();
                                        writeBuffer.Reset ();
+                                       asyncWriteRequest = null;
+                                       asyncReadRequest = null;
                                        asyncHandshakeRequest = null;
                                }
                        }
-               }
-
-               internal void EndProcessAuthentication (IAsyncResult result)
-               {
-                       if (result == null)
-                               throw new ArgumentNullException ("asyncResult");
-
-                       var lazyResult = (LazyAsyncResult)result;
-                       if (Interlocked.Exchange (ref asyncHandshakeRequest, null) == null)
-                               throw new InvalidOperationException ("Invalid end call.");
-
-                       lazyResult.InternalWaitForCompletion ();
-
-                       readBuffer.Reset ();
-                       writeBuffer.Reset ();
-
-                       var e = lazyResult.Result as Exception;
-                       if (e != null)
-                               ExceptionDispatchInfo.Capture (SetException (e)).Throw ();
-               }
-
-               internal void ValidateCreateContext (bool serverMode, string targetHost, SslProtocols enabledProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, bool clientCertRequired)
-               {
-                       if (xobileTlsContext != null)
-                               throw new InvalidOperationException ();
-
-                       if (serverMode) {
-                               if (serverCertificate == null)
-                                       throw new ArgumentException ("serverCertificate");
-                       } else {                                
-                               if (targetHost == null)
-                                       throw new ArgumentException ("targetHost");
-                               if (targetHost.Length == 0)
-                                       targetHost = "?" + Interlocked.Increment (ref uniqueNameInteger).ToString (NumberFormatInfo.InvariantInfo);
-                       }
 
-                       xobileTlsContext = CreateContext (this, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, clientCertRequired);
+                       if (result.Error != null)
+                               result.Error.Throw ();
                }
 
                protected abstract MobileTlsContext CreateContext (
-                       MobileAuthenticatedStream parent, bool serverMode, string targetHost,
-                       SSA.SslProtocols enabledProtocols, X509Certificate serverCertificate,
-                       X509CertificateCollection clientCertificates, bool askForClientCert);
+                       bool serverMode, string targetHost, SSA.SslProtocols enabledProtocols,
+                       X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
+                       bool askForClientCert);
 
                public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
                {
-                       return BeginReadOrWrite (ref asyncReadRequest, ref readBuffer, ProcessRead, new BufferOffsetSize (buffer, offset, count), asyncCallback, asyncState);
+                       var asyncRequest = new AsyncReadRequest (this, false, buffer, offset, count);
+                       var task = StartOperation (OperationType.Read, asyncRequest, CancellationToken.None);
+                       return TaskToApm.Begin (task, asyncCallback, asyncState);
                }
 
                public override int EndRead (IAsyncResult asyncResult)
                {
-                       return (int)EndReadOrWrite (asyncResult, ref asyncReadRequest);
+                       return TaskToApm.End<int> (asyncResult);
                }
 
                public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
                {
-                       return BeginReadOrWrite (ref asyncWriteRequest, ref writeBuffer, ProcessWrite, new BufferOffsetSize (buffer, offset, count), asyncCallback, asyncState);
+                       var asyncRequest = new AsyncWriteRequest (this, false, buffer, offset, count);
+                       var task = StartOperation (OperationType.Write, asyncRequest, CancellationToken.None);
+                       return TaskToApm.Begin (task, asyncCallback, asyncState);
                }
 
                public override void EndWrite (IAsyncResult asyncResult)
                {
-                       EndReadOrWrite (asyncResult, ref asyncWriteRequest);
+                       TaskToApm.End (asyncResult);
                }
 
                public override int Read (byte[] buffer, int offset, int count)
                {
-                       return ProcessReadOrWrite (ref asyncReadRequest, ref readBuffer, ProcessRead, new BufferOffsetSize (buffer, offset, count), null);
+                       var asyncRequest = new AsyncReadRequest (this, true, buffer, offset, count);
+                       var task = StartOperation (OperationType.Read, asyncRequest, CancellationToken.None);
+                       return task.Result;
                }
 
                public void Write (byte[] buffer)
                {
                        Write (buffer, 0, buffer.Length);
                }
+
                public override void Write (byte[] buffer, int offset, int count)
                {
-                       ProcessReadOrWrite (ref asyncWriteRequest, ref writeBuffer, ProcessWrite, new BufferOffsetSize (buffer, offset, count), null);
+                       var asyncRequest = new AsyncWriteRequest (this, true, buffer, offset, count);
+                       var task = StartOperation (OperationType.Write, asyncRequest, CancellationToken.None);
+                       task.Wait ();
                }
 
-               IAsyncResult BeginReadOrWrite (ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize2 internalBuffer, AsyncOperation operation, BufferOffsetSize userBuffer, AsyncCallback asyncCallback, object asyncState)
+               public override Task<int> ReadAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken)
                {
-                       LazyAsyncResult lazyResult = new LazyAsyncResult (this, asyncState, asyncCallback);
-                       ProcessReadOrWrite (ref nestedRequest, ref internalBuffer, operation, userBuffer, lazyResult);
-                       return lazyResult;
+                       var asyncRequest = new AsyncReadRequest (this, false, buffer, offset, count);
+                       return StartOperation (OperationType.Read, asyncRequest, cancellationToken);
                }
 
-               object EndReadOrWrite (IAsyncResult asyncResult, ref AsyncProtocolRequest nestedRequest)
+               public override Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken)
                {
-                       if (asyncResult == null)
-                               throw new ArgumentNullException("asyncResult");
-
-                       var lazyResult = (LazyAsyncResult)asyncResult;
-
-                       if (Interlocked.Exchange (ref nestedRequest, null) == null)
-                               throw new InvalidOperationException ("Invalid end call.");
-
-                       // No "artificial" timeouts implemented so far, InnerStream controls timeout.
-                       lazyResult.InternalWaitForCompletion ();
-
-                       Debug ("EndReadOrWrite");
-
-                       var e = lazyResult.Result as Exception;
-                       if (e != null) {
-                               var ioEx = e as IOException;
-                               if (ioEx != null)
-                                       throw ioEx;
-                               throw new IOException ("read failed", e);
-                       }
-
-                       return lazyResult.Result;
+                       var asyncRequest = new AsyncWriteRequest (this, false, buffer, offset, count);
+                       return StartOperation (OperationType.Write, asyncRequest, cancellationToken);
                }
 
-               int ProcessReadOrWrite (ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize2 internalBuffer, AsyncOperation operation, BufferOffsetSize userBuffer, LazyAsyncResult lazyResult)
+               async Task<int> StartOperation (OperationType type, AsyncProtocolRequest asyncRequest, CancellationToken cancellationToken)
                {
-                       if (userBuffer == null || userBuffer.Buffer == null)
-                               throw new ArgumentNullException ("buffer");
-                       if (userBuffer.Offset < 0)
-                               throw new ArgumentOutOfRangeException ("offset");
-                       if (userBuffer.Size < 0 || userBuffer.Offset + userBuffer.Size > userBuffer.Buffer.Length)
-                               throw new ArgumentOutOfRangeException ("count");
-
-                       CheckThrow (true);
+                       CheckThrow (true, type != OperationType.Read);
+                       Debug ("StartOperationAsync: {0} {1}", asyncRequest, type);
 
-                       var name = internalBuffer == readBuffer ? "read" : "write";
-                       Debug ("ProcessReadOrWrite: {0} {1}", name, userBuffer);
+                       if (type == OperationType.Read) {
+                               if (Interlocked.CompareExchange (ref asyncReadRequest, asyncRequest, null) != null)
+                                       throw new InvalidOperationException ("Invalid nested call.");
+                       } else {
+                               if (Interlocked.CompareExchange (ref asyncWriteRequest, asyncRequest, null) != null)
+                                       throw new InvalidOperationException ("Invalid nested call.");
+                       }
 
-                       var asyncRequest = new AsyncProtocolRequest (this, lazyResult, userBuffer);
-                       return StartOperation (ref nestedRequest, ref internalBuffer, operation, asyncRequest, name);
-               }
+                       AsyncProtocolResult result;
 
-               int StartOperation (ref AsyncProtocolRequest nestedRequest, ref BufferOffsetSize2 internalBuffer, AsyncOperation operation, AsyncProtocolRequest asyncRequest, string name)
-               {
-                       if (Interlocked.CompareExchange (ref nestedRequest, asyncRequest, null) != null)
-                               throw new InvalidOperationException ("Invalid nested call.");
-
-                       bool failed = false;
                        try {
-                               internalBuffer.Reset ();
-                               asyncRequest.StartOperation (operation);
-                               return asyncRequest.UserResult;
+                               lock (ioLock) {
+                                       if (type == OperationType.Read)
+                                               readBuffer.Reset ();
+                                       else
+                                               writeBuffer.Reset ();
+                               }
+                               result = await asyncRequest.StartOperation (cancellationToken).ConfigureAwait (false);
                        } catch (Exception e) {
-                               failed = true;
-                               if (e is IOException)
-                                       throw;
-                               throw new IOException (name + " failed", e);
+                               var info = SetException (GetIOException (e, asyncRequest.Name + " failed"));
+                               result = new AsyncProtocolResult (info);
                        } finally {
-                               if (asyncRequest.UserAsyncResult == null || failed) {
-                                       internalBuffer.Reset ();
-                                       nestedRequest = null;
+                               lock (ioLock) {
+                                       if (type == OperationType.Read) {
+                                               readBuffer.Reset ();
+                                               asyncReadRequest = null;
+                                       } else {
+                                               writeBuffer.Reset ();
+                                               asyncWriteRequest = null;
+                                       }
                                }
                        }
+
+                       if (result.Error != null)
+                               result.Error.Throw ();
+                       return result.UserResult;
                }
 
                static int nextId;
@@ -384,26 +390,31 @@ namespace Mono.Net.Security
                        Console.Error.WriteLine ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
                }
 
-               #region Called back from native code via SslConnection
+#region Called back from native code via SslConnection
 
                /*
                 * Called from within SSLRead() and SSLHandshake().  We only access tha managed byte[] here.
                 */
-               internal int InternalRead (byte[] buffer, int offset, int size, out bool wantMore)
+               internal int InternalRead (byte[] buffer, int offset, int size, out bool outWantMore)
                {
                        try {
-                               Debug ("InternalRead: {0} {1} {2} {3}", offset, size, asyncReadRequest != null, readBuffer != null);
+                               Debug ("InternalRead: {0} {1} {2} {3} {4}", offset, size,
+                                      asyncHandshakeRequest != null ? "handshake" : "",
+                                      asyncReadRequest != null ? "async" : "",
+                                      readBuffer != null ? readBuffer.ToString () : "");
                                var asyncRequest = asyncHandshakeRequest ?? asyncReadRequest;
-                               return InternalRead (asyncRequest, readBuffer, buffer, offset, size, out wantMore);
+                               var (ret, wantMore) = InternalRead (asyncRequest, readBuffer, buffer, offset, size);
+                               outWantMore = wantMore;
+                               return ret;
                        } catch (Exception ex) {
                                Debug ("InternalRead failed: {0}", ex);
-                               SetException_internal (ex);
-                               wantMore = false;
+                               SetException (GetIOException (ex, "InternalRead() failed"));
+                               outWantMore = false;
                                return -1;
                        }
                }
 
-               int InternalRead (AsyncProtocolRequest asyncRequest, BufferOffsetSize internalBuffer, byte[] buffer, int offset, int size, out bool wantMore)
+               (int, bool) InternalRead (AsyncProtocolRequest asyncRequest, BufferOffsetSize internalBuffer, byte[] buffer, int offset, int size)
                {
                        if (asyncRequest == null)
                                throw new InvalidOperationException ();
@@ -422,11 +433,10 @@ namespace Mono.Net.Security
                         * native function again.
                         */
                        if (internalBuffer.Size == 0 && !internalBuffer.Complete) {
-                               Debug ("InternalRead #1: {0} {1}", internalBuffer.Offset, internalBuffer.TotalBytes);
+                               Debug ("InternalRead #1: {0} {1} {2}", internalBuffer.Offset, internalBuffer.TotalBytes, size);
                                internalBuffer.Offset = internalBuffer.Size = 0;
                                asyncRequest.RequestRead (size);
-                               wantMore = true;
-                               return 0;
+                               return (0, true);
                        }
 
                        /*
@@ -441,8 +451,7 @@ namespace Mono.Net.Security
                        Buffer.BlockCopy (internalBuffer.Buffer, internalBuffer.Offset, buffer, offset, len);
                        internalBuffer.Offset += len;
                        internalBuffer.Size -= len;
-                       wantMore = !internalBuffer.Complete && len < size;
-                       return len;
+                       return (len, !internalBuffer.Complete && len < size);
                }
 
                /*
@@ -456,7 +465,7 @@ namespace Mono.Net.Security
                                return InternalWrite (asyncRequest, writeBuffer, buffer, offset, size);
                        } catch (Exception ex) {
                                Debug ("InternalWrite failed: {0}", ex);
-                               SetException_internal (ex);
+                               SetException (GetIOException (ex, "InternalWrite() failed"));
                                return false;
                        }
                }
@@ -511,22 +520,30 @@ namespace Mono.Net.Security
                        return true;
                }
 
-               #endregion
+#endregion
 
-               #region Inner Stream
+#region Inner Stream
 
                /*
                 * Read / write data from the inner stream; we're only called from managed code and only manipulate
                 * the internal buffers.
                 */
-               internal int InnerRead (int requestedSize)
+               internal async Task<int> InnerRead (bool sync, int requestedSize, CancellationToken cancellationToken)
                {
+                       cancellationToken.ThrowIfCancellationRequested ();
                        Debug ("InnerRead: {0} {1} {2} {3}", readBuffer.Offset, readBuffer.Size, readBuffer.Remaining, requestedSize);
 
                        var len = System.Math.Min (readBuffer.Remaining, requestedSize);
                        if (len == 0)
                                throw new InvalidOperationException ();
-                       var ret = InnerStream.Read (readBuffer.Buffer, readBuffer.EndOffset, len);
+
+                       Task<int> task;
+                       if (sync)
+                               task = Task.Run (() => InnerStream.Read (readBuffer.Buffer, readBuffer.EndOffset, len));
+                       else
+                               task = InnerStream.ReadAsync (readBuffer.Buffer, readBuffer.EndOffset, len, cancellationToken);
+
+                       var ret = await task.ConfigureAwait (false);
                        Debug ("InnerRead done: {0} {1} - {2}", readBuffer.Remaining, len, ret);
 
                        if (ret >= 0) {
@@ -549,165 +566,126 @@ namespace Mono.Net.Security
                        return ret;
                }
 
-               internal void InnerWrite ()
+               internal async Task InnerWrite (bool sync, CancellationToken cancellationToken)
                {
+                       cancellationToken.ThrowIfCancellationRequested ();
                        Debug ("InnerWrite: {0} {1}", writeBuffer.Offset, writeBuffer.Size);
-                       InnerFlush ();
-               }
 
-               internal void InnerFlush ()
-               {
-                       if (writeBuffer.Size > 0) {
-                               InnerStream.Write (writeBuffer.Buffer, writeBuffer.Offset, writeBuffer.Size);
-                               writeBuffer.TotalBytes += writeBuffer.Size;
-                               writeBuffer.Offset = writeBuffer.Size = 0;
-                       }
+                       if (writeBuffer.Size == 0)
+                               return;
+
+                       Task task;
+                       if (sync)
+                               task = Task.Run (() => InnerStream.Write (writeBuffer.Buffer, writeBuffer.Offset, writeBuffer.Size));
+                       else
+                               task = InnerStream.WriteAsync (writeBuffer.Buffer, writeBuffer.Offset, writeBuffer.Size);
+
+                       await task.ConfigureAwait (false);
+
+                       writeBuffer.TotalBytes += writeBuffer.Size;
+                       writeBuffer.Offset = writeBuffer.Size = 0;
                }
 
-               #endregion
+#endregion
 
-               #region Main async I/O loop
+#region Main async I/O loop
 
-               AsyncOperationStatus ProcessHandshake (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status)
+               internal AsyncOperationStatus ProcessHandshake (AsyncOperationStatus status)
                {
                        Debug ("ProcessHandshake: {0}", status);
 
-                       /*
-                        * The first time we're called (AsyncOperationStatus.Initialize), we need to setup the SslContext and
-                        * start the handshake.
-                       */
-                       if (status == AsyncOperationStatus.Initialize) {
-                               xobileTlsContext.StartHandshake ();
-                               return AsyncOperationStatus.Continue;
-                       } else if (status == AsyncOperationStatus.ReadDone) {
-                               // remote prematurely closed connection.
-                               throw new IOException ("Remote prematurely closed connection.");
-                       } else if (status != AsyncOperationStatus.Continue) {
-                               throw new InvalidOperationException ();
-                       }
+                       lock (ioLock) {
+                               /*
+                                * The first time we're called (AsyncOperationStatus.Initialize), we need to setup the SslContext and
+                                * start the handshake.
+                               */
+                               if (status == AsyncOperationStatus.Initialize) {
+                                       xobileTlsContext.StartHandshake ();
+                                       return AsyncOperationStatus.Continue;
+                               } else if (status == AsyncOperationStatus.ReadDone) {
+                                       throw new IOException (SR.net_auth_eof);
+                               } else if (status != AsyncOperationStatus.Continue) {
+                                       throw new InvalidOperationException ();
+                               }
 
-                       /*
-                        * SSLHandshake() will return repeatedly with 'SslStatus.WouldBlock', we then need
-                        * to take care of I/O and call it again.
-                       */
-                       if (!xobileTlsContext.ProcessHandshake ()) {
                                /*
-                                * Flush the internal write buffer.
-                                */
-                               InnerFlush ();
+                                * SSLHandshake() will return repeatedly with 'SslStatus.WouldBlock', we then need
+                                * to take care of I/O and call it again.
+                               */
+                               if (xobileTlsContext.ProcessHandshake ()) {
+                                       xobileTlsContext.FinishHandshake ();
+                                       return AsyncOperationStatus.Complete;
+                               }
                                return AsyncOperationStatus.Continue;
                        }
-
-                       xobileTlsContext.FinishHandshake ();
-                       return AsyncOperationStatus.Complete;
                }
 
-               AsyncOperationStatus ProcessRead (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status)
+               internal (int, bool) ProcessRead (BufferOffsetSize userBuffer)
                {
-                       Debug ("ProcessRead - read user: {0} {1}", status, asyncRequest.UserBuffer);
-
-                       int ret;
-                       bool wantMore;
                        lock (ioLock) {
-                               ret = Context.Read (asyncRequest.UserBuffer.Buffer, asyncRequest.UserBuffer.Offset, asyncRequest.UserBuffer.Size, out wantMore);
+                               // This operates on the internal buffer and will never block.
+                               var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
+                               return (ret, wantMore);
                        }
-                       Debug ("ProcessRead - read user done: {0} - {1} {2}", asyncRequest.UserBuffer, ret, wantMore);
-
-                       if (ret < 0) {
-                               asyncRequest.UserResult = -1;
-                               return AsyncOperationStatus.Complete;
-                       }
-
-                       asyncRequest.CurrentSize += ret;
-                       asyncRequest.UserBuffer.Offset += ret;
-                       asyncRequest.UserBuffer.Size -= ret;
-
-                       Debug ("Process Read - read user done #1: {0} - {1} {2}", asyncRequest.UserBuffer, asyncRequest.CurrentSize, wantMore);
-
-                       if (wantMore && asyncRequest.CurrentSize == 0)
-                               return AsyncOperationStatus.WantRead;
-
-                       asyncRequest.ResetRead ();
-                       asyncRequest.UserResult = asyncRequest.CurrentSize;
-                       return AsyncOperationStatus.Complete;
                }
 
-               AsyncOperationStatus ProcessWrite (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status)
+               internal (int, bool) ProcessWrite (BufferOffsetSize userBuffer)
                {
-                       Debug ("ProcessWrite - write user: {0} {1}", status, asyncRequest.UserBuffer);
-
-                       if (asyncRequest.UserBuffer.Size == 0) {
-                               asyncRequest.UserResult = asyncRequest.CurrentSize;
-                               return AsyncOperationStatus.Complete;
-                       }
-
-                       int ret;
-                       bool wantMore;
                        lock (ioLock) {
-                               ret = Context.Write (asyncRequest.UserBuffer.Buffer, asyncRequest.UserBuffer.Offset, asyncRequest.UserBuffer.Size, out wantMore);
-                       }
-                       Debug ("ProcessWrite - write user done: {0} - {1} {2}", asyncRequest.UserBuffer, ret, wantMore);
-
-                       if (ret < 0) {
-                               asyncRequest.UserResult = -1;
-                               return AsyncOperationStatus.Complete;
+                               // This operates on the internal buffer and will never block.
+                               var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
+                               return (ret, wantMore);
                        }
-
-                       asyncRequest.CurrentSize += ret;
-                       asyncRequest.UserBuffer.Offset += ret;
-                       asyncRequest.UserBuffer.Size -= ret;
-
-                       if (wantMore || writeBuffer.Size > 0)
-                               return AsyncOperationStatus.WantWrite;
-
-                       asyncRequest.ResetWrite ();
-                       asyncRequest.UserResult = asyncRequest.CurrentSize;
-                       return AsyncOperationStatus.Complete;
                }
 
-               AsyncOperationStatus ProcessClose (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status)
+               internal AsyncOperationStatus ProcessShutdown (AsyncOperationStatus status)
                {
-                       Debug ("ProcessClose: {0}", status);
+                       Debug ("ProcessShutdown: {0}", status);
 
                        lock (ioLock) {
-                               if (xobileTlsContext == null)
-                                       return AsyncOperationStatus.Complete;
-
-                               xobileTlsContext.Close ();
-                               xobileTlsContext = null;
-                               return AsyncOperationStatus.Continue;
+                               xobileTlsContext.Shutdown ();
+                               shutdown = true;
+                               return AsyncOperationStatus.Complete;
                        }
                }
 
-               AsyncOperationStatus ProcessFlush (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status)
-               {
-                       Debug ("ProcessFlush: {0}", status);
-                       return AsyncOperationStatus.Complete;
-               }
-
-               #endregion
+#endregion
 
                public override bool IsServer {
-                       get { return xobileTlsContext != null && xobileTlsContext.IsServer; }
+                       get {
+                               CheckThrow (false);
+                               return xobileTlsContext != null && xobileTlsContext.IsServer;
+                       }
                }
 
                public override bool IsAuthenticated {
-                       get { return xobileTlsContext != null && lastException == null && xobileTlsContext.IsAuthenticated; }
+                       get {
+                               lock (ioLock) {
+                                       // Don't use CheckThrow(), we want to return false if we're not authenticated.
+                                       return xobileTlsContext != null && lastException == null && xobileTlsContext.IsAuthenticated;
+                               }
+                       }
                }
 
                public override bool IsMutuallyAuthenticated {
                        get {
-                               return IsAuthenticated &&
-                                       (Context.IsServer? Context.LocalServerCertificate: Context.LocalClientCertificate) != null &&
-                                       Context.IsRemoteCertificateAvailable;
+                               lock (ioLock) {
+                                       // Don't use CheckThrow() here.
+                                       if (!IsAuthenticated)
+                                               return false;
+                                       if ((xobileTlsContext.IsServer ? xobileTlsContext.LocalServerCertificate : xobileTlsContext.LocalClientCertificate) == null)
+                                               return false;
+                                       return xobileTlsContext.IsRemoteCertificateAvailable;
+                               }
                        }
                }
 
                protected override void Dispose (bool disposing)
                {
                        try {
-                               lastException = new ObjectDisposedException ("MobileAuthenticatedStream");
                                lock (ioLock) {
+                                       Debug ("Dispose: {0}", xobileTlsContext != null);
+                                       lastException = ExceptionDispatchInfo.Capture (new ObjectDisposedException ("MobileAuthenticatedStream"));
                                        if (xobileTlsContext != null) {
                                                xobileTlsContext.Dispose ();
                                                xobileTlsContext = null;
@@ -720,26 +698,53 @@ namespace Mono.Net.Security
 
                public override void Flush ()
                {
-                       CheckThrow (true);
-                       var asyncRequest = new AsyncProtocolRequest (this, null);
-                       StartOperation (ref asyncWriteRequest, ref writeBuffer, ProcessFlush, asyncRequest, "flush");
+                       // Write() automatically flushes the underlying stream.
                }
 
-               public override void Close ()
-               {
-                       /*
-                        * SSLClose() is a little bit tricky as it might attempt to send a close_notify alert
-                        * and thus call our write callback.
-                        *
-                        * It is also not thread-safe with SSLRead() or SSLWrite(), so we need to take the I/O lock here.
-                        */
-                       if (Interlocked.Exchange (ref closeRequested, 1) == 1)
-                               return;
-                       if (xobileTlsContext == null)
-                               return;
+               public SslProtocols SslProtocol {
+                       get {
+                               lock (ioLock) {
+                                       CheckThrow (true);
+                                       return (SslProtocols)xobileTlsContext.NegotiatedProtocol;
+                               }
+                       }
+               }
+
+               public X509Certificate RemoteCertificate {
+                       get {
+                               lock (ioLock) {
+                                       CheckThrow (true);
+                                       return xobileTlsContext.RemoteCertificate;
+                               }
+                       }
+               }
+
+               public X509Certificate LocalCertificate {
+                       get {
+                               lock (ioLock) {
+                                       CheckThrow (true);
+                                       return InternalLocalCertificate;
+                               }
+                       }
+               }
+
+               public X509Certificate InternalLocalCertificate {
+                       get {
+                               lock (ioLock) {
+                                       CheckThrow (false);
+                                       if (xobileTlsContext == null)
+                                               return null;
+                                       return xobileTlsContext.IsServer ? xobileTlsContext.LocalServerCertificate : xobileTlsContext.LocalClientCertificate;
+                               }
+                       }
+               }
 
-                       var asyncRequest = new AsyncProtocolRequest (this, null);
-                       StartOperation (ref asyncWriteRequest, ref writeBuffer, ProcessClose, asyncRequest, "close");
+               public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
+               {
+                       lock (ioLock) {
+                               CheckThrow (true);
+                               return xobileTlsContext.ConnectionInfo;
+                       }
                }
 
                //
@@ -769,7 +774,7 @@ namespace Mono.Net.Security
                }
 
                public override bool CanWrite {
-                       get { return IsAuthenticated & InnerStream.CanWrite; }
+                       get { return IsAuthenticated & InnerStream.CanWrite && !shutdown; }
                }
 
                public override bool CanSeek {
@@ -803,46 +808,10 @@ namespace Mono.Net.Security
                        set { InnerStream.WriteTimeout = value; }
                }
 
-               public SslProtocols SslProtocol {
-                       get {
-                               CheckThrow (true);
-                               return (SslProtocols)Context.NegotiatedProtocol;
-                       }
-               }
-
-               public X509Certificate RemoteCertificate {
-                       get {
-                               CheckThrow (true);
-                               return Context.RemoteCertificate;
-                       }
-               }
-
-               public X509Certificate LocalCertificate {
-                       get {
-                               CheckThrow (true);
-                               return InternalLocalCertificate;
-                       }
-               }
-
-               public X509Certificate InternalLocalCertificate {
-                       get {
-                               CheckThrow (false);
-                               if (!HasContext)
-                                       return null;
-                               return Context.IsServer ? Context.LocalServerCertificate : Context.LocalClientCertificate;
-                       }
-               }
-
-               public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
-               {
-                       CheckThrow (true);
-                       return Context.ConnectionInfo;
-               }
-
                public SSA.CipherAlgorithmType CipherAlgorithm {
                        get {
                                CheckThrow (true);
-                               var info = Context.ConnectionInfo;
+                               var info = GetConnectionInfo ();
                                if (info == null)
                                        return SSA.CipherAlgorithmType.None;
                                switch (info.CipherAlgorithmType) {
@@ -861,7 +830,7 @@ namespace Mono.Net.Security
                public SSA.HashAlgorithmType HashAlgorithm {
                        get {
                                CheckThrow (true);
-                               var info = Context.ConnectionInfo;
+                               var info = GetConnectionInfo ();
                                if (info == null)
                                        return SSA.HashAlgorithmType.None;
                                switch (info.HashAlgorithmType) {
@@ -883,7 +852,7 @@ namespace Mono.Net.Security
                public SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
                        get {
                                CheckThrow (true);
-                               var info = Context.ConnectionInfo;
+                               var info = GetConnectionInfo ();
                                if (info == null)
                                        return SSA.ExchangeAlgorithmType.None;
                                switch (info.ExchangeAlgorithmType) {
@@ -898,7 +867,7 @@ namespace Mono.Net.Security
                        }
                }
 
-               #region Need to Implement
+#region Need to Implement
                public int CipherStrength {
                        get {
                                throw new NotImplementedException ();
@@ -920,7 +889,7 @@ namespace Mono.Net.Security
                        }
                }
 
-               #endregion
+#endregion
        }
 }
 #endif
index 79f0468d4619aee415b238d9171366fe801abb8e..b4ba1c014cabf7cb5e47d7410d46d19e5aa10106 100644 (file)
@@ -169,7 +169,7 @@ namespace Mono.Net.Security
 
                public abstract int Write (byte[] buffer, int offset, int count, out bool wantMore);
 
-               public abstract void Close ();
+               public abstract void Shutdown ();
 
                protected bool ValidateCertificate (X509Certificate leaf, X509Chain chain)
                {
index 96d81315139bdede6a05c6d2a4b36aeb5701b453..660e3b41bb6b5e5ca366a52dfbba32ad5810830e 100644 (file)
@@ -83,6 +83,8 @@ namespace Mono.Net.Security
                                if (initialized)
                                        return;
 
+                               InitializeProviderRegistration ();
+
                                MSI.MonoTlsProvider provider;
                                try {
                                        provider = CreateDefaultProviderImpl ();
index cfcd038e9b54b2ee876d4b8b5d5010f9275ecacd..896362d98a4b14de35203b4f70c0a0f812c7de14 100644 (file)
@@ -9,6 +9,8 @@ partial class SR
 {
        public const string mono_net_io_shutdown = "mono_net_io_shutdown";
        public const string mono_net_io_renegotiate = "mono_net_io_renegotiate";
+       
+       public const string net_ssl_io_already_shutdown = "Write operations are not allowed after the channel was shutdown.";
 
        public const string net_log_set_socketoption_reuseport_default_on = "net_log_set_socketoption_reuseport_default_on";
        public const string net_log_set_socketoption_reuseport_not_supported = "net_log_set_socketoption_reuseport_not_supported";
index fe514b868d2ddd7479dee6238a5848350be33611..f80d759f63d222ebc29626a9db2e8a5ebbeb9b49 100644 (file)
@@ -56,6 +56,7 @@ namespace System.ComponentModel
                        case 6000: /* ERROR_ENCRYPTION_FAILED */ return "Encryption failed";
                        case 10004: /* WSAEINTR */ return "interrupted";
                        case 10009: /* WSAEBADF */ return "Bad file number";
+                       case 10013: /* WSAEACCES */ return "Access denied";
                        case 10014: /* WSAEFAULT */ return "Bad address";
                        case 10022: /* WSAEINVAL */ return "Invalid arguments";
                        case 10024: /* WSAEMFILE */ return "Too many open files";
@@ -1600,7 +1601,6 @@ namespace System.ComponentModel
                        case 9904: /* DNS_ERROR_DP_ALREADY_ENLISTED */ return "DNS error dp already enlisted";
                        case 10110: /* WSA_E_NO_MORE */ return "E_NO_MORE";
                        case 10111: /* WSA_E_CANCELLED */ return "E_CANCELLED";
-                       case 10013: /* WSAEACCES */ return "Access denied";
                        case 11005: /* WSA_QOS_RECEIVERS */ return "QOS receivers";
                        case 11006: /* WSA_QOS_SENDERS */ return "QOS senders";
                        case 11007: /* WSA_QOS_NO_SENDERS */ return "QOS no senders";
index 84e50a619d6a57f3ed03cb770bece9d664e6d9ae..2019ff147ada8755c24dd360369272f9d852f4ab 100644 (file)
@@ -61,8 +61,10 @@ namespace System.Net.Configuration
                        properties = new ConfigurationPropertyCollection ();
 
                        properties.Add (bypassListProp);
+                       properties.Add (enabledProp);
                        properties.Add (moduleProp);
                        properties.Add (proxyProp);
+                       properties.Add (useDefaultCredentialsProp);
                }
 
                public DefaultProxySection ()
index bce70c4277ca1876cd8b5a961e86481e1f8053e0..bbe366aa292700e84a3a9cd9dc5893cbc24b5f3d 100644 (file)
@@ -62,6 +62,7 @@ namespace System.Net.Configuration
 
                        properties = new ConfigurationPropertyCollection ();
                                                                    
+                       properties.Add (autoDetectProp);
                        properties.Add (bypassOnLocalProp);
                        properties.Add (proxyAddressProp);
                        properties.Add (scriptLocationProp);
index f1f5936be75cab98e14fe59bf44fafafe3cef09f..0ef32ad34334afc54328783b840d15ef2bb45380 100644 (file)
@@ -207,17 +207,6 @@ namespace System.Net.NetworkInformation {
                        return Send (addresses [0], timeout, buffer, options);
                }
 
-               static IPAddress GetNonLoopbackIPV4 ()
-               {
-#pragma warning disable 618
-                       foreach (IPAddress addr in Dns.GetHostByName (Dns.GetHostName ()).AddressList)
-                               if (!IPAddress.IsLoopback (addr) && addr.AddressFamily == AddressFamily.InterNetwork)
-                                       return addr;
-#pragma warning restore 618
-
-                       throw new InvalidOperationException ("Could not resolve non-loopback IP address for localhost");
-               }
-
                public PingReply Send (IPAddress address, int timeout, byte [] buffer, PingOptions options)
                {
                        if (address == null)
@@ -243,8 +232,7 @@ namespace System.Net.NetworkInformation {
                private PingReply SendPrivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options)
                {
                        IPEndPoint target = new IPEndPoint (address, 0);
-                       IPEndPoint client = new IPEndPoint (GetNonLoopbackIPV4 (), 0);
-
+                       
                        // FIXME: support IPv6
                        using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp)) {
                                if (options != null) {
@@ -264,7 +252,7 @@ namespace System.Net.NetworkInformation {
                                // receive
                                bytes = new byte [100];
                                do {
-                                       EndPoint endpoint = client;
+                                       EndPoint endpoint = target;
                                        SocketError error = 0;
                                        int rc = s.ReceiveFrom (bytes, 0, 100, SocketFlags.None,
                                                        ref endpoint, out error);
index 6d61e08dfb1bf659161ca1869175ffa3e70cdb16..c0b702fde1b2f92798271fdf943402e1460eb27a 100644 (file)
@@ -223,6 +223,11 @@ namespace System.Net.Security
                        return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
                }
 
+               public virtual Task ShutdownAsync ()
+               {
+                       return Impl.ShutdownAsync ();
+               }
+
                public override bool IsAuthenticated {
                        get { return Impl.IsAuthenticated; }
                }
index 06fefad105ac81e87e83fa25a76f8b3dc74e8343..1c2a4167301b6df077b7ef1467aa4fd626571d22 100644 (file)
@@ -152,6 +152,11 @@ namespace System.Net.Security
                        throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
                }
 
+               public virtual Task ShutdownAsync ()
+               {
+                       throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
+               }
+
                public override bool IsAuthenticated {
                        get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
                }
index 89911c426b4420c4cc944c0dea38db8850a40204..d19756b6c30013be319b87d94a0747081fc47394 100644 (file)
@@ -976,60 +976,7 @@ namespace System.Net.Sockets
                                EndPoint = remoteEP,
                        };
 
-                       // Bug #75154: Connect() should not succeed for .Any addresses.
-                       if (remoteEP is IPEndPoint) {
-                               IPEndPoint ep = (IPEndPoint) remoteEP;
-                               if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)) {
-                                       sockares.Complete (new SocketException ((int) SocketError.AddressNotAvailable), true);
-                                       return sockares;
-                               }
-
-                               sockares.EndPoint = remoteEP = RemapIPEndPoint (ep);
-                       }
-
-                       int error = 0;
-
-                       if (connect_in_progress) {
-                               // This could happen when multiple IPs are used
-                               // Calling connect() again will reset the connection attempt and cause
-                               // an error. Better to just close the socket and move on.
-                               connect_in_progress = false;
-                               m_Handle.Dispose ();
-                               m_Handle = new SafeSocketHandle (Socket_internal (addressFamily, socketType, protocolType, out error), true);
-                               if (error != 0)
-                                       throw new SocketException (error);
-                       }
-
-                       bool blk = is_blocking;
-                       if (blk)
-                               Blocking = false;
-                       Connect_internal (m_Handle, remoteEP.Serialize (), out error, false);
-                       if (blk)
-                               Blocking = true;
-
-                       if (error == 0) {
-                               // succeeded synch
-                               is_connected = true;
-                               is_bound = true;
-                               sockares.Complete (true);
-                               return sockares;
-                       }
-
-                       if (error != (int) SocketError.InProgress && error != (int) SocketError.WouldBlock) {
-                               // error synch
-                               is_connected = false;
-                               is_bound = false;
-                               sockares.Complete (new SocketException (error), true);
-                               return sockares;
-                       }
-
-                       // continue asynch
-                       is_connected = false;
-                       is_bound = false;
-                       connect_in_progress = true;
-
-                       IOSelector.Add (sockares.Handle, new IOSelectorJob (IOOperation.Write, BeginConnectCallback, sockares));
-
+                       BeginSConnect (sockares);
                        return sockares;
                }
 
@@ -1055,39 +1002,85 @@ namespace System.Net.Sockets
 
                        is_connected = false;
 
-                       return BeginMConnect (sockares);
+                       BeginMConnect (sockares);
+                       return sockares;
                }
 
-               internal IAsyncResult BeginMConnect (SocketAsyncResult sockares)
+               static void BeginMConnect (SocketAsyncResult sockares)
                {
-                       SocketAsyncResult ares = null;
                        Exception exc = null;
-                       AsyncCallback callback;
 
                        for (int i = sockares.CurrentAddress; i < sockares.Addresses.Length; i++) {
                                try {
                                        sockares.CurrentAddress++;
+                                       sockares.EndPoint = new IPEndPoint (sockares.Addresses [i], sockares.Port);
 
-                                       ares = (SocketAsyncResult) BeginConnect (new IPEndPoint (sockares.Addresses [i], sockares.Port), null, sockares);
-                                       if (ares.IsCompleted && ares.CompletedSynchronously) {
-                                               ares.CheckIfThrowDelayedException ();
-
-                                               callback = ares.AsyncCallback;
-                                               if (callback != null)
-                                                       ThreadPool.UnsafeQueueUserWorkItem (_ => callback (ares), null);
-                                       }
-
-                                       break;
+                                       BeginSConnect (sockares);
+                                       return;
                                } catch (Exception e) {
                                        exc = e;
-                                       ares = null;
                                }
                        }
 
-                       if (ares == null)
-                               throw exc;
+                       throw exc;
+               }
 
-                       return sockares;
+               static void BeginSConnect (SocketAsyncResult sockares)
+               {
+                       EndPoint remoteEP = sockares.EndPoint;
+                       // Bug #75154: Connect() should not succeed for .Any addresses.
+                       if (remoteEP is IPEndPoint) {
+                               IPEndPoint ep = (IPEndPoint) remoteEP;
+                               if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)) {
+                                       sockares.Complete (new SocketException ((int) SocketError.AddressNotAvailable), true);
+                                       return;
+                               }
+
+                               sockares.EndPoint = remoteEP = sockares.socket.RemapIPEndPoint (ep);
+                       }
+
+                       int error = 0;
+
+                       if (sockares.socket.connect_in_progress) {
+                               // This could happen when multiple IPs are used
+                               // Calling connect() again will reset the connection attempt and cause
+                               // an error. Better to just close the socket and move on.
+                               sockares.socket.connect_in_progress = false;
+                               sockares.socket.m_Handle.Dispose ();
+                               sockares.socket.m_Handle = new SafeSocketHandle (sockares.socket.Socket_internal (sockares.socket.addressFamily, sockares.socket.socketType, sockares.socket.protocolType, out error), true);
+                               if (error != 0)
+                                       throw new SocketException (error);
+                       }
+
+                       bool blk = sockares.socket.is_blocking;
+                       if (blk)
+                               sockares.socket.Blocking = false;
+                       Connect_internal (sockares.socket.m_Handle, remoteEP.Serialize (), out error, false);
+                       if (blk)
+                               sockares.socket.Blocking = true;
+
+                       if (error == 0) {
+                               // succeeded synch
+                               sockares.socket.is_connected = true;
+                               sockares.socket.is_bound = true;
+                               sockares.Complete (true);
+                               return;
+                       }
+
+                       if (error != (int) SocketError.InProgress && error != (int) SocketError.WouldBlock) {
+                               // error synch
+                               sockares.socket.is_connected = false;
+                               sockares.socket.is_bound = false;
+                               sockares.Complete (new SocketException (error), true);
+                               return;
+                       }
+
+                       // continue asynch
+                       sockares.socket.is_connected = false;
+                       sockares.socket.is_bound = false;
+                       sockares.socket.connect_in_progress = true;
+
+                       IOSelector.Add (sockares.Handle, new IOSelectorJob (IOOperation.Write, BeginConnectCallback, sockares));
                }
 
                static IOAsyncCallback BeginConnectCallback = new IOAsyncCallback (ares => {
@@ -1098,18 +1091,11 @@ namespace System.Net.Sockets
                                return;
                        }
 
-                       SocketAsyncResult mconnect = sockares.AsyncState as SocketAsyncResult;
-                       bool is_mconnect = mconnect != null && mconnect.Addresses != null;
-
                        try {
-                               EndPoint ep = sockares.EndPoint;
-                               int error_code = (int) sockares.socket.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
-
-                               if (error_code == 0) {
-                                       if (is_mconnect)
-                                               sockares = mconnect;
+                               int error = (int) sockares.socket.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
 
-                                       sockares.socket.seed_endpoint = ep;
+                               if (error == 0) {
+                                       sockares.socket.seed_endpoint = sockares.EndPoint;
                                        sockares.socket.is_connected = true;
                                        sockares.socket.is_bound = true;
                                        sockares.socket.connect_in_progress = false;
@@ -1118,26 +1104,21 @@ namespace System.Net.Sockets
                                        return;
                                }
 
-                               if (!is_mconnect) {
+                               if (sockares.Addresses == null) {
                                        sockares.socket.connect_in_progress = false;
-                                       sockares.Complete (new SocketException (error_code));
+                                       sockares.Complete (new SocketException (error));
                                        return;
                                }
 
-                               if (mconnect.CurrentAddress >= mconnect.Addresses.Length) {
-                                       mconnect.Complete (new SocketException (error_code));
+                               if (sockares.CurrentAddress >= sockares.Addresses.Length) {
+                                       sockares.Complete (new SocketException (error));
                                        return;
                                }
 
-                               mconnect.socket.BeginMConnect (mconnect);
+                               BeginMConnect (sockares);
                        } catch (Exception e) {
                                sockares.socket.connect_in_progress = false;
-
-                               if (is_mconnect)
-                                       sockares = mconnect;
-
                                sockares.Complete (e);
-                               return;
                        }
                });
 
index 419035efe15fe3ad31aac61aa2ba427ccc397620..57c549fd2a23ddc44c6fe28c16ed6c84180c9d7e 100644 (file)
@@ -262,7 +262,6 @@ namespace System.Net.Sockets
                        SetResults(SocketError.Success, bytesTransferred, flags);
                        current_socket = connectSocket;
 
-                       Complete ();
                        OnCompleted (this);
                }
 
diff --git a/mcs/class/System/System.Net.WebSockets/HttpListenerWebSocketContext.platformnotsupported.cs b/mcs/class/System/System.Net.WebSockets/HttpListenerWebSocketContext.platformnotsupported.cs
new file mode 100644 (file)
index 0000000..99fc21b
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// HttpListenerWebSocketContext.platformnotsupported.cs
+//
+// Author:
+//       Marek Safar <marek.safar@gmail.com>
+//
+// Copyright (c) 2017 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.
+//
+
+namespace System.Net.WebSockets
+{
+       public partial class HttpListenerWebSocketContext : System.Net.WebSockets.WebSocketContext
+       {
+               const string EXCEPTION_MESSAGE = "System.Net.WebSockets.HttpListenerWebSocketContext is not supported on the current platform.";
+
+               private HttpListenerWebSocketContext() { }
+               public override System.Net.CookieCollection CookieCollection { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override System.Collections.Specialized.NameValueCollection Headers { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override bool IsAuthenticated { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override bool IsLocal { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override bool IsSecureConnection { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override string Origin { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override System.Uri RequestUri { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override string SecWebSocketKey { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override System.Collections.Generic.IEnumerable<string> SecWebSocketProtocols { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override string SecWebSocketVersion { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override System.Security.Principal.IPrincipal User { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+               public override System.Net.WebSockets.WebSocket WebSocket { get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); } }
+       }
+}
\ No newline at end of file
index 61e5b6472b96582b820051cf9f4e7de47e65aa85..a38c2ff9c486fded93b9ba91633e543ae750671d 100644 (file)
@@ -276,6 +276,7 @@ ReferenceSources/SettingsSectionInternal.cs
 ReferenceSources/SecureStringHelper.cs
 ReferenceSources/Socket.cs
 ReferenceSources/SR.cs
+ReferenceSources/SR2.cs
 ReferenceSources/SRCategoryAttribute.cs
 ReferenceSources/Win32Exception.cs
 
@@ -918,8 +919,6 @@ corefx/SR.cs
 ../../../external/corefx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocketOptions.cs
 ../../../external/corefx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs
 
-../../../external/corefx/src/System.Net.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs
-
 ../../../external/corefx/src/System.Private.Uri/src/System/UriBuilder.cs
 
 ../../../external/corefx/src/System.Runtime.Extensions/src/System/CodeDom/Compiler/IndentedTextWriter.cs
index 548180b26cb54581b23037a3fba50b27d110973b..f161a1657e9e8f21a53aeb135f7a0271d4ea5b82 100644 (file)
@@ -51,3 +51,5 @@ System.Net/WebConnectionStream.cs
 ../referencesource/System/net/System/Net/Sockets/TCPClient.cs
 ../referencesource/System/net/System/Net/Sockets/TCPListener.cs
 ../referencesource/System/net/System/Net/Sockets/UDPClient.cs
+
+../../../external/corefx/src/System.Net.HttpListener/src/System/Net/WebSockets/HttpListenerWebSocketContext.cs
index ad5e4c7bee884a6c7cc123110d6a27ecf7e6567b..c639ae74fae81646c705daed98799b1a5629ab9e 100644 (file)
@@ -19,4 +19,5 @@ System.Net/HttpWebRequest.platformnotsupported.cs
 System.Net/HttpWebResponse.platformnotsupported.cs
 System.Net/ServicePoint.platformnotsupported.cs
 System.Net/ServicePointManager.platformnotsupported.cs
+System.Net.WebSockets/HttpListenerWebSocketContext.platformnotsupported.cs
 ../Mono.Security/Mono.Security.X509.Extensions/AuthorityKeyIdentifierExtension.cs
index 46b53b430521e615b5766bb2d9fd720efbd9d4ed..110199b4bcd9869ae5ed238045261358ed207c23 100644 (file)
@@ -245,7 +245,6 @@ Mono.Net.Dns/ResolverError.cs
 Mono.Net.Dns/SimpleResolverEventArgs.cs
 ReferenceSources/BinaryCompatibility.cs
 ReferenceSources/ConfigurationManagerInternalFactory.cs
-ReferenceSources/SR2.cs
 
 ../referencesource/System/misc/PrivilegedConfigurationManager.cs
 
diff --git a/mcs/class/Xunit.NetCore.Extensions/Makefile b/mcs/class/Xunit.NetCore.Extensions/Makefile
deleted file mode 100644 (file)
index 5be627d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-thisdir = class/Xunit.NetCore.Extensions
-SUBDIRS = 
-include ../../build/rules.make
-
-XUNIT_LIBS := xunit.core xunit.abstractions xunit.execution.desktop xunit.assert
-
-LIBRARY = Xunit.NetCore.Extensions.dll
-LIB_REFS = System System.Core System.Runtime.InteropServices.RuntimeInformation Facades/System.Runtime Facades/System.Threading.Tasks
-LIB_MCS_FLAGS = $(patsubst %,-r:$(topdir)/../external/xunit-binaries/%.dll,$(XUNIT_LIBS))
-
-EXTRA_DISTFILES =
-
-NO_TEST = yes
-NO_INSTALL = yes
-NO_SIGN_ASSEMBLY = yes
-
-include ../../build/library.make
diff --git a/mcs/class/Xunit.NetCore.Extensions/Microsoft.Xunit.Performance/BenchmarkAttribute.cs b/mcs/class/Xunit.NetCore.Extensions/Microsoft.Xunit.Performance/BenchmarkAttribute.cs
deleted file mode 100644 (file)
index 5697d10..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using Xunit;
-using Xunit.Sdk;
-
-namespace Microsoft.Xunit.Performance
-{
-       [TraitDiscoverer("Microsoft.Xunit.Performance.BenchmarkDiscoverer", "Xunit.NetCore.Extensions")]
-       [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
-       public class BenchmarkAttribute : Attribute, ITraitAttribute
-       {
-               public long InnerIterationCount { get; set; }
-       }
-}
diff --git a/mcs/class/Xunit.NetCore.Extensions/Microsoft.Xunit.Performance/BenchmarkDiscover.cs b/mcs/class/Xunit.NetCore.Extensions/Microsoft.Xunit.Performance/BenchmarkDiscover.cs
deleted file mode 100644 (file)
index 40d2d8a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Collections.Generic;
-using Xunit.Sdk;
-using Xunit.Abstractions;
-
-namespace Xunit.NetCore.Extensions
-{
-    public class BenchmarkDiscoverer : ITraitDiscoverer
-    {
-        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
-        {
-            yield return new KeyValuePair<string, string>("Benchmark", "True");
-        }
-    }
-}
diff --git a/mcs/class/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.dll.sources b/mcs/class/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.dll.sources
deleted file mode 100644 (file)
index 145dae4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-../../../external/buildtools/src/xunit.netcore.extensions/*.cs
-../../../external/buildtools/src/xunit.netcore.extensions/Attributes/*.cs
-../../../external/buildtools/src/xunit.netcore.extensions/Discoverers/*.cs
-
-Microsoft.Xunit.Performance/BenchmarkAttribute.cs
-Microsoft.Xunit.Performance/BenchmarkDiscover.cs
index 9cd987fabb54d3737dabbaf25aa38a4dba2c437f..d070a293e3680d8ed0e22f05c90918f313f93dd2 100644 (file)
@@ -8,7 +8,7 @@ thisdir = class/aot-compiler
 
 include ../../build/rules.make
 
-the_libdir = $(topdir)/class/lib/$(PROFILE)/
+the_libdir = $(topdir)/class/lib/$(PROFILE_DIRECTORY)/
 CSC_DIR = $(dir $(CSC_LOCATION))
 # The directory where the AOT images are stored
 images_dir = $(the_libdir)
@@ -38,6 +38,8 @@ runtime_dep = $(dir $(RUNTIME))/../mono/mini/mono
 PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
 LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
 
+LOG_FILE = $(PROFILE_DIRECTORY)_aot.log
+
 ifndef SKIP_AOT
 
 profile_file:=$(wildcard $(topdir)/class/lib/build/csc.*.aotprofile)
@@ -50,32 +52,32 @@ endif
 
 ifdef PLATFORM_AOT_SUFFIX
 $(mcs_aot_image): $(mcs_exe) $(mscorlib_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(mcs_aot_image) --debug $(mcs_exe) || cat $(PROFILE)_aot.log || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(mcs_aot_image) --debug $(mcs_exe) || cat $(LOG_FILE) || (cat $(LOG_FILE); exit 1)
 
 $(csc_aot_image): $(csc_exe) $(mscorlib_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_aot_image) --debug $(csc_exe) || cat $(PROFILE)_aot.log || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_aot_image) --debug $(csc_exe) || cat $(LOG_FILE) || (cat $(LOG_FILE); exit 1)
 
 $(mscorlib_aot_image): $(mscorlib_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg) --debug $(mscorlib_dll) || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg) --debug $(mscorlib_dll) || (cat $(LOG_FILE); exit 1)
 
 $(csc_MC_image): $(csc_MC_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_MC_image) --debug $(csc_MC_dll) || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_MC_image) --debug $(csc_MC_dll) || (cat $(LOG_FILE); exit 1)
 
 $(csc_MCS_image): $(csc_MCS_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_MCS_image) --debug $(csc_MCS_dll) || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_MCS_image) --debug $(csc_MCS_dll) || (cat $(LOG_FILE); exit 1)
 
 $(csc_SRM_image): $(csc_SRM_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_SRM_image) --debug --apply-bindings=$(csc_exe).config $(csc_SRM_dll) || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_SRM_image) --debug --apply-bindings=$(csc_exe).config $(csc_SRM_dll) || (cat $(LOG_FILE); exit 1)
 
 $(csc_SCI_image): $(csc_SCI_dll) $(runtime_dep)
-       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_SCI_image) --debug $(csc_SCI_dll) || (cat $(PROFILE)_aot.log; exit 1)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(LOG_FILE) 2>&1 $(RUNTIME) --aot=bind-to-runtime-version$(profile_arg),outfile=$(csc_SCI_image) --debug $(csc_SCI_dll) || (cat $(LOG_FILE); exit 1)
 
 ifdef ENABLE_AOT
 
 CSC_IMAGES = $(csc_aot_image) $(csc_SRM_image) $(csc_SCI_image) $(csc_MC_image) $(csc_MCS_image)
 
 clean-local:
-       -rm -f $(mscorlib_aot_image) $(mcs_aot_image) $(CSC_IMAGES) $(PROFILE)_aot.log
+       -rm -f $(mscorlib_aot_image) $(mcs_aot_image) $(CSC_IMAGES) $(LOG_FILE)
 
 # AOT build profile to speed up build
 ifeq ($(PROFILE),build)
diff --git a/mcs/class/build-rx-dll-sources.sh b/mcs/class/build-rx-dll-sources.sh
deleted file mode 100644 (file)
index 0eeb671..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-
-// useful grep
-// grep -h "#if" /svn/mono/external/rx/Rx/NET/Source/System.Reactive.*/*.cs /svn/mono/external/rx/Rx/NET/Source/System.Reactive.*/*/*.cs /svn/mono/external/rx/Rx/NET/Source/System.Reactive.*/*/*/*.cs | sort | uniq
-
-using System.Diagnostics;
-using System.IO;
-using System.Xml.Linq;
-using System.Xml.XPath;
-
-var template_android = File.ReadAllText ("project_template_android.txt");
-var template_ios = File.ReadAllText ("project_template_ios.txt");
-
-var guids_android = new string [] { 
-// Ix
-"5F7F40B6-19D3-48C7-8E15-AE1F976F60E1", "065F2411-7610-4AD6-9513-A1EFFCE576C0",
-"C4037060-1692-4423-B29E-76F3A74A72A5",
-// Rx
-"4fa878dc-6e88-43c4-b37b-8c1151cec56f", "fef62c23-10cd-4def-a5ae-54a8b309e970", "d263c126-9d3c-4299-a0c1-f25c703d07c9", "ec704077-ea31-4852-ad24-6732244174c0", "9360e845-d79d-4288-9100-63a80fad2bf0", "00dc3654-e373-4e3f-80fe-109f795adf1f", "e662282b-4341-4f86-aaaa-a942335b47fb", "a153a379-670c-42c2-9018-fc0d933a4f7f", "b29d45a6-0b8c-49c5-82a2-457e4d3cbc33", "3a3b5e76-029f-46b0-9ccf-fefe06eb61e7", "328e4291-92f0-49de-a0fd-fbc714a47f53", "cb2ab716-bfcb-43bc-a03b-a3bda427746c", "73c5260f-8972-4e7c-822b-1a3a0358fa0b" };
-var guids_ios = new string [] {
-// Ix
-"AD6FCBE9-0F6A-4F27-8147-17AB1C8799A2", "220AD2F1-FEE9-4514-8F36-6BE37F0AAD7F",
-"4779C7FF-6969-4715-9389-DF6C43655D6F",
-// Rx
-"6f2675f5-fcc7-4a28-9dc3-657b4613dcc5", "a67f34b5-75c1-4319-a93e-93df87e728a4", "79a43ceb-1a18-49ea-aac4-b72b9c90bf5a", "0a977063-0796-4cd4-84b8-aedb2d648b26", "b41cb61a-dca0-4539-8f99-7b3499e18e6d", "24f995bd-7075-489c-b7a5-7fde08c304b6", "894021ec-14fb-430a-8572-bea9569ae435", "92857c8e-0e83-4d02-a831-8af3fed43336", "912e14a2-7bdf-4600-8d55-e8c4f33a2063", "0f6c2933-8d0c-41e6-9f77-e8714ab8c4ab", "1a476d81-f91a-448f-8790-f55498e013d2", "47d85a91-e8e2-4088-bf5a-68a161754d48", "45377009-1425-47fc-985e-05f98022f9e3" };
-
-var asses = new string [] {
-       "System.Interactive",
-       "System.Interactive.Async",
-       "System.Interactive.Providers",
-       "System.Reactive.Interfaces",
-       "System.Reactive.Core",
-       "System.Reactive.PlatformServices",
-       "System.Reactive.Linq",
-       "System.Reactive.Debugger", // maybe needed for testing assembly.
-       "System.Reactive.Experimental", // needed for testing assembly.
-       "System.Reactive.Providers",
-       "System.Reactive.Runtime.Remoting",
-       "System.Reactive.Windows.Forms",
-       "System.Reactive.Windows.Threading",
-       "System.Reactive.Observable.Aliases",
-       "Microsoft.Reactive.Testing",
-       "Tests.System.Reactive",
-       };
-
-var excluded_android_asses = new string [] {
-       "System.Reactive.Windows.Forms",
-       "System.Reactive.Windows.Threading",
-       };
-var excluded_ios_asses = new string [] {
-       "System.Reactive.Providers",
-       "System.Reactive.Windows.Forms",
-       "System.Reactive.Windows.Threading",
-       }
-
-var blacklist = new string [] {
-       // WPF Dispatcher.Invoke() is not implemented.
-       "DispatcherSchedulerTest.cs",
-       // This is not limited to Dispatcher, but many of them are relevant to it, or Winforms (we filter it out by not defining HAS_WINFORMS)
-       "ObservableConcurrencyTest.cs",
-       };
-
-int guid_idx = 0;
-foreach (var ass in asses) {
-
-       var ix = ass.Contains ("Interactive");
-
-       var dstAndroid = ix ? "../../external/rx/Ix/NET/Ix_Xamarin/android" :
-               "../../external/rx/Rx/NET/Source/Rx_Xamarin/android";
-       var dstIOS = ix ? "../../external/rx/Ix/NET/Ix_Xamarin/iOS" :
-               "../../external/rx/Rx/NET/Source/Rx_Xamarin/iOS";
-
-
-       var monoass = ass == "Microsoft.Reactive.Testing" ?
-               "Mono.Reactive.Testing" : ass;
-       var basePath = ix ? "../../external/rx/Ix/NET" :
-               "../../external/rx/Rx/NET/Source";
-       var csproj = Path.Combine (basePath, ass, ass + ".csproj");
-       var pathPrefix = ass == "Tests.System.Reactive" ? "../" : "";
-
-       var category = ix ? "Ix_Xamarin" : "Rx_Xamarin";
-       var category2 = ix ? "ix" : "rx";
-       var android_dir = Path.GetFullPath (Path.Combine (csproj, "..", "..", category, "android", category2, monoass));
-       var ios_dir = Path.GetFullPath (Path.Combine (csproj, "..", "..", category, "iOS", category2, monoass));
-       var android_proj = Path.Combine (android_dir, "android_" + monoass + ".csproj");
-       var ios_proj = Path.Combine (ios_dir, "ios_" + monoass + ".csproj");
-       if (!Directory.Exists (android_dir))
-               Directory.CreateDirectory (android_dir);
-       if (!Directory.Exists (ios_dir))
-               Directory.CreateDirectory (ios_dir);
-
-       // tests are built under Mono.Reactive.Testing directory.
-       
-       var sources =
-               monoass == "Tests.System.Reactive" ?
-               Path.Combine ("Mono.Reactive.Testing", "Mono.Reactive.Testing_test.dll.sources") :
-               Path.Combine (monoass, monoass + ".dll.sources");
-
-       var assdir = Path.Combine (monoass, "Assembly");
-       var assinfo = Path.Combine (monoass, "Assembly", "AssemblyInfo.cs");
-
-       var projectRefs = "";
-
-       if (monoass != "Tests.System.Reactive") {
-               if (!Directory.Exists (assdir))
-                       Directory.CreateDirectory (assdir);
-               using (var tw = File.CreateText (assinfo)) {
-                       //tw.WriteLine ("[assembly:System.Reflection.AssemblyVersion (\"2.1.30214.0\")]");
-                       //tw.WriteLine ("[assembly:System.Reflection.AssemblyFileVersion (\"2.1.30214.0\")]");
-               }
-       }
-
-       var sourcesXml = "";
-       var projectRefsXml = "";
-       var resourcesXml = "";
-
-       var doc = XDocument.Load (csproj);
-       var rootNS = doc.XPathSelectElement ("//*[local-name()='RootNamespace']").Value;
-       var guid = doc.XPathSelectElement ("//*[local-name()='ProjectGuid']").Value;
-
-       foreach (var e in doc.XPathSelectElements ("//*[local-name()='ProjectReference']"))
-               projectRefsXml += e;
-
-       Console.WriteLine ("Writing " + sources + " ...");
-       using (var tw = File.CreateText (sources)) {
-               if (monoass != "Tests.System.Reactive")
-                       tw.WriteLine ("Assembly/AssemblyInfo.cs");
-               foreach (var path in doc.XPathSelectElements ("//*[local-name()='Compile']")
-                       .Select (el => el.Attribute ("Include").Value)
-                       .Select (s => s.Replace ("\\", "/"))) {
-                       if (!blacklist.Any (b => path.Contains (b))) {
-                               var p = Path.Combine (ass, path);
-                               var p2 = Path.Combine ("..", basePath, ass, path);
-                               tw.WriteLine (Path.Combine (pathPrefix, p2));
-                               sourcesXml += "    <Compile Include=\"..\\..\\..\\..\\" + p.Replace ('/', '\\') + "\">\n      <Link>" + path.Replace ('/', '\\') + "</Link>\n    </Compile>\n";
-                       }
-               }
-       }
-
-       Console.WriteLine ("Writing more_build_args...");
-       var argsPath = Path.Combine (Path.GetDirectoryName (sources), "more_build_args");
-       using (var tw = File.CreateText (argsPath)) {
-               if (ass.StartsWith ("System")) {
-                       tw.WriteLine ("-d:SIGNED");
-                       tw.WriteLine ("-delaysign");
-                       tw.WriteLine ("-keyfile:../reactive.pub");
-               }
-
-               foreach (var path in doc.XPathSelectElements ("//*[local-name()='EmbeddedResource']")) {
-                       var res = path.Attribute ("Include").Value;
-                       var resx = Path.Combine (basePath, ass, res);
-                       var resFileName = res.Replace ("resx", "resources");
-                       var resxDest = Path.Combine (monoass, res);
-                       var resPath = Path.Combine (monoass, resFileName);
-                       if (File.Exists (resxDest))
-                               File.Delete (resxDest);
-                       File.Copy (resx, resxDest);
-                       //Process.Start ("resgen", String.Format ("{0} {1}", resx, resPath));
-                       tw.WriteLine ("-resource:{0},{1}.{2}", resFileName, rootNS, resFileName);
-                       var p = Path.Combine ("..", basePath, ass, res);
-                       resourcesXml += "    <EmbeddedResource Include='..\\..\\..\\..\\..\\..\\" + p + "'>\n      <Link>" + res + "</Link>\n    </EmbeddedResource>\n";
-               }
-       }
-       foreach (var f in new string [] { android_proj, ios_proj}) {
-               string prj_guid;
-               string template, prj_prefix, nunitProjRef, nunitRef;
-               var androidNUnit = "<ProjectReference Include=\"..\\..\\Andr.Unit\\Android.NUnitLite\\Android.NUnitLite.csproj\"><Project>{6A005891-A3D6-4398-A729-F645397D573A}</Project><Name>Android.NUnitLite</Name></ProjectReference>";
-               if (f == android_proj) {
-                       prj_guid = guids_android [guid_idx].ToUpper ();
-                       template = template_android;
-                       prj_prefix ="android_";
-                       nunitProjRef = ass.Contains ("Test") ? androidNUnit : "";
-                       nunitRef = "";
-               } else {
-                       prj_guid = guids_ios [guid_idx].ToUpper ();
-                       template = template_ios;
-                       prj_prefix ="ios_";
-                       nunitProjRef = "";
-                       nunitRef = ass.Contains ("Test") ? "<Reference Include='MonoTouch.NUnitLite' />" : "";
-               }
-               using (var tw = File.CreateText (f)) {
-                       tw.Write (template
-                               .Replace ("PROJECT_GUID_GOES_HERE", '{' + prj_guid + '}')
-                               .Replace ("ASSEMBLY_NAME_GOES_HERE", monoass)
-                               .Replace ("OPTIONAL_ANDROID_NUNITLITE", nunitProjRef)
-                               .Replace ("OPTIONAL_MONOTOUCH_NUNITLITE", nunitRef)
-                               .Replace ("PROJECT_REFERENCES_GO_HERE",
-                                       projectRefsXml
-                                               .Replace (" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"", "")
-                                               .Replace ("Microsoft.Reactive.Testing", "Mono.Reactive.Testing")
-                                               .Replace ("System", prj_prefix + "System")
-                                               .Replace ("Mono", prj_prefix + "Mono")
-                                               .Replace ("Include=\"..\\" + prj_prefix, "Include=\"..\\"))
-                               .Replace ("RESOURCES_GO_HERE", resourcesXml.Replace ('\\', f == ios_proj ? '/' : '\\')) // whoa, BACKSLASH doesn't work only on android on MD/mac...!
-                               .Replace ("SOURCES_GO_HERE", sourcesXml.Replace ('\\', f == ios_proj ? '/' : '\\'))); // whoa, BACKSLASH doesn't work only on android on MD/mac...!
-               }
-       }
-       guid_idx++;
-}
-
index 6e1e9ef1264ab13c08957d9d6938eeed71c9497a..54b21cdf3ba79901f7b577047b3c3222d27b4ef3 100644 (file)
@@ -79,6 +79,8 @@ using System.Runtime.InteropServices;
 [assembly: InternalsVisibleTo ("System.Runtime.WindowsRuntime, PublicKey=00000000000000000400000000000000")]
 [assembly: InternalsVisibleTo ("System.Runtime.WindowsRuntime.UI.Xaml, PublicKey=00000000000000000400000000000000")]
 
+[assembly: InternalsVisibleTo ("System.Runtime.InteropServices.RuntimeInformation, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+
 #if MONOTOUCH
 #if MONOTOUCH_TV
 [assembly: InternalsVisibleTo ("Xamarin.TVOS, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
index f70ee556ac6adb177de9fa5cc15cc469928fefca..92884a2591d87096214b2498460e1c9499351f3a 100644 (file)
@@ -51,7 +51,7 @@ namespace Mono {
 
                // handle.h HandleStackMark
                struct HandleStackMark {
-                       int size;
+                       int size, interior_size;
                        IntPtr chunk;
                }
 
index bc944350b304c4f9ca677606b59f43cab3c3041d..f643b072359e20a89be3a4d6de9eea8a6f4afe15 100644 (file)
@@ -30,12 +30,15 @@ using System.Collections.Generic;
 
 namespace System.Diagnostics.Tracing
 {
-       public abstract class EventListener : IDisposable
+       public class EventListener : IDisposable
        {
-               protected EventListener ()
+               public EventListener ()
                {
                }
 
+               //public event System.EventHandler<EventSourceCreatedEventArgs> EventSourceCreated;
+               //public event System.EventHandler<EventWrittenEventArgs> EventWritten;
+
                public static int EventSourceIndex(EventSource eventSource)
                {
                        return 0;
@@ -61,7 +64,9 @@ namespace System.Diagnostics.Tracing
                {
                }
 
-               protected internal abstract void OnEventWritten (EventWrittenEventArgs eventData);
+               protected internal virtual void OnEventWritten (EventWrittenEventArgs eventData)
+               {
+               }
 
                public virtual void Dispose()
                {
index 664d9305745369610b87f6ce3d9a44050db45507..f6b752d1784fdb631a7f8439de3426608c39c963 100644 (file)
@@ -224,14 +224,6 @@ namespace System.IO
                                }
                        }
 
-                       if (access == FileAccess.Read && mode != FileMode.Create && mode != FileMode.OpenOrCreate &&
-                                       mode != FileMode.CreateNew && !File.Exists (path)) {
-                               // don't leak the path information for isolated storage
-                               string msg = Locale.GetText ("Could not find file \"{0}\".");
-                               string fname = GetSecureFileName (path);
-                               throw new FileNotFoundException (String.Format (msg, fname), fname);
-                       }
-
                        // IsolatedStorage needs to keep the Name property to the default "[Unknown]"
                        if (!anonymous)
                                this.name = path;
index f8522ebe862a6dee35fac7668cf2d959260eb50d..cd6a5a76487627767fbeea600afe85292bf43d6d 100644 (file)
@@ -229,7 +229,9 @@ namespace System.Reflection.Emit {
                }
 
                internal FieldInfo RuntimeResolve () {
-                       return typeb.CreateType ().GetField (this);
+                       // typeb.CreateType() populates this.handle
+                       var type_handle = new RuntimeTypeHandle (typeb.CreateType () as RuntimeType);
+                       return FieldInfo.GetFieldFromHandle (handle, type_handle);
                }
 
                public override Module Module {
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/CALLCONV.cs b/mcs/class/corlib/System.Runtime.InteropServices/CALLCONV.cs
deleted file mode 100644 (file)
index d956b45..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// System.Runtime.InteropServices.CALLCONV.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Serializable]
-       public enum CALLCONV
-       {
-               CC_CDECL = 1,
-               CC_PASCAL = 2,
-               CC_MSCPASCAL = 2,
-               CC_MACPASCAL = 3,
-               CC_STDCALL = 4,
-               CC_RESERVED = 5,
-               CC_SYSCALL = 6,
-               CC_MPWCDECL = 7,
-               CC_MPWPASCAL = 8,
-               CC_MAX = 9
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/DISPPARAMS.cs b/mcs/class/corlib/System.Runtime.InteropServices/DISPPARAMS.cs
deleted file mode 100644 (file)
index b038963..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-
-//
-// 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.
-//
-
-// System.Runtime.InteropServices/DISPPARAMS.cs
-//
-// Paolo Molaro (lupus@ximian.com)
-//
-// (C) 2002 Ximian, Inc.
-
-using System;
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct DISPPARAMS {
-               public IntPtr rgvarg;
-               public IntPtr rgdispidNamedArgs;
-               public int cArgs;
-               public int cNamedArgs;
-       }
-}
-
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ELEMDESC.cs b/mcs/class/corlib/System.Runtime.InteropServices/ELEMDESC.cs
deleted file mode 100644 (file)
index be58742..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// System.Runtime.InteropServices.ELEMDESC.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct ELEMDESC
-       {
-               public TYPEDESC tdesc;
-               public DESCUNION desc;
-
-               [ComVisible (false)]
-               [StructLayout (LayoutKind.Explicit, CharSet = CharSet.Unicode)]
-               public struct DESCUNION
-               {
-                       [FieldOffset (0)]
-                       public IDLDESC idldesc;
-                       [FieldOffset (0)]
-                       public PARAMDESC paramdesc;
-               }
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/EXCEPINFO.cs b/mcs/class/corlib/System.Runtime.InteropServices/EXCEPINFO.cs
deleted file mode 100644 (file)
index 0e61c36..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-
-//
-// 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.
-//
-
-// System.Runtime.InteropServices/EXCEPINFO.cs
-//
-// Paolo Molaro (lupus@ximian.com)
-//
-// (C) 2002 Ximian, Inc.
-
-using System;
-
-#if !FULL_AOT_RUNTIME
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct EXCEPINFO {
-               public short wCode;
-               public short wReserved;
-               [MarshalAs (UnmanagedType.BStr)]
-               public string bstrSource;
-               [MarshalAs (UnmanagedType.BStr)]
-               public string bstrDescription;
-               [MarshalAs (UnmanagedType.BStr)]
-               public string bstrHelpFile;
-               public int dwHelpContext;
-               public IntPtr pvReserved;
-               public IntPtr pfnDeferredFillIn;
-       }
-}
-
-#endif
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/FUNCDESC.cs b/mcs/class/corlib/System.Runtime.InteropServices/FUNCDESC.cs
deleted file mode 100644 (file)
index 30d251a..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// System.Runtime.InteropServices.FUNCDESC.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential)]
-       public struct FUNCDESC
-       {
-               public int memid;
-               public IntPtr lprgscode;
-               public IntPtr lprgelemdescParam;
-               public FUNCKIND funckind;
-               public INVOKEKIND invkind;
-               public CALLCONV callconv;
-               public short cParams;
-               public short cParamsOpt;
-               public short oVft;
-               public short cScodes;
-               public ELEMDESC elemdescFunc;
-               public short wFuncFlags;
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/FUNCFLAGS.cs b/mcs/class/corlib/System.Runtime.InteropServices/FUNCFLAGS.cs
deleted file mode 100644 (file)
index 13d5da8..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// System.Runtime.InteropServices.FUNCFLAGS.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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;
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Flags, Serializable]
-       public enum FUNCFLAGS
-       {
-               FUNCFLAG_FRESTRICTED = 1,
-               FUNCFLAG_FSOURCE = 2,
-               FUNCFLAG_FBINDABLE = 4,
-               FUNCFLAG_FREQUESTEDIT = 8,
-               FUNCFLAG_FDISPLAYBIND = 16,
-               FUNCFLAG_FDEFAULTBIND = 32,
-               FUNCFLAG_FHIDDEN = 64,
-               FUNCFLAG_FUSESGETLASTERROR = 128,
-               FUNCFLAG_FDEFAULTCOLLELEM = 256,
-               FUNCFLAG_FUIDEFAULT = 512,
-               FUNCFLAG_FNONBROWSABLE = 1024,
-               FUNCFLAG_FREPLACEABLE = 2048,
-               FUNCFLAG_FIMMEDIATEBIND = 4096
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/FUNCKIND.cs b/mcs/class/corlib/System.Runtime.InteropServices/FUNCKIND.cs
deleted file mode 100644 (file)
index eee7d3f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// System.Runtime.InteropServices.FUNCKIND.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Serializable]
-       public enum FUNCKIND
-       {
-               FUNC_VIRTUAL = 0,
-               FUNC_PUREVIRTUAL = 1,
-               FUNC_NONVIRTUAL = 2,
-               FUNC_STATIC = 3,
-               FUNC_DISPATCH = 4
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/IDLDESC.cs b/mcs/class/corlib/System.Runtime.InteropServices/IDLDESC.cs
deleted file mode 100644 (file)
index dfa5518..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Runtime.InteropServices.IDLDESC.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct IDLDESC
-       {
-               public int dwReserved;
-               public IDLFLAG wIDLFlags;
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/IDLFLAG.cs b/mcs/class/corlib/System.Runtime.InteropServices/IDLFLAG.cs
deleted file mode 100644 (file)
index e29a1a8..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// System.Runtime.InteropServices.IDLFLAG.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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;
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Flags, Serializable]
-       public enum IDLFLAG
-       {
-               IDLFLAG_NONE = 0,
-               IDLFLAG_FIN = 1,
-               IDLFLAG_FOUT = 2,
-               IDLFLAG_FLCID = 4,
-               IDLFLAG_FRETVAL = 8
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/IMPLTYPEFLAGS.cs b/mcs/class/corlib/System.Runtime.InteropServices/IMPLTYPEFLAGS.cs
deleted file mode 100644 (file)
index 7da65a8..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//
-// System.Runtime.InteropServices.IMPLTYPEFLAGS.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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;
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Flags, Serializable]
-       public enum IMPLTYPEFLAGS
-       {
-               IMPLTYPEFLAG_FDEFAULT = 1,
-               IMPLTYPEFLAG_FSOURCE = 2,
-               IMPLTYPEFLAG_FRESTRICTED = 4,
-               IMPLTYPEFLAG_FDEFAULTVTABLE = 8
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/INVOKEKIND.cs b/mcs/class/corlib/System.Runtime.InteropServices/INVOKEKIND.cs
deleted file mode 100644 (file)
index 72c2edb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-
-//
-// 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.
-//
-
-// System.Runtime.InteropServices/INVOKEKIND.cs
-//
-// Paolo Molaro (lupus@ximian.com)
-//
-// (C) 2002 Ximian, Inc.
-
-using System;
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Serializable]
-       public enum INVOKEKIND {
-               INVOKE_FUNC = 1,
-               INVOKE_PROPERTYGET = 2,
-               INVOKE_PROPERTYPUT = 4,
-               INVOKE_PROPERTYPUTREF = 8
-       }
-}
-
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/PARAMDESC.cs b/mcs/class/corlib/System.Runtime.InteropServices/PARAMDESC.cs
deleted file mode 100644 (file)
index 8241204..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Runtime.InteropServices.PARAMDESC.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct PARAMDESC
-       {
-               public IntPtr lpVarValue;
-               public PARAMFLAG wParamFlags;
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/PARAMFLAG.cs b/mcs/class/corlib/System.Runtime.InteropServices/PARAMFLAG.cs
deleted file mode 100644 (file)
index 5715c8f..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// System.Runtime.InteropServices.PARAMFLAG.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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;
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [Serializable]
-       [Flags]
-       public enum PARAMFLAG
-       {
-               PARAMFLAG_NONE = 0,
-               PARAMFLAG_FIN = 1,
-               PARAMFLAG_FOUT = 2,
-               PARAMFLAG_FLCID = 4,
-               PARAMFLAG_FRETVAL = 8,
-               PARAMFLAG_FOPT = 16,
-               PARAMFLAG_FHASDEFAULT = 32,
-               PARAMFLAG_FHASCUSTDATA = 64
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/TYPEATTR.cs b/mcs/class/corlib/System.Runtime.InteropServices/TYPEATTR.cs
deleted file mode 100644 (file)
index 9b7bdd1..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// System.Runtime.InteropServices.TYPEATTR.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct TYPEATTR
-       {
-               public const int MEMBER_ID_NIL = -1;
-
-               public Guid guid;
-               public int lcid;
-               public int dwReserved;
-               public int memidConstructor;
-               public int memidDestructor;
-               public IntPtr lpstrSchema;
-               public int cbSizeInstance;
-               public TYPEKIND typekind;
-               public short cFuncs;
-               public short cVars;
-               public short cImplTypes;
-               public short cbSizeVft;
-               public short cbAlignment;
-               public TYPEFLAGS wTypeFlags;
-               public short wMajorVerNum;
-               public short wMinorVerNum;
-               public TYPEDESC tdescAlias;
-               public IDLDESC idldescType;
-       }
-}
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/TYPEDESC.cs b/mcs/class/corlib/System.Runtime.InteropServices/TYPEDESC.cs
deleted file mode 100644 (file)
index 5dcf95c..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// System.Runtime.InteropServices.TYPEDESC.cs
-//
-// Author:
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.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.
-//
-
-namespace System.Runtime.InteropServices
-{
-       [Obsolete]
-       [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
-       public struct TYPEDESC
-       {
-               public IntPtr lpValue;
-               public short vt;
-       }
-}
index b0eef4e4c0e4a72bd38995c925c2c1baf9038df2..4d20d6a67879155c1e8b32c91548f97ef55cede0 100644 (file)
@@ -73,19 +73,59 @@ namespace System.Runtime.Remoting.Messaging {
        [Serializable]
        internal class CADMethodRef
        {
-               internal string FullTypeName;
-               internal IntPtr MethodHandlePtr;
+               Type[] GetTypes (string[] typeArray)
+               {
+                       Type[] res = new Type [typeArray.Length];
+                       for (int i = 0; i < typeArray.Length; ++i)
+                               res [i] = Type.GetType (typeArray [i], true);
+                       return res;
+               }
 
-               public RuntimeMethodHandle MethodHandle {
-                       get {
-                               return new RuntimeMethodHandle (MethodHandlePtr);
-                       }
+               bool ctor;
+               string typeName;
+               string methodName;
+               string[] param_names;
+               string[] generic_arg_names;
+
+               public MethodBase Resolve ()
+               {
+                       Type type = Type.GetType (typeName, true);
+                       MethodBase sig_cand = null;
+                       Type[] param_types = GetTypes (param_names);
+                       if (ctor)
+                               sig_cand = type.GetConstructor (BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance, null, param_types, null);
+                       else
+                               sig_cand = type.GetMethod (methodName, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance, null, param_types, null);
+
+                       if (sig_cand != null && generic_arg_names != null)
+                               sig_cand = ((MethodInfo)sig_cand).MakeGenericMethod (GetTypes (generic_arg_names));
+
+                       if (sig_cand == null)
+                               throw new RemotingException ($"Method '{methodName}' not found in type '{typeName}'");
+
+                       return sig_cand;
                }
 
                public CADMethodRef (IMethodMessage msg)
                {
-                       MethodHandlePtr = msg.MethodBase.MethodHandle.Value;
-                       FullTypeName = msg.MethodBase.DeclaringType.AssemblyQualifiedName;
+                       MethodBase method = msg.MethodBase;
+                       typeName = method.DeclaringType.AssemblyQualifiedName;
+                       ctor = method.IsConstructor;
+                       methodName = method.Name;
+
+                       if (!ctor && method.IsGenericMethod) {
+                               var ga = method.GetGenericArguments ();
+                               generic_arg_names = new string [ga.Length];
+                               for (int i = 0; i < ga.Length; ++i)
+                                       generic_arg_names [i] = ga [i].AssemblyQualifiedName;
+
+                               method = ((MethodInfo)method).GetGenericMethodDefinition ();
+                       }
+
+                       var param_types = method.GetParameters ();
+                       param_names = new string [param_types.Length];
+                       for (int i = 0; i < param_types.Length; ++i)
+                               param_names [i] = param_types [i].ParameterType.AssemblyQualifiedName;
                }
        }
 
@@ -102,62 +142,11 @@ namespace System.Runtime.Remoting.Messaging {
                        serializedMethod = CADSerializer.SerializeObject (methodRef).GetBuffer ();
                }
 
-               internal MethodBase method {
-                       get { return GetMethod (); }
-               }
-
                internal MethodBase GetMethod ()
                {
                        CADMethodRef methRef = (CADMethodRef)CADSerializer.DeserializeObjectSafe (serializedMethod);
 
-                       MethodBase _method;
-
-                       Type tt = Type.GetType (methRef.FullTypeName, true);
-                       if (tt.IsGenericType || tt.IsGenericTypeDefinition) {
-                               _method = MethodBase.GetMethodFromHandleNoGenericCheck (methRef.MethodHandle);
-                       } else {
-                               _method = MethodBase.GetMethodFromHandle (methRef.MethodHandle);
-                       }
-
-                       if (tt != _method.DeclaringType) {
-                               // The target domain has loaded the type from a different assembly.
-                               // We need to locate the correct type and get the method from it
-                               Type [] signature = GetSignature (_method, true);
-                               if (_method.IsGenericMethod) {
-                                       MethodBase [] methods = tt.GetMethods (BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance);
-                                       Type [] base_args = _method.GetGenericArguments ();
-                                       foreach (MethodBase method in methods) {
-                                               if (!method.IsGenericMethod || method.Name != _method.Name)
-                                                       continue;
-                                               Type [] method_args = method.GetGenericArguments ();
-                                               if (base_args.Length != method_args.Length)
-                                                       continue;
-
-                                               MethodInfo method_instance = ((MethodInfo) method).MakeGenericMethod (base_args);
-                                               Type [] base_sig = GetSignature (method_instance, false);
-                                               if (base_sig.Length != signature.Length) {
-                                                       continue;
-                                               }
-                                               bool dont = false;
-                                               for (int i = base_sig.Length - 1; i >= 0; i--) {
-                                                       if (base_sig [i] != signature [i]) {
-                                                               dont = true;
-                                                               break;
-                                                       }
-                                               }
-                                               if (dont)
-                                                       continue;
-                                               return method_instance;
-                                       }
-                                       return _method;
-                               }
-
-                               MethodBase mb = tt.GetMethod (_method.Name, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance, null, signature, null);
-                               if (mb == null)
-                                       throw new RemotingException ("Method '" + _method.Name + "' not found in type '" + tt + "'");
-                               return mb;
-                       }
-                       return _method;
+                       return methRef.Resolve ();
                }
 
                static protected Type [] GetSignature (MethodBase methodBase, bool load)
@@ -174,6 +163,7 @@ namespace System.Runtime.Remoting.Messaging {
                        }
                        return signature;
                }
+
                // Helper to marshal properties
                internal static int MarshalProperties (IDictionary dict, ref ArrayList args) {
                        IDictionary serDict = dict;
@@ -457,7 +447,7 @@ namespace System.Runtime.Remoting.Messaging {
                        _returnValue = MarshalArgument ( retMsg.ReturnValue, ref serializeList);
                        _args = MarshalArguments ( retMsg.Args, ref serializeList);
 
-                       _sig = GetSignature (method, true);
+                       _sig = GetSignature (GetMethod (), true);
 
                        if (null != retMsg.Exception) {
                                if (null == serializeList)
index 32796ff7337766b2eaa9674e0fa45bc509df293d..82d242a8e01fa956e77690592a701bd4b39a1f96 100644 (file)
@@ -27,7 +27,7 @@
 //
 
 namespace System.Security.AccessControl {
-       public enum AceType {
+       public enum AceType : byte {
                AccessAllowed = 0,
                AccessDenied = 1,
                SystemAudit = 2,
index 022774c804980764437a752403c4ee03cfc61867..1cbc404d2dbd253447ffda41e0a732cffa1d6e8d 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Security.Policy {
 
        [Serializable]
        [ComVisible (true)]
-       public class PolicyException : SystemException, _Exception {
+       public class PolicyException : SystemException {
                // Constructors
                public PolicyException ()
                        : base (Locale.GetText ("Cannot run because of policy."))
index 5c812b6f592288d5ac486919837ee6170de6ddde..1c5cdd3ae820dc363687a19efbfe553ca31b6b20 100644 (file)
@@ -574,11 +574,17 @@ namespace System
 #if LIBC
                private static TimeZoneInfo FindSystemTimeZoneByFileName (string id, string filepath)
                {
-                       if (!File.Exists (filepath))
-                               throw new TimeZoneNotFoundException ();
-
-                       using (FileStream stream = File.OpenRead (filepath)) {
+                       FileStream stream = null;
+                       try {
+                               stream = File.OpenRead (filepath);      
+                       } catch (Exception ex) {
+                               throw new TimeZoneNotFoundException ("Couldn't read time zone file " + filepath, ex);
+                       }
+                       try {
                                return BuildFromStream (id, stream);
+                       } finally {
+                               if (stream != null)
+                                       stream.Dispose();
                        }
                }
 #endif
index cf95e49fa3a8774831a9cefea2ab49ea12d3ff9d..4fc95243fe0b899020c9f96256de8d9387082442 100644 (file)
@@ -14,6 +14,8 @@ using System;
 using System.IO;
 using System.Globalization;
 using System.Threading;
+using System.Runtime.InteropServices;
+
 
 using NUnit.Framework;
 
@@ -2680,5 +2682,53 @@ namespace MonoTests.System.IO
                        MoveTest (FileAccess.ReadWrite, FileShare.Write | FileShare.Delete, true);
                        MoveTest (FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete, true);
                }
+
+
+               [DllImport ("libc", SetLastError=true)]
+               public static extern int symlink (string oldpath, string newpath);
+
+               [Test]
+               public void SymLinkLoop ()
+               {
+                       if (!RunningOnUnix)
+                               Assert.Ignore ("Symlink are hard on windows");
+
+                       var name1 = Path.GetRandomFileName ();
+                       var name2 = Path.GetRandomFileName ();
+
+                       var path1 = Path.Combine (Path.GetTempPath (), name1);
+                       var path2 = Path.Combine (Path.GetTempPath (), name2);
+
+                       File.Delete (path1);
+                       File.Delete (path2);
+
+                       try {
+                               symlink (path1, path2);
+                               symlink (path2, path1);
+
+                               Assert.IsTrue (File.Exists (path1), "File.Exists must return true for path1 symlink loop");
+                               Assert.IsTrue (File.Exists (path2), "File.Exists must return true for path2 symlink loop");
+
+                               try {
+                                       using (var f = File.Open (path1, FileMode.Open, FileAccess.Read)) {
+                                               Assert.Fail ("File.Open must throw for symlink loops");
+                                       }
+                               } catch (IOException ex) {
+                                       Assert.AreEqual (0x80070781u, (uint)ex.HResult, "Ensure HRESULT is correct");
+                               }
+
+                               File.Delete (path1); //Delete must not throw and must work
+                               Assert.IsFalse (File.Exists (path1), "File.Delete must delete symlink loops");
+
+                       } finally {
+                               try {
+                                       File.Delete (path1);
+                                       File.Delete (path2);
+                               } catch (IOException) {
+                                       //Don't double fault any exception from the tests.
+                               }
+
+                       }
+               }
        }
 }
index f66c6c1ee4bc5ca557a046389594609be2c324fd..86f87defcf7b78bf32dc068e20857b9351e79c19 100644 (file)
@@ -11306,5 +11306,91 @@ namespace MonoTests.System.Reflection.Emit
 
                        Assert.AreSame (buildX, defX);
                }
+
+               [Test]
+               public void FieldsWithSameName () {
+                       // Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=57222
+                       string fileName = CreateTempAssembly ();
+
+                       var assemblyName = new AssemblyName { Name = "test" };
+                       var dynamicAssembly = AssemblyBuilder.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.RunAndSave);
+                       var dynamicModule = dynamicAssembly.DefineDynamicModule (assemblyName.Name, fileName);
+                       var typeBuilder = dynamicModule.DefineType ("type1", TypeAttributes.Public | TypeAttributes.Class);
+
+                       var mainMethod = typeBuilder.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static, typeof (int), new Type[0]);
+                       var mainMethodIl = mainMethod.GetILGenerator ();
+
+                       var f1 = typeBuilder.DefineField ("x", typeof (byte), FieldAttributes.Private | FieldAttributes.Static);
+                       var f2 = typeBuilder.DefineField ("x", typeof (sbyte), FieldAttributes.Private | FieldAttributes.Static);
+
+                       mainMethodIl.Emit (OpCodes.Ldsflda, f1);
+                       mainMethodIl.Emit (OpCodes.Ldsflda, f2);
+                       mainMethodIl.Emit (OpCodes.Pop);
+                       mainMethodIl.Emit (OpCodes.Pop);
+                       mainMethodIl.Emit (OpCodes.Ldc_I4_0);
+                       mainMethodIl.Emit (OpCodes.Ret);
+
+                       typeBuilder.CreateType ();
+                       dynamicAssembly.SetEntryPoint (mainMethod);
+
+                       dynamicAssembly.Save (fileName);
+               }
+               [Test]
+               public void FieldsWithSameNameAndType () {
+                       // https://bugzilla.xamarin.com/show_bug.cgi?id=57222
+                       string fileName = CreateTempAssembly ();
+
+                       var assemblyName = new AssemblyName { Name = "test" };
+                       var dynamicAssembly = AssemblyBuilder.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.RunAndSave);
+                       var dynamicModule = dynamicAssembly.DefineDynamicModule (assemblyName.Name, fileName);
+                       var typeBuilder = dynamicModule.DefineType ("type1", TypeAttributes.Public | TypeAttributes.Class);
+
+                       var mainMethod = typeBuilder.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static, typeof (int), new Type[0]);
+                       var mainMethodIl = mainMethod.GetILGenerator ();
+
+                       var f1 = typeBuilder.DefineField ("x", typeof (sbyte), FieldAttributes.Private | FieldAttributes.Static);
+                       var f2 = typeBuilder.DefineField ("x", typeof (sbyte), FieldAttributes.Private | FieldAttributes.Static);
+
+                       mainMethodIl.Emit (OpCodes.Ldsflda, f1);
+                       mainMethodIl.Emit (OpCodes.Ldsflda, f2);
+                       mainMethodIl.Emit (OpCodes.Pop);
+                       mainMethodIl.Emit (OpCodes.Pop);
+                       mainMethodIl.Emit (OpCodes.Ldc_I4_0);
+                       mainMethodIl.Emit (OpCodes.Ret);
+
+                       typeBuilder.CreateType ();
+                       dynamicAssembly.SetEntryPoint (mainMethod);
+
+                       dynamicAssembly.Save (fileName);
+               }
+
+               [Test]
+               public void MethodsWithSameNameAndSig () {
+                       // https://bugzilla.xamarin.com/show_bug.cgi?id=57222
+                       string fileName = CreateTempAssembly ();
+
+                       var assemblyName = new AssemblyName { Name = "test" };
+                       var dynamicAssembly = AssemblyBuilder.DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.RunAndSave);
+                       var dynamicModule = dynamicAssembly.DefineDynamicModule (assemblyName.Name, fileName);
+                       var typeBuilder = dynamicModule.DefineType ("type1", TypeAttributes.Public | TypeAttributes.Class);
+
+                       var mainMethod = typeBuilder.DefineMethod ("Main", MethodAttributes.Public | MethodAttributes.Static, typeof (int), new Type[0]);
+                       var mainMethodIl = mainMethod.GetILGenerator ();
+
+                       var m1 = typeBuilder.DefineMethod ("X", MethodAttributes.Private | MethodAttributes.Static, typeof (void), new Type [0]);
+                       var m2 = typeBuilder.DefineMethod ("X", MethodAttributes.Private | MethodAttributes.Static, typeof (void), new Type [0]);
+                       m1.GetILGenerator ().Emit (OpCodes.Ret);
+                       m2.GetILGenerator ().Emit (OpCodes.Ret);
+
+                       mainMethodIl.Emit (OpCodes.Call, m1);
+                       mainMethodIl.Emit (OpCodes.Call, m2);
+                       mainMethodIl.Emit (OpCodes.Ldc_I4_0);
+                       mainMethodIl.Emit (OpCodes.Ret);
+
+                       typeBuilder.CreateType ();
+                       dynamicAssembly.SetEntryPoint (mainMethod);
+
+                       dynamicAssembly.Save (fileName);
+               }
        }
 }
index 593edcf65c69780f331dae72e4e353651dbf87a2..7ceec51affc0b047af1602c85b591cd4a386e0aa 100644 (file)
@@ -628,6 +628,19 @@ namespace MonoTests.System.Threading {
                        }
                }
 #endif // MONO_FEATURE_THREAD_SUSPEND_RESUME
+
+               [Test]
+               public static void SignalAndWait()
+               {
+                       using (var eventToSignal = new AutoResetEvent (false))
+                       using (var eventToWait = new AutoResetEvent (false))
+                       {
+                               eventToWait.Set ();
+
+                               Assert.IsTrue (WaitHandle.SignalAndWait (eventToSignal, eventToWait), "#1");
+                               Assert.IsTrue (eventToSignal.WaitOne (), "#2");
+                       }
+               }
        }
 }
 
index 261e9b5692537a0593711614e27b619b917e3637..c168a31e4267f0059f18815f65a7b5043ff16872 100644 (file)
@@ -14,6 +14,8 @@ using System.Runtime.CompilerServices;
 using System.Threading;
 using System.Collections.Generic;
 
+#pragma warning disable CS1718
+
 namespace MonoTests.System
 {
        [TestFixture]
index eda79f7927d24d7faec8bcac20d1d8fff7bc2976..31959c173984ea0d2d5a32ab360e8b6bfccd340b 100644 (file)
@@ -2,8 +2,6 @@ namespace System.Diagnostics.Private
 {
        static partial class Debug
        {
-               static readonly string NewLine = Environment.NewLine;
-
                static void ShowAssertDialog (string stackTrace, string message, string detailMessage)
                {
                        // FIXME should we g_error in this case?
index b804694794b6bf4f6705d8b96f9a6b5bf53063d5..9c41ec0103c0ba9848d7d9657d08639f7c6a6252 100644 (file)
@@ -60,6 +60,7 @@
     <Compile Include="..\..\..\external\corefx\src\System.Collections.Concurrent\src\System\Collections\Concurrent\OrderablePartitioner.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\System.Collections.Concurrent\src\System\Collections\Concurrent\Partitioner.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\System.Collections.Concurrent\src\System\Collections\Concurrent\PartitionerStatic.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Collections\src\System\Collections\Generic\CollectionExtensions.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\X509ContentType.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\System.Security.Cryptography.X509Certificates\src\System\Security\Cryptography\X509Certificates\X509KeyStorageFlags.cs" />\r
     <Compile Include="..\..\..\external\corert\src\Common\src\Interop\Unix\Interop.Libraries.cs" />\r
@@ -76,6 +77,7 @@
     <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\Collections\Generic\KeyValuePair.cs" />\r
     <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\Diagnostics\Debug.cs" />\r
     <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\IO\Win32Marshal.cs" />\r
+    <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\IsByRefLikeAttribute.cs" />\r
     <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\IsReadOnlyAttribute.cs" />\r
     <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\ITuple.cs" />\r
     <Compile Include="..\..\..\external\corert\src\System.Private.CoreLib\shared\System\Runtime\CompilerServices\RuntimeFeature.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\reflection\pointer.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\reflection\propertyattributes.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\reflection\reflectioncontext.cs" />\r
+    <Compile Include="..\referencesource\mscorlib\system\reflection\reflectiontypeloadexception.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\reflection\resourceattributes.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\reflection\RuntimeReflectionExtensions.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\reflection\targetexception.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\safehandle.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\sehexception.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\ucomienumconnections.cs" />\r
+    <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\ucomitypeinfo.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\unknownwrapper.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\variantWrapper.cs" />\r
     <Compile Include="..\referencesource\mscorlib\system\runtime\interopservices\windowsruntime\attributes.cs" />\r
     <Compile Include="System.Reflection\ParameterInfo.cs" />\r
     <Compile Include="System.Reflection\PortableExecutableKinds.cs" />\r
     <Compile Include="System.Reflection\PropertyInfo.cs" />\r
-    <Compile Include="System.Reflection\ReflectionTypeLoadException.cs" />\r
     <Compile Include="System.Reflection\StrongNameKeyPair.cs" />\r
     <Compile Include="System.Resources\Win32Resources.cs" />\r
     <Compile Include="System.Runtime.CompilerServices\ConditionalWeakTable.cs" />\r
     <Compile Include="System.Runtime.InteropServices\_TypeBuilder.cs" />\r
     <Compile Include="System.Runtime.InteropServices\BIND_OPTS.cs" />\r
     <Compile Include="System.Runtime.InteropServices\BINDPTR.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\CALLCONV.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ComEventsHelper.cs" />\r
     <Compile Include="System.Runtime.InteropServices\CustomQueryInterfaceMode.cs" />\r
     <Compile Include="System.Runtime.InteropServices\DESCKIND.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\DISPPARAMS.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\ELEMDESC.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\EXCEPINFO.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ExporterEventKind.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ExtensibleClassFactory.cs" />\r
     <Compile Include="System.Runtime.InteropServices\FILETIME.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\FUNCDESC.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\FUNCFLAGS.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\FUNCKIND.cs" />\r
     <Compile Include="System.Runtime.InteropServices\GCHandle.cs" />\r
     <Compile Include="System.Runtime.InteropServices\GCHandleType.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\IDLDESC.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\IDLFLAG.cs" />\r
     <Compile Include="System.Runtime.InteropServices\IErrorInfo.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\IMPLTYPEFLAGS.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ImporterEventKind.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\INVOKEKIND.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ITypeLibConverter.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ITypeLibExporterNameProvider.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ITypeLibExporterNotifySink.cs" />\r
     <Compile Include="System.Runtime.InteropServices\ManagedErrorInfo.cs" />\r
     <Compile Include="System.Runtime.InteropServices\Marshal.cs" />\r
     <Compile Include="System.Runtime.InteropServices\MarshalAsAttribute.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\PARAMDESC.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\PARAMFLAG.cs" />\r
     <Compile Include="System.Runtime.InteropServices\RegistrationClassContext.cs" />\r
     <Compile Include="System.Runtime.InteropServices\RegistrationConnectionType.cs" />\r
     <Compile Include="System.Runtime.InteropServices\RegistrationServices.cs" />\r
     <Compile Include="System.Runtime.InteropServices\SafeHandle.cs" />\r
     <Compile Include="System.Runtime.InteropServices\STATSTG.cs" />\r
     <Compile Include="System.Runtime.InteropServices\SYSKIND.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\TYPEATTR.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\TYPEDESC.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\TYPEFLAGS.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\TYPEKIND.cs" />\r
     <Compile Include="System.Runtime.InteropServices\TYPELIBATTR.cs" />\r
     <Compile Include="System.Runtime.InteropServices\TypeLibConverter.cs" />\r
     <Compile Include="System.Runtime.InteropServices\TypeLibExporterFlags.cs" />\r
     <Compile Include="System.Runtime.InteropServices\UCOMIRunningObjectTable.cs" />\r
     <Compile Include="System.Runtime.InteropServices\UCOMIStream.cs" />\r
     <Compile Include="System.Runtime.InteropServices\UCOMITypeComp.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\UCOMITypeInfo.cs" />\r
     <Compile Include="System.Runtime.InteropServices\UCOMITypeLib.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\VARDESC.cs" />\r
-    <Compile Include="System.Runtime.InteropServices\VARFLAGS.cs" />\r
     <Compile Include="System.Runtime.Remoting.Activation\ActivationServices.cs" />\r
     <Compile Include="System.Runtime.Remoting.Activation\ActivatorLevel.cs" />\r
     <Compile Include="System.Runtime.Remoting.Activation\AppDomainLevelActivator.cs" />\r
     <EmbeddedResource Include="resources/collation.cjkKOlv2.bin">\r
       <LogicalName>collation.cjkKOlv2.bin</LogicalName>\r
     </EmbeddedResource>\r
+    <EmbeddedResource Include="LinkerDescriptor/mscorlib.xml">\r
+      <LogicalName>mscorlib.xml</LogicalName>\r
+    </EmbeddedResource>\r
   </ItemGroup>\r
 </Project>\r
 
index c4af3f5b553037fedd3d8c19a405c27763e5145e..9b245081069acf75ec49ec7942b32ac00137b1f1 100644 (file)
@@ -257,7 +257,6 @@ System.Reflection/MonoProperty.cs
 System.Reflection/ParameterInfo.cs
 System.Reflection/PortableExecutableKinds.cs
 System.Reflection/PropertyInfo.cs
-System.Reflection/ReflectionTypeLoadException.cs
 System.Reflection/StrongNameKeyPair.cs
 System.Reflection.Emit/AssemblyBuilder.cs
 System.Reflection.Emit/AssemblyBuilderAccess.cs
@@ -362,24 +361,13 @@ System.Runtime.InteropServices/_Type.cs
 System.Runtime.InteropServices/_TypeBuilder.cs
 System.Runtime.InteropServices/BIND_OPTS.cs
 System.Runtime.InteropServices/BINDPTR.cs
-System.Runtime.InteropServices/CALLCONV.cs
 System.Runtime.InteropServices/DESCKIND.cs
-System.Runtime.InteropServices/DISPPARAMS.cs
-System.Runtime.InteropServices/ELEMDESC.cs
-System.Runtime.InteropServices/EXCEPINFO.cs
 System.Runtime.InteropServices/ExporterEventKind.cs
 System.Runtime.InteropServices/ExtensibleClassFactory.cs
 System.Runtime.InteropServices/FILETIME.cs
-System.Runtime.InteropServices/FUNCDESC.cs
-System.Runtime.InteropServices/FUNCFLAGS.cs
-System.Runtime.InteropServices/FUNCKIND.cs
 System.Runtime.InteropServices/GCHandle.cs
 System.Runtime.InteropServices/GCHandleType.cs
-System.Runtime.InteropServices/IDLDESC.cs
-System.Runtime.InteropServices/IDLFLAG.cs
 System.Runtime.InteropServices/IErrorInfo.cs
-System.Runtime.InteropServices/IMPLTYPEFLAGS.cs
-System.Runtime.InteropServices/INVOKEKIND.cs
 System.Runtime.InteropServices/ITypeLibConverter.cs
 System.Runtime.InteropServices/ITypeLibExporterNameProvider.cs
 System.Runtime.InteropServices/ITypeLibExporterNotifySink.cs
@@ -389,8 +377,6 @@ System.Runtime.InteropServices/LIBFLAGS.cs
 System.Runtime.InteropServices/ManagedErrorInfo.cs
 System.Runtime.InteropServices/Marshal.cs
 System.Runtime.InteropServices/MarshalAsAttribute.cs
-System.Runtime.InteropServices/PARAMDESC.cs
-System.Runtime.InteropServices/PARAMFLAG.cs
 System.Runtime.InteropServices/RegistrationClassContext.cs
 System.Runtime.InteropServices/RegistrationConnectionType.cs
 System.Runtime.InteropServices/STATSTG.cs
@@ -398,10 +384,6 @@ System.Runtime.InteropServices/RegistrationServices.cs
 System.Runtime.InteropServices/SafeBuffer.cs
 System.Runtime.InteropServices/SafeHandle.cs
 System.Runtime.InteropServices/SYSKIND.cs
-System.Runtime.InteropServices/TYPEATTR.cs
-System.Runtime.InteropServices/TYPEDESC.cs
-System.Runtime.InteropServices/TYPEFLAGS.cs
-System.Runtime.InteropServices/TYPEKIND.cs
 System.Runtime.InteropServices/TYPELIBATTR.cs
 System.Runtime.InteropServices/TypeLibConverter.cs
 System.Runtime.InteropServices/TypeLibExporterFlags.cs
@@ -418,10 +400,7 @@ System.Runtime.InteropServices/UCOMIPersistFile.cs
 System.Runtime.InteropServices/UCOMIRunningObjectTable.cs
 System.Runtime.InteropServices/UCOMIStream.cs
 System.Runtime.InteropServices/UCOMITypeComp.cs
-System.Runtime.InteropServices/UCOMITypeInfo.cs
 System.Runtime.InteropServices/UCOMITypeLib.cs
-System.Runtime.InteropServices/VARDESC.cs
-System.Runtime.InteropServices/VARFLAGS.cs
 System.Runtime.InteropServices/CustomQueryInterfaceMode.cs
 System.Runtime.InteropServices/ComEventsHelper.cs
 
@@ -1233,6 +1212,7 @@ ReferenceSources/AppContextDefaultValues.cs
 ../referencesource/mscorlib/system/reflection/pointer.cs
 ../referencesource/mscorlib/system/reflection/propertyattributes.cs
 ../referencesource/mscorlib/system/reflection/reflectioncontext.cs
+../referencesource/mscorlib/system/reflection/reflectiontypeloadexception.cs
 ../referencesource/mscorlib/system/reflection/resourceattributes.cs
 ../referencesource/mscorlib/system/reflection/RuntimeReflectionExtensions.cs
 ../referencesource/mscorlib/system/reflection/targetexception.cs
@@ -1301,6 +1281,7 @@ ReferenceSources/AppContextDefaultValues.cs
 ../referencesource/mscorlib/system/runtime/interopservices/safearraytypemismatchexception.cs
 ../referencesource/mscorlib/system/runtime/interopservices/safehandle.cs
 ../referencesource/mscorlib/system/runtime/interopservices/sehexception.cs
+../referencesource/mscorlib/system/runtime/interopservices/ucomitypeinfo.cs
 ../referencesource/mscorlib/system/runtime/interopservices/ucomienumconnections.cs
 ../referencesource/mscorlib/system/runtime/interopservices/unknownwrapper.cs
 ../referencesource/mscorlib/system/runtime/interopservices/variantWrapper.cs
@@ -1658,6 +1639,7 @@ corert/ThreadPoolBoundHandle.cs
 ../../../external/corert/src/System.Private.CoreLib/shared/System/Diagnostics/Debug.cs
 
 ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IsReadOnlyAttribute.cs
+../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IsByRefLikeAttribute.cs
 ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ITuple.cs
 ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/RuntimeFeature.cs
 ../../../external/corert/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs
@@ -1678,6 +1660,8 @@ corert/ThreadPoolBoundHandle.cs
 
 corefx/SR.cs
 
+../../../external/corefx/src/System.Collections/src/System/Collections/Generic/CollectionExtensions.cs
+
 ../../../external/corefx/src/System.Collections.Concurrent/src/System/Collections/Concurrent/CDSCollectionETWBCLProvider.cs
 ../../../external/corefx/src/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs
 ../../../external/corefx/src/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentQueue.cs
diff --git a/mcs/class/monodoc/Test/README.md b/mcs/class/monodoc/Test/README.md
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/mcs/class/project_template_android.txt b/mcs/class/project_template_android.txt
deleted file mode 100644 (file)
index 5444595..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>10.0.0</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>PROJECT_GUID_GOES_HERE</ProjectGuid>
-    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <OutputType>Library</OutputType>
-    <RootNamespace>System.Reactive</RootNamespace>
-    <AssemblyName>ASSEMBLY_NAME_GOES_HERE</AssemblyName>
-    <DefineConstants>NO_TASK_DELAY;NO_WINDOWS_THREADING;NO_REMOTING;HAS_AWAIT;NUNIT;MONODROID;$(SignAssemblySpec)</DefineConstants>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>True</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <AndroidLinkMode>None</AndroidLinkMode>
-    <ConsolePause>False</ConsolePause>
-    <DefineConstants>DEBUG;NO_TASK_DELAY;NO_WINDOWS_THREADING;NO_REMOTING;HAS_AWAIT;NUNIT;MONODROID;$(SignAssemblySpec)</DefineConstants>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>True</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <ConsolePause>False</ConsolePause>
-    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
-    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Xml" />
-    <Reference Include="System.Core" />
-  </ItemGroup>
-  <ItemGroup>
-OPTIONAL_ANDROID_NUNITLITE
-PROJECT_REFERENCES_GO_HERE
-    <!--
-    <ProjectReference Include="..\Andr.Unit\Android.NUnitLite\Android.NUnitLite.csproj">
-      <Project>{6A005891-A3D6-4398-A729-F645397D573A}</Project>
-      <Name>Android.NUnitLite</Name>
-    </ProjectReference>
-    -->
-  </ItemGroup>
-  <ItemGroup>
-SOURCES_GO_HERE
-    <!--
-    <Compile Include="..\..\..\Microsoft.Reactive.Testing\ColdObservable.cs">
-      <Link>ColdObservable.cs</Link>
-    </Compile>
-    -->
-RESOURCES_GO_HERE
-  </ItemGroup>
-  <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
-</Project>
diff --git a/mcs/class/project_template_ios.txt b/mcs/class/project_template_ios.txt
deleted file mode 100644 (file)
index 6a6d996..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>10.0.0</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>PROJECT_GUID_GOES_HERE</ProjectGuid>
-    <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>System.Reactive</RootNamespace>
-    <IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
-    <AssemblyName>ASSEMBLY_NAME_GOES_HERE</AssemblyName>
-    <ProductSignAssembly>true</ProductSignAssembly>
-    <DefineConstants>NO_TASK_DELAY;NO_WINDOWS_THREADING;NO_REMOTING;NO_REFLECTION_EMIT;NO_EXPRESSIONS;HAS_AWAIT;NUNIT;$(SignAssemblySpec)</DefineConstants>
-    <additionalargs>-delaySign</additionalargs>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>True</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>False</Optimize>
-    <OutputPath>bin\Debug</OutputPath>
-    <ConsolePause>False</ConsolePause>
-    <WarningLevel>4</WarningLevel>
-    <DefineConstants>DEBUG;NO_TASK_DELAY;NO_WINDOWS_THREADING;NO_REMOTING;NO_REFLECTION_EMIT;NO_EXPRESSIONS;HAS_AWAIT;NUNIT;$(SignAssemblySpec)</DefineConstants>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>True</Optimize>
-    <OutputPath>bin\Release</OutputPath>
-    <ConsolePause>False</ConsolePause>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup>
-    <!--
-    <TargetFrameworkIdentifier>iOS</TargetFrameworkIdentifier>
-    <TargetFrameworkVersion>v2.0.5</TargetFrameworkVersion>
-    -->
-    <!-- NoStdLib>true</NoStdLib -->
-    <BuildPlatform>MOBILE</BuildPlatform>
-    <BuildFlavor>MONOTOUCH</BuildFlavor>
-  </PropertyGroup>
-  <Import Project="..\..\..\Common.targets" />
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="MonoTouch.NUnitLite" />
-    OPTIONAL_MONOTOUCH_NUNITLITE
-  </ItemGroup>
-  <ItemGroup>
-    PROJECT_REFERENCES_GO_HERE
-    <!--
-    <ProjectReference Include="..\Andr.Unit\Android.NUnitLite\Android.NUnitLite.csproj">
-      <Project>{6A005891-A3D6-4398-A729-F645397D573A}</Project>
-      <Name>Android.NUnitLite</Name>
-    </ProjectReference>
-    -->
-  </ItemGroup>
-  <ItemGroup>
-    SOURCES_GO_HERE
-    <!--
-    <Compile Include="..\..\..\Microsoft.Reactive.Testing\ColdObservable.cs">
-      <Link>ColdObservable.cs</Link>
-    </Compile>
-    -->
-    RESOURCES_GO_HERE
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <ItemGroup>
-    <Folder Include="Properties\" />
-  </ItemGroup>
-</Project>
index 145bbb5424b7ffae80cfb0d158a3c230a822a941..c9fca00b3e437277f5fc58b1c8e9a9e2af2710f2 100644 (file)
@@ -783,9 +783,10 @@ namespace System.IO
         internal override DirectoryInfo CreateObject(SearchResult result)
         {
             String name = result.FullPath;
-            String permissionName = name + "\\.";
 
 #if MONO_FEATURE_CAS
+            String permissionName = name + "\\.";
+
 #if FEATURE_CORECLR
             FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
             state.EnsureState();
@@ -821,9 +822,10 @@ namespace System.IO
             if (isDir)
             {
                 String name = result.FullPath;
-                String permissionName = name + "\\.";
 
 #if MONO_FEATURE_CAS
+                String permissionName = name + "\\.";
+
 #if FEATURE_CORECLR
                 FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
                 state.EnsureState();
index 04a7b62e56dc4a77dc596f41f4e8edb6b94b1ea1..2871edb13f463cd2abe387498ab4a46ca5a27fb6 100644 (file)
@@ -303,6 +303,7 @@ namespace System.Runtime.InteropServices
         VARFLAG_FIMMEDIATEBIND    =0x1000
     }
 
+#if !FULL_AOT_RUNTIME
     [Obsolete("Use System.Runtime.InteropServices.ComTypes.ITypeInfo instead. http://go.microsoft.com/fwlink/?linkid=14202", false)]
     [Guid("00020401-0000-0000-C000-000000000046")]
     [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
@@ -329,4 +330,5 @@ namespace System.Runtime.InteropServices
         void ReleaseFuncDesc(IntPtr pFuncDesc);
         void ReleaseVarDesc(IntPtr pVarDesc);
     }
+#endif
 }
diff --git a/mcs/errors/cs0019-72.cs b/mcs/errors/cs0019-72.cs
new file mode 100644 (file)
index 0000000..90cbae7
--- /dev/null
@@ -0,0 +1,10 @@
+// CS0019: Operator `??' cannot be applied to operands of type `void' and `throw expression'
+// Line: 20
+
+class C
+{
+       public static void Main ()
+       {
+               var s = Main () ?? throw null;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0128-3.cs b/mcs/errors/cs0128-3.cs
new file mode 100644 (file)
index 0000000..380616c
--- /dev/null
@@ -0,0 +1,16 @@
+// CS0128: A local variable named `x' is already defined in this scope
+// Line: 9
+
+class X
+{
+       public static void Main ()
+       {
+               Foo (out int x);
+               Foo (out int x);
+       }
+
+       static void Foo (out int arg)
+       {
+               arg = 2;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0128-4.cs b/mcs/errors/cs0128-4.cs
new file mode 100644 (file)
index 0000000..4a38920
--- /dev/null
@@ -0,0 +1,13 @@
+// CS0128: A local variable named `s' is already defined in this scope
+// Line: 12
+
+class C
+{
+       public static void Main ()
+       {
+               object o = null;
+
+               var x1 = o is string s;
+               var x2 = o is string s;
+       }
+}
diff --git a/mcs/errors/cs0136-20.cs b/mcs/errors/cs0136-20.cs
new file mode 100644 (file)
index 0000000..0a7e680
--- /dev/null
@@ -0,0 +1,13 @@
+// CS0136: A local variable named `s' cannot be declared in this scope because it would give a different meaning to `s', which is already used in a `parent or current' scope to denote something else
+// Line: 10
+
+internal class Program
+{
+       public static void Main ()
+       {
+               object o = null;
+               if (o is string s) {
+                       int s = 1;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0155-5.cs b/mcs/errors/cs0155-5.cs
new file mode 100644 (file)
index 0000000..774700a
--- /dev/null
@@ -0,0 +1,7 @@
+// CS0155: The type caught or thrown must be derived from System.Exception
+// Line: 9
+
+class X
+{
+    public int Test () => throw "";
+}
diff --git a/mcs/errors/cs0162-21.cs b/mcs/errors/cs0162-21.cs
new file mode 100644 (file)
index 0000000..e8bd4b2
--- /dev/null
@@ -0,0 +1,19 @@
+// CS0162: Unreachable code detected
+// Line: 12
+// Compiler options: -warnaserror -warn:2
+
+using System;
+
+class X
+{
+    void Test ()
+    {
+        var x = true ? throw new NullReferenceException () : 1;
+        x = 2;
+        return;
+    }
+
+       static void Main () 
+       {
+       }
+}
diff --git a/mcs/errors/cs0165-56.cs b/mcs/errors/cs0165-56.cs
new file mode 100644 (file)
index 0000000..06eb6cc
--- /dev/null
@@ -0,0 +1,14 @@
+// CS0165: Use of unassigned local variable `s'
+// Line: 12
+
+class X
+{
+    static string Foo (object arg)
+    {
+        if (arg is string s) {
+
+        }
+
+        return s;
+    }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0173-6.cs b/mcs/errors/cs0173-6.cs
new file mode 100644 (file)
index 0000000..6c2dab2
--- /dev/null
@@ -0,0 +1,10 @@
+// CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between `throw expression' and `throw expression'
+// Line: 8
+
+class C
+{
+       public static void Test (bool b)
+       {
+               var s = b ? throw null : throw null;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0208-19.cs b/mcs/errors/cs0208-19.cs
new file mode 100644 (file)
index 0000000..82b0f43
--- /dev/null
@@ -0,0 +1,20 @@
+// CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type `CS208.Foo'
+// Line: 17
+// Compiler options: -unsafe
+
+namespace CS208
+{
+       public struct Foo
+       {
+               public string PP { get; set; }
+       }
+
+       public class Bar
+       {
+               unsafe static void Main ()
+               {                       
+                       Foo f = new Foo ();
+                       void *s = &f;
+               }
+       }
+}
diff --git a/mcs/errors/cs0411-25.cs b/mcs/errors/cs0411-25.cs
new file mode 100644 (file)
index 0000000..c7f92fb
--- /dev/null
@@ -0,0 +1,16 @@
+// CS0411: The type arguments for method `C.Foo<T>(System.Func<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
+// Line: 10
+
+using System;
+
+public class C
+{
+    public static void Main ()
+    {
+        Foo (() => throw null);
+    }
+
+    static void Foo<T> (Func<T> arg)
+    {
+    }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs0535-7.cs b/mcs/errors/cs0535-7.cs
new file mode 100644 (file)
index 0000000..11a7670
--- /dev/null
@@ -0,0 +1,40 @@
+// CS0535: `CC' does not implement interface member `IA.Coordinate.set'
+// Line: 33
+
+using System;
+
+public interface IA
+{
+       object Coordinate {
+               get;
+               set;
+       }
+}
+
+public abstract class CA : IA
+{
+       public abstract object Coordinate {
+               get;
+               set;
+       }
+}
+
+public  partial class CB : CA
+{
+       public override object Coordinate {
+               get {
+                       throw new NotImplementedException ();
+               }
+               set {
+               }
+       }
+}
+
+public class CC : CB, IA
+{
+       public new object Coordinate {
+               get {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/errors/cs0535-8.cs b/mcs/errors/cs0535-8.cs
new file mode 100644 (file)
index 0000000..853794e
--- /dev/null
@@ -0,0 +1,40 @@
+// CS0535: `CC' does not implement interface member `IA.this[int].set'
+// Line: 33
+
+using System;
+
+public interface IA
+{
+       object this[int arg] {
+               get;
+               set;
+       }
+}
+
+public abstract class CA : IA
+{
+       public abstract object this[int arg] {
+               get;
+               set;
+       }
+}
+
+public  partial class CB : CA
+{
+       public override object this[int arg] {
+               get {
+                       throw new NotImplementedException ();
+               }
+               set {
+               }
+       }
+}
+
+public class CC : CB, IA
+{
+       public new object this[int arg] {
+               get {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/errors/cs0815-7.cs b/mcs/errors/cs0815-7.cs
deleted file mode 100644 (file)
index af3d10f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// CS0815: An implicitly typed local variable declaration cannot be initialized with `void'
-// Line: 8
-// Compiler options: -langversion:experimental
-
-class X
-{
-       public static void Main ()
-       {
-               Foo (out var x = Main ());
-       }
-
-       static void Foo (out int i)
-       {
-               i = 0;
-       }
-}
\ No newline at end of file
diff --git a/mcs/errors/cs1031-3.cs b/mcs/errors/cs1031-3.cs
new file mode 100644 (file)
index 0000000..3126dfa
--- /dev/null
@@ -0,0 +1,18 @@
+// CS1031: Type expected
+// Line: 16
+
+public class B<Y>  where Y: B<Y>
+{
+}
+
+public class A<X>: B<A<X>>
+{
+}
+
+public class Repro
+{
+       public static void Main (string[] args)
+       {
+               var h = typeof (B<A<>>);
+       }
+}
\ No newline at end of file
index e1fd9567feafa53bfd859ad33aa66627ed94c542..746d04d510dc06bf780bee1e57c2c4f721b4040c 100755 (executable)
@@ -1,4 +1,4 @@
-// CS1043: Invalid accessor body `1', expecting `;' or `{'
+// CS1043: Invalid accessor body `1', expecting `;', `{', or `=>'
 // Line: 6
 
 class C
index 15b3864f8220444d594db3189a336adfd6134bce..489488192a5136ed6c0e20320e4e50f8c695eb8d 100644 (file)
@@ -1,4 +1,4 @@
-// CS1061: Type `int' does not contain a definition for `GetValueOrDefault' and no extension method `GetValueOrDefault' of type `int' could be found. Are you missing an assembly reference?
+// CS1061: Type `int' does not contain a definition for `GetValueOrDefault' and no extension method `GetValueOrDefault' of type `int' could be found. Are you missing `System.Collections.Generic' using directive?
 // Line: 9
 
 class C
diff --git a/mcs/errors/cs1503-17.cs b/mcs/errors/cs1503-17.cs
deleted file mode 100644 (file)
index 07da09d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// CS1501: Argument `#1' cannot convert `ref string' expression to type `ref int'
-// Line: 8
-// Compiler options: -langversion:experimental
-
-class C
-{
-       public static void Main ()
-       {
-               Foo (ref var x = "");
-       }
-
-       static void Foo (ref int i)
-       {
-       }
-}
\ No newline at end of file
index 88f9c12deca51b8d214bd2e87c42b18b4efa6746..cfa63a7d8355e7be6928a4cfa58b370cb57d8743 100644 (file)
@@ -1,3 +1,3 @@
-// CS1617: Invalid -langversion option `ISO'. It must be `ISO-1', `ISO-2', Default or value in range 1 to 6
+// CS1617: Invalid -langversion option `ISO'. It must be `ISO-1', `ISO-2', Default or value in range 1 to 7
 // Line: 0
 // Compiler options: -langversion:ISO
index b756cd7b60cee7ebe1215c599ca437d97f70e439..498b627ead59742e13a96d60107a8d969673ebee 100644 (file)
@@ -1,5 +1,5 @@
-// CS1644: Feature `declaration expression' cannot be used because it is not part of the C# 5.0 language specification
-// Line: 12
+// CS1644: Feature `out variable declaration' cannot be used because it is not part of the C# 5.0 language specification
+// Line: 9
 // Compiler options: -langversion:5
 
 class C
diff --git a/mcs/errors/cs1644-51.cs b/mcs/errors/cs1644-51.cs
new file mode 100644 (file)
index 0000000..0cc6150
--- /dev/null
@@ -0,0 +1,8 @@
+// CS1644: Feature `throw expression' cannot be used because it is not part of the C# 6.0 language specification
+// Line: 5
+// Compiler options: -langversion:6
+
+static class Class
+{
+       int Prop => throw null;
+}
diff --git a/mcs/errors/cs1644-52.cs b/mcs/errors/cs1644-52.cs
new file mode 100644 (file)
index 0000000..039ad7d
--- /dev/null
@@ -0,0 +1,13 @@
+// CS1644: Feature `pattern matching' cannot be used because it is not part of the C# 6.0 language specification
+// Line: 9
+// Compiler options: -langversion:6
+
+class Class
+{
+       static void Foo (object arg)
+       {
+               if (arg is Type v) {
+                       return;
+               }
+       }       
+}
diff --git a/mcs/errors/cs8046.cs b/mcs/errors/cs8046.cs
deleted file mode 100644 (file)
index 3335e29..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// CS8046: An expression tree cannot contain a declaration expression
-// Line: 11
-// Compiler options: -langversion:experimental
-
-using System;
-using System.Linq.Expressions;
-
-class C
-{
-       static void Main()
-       {
-               Expression<Func<bool>> e = () => Out (out int x);
-       }
-
-       static bool Out (out int value)
-       {
-               value = 3;
-               return true;
-       }
-}
\ No newline at end of file
diff --git a/mcs/errors/cs8047.cs b/mcs/errors/cs8047.cs
deleted file mode 100644 (file)
index cd91a4f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// CS8047: Declaration expression cannot be used in this context
-// Line: 8
-// Compiler options: -langversion:experimental
-
-public class C
-{
-       public static void Main ()
-       {
-               dynamic target = 3;
-               var x = new Test (target, out var y);
-       }
-}
-
-class Test
-{
-       public Test (int x, out int y)
-       {
-               y = 0;
-       }
-}
\ No newline at end of file
diff --git a/mcs/errors/cs8116.cs b/mcs/errors/cs8116.cs
new file mode 100644 (file)
index 0000000..02fa062
--- /dev/null
@@ -0,0 +1,13 @@
+// CS8116: The nullable type `byte?' pattern matching is not allowed. Consider using underlying type `byte'
+// Line: 11
+
+using System;
+
+class C
+{
+       public static void Main ()
+       {
+               object o2 = null;
+               bool r2 = o2 is Nullable<byte> t3;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8117.cs b/mcs/errors/cs8117.cs
new file mode 100644 (file)
index 0000000..de26499
--- /dev/null
@@ -0,0 +1,10 @@
+// CS8117: Cannot use null as pattern matching operand
+// Line: 8
+
+class C
+{
+       static object Test ()
+       {
+               return null is object res;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8122.cs b/mcs/errors/cs8122.cs
new file mode 100644 (file)
index 0000000..3f31be0
--- /dev/null
@@ -0,0 +1,14 @@
+// CS8122: An expression tree cannot contain a pattern matching operator
+// Line: 12
+
+using System;
+using System.Linq.Expressions;
+
+class X
+{
+       public static void Main ()
+       {
+               object o = 1;
+               Expression<Func<bool>> e = () => o is int y;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8188.cs b/mcs/errors/cs8188.cs
new file mode 100644 (file)
index 0000000..d2f225f
--- /dev/null
@@ -0,0 +1,13 @@
+// CS8188: An expression tree cannot not contain a throw expression
+// Line: 11
+
+using System;
+using System.Linq.Expressions;
+
+class C
+{
+       public static void Main ()
+       {
+               Expression<Func<object>> l = () => throw null;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8196-2.cs b/mcs/errors/cs8196-2.cs
new file mode 100644 (file)
index 0000000..cf58de3
--- /dev/null
@@ -0,0 +1,16 @@
+// CS8196: Reference to an implicitly typed out variable `x1' is not permitted in the same argument list
+// Line: 8
+
+public class C
+{
+       public static void Main ()
+       {
+               Test (out var x1, out x1);
+       }
+
+       static void Test (out int x, out int x2)
+       {
+               x = 1;
+               x2 = 2;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8196.cs b/mcs/errors/cs8196.cs
new file mode 100644 (file)
index 0000000..cf58de3
--- /dev/null
@@ -0,0 +1,16 @@
+// CS8196: Reference to an implicitly typed out variable `x1' is not permitted in the same argument list
+// Line: 8
+
+public class C
+{
+       public static void Main ()
+       {
+               Test (out var x1, out x1);
+       }
+
+       static void Test (out int x, out int x2)
+       {
+               x = 1;
+               x2 = 2;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8197.cs b/mcs/errors/cs8197.cs
new file mode 100644 (file)
index 0000000..f8538a1
--- /dev/null
@@ -0,0 +1,19 @@
+// CS8197: Cannot infer the type of implicitly-typed out variable `y'
+// Line: 9
+
+public class C
+{
+       public static void Main ()
+       {
+               dynamic target = 3;
+               var x = new Test (target, out var y);
+       }
+}
+
+class Test
+{
+       public Test (int x, out int y)
+       {
+               y = 0;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8198.cs b/mcs/errors/cs8198.cs
new file mode 100644 (file)
index 0000000..267c57e
--- /dev/null
@@ -0,0 +1,19 @@
+// CS8198: An expression tree cannot contain out variable declaration
+// Line: 11
+
+using System;
+using System.Linq.Expressions;
+
+class C
+{
+       static void Main()
+       {
+               Expression<Func<bool>> e = () => Out (out int x);
+       }
+
+       static bool Out (out int value)
+       {
+               value = 3;
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8200-2.cs b/mcs/errors/cs8200-2.cs
new file mode 100644 (file)
index 0000000..d5ad763
--- /dev/null
@@ -0,0 +1,13 @@
+// CS8200: Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers
+// Line: 6
+
+public class C
+{
+       bool res = Foo (out int arg);
+
+       static bool Foo (out int arg)
+       {
+               arg = 2;
+               return false;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8200-3.cs b/mcs/errors/cs8200-3.cs
new file mode 100644 (file)
index 0000000..52c87bf
--- /dev/null
@@ -0,0 +1,13 @@
+// CS8200: Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers
+// Line: 11
+
+public class C
+{
+       bool Prop { get; } = Foo (out int arg);
+
+       static bool Foo (out int arg)
+       {
+               arg = 2;
+               return false;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8200-4.cs b/mcs/errors/cs8200-4.cs
new file mode 100644 (file)
index 0000000..fbba19f
--- /dev/null
@@ -0,0 +1,15 @@
+// CS8200: Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers
+// Line: 8
+
+using System;
+
+public class C
+{
+       event Action H = Foo (out var res);
+
+       static Action Foo (out int arg)
+       {
+               arg = 2;
+               return null;
+       }
+}
diff --git a/mcs/errors/cs8200-5.cs b/mcs/errors/cs8200-5.cs
new file mode 100644 (file)
index 0000000..ce4e647
--- /dev/null
@@ -0,0 +1,12 @@
+// CS8200: Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers
+// Line: 6
+
+public class C
+{
+       bool res = Foo () is string s;
+
+       static object Foo ()
+       {
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8200-6.cs b/mcs/errors/cs8200-6.cs
new file mode 100644 (file)
index 0000000..b93764c
--- /dev/null
@@ -0,0 +1,12 @@
+// CS8200: Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers
+// Line: 6
+
+class X
+{
+    public static bool Test { get; } = Foo () is bool x;
+
+    static object Foo ()
+    {
+        return false;
+    }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8200.cs b/mcs/errors/cs8200.cs
new file mode 100644 (file)
index 0000000..e7565e4
--- /dev/null
@@ -0,0 +1,20 @@
+// CS8200: Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers
+// Line: 11
+
+public class C
+{
+       public C (bool value)
+       {               
+       }
+
+       public C ()
+               : this (Foo (out int arg))
+       {       
+       }
+
+       static bool Foo (out int arg)
+       {
+               arg = 2;
+               return false;
+       }
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8201.cs b/mcs/errors/cs8201.cs
new file mode 100644 (file)
index 0000000..7a11417
--- /dev/null
@@ -0,0 +1,15 @@
+// CS8201: Out variable and pattern variable declarations are not allowed within a query clause
+// Line: 11
+
+using System.Linq;
+
+class Program
+{
+       public static void Main ()
+       {
+               var a = "abcdef";
+               var res = from x in a from y in M (a, out var z) select x;
+       }
+
+       public static T M<T>(T x, out T z) => z = x;
+}
\ No newline at end of file
diff --git a/mcs/errors/cs8208.cs b/mcs/errors/cs8208.cs
new file mode 100644 (file)
index 0000000..ca6cd1d
--- /dev/null
@@ -0,0 +1,12 @@
+// CS8208: The type `dynamic' pattern matching is not allowed
+// Line: 9
+
+static class Program
+{
+       public static void Main ()
+       {
+               object o = null;            
+               if (o is dynamic res) {
+               }
+       }
+}
index d27fe806048797af33538b202c262e0e040dff4e..6cec0e1da6dc57513c0af368e3ec08a8f5ac6848 100644 (file)
@@ -1652,9 +1652,10 @@ namespace Mono.CSharp {
                        fc.TryFinally = prev_tf;
                }
 
-               public override void MarkReachable (Reachability rc)
+               public override Reachability MarkReachable (Reachability rc)
                {
                        block.MarkReachable (rc);
+                       return rc;
                }
 
                public void SetHasThisAccess ()
index a5edeb53cf68b8e77b94dcf7a5363131038c423a..702ace629c3f3e4fb23802345b31a97428eca232 100644 (file)
@@ -651,13 +651,35 @@ namespace Mono.CSharp
                //
                // Returns dynamic when at least one argument is of dynamic type
                //
-               public void Resolve (ResolveContext ec, out bool dynamic)
+               public void Resolve (ResolveContext rc, out bool dynamic)
                {
                        dynamic = false;
+
+                       List<LocalVariable> var_locals = null;
                        foreach (Argument a in args) {
-                               a.Resolve (ec);
-                               if (a.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && !a.IsByRef)
+                               a.Resolve (rc);
+
+                               if (a.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic && !a.IsByRef) {
                                        dynamic = true;
+                                       continue;
+                               }
+
+                               if (a.Type == InternalType.VarOutType) {
+                                       var de = a.Expr as DeclarationExpression;
+                                       if (de != null) {
+                                               if (var_locals == null)
+                                                       var_locals = new List<LocalVariable> ();
+
+                                               var_locals.Add (de.Variable);
+                                               continue;
+                                       }
+
+                                       var lvr = a.Expr as LocalVariableReference;
+                                       if (lvr != null && var_locals != null && var_locals.Contains (lvr.local_info)) {
+                                               rc.Report.Error (8196, lvr.Location, "Reference to an implicitly typed out variable `{0}' is not permitted in the same argument list", lvr.Name);
+                                               lvr.Type = InternalType.ErrorType;
+                                       }
+                               }
                        }
                }
 
index 7200501984e2230825ba7f8dfdaf06f3cec5fba6..43399ffc3ae105be93bdbe212052714c7f7cde95 100644 (file)
@@ -503,11 +503,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override void MarkReachable (Reachability rc)
+               public override Reachability MarkReachable (Reachability rc)
                {
-                       var es = source as ExpressionStatement;
-                       if (es != null)
-                               es.MarkReachable (rc);
+                       return source.MarkReachable (rc);
                }
        }
 
index 39d114fd451cb516dca4d5a8e9679e07ecf6a2ff..fd6499346e88b08abfc56ff85071cc9997c83af1 100644 (file)
@@ -127,10 +127,9 @@ namespace Mono.CSharp
                        stmt.EmitStatement (ec);
                }
 
-               public override void MarkReachable (Reachability rc)
+               public override Reachability MarkReachable (Reachability rc)
                {
-                       base.MarkReachable (rc);
-                       stmt.MarkReachable (rc);
+                       return stmt.MarkReachable (rc);
                }
 
                public override object Accept (StructuralVisitor visitor)
@@ -514,11 +513,12 @@ namespace Mono.CSharp
                        ec.Emit (OpCodes.Ret);
                }
 
-               public override void MarkReachable (Reachability rc)
+               public override Reachability MarkReachable (Reachability rc)
                {
                        //
                        // Reachability has been done in AsyncInitializerStatement
                        //
+                       return rc;
                }
        }
 
index da85bf386b21c306f44105af857dec6196e43509..f19c1a400e33d6e0f676f93f4cdf15f3af415129 100644 (file)
@@ -469,27 +469,37 @@ namespace Mono.CSharp {
                                //
                                lc = left as EnumConstant;
                                rc = right as EnumConstant;
-                               if (lc != null || rc != null){
+                               if (lc != null || rc != null) {
+                                       TypeSpec res_type;
                                        if (lc == null) {
-                                               lc = rc;
-                                               lt = lc.Type;
-                                               right = left;
-                                       }
+                                               res_type = right.Type;
 
-                                       // U has to be implicitly convetible to E.base
-                                       right = right.ConvertImplicitly (lc.Child.Type);
-                                       if (right == null)
-                                               return null;
+                                               // Y has to be implicitly convertible to E.base
+                                               left = left.ConvertImplicitly (rc.Child.Type);
+                                               if (left == null)
+                                                       return null;
 
-                                       result = BinaryFold (ec, oper, lc.Child, right, loc);
+                                               right = rc.Child;
+                                       } else {
+                                               res_type = left.Type;
+
+                                               // U has to be implicitly convertible to E.base
+                                               right = right.ConvertImplicitly (lc.Child.Type);
+                                               if (right == null)
+                                                       return null;
+
+                                               left = lc.Child;
+                                       }
+
+                                       result = BinaryFold (ec, oper, left, right, loc);
                                        if (result == null)
                                                return null;
 
-                                       result = result.Reduce (ec, lt);
+                                       result = result.Reduce (ec, res_type);
                                        if (result == null)
                                                return null;
 
-                                       return new EnumConstant (result, lt);
+                                       return new EnumConstant (result, res_type);
                                }
 
                                if (left is NullLiteral && right is NullLiteral) {
index 2f2fe4580b400dfc74c80bd59366ceeeada97f71..d1aedad9971215c790a12e6adb52a332cdd52c79 100644 (file)
@@ -639,6 +639,15 @@ namespace Mono.CSharp
                        }
                }
 
+               public bool HasInstanceField {
+                       get {
+                               return (caching_flags & Flags.HasInstanceField) != 0;
+                       }
+                       set {
+                               caching_flags |= Flags.HasInstanceField;
+                       }
+               }
+
                // Indicated whether container has StructLayout attribute set Explicit
                public bool HasExplicitLayout {
                        get { return (caching_flags & Flags.HasExplicitLayout) != 0; }
@@ -848,18 +857,22 @@ namespace Mono.CSharp
                        if ((field.ModFlags & Modifiers.STATIC) != 0)
                                return true;
 
-                       var first_field = PartialContainer.first_nonstatic_field;
-                       if (first_field == null) {
+                       if (!PartialContainer.HasInstanceField) {
+                               PartialContainer.HasInstanceField = true;
                                PartialContainer.first_nonstatic_field = field;
                                return true;
                        }
 
-                       if (Kind == MemberKind.Struct && first_field.Parent != field.Parent) {
-                               Report.SymbolRelatedToPreviousError (first_field.Parent);
-                               Report.Warning (282, 3, field.Location,
-                                       "struct instance field `{0}' found in different declaration from instance field `{1}'",
-                                       field.GetSignatureForError (), first_field.GetSignatureForError ());
+                       if (Kind == MemberKind.Struct) {
+                               var first_field = PartialContainer.first_nonstatic_field;
+                               if (first_field.Parent != field.Parent) {
+                                       Report.SymbolRelatedToPreviousError (first_field.Parent);
+                                       Report.Warning (282, 3, field.Location,
+                                               "struct instance field `{0}' found in different declaration from instance field `{1}'",
+                                               field.GetSignatureForError (), first_field.GetSignatureForError ());
+                               }
                        }
+
                        return true;
                }
 
@@ -1299,7 +1312,7 @@ namespace Mono.CSharp
                        //
                        // Sets .size to 1 for structs with no instance fields
                        //
-                       int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null && !(this is StateMachine) ? 1 : 0;
+                       int type_size = Kind == MemberKind.Struct && !HasInstanceField && !(this is StateMachine) ? 1 : 0;
 
                        var parent_def = Parent as TypeDefinition;
                        if (parent_def == null) {
@@ -2214,6 +2227,10 @@ namespace Mono.CSharp
                                Module.PredefinedAttributes.CompilerGenerated.EmitAttribute (TypeBuilder);
 
 #if STATIC
+                       if (Kind == MemberKind.Struct && HasInstanceField) {
+                               TypeBuilder.__SetLayout (0, 0);
+                       }
+
                        if ((TypeBuilder.Attributes & TypeAttributes.StringFormatMask) == 0 && Module.HasDefaultCharSet)
                                TypeBuilder.__SetAttributes (TypeBuilder.Attributes | Module.DefaultCharSetType);
 #endif
@@ -3146,7 +3163,7 @@ namespace Mono.CSharp
                                return false;
                        }
 
-                       if (first_nonstatic_field != null) {
+                       if (HasInstanceField) {
                                requires_delayed_unmanagedtype_check = true;
 
                                foreach (var member in Members) {
index ddcb149f942a7c818e78b848558ae693882132d1..b7e773cffed98e88eb596dd77d51a3d06149de2a 100644 (file)
@@ -22,7 +22,8 @@ namespace Mono.CSharp
        {
                Normal = 0,
                Probing = 1,
-               IgnoreAccessibility = 2
+               IgnoreAccessibility = 2,
+               IgnoreStaticUsing = 1 << 10
        }
 
        //
@@ -112,6 +113,9 @@ namespace Mono.CSharp
 
                        if (rc.HasSet (ResolveContext.Options.BaseInitializer))
                                flags |= ResolveContext.Options.BaseInitializer;
+
+                       if (rc.HasSet (ResolveContext.Options.QueryClauseScope))
+                               flags |= ResolveContext.Options.QueryClauseScope;
                }
 
                public ExceptionStatement CurrentTryBlock { get; set; }
@@ -195,6 +199,8 @@ namespace Mono.CSharp
 
                        NameOfScope = 1 << 17,
 
+                       QueryClauseScope = 1 << 18,
+
                        ///
                        /// Indicates the current context is in probing mode, no errors are reported. 
                        ///
@@ -559,6 +565,11 @@ namespace Mono.CSharp
                        variable.SetAssigned (DefiniteAssignment, generatedAssignment);
                }
 
+               public void SetVariableAssigned (VariableInfo variable, DefiniteAssignmentBitSet da)
+               {
+                       variable.SetAssigned (da, false);
+               }
+
                public void SetStructFieldAssigned (VariableInfo variable, string name)
                {
                        variable.SetStructFieldAssigned (DefiniteAssignment, name);
index 36c5626bcc32dd190a10ff102953fb65f56ea8e3..3adb909e6f5afc782964f929c325165b6694813d 100644 (file)
@@ -744,6 +744,9 @@ namespace Mono.CSharp {
                        if (expr_type == target_type)
                                return true;
 
+                       if (expr_type == InternalType.ThrowExpr)
+                               return target_type.Kind != MemberKind.InternalCompilerType;
+
                        if (target_type.IsNullableType)
                                return ImplicitNulableConversion (null, expr, target_type) != null;
 
@@ -1370,7 +1373,7 @@ namespace Mono.CSharp {
                        Expression e;
 
                        if (expr_type == target_type) {
-                               if (expr_type != InternalType.NullLiteral && expr_type != InternalType.AnonymousMethod)
+                               if (expr_type != InternalType.NullLiteral && expr_type != InternalType.AnonymousMethod && expr_type != InternalType.ThrowExpr)
                                        return expr;
                                return null;
                        }
@@ -1396,6 +1399,10 @@ namespace Mono.CSharp {
                                return null;
                        }
 
+                       if (expr_type == InternalType.ThrowExpr) {
+                               return target_type.Kind == MemberKind.InternalCompilerType ? null : EmptyCast.Create (expr, target_type);
+                       }
+
                        if (target_type.IsNullableType)
                                return ImplicitNulableConversion (ec, expr, target_type);
 
index a9748379086bbde75a62e2c78329576af82f3755..2df53e916640209092711ab75dee2489d0e8f64d 100644 (file)
@@ -219,7 +219,7 @@ namespace Mono.CSharp
 %token STRUCT  
 %token SWITCH  
 %token THIS    
-%token THROW   
+%token THROW
 %token TRUE    
 %token TRY     
 %token TYPEOF  
@@ -261,6 +261,7 @@ namespace Mono.CSharp
 %token WHEN
 %token INTERPOLATED_STRING
 %token INTERPOLATED_STRING_END
+%token THROW_EXPR
 
 /* C# keywords which are not really keywords */
 %token GET
@@ -917,11 +918,25 @@ named_argument
                $$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4, arg_mod);
                lbag.AddLocation ($$, GetLocation($2));
          }
+       | identifier_inside_body COLON OUT named_argument_expr_or_out_variable_declaration
+         {
+               if (lang_version <= LanguageVersion.V_3)
+                       FeatureIsNotAvailable (GetLocation ($1), "named argument");
+
+               var lt = (LocatedToken) $1;
+               $$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4, Argument.AType.Out);
+               lbag.AddLocation ($$, GetLocation($2));
+         }
+
        ;
 
 named_argument_expr
        : expression_or_error
-//     | declaration_expression
+       ;
+
+named_argument_expr_or_out_variable_declaration
+       : expression_or_error
+       | out_variable_declaration
        ;
        
 opt_named_modifier
@@ -930,10 +945,6 @@ opt_named_modifier
          { 
                $$ = Argument.AType.Ref;
          }
-       | OUT
-         { 
-               $$ = Argument.AType.Out;
-         }
        ;
                  
 opt_class_member_declarations
@@ -2073,7 +2084,8 @@ set_accessor_declaration
        ;
 
 accessor_body
-       : block 
+       : block
+       | expression_block
        | SEMICOLON
          {
                // TODO: lbag
@@ -2086,6 +2098,7 @@ accessor_body
          }
        ;
 
+
 interface_declaration
        : opt_attributes
          opt_modifiers
@@ -2629,15 +2642,10 @@ event_declarator
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
                lbag.AddLocation ($$, GetLocation ($1));
          }
-       | COMMA IDENTIFIER ASSIGN
+       | COMMA IDENTIFIER ASSIGN event_variable_initializer
          {
-               ++lexer.parsing_block;
-         }
-         event_variable_initializer
-         {
-               --lexer.parsing_block;
                var lt = (LocatedToken) $2;       
-               $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $5);
+               $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), (Expression) $4);
                lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
          }
        ;
@@ -2652,11 +2660,19 @@ event_variable_initializer
                if ((current_event_field.ModFlags & Modifiers.ABSTRACT) != 0) {
                        report.Error (74, lexer.Location, "`{0}': abstract event cannot have an initializer",
                                current_event_field.GetSignatureForError ());
-               }               
+               }
+
+               ++lexer.parsing_block;
+               current_local_parameters = ParametersCompiled.EmptyReadOnlyParameters;
+               start_block (lexer.Location);
          }
          variable_initializer
          {
                $$ = $2;
+
+               --lexer.parsing_block;
+               end_block (lexer.Location);
+               current_local_parameters = null;
          }
        ;
        
@@ -2742,7 +2758,8 @@ event_accessor_block
                report.Error (73, lexer.Location, "An add or remove accessor must have a body");
                $$ = null;
          }
-       | block;
+       | block
+       | expression_block
        ;
 
 attributes_without_members
@@ -3718,16 +3735,12 @@ non_simple_argument
                $$ = new Argument ((Expression) $2, Argument.AType.Ref);
                lbag.AddLocation ($$, GetLocation ($1));
          }
-       | REF declaration_expression
-         {
-               $$ = new Argument ((Expression) $2, Argument.AType.Ref);
-         }
        | OUT variable_reference 
          { 
                $$ = new Argument ((Expression) $2, Argument.AType.Out);
                lbag.AddLocation ($$, GetLocation ($1));
          }
-       | OUT declaration_expression
+       | OUT out_variable_declaration
          {
                $$ = new Argument ((Expression) $2, Argument.AType.Out);
          }
@@ -3743,46 +3756,17 @@ non_simple_argument
          }       
        ;
 
-declaration_expression
-       : OPEN_PARENS declaration_expression CLOSE_PARENS
-         {
-               $$ = new ParenthesizedExpression ((Expression) $2, GetLocation ($1));
-               lbag.AddLocation ($$, GetLocation ($1), GetLocation ($3));
-         }
-/*
-       | CHECKED open_parens_any declaration_expression CLOSE_PARENS
-         {
-               $$ = new CheckedExpr ((Expression) $3, GetLocation ($1));
-               lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
-         }
-       | UNCHECKED open_parens_any declaration_expression CLOSE_PARENS
-         {
-               $$ = new UnCheckedExpr ((Expression) $3, GetLocation ($1));
-               lbag.AddLocation ($$, GetLocation ($2), GetLocation ($4));
-         }
-*/
-       | variable_type identifier_inside_body
+out_variable_declaration
+       : variable_type identifier_inside_body
          {
-               if (lang_version != LanguageVersion.Experimental)
-                       FeatureIsNotAvailable (GetLocation ($1), "declaration expression");
+               if (lang_version < LanguageVersion.V_7)
+                       FeatureIsNotAvailable (GetLocation ($1), "out variable declaration");
 
                var lt = (LocatedToken) $2;
                var lv = new LocalVariable (current_block, lt.Value, lt.Location);
                current_block.AddLocalName (lv);
                $$ = new DeclarationExpression ((FullNamedExpression) $1, lv);
          }
-       | variable_type identifier_inside_body ASSIGN expression
-         {
-               if (lang_version != LanguageVersion.Experimental)
-                       FeatureIsNotAvailable (GetLocation ($1), "declaration expression");
-
-               var lt = (LocatedToken) $2;
-               var lv = new LocalVariable (current_block, lt.Value, lt.Location);
-               current_block.AddLocalName (lv);
-               $$ = new DeclarationExpression ((FullNamedExpression) $1, lv) {
-                       Initializer = (Expression) $4
-               };
-         }
        ;
 
 variable_reference
@@ -4307,6 +4291,13 @@ unary_expression
                
                $$ = new Await ((Expression) $2, GetLocation ($1));
          }
+       | THROW_EXPR prefixed_unary_expression
+         {
+               if (lang_version < LanguageVersion.V_7)
+                       FeatureIsNotAvailable (lexer.Location, "throw expression");
+
+               $$ = new ThrowExpression ((Expression) $2, GetLocation ($1));
+         }
        | BANG error
          {
                Error_SyntaxError (yyToken);
@@ -4476,12 +4467,13 @@ additive_expression
          {
                var is_expr = new Is ((Expression) $1, (Expression) $3, GetLocation ($2));
                if ($4 != null) {
-                       if (lang_version != LanguageVersion.Experimental)
-                               FeatureIsNotAvailable (GetLocation ($4), "type pattern matching");
+                       if (lang_version < LanguageVersion.V_7)
+                               FeatureIsNotAvailable (GetLocation ($4), "pattern matching");
 
                        var lt = (LocatedToken) $4;
-                       is_expr.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
-                       current_block.AddLocalName (is_expr.Variable);
+                       var lv = new LocalVariable (current_block, lt.Value, lt.Location);
+                       is_expr.Variable = lv;
+                       current_block.AddLocalName (lv);
                }
 
                $$ = is_expr;
@@ -4841,6 +4833,15 @@ conditional_expression
                $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, (Expression) $5, GetLocation ($2));
                lbag.AddLocation ($$, GetLocation ($4));
          }
+       | null_coalescing_expression INTERR expression COLON THROW prefixed_unary_expression
+         {
+               if (lang_version < LanguageVersion.V_7)
+                       FeatureIsNotAvailable (lexer.Location, "throw expression");
+
+               var expr = new ThrowExpression ((Expression) $6, GetLocation ($5));
+               $$ = new Conditional (new BooleanExpression ((Expression) $1), (Expression) $3, expr, GetLocation ($2));
+               lbag.AddLocation ($$, GetLocation ($4));
+         }
        | null_coalescing_expression INTERR expression error
          {
                Error_SyntaxError (yyToken);
@@ -6363,11 +6364,16 @@ return_statement
        ;
 
 throw_statement
-       : THROW opt_expression SEMICOLON
+       : THROW expression SEMICOLON
          {
                $$ = new Throw ((Expression) $2, GetLocation ($1));
                lbag.AddStatement ($$, GetLocation ($3));
          }
+       | THROW SEMICOLON
+         {
+               $$ = new Throw (null, GetLocation ($1));
+               lbag.AddStatement ($$, GetLocation ($2));
+         }
        | THROW expression error
          {
                Error_SyntaxError (yyToken);
@@ -7700,8 +7706,7 @@ void start_block (Location loc)
        }
 }
 
-Block
-end_block (Location loc)
+Block end_block (Location loc)
 {
        Block retval = current_block.Explicit;
        retval.SetEndLocation (loc);
@@ -8078,6 +8083,7 @@ static string GetTokenName (int token)
        case Token.THIS:
                return "this";
        case Token.THROW:
+       case Token.THROW_EXPR:
                return "throw";
        case Token.TRUE:
                return "true";
index e6a95fe8163a3590acb9f23602cc10d4cdec63dd..1be3309b1bfdd611d404408e743e0414f81f2860 100644 (file)
@@ -893,6 +893,16 @@ namespace Mono.CSharp
                                if (parsing_block == 0)
                                        res = -1;
 
+                               break;
+                       case Token.THROW:
+                               switch (current_token) {
+                               case Token.ARROW:
+                               case Token.OP_COALESCING:
+                               case Token.INTERR:
+                                       res = Token.THROW_EXPR;
+                                       break;
+                               }
+
                                break;
                        }
 
@@ -1267,7 +1277,8 @@ namespace Mono.CSharp
                        else if (the_token == Token.INTERR_NULLABLE || the_token == Token.STAR)
                                goto again;
                        else if (the_token == Token.OP_GENERICS_LT) {
-                               if (!parse_less_than (ref genericDimension))
+                               int unused = 0;
+                               if (!parse_less_than (ref unused))
                                        return false;
                                goto again;
                        } else if (the_token == Token.OPEN_BRACKET) {
@@ -1314,7 +1325,8 @@ namespace Mono.CSharp
                        }
 
                        if (d == '.') {
-                               return Token.INTERR_OPERATOR;
+                               d = reader.Peek ();
+                               return d >= '0' && d <= '9' ? Token.INTERR : Token.INTERR_OPERATOR;
                        }
 
                        if (d != ' ') {
@@ -1344,6 +1356,7 @@ namespace Mono.CSharp
                        case Token.THIS:
                        case Token.NEW:
                        case Token.INTERPOLATED_STRING:
+                       case Token.THROW:
                                next_token = Token.INTERR;
                                break;
                                
index 340eb488ab08c6a37f1d52cae579f9e7edb38643..0f0b1d1bb69749696d80b025d5da5bf27faf276b 100644 (file)
@@ -290,7 +290,8 @@ namespace Mono.CSharp {
                        HasInstanceConstructor = 1 << 16,
                        HasUserOperators = 1 << 17,
                        CanBeReused = 1 << 18,
-                       InterfacesExpanded = 1 << 19
+                       InterfacesExpanded = 1 << 19,
+                       HasInstanceField = 1 << 20
                }
 
                /// <summary>
index 0a11914328ae79629b356b78bd879de1942f3b69..4db99f7e5fe7ceff533fc010e89ff078d489f9e0 100644 (file)
@@ -44,31 +44,45 @@ namespace Mono.CSharp
 
                void tokenize_file (SourceFile sourceFile, ModuleContainer module, ParserSession session)
                {
-                       Stream input;
+                       Stream input = null;
+                       SeekableStreamReader reader = null;
 
                        try {
-                               input = File.OpenRead (sourceFile.Name);
+                               if (sourceFile.GetInputStream != null) {
+                                       reader = sourceFile.GetInputStream (sourceFile);
+                                       if (reader == null) {
+                                               throw new FileNotFoundException ("Delegate returned null", sourceFile.Name);
+                                       }
+                               } else {
+                                       input = File.OpenRead (sourceFile.Name);
+                               }
                        } catch {
                                Report.Error (2001, "Source file `" + sourceFile.Name + "' could not be found");
                                return;
                        }
 
-                       using (input){
-                               SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
-                               var file = new CompilationSourceFile (module, sourceFile);
+                       if (reader == null) {
+                               using (input) {
+                                       reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
+                                       DoTokenize (sourceFile, module, session, reader);
+                               }
+                       } else {
+                               DoTokenize (sourceFile, module, session, reader);
+                       }
+               }
+
+               void DoTokenize (SourceFile sourceFile, ModuleContainer module, ParserSession session, SeekableStreamReader reader) {
+                       var file = new CompilationSourceFile (module, sourceFile);
 
-                               Tokenizer lexer = new Tokenizer (reader, file, session, ctx.Report);
-                               int token, tokens = 0, errors = 0;
+                       Tokenizer lexer = new Tokenizer (reader, file, session, ctx.Report);
+                       int token, tokens = 0, errors = 0;
 
-                               while ((token = lexer.token ()) != Token.EOF){
-                                       tokens++;
-                                       if (token == Token.ERROR)
-                                               errors++;
-                               }
-                               Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
+                       while ((token = lexer.token ()) != Token.EOF) {
+                               tokens++;
+                               if (token == Token.ERROR)
+                                       errors++;
                        }
-                       
-                       return;
+                       Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
                }
 
                void Parse (ModuleContainer module)
@@ -129,36 +143,50 @@ namespace Mono.CSharp
 
                public void Parse (SourceFile file, ModuleContainer module, ParserSession session, Report report)
                {
-                       Stream input;
+                       Stream input = null;
+                       SeekableStreamReader reader = null;
 
                        try {
-                               input = File.OpenRead (file.Name);
+                               if (file.GetInputStream != null) {
+                                       reader = file.GetInputStream (file);
+                                       if (reader == null) {
+                                               throw new FileNotFoundException ("Delegate returned null", file.Name);
+                                       }
+                               } else {
+                                       input = File.OpenRead (file.Name);
+                               }
                        } catch {
                                report.Error (2001, "Source file `{0}' could not be found", file.Name);
                                return;
                        }
 
-                       // Check 'MZ' header
-                       if (input.ReadByte () == 77 && input.ReadByte () == 90) {
+                       if (reader == null) {
+                               using (input) {
+                                       // Check 'MZ' header
+                                       if (input.ReadByte () == 77 && input.ReadByte () == 90) {
 
-                               report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
-                               input.Close ();
-                               return;
-                       }
+                                               report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
+                                               return;
+                                       }
 
-                       input.Position = 0;
-                       SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding, session.StreamReaderBuffer);
+                                       input.Position = 0;
+                                       reader = new SeekableStreamReader (input, ctx.Settings.Encoding, session.StreamReaderBuffer);
 
+                                       DoParse (file, module, session, report, reader);
+                               }
+                       } else {
+                               DoParse (file, module, session, report, reader);
+                       }
+               }
+
+               void DoParse (SourceFile file, ModuleContainer module, ParserSession session, Report report, SeekableStreamReader reader) {
                        Parse (reader, file, module, session, report);
 
                        if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum) {
-                               input.Position = 0;
+                               reader.Stream.Position = 0;
                                var checksum = session.GetChecksumAlgorithm ();
-                               file.SetChecksum (checksum.ComputeHash (input));
+                               file.SetChecksum (checksum.ComputeHash (reader.Stream));
                        }
-
-                       reader.Dispose ();
-                       input.Close ();
                }
 
                public static void Parse (SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, ParserSession session, Report report)
index 09d78302854915f3eb5108a6698c2dfb8d50da1c..fd4662b2fed315fd7c7aa36aa5ec8e7803bf3f19 100644 (file)
@@ -282,7 +282,7 @@ namespace Mono.CSharp
                        foreach (var arg in arguments) {
                                if (arg.Type == InternalType.VarOutType) {
                                        // Should be special error message about dynamic dispatch
-                                       rc.Report.Error (8047, arg.Expr.Location, "Declaration expression cannot be used in this context");
+                                       rc.Report.Error (8197, arg.Expr.Location, "Cannot infer the type of implicitly-typed out variable `{0}'", ((DeclarationExpression) arg.Expr).Variable.Name);
                                }
                        }
 
index 82e86649ca65432646dd1b9e946f7dc9d005eb64..73e50c4068f62902fd8f04dd4062e324366dd717 100644 (file)
@@ -239,6 +239,15 @@ namespace Mono.CSharp {
                        return null;
                }
 
+               protected void CheckExpressionVariable (ResolveContext rc)
+               {
+                       if (rc.HasAny (ResolveContext.Options.BaseInitializer | ResolveContext.Options.FieldInitializerScope)) {
+                               rc.Report.Error (8200, loc, "Out variable and pattern variable declarations are not allowed within constructor initializers, field initializers, or property initializers");
+                       } else if (rc.HasSet (ResolveContext.Options.QueryClauseScope)) {
+                               rc.Report.Error (8201, loc, "Out variable and pattern variable declarations are not allowed within a query clause");
+                       }
+               }
+
                public static void ErrorIsInaccesible (IMemberContext rc, string member, Location loc)
                {
                        rc.Module.Compiler.Report.Error (122, loc, "`{0}' is inaccessible due to its protection level", member);
@@ -638,6 +647,10 @@ namespace Mono.CSharp {
                        ec.Emit (OpCodes.Pop);
                }
 
+               public virtual void EmitPrepare (EmitContext ec)
+               {
+               }
+
                //
                // Emits the expression into temporary field variable. The method
                // should be used for await expressions only
@@ -995,6 +1008,11 @@ namespace Mono.CSharp {
                {
                }
 
+               public virtual Reachability MarkReachable (Reachability rc)
+               {
+                       return rc;
+               }
+
                //
                // Special version of flow analysis for expressions which can return different
                // on-true and on-false result. Used by &&, ||, ?: expressions
@@ -1295,10 +1313,6 @@ namespace Mono.CSharp {
        /// </summary>
        public abstract class ExpressionStatement : Expression
        {
-               public virtual void MarkReachable (Reachability rc)
-               {
-               }
-
                public virtual ExpressionStatement ResolveStatement (BlockContext ec)
                {
                        Expression e = Resolve (ec);
@@ -1460,6 +1474,11 @@ namespace Mono.CSharp {
 #endif
                }
 
+               public override Reachability MarkReachable (Reachability rc)
+               {
+                       return child.MarkReachable (rc);
+               }
+
                protected override void CloneTo (CloneContext clonectx, Expression t)
                {
                        // Nothing to clone
@@ -2408,6 +2427,11 @@ namespace Mono.CSharp {
                {
                        return orig_expr.MakeExpression (ctx);
                }
+
+               public override Reachability MarkReachable (Reachability rc)
+               {
+                       return expr.MarkReachable (rc);
+               }
        }
 
        //
@@ -2762,9 +2786,13 @@ namespace Mono.CSharp {
                        return null;
                }
 
-               public bool IsPossibleTypeOrNamespace (IMemberContext mc)
+               bool IsPossibleTypeOrNamespace (IMemberContext mc)
                {
-                       return mc.LookupNamespaceOrType (Name, Arity, LookupMode.Probing, loc) != null;
+                       //
+                       // Has to ignore static usings because we are looking for any member not just type
+                       // in this context
+                       //
+                       return mc.LookupNamespaceOrType (Name, Arity, LookupMode.Probing | LookupMode.IgnoreStaticUsing, loc) != null;
                }
 
                public bool IsPossibleType (IMemberContext mc)
@@ -2886,6 +2914,15 @@ namespace Mono.CSharp {
                                        return me;
                                }
 
+                               //
+                               // Stage 3: Lookup nested types, namespaces and type parameters in the context
+                               //
+                               if ((restrictions & MemberLookupRestrictions.InvocableOnly) == 0 && !variable_found) {
+                                       if (IsPossibleTypeOrNamespace (rc)) {
+                                               return ResolveAsTypeOrNamespace (rc, false);
+                                       }
+                               }
+
                                var expr = NamespaceContainer.LookupStaticUsings (rc, Name, Arity, loc);
                                if (expr != null) {
                                        if (Arity > 0) {
@@ -2898,15 +2935,6 @@ namespace Mono.CSharp {
                                        return expr;
                                }
 
-                               //
-                               // Stage 3: Lookup nested types, namespaces and type parameters in the context
-                               //
-                               if ((restrictions & MemberLookupRestrictions.InvocableOnly) == 0 && !variable_found) {
-                                       if (IsPossibleTypeOrNamespace (rc)) {
-                                               return ResolveAsTypeOrNamespace (rc, false);
-                                       }
-                               }
-
                                if ((restrictions & MemberLookupRestrictions.NameOfExcluded) == 0 && Name == "nameof")
                                        return new NameOf (this);
 
@@ -5402,10 +5430,8 @@ namespace Mono.CSharp {
 
                static TypeSpec MoreSpecific (TypeSpec p, TypeSpec q)
                {
-                       if (TypeManager.IsGenericParameter (p) && !TypeManager.IsGenericParameter (q))
-                               return q;
-                       if (!TypeManager.IsGenericParameter (p) && TypeManager.IsGenericParameter (q))
-                               return p;
+                       if (p.IsGenericParameter != q.IsGenericParameter)
+                               return p.IsGenericParameter ? q : p;
 
                        var ac_p = p as ArrayContainer;
                        if (ac_p != null) {
@@ -5418,18 +5444,22 @@ namespace Mono.CSharp {
                                        return p;
                                if (specific == ac_q.Element)
                                        return q;
-                       } else if (p.IsGeneric && q.IsGeneric) {
-                               var pargs = TypeManager.GetTypeArguments (p);
-                               var qargs = TypeManager.GetTypeArguments (q);
+
+                               return null;
+                       }
+
+                       if (p.IsGeneric && q.IsGeneric) {
+                               var pargs = p.TypeArguments;
+                               var qargs = q.TypeArguments;
 
                                bool p_specific_at_least_once = false;
                                bool q_specific_at_least_once = false;
 
                                for (int i = 0; i < pargs.Length; i++) {
-                                       TypeSpec specific = MoreSpecific (pargs[i], qargs[i]);
-                                       if (specific == pargs[i])
+                                       TypeSpec specific = MoreSpecific (pargs [i], qargs [i]);
+                                       if (specific == pargs [i])
                                                p_specific_at_least_once = true;
-                                       if (specific == qargs[i])
+                                       if (specific == qargs [i])
                                                q_specific_at_least_once = true;
                                }
 
index d4e83a506a0fcfbf1d1b00d8522173ca92f15462..60e0c6d64a05de757fecad7d838f71415d8545af 100644 (file)
@@ -958,6 +958,12 @@ namespace Mono.CSharp
                                importer.ImportAssembly (a, module.GlobalRootNamespace);
                        }
                }
+
+               public void ImportTypes (bool importExtensionTypes, params Type[] types) {
+#if !STATIC
+                       importer.ImportTypes (types, module.GlobalRootNamespace, importExtensionTypes);
+#endif
+               }
        }
 
        
index c054330db202f339be76b7a07f01626fd207f7fe..da37657867ed0e59f43a1d9eefdd010e977e9ae8 100644 (file)
@@ -1490,6 +1490,11 @@ namespace Mono.CSharp
                        expr.EmitSideEffect (ec);
                }
 
+               public override void EmitPrepare (EmitContext ec)
+               {
+                       expr.EmitPrepare (ec);
+               }
+
                public override void FlowAnalysis (FlowAnalysisContext fc)
                {
                        expr.FlowAnalysis (fc);
@@ -1535,7 +1540,7 @@ namespace Mono.CSharp
                public override Expression CreateExpressionTree (ResolveContext ec)
                {
                        if (Variable != null)
-                               throw new NotSupportedException ();
+                               ec.Report.Error (8122, loc, "An expression tree cannot contain a pattern matching operator");
 
                        Arguments args = Arguments.CreateForExpressionTree (ec, null,
                                expr.CreateExpressionTree (ec),
@@ -1590,6 +1595,14 @@ namespace Mono.CSharp
                        ec.Emit (on_true ? OpCodes.Brtrue : OpCodes.Brfalse, target);
                }
 
+               public override void EmitPrepare (EmitContext ec)
+               {
+                       base.EmitPrepare (ec);
+
+                       if (Variable != null)
+                               Variable.CreateBuilder (ec);
+               }
+
                void EmitPatternMatch (EmitContext ec)
                {
                        var no_match = ec.DefineLabel ();
@@ -1695,7 +1708,13 @@ namespace Mono.CSharp
                                        value_on_stack = false;
                                }
 
-                               Variable.CreateBuilder (ec);
+                               //
+                               // It's ok to have variable builder create out of order. It simplified emit
+                               // of statements like while (condition) { }
+                               //
+                               if (!Variable.Created)
+                                       Variable.CreateBuilder (ec);
+                               
                                Variable.EmitAssign (ec);
 
                                if (expr_unwrap != null) {
@@ -1739,6 +1758,21 @@ namespace Mono.CSharp
                                fc.SetVariableAssigned (Variable.VariableInfo, true);
                }
 
+               public override void FlowAnalysisConditional (FlowAnalysisContext fc)
+               {
+                       if (Variable == null) {
+                               base.FlowAnalysisConditional (fc);
+                               return;
+                       }
+
+                       expr.FlowAnalysis (fc);
+
+                       fc.DefiniteAssignmentOnTrue = fc.BranchDefiniteAssignment ();
+                       fc.DefiniteAssignmentOnFalse = fc.DefiniteAssignment;
+
+                       fc.SetVariableAssigned (Variable.VariableInfo, fc.DefiniteAssignmentOnTrue);
+               }
+
                protected override void ResolveProbeType (ResolveContext rc)
                {
                        if (!(ProbeType is TypeExpr) && rc.Module.Compiler.Settings.Version == LanguageVersion.Experimental) {
@@ -1849,6 +1883,15 @@ namespace Mono.CSharp
 
                Expression ResolveResultExpression (ResolveContext ec)
                {
+                       if (Variable != null) {
+                               if (expr is NullLiteral) {
+                                       ec.Report.Error (8117, loc, "Cannot use null as pattern matching operand");
+                                       return this;
+                               }
+
+                               CheckExpressionVariable (ec);
+                       }
+
                        TypeSpec d = expr.Type;
                        bool d_is_nullable = false;
 
@@ -1856,7 +1899,7 @@ namespace Mono.CSharp
                        // If E is a method group or the null literal, or if the type of E is a reference
                        // type or a nullable type and the value of E is null, the result is false
                        //
-                       if (expr.IsNull || expr.eclass == ExprClass.MethodGroup)
+                       if (expr.IsNull)
                                return CreateConstantResult (ec, false);
 
                        if (d.IsNullableType) {
@@ -1870,6 +1913,11 @@ namespace Mono.CSharp
                        TypeSpec t = probe_type_expr;
                        bool t_is_nullable = false;
                        if (t.IsNullableType) {
+                               if (Variable != null) {
+                                       ec.Report.Error (8116, loc, "The nullable type `{0}' pattern matching is not allowed. Consider using underlying type `{1}'",
+                                                                        t.GetSignatureForError (), Nullable.NullableInfo.GetUnderlyingType (t).GetSignatureForError ());
+                               }
+
                                var ut = Nullable.NullableInfo.GetUnderlyingType (t);
                                if (!ut.IsGenericParameter) {
                                        t = ut;
@@ -1914,9 +1962,13 @@ namespace Mono.CSharp
                                        return ResolveGenericParameter (ec, d, tps);
 
                                if (t.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
-                                       ec.Report.Warning (1981, 3, loc,
-                                               "Using `{0}' to test compatibility with `{1}' is identical to testing compatibility with `object'",
-                                               OperatorName, t.GetSignatureForError ());
+                                       if (Variable != null) {
+                                               ec.Report.Error (8208, loc, "The type `{0}' pattern matching is not allowed", t.GetSignatureForError ());
+                                       } else {
+                                               ec.Report.Warning (1981, 3, loc,
+                                                       "Using `{0}' to test compatibility with `{1}' is identical to testing compatibility with `object'",
+                                                       OperatorName, t.GetSignatureForError ());
+                                       }
                                }
 
                                if (TypeManager.IsGenericParameter (d))
@@ -2562,12 +2614,14 @@ namespace Mono.CSharp
 
                public override Expression CreateExpressionTree (ResolveContext rc)
                {
-                       rc.Report.Error (8046, loc, "An expression tree cannot contain a declaration expression");
+                       rc.Report.Error (8198, loc, "An expression tree cannot contain out variable declaration");
                        return null;
                }
 
                bool DoResolveCommon (ResolveContext rc)
                {
+                       CheckExpressionVariable (rc);
+
                        var var_expr = VariableType as VarExpr;
                        if (var_expr != null) {
                                type = InternalType.VarOutType;
@@ -7570,14 +7624,21 @@ namespace Mono.CSharp
                        bool is_value_type = type.IsStructOrEnum;
                        VariableReference vr = target as VariableReference;
 
+                       bool prepare_await = ec.HasSet (BuilderContext.Options.AsyncBody) && arguments?.ContainsEmitWithAwait () == true;
+
                        if (target != null && is_value_type && (vr != null || method == null)) {
+                               if (prepare_await) {
+                                       arguments = arguments.Emit (ec, false, true);
+                                       prepare_await = false;
+                               }
+                               
                                target.AddressOf (ec, AddressOp.Store);
                        } else if (vr != null && vr.IsRef) {
                                vr.EmitLoad (ec);
                        }
 
                        if (arguments != null) {
-                               if (ec.HasSet (BuilderContext.Options.AsyncBody) && (arguments.Count > (this is NewInitialize ? 0 : 1)) && arguments.ContainsEmitWithAwait ())
+                               if (prepare_await)
                                        arguments = arguments.Emit (ec, false, true);
 
                                arguments.Emit (ec);
@@ -12728,4 +12789,68 @@ namespace Mono.CSharp
                        return value;
                }
        }
+
+       class ThrowExpression : ExpressionStatement
+       {
+               Expression expr;
+
+               public ThrowExpression (Expression expr, Location loc)
+               {
+                       this.expr = expr;
+                       this.loc = loc;
+               }
+
+               protected override void CloneTo (CloneContext clonectx, Expression t)
+               {
+                       var target = (ThrowExpression)t;
+                       target.expr = expr.Clone (clonectx);
+               }
+
+               public override bool ContainsEmitWithAwait ()
+               {
+                       return expr.ContainsEmitWithAwait ();
+               }
+
+               public override Expression CreateExpressionTree (ResolveContext rc)
+               {
+                       rc.Report.Error (8188, loc, "An expression tree cannot not contain a throw expression");
+                       return expr;
+               }
+
+               protected override Expression DoResolve (ResolveContext rc)
+               {
+                       expr = expr.Resolve (rc, ResolveFlags.Type | ResolveFlags.VariableOrValue);
+
+                       if (expr == null)
+                               return null;
+
+                       expr = Throw.ConvertType (rc, expr);
+
+                       eclass = ExprClass.Value;
+                       type = InternalType.ThrowExpr;
+                       return this;
+               }
+
+               public override void Emit (EmitContext ec)
+               {
+                       EmitStatement (ec);
+               }
+
+               public override void EmitStatement (EmitContext ec)
+               {
+                       expr.Emit (ec);
+
+                       ec.Emit (OpCodes.Throw);
+               }
+
+               public override void FlowAnalysis (FlowAnalysisContext fc)
+               {
+                       expr.FlowAnalysis (fc);
+               }
+
+               public override Reachability MarkReachable (Reachability rc)
+               {
+                       return Reachability.CreateUnreachable ();
+               }
+       }
 }
index 8ddef4f36947b630ee655efd11adbe80fa385b5c..6b35de9846c6ba3d0be116b321af98c721297926 100644 (file)
@@ -3091,7 +3091,8 @@ namespace Mono.CSharp {
                        // Some types cannot be used as type arguments
                        //
                        if ((bound.Type.Kind == MemberKind.Void && !voidAllowed) || bound.Type.IsPointer || bound.Type.IsSpecialRuntimeType ||
-                               bound.Type == InternalType.MethodGroup || bound.Type == InternalType.AnonymousMethod || bound.Type == InternalType.VarOutType)
+                           bound.Type == InternalType.MethodGroup || bound.Type == InternalType.AnonymousMethod || bound.Type == InternalType.VarOutType ||
+                           bound.Type == InternalType.ThrowExpr)
                                return;
 
                        var a = bounds [index];
index d73bc4578df0dd5f0aa2c65e3b0bfb97bd0825dd..dbec2c0469f603bce116c228d4a3252b2abc85be 100644 (file)
@@ -195,7 +195,7 @@ namespace Mono.CSharp
                        TypeSpec field_type;
 
                        try {
-                               field_type = ImportType (fi.FieldType, new DynamicTypeReader (fi));
+                               field_type = ImportType (fi.FieldType, new DynamicTypeReader (fi), declaringType);
 
                                //
                                // Private field has private type which is not fixed buffer
@@ -275,7 +275,7 @@ namespace Mono.CSharp
                        if (add.Modifiers != remove.Modifiers)
                                throw new NotImplementedException ("Different accessor modifiers " + ei.Name);
 
-                       var event_type = ImportType (ei.EventHandlerType, new DynamicTypeReader (ei));
+                       var event_type = ImportType (ei.EventHandlerType, new DynamicTypeReader (ei), declaringType);
                        var definition = new ImportedMemberDefinition (ei, event_type,  this);
                        return new EventSpec (declaringType, definition, event_type, add.Modifiers, add, remove);
                }
@@ -346,7 +346,7 @@ namespace Mono.CSharp
                                if (type.HasElementType) {
                                        var element = type.GetElementType ();
                                        ++dtype.Position;
-                                       spec = ImportType (element, dtype);
+                                       spec = ImportType (element, dtype, null);
 
                                        if (!type.IsArray) {
                                                throw new NotImplementedException ("Unknown element type " + type.ToString ());
@@ -414,6 +414,9 @@ namespace Mono.CSharp
                                kind = MemberKind.Constructor;
                                returnType = module.Compiler.BuiltinTypes.Void;
                        } else {
+                               var mi = (MethodInfo)mb;
+                               returnType = ImportType (mi.ReturnType, new DynamicTypeReader (mi.ReturnParameter), declaringType);
+
                                //
                                // Detect operators and destructors
                                //
@@ -427,7 +430,7 @@ namespace Mono.CSharp
                                                                kind = MemberKind.Operator;
                                                        }
                                                }
-                                       } else if (parameters.IsEmpty && name == Destructor.MetadataName) {
+                                       } else if (parameters.IsEmpty && name == Destructor.MetadataName && returnType.Kind == MemberKind.Void) {
                                                kind = MemberKind.Destructor;
                                                if (declaringType.BuiltinType == BuiltinTypeSpec.Type.Object) {
                                                        mod &= ~Modifiers.OVERRIDE;
@@ -436,9 +439,6 @@ namespace Mono.CSharp
                                        }
                                }
 
-                               var mi = (MethodInfo) mb;
-                               returnType = ImportType (mi.ReturnType, new DynamicTypeReader (mi.ReturnParameter));
-
                                // Cannot set to OVERRIDE without full hierarchy checks
                                // this flag indicates that the method could be override
                                // but further validation is needed
@@ -545,13 +545,13 @@ namespace Mono.CSharp
                                        // Strip reference wrapping
                                        //
                                        var el = p.ParameterType.GetElementType ();
-                                       types[i] = ImportType (el, new DynamicTypeReader (p));  // TODO: 1-based positio to be csc compatible
+                                       types[i] = ImportType (el, new DynamicTypeReader (p), parent);  // TODO: 1-based positio to be csc compatible
                                } else if (i == 0 && method.IsStatic && (parent.Modifiers & Modifiers.METHOD_EXTENSION) != 0 &&
                                        HasAttribute (CustomAttributeData.GetCustomAttributes (method), "ExtensionAttribute", CompilerServicesNamespace)) {
                                        mod = Parameter.Modifier.This;
-                                       types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));
+                                       types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p), parent);
                                } else {
-                                       types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p));
+                                       types[i] = ImportType (p.ParameterType, new DynamicTypeReader (p), parent);
 
                                        if (i >= pi.Length - 2 && types[i] is ArrayContainer) {
                                                if (HasAttribute (CustomAttributeData.GetCustomAttributes (p), "ParamArrayAttribute", "System")) {
@@ -645,14 +645,7 @@ namespace Mono.CSharp
                                        if (set_param_count == 0) {
                                                set_based_param = ParametersCompiled.EmptyReadOnlyParameters;
                                        } else {
-                                               //
-                                               // Create indexer parameters based on setter method parameters (the last parameter has to be removed)
-                                               //
-                                               var data = new IParameterData[set_param_count];
-                                               var types = new TypeSpec[set_param_count];
-                                               Array.Copy (set.Parameters.FixedParameters, data, set_param_count);
-                                               Array.Copy (set.Parameters.Types, types, set_param_count);
-                                               set_based_param = new ParametersImported (data, types, set.Parameters.HasParams);
+                                               set_based_param = IndexerSpec.CreateParametersFromSetter (set, set_param_count);
                                        }
 
                                        mod = set.Modifiers;
@@ -1092,7 +1085,7 @@ namespace Mono.CSharp
                        }
                }
 
-               protected void ImportTypes (MetaType[] types, Namespace targetNamespace, bool importExtensionTypes)
+               public void ImportTypes (MetaType[] types, Namespace targetNamespace, bool importExtensionTypes)
                {
                        Namespace ns = targetNamespace;
                        string prev_namespace = null;
@@ -1199,15 +1192,15 @@ namespace Mono.CSharp
 
                public TypeSpec ImportType (MetaType type)
                {
-                       return ImportType (type, new DynamicTypeReader (type));
+                       return ImportType (type, new DynamicTypeReader (type), null);
                }
 
-               TypeSpec ImportType (MetaType type, DynamicTypeReader dtype)
+               TypeSpec ImportType (MetaType type, DynamicTypeReader dtype, TypeSpec currentType)
                {
                        if (type.HasElementType) {
                                var element = type.GetElementType ();
                                ++dtype.Position;
-                               var spec = ImportType (element, dtype);
+                               var spec = ImportType (element, dtype, currentType);
 
                                if (type.IsArray)
                                        return ArrayContainer.MakeType (module, spec, type.GetArrayRank ());
@@ -1223,11 +1216,19 @@ namespace Mono.CSharp
                        if (compiled_types.TryGetValue (type, out compiled_type)) {
                                if (compiled_type.BuiltinType == BuiltinTypeSpec.Type.Object && dtype.IsDynamicObject ())
                                        return module.Compiler.BuiltinTypes.Dynamic;
+                       } else {
+                               compiled_type = CreateType (type, dtype, true);
+                       }
 
-                               return compiled_type;
+                       if (currentType == compiled_type && currentType?.IsGeneric == true) {
+                               //
+                               // Inflates current type to match behaviour of TypeDefinition::CurrentType used by compiled types
+                               //
+                               var targs = compiled_type.MemberDefinition.TypeParameters;
+                               compiled_type = compiled_type.MakeGenericType (module, targs);
                        }
 
-                       return CreateType (type, dtype, true);
+                       return compiled_type;
                }
 
                static bool IsMissingType (MetaType type)
index 40c500d365ef131b253ca9fa3ae78b7c10b47a68..68f4b6ff30bfabd31d6a2597e5a18a06d002550f 100644 (file)
@@ -79,10 +79,11 @@ namespace Mono.CSharp.Linq
                        {
                        }
 
-                       protected override MethodGroupExpr DoResolveOverload (ResolveContext ec)
+                       protected override MethodGroupExpr DoResolveOverload (ResolveContext rc)
                        {
-                               MethodGroupExpr rmg = mg.OverloadResolve (ec, ref arguments, this, OverloadResolver.Restrictions.None);
-                               return rmg;
+                               using (rc.Set (ResolveContext.Options.QueryClauseScope)) {
+                                       return mg.OverloadResolve (rc, ref arguments, this, OverloadResolver.Restrictions.None);
+                               }
                        }
 
                        protected override Expression DoResolveDynamic (ResolveContext ec, Expression memberExpr)
index 658f3b765fa4f48f4e9e1bce1787cca9a387e215..287aac0797a375b222d27470769e692f0dabefe7 100644 (file)
@@ -59,6 +59,7 @@ namespace Mono.CSharp
                public readonly string OriginalFullPathName;
                public readonly int Index;
                public bool AutoGenerated;
+               public Func<SourceFile, SeekableStreamReader> GetInputStream;
 
                SourceFileEntry file;
                byte[] algGuid, checksum;
@@ -71,6 +72,11 @@ namespace Mono.CSharp
                        this.OriginalFullPathName = path;
                }
 
+               public SourceFile (string name, string path, int index, Func<SourceFile, SeekableStreamReader> inputStreamDelegate) : this (name, path, index)
+               {
+                       this.GetInputStream = inputStreamDelegate;
+               }
+
                public byte[] Checksum {
                        get {
                                return checksum;
index 5384ee1368607a30ea61290b5f19610aa15349e0..3314ca2d48c24d8341e6c44faf7523343d0fc182 100644 (file)
@@ -1157,7 +1157,7 @@ namespace Mono.CSharp {
                                        match = texpr_fne;
                        }
 
-                       if (types_using_table != null) {
+                       if (types_using_table != null && (mode & LookupMode.IgnoreStaticUsing) == 0) {
                                foreach (var using_type in types_using_table) {
                                        var type = MemberCache.FindNestedType (using_type, name, arity, true);
                                        if (type == null)
index 754c888e8b1158711b9f4200666e7a22e6ff273f..a679bdbf60c737334209c239a97dcb6f416adbc3 100644 (file)
@@ -1234,6 +1234,11 @@ namespace Mono.CSharp.Nullable
                                        type = ltype;
                                        return this;
                                }
+                       } else if (ltype == InternalType.ThrowExpr) {
+                               //
+                               // LAMESPEC: I am not really sure what's point of allowing throw on left side
+                               //
+                               return ReducedExpression.Create (right, this, false).Resolve (ec);
                        } else {
                                return null;
                        }
index 275f1013e8b9dfb533215ddeaeb466e4d4a8faf9..1360dbdfd65c3cc4144c8e26b052c4fb200e796f 100644 (file)
@@ -142,6 +142,9 @@ namespace Mono.CSharp {
        }
 
        public class ParamsParameter : Parameter {
+
+               bool ParamsAttributeEmit;
+
                public ParamsParameter (FullNamedExpression type, string name, Attributes attrs, Location loc):
                        base (type, name, Parameter.Modifier.PARAMS, attrs, loc)
                {
@@ -158,13 +161,18 @@ namespace Mono.CSharp {
                                return null;
                        }
 
+                       var mc = ec as MemberCore;
+                       ParamsAttributeEmit = mc == null || (mc.ModFlags & Modifiers.OVERRIDE) == 0;
+
                        return parameter_type;
                }
 
                public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
                {
                        base.ApplyAttributes (mb, cb, index, pa);
-                       pa.ParamArray.EmitAttribute (builder);
+
+                       if (ParamsAttributeEmit)
+                               pa.ParamArray.EmitAttribute (builder);
                }
        }
 
index 661142822f802a9f55ed7560eb510ca5c30c1f50..507b937e2c904310786e8798ee2196d2ef52dcb2 100644 (file)
@@ -147,7 +147,6 @@ namespace Mono.CSharp {
                        int i = 0;
                        if (abstract_methods != null) {
                                int count = abstract_methods.Length;
-                               pending_implementations [i].methods = new MethodSpec [count];
                                pending_implementations [i].need_proxy = new MethodSpec [count];
 
                                pending_implementations [i].methods = abstract_methods;
@@ -527,7 +526,47 @@ namespace Mono.CSharp {
                bool BaseImplements (TypeSpec iface_type, MethodSpec mi, out MethodSpec base_method)
                {
                        base_method = null;
-                       var base_type = container.BaseType;
+                       bool base_can_implement = true;
+                       TypeSpec lookup_type;
+
+                       //
+                       // Special handling for properties/indexers which cannot have accessors
+                       // implementing an interface found in different types (e.g. current and base)
+                       //
+                       if (mi.IsAccessor && container.Interfaces != null) {
+
+                               bool new_implementation = false;
+                               foreach (var iface in container.Interfaces) {
+                                       if (TypeSpecComparer.IsEqual (iface, iface_type)) {
+                                               new_implementation = true;
+                                               break;
+                                       }
+                               }
+
+                               if (new_implementation) {
+                                       MemberFilter filter;
+                                       if (mi.Parameters.Count > 1) {
+                                               var indexer_params = mi.Name [0] == 'g' ? mi.Parameters : IndexerSpec.CreateParametersFromSetter (mi, mi.Parameters.Count - 1);
+                                               filter = new MemberFilter (MemberCache.IndexerNameAlias, 0, MemberKind.Indexer, indexer_params, null);
+                                       } else {
+                                               var pname = mi.Name.Substring (4);
+                                               filter = MemberFilter.Property (pname, null);
+                                       }
+
+                                       var prop = MemberCache.FindMember (container.CurrentType, filter, BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly);
+                                       if (prop != null && (prop.Modifiers & Modifiers.NEW) != 0)
+                                               base_can_implement = false;
+                               }
+                       }
+
+                       if (base_can_implement) {
+                               lookup_type = container.BaseType;
+
+                               if (lookup_type.ImplementsInterface (iface_type, false))
+                                       return true;
+                       } else {
+                               lookup_type = container.CurrentType;
+                       }
 
                        //
                        // Setup filter with no return type to give better error message
@@ -537,7 +576,7 @@ namespace Mono.CSharp {
                        MethodSpec close_match = null;
 
                        while (true) {
-                               var candidates = MemberCache.FindMembers (base_type, mi.Name, false);
+                               var candidates = MemberCache.FindMembers (lookup_type, mi.Name, !base_can_implement);
                                if (candidates == null) {
                                        base_method = close_match;
                                        return false;
@@ -630,8 +669,11 @@ namespace Mono.CSharp {
                                        break;
                                }
 
-                               base_type = candidates[0].DeclaringType.BaseType;
-                               if (base_type == null) {
+                               if (!base_can_implement)
+                                       return false;
+
+                               lookup_type = candidates[0].DeclaringType.BaseType;
+                               if (lookup_type == null) {
                                        base_method = close_match;
                                        return false;
                                }
@@ -668,10 +710,6 @@ namespace Mono.CSharp {
                        for (i = 0; i < top; i++){
                                TypeSpec type = pending_implementations [i].type;
 
-                               bool base_implements_type = type.IsInterface &&
-                                       container.BaseType != null &&
-                                       container.BaseType.ImplementsInterface (type, false);
-
                                for (int j = 0; j < pending_implementations [i].methods.Count; ++j) {
                                        var mi = pending_implementations[i].methods[j];
                                        if (mi == null)
@@ -686,11 +724,8 @@ namespace Mono.CSharp {
                                                        continue;
                                                }
 
-                                               if (pending_implementations [i].optional)
-                                                       continue;
-
                                                MethodSpec candidate;
-                                               if (base_implements_type || BaseImplements (type, mi, out candidate))
+                                               if (BaseImplements (type, mi, out candidate))
                                                        continue;
 
                                                if (candidate == null) {
index 6b1990e1f0983d87bd8b91d0f60dee7efe51129c..0d4efedbd1e6465e4df5f4e50eaa67e07e86db7b 100644 (file)
@@ -820,8 +820,10 @@ namespace Mono.CSharp
                        Parent.PartialContainer.Members.Add (BackingField);
 
                        FieldExpr fe = new FieldExpr (BackingField, Location);
-                       if ((BackingField.ModFlags & Modifiers.STATIC) == 0)
+                       if ((BackingField.ModFlags & Modifiers.STATIC) == 0) {
                                fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
+                               Parent.PartialContainer.HasInstanceField = true;
+                       }
 
                        //
                        // Create get block but we careful with location to
@@ -1791,6 +1793,18 @@ namespace Mono.CSharp
                }
                #endregion
 
+               public static ParametersImported CreateParametersFromSetter (MethodSpec setter, int set_param_count)
+               {
+                       //
+                       // Creates indexer parameters based on setter method parameters (the last parameter has to be removed)
+                       //
+                       var data = new IParameterData [set_param_count];
+                       var types = new TypeSpec [set_param_count];
+                       Array.Copy (setter.Parameters.FixedParameters, data, set_param_count);
+                       Array.Copy (setter.Parameters.Types, types, set_param_count);
+                       return new ParametersImported (data, types, setter.Parameters.HasParams);
+               }
+
                public override string GetSignatureForDocumentation ()
                {
                        return base.GetSignatureForDocumentation () + parameters.GetSignatureForDocumentation ();
index afa4f75bd84865f72666678e53685c0c31df5462..f73bed2b0b0d6b342ceb69dcc362bc54e06adf8e 100644 (file)
@@ -104,6 +104,9 @@ namespace Mono.CSharp {
                        case LanguageVersion.V_6:
                                version = "6.0";
                                break;
+                       case LanguageVersion.V_7:
+                               version = "7.0";
+                               break;
                        default:
                                throw new InternalErrorException ("Invalid feature version", compiler.Settings.Version);
                        }
index a823cd25ea37f0d29feb36d9e3a8de142202f2ab..f3a7bb79b07a9c0edff9f97614d4b57f4b039f45 100644 (file)
@@ -29,9 +29,10 @@ namespace Mono.CSharp {
                V_4 = 4,
                V_5 = 5,
                V_6 = 6,
+               V_7 = 7,
                Experimental = 100,
 
-               Default = LanguageVersion.V_6,
+               Default = V_7,
        }
 
        public enum RuntimeVersion
@@ -1163,15 +1164,15 @@ namespace Mono.CSharp {
                                case "6":
                                        settings.Version = LanguageVersion.V_6;
                                        return ParseResult.Success;
+                               case "7":
+                                       settings.Version = LanguageVersion.V_7;
+                                       return ParseResult.Success;
                                case "experimental":
                                        settings.Version = LanguageVersion.Experimental;
                                        return ParseResult.Success;
-                               case "future":
-                                       report.Warning (8000, 1, "Language version `future' is no longer supported");
-                                       goto case "6";
                                }
 
-                               report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', Default or value in range 1 to 6", value);
+                               report.Error (1617, "Invalid -langversion option `{0}'. It must be `ISO-1', `ISO-2', Default or value in range 1 to 7", value);
                                return ParseResult.Error;
 
                        case "/codepage":
index 20eb19e6cee8b4fb54b7df5d9ff4e57338f1a680..dd7f737139ea372f64af929377608936fd582120 100644 (file)
@@ -558,6 +558,8 @@ namespace Mono.CSharp {
                                ec.Emit (OpCodes.Br, ec.LoopBegin);
                                ec.MarkLabel (while_loop);
 
+                               expr.EmitPrepare (ec);
+
                                Statement.Emit (ec);
                        
                                ec.MarkLabel (ec.LoopBegin);
@@ -1114,6 +1116,7 @@ namespace Mono.CSharp {
        public class Return : ExitStatement
        {
                Expression expr;
+               bool expr_returns;
 
                public Return (Expression expr, Location l)
                {
@@ -1339,7 +1342,9 @@ namespace Mono.CSharp {
                        if (expr != null)
                                expr.FlowAnalysis (fc);
 
-                       base.DoFlowAnalysis (fc);
+                       if (!expr_returns)
+                               base.DoFlowAnalysis (fc);
+                       
                        return true;
                }
 
@@ -1352,6 +1357,12 @@ namespace Mono.CSharp {
                public override Reachability MarkReachable (Reachability rc)
                {
                        base.MarkReachable (rc);
+
+                       if (Expr != null) {
+                               rc = Expr.MarkReachable (rc);
+                               expr_returns = rc.IsUnreachable;
+                       }
+
                        return Reachability.CreateUnreachable ();
                }
 
@@ -1767,6 +1778,19 @@ namespace Mono.CSharp {
                        }
                }
 
+               public static Expression ConvertType (ResolveContext rc, Expression expr)
+               {
+                       var et = rc.BuiltinTypes.Exception;
+                       if (Convert.ImplicitConversionExists (rc, expr, et))
+                               expr = Convert.ImplicitConversion (rc, expr, et, expr.Location);
+                       else {
+                               rc.Report.Error (155, expr.Location, "The type caught or thrown must be derived from System.Exception");
+                               expr = EmptyCast.Create (expr, et);
+                       }
+
+                       return expr;
+               }
+
                public override bool Resolve (BlockContext ec)
                {
                        if (expr == null) {
@@ -1790,11 +1814,7 @@ namespace Mono.CSharp {
                        if (expr == null)
                                return false;
 
-                       var et = ec.BuiltinTypes.Exception;
-                       if (Convert.ImplicitConversionExists (ec, expr, et))
-                               expr = Convert.ImplicitConversion (ec, expr, et, loc);
-                       else
-                               ec.Report.Error (155, expr.Location, "The type caught or thrown must be derived from System.Exception");
+                       expr = ConvertType (ec, expr);
 
                        return true;
                }
@@ -2251,11 +2271,8 @@ namespace Mono.CSharp {
 
                public override Reachability MarkReachable (Reachability rc)
                {
-                       var init = initializer as ExpressionStatement;
-                       if (init != null)
-                               init.MarkReachable (rc);
-
-                       return base.MarkReachable (rc);
+                       base.MarkReachable (rc);
+                       return initializer == null ? rc : initializer.MarkReachable (rc);
                }
 
                protected override void CloneTo (CloneContext clonectx, Statement target)
@@ -2418,6 +2435,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool Created {
+                       get {
+                               return builder != null;
+                       }
+               }
+
                public bool IsDeclared {
                        get {
                                return type != null;
@@ -7459,6 +7482,10 @@ namespace Mono.CSharp {
                                                ec.Emit (OpCodes.Br, end);
 
                                        ec.MarkLabel (labels [i + 1]);
+
+                                       ec.EmitInt (0);
+                                       ec.Emit (OpCodes.Stloc, state_variable);
+
                                        c = catch_sm [i];
                                        ec.AsyncThrowVariable = c.Variable;
                                        c.Block.Emit (ec);
index ab3cc5c1492bc3f62be5b9c7e77600a4047d8104..fe6343a814db2f0136d48500c484d376491fbd30 100644 (file)
@@ -73,7 +73,7 @@ namespace Mono.CSharp {
 #endif
 
                StreamReader reader;
-               Stream stream;
+               public readonly Stream Stream;
 
                char[] buffer;
                int read_ahead_length;  // the length of read buffer
@@ -83,7 +83,7 @@ namespace Mono.CSharp {
 
                public SeekableStreamReader (Stream stream, Encoding encoding, char[] sharedBuffer = null)
                {
-                       this.stream = stream;
+                       this.Stream = stream;
                        this.buffer = sharedBuffer;
 
                        InitializeStream (DefaultReadAheadSize);
@@ -105,7 +105,7 @@ namespace Mono.CSharp {
                        if (buffer == null || buffer.Length < required_buffer_size)
                                buffer = new char [required_buffer_size];
 
-                       stream.Position = 0;
+                       Stream.Position = 0;
                        buffer_start = char_count = pos = 0;
                }
 
@@ -134,7 +134,7 @@ namespace Mono.CSharp {
                                        // Cannot use handy reader.DiscardBufferedData () because it for
                                        // some strange reason resets encoding as well
                                        //
-                                       reader = new StreamReader (stream, reader.CurrentEncoding, true);
+                                       reader = new StreamReader (Stream, reader.CurrentEncoding, true);
                                }
 
                                while (value > buffer_start + char_count) {
index 696bde556c820ad00f9d206bac897e80c10ee470..53402940dc2dda5959bc5d925cefe29d0701d40c 100644 (file)
@@ -1432,6 +1432,7 @@ namespace Mono.CSharp
                public static readonly InternalType Namespace = new InternalType ("<namespace>");
                public static readonly InternalType ErrorType = new InternalType ("<error>");
                public static readonly InternalType VarOutType = new InternalType ("var out");
+               public static readonly InternalType ThrowExpr = new InternalType ("throw expression");
 
                readonly string name;
 
index d8fee033830cf1a65ea14b44a462ef8c0dc6eb77..8db59d7e48d63650f38af54129943c59971b9e47 100644 (file)
@@ -170,6 +170,11 @@ public class ConditionalParsing
                var t = (Int32)sbyte.MaxValue;
        }
 
+       void Test_22 (bool args)
+       {
+               var x = args ?.2f : -.2f;
+       }
+
        static void Helper<T> (T arg)
        {
        }
diff --git a/mcs/tests/gtest-646-lib.cs b/mcs/tests/gtest-646-lib.cs
new file mode 100644 (file)
index 0000000..969dbd7
--- /dev/null
@@ -0,0 +1,14 @@
+// Compiler options: -t:library
+
+public class CompilerBug<T>
+{
+       public int Foo (CompilerBug<T> p1, CompilerBug<T> p2)
+       {
+               return 1;
+       }
+
+       public int Foo (CompilerBug<object> p1, CompilerBug<T> p2)
+       {
+               return 2;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/gtest-646.cs b/mcs/tests/gtest-646.cs
new file mode 100644 (file)
index 0000000..bc3d6a8
--- /dev/null
@@ -0,0 +1,31 @@
+// Compiler options: -r:gtest-646-lib.dll
+
+public class LocalBug<T>
+{
+       public int Foo (LocalBug<T> p1, LocalBug<T> p2)
+       {
+               return 1;
+       }
+
+       public int Foo (LocalBug<object> p1, LocalBug<T> p2)
+       {
+               return 2;
+       }
+}
+
+class X
+{
+       public static int Main ()
+       {
+               var o = new CompilerBug<object> ();
+               if (o.Foo (o, o) != 2)
+                       return 1;
+
+               var o2 = new LocalBug<object> ();
+               if (o2.Foo (o2, o2) != 2)
+                       return 2;
+
+               return 0;
+       }
+}
+
index 51d0b2086fda73f48a672f0c03f5224f8d26104f..eac11ac15f91607127af3ecdd47cab1e7ce9215f 100644 (file)
@@ -5,3 +5,4 @@
 # csXXXX.cs IGNORE     : adds test to ignore list
 
 gtest-230.cs
+test-pattern-02.cs
diff --git a/mcs/tests/test-943.cs b/mcs/tests/test-943.cs
new file mode 100644 (file)
index 0000000..088e2f7
--- /dev/null
@@ -0,0 +1,19 @@
+using System;
+
+public struct MyStruct
+{
+       public int X { get; set; }
+}
+
+class X
+{
+       public static int Main ()
+       {
+               var s = typeof (MyStruct);
+
+               if (s.StructLayoutAttribute.Size != 0)
+                       return 1;
+
+               return 0;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-944-lib.cs b/mcs/tests/test-944-lib.cs
new file mode 100644 (file)
index 0000000..4c91eff
--- /dev/null
@@ -0,0 +1,9 @@
+// Compiler options: -t:library
+
+public class Class1
+{
+       public byte[] Finalize ()
+       {
+               return null;
+       }
+}
diff --git a/mcs/tests/test-944.cs b/mcs/tests/test-944.cs
new file mode 100644 (file)
index 0000000..4aff1f8
--- /dev/null
@@ -0,0 +1,10 @@
+// Compiler options: -r:test-944-lib.dll
+
+public class Class2
+{
+       public static void Main ()
+       {
+               var writer = new Class1();
+               byte[] bytes = writer.Finalize();
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-945.cs b/mcs/tests/test-945.cs
new file mode 100644 (file)
index 0000000..398787d
--- /dev/null
@@ -0,0 +1,22 @@
+public abstract class A
+{
+       public abstract void Bind (string [] args);
+}
+
+public class B : A
+{
+       public override void Bind (params string [] args)
+       {
+       }
+
+       public static int Main ()
+       {
+               var m = typeof (B).GetMethod ("Bind");
+               var p = m.GetParameters ();
+               var ca = p[0].GetCustomAttributes (false);
+               if (ca.Length != 0)
+                       return 1;
+               
+               return 0;
+       }
+}
diff --git a/mcs/tests/test-946.cs b/mcs/tests/test-946.cs
new file mode 100644 (file)
index 0000000..8841f1b
--- /dev/null
@@ -0,0 +1,19 @@
+using System;
+
+class X
+{
+       public static void Main ()
+       {
+
+       }
+
+       int ImportScope (int scope)
+       {
+               switch (scope) {
+               case 200:
+                       throw new NotImplementedException ();
+               }
+
+               throw new NotSupportedException ();
+       }       
+}
\ No newline at end of file
index 2f2b7ab2c9ecf6efbb09b6de7a858a561f65258f..036850e34bbd396b89818a143a148ddff87b2ffd 100644 (file)
@@ -41,6 +41,10 @@ class X {
                        return 3;
                if (Test.A == Test.B)
                        return 4;
+
+               const A e2 = 3 - A.b;
+               if (e2 != A.a)
+                       return 5;
                
                return 0;
        }
diff --git a/mcs/tests/test-async-92.cs b/mcs/tests/test-async-92.cs
new file mode 100644 (file)
index 0000000..e41ac00
--- /dev/null
@@ -0,0 +1,22 @@
+using System.Threading.Tasks;
+
+public class A
+{
+       public async Task<ValueType> Test1 (int input2)
+       {
+               return new ValueType (await Task.FromResult (12345));
+       }
+
+       public static void Main ()
+       {
+               var a = new A ();
+               a.Test1 (1).Wait ();
+       }
+}
+
+public struct ValueType
+{
+       public ValueType (int field2)
+       {
+       }
+}
diff --git a/mcs/tests/test-async-93.cs b/mcs/tests/test-async-93.cs
new file mode 100644 (file)
index 0000000..249de2a
--- /dev/null
@@ -0,0 +1,44 @@
+using System;
+using System.Threading.Tasks;
+public class Test
+{
+       public static int Main()
+       {
+               var t = new Test ();
+               t.Entry().Wait();
+               if (t.caughtCounter != 1)
+                       return 1;
+
+               return 0;
+       }
+       int caughtCounter;
+
+       async Task Entry()
+       {
+               for (int i = 0; i < 5; ++i) {
+                       try {
+                               var result = Func(i);
+                               Console.WriteLine($"{i} result {result}");
+                       } catch (Exception e) {
+                               await Nothing();
+                               Console.WriteLine($"{i} caught");
+                               ++caughtCounter;
+                       }
+               }
+       }
+       bool Func(int i)
+       {
+               if (i == 0) {
+                       throw new Exception();
+               } else {
+                       return true;
+               }
+       }
+       async Task Nothing()
+       {
+       }
+}
\ No newline at end of file
index 9078ff7caaa4814263d2c234eba8ba3ec388bb1a..880d3344585a87c342b090cb2fef7e07f4497fd4 100644 (file)
@@ -1,4 +1,3 @@
-// Compiler options: -langversion:experimental
 using System;
 
 class DeclarationExpression
@@ -14,29 +13,13 @@ class DeclarationExpression
                                return 2;
                }
 
-               Out (out int o2 = 2);
-               if (o2 != 3)
-                       return 3;
-
                Out (out var o3);
                if (o3 != 3)
                        return 4;
 
-               Ref (ref int r = 2);
-               if (r != 7)
-                       return 5;
-
-               Ref (ref ((var r2 = 3)));
-               if (r2 != 8)
-                       return 6;
-
-//             Out2 (str: "b", v: out var o5);
-//             if (o5 != 9)
-//                     return 7;
-
-               Out3 (out var o6 = 9m);
-               if (o6.GetType () != typeof (decimal))
-                       return 8;
+               Out2 (str: "b", v: out var o5);
+               if (o5 != 9)
+                       return 7;
 
                Console.WriteLine ("ok");
                return 0;
@@ -53,14 +36,4 @@ class DeclarationExpression
                v = 9;
                return true;
        }
-
-       static void Out3<T> (out T t)
-       {
-               t = default (T);
-       }
-
-       static void Ref (ref int arg)
-       {
-               arg += 5;
-       }
 }
\ No newline at end of file
index 1c2ce76072838cb2c7adef53527300ca28707907..1d1c355e1a7046dbca07d194c785d44598cb3918 100644 (file)
@@ -1,27 +1,11 @@
-// Compiler options: -langversion:experimental
+using System;
 
-using static System.Console;
-
-public class DeclarationExpressions
+public class C
 {
-       public static void Main()
-       {
-               // TODO:
-               //Test (int value = 5);
-               //WriteLine (value);
-       }
-
-       void M2 ()
+       public static void Main ()
        {
-//             for (int i = 0; int v = 2; ++i) {
-
-//             }
-
        }
 
-       static int Test (int x)
-       {
-               WriteLine (x);
-               return x;
-       }
+       bool Test1 => int.TryParse ("1", out int x);
+       int Test2 => int.TryParse ("2", out int x) ? x : 0;
 }
\ No newline at end of file
diff --git a/mcs/tests/test-decl-expr-03.cs b/mcs/tests/test-decl-expr-03.cs
new file mode 100644 (file)
index 0000000..bc0f01c
--- /dev/null
@@ -0,0 +1,15 @@
+using System;
+using System.Linq;
+
+public class C
+{
+       public static void Main ()
+       {
+               var a = "abcdef";
+
+               var t1 = from x in Foo (a, out var q1) select x;
+               var t2 = from x in a join y in Foo (a, out var q2) on x equals y select x;
+       }
+
+       public static T Foo<T> (T x, out T z) => z = x;
+}
\ No newline at end of file
diff --git a/mcs/tests/test-decl-expr-04.cs b/mcs/tests/test-decl-expr-04.cs
new file mode 100644 (file)
index 0000000..f30c4fe
--- /dev/null
@@ -0,0 +1,18 @@
+public class C
+{
+       public static void Main ()
+       {
+               Test2 (Test (out var x1), x1);
+       }
+
+       static int Test (out int x)
+       {
+               x = 1;
+               return 2;
+       }
+
+       static int Test2 (int x, int y)
+       {
+               return 2;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-expression-bodied-03.cs b/mcs/tests/test-expression-bodied-03.cs
new file mode 100644 (file)
index 0000000..fdde90c
--- /dev/null
@@ -0,0 +1,20 @@
+using System;
+
+class X
+{
+       int v;
+
+       public int Prop {
+               get => 1;
+               set => v = value;
+       }
+
+       public event Action A {
+               add => v = 1;
+               remove => v = 2;
+       }
+
+       public static void Main ()
+       {               
+       }
+}
\ No newline at end of file
index 6db67fb16726fcc16c64a92e004451554f8ff008..84517a6a57431956468f3a253352f44a53de5e93 100644 (file)
@@ -1,5 +1,3 @@
-// Compiler options: -langversion:experimental
-
 using System;
 
 class TypePattern
@@ -8,31 +6,14 @@ class TypePattern
        {
                object o = 3;
                bool r = o is System.String t1;
-               if (t1 != null)
-                       return 1;
-
                if (r)
                        return 2;
 
                if (o is string t2)
                        return 3;
 
-               if (t2 != null)
-                       return 4;
-
-               object o2 = (int?) 4;
-               bool r2 = o2 is byte? t3;
-
-               if (t3 != null)
-                       return 5;
-
-               if (r2)
-                       return 6;
-
                long? l = 5;
                bool r3 = l is long t4;
-               if (t4 != 5)
-                       return 7;
 
                if (!r3)
                        return 8;
@@ -40,4 +21,22 @@ class TypePattern
                Console.WriteLine ("ok");
                return 0;
        }
+
+       static void Test1 (object arg)
+       {
+               while (arg is int b) {
+                       b = 2;
+               }
+       }
+
+       static string Test2 (object arg)
+       {
+               if (arg is string s) {
+                       return s;
+               } else {
+                       s = "";
+               }
+               
+               return s;
+       }
 }
\ No newline at end of file
index 695775ec17939daa00e130e0fa5aeced6da913d1..2858457b2dfffaa352829ba7594b962d4f15fb5f 100644 (file)
@@ -48,14 +48,14 @@ class ConstantPattern
 
                object o4 = (byte?)255;
                var ggg = o4 is 255;
-               if (!ggg)
+               if (ggg)
                        return 8;
 
                if (o4 is null)
                        return 9;
 
                object o5 = (double)-255;
-               if (!(o5 is -byte.MaxValue))
+               if (o5 is -byte.MaxValue)
                        return 10;
 
                object o6 = MyEnum.V_4;
diff --git a/mcs/tests/test-static-using-13.cs b/mcs/tests/test-static-using-13.cs
new file mode 100644 (file)
index 0000000..6760539
--- /dev/null
@@ -0,0 +1,21 @@
+using System;
+using static TestClass;
+
+internal class Program
+{
+       public static void Main (string[] args)
+       {
+               var res = Directions.Up;
+       }
+}
+
+public enum Directions
+{
+       Up,
+       NotUp,
+}
+
+public static class TestClass
+{
+       public static int Directions;
+}
diff --git a/mcs/tests/test-throw-expr-01.cs b/mcs/tests/test-throw-expr-01.cs
new file mode 100644 (file)
index 0000000..e17fa42
--- /dev/null
@@ -0,0 +1,61 @@
+using System;
+
+class X
+{
+       public static void Main ()
+       {
+               Func<object> f = () => throw null;
+       }
+
+       public int Test () => throw null;
+
+       object Foo ()
+       {
+               return null;
+       }
+
+       public object Test2 () => Foo () ?? throw null;
+
+       static void Test3 (out int z) => throw null;
+
+       int this [int x] {
+               get => throw null;
+       }    
+
+       public event Action Event {
+               add => throw null; 
+               remove => throw null;
+       }
+
+       void TestExpr_1 (bool b)
+       {
+               int x = b ? throw new NullReferenceException () : 1;        
+       }
+
+       void TestExpr_2 (bool b)
+       {
+               int x = b ? 2 : throw new NullReferenceException ();
+       }
+
+       void TestExpr_3 (string s)
+       {
+               s = s ?? throw new NullReferenceException ();
+       }
+
+       void TestExpr_4 ()
+       {
+               throw new ApplicationException () ?? throw new NullReferenceException() ?? throw null;
+       }
+
+       void TestExpr_5 ()
+       {
+               Action a = () => throw new ApplicationException () ?? throw new NullReferenceException() ?? throw null;
+       }
+
+       static int TestExpr_6 (out int z) => throw null;
+
+       int TestExpr_7 (out int z)
+       {
+               return true ? throw new NullReferenceException () : 1;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-throw-expr-02.cs b/mcs/tests/test-throw-expr-02.cs
new file mode 100644 (file)
index 0000000..515d687
--- /dev/null
@@ -0,0 +1,22 @@
+using System;
+
+class Program
+{
+    public static int Main ()
+    {
+        Console.WriteLine (M (1));
+        try {
+            Console.WriteLine (M (null));
+        } catch (Exception) {
+            Console.WriteLine ("thrown");
+            return 0;
+        }
+
+        return 1;
+    }
+
+    static string M (object data)
+    {
+        return data?.ToString () ?? throw null;
+    }
+}
\ No newline at end of file
index 0ce8465a3f05977abecfd1deb58c560bb9a713cb..5b1f686ddd765817d716aebf3bdc031df02dba1f 100644 (file)
       <method name="Void Test_21()" attrs="129">
         <size>5</size>
       </method>
+      <method name="Void Test_22(Boolean)" attrs="129">
+        <size>24</size>
+      </method>
     </type>
   </test>
   <test name="gtest-410.cs">
       </method>
     </type>
   </test>
+  <test name="gtest-646.cs">
+    <type name="LocalBug`1[T]">
+      <method name="Int32 Foo(LocalBug`1[T], LocalBug`1[T])" attrs="134">
+        <size>10</size>
+      </method>
+      <method name="Int32 Foo(LocalBug`1[System.Object], LocalBug`1[T])" attrs="134">
+        <size>10</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="X">
+      <method name="Int32 Main()" attrs="150">
+        <size>64</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">
       </method>
     </type>
   </test>
+  <test name="test-943.cs">
+    <type name="MyStruct">
+      <method name="Int32 get_X()" attrs="2182">
+        <size>14</size>
+      </method>
+      <method name="Void set_X(Int32)" attrs="2182">
+        <size>8</size>
+      </method>
+    </type>
+    <type name="X">
+      <method name="Int32 Main()" attrs="150">
+        <size>44</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-944.cs">
+    <type name="Class2">
+      <method name="Void Main()" attrs="150">
+        <size>15</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-945.cs">
+    <type name="A">
+      <method name="Void Bind(System.String[])" attrs="1478">
+        <size>0</size>
+      </method>
+      <method name="Void .ctor()" attrs="6276">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="B">
+      <method name="Void Bind(System.String[])" attrs="198">
+        <size>2</size>
+      </method>
+      <method name="Int32 Main()" attrs="150">
+        <size>63</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-946.cs">
+    <type name="X">
+      <method name="Void Main()" attrs="150">
+        <size>2</size>
+      </method>
+      <method name="Int32 ImportScope(Int32)" attrs="129">
+        <size>29</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">
     </type>
     <type name="C+&lt;TestSingleAwait&gt;c__async0">
       <method name="Void MoveNext()" attrs="486">
-        <size>274</size>
+        <size>276</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="C+&lt;TestDoubleAwait&gt;c__async1">
       <method name="Void MoveNext()" attrs="486">
-        <size>419</size>
+        <size>423</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="C+&lt;TestRethrow&gt;c__async0">
       <method name="Void MoveNext()" attrs="486">
-        <size>363</size>
+        <size>367</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="Test+&lt;BreakTest&gt;c__async1">
       <method name="Void MoveNext()" attrs="486">
-        <size>903</size>
+        <size>906</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="Test+&lt;ContinueTest&gt;c__async2">
       <method name="Void MoveNext()" attrs="486">
-        <size>903</size>
+        <size>906</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="Program+&lt;Test&gt;c__async0">
       <method name="Void MoveNext()" attrs="486">
-        <size>543</size>
+        <size>545</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="Program+&lt;Test2&gt;c__async1">
       <method name="Void MoveNext()" attrs="486">
-        <size>398</size>
+        <size>400</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="Test+&lt;AsyncWithDeepTry&gt;c__async0">
       <method name="Void MoveNext()" attrs="486">
-        <size>460</size>
+        <size>463</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
       </method>
     </type>
   </test>
+  <test name="test-async-92.cs">
+    <type name="A">
+      <method name="System.Threading.Tasks.Task`1[ValueType] Test1(Int32)" attrs="134">
+        <size>33</size>
+      </method>
+      <method name="Void Main()" attrs="150">
+        <size>20</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="ValueType">
+      <method name="Void .ctor(Int32)" attrs="6278">
+        <size>2</size>
+      </method>
+    </type>
+    <type name="A+&lt;Test1&gt;c__async0">
+      <method name="Void MoveNext()" attrs="486">
+        <size>174</size>
+      </method>
+      <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+        <size>13</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-async-93.cs">
+    <type name="Test">
+      <method name="Int32 Main()" attrs="150">
+        <size>46</size>
+      </method>
+      <method name="System.Threading.Tasks.Task Entry()" attrs="129">
+        <size>41</size>
+      </method>
+      <method name="Boolean Func(Int32)" attrs="129">
+        <size>24</size>
+      </method>
+      <method name="System.Threading.Tasks.Task Nothing()" attrs="129">
+        <size>33</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+    <type name="Test+&lt;Entry&gt;c__async0">
+      <method name="Void MoveNext()" attrs="486">
+        <size>344</size>
+      </method>
+      <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+        <size>13</size>
+      </method>
+    </type>
+    <type name="Test+&lt;Nothing&gt;c__async1">
+      <method name="Void MoveNext()" attrs="486">
+        <size>61</size>
+      </method>
+      <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+        <size>13</size>
+      </method>
+    </type>
+  </test>
   <test name="test-cls-00.cs">
     <type name="CLSCLass_6">
       <method name="Void add_Disposed(Delegate)" attrs="2182">
   <test name="test-decl-expr-01.cs">
     <type name="DeclarationExpression">
       <method name="Int32 Main()" attrs="150">
-        <size>223</size>
+        <size>121</size>
       </method>
       <method name="Boolean Out(Int32 ByRef)" attrs="145">
         <size>13</size>
       <method name="Boolean Out2(Int32 ByRef, System.String)" attrs="145">
         <size>14</size>
       </method>
-      <method name="Void Out3[T](T ByRef)" attrs="145">
-        <size>17</size>
-      </method>
-      <method name="Void Ref(Int32 ByRef)" attrs="145">
-        <size>8</size>
-      </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
       </method>
     </type>
   </test>
   <test name="test-decl-expr-02.cs">
-    <type name="DeclarationExpressions">
+    <type name="C">
       <method name="Void Main()" attrs="150">
         <size>2</size>
       </method>
-      <method name="Void M2()" attrs="129">
-        <size>2</size>
+      <method name="Boolean get_Test1()" attrs="2177">
+        <size>20</size>
       </method>
-      <method name="Int32 Test(Int32)" attrs="145">
+      <method name="Int32 get_Test2()" attrs="2177">
+        <size>32</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-decl-expr-03.cs">
+    <type name="C">
+      <method name="Void Main()" attrs="150">
+        <size>153</size>
+      </method>
+      <method name="T Foo[T](T, T ByRef)" attrs="150">
+        <size>18</size>
+      </method>
+      <method name="Char &lt;Main&gt;m__0(Char)" attrs="145">
+        <size>10</size>
+      </method>
+      <method name="Char &lt;Main&gt;m__1(Char)" attrs="145">
+        <size>10</size>
+      </method>
+      <method name="Char &lt;Main&gt;m__2(Char)" attrs="145">
+        <size>10</size>
+      </method>
+      <method name="Char &lt;Main&gt;m__3(Char, Char)" attrs="145">
+        <size>10</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-decl-expr-04.cs">
+    <type name="C">
+      <method name="Void Main()" attrs="150">
         <size>16</size>
       </method>
+      <method name="Int32 Test(Int32 ByRef)" attrs="145">
+        <size>13</size>
+      </method>
+      <method name="Int32 Test2(Int32, Int32)" attrs="145">
+        <size>10</size>
+      </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
       </method>
     </type>
     <type name="X+&lt;Test&gt;c__async0">
       <method name="Void MoveNext()" attrs="486">
-        <size>281</size>
+        <size>283</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="X+&lt;TestGeneric&gt;c__async1">
       <method name="Void MoveNext()" attrs="486">
-        <size>250</size>
+        <size>252</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
     </type>
     <type name="Test+&lt;TestCapturedException&gt;c__async0">
       <method name="Void MoveNext()" attrs="486">
-        <size>491</size>
+        <size>495</size>
       </method>
       <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
         <size>13</size>
       </method>
     </type>
   </test>
+  <test name="test-expression-bodied-03.cs">
+    <type name="X">
+      <method name="Int32 get_Prop()" attrs="2182">
+        <size>9</size>
+      </method>
+      <method name="Void set_Prop(Int32)" attrs="2182">
+        <size>8</size>
+      </method>
+      <method name="Void add_A(System.Action)" attrs="2182">
+        <size>8</size>
+      </method>
+      <method name="Void remove_A(System.Action)" attrs="2182">
+        <size>8</size>
+      </method>
+      <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-externalias-01.cs">
     <type name="Test">
       <method name="Int32 Main()" attrs="150">
   <test name="test-pattern-01.cs">
     <type name="TypePattern">
       <method name="Int32 Main()" attrs="150">
-        <size>227</size>
-      </method>
-      <method name="Void .ctor()" attrs="6278">
-        <size>7</size>
-      </method>
-    </type>
-  </test>
-  <test name="test-pattern-02.cs">
-    <type name="ConstantPattern">
-      <method name="Int32 Main()" attrs="150">
-        <size>609</size>
+        <size>118</size>
       </method>
       <method name="Void .ctor()" attrs="6278">
         <size>7</size>
       </method>
-    </type>
-    <type name="&lt;PatternMatchingHelper&gt;">
-      <method name="Boolean NumberMatcher(System.Object, System.Object, Boolean)" attrs="150">
-        <size>69</size>
+      <method name="Void Test1(System.Object)" attrs="145">
+        <size>24</size>
       </method>
-    </type>
-    <type name="ConstantPattern">
-      <method name="Boolean Generic[T](T)" attrs="145">
-        <size>28</size>
+      <method name="System.String Test2(System.Object)" attrs="145">
+        <size>39</size>
       </method>
     </type>
   </test>
       </method>
     </type>
   </test>
+  <test name="test-static-using-13.cs">
+    <type name="Program">
+      <method name="Void Main(System.String[])" attrs="150">
+        <size>4</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-throw-expr-01.cs">
+    <type name="X">
+      <method name="Void Main()" attrs="150">
+        <size>32</size>
+      </method>
+      <method name="Int32 Test()" attrs="134">
+        <size>10</size>
+      </method>
+      <method name="System.Object Foo()" attrs="129">
+        <size>10</size>
+      </method>
+      <method name="System.Object Test2()" attrs="134">
+        <size>23</size>
+      </method>
+      <method name="Void Test3(Int32 ByRef)" attrs="145">
+        <size>3</size>
+      </method>
+      <method name="Int32 get_Item(Int32)" attrs="2177">
+        <size>10</size>
+      </method>
+      <method name="Void add_Event(System.Action)" attrs="2182">
+        <size>3</size>
+      </method>
+      <method name="Void remove_Event(System.Action)" attrs="2182">
+        <size>3</size>
+      </method>
+      <method name="Void TestExpr_1(Boolean)" attrs="129">
+        <size>21</size>
+      </method>
+      <method name="Void TestExpr_2(Boolean)" attrs="129">
+        <size>21</size>
+      </method>
+      <method name="Void TestExpr_3(System.String)" attrs="129">
+        <size>18</size>
+      </method>
+      <method name="Void TestExpr_4()" attrs="129">
+        <size>16</size>
+      </method>
+      <method name="Void TestExpr_5()" attrs="129">
+        <size>32</size>
+      </method>
+      <method name="System.Object &lt;Main&gt;m__0()" attrs="145">
+        <size>10</size>
+      </method>
+      <method name="Void &lt;TestExpr_5&gt;m__1()" attrs="145">
+        <size>3</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+      <method name="Int32 TestExpr_6(Int32 ByRef)" attrs="145">
+        <size>10</size>
+      </method>
+      <method name="Int32 TestExpr_7(Int32 ByRef)" attrs="129">
+        <size>15</size>
+      </method>
+    </type>
+  </test>
+  <test name="test-throw-expr-02.cs">
+    <type name="Program">
+      <method name="Int32 Main()" attrs="150">
+        <size>63</size>
+      </method>
+      <method name="System.String M(System.Object)" attrs="145">
+        <size>33</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="test-var-01.cs">
     <type name="Test">
       <method name="Int32 Main()" attrs="150">
index 4748d08ef4c423d98ebe8f42ba930c531c482877..ca9d1dfd03b379fb556aaed8632aac224e35ae95 100644 (file)
@@ -58,13 +58,6 @@ SUBDIRS = $(build_SUBDIRS) $(net_4_5_dirs)
 include ../build/rules.make
 
 DISTFILES = \
-       assemblies.xml                  \
-       mono-win32-setup-dark.bmp       \
-       mono-win32-setup-light.bmp      \
-       mono-win32-setup.nsi            \
-       scan-tests.pl                   \
-       tinderbox/smtp.c                \
-       tinderbox/tinderbox.sh          \
        removecomments.sh
 
 test-local csproj-local run-test-local run-test-ondotnet-local all-local install-local uninstall-local doc-update-local:
diff --git a/mcs/tools/assemblies.xml b/mcs/tools/assemblies.xml
deleted file mode 100644 (file)
index 9dd9652..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<assemblies>
-       <path url="C:\WINNT\Microsoft.NET\Framework\v1.0.3705">
-               <assembly file="mscorlib.dll"/>
-               <assembly file="System.Web.dll"/>
-               <assembly file="System.dll"/>
-               <assembly file="System.Drawing.dll"/>
-               <assembly file="System.Security.dll"/>
-               <assembly file="System.Windows.Forms.dll"/>
-               <assembly file="System.Xml.dll"/>
-               <assembly file="System.Data.dll"/>
-               <assembly file="System.Design.dll"/>
-               <assembly file="System.EnterpriseServices.dll"/>
-               <assembly file="System.Management.dll"/>
-               <assembly file="System.Messaging.dll"/>
-               <assembly file="System.Runtime.Remoting.dll"/>
-               <assembly file="System.ServiceProcess.dll"/>
-               <assembly file="System.Web.RegularExpressions.dll"/>
-               <assembly file="System.Web.Services.dll"/>
-               <assembly file="System.Web.Mobile.dll"/>
-       </path>
-</assemblies>
index f18fc0b60dc3c6258ddbeb30e90f0880b897db46..f80636d8747e6fdfb4f8c00929b9c44709030c54 100644 (file)
@@ -8,7 +8,7 @@
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectGuid>{FA920637-C202-4E75-AC0F-1A8DBD631DF1}</ProjectGuid>\r
     <OutputType>Exe</OutputType>\r
-    <NoWarn>1699</NoWarn>\r
+    <NoWarn>1699,1699</NoWarn>\r
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Windows_NT'">win32</HostPlatform>\r
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix' and $([System.IO.File]::Exists('/usr/lib/libc.dylib'))">darwin</HostPlatform>\r
     <HostPlatform Condition=" '$(HostPlatform)' == '' and '$(OS)' == 'Unix'">linux</HostPlatform>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
     <DebugSymbols>true</DebugSymbols>\r
     <DebugType>full</DebugType>\r
-    <NoWarn>1699</NoWarn>\r
+    <NoWarn>1699,1699</NoWarn>\r
     <Optimize>false</Optimize>\r
-    <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS</DefineConstants>\r
+    <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS</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</NoWarn>\r
+    <NoWarn>1699,1699</NoWarn>\r
     <Optimize>true</Optimize>\r
-    <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS</DefineConstants>\r
+    <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM;MULTIPLEX_OS</DefineConstants>\r
     <ErrorReport>prompt</ErrorReport>\r
     <WarningLevel>4</WarningLevel>\r
   </PropertyGroup>\r
     <Compile Include="..\..\..\external\linker\linker\Mono.Linker\LoadException.cs" />\r
     <Compile Include="..\..\..\external\linker\linker\Mono.Linker\MarkException.cs" />\r
     <Compile Include="..\..\..\external\linker\linker\Mono.Linker\MethodAction.cs" />\r
+    <Compile Include="..\..\..\external\linker\linker\Mono.Linker\MethodReferenceExtensions.cs" />\r
     <Compile Include="..\..\..\external\linker\linker\Mono.Linker\Pipeline.cs" />\r
     <Compile Include="..\..\..\external\linker\linker\Mono.Linker\TypePreserve.cs" />\r
+    <Compile Include="..\..\..\external\linker\linker\Mono.Linker\TypeReferenceExtensions.cs" />\r
     <Compile Include="..\..\..\external\linker\linker\Mono.Linker\XApiReader.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
   <ItemGroup>\r
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
-  <ItemGroup>\r
-    <EmbeddedResource Include="Descriptors/mscorlib.xml">\r
-      <LogicalName>mscorlib.xml</LogicalName>\r
-    </EmbeddedResource>\r
-    <EmbeddedResource Include="Descriptors/System.xml">\r
-      <LogicalName>System.xml</LogicalName>\r
-    </EmbeddedResource>\r
-    <EmbeddedResource Include="Descriptors/System.Core.xml">\r
-      <LogicalName>System.Core.xml</LogicalName>\r
-    </EmbeddedResource>\r
-    <EmbeddedResource Include="Descriptors/System.Drawing.xml">\r
-      <LogicalName>System.Drawing.xml</LogicalName>\r
-    </EmbeddedResource>\r
-    <EmbeddedResource Include="Descriptors/System.Web.xml">\r
-      <LogicalName>System.Web.xml</LogicalName>\r
-    </EmbeddedResource>\r
-    <EmbeddedResource Include="Descriptors/Mono.Posix.xml">\r
-      <LogicalName>Mono.Posix.xml</LogicalName>\r
-    </EmbeddedResource>\r
-  </ItemGroup>\r
 </Project>\r
 
index a76e9f88c92a1440897c007e92937f4d16b89311..4febb86c32014b1ea38858496f77a55cf301bbe2 100755 (executable)
@@ -1110,6 +1110,14 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                }
 
                if (error != null) {
+                       Console.Error.WriteLine ("Failure to load i18n assemblies, the following directories were searched for the assemblies:");
+                       foreach (var path in link_paths){
+                               Console.Error.WriteLine ("   Path: " + path);
+                       }
+                       if (custom_mode){
+                               Console.WriteLine ("In Custom mode, you need to provide the directory to lookup assemblies from using -L");
+                       }
+                       
                        Error ("Couldn't load one or more of the i18n assemblies: " + error);
                        Environment.Exit (1);
                }
@@ -1118,10 +1126,10 @@ 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> ();
-       static readonly string resourcePathSeparator = (Path.DirectorySeparatorChar == '\\') ? $"\\{Path.DirectorySeparatorChar}" : $"{Path.DirectorySeparatorChar}";
 
        public static string GetAssemblyName (string path)
        {
+               string resourcePathSeparator = style == "windows" ? "\\\\" : "/";
                string name = Path.GetFileName (path);
 
                // A bit of a hack to support satellite assemblies. They all share the same name but
@@ -1183,7 +1191,12 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                Assembly a = null;
                
                try {
+                       if (!quiet)
+                               Console.WriteLine ("Attempting to load assembly: {0}", assembly);
                        a = universe.LoadFile (assembly);
+                       if (!quiet)
+                               Console.WriteLine ("Assembly {0} loaded successfully.", assembly);
+                       
                } catch (FileNotFoundException){
                        Error ($"Cannot find assembly `{assembly}'");
                } catch (IKVM.Reflection.BadImageFormatException f) {
@@ -1206,6 +1219,8 @@ void          mono_register_config_for_assembly (const char* assembly_name, cons
                string total_log = "";
                foreach (string dir in link_paths){
                        string full_path = Path.Combine (dir, assembly);
+                       if (!quiet)
+                               Console.WriteLine ("Attempting to load assembly from: " + full_path);
                        if (!assembly.EndsWith (".dll") && !assembly.EndsWith (".exe"))
                                full_path += ".dll";
                        
diff --git a/mcs/tools/mono-win32-setup-dark.bmp b/mcs/tools/mono-win32-setup-dark.bmp
deleted file mode 100755 (executable)
index d54f6a3..0000000
Binary files a/mcs/tools/mono-win32-setup-dark.bmp and /dev/null differ
diff --git a/mcs/tools/mono-win32-setup-light.bmp b/mcs/tools/mono-win32-setup-light.bmp
deleted file mode 100755 (executable)
index df4aec1..0000000
Binary files a/mcs/tools/mono-win32-setup-light.bmp and /dev/null differ
diff --git a/mcs/tools/mono-win32-setup.nsi b/mcs/tools/mono-win32-setup.nsi
deleted file mode 100755 (executable)
index d4dc171..0000000
+++ /dev/null
@@ -1,708 +0,0 @@
-; =====================================================\r
-; mono.nsi - Mono Setup wizard for windows\r
-; =====================================================\r
-;\r
-; (C) Copyright 2003 by Johannes Roith\r
-; (C) Copyright 2003 by Daniel Morgan\r
-;\r
-; Authors: \r
-;       Johannes Roith <johannes@jroith.de>\r
-;       Daniel Morgan <danmorg@sc.rr.com>\r
-;\r
-; This .nsi includes code from the NSIS Archives:\r
-; function StrReplace and VersionCheck \r
-; by Hendri Adriaens\r
-; HendriAdriaens@hotmail.com\r
-; \r
-; =====================================================\r
-;\r
-; This script can build a binary setup wizard of mono.\r
-; It is released under the GNU GPL.\r
-;\r
-; =====================================================\r
-; SET MILESTONE & SOURCE DIR\r
-; =====================================================\r
-;\r
-;\r
-  !define MILESTONE "0.24" ;\r
-  !define SOURCE_INSTALL_DIR "c:\mono-0.23-setup\install\\*" ;\r
-\r
-; =====================================================\r
-; SET LOGO\r
-; =====================================================\r
-;\r
-;  Beautification:\r
-;\r
-;  This adds a Mono-specific Image on the left\r
-;  You can choose between the light or dark one.\r
-;  \r
-;  If you wish no mono-specifi logo, please outcomment\r
-;  the lines.\r
-;  \r
-;  "light" is enabled.\r
-;\r
-;  !define MUI_SPECIALBITMAP "mono-win32-setup-dark.bmp"\r
-   !define MUI_SPECIALBITMAP "mono-win32-setup-light.bmp"\r
-\r
-; =====================================================\r
-; BUILDING\r
-; =====================================================\r
-;\r
-; 1. Build mono. The install directory must not contain\r
-;    anything else - everything gets packed in!!!\r
-;\r
-; 2. In your install directory, delete the *.a files.\r
-;     Most people won't need them and it saves ~ 4 MB.\r
-;\r
-; 3. Get latest nsis from cvs or a development snapshot\r
-;    from http://nsis.sf.net\r
-;\r
-; 4. Adapt the MILESTONE\r
-;\r
-; 5. Adapt the SOURCE_INSTALL_DIR above to match your \r
-;     install directory. Do not remove \\* at the end!!\r
-;\r
-; 6. Open this script in makensisw.exe\r
-;\r
-; 7. The output file is mono-[MILESTONE]-win32-1.exe\r
-;\r
-;\r
-;\r
-;\r
-;\r
-; =====================================================\r
-; MONO & REGISTRY / DETECTING MONO\r
-; =====================================================\r
-;\r
-;\r
-; This setup creates several Registry Keys:\r
-;\r
-; HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR\r
-; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} SdkInstallRoot\r
-; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} FrameworkAssemblyDirectory\r
-; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} MonoConfigDir\r
-;\r
-; =====================================================\r
-;\r
-; To get the current Mono Install Directory:\r
-;\r
-; 1. Get DefaultCLR\r
-; 2. Get HKEY_LOCAL_MACHINE SOFTWARE\Mono\$THE_DEFAULT_CLR_VALUE SdkInstallRoot\r
-;\r
-; =====================================================\r
-;\r
-; To get the current Mono assembly Directory:\r
-;\r
-; 1. Get DefaultCLR\r
-; 2. Get HKEY_LOCAL_MACHINE SOFTWARE\Mono\$THE_DEFAULT_CLR_VALUE FrameworkAssemblyDirectory\r
-; \r
-; =====================================================\r
-; Do not edit below\r
-; =====================================================\r
-;\r
-;\r
-; =====================================================\r
-; GENERAL SETTING - NEED NOT TO BE CHANGED\r
-; =====================================================\r
-\r
- !define NAME "Mono" ;\r
- !define TARGET_INSTALL_DIR "$PROGRAMFILES\Mono-${MILESTONE}" ;\r
- !define OUTFILE "mono-${MILESTONE}-win32-1.exe" ;\r
-\r
-; =====================================================\r
-; SCRIPT\r
-; =====================================================\r
-\r
- !define MUI_PRODUCT "${NAME}"\r
- !define MUI_VERSION "${MILESTONE}"\r
- !define FULLNAME "${MUI_PRODUCT} ${MUI_VERSION}"\r
- !define MUI_UI "${NSISDIR}\Contrib\UIs\modern2.exe"\r
- !define MUI_ICON "${NSISDIR}\Contrib\Icons\setup.ico"\r
- !define MUI_UNICON "${NSISDIR}\Contrib\Icons\normal-uninstall.ico"\r
- !define MUI_WELCOMEPAGE\r
- !define MUI_DIRECTORYPAGE\r
- !define MUI_DIRECTORYSELECTIONPAGE\r
- !include "${NSISDIR}\Contrib\Modern UI\System.nsh"\r
- !insertmacro MUI_SYSTEM\r
- !insertmacro MUI_LANGUAGE "ENGLISH"\r
-\r
-\r
- OutFile "${OUTFILE}"\r
- InstallDir "${TARGET_INSTALL_DIR}"\r
-\r
-\r
-;========================\r
-; Uninstaller\r
-;========================\r
-\r
-Section "Uninstall"\r
-\r
-  MessageBox MB_YESNO "Are you sure you want to uninstall Mono from your system?" IDNO NoUnInstall\r
-\r
-  Delete $INSTDIR\Uninst.exe ; delete Uninstaller\r
-  DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} ; Remove Entry in Software List\r
-\r
-  MessageBox MB_YESNO "Mono was installed into $INSTDIR. Should this directory be removed completly?" IDNO GoNext1\r
-  RMDir /r $INSTDIR\r
-  GoNext1:\r
-\r
-  DeleteRegKey HKLM SOFTWARE\Mono\${MILESTONE}\r
-\r
-  ; If the Default-Key is the current Milestone, we just remove the wrappers\r
-\r
-  ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono\ DefaultCLR\r
-  StrCmp $0 ${MILESTONE} DeleteWrappers\r
-\r
-  MessageBox MB_YESNO "Mono ${MILESTONE} has been removed, but the default installation of Mono differs form this version. Should the wrappers and the Mono registry key be still be removed? This could disable other Mono installations." IDNO GoNext2\r
-\r
-  DeleteWrappers:\r
-\r
-  ; Complete Uninstall\r
-\r
-  DeleteRegKey HKLM SOFTWARE\Mono\r
-  Delete $WINDIR\monobasepath.bat\r
-  Delete $WINDIR\mcs.bat\r
-  Delete $WINDIR\mbas.bat\r
-  Delete $WINDIR\mint.bat\r
-  Delete $WINDIR\mono.bat\r
-  Delete $WINDIR\monodis.bat\r
-  Delete $WINDIR\monoilasm.bat\r
-  Delete $WINDIR\sqlsharp.bat\r
-  Delete $WINDIR\secutil.bat\r
-  Delete $WINDIR\cert2spc.bat\r
-  Delete $WINDIR\monoresgen.bat\r
-  Delete $WINDIR\monosn.bat\r
-  Delete $WINDIR\cilc.bat\r
-\r
-  GoNext2:\r
-  NoUnInstall:\r
-\r
-SectionEnd\r
-\r
-\r
- Section\r
-\r
- ; Warn people if a newer Mono is already installed\r
-\r
- ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono\ DefaultCLR\r
- Push $0\r
- Push ${MILESTONE} \r
- Call VersionCheck\r
- Pop $0\r
- StrCmp $0 0 NoAskInstall\r
- StrCmp $0 2 NoAskInstall\r
- MessageBox MB_YESNO "A newer Mono version is already installed. Still continue?" IDNO NoInstall\r
-\r
- NoAskInstall:\r
-\r
- SetOutPath $INSTDIR\r
- File /r "${SOURCE_INSTALL_DIR}"\r
- WriteUninstaller Uninst.exe\r
-\r
- WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} SdkInstallRoot $INSTDIR\r
- WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} FrameworkAssemblyDirectory $INSTDIR\lib\r
- WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} MonoConfigDir $INSTDIR\etc\mono\r
- ;WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} GtkSharpLibPath $INSTDIR\lib\r
- WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR ${MILESTONE}\r
-\r
- ; Mono Uninstall Entry in Windows Software List in the Control panel\r
- WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} DisplayName "Mono ${MILESTONE}"\r
- WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} UninstallString $INSTDIR\uninst.exe\r
-\r
- ;original string is like C:\mono-0.20\install\r
- StrCpy $5 $INSTDIR \r
- Push $5\r
- Push "\" ;search for this string\r
- Push "/" ;replace with this string\r
- Call StrReplace\r
- ;resulting string which is like C:/mono-0.20/install\r
- Pop $6\r
-\r
-;========================\r
-; Write the wrapper files\r
-;========================\r
-\r
-; create bin/mono wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\mono.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/mint wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\mint.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mint.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/mcs wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\mcs.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/mcs.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/mbas wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\mbas.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/mbas.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/sqlsharp wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\sqlsharp.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/sqlsharp.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/monodis wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\monodis.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/monodis.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/monoresgen wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\monoresgen.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/monoresgen.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/monoilasm wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\monoilasm.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/monoilasm.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/monosn wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\monosn.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/monosn.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/secutil wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\secutil.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/secutil.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/cert2spc wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\cert2spc.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/cert2spc.exe "$$@"'\r
-FileClose $0\r
-\r
-; create bin/cilc wrapper to be used if the user has cygwin\r
-FileOpen $0 "$INSTDIR\bin\cilc.exe.sh" "w"\r
-FileWrite $0 "#!/bin/sh$\r$\n"\r
-FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"\r
-FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"\r
-FileWrite $0 '$6/bin/mono.exe $6/bin/cilc.exe "$$@"'\r
-FileClose $0\r
-\r
-;\r
-; These wrappers are copied to the windows directory.\r
-;\r
-\r
-;========================\r
-; Write the path file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\monobasepath.bat" "w"\r
-FileWrite $0 'set MONO_BASEPATH="$INSTDIR"$\r$\n'\r
-FileWrite $0 'set MONO_PATH=$INSTDIR\lib$\r$\n'\r
-FileWrite $0 'set MONO_CFG_DIR="$INSTDIR\etc\mono"'\r
-FileClose $0\r
-\r
-\r
-;========================\r
-; Write the mcs file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\mcs.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\mcs.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the mbas file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\mbas.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\mbas.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the mint file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\mint.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mint.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the mono file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\mono.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-FileClose $0\r
-\r
-;========================\r
-; Write monodis\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\monodis.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\monodis.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write monoilasm\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\monoilasm.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\monoilasm.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-\r
-;========================\r
-; Write the sqlsharp file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\sqlsharp.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\sqlsharp.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the secutil file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\secutil.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\secutil.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the cert2spc file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\cert2spc.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\cert2spec.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-\r
-;========================\r
-; Write the monoresgen file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\monoresgen.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\monoresgen.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the monosn file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\monosn.bat" "w"\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\monosn.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-;========================\r
-; Write the cilc file\r
-;========================\r
-\r
-FileOpen $0 "$WINDIR\cilc.bat" "w"\r
-\r
-\r
-FileWrite $0 "@echo off$\r$\n"\r
-FileWrite $0 "call monobasepath.bat$\r$\n"\r
-FileWrite $0 "set MONOARGS=$\r$\n"\r
-FileWrite $0 ":loop$\r$\n"\r
-FileWrite $0 "if x%1 == x goto :done$\r$\n"\r
-FileWrite $0 "set MONOARGS=%MONOARGS% %1$\r$\n"\r
-FileWrite $0 "shift$\r$\n"\r
-FileWrite $0 "goto loop$\r$\n"\r
-FileWrite $0 ":done$\r$\n"\r
-FileWrite $0 "setlocal$\r$\n"\r
-FileWrite $0 'set path="$INSTDIR\bin\;$INSTDIR\lib\;%path%"$\r$\n'\r
-FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\bin\cilc.exe" %MONOARGS%$\r$\n'\r
-FileWrite $0 "endlocal$\r$\n"\r
-\r
-FileClose $0\r
-\r
-NoInstall:\r
-SectionEnd\r
-\r
-; function StrReplace\r
-; by Hendri Adriaens\r
-; HendriAdriaens@hotmail.com\r
-; found in the NSIS Archives\r
-function StrReplace\r
-  Exch $0 ;this will replace wrong characters\r
-  Exch\r
-  Exch $1 ;needs to be replaced\r
-  Exch\r
-  Exch 2\r
-  Exch $2 ;the orginal string\r
-  Push $3 ;counter\r
-  Push $4 ;temp character\r
-  Push $5 ;temp string\r
-  Push $6 ;length of string that need to be replaced\r
-  Push $7 ;length of string that will replace\r
-  Push $R0 ;tempstring\r
-  Push $R1 ;tempstring\r
-  Push $R2 ;tempstring\r
-  StrCpy $3 "-1"\r
-  StrCpy $5 ""\r
-  StrLen $6 $1\r
-  StrLen $7 $0\r
-  Loop:\r
-  IntOp $3 $3 + 1\r
-  StrCpy $4 $2 $6 $3\r
-  StrCmp $4 "" ExitLoop\r
-  StrCmp $4 $1 Replace\r
-  Goto Loop\r
-  Replace:\r
-  StrCpy $R0 $2 $3\r
-  IntOp $R2 $3 + $6\r
-  StrCpy $R1 $2 "" $R2\r
-  StrCpy $2 $R0$0$R1\r
-  IntOp $3 $3 + $7\r
-  Goto Loop\r
-  ExitLoop:\r
-  StrCpy $0 $2\r
-  Pop $R2\r
-  Pop $R1\r
-  Pop $R0\r
-  Pop $7\r
-  Pop $6\r
-  Pop $5\r
-  Pop $4\r
-  Pop $3\r
-  Pop $2\r
-  Pop $1\r
-  Exch $0\r
-FunctionEnd\r
-\r
-Function VersionCheck\r
-  Exch $0 ;second versionnumber\r
-  Exch\r
-  Exch $1 ;first versionnumber\r
-  Push $R0 ;counter for $0\r
-  Push $R1 ;counter for $1\r
-  Push $3 ;temp char\r
-  Push $4 ;temp string for $0\r
-  Push $5 ;temp string for $1\r
-  StrCpy $R0 "-1"\r
-  StrCpy $R1 "-1"\r
-  Start:\r
-  StrCpy $4 ""\r
-  DotLoop0:\r
-  IntOp $R0 $R0 + 1\r
-  StrCpy $3 $0 1 $R0\r
-  StrCmp $3 "" DotFound0\r
-  StrCmp $3 "." DotFound0\r
-  StrCpy $4 $4$3\r
-  Goto DotLoop0\r
-  DotFound0:\r
-  StrCpy $5 ""\r
-  DotLoop1:\r
-  IntOp $R1 $R1 + 1\r
-  StrCpy $3 $1 1 $R1\r
-  StrCmp $3 "" DotFound1\r
-  StrCmp $3 "." DotFound1\r
-  StrCpy $5 $5$3\r
-  Goto DotLoop1\r
-  DotFound1:\r
-  Strcmp $4 "" 0 Not4\r
-    StrCmp $5 "" Equal\r
-    Goto Ver2Less\r
-  Not4:\r
-  StrCmp $5 "" Ver2More\r
-  IntCmp $4 $5 Start Ver2Less Ver2More\r
-  Equal:\r
-  StrCpy $0 "0"\r
-  Goto Finish\r
-  Ver2Less:\r
-  StrCpy $0 "1"\r
-  Goto Finish\r
-  Ver2More:\r
-  StrCpy $0 "2"\r
-  Finish:\r
-  Pop $5\r
-  Pop $4\r
-  Pop $3\r
-  Pop $R1\r
-  Pop $R0\r
-  Pop $1\r
-  Exch $0\r
-FunctionEnd
\ No newline at end of file
diff --git a/mcs/tools/scan-tests.pl b/mcs/tools/scan-tests.pl
deleted file mode 100755 (executable)
index 5cb0f86..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use Carp;
-
-my @allfiles;
-
-my @badsuites = qw[System\.Collections/HashtableTest System\.Collections/StackTest System\.Collections\.Specialized\.BasicOperationsTest];
-my @badtests = qw[PathTest:TestGetTempFileName XmlTextReaderTests:TestIsNameChar XmlTextReaderTests:TestIsFirstNameChar ByteTest:TestParse];
-my @mapfiles = ('s,^MonoTests\.(.*)/,$1/,',
-               's,^Ximian\.Mono\.Tests(.*)/,,',
-               's,^System\.Net/,,',
-               's,^Collections\.Specialized\.,,',
-               's,^Text\.RegularExpressions\.,,'
-               );
-my @maptests = ();
-my @mapnamespace = ();
-
-die "Usage: $0 input output" unless $#ARGV == 1;
-
-my $namespace = 'MonoTests';
-
-sub parse_test {
-    my ($filename, $namespace, $testname, $suite) = @_;
-
-    foreach (@badsuites) {
-       return if $filename =~ /$_/;
-    }
-
-    my $map;
-    foreach $map (@mapfiles) {
-       eval "\$filename =~ $map";
-    }
-
-    foreach (@allfiles) {
-       return if $filename eq $_->[0];
-    }
-
-    # print STDERR "PARSE: |$filename|\n";
-
-    push @allfiles, [$filename,$namespace,$testname,$suite,[]];
-
-    my $INPUT;
-    open $INPUT, $filename or croak "open ($filename): $!";
-    while (defined ($_ = <$INPUT>)) {
-       if (/^\s*namespace\s*([\w\.]+?)\s*$/) {
-           $namespace = $1;
-           next;
-       }
-       if (/^\s*suite\.AddTest\s*\((.*)\.(.*?)\.Suite\)/) {
-           my $filename = (defined $namespace) ? qq[$namespace.$1/$2.cs] : qq[$1/$2.cs];
-           my $nsprefix = (defined $namespace) ? qq[$namespace.$1] : qq[MonoTests.$1];
-           parse_test ($filename, $nsprefix, $1, $2);
-           next;
-       }
-       if (/^\s*suite\.AddTest\s*\((.*?)\.Suite\)/) {
-           my $filename = (defined $namespace) ? qq[$namespace/$1.cs] : qq[$1.cs];
-           parse_test ($filename, $namespace, '', $1);
-           next;
-       }
-       if (/^\s*suite\.AddTest\s*\(\s*new\s+TestSuite\s*\(\s*typeof\(\s*(.*)\s*\)\s*\)\s*\);/) {
-           my $filename = (defined $namespace) ? qq[$namespace/$1.cs] : qq[$1.cs];
-           parse_test ($filename, $namespace, '', $1);
-           next;
-       }
-    }
-    close $INPUT;
-}
-
-parse_test ($ARGV[0], undef, '', '');
-
-my $file;
-foreach $file (@allfiles) {
-    my ($filename,$namespace,$testname,$suite) = @$file;
-
-    open SUITE, $filename or croak "open ($filename): $!";
-    while (defined ($_ = <SUITE>)) {
-       next unless /^\s*public\s+void\s+(Test.*?)\s*\(\s*\)/;
-       push @{$file->[4]}, $1;
-    }
-    close SUITE;
-}
-
-open OUTPUT, "> $ARGV[1]" or croak "open (> $ARGV[1]): $!";
-select OUTPUT;
-
-print qq[using NUnit.Framework;\n];
-print qq[using System;\n];
-print qq[using System.Threading;\n];
-print qq[using System.Globalization;\n\n];
-
-
-my $alltest;
-foreach $alltest (@allfiles) {
-
-    my ($filename,$namespace,$testname,$suite,$tests) = @$alltest;
-    my @tests = @$tests;
-
-    next unless defined $namespace;
-    next unless $#tests >= 0;
-
-    # print STDERR "DOING TEST: |$testname|$filename|\n";
-
-    $namespace .= ".$testname" unless $testname eq '';
-
-    print qq[namespace $namespace\n\{\n];
-    print qq[\tpublic class Run$suite : $suite\n\t\{\n];
-    print qq[\t\tprotected override void RunTest ()\n\t\t\{\n];
-#    print qq[\t\t\tbool errorThrown = false;\n\n];
-    my $test;
-  testloop:
-    foreach $test (@tests) {
-       my $badtest;
-       $filename =~ s/\.cs$//;
-       my $fullname = qq[$filename:$test];
-       # print STDERR "TEST: |$fullname|\n";
-       foreach $badtest (@badtests) {
-           next testloop if $fullname =~ /$badtest/;
-       }
-#      print qq[\t\t\ttry \{\n\t\t\t\t$test ();\n\t\t\t\} catch \{\n];
-#      print qq[\t\t\t\tConsole.WriteLine ("$namespace:$suite:$test failed");\n];
-#      print qq[\t\t\t\terrorThrown = true;\n];
-#      print qq[\t\t\t\}\n];
-       print qq[\t\t\t$test ();\n];
-#      print qq[\t\t\tConsole.WriteLine ("$namespace:$suite:$test DONE");\n];
-    }
-    print qq[\n];
-#    print qq[\t\t\tif (errorThrown)\n\t\t\t\tthrow new ArgumentException ();\n];
-    print qq[\t\t\}\n\t\}\n];
-    print qq[\}\n\n];
-}
-
-print qq[namespace $namespace\n\{\n];
-print qq[\tpublic class RunAllTests\n\t\{\n];
-print qq[\t\tpublic static void AddAllTests (TestSuite suite)\n];
-print qq[\t\t\{\n];
-
-foreach $alltest (@allfiles) {
-    my ($filename,$namespace,$testname,$suite,$tests) = @$alltest;
-    my @tests = @$tests;
-
-    next unless defined $namespace;
-    next unless $#tests >= 0;
-
-    $namespace .= ".$testname" unless $testname eq '';
-
-    print qq[\t\t\tsuite.AddTest (new $namespace.Run$suite ());\n];
-}
-
-print qq[\t\t\}\n\t\}\n\}\n\n];
-
-print qq[class MainApp\n\{\n];
-print qq[\tpublic static void Main()\n\t\{\n];
-print qq[\t\tThread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");\n\n];
-print qq[\t\tTestResult result = new TestResult ();\n];
-print qq[\t\tTestSuite suite = new TestSuite ();\n];
-print qq[\t\t$namespace.RunAllTests.AddAllTests (suite);\n];
-print qq[\t\tsuite.Run (result);\n];
-print qq[\t\tMonoTests.MyTestRunner.Print (result);\n];
-print qq[\t\}\n\}\n\n];
-
-close OUTPUT;
-
diff --git a/mcs/tools/security/security.proj b/mcs/tools/security/security.proj
deleted file mode 100644 (file)
index 33d6c52..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <PropertyGroup>\r
-    <OutputType>Exe</OutputType>\r
-    <AssemblyName>sn</AssemblyName>\r
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
-    <ResponseFile>sn.exe.sources</ResponseFile>\r
-    <CodePage>65001</CodePage>\r
-    <OutputPath>..\..\class\lib\basic\</OutputPath>\r
-    <UseVSHostingProcess>false</UseVSHostingProcess>\r
-  </PropertyGroup>\r
-  <Import Project="$(MSBuildProjectDirectory)\..\..\build\msbuild\Mono.Common.targets"/>\r
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
-  <Target Name="Build" >\r
-     <Csc \r
-       CodePage="65001" \r
-       DefineConstants="BOOTSTRAP_BASIC,NET_1_1,NET_2_0"\r
-       OutputAssembly="..\..\class\lib\basic\sn.exe"\r
-       Sources="sn.cs;StrongNameManager.cs;AssemblyInfo.cs;..\..\build\common\Consts.cs"\r
-       References="..\..\class\lib\basic\Mono.Security.dll"\r
-        />\r
-  </Target>\r
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'basic|AnyCPU' ">\r
-    <Csc/>\r
-    <DefineConstants>BOOTSTRAP_BASIC,NET_1_1,NET_2_0</DefineConstants>\r
-  </PropertyGroup>\r
-\r
-</Project>
\ No newline at end of file
diff --git a/mcs/tools/tinderbox/smtp.c b/mcs/tools/tinderbox/smtp.c
deleted file mode 100644 (file)
index a4f0b03..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-// simple tool for sending smtp messages
-//
-//
-#include <stdio.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <string.h>
-#include <netdb.h>
-
-#include <unistd.h>
-#include <stdlib.h>
-#define _GNU_SOURCE
-#include <getopt.h>
-#include <ctype.h>
-#include <time.h>
-
-typedef int bool;
-enum { false = 0, true = 1};
-
-struct option rgOptions [] =
-{
-       {"cc",      required_argument,  NULL, 'c'},
-       {"help",    required_argument,  NULL, '?'},
-       {"to",      required_argument,  NULL, 't'},
-       {"from",    required_argument,  NULL, 'f'},
-       {"message", required_argument,  NULL, 'm'},
-       {"subject", required_argument,  NULL, 's'},
-       {"host",    required_argument,  NULL, 'h'},
-       {"attach",  required_argument,  NULL, 'a'},
-};
-
-typedef struct MailFields
-{
-       const char *szTo;
-       const char *szFrom;
-       const char *szHost;
-       const char *szSubject;
-       bool fAttachments;
-       bool fCC;
-       int cArgs;
-       char **rgszArgs;
-       FILE *pfMsg;
-} MailFields;
-
-const char *szOptions = "t:f:s:h:c:a:m:?";
-
-void help ()
-{
-       printf (
-               "Usage: smtp [OPTIONS]\n\n"
-               "Mandatory arguments:\n"
-               "\t-t, --to ADDRESS\tspecify destination email address\n"
-               "\t-f, --from ADDRESS\tspecify sender's email address\n"
-               "Optional arguments:\n"
-               "\t-s, --subject SUBJECT\tspecify subject of message\n"
-               "\t-m, --message FILENAME\tread text of message from FILENAME\n"
-               "\t-a, --attach FILENAME\tadd FILENAME to message as attachment\n"
-               "\t-c, --cc ADDRESS\tadd ADDRESS to CC list\n"
-               "\t-h, --host HOSTNAME\tconnect to smpt server HOSTNAME (default: localhost)\n"
-       );
-}
-
-int GetResponse (FILE *ps)
-{
-       char szLine [1024];
-       char *psz;
-       int hr;
-
-       fflush (ps);
-
-       do
-       {
-               fgets (szLine, sizeof (szLine), ps);
-
-               for (psz = szLine; isdigit (*psz); psz++)
-                       ;
-       }
-       while (*psz != '\0' && *psz != ' ');
-
-       hr = atol (szLine);
-       return hr;
-}
-
-FILE *TcpOpen (const char *szHost, int nPort)
-{
-       int s;
-       struct sockaddr_in sa;
-       struct hostent *he;
-       struct protoent *pe;
-       FILE *ps;
-
-       pe = getprotobyname ("TCP");
-       s = socket (PF_INET, SOCK_STREAM, pe->p_proto);
-       endprotoent ();
-
-       bzero ((char *)&sa,sizeof (sa));
-       sa.sin_family = AF_INET;
-       sa.sin_addr.s_addr = inet_addr (szHost);
-       sa.sin_port = htons (25);
-
-       if ((he = gethostbyname (szHost)) != NULL)
-               bcopy (he->h_addr, (char *)&sa.sin_addr, he->h_length);
-       else if ((sa.sin_addr.s_addr = inet_addr (szHost)) < 0)
-               perror ("gethostbyname ()");
-
-       if (connect (s, (struct sockaddr *) &sa, 16) == -1)
-               perror ("connect ()");
-       else if ((ps = fdopen (s, "r+")) == NULL)
-               perror ("fdopen ()");
-       else
-               return ps;
-
-       close (s);
-       return NULL;
-}
-
-
-void SendMail (const char *szTo, const MailFields *pmf)
-{
-       char rgchBoundary [20];
-       FILE *ps;
-       int hr;
-
-       ps = TcpOpen (pmf->szHost, 25);
-
-       hr = GetResponse (ps);
-
-       fprintf (ps, "HELO\r\n");
-       hr = GetResponse (ps);
-
-       fprintf (ps, "MAIL FROM: %s\r\n", pmf->szFrom);
-       hr = GetResponse (ps);
-
-       fprintf (ps, "RCPT TO: %s\r\n", szTo);
-       hr = GetResponse (ps);
-
-       fprintf (ps, "DATA %s\r\n", pmf->szSubject);
-       hr = GetResponse (ps);
-
-       fprintf (ps, "From: %s\r\nTo: %s\r\nSubject: %s\r\n", pmf->szFrom, pmf->szTo, pmf->szSubject);
-
-       if (pmf->fCC)
-       {
-               bool fFirst = true;
-               int nOpt, iOpt;
-               fprintf (ps, "CC:");
-               optind = 0;
-               while ((nOpt = getopt_long (pmf->cArgs, pmf->rgszArgs, szOptions, rgOptions, &iOpt)) != -1)
-               {
-                       if (nOpt == 'c')
-                       {
-                               if (!fFirst)
-                                       fprintf (ps, ";");
-                               fprintf (ps, " %s", optarg);
-                               fFirst = false;
-                       }
-               }
-               fprintf (ps, "\r\n");
-       }
-
-       if (pmf->fAttachments)
-       {
-               int ich;
-               srand ((int) time (NULL));
-               for (ich = 0; ich < sizeof (rgchBoundary) - 1; ich ++)
-                       rgchBoundary [ich] = rand () % ('Z'-'A') + 'A';
-               rgchBoundary [ich] = '\0';
-
-               fprintf (ps, 
-                       "MIME-Version: 1.0\r\n"
-                       "Content-Type: multipart/mixed; boundary=\"multipart-%s\"\r\n\r\n", rgchBoundary);
-
-               fprintf (ps, "--multipart-%s\r\n\r\n", rgchBoundary);
-       }
-
-       if (pmf->pfMsg != NULL)
-       {
-               rewind (pmf->pfMsg);
-               while (!feof (pmf->pfMsg))
-               {
-                       char strLine [1024];
-                       int cch;
-
-                       fgets (strLine, sizeof (strLine), pmf->pfMsg);
-                       cch = strlen (strLine);
-                       while (strLine [cch - 1] == '\r' || strLine [cch - 1] == '\n')
-                               cch --;
-                       strLine [cch] = '\0';
-
-                       if (cch == 1 && strLine [0] == '.')
-                               fputc ('.', ps);
-
-                       fprintf (ps, "%s\r\n", strLine);
-                       fflush (ps);
-               }
-       }
-
-       if (pmf->fAttachments)
-       {
-               int nOpt, iOpt;
-               optind = 0;
-               while ((nOpt = getopt_long (pmf->cArgs, pmf->rgszArgs, szOptions, rgOptions, &iOpt)) != -1)
-               {
-                       if (nOpt == 'a')
-                       {
-                               const char rgchBase64 [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-                               FILE *pf = fopen (optarg, "r");
-                               int cch = 0;
-
-                               const char *szBasename = (char *) strrchr ((const char *) optarg, '/');
-                               if (szBasename == NULL || szBasename [1] == '\0')
-                                       szBasename = optarg;
-                               else
-                                       szBasename ++;
-
-                               fprintf (ps, "--multipart-%s\r\nContent-Type: text/plain; name=\"%s\"\r\nContent-Disposition: attachment; name=\"%s\"\r\nContent-Transfer-Encoding: base64\r\n\r\n", rgchBoundary, szBasename, szBasename);
-
-                               while (true)
-                               {
-                                       int ch1, ch2, ch3;
-                                       if ((ch1 = fgetc (pf)) == -1)
-                                               break;
-
-                                       fputc (rgchBase64 [ch1 >> 2], ps);
-
-                                       if ((ch2 = fgetc (pf)) == -1)
-                                       {
-                                               fputc (rgchBase64 [(ch1 << 4) & 0x30], ps);
-                                               fputc ('=', ps);
-                                               fputc ('=', ps);
-                                               break;
-                                       }
-
-                                       fputc (rgchBase64 [(ch2 >> 4) | ((ch1 << 4) & 0x30)], ps);
-
-                                       if ((ch3 = fgetc (pf)) == -1)
-                                       {
-                                               fputc (rgchBase64 [(ch2 << 2) & 0x3c], ps);
-                                               fputc ('=', ps);
-                                               break;
-                                       }
-
-                                       fputc (rgchBase64 [((ch2 << 2) & 0x3c) | (ch3 >> 6)], ps);
-                                       fputc (rgchBase64 [ch3 & 0x3f], ps);
-                                       
-                                       cch += 4;
-                                       if (cch >= 76)
-                                               fprintf (ps, "\r\n");
-                               }
-                               fclose (pf);
-                               fprintf (ps, "\r\n\r\n");
-                       }
-               }
-       }
-
-       fprintf (ps, "\r\n.\r\nQUIT\r\n");
-       hr = GetResponse (ps);
-
-       fclose (ps);
-}
-
-int main (int cArgs, char *rgszArgs [])
-{
-       int nOpt, iOpt = 0;
-       MailFields mf;
-       bzero ((char *) &mf, sizeof (mf));
-       mf.cArgs = cArgs;
-       mf.rgszArgs = rgszArgs;
-
-       while ((nOpt = getopt_long (cArgs, rgszArgs, szOptions, rgOptions, &iOpt)) != -1)
-       {
-               switch (nOpt)
-               {
-                       case 't':
-                               if (mf.szTo != NULL)
-                                       goto _default;
-                               mf.szTo = optarg;
-                               break;
-                       case 'f':
-                               if (mf.szFrom != NULL)
-                                       goto _default;
-                               mf.szFrom = optarg;
-                               break;
-                       case 's':
-                               if (mf.szSubject != NULL)
-                                       goto _default;
-                               mf.szSubject = optarg;
-                               break;
-                       case 'h':
-                               if (mf.szHost != NULL)
-                                       goto _default;
-                               mf.szHost = optarg;
-                               break;
-                       case 'c':
-                               mf.fCC = true;
-                               break;
-                       case 'a':
-                               {
-                                       FILE *pfTmp = fopen (optarg, "r");
-                                       mf.fAttachments = true;
-                                       if (pfTmp == NULL)
-                                       {
-                                               fprintf (stderr, "File not found: %s\n", optarg);
-                                               exit (1);
-                                       }
-                                       fclose (pfTmp);
-                               }
-                               break;
-                       case 'm':
-                               if (mf.pfMsg != NULL)
-                                       goto _default;
-
-                               mf.pfMsg = fopen (optarg, "r");
-                               if (mf.pfMsg == NULL)
-                               {
-                                       fprintf (stderr, "File not found: %s\n", optarg);
-                                       exit (1);
-                               }
-                               break;
-                       case '?':
-                       default: _default:
-                               printf ("%c: %i\n", nOpt, iOpt);
-                               help ();
-                               return 1;
-               }
-       }
-       
-       if (mf.szHost == NULL)
-               mf.szHost = "localhost";
-
-       if (mf.szSubject == NULL)
-               mf.szSubject = "";
-
-       if (mf.szTo == NULL)
-       {
-               perror ("must specify 'to' field");
-               help ();
-               return 1;
-       }
-
-       if (mf.szFrom == NULL)
-       {
-               perror ("must specify 'from' field");
-               help ();
-               return 1;
-       }
-
-       SendMail (mf.szTo, &mf);
-
-       if (mf.fCC)
-       {
-               optind = 0;
-               while ((nOpt = getopt_long (cArgs, rgszArgs, szOptions, rgOptions, &iOpt)) != -1)
-               {
-                       if (nOpt == 'c')
-                       {
-                               int optindTmp = optind;
-                               SendMail (optarg, &mf);
-                               optind = optindTmp;
-                       }
-               }
-       }
-
-       if (mf.pfMsg != NULL)
-               fclose (mf.pfMsg);
-
-       return 0;
-}
-
diff --git a/mcs/tools/tinderbox/tinderbox.sh b/mcs/tools/tinderbox/tinderbox.sh
deleted file mode 100755 (executable)
index 3b99163..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-#!/bin/bash
-
-# TOPDIR: set this to the directory containing
-# your 'mono' and 'mcs' directories. Do NOT use '~' here.
-TOPDIR=$HOME/mono
-
-# BACKUP: initially this directory should contain a working install of mono.
-# this directory should minimally contain the 'bin' and 'lib' dirs.
-# after each successful build, the results are placed in here.
-BACKUP=$TOPDIR/install.bak
-
-# INSTALL: this is used as the install directory for
-# the various stages of the build.
-INSTALL=$TOPDIR/install
-
-# SENDMAIL: uncomment this line if you want to send notifications.
-# be careful to check the recipients below before running this script!
-SENDMAIL=$TOPDIR/mcs/tools/tinderbox/smtp
-
-# EMAIL_*: notification addresses. please change these before running!
-EMAIL_FATAL="piersh@friskit.com"
-EMAIL_MESSAGE="mono-patches@lists.ximian.com"
-#EMAIL_MESSAGE="piersh@friskit.com"
-#EMAIL_MESSAGE="mono-hackers-list@ximian.com"
-EMAIL_FROM="piersh@friskit.com"
-EMAIL_CC="-c mono-hackers-list@lists.ximian.com"
-EMAIL_HOST="zeus.sfhq.friskit.com"
-
-LOGBASE=$TOPDIR/.build.log
-LOG=$LOGBASE.txt
-LOGPREV=$LOGBASE.prev
-LOGFATAL=$LOGBASE.fatal
-LOGDATE=$TOPDIR/.build.date
-LOGLOG=$TOPDIR/.build.log.log
-BUILDMSG=$TOPDIR/.build.msg
-export LOGDATE
-
-DELAY_SUCCESS=5m                       # wait after a successful build
-DELAY_CHECK_BROKEN=5m          # wait while verifying the build is broken
-DELAY_STILL_BROKEN=3m          # wait while waiting for fix
-DELAY_BROKEN=5m                                # wait after notification sent
-
-FILTER_LOG="sed -e 's/^in <0x[0-9a-z]*>//' -e 's/:[0-9]*): WARNING \*\*:/): WARNING **/' -e 's/^\[[0-9][0-9]*:[0-9][0-9]*\] - .*//' -e 's/^[0-9][0-9]* - Member cache//' -e 's/^[0-9][0-9]* - Misc counter//' -e 's/: [0-9]* Trace\/breakpoint/ : Trace\/breakpoint/' -e 's/Needed to allocate blacklisted block at 0x[0-9a-f]*//'"
-
-function fatal ()
-{
-       $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_FATAL -a $LOGFATAL -s "[MONOBUILD] FATAL ERROR (`uname -s -m`)"
-       echo FATAL: `date` >> $LOGLOG
-       echo FATAL ERROR
-       exit 1
-}
-
-function build_mono ()
-{
-       # try to build
-
-       echo building...
-
-       cd $TOPDIR
-
-       rm -f $LOGFATAL
-       touch $LOGFATAL
-
-       [ -f $LOG ] && mv $LOG $LOGPREV
-       touch $LOG
-
-       # restore tools from backup
-       rm -fr $INSTALL
-       cp -a $BACKUP $INSTALL
-
-       # update from CVS
-       cvs -z3 update -APd mcs mono 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # clean mcs
-       cd $TOPDIR/mcs
-       make -f makefile.gnu clean 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # build JAY
-       cd $TOPDIR/mcs/jay
-       make -f makefile.gnu 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # build MCS compiler
-       cd $TOPDIR/mcs/mcs
-       make -f makefile.gnu 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # build CORLIB with old tools
-       cd $TOPDIR/mcs/class/corlib
-       make -f makefile.gnu 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # copy new MCS and CORLIB to build tools
-       cp -f $TOPDIR/mcs/class/lib/corlib.dll $INSTALL/lib/
-       cp -f $TOPDIR/mcs/mcs/mcs.exe $INSTALL/bin/
-
-
-
-       cd $TOPDIR/mono
-
-       # configure mono build
-       rm -f config.cache
-       ./autogen.sh --prefix=$INSTALL 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # clean mono
-       make clean 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # build mono
-       make 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       # install runtime
-       cd $TOPDIR/mono/mono
-       make install 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-
-
-       # clean/make runtime libraries/tools
-       cd $TOPDIR/mcs
-       make -f makefile.gnu clean 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-       make -f makefile.gnu 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-
-
-       # retrieve runtime libraries
-       cd $TOPDIR/mono/runtime
-       rm -f *.dll *.exe
-
-       # install everything
-       cd $TOPDIR/mono
-       make install 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-
-       # test mcs self-build
-       cd $TOPDIR/mcs/mcs
-       make -f makefile.gnu clean 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-       make -f makefile.gnu 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-
-       # test corlib self-build
-       cd $TOPDIR/mcs/class/corlib
-       make -f makefile.gnu clean 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-       make -f makefile.gnu 2>&1 | tee -a $LOG
-       [ $PIPESTATUS == "0" ] || return 1
-
-
-       # it worked, backup build tools
-       rm -fr $BACKUP
-       cp -a $INSTALL $BACKUP
-
-       return 0
-}
-
-function compare_logs ()
-{
-       touch $LOG $LOGPREV
-       echo Comparing build logs
-       eval $FILTER_LOG $LOG > $LOG.tmp
-       eval $FILTER_LOG $LOGPREV > $LOGPREV.tmp
-       diff -b --brief $LOG.tmp $LOGPREV.tmp
-}
-
-function build_fixed ()
-{
-       echo "Build fixed:       `date`" > $BUILDMSG
-       echo "Previous breakage: `cat .build.date.last_fail`" >> $BUILDMSG
-       echo "Previous build:    `cat .build.date.last_success`" >> $BUILDMSG
-       echo >> $BUILDMSG
-
-       $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_MESSAGE $EMAIL_CC -s "[MONOBUILD] fixed (`uname -s -m`)" -m $BUILDMSG
-       rm -f $BUILDMSG
-}
-
-function build_failed ()
-{
-       echo "Build broken:   `date`" > $BUILDMSG
-       echo "Broken since:   `cat .build.date.last_fail`" >> $BUILDMSG
-       echo "Previous build: `cat .build.date.last_success`" >> $BUILDMSG
-       echo >> $BUILDMSG
-
-       sed -e 's/$/\r/' < $LOG > errors.txt
-       tail -25 errors.txt >> $BUILDMSG
-       rm -f errors.txt.gz
-       gzip errors.txt
-
-       $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_MESSAGE $EMAIL_CC -a errors.txt.gz -s "[MONOBUILD] broken (`uname -s -m`)" -m $BUILDMSG
-       rm -f $BUILDMSG errors.txt.gz
-}
-
-function stabilize ()
-{
-       cd $TOPDIR
-       while ! compare_logs ; do
-
-               date > $LOGDATE.last_fail
-               echo "|||||||||||||||||||||||||"
-               echo "|||||| LOGS DIFFER ||||||"
-               echo "|||||||||||||||||||||||||"
-               echo CHECK: `date` >> $LOGLOG
-
-               echo sleeping for $DELAY_CHECK_BROKEN
-               sleep $DELAY_CHECK_BROKEN
-
-               if build_mono ; then
-                       return 0
-               fi
-
-               cd $TOPDIR
-
-       done
-       return 1
-}
-
-[ -f $LOGPREV ] && mv $LOGPREV $LOG
-
-while [ 1 ] ; do
-
-       cd $TOPDIR
-       
-       if build_mono ; then
-
-               cd $TOPDIR
-
-               echo "|||||||||||||||||||||||||"
-               echo "|||| BUILD SUCCEEDED ||||"
-               echo "|||||||||||||||||||||||||"
-               echo SUCCESS: `date` >> $LOGLOG
-               date > $LOGDATE.last_success
-               echo sleeping for $DELAY_SUCCESS
-               sleep $DELAY_SUCCESS
-
-       else
-
-               if ! stabilize ; then
-
-                       build_failed
-
-                       echo "||||||||||||||||||||||"
-                       echo "|||| BUILD BROKEN ||||"
-                       echo "||||||||||||||||||||||"
-                       echo BROKEN: `date` >> $LOGLOG
-                       date > $LOGDATE.last_fail
-                       echo sleeping for $DELAY_BROKEN
-                       sleep $DELAY_BROKEN
-
-                       until build_mono ; do
-
-                               cd $TOPDIR
-                               echo "||||||||||||||||||||||||||||"
-                               echo "|||| BUILD STILL BROKEN ||||"
-                               echo "||||||||||||||||||||||||||||"
-                               echo STILL BROKEN: `date` >> $LOGLOG
-                               date > $LOGDATE.last_fail
-                               echo sleeping for $DELAY_STILL_BROKEN
-                               sleep $DELAY_STILL_BROKEN
-
-                       done
-
-                       cd $TOPDIR
-                       build_fixed
-                       echo "|||||||||||||||||||||"
-                       echo "|||| BUILD FIXED ||||"
-                       echo "|||||||||||||||||||||"
-                       echo FIXED: `date` >> $LOGLOG
-                       date > $LOGDATE.last_success
-                       echo sleeping for $DELAY_SUCCESS
-                       sleep $DELAY_SUCCESS
-
-               fi
-
-       fi
-
-done
-
diff --git a/mcs/winexe.in b/mcs/winexe.in
deleted file mode 100755 (executable)
index 19a4782..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-@bindir@/bin/mono.exe @bindir@/bin/@thewindowexe@ "$@"
index ea8fda67dc35096689e0e580561e7e4b68b38577..016175bea3b4c56f370f7ff512f47093c7e0e70b 100644 (file)
@@ -39,8 +39,10 @@ mono_read (BIO *bio, char *out, int outl)
 
        ret = mono->read_func (mono->instance, out, outl, &wantMore);
 
-       if (ret < 0)
+       if (ret < 0) {
+               errno = EIO;
                return -1;
+       }
        if (ret > 0)
                return ret;
 
index eca323ce2ae27a194018f0180f89131d3a34443d..17291b5c585e18cd0f11e2c2b4f8bb8c01766776 100644 (file)
@@ -60,6 +60,18 @@ mono_btls_ssl_close (MonoBtlsSsl *ptr)
        ;
 }
 
+MONO_API int
+mono_btls_ssl_shutdown (MonoBtlsSsl *ptr)
+{
+    return SSL_shutdown (ptr->ssl);
+}
+
+MONO_API void
+mono_btls_ssl_set_quiet_shutdown (MonoBtlsSsl *ptr, int mode)
+{
+    SSL_set_quiet_shutdown (ptr->ssl, mode);
+}
+
 MONO_API void
 mono_btls_ssl_set_bio (MonoBtlsSsl *ptr, BIO *bio)
 {
index 98b017340e1b1a956da2bafdaf056e5bd3c0b33b..ac93c114995fee4bdf6f24f6c838158ca34aee4c 100644 (file)
@@ -68,6 +68,12 @@ mono_btls_ssl_get_peer_certificate (MonoBtlsSsl *ptr);
 void
 mono_btls_ssl_close (MonoBtlsSsl *ptr);
 
+int
+mono_btls_ssl_shutdown (MonoBtlsSsl *ptr);
+
+MONO_API void
+mono_btls_ssl_set_quiet_shutdown (MonoBtlsSsl *ptr, int mode);
+
 int
 mono_btls_ssl_get_error (MonoBtlsSsl *ptr, int ret_code);
 
index 14090d8c3ecc5d60c50a5d2225e23b0a559b3e47..06085362c54484072e624443e2c11b6a9dc573c3 100644 (file)
@@ -8,7 +8,7 @@ if SUPPORT_SGEN
 metadata_lib=$(top_builddir)/mono/metadata/libmonoruntimesgen-static.la
 gc_lib=$(top_builddir)/mono/sgen/libmonosgen-static.la
 else
-metadata_lib=$(top_builddir)/mono/metadata/libmonoruntime-static.a
+metadata_lib=$(top_builddir)/mono/metadata/libmonoruntime-static.la
 gc_lib=$(LIBGC_STATIC_LIBS)
 endif
 
index 9242e8639fe4fc147608b82d559b3a6d7e62b28f..c13675e8233525e0fd63f80f51b45f6677b19d94 100755 (executable)
 #include "mono/metadata/class-internals.h"
 #include "mono/utils/mono-compiler.h"
 
-#if defined(__native_client__) && defined(__GLIBC__)
-volatile int __nacl_thread_suspension_needed = 0;
-void __nacl_suspend_thread_if_needed() {}
-#endif
-
 void
 dump_table_assembly (MonoImage *m)
 {
index ca9c92e0ae60cdb0a808a654ade306a8d2565c70..a994e4603d30214cbfb5d5a40e7fd9d17459d023 100755 (executable)
@@ -25,6 +25,9 @@
 
 extern gboolean substitute_with_mscorlib_p;
 
+static char *
+get_token_comment (const char *prefix, guint32 token);
+
 static MonoGenericContainer *
 get_memberref_container (MonoImage *m, guint32 mrp_token, MonoGenericContainer *container);
 
@@ -59,7 +62,7 @@ get_typedef (MonoImage *m, int idx)
         /* Check if this is a nested type */
         token = MONO_TOKEN_TYPE_DEF | (idx);
         token = mono_metadata_nested_in_typedef (m, token);
-       tstring = show_tokens ? g_strdup_printf ("/*%08x*/", token) : NULL;
+       tstring = get_token_comment (NULL, token);
         if (token) {
                 char *outer;
                 
@@ -258,11 +261,12 @@ get_typespec (MonoImage *m, guint32 idx, gboolean is_def, MonoGenericContainer *
 
        if (show_tokens) {
                int token = mono_metadata_make_token (MONO_TABLE_TYPESPEC, idx);
-               result = g_strdup_printf ("%s/*%08x*/", res->str, token);
-       } else
+               result = get_token_comment (res->str, token);
+               g_string_free (res, TRUE);
+       } else {
                result = res->str;
-
-       g_string_free (res, FALSE);
+               g_string_free (res, FALSE);
+       }
 
        return result;
 }
@@ -316,7 +320,7 @@ get_typeref (MonoImage *m, int idx)
 
        if (show_tokens) {
                int token = mono_metadata_make_token (MONO_TABLE_TYPEREF, idx);
-               char *temp = g_strdup_printf ("%s/*%08x*/", ret, token);
+               char *temp = get_token_comment (ret, token);
                g_free (ret);
                ret = temp;
        }
@@ -1294,7 +1298,7 @@ get_type (MonoImage *m, const char *ptr, char **result, gboolean is_def, MonoGen
                }
 
                if (show_tokens) {
-                       *result = g_strdup_printf ("%s/*%08x*/", temp, token);
+                       *result = get_token_comment (temp, token);
                        g_free (temp);
                } else
                        *result = temp;
@@ -1769,6 +1773,25 @@ get_fieldref_signature (MonoImage *m, int idx, MonoGenericContainer *container)
         return full_sig;
 }
 
+/**
+ * get_token_comment:
+ *
+ * If show_tokens is TRUE, return "prefix""token(table)".
+ * If show_tokens is FALSE, return "prefix" or NULL if prefix is NULL.
+ * Caller is responsible for freeing.
+ */
+char *
+get_token_comment (const char *prefix, guint32 token)
+{
+       if (!show_tokens)
+               return prefix ? g_strdup_printf ("%s", prefix) : NULL;
+       gint32 tableidx = mono_metadata_token_table (token);
+       if ((tableidx < 0) || (tableidx > MONO_TABLE_LAST))
+               return g_strdup_printf ("%s/*%08x*/", prefix ? prefix : "", token);
+       else
+               return g_strdup_printf ("%s/*%08x(%s)*/", prefix ? prefix : "", token, mono_meta_table_name (tableidx));
+}
+
 /**
  * get_field:
  * @m: metadata context
@@ -1783,7 +1806,7 @@ get_field (MonoImage *m, guint32 token, MonoGenericContainer *container)
 {
        int idx = mono_metadata_token_index (token);
        guint32 cols [MONO_FIELD_SIZE];
-       char *sig, *res, *type, *estype, *esname;
+       char *sig, *res, *type, *estype, *esname, *token_comment;
        guint32 type_idx;
 
        /*
@@ -1812,16 +1835,20 @@ get_field (MonoImage *m, guint32 token, MonoGenericContainer *container)
        type = get_typedef (m, type_idx);
        estype = get_escaped_name (type);
        esname = get_escaped_name (mono_metadata_string_heap (m, cols [MONO_FIELD_NAME]));
-       res = g_strdup_printf ("%s %s%s%s",
+       token_comment = get_token_comment (NULL, token);
+       res = g_strdup_printf ("%s %s%s%s%s",
                        sig, 
                        estype ? estype : "",
                        estype ? "::" : "",
-                       esname);
+                       esname,
+                       token_comment ? token_comment : ""
+               );
 
        g_free (type);
        g_free (sig);
        g_free (estype);
        g_free (esname);
+       g_free (token_comment);
 
        return res;
 }
@@ -1909,12 +1936,11 @@ get_method_core (MonoImage *m, guint32 token, gboolean fullsig, MonoGenericConta
                        container = mono_method_get_generic_container (((MonoMethodInflated *) mh)->declaring);
                esname = get_escaped_name (mh->name);
                sig = dis_stringify_type (m, &mh->klass->byval_arg, TRUE);
-               if (show_tokens)
-                       name = g_strdup_printf ("%s/*%08x*/%s%s", sig ? sig : "", token, sig ? "::" : "", esname);
-               else
-                       name = g_strdup_printf ("%s%s%s", sig ? sig : "", sig ? "::" : "", esname);
+               char *token_comment = get_token_comment (NULL, token);
+               name = g_strdup_printf ("%s%s%s%s", sig ? sig : "", token_comment ? token_comment : "", sig ? "::" : "", esname);
                g_free (sig);
                g_free (esname);
+               g_free (token_comment);
        } else {
                name = NULL;
                mono_error_cleanup (&error);
@@ -1979,7 +2005,7 @@ get_method_core (MonoImage *m, guint32 token, gboolean fullsig, MonoGenericConta
        }
        
        if (show_tokens) {
-               char *retval = g_strdup_printf ("%s /* %08x */", sig, token);
+               char *retval = get_token_comment (sig, token);
                g_free (sig);
                return retval;
        } else
index 4c29af97bc9773c514f7a3886fd6ceff755ec6d5..a149edb2608abf6a1e85f517cf465e2c30168ee8 100644 (file)
@@ -1951,8 +1951,10 @@ monodis_assembly_search_hook (MonoAssemblyName *aname, gpointer user_data)
 static void
 usage (void)
 {
-       GString *args = g_string_new ("[--output=filename] [--filter=filename] [--help] [--mscorlib]\n");
+       GString *args = g_string_new ("[--output=filename] [--filter=filename]\n");
        int i;
+
+       g_string_append (args, "[--help] [--mscorlib] [--show-tokens] [--show-method-tokens]\n");
        
        for (i = 0; table_list [i].name != NULL; i++){
                g_string_append (args, "[");
index 182d117308c9b9254b93762a78e15f127c9e33a3..5783a12fd81f1ec8c241238750f680bc520dea3b 100644 (file)
@@ -77,6 +77,9 @@ is useful for round-tripping the IL with ilasm.
 .TP
 .I "--show-method-tokens"
 Display tokens for disassembled methods.
+.TP
+.I "--show-tokens"
+Display tokens for strings, types, methods, fields, etc.
 .SH OPTIONS TO DISPLAY METADATA TABLES
 The following options are used to display metadata tables instead of
 disassembling the CIL image.
index 246eec3b68c4605605751b6ac8490decd568b380..a9f976f8c207799107f48d02bb367fc5019a6efb 100644 (file)
@@ -193,6 +193,7 @@ common_sources = \
        mono-endian.c           \
        mono-endian.h           \
        mono-hash.h             \
+       mono-conc-hash.h                \
        mono-mlist.c            \
        mono-mlist.h            \
        mono-perfcounters.c     \
@@ -202,7 +203,6 @@ common_sources = \
        mono-route.c            \
        mono-route.h            \
        monitor.h               \
-       nacl-stub.c             \
        normalization-tables.h  \
        number-formatter.h      \
        number-ms.c             \
@@ -280,6 +280,7 @@ gc_dependent_sources = \
        gc.c            \
        monitor.c       \
        mono-hash.c     \
+       mono-conc-hash.c        \
        object.c        \
        dynamic-image.c \
        sre.c   \
index f8de9e2d23e3842a747a4948d641847b77f3464c..02ca3bbf949dcfa99b1b35c56eccea187d7bfbb3 100644 (file)
@@ -1148,6 +1148,7 @@ leave:
 MonoAssembly*
 mono_try_assembly_resolve_handle (MonoDomain *domain, MonoStringHandle fname, MonoAssembly *requesting, gboolean refonly, MonoError *error)
 {
+       HANDLE_FUNCTION_ENTER ();
        MonoAssembly *ret = NULL;
        MonoMethod *method;
        MonoBoolean isrefonly;
@@ -1156,7 +1157,7 @@ mono_try_assembly_resolve_handle (MonoDomain *domain, MonoStringHandle fname, Mo
        error_init (error);
 
        if (mono_runtime_get_no_exec ())
-               return ret;
+               goto leave;
 
        g_assert (domain != NULL && !MONO_HANDLE_IS_NULL (fname));
 
@@ -1167,14 +1168,16 @@ mono_try_assembly_resolve_handle (MonoDomain *domain, MonoStringHandle fname, Mo
        MonoReflectionAssemblyHandle requesting_handle;
        if (requesting) {
                requesting_handle = mono_assembly_get_object_handle (domain, requesting, error);
-               return_val_if_nok (error, ret);
+               if (!is_ok (error))
+                       goto leave;
        }
        params [0] = MONO_HANDLE_RAW (fname);
        params[1] = requesting ? MONO_HANDLE_RAW (requesting_handle) : NULL;
        params [2] = &isrefonly;
        MonoReflectionAssemblyHandle result = MONO_HANDLE_NEW (MonoReflectionAssembly, mono_runtime_invoke_checked (method, domain->domain, params, error));
        ret = !MONO_HANDLE_IS_NULL (result) ? MONO_HANDLE_GETVAL (result, assembly) : NULL;
-       return ret;
+leave:
+       HANDLE_FUNCTION_RETURN_VAL (ret);
 }
 
 MonoAssembly *
@@ -1243,6 +1246,7 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
 static void
 mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
 {
+       HANDLE_FUNCTION_ENTER ();
        static MonoClassField *assembly_load_field;
        static MonoMethod *assembly_load_method;
        MonoError error;
@@ -1253,7 +1257,7 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
 
        if (!domain->domain)
                /* This can happen during startup */
-               return;
+               goto leave;
 #ifdef ASSEMBLY_LOAD_DEBUG
        fprintf (stderr, "Loading %s into domain %s\n", assembly->aname.name, domain->friendly_name);
 #endif
@@ -1271,7 +1275,7 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
        mono_field_get_value ((MonoObject*) domain->domain, assembly_load_field, &load_value);
        if (load_value == NULL) {
                /* No events waiting to be triggered */
-               return;
+               goto leave;
        }
 
        MonoReflectionAssemblyHandle ref_assembly = mono_assembly_get_object_handle (domain, assembly, &error);
@@ -1286,6 +1290,8 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
 
        mono_runtime_invoke_checked (assembly_load_method, domain->domain, params, &error);
        mono_error_cleanup (&error);
+leave:
+       HANDLE_FUNCTION_RETURN ();
 }
 
 /*
@@ -2260,10 +2266,6 @@ ves_icall_System_AppDomain_InternalUnload (gint32 domain_id, MonoError *error)
        if (g_hasenv ("MONO_NO_UNLOAD"))
                return;
 
-#ifdef __native_client__
-       return;
-#endif
-
        MonoException *exc = NULL;
        mono_domain_try_unload (domain, (MonoObject**)&exc);
        if (exc)
index 5bc9486f897e85703bbf689875c78867e671f786..86efc2999f6562594f0503e4a60d4461edc20a28 100644 (file)
@@ -332,27 +332,6 @@ static const AssemblyVersionMap framework_assemblies [] = {
 static GList *loaded_assemblies = NULL;
 static MonoAssembly *corlib;
 
-#if defined(__native_client__)
-
-/* On Native Client, allow mscorlib to be loaded from memory  */
-/* instead of loaded off disk.  If these are not set, default */
-/* mscorlib loading will take place                           */
-
-/* NOTE: If mscorlib data is passed to mono in this way then */
-/* it needs to remain allocated during the use of mono.      */
-
-static void *corlibData = NULL;
-static size_t corlibSize = 0;
-
-void
-mono_set_corlib_data (void *data, size_t size)
-{
-  corlibData = data;
-  corlibSize = size;
-}
-
-#endif
-
 static char* unquote (const char *str);
 
 /* This protects loaded_assemblies and image->references */
@@ -462,12 +441,6 @@ mono_set_assemblies_path (const char* path)
        }
 }
 
-/* Native Client can't get this info from an environment variable so */
-/* it's passed in to the runtime, or set manually by embedding code. */
-#ifdef __native_client__
-char* nacl_mono_path = NULL;
-#endif
-
 static void
 check_path_env (void)
 {
@@ -475,10 +448,6 @@ check_path_env (void)
                return;
 
        char* path = g_getenv ("MONO_PATH");
-#ifdef __native_client__
-       if (!path)
-               path = strdup (nacl_mono_path);
-#endif
        if (!path)
                return;
 
@@ -1980,11 +1949,24 @@ mono_assembly_open_predicate (const char *filename, gboolean refonly,
        }
 
        if (image->assembly) {
-               /* Already loaded by another appdomain */
-               mono_assembly_invoke_load_hook (image->assembly);
-               mono_image_close (image);
-               g_free (fname);
-               return image->assembly;
+               /* We want to return the MonoAssembly that's already loaded,
+                * but if we're using the strict assembly loader, we also need
+                * to check that the previously loaded assembly matches the
+                * predicate.  It could be that we previously loaded a
+                * different version that happens to have the filename that
+                * we're currently probing. */
+               if (mono_loader_get_strict_strong_names () &&
+                   predicate && !predicate (image->assembly, user_data)) {
+                       mono_image_close (image);
+                       g_free (fname);
+                       return NULL;
+               } else {
+                       /* Already loaded by another appdomain */
+                       mono_assembly_invoke_load_hook (image->assembly);
+                       mono_image_close (image);
+                       g_free (fname);
+                       return image->assembly;
+               }
        }
 
        ass = mono_assembly_load_from_predicate (image, fname, refonly, predicate, user_data, status);
@@ -3492,23 +3474,6 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *
                return corlib;
        }
 
-       // In native client, Corlib is embedded in the executable as static variable corlibData
-#if defined(__native_client__)
-       if (corlibData != NULL && corlibSize != 0) {
-               int status = 0;
-               /* First "FALSE" instructs mono not to make a copy. */
-               /* Second "FALSE" says this is not just a ref.      */
-               MonoImage* image = mono_image_open_from_data_full (corlibData, corlibSize, FALSE, &status, FALSE);
-               if (image == NULL || status != 0)
-                       g_print("mono_image_open_from_data_full failed: %d\n", status);
-               corlib = mono_assembly_load_from_full (image, "mscorlib", &status, FALSE);
-               if (corlib == NULL || status != 0)
-                       g_print ("mono_assembly_load_from_full failed: %d\n", status);
-               if (corlib)
-                       return corlib;
-       }
-#endif
-
        // A nonstandard preload hook may provide a special mscorlib assembly
        aname = mono_assembly_name_new ("mscorlib.dll");
        corlib = invoke_assembly_preload_hook (aname, assemblies_path);
index 99704f7c428bfe69fac794b09e43e8515c62573b..42f4d16597d1b44d5cd5ac7c7faa7a8314387a41 100644 (file)
@@ -129,7 +129,7 @@ mono_gc_base_init (void)
         * we used to do this only when running on valgrind,
         * but it happens also in other setups.
         */
-#if defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) && !defined(__native_client__)
+#if defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
        {
                size_t size;
                void *sstart;
@@ -164,8 +164,6 @@ mono_gc_base_init (void)
 
                GC_stackbottom = (char*)ss.ss_sp;
        }
-#elif defined(__native_client__)
-       /* Do nothing, GC_stackbottom is set correctly in libgc */
 #else
        {
                int dummy;
@@ -410,6 +408,8 @@ boehm_thread_unregister (MonoThreadInfo *p)
 
        if (p->runtime_thread)
                mono_threads_add_joinable_thread ((gpointer)tid);
+
+       mono_handle_stack_free (p->handle_stack);
 }
 
 static void
index a998457113d3b60c6e475a8cb714743e932f34a6..4ed4f39da3dc5d648fa30936fb8d50f1d3fd7974 100644 (file)
@@ -1631,8 +1631,7 @@ mono_class_setup_fields (MonoClass *klass)
                        char *class_name = mono_type_get_full_name (klass);
                        char *type_name = mono_type_full_name (field->type);
 
-                       mono_class_set_type_load_failure (klass, "");
-                       g_warning ("Invalid type %s for instance field %s:%s", type_name, class_name, field->name);
+                       mono_class_set_type_load_failure (klass, "Invalid type %s for instance field %s:%s", type_name, class_name, field->name);
                        g_free (class_name);
                        g_free (type_name);
                        break;
@@ -9107,10 +9106,25 @@ mono_class_get_methods (MonoClass* klass, gpointer *iter)
 static MonoMethod*
 mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter)
 {
-       MonoMethod** method;
+       gboolean static_iter = FALSE;
+
        if (!iter)
                return NULL;
-       if (klass->methods || !MONO_CLASS_HAS_STATIC_METADATA (klass)) {
+
+       /*
+        * If the lowest bit of the iterator is 1, this is an iterator for static metadata,
+        * and the upper bits contain an index. Otherwise, the iterator is a pointer into
+        * klass->methods.
+        */
+       if ((gsize)(*iter) & 1)
+               static_iter = TRUE;
+       /* Use the static metadata only if klass->methods is not yet initialized */
+       if (!static_iter && !(klass->methods || !MONO_CLASS_HAS_STATIC_METADATA (klass)))
+               static_iter = TRUE;
+
+       if (!static_iter) {
+               MonoMethod** methodptr;
+
                if (!*iter) {
                        mono_class_setup_methods (klass);
                        /*
@@ -9120,20 +9134,22 @@ mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter)
                        if (!klass->methods)
                                return NULL;
                        /* start from the first */
-                       method = &klass->methods [0];
+                       methodptr = &klass->methods [0];
                } else {
-                       method = (MonoMethod **)*iter;
-                       method++;
+                       methodptr = (MonoMethod **)*iter;
+                       methodptr++;
                }
+               if (*iter)
+                       g_assert ((guint64)(*iter) > 0x100);
                int mcount = mono_class_get_method_count (klass);
-               while (method < &klass->methods [mcount]) {
-                       if (*method && ((*method)->flags & METHOD_ATTRIBUTE_VIRTUAL))
+               while (methodptr < &klass->methods [mcount]) {
+                       if (*methodptr && ((*methodptr)->flags & METHOD_ATTRIBUTE_VIRTUAL))
                                break;
-                       method ++;
+                       methodptr ++;
                }
-               if (method < &klass->methods [mcount]) {
-                       *iter = method;
-                       return *method;
+               if (methodptr < &klass->methods [mcount]) {
+                       *iter = methodptr;
+                       return *methodptr;
                } else {
                        return NULL;
                }
@@ -9145,7 +9161,7 @@ mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter)
                if (!*iter) {
                        start_index = 0;
                } else {
-                       start_index = GPOINTER_TO_UINT (*iter);
+                       start_index = GPOINTER_TO_UINT (*iter) >> 1;
                }
 
                int first_idx = mono_class_get_first_method_idx (klass);
@@ -9166,7 +9182,7 @@ mono_class_get_virtual_methods (MonoClass* klass, gpointer *iter)
                        mono_error_cleanup (&error); /* FIXME don't swallow the error */
 
                        /* Add 1 here so the if (*iter) check fails */
-                       *iter = GUINT_TO_POINTER (i + 1);
+                       *iter  = GUINT_TO_POINTER (((i + 1) << 1) | 1);
                        return res;
                } else {
                        return NULL;
index 86309ef20234d4dd559726f0c9fcfe1a32f08e32..d522657b62f0b97efa9792ba77734e29d2882e12 100644 (file)
@@ -1090,7 +1090,7 @@ mono_cominterop_get_invoke (MonoMethod *method)
        for (i = 1; i <= sig->param_count; i++)
                mono_mb_emit_ldarg (mb, i);
 
-       if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
+       if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) || mono_class_is_interface (method->klass)) {
                MonoMethod * native_wrapper = mono_cominterop_get_native_wrapper(method);
                mono_mb_emit_managed_call (mb, native_wrapper, NULL);
        }
index 98b3ba551cb005a3af4cbadc884cb576a81e4984..fe71923dbbadbdb97378b047a0f822f80a977749 100644 (file)
@@ -8,10 +8,6 @@
  * Copyright (C) 2005-2009 Novell, Inc. (http://www.novell.com)
  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
-#if defined(__native_client__)
-#include "console-null.c"
-#else
-
 #include <config.h>
 #include <glib.h>
 #include <stdio.h>
@@ -525,5 +521,3 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardow
 
        return TRUE;
 }
-#endif /* #if defined(__native_client__) */
-
index c9fb4add3dd46edb349dc33e980c637972a8d059..6d8042c07680206f4ed4778cf056266fa67bba2f 100644 (file)
@@ -12,6 +12,7 @@
 #include <mono/metadata/lock-tracer.h>
 #include <mono/utils/mono-codeman.h>
 #include <mono/metadata/mono-hash.h>
+#include <mono/metadata/mono-conc-hash.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-internal-hash.h>
 #include <mono/metadata/mempool-internals.h>
@@ -69,6 +70,7 @@ struct _MonoJitInfoTable
 {
        MonoDomain             *domain;
        int                     num_chunks;
+       int                     num_valid;
        MonoJitInfoTableChunk  *chunks [MONO_ZERO_LEN_ARRAY];
 };
 
@@ -241,6 +243,8 @@ struct _MonoJitInfo {
         * d.tramp_info contains additional data in this case.
         */
        gboolean    is_trampoline:1;
+       /* Whenever this jit info refers to an interpreter method */
+       gboolean    is_interp:1;
 
        /* FIXME: Embed this after the structure later*/
        gpointer    gc_info; /* Currently only used by SGen */
@@ -336,7 +340,7 @@ struct _MonoDomain {
        MonoGHashTable     *ldstr_table;
        /* hashtables for Reflection handles */
        MonoGHashTable     *type_hash;
-       MonoGHashTable     *refobject_hash;
+       MonoConcGHashTable     *refobject_hash;
        /* maps class -> type initialization exception object */
        MonoGHashTable    *type_init_exception_hash;
        /* maps delegate trampoline addr -> delegate object */
index 2e6a52170078f5487e79fb00c2df5e32508b741b..7a12a7f4f727df945ec2a21815c6dbece75bce0b 100644 (file)
@@ -1037,10 +1037,6 @@ mono_domain_free (MonoDomain *domain, gboolean force)
 
        mono_debug_domain_unload (domain);
 
-       mono_appdomains_lock ();
-       appdomains_list [domain->domain_id] = NULL;
-       mono_appdomains_unlock ();
-
        /* must do this early as it accesses fields and types */
        if (domain->special_static_fields) {
                mono_alloc_special_static_data_free (domain->special_static_fields);
@@ -1214,6 +1210,10 @@ mono_domain_free (MonoDomain *domain, gboolean force)
 
        mono_gc_deregister_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED));
 
+       mono_appdomains_lock ();
+       appdomains_list [domain->domain_id] = NULL;
+       mono_appdomains_unlock ();
+
        /* FIXME: anything else required ? */
 
        mono_gc_free_fixed (domain);
index b846347126cb0bf39f5baea7359c3544099cf384..9ea2bcf0ee5c5252c362d8b8106a623db82faa87 100644 (file)
@@ -314,12 +314,7 @@ mono_dynamic_image_create (MonoDynamicAssembly *assembly, char *assembly_name, c
        else
                version = mono_get_runtime_info ()->runtime_version;
 
-#if HAVE_BOEHM_GC
-       /* The MonoGHashTable's need GC tracking */
-       image = (MonoDynamicImage *)GC_MALLOC (sizeof (MonoDynamicImage));
-#else
        image = g_new0 (MonoDynamicImage, 1);
-#endif
 
        mono_profiler_module_event (&image->image, MONO_PROFILE_START_LOAD);
        
@@ -549,10 +544,5 @@ mono_dynamic_image_free (MonoDynamicImage *image)
 void
 mono_dynamic_image_free_image (MonoDynamicImage *image)
 {
-       /* See create_dynamic_mono_image () */
-#if HAVE_BOEHM_GC
-       /* Allocated using GC_MALLOC */
-#else
        g_free (image);
-#endif
 }
index 111ed39e6ba610289e1faf69a43f336f05e0a4da..f561dc15b4cb01fd6956f23df5c277339b0fdd08 100644 (file)
@@ -416,10 +416,6 @@ mono_domain_finalize (MonoDomain *domain, guint32 timeout)
        gboolean ret;
        gint64 start;
 
-#if defined(__native_client__)
-       return FALSE;
-#endif
-
        if (mono_thread_internal_current () == gc_thread)
                /* We are called from inside a finalizer, not much we can do here */
                return FALSE;
index 00a11e67319e375ff9004906341b53320767fbcb..736fd56a7a94e7aa4d9715e43d51a13f6beb7177 100644 (file)
@@ -69,68 +69,63 @@ Combine: MonoDefaults, GENERATE_GET_CLASS_WITH_CACHE, TYPED_HANDLE_DECL and frie
  * points to a valid value.
  */
 
-const MonoObjectHandle mono_null_value_handle = NULL;
-
-#define THIS_IS_AN_OK_NUMBER_OF_HANDLES 100
-
-enum {
-       HANDLE_CHUNK_PTR_OBJ = 0x0, /* chunk element points to beginning of a managed object */
-       HANDLE_CHUNK_PTR_INTERIOR = 0x1, /* chunk element points into the middle of a managed object */
-       HANDLE_CHUNK_PTR_MASK = 0x1
-};
+#ifdef HAVE_BOEHM_GC
+static HandleStack*
+new_handle_stack ()
+{
+       return (HandleStack *)mono_gc_alloc_fixed (sizeof (HandleStack), MONO_GC_DESCRIPTOR_NULL, MONO_ROOT_SOURCE_HANDLE, "Thread Handle Stack");
+}
 
-/* number of bits in each word of the interior pointer bitmap */
-#define INTERIOR_HANDLE_BITMAP_BITS_PER_WORD (sizeof(guint32) << 3)
+static void
+free_handle_stack (HandleStack *stack)
+{
+       mono_gc_free_fixed (stack);
+}
 
-static gboolean
-bitset_bits_test (guint32 *bitmaps, int idx)
+static HandleChunk*
+new_handle_chunk ()
 {
-       int w = idx / INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-       int b = idx % INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-       guint32 bitmap = bitmaps [w];
-       guint32 mask = 1u << b;
-       return ((bitmap & mask) != 0);
+       return (HandleChunk *)GC_MALLOC (sizeof (HandleChunk));
 }
 
 static void
-bitset_bits_set (guint32 *bitmaps, int idx)
+free_handle_chunk (HandleChunk *chunk)
 {
-       int w = idx / INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-       int b = idx % INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-       guint32 *bitmap = &bitmaps [w];
-       guint32 mask = 1u << b;
-       *bitmap |= mask;
 }
+#else
+static HandleStack*
+new_handle_stack ()
+{
+       return g_new (HandleStack, 1);
+}
+
 static void
-bitset_bits_clear (guint32 *bitmaps, int idx)
+free_handle_stack (HandleStack *stack)
 {
-       int w = idx / INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-       int b = idx % INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-       guint32 *bitmap = &bitmaps [w];
-       guint32 mask = ~(1u << b);
-       *bitmap &= mask;
+       g_free (stack);
 }
 
-static gpointer*
-chunk_element_objslot_init (HandleChunk *chunk, int idx, gboolean interior)
+static HandleChunk*
+new_handle_chunk ()
 {
-       if (interior)
-               bitset_bits_set (chunk->interior_bitmap, idx);
-       else
-               bitset_bits_clear (chunk->interior_bitmap, idx);
-       return &chunk->elems [idx].o;
+       return g_new (HandleChunk, 1);
 }
 
-static HandleChunkElem*
-chunk_element (HandleChunk *chunk, int idx)
+static void
+free_handle_chunk (HandleChunk *chunk)
 {
-       return &chunk->elems[idx];
+       g_free (chunk);
 }
+#endif
+
+const MonoObjectHandle mono_null_value_handle = NULL;
 
-static guint
-chunk_element_kind (HandleChunk *chunk, int idx)
+#define THIS_IS_AN_OK_NUMBER_OF_HANDLES 100
+
+static HandleChunkElem*
+chunk_element (HandleChunk *chunk, int idx)
 {
-       return bitset_bits_test (chunk->interior_bitmap, idx) ? HANDLE_CHUNK_PTR_INTERIOR : HANDLE_CHUNK_PTR_OBJ;
+       return &chunk->elems[idx];
 }
 
 static HandleChunkElem*
@@ -207,25 +202,12 @@ mono_handle_chunk_leak_check (HandleStack *handles) {
 }
 #endif
 
-MonoRawHandle
-#ifndef MONO_HANDLE_TRACK_OWNER
-mono_handle_new (MonoObject *object)
-#else
-mono_handle_new (MonoObject *object, const char *owner)
-#endif
-{
-#ifndef MONO_HANDLE_TRACK_OWNER
-       return mono_handle_new_full (object, FALSE);
-#else
-       return mono_handle_new_full (object, FALSE, owner);
-#endif
-}
 /* Actual handles implementation */
 MonoRawHandle
 #ifndef MONO_HANDLE_TRACK_OWNER
-mono_handle_new_full (gpointer rawptr, gboolean interior)
+mono_handle_new (MonoObject *obj)
 #else
-mono_handle_new_full (gpointer rawptr, gboolean interior, const char *owner)
+mono_handle_new (MonoObject *obj, const char *owner)
 #endif
 {
        MonoThreadInfo *info = mono_thread_info_current ();
@@ -238,7 +220,7 @@ mono_handle_new_full (gpointer rawptr, gboolean interior, const char *owner)
 retry:
        if (G_LIKELY (top->size < OBJECTS_PER_HANDLES_CHUNK)) {
                int idx = top->size;
-               gpointer* objslot = chunk_element_objslot_init (top, idx, interior);
+               gpointer* objslot = &top->elems [idx].o;
                /* can be interrupted anywhere here, so:
                 * 1. make sure the new slot is null
                 * 2. make the new slot scannable (increment size)
@@ -251,7 +233,7 @@ retry:
                mono_memory_write_barrier ();
                top->size++;
                mono_memory_write_barrier ();
-               *objslot = rawptr;
+               *objslot = obj;
                SET_OWNER (top,idx);
                SET_SP (handles, top, idx);
                return objslot;
@@ -264,9 +246,8 @@ retry:
                handles->top = top;
                goto retry;
        }
-       HandleChunk *new_chunk = g_new (HandleChunk, 1);
+       HandleChunk *new_chunk = new_handle_chunk ();
        new_chunk->size = 0;
-       memset (new_chunk->interior_bitmap, 0, INTERIOR_HANDLE_BITMAP_WORDS);
        new_chunk->prev = top;
        new_chunk->next = NULL;
        /* make sure size == 0 before new chunk is visible */
@@ -276,20 +257,55 @@ retry:
        goto retry;
 }
 
+MonoRawHandle
+#ifndef MONO_HANDLE_TRACK_OWNER
+mono_handle_new_interior (gpointer rawptr)
+#else
+mono_handle_new_interior (gpointer rawptr, const char *owner)
+#endif
+{
+       MonoThreadInfo *info = mono_thread_info_current ();
+       HandleStack *handles = (HandleStack *)info->handle_stack;
+       HandleChunk *top = handles->interior;
+#ifdef MONO_HANDLE_TRACK_SP
+       mono_handle_chunk_leak_check (handles);
+#endif
+
+       g_assert (top);
 
+       /*
+        * Don't extend the chunk now, interior handles are
+        * only used for icall arguments, they shouldn't
+        * overflow.
+        */
+       g_assert (top->size < OBJECTS_PER_HANDLES_CHUNK);
+       int idx = top->size;
+       gpointer *objslot = &top->elems [idx].o;
+       *objslot = NULL;
+       mono_memory_write_barrier ();
+       top->size++;
+       mono_memory_write_barrier ();
+       *objslot = rawptr;
+       SET_OWNER (top,idx);
+       SET_SP (handles, top, idx);
+       return objslot;
+}
 
 HandleStack*
 mono_handle_stack_alloc (void)
 {
-       HandleStack *stack = g_new (HandleStack, 1);
-       HandleChunk *chunk = g_new (HandleChunk, 1);
+       HandleStack *stack = new_handle_stack ();
+       HandleChunk *chunk = new_handle_chunk ();
+       HandleChunk *interior = new_handle_chunk ();
 
-       chunk->size = 0;
-       memset (chunk->interior_bitmap, 0, INTERIOR_HANDLE_BITMAP_WORDS);
        chunk->prev = chunk->next = NULL;
+       chunk->size = 0;
+       interior->prev = interior->next = NULL;
+       interior->size = 0;
        mono_memory_write_barrier ();
        stack->top = stack->bottom = chunk;
-#ifdef MONO_HANDLE_TRACK_OWNER
+       stack->interior = interior;
+#ifdef MONO_HANDLE_TRACK_SP
        stack->stackmark_sp = NULL;
 #endif
        return stack;
@@ -305,11 +321,46 @@ mono_handle_stack_free (HandleStack *stack)
        mono_memory_write_barrier ();
        while (c) {
                HandleChunk *next = c->next;
-               g_free (c);
+               free_handle_chunk (c);
                c = next;
        }
-       g_free (c);
-       g_free (stack);
+       free_handle_chunk (c);
+       free_handle_chunk (stack->interior);
+       free_handle_stack (stack);
+}
+
+void
+mono_handle_stack_free_domain (HandleStack *stack, MonoDomain *domain)
+{
+       /* Called by the GC while clearing out objects of the given domain from the heap. */
+       /* If there are no handles-related bugs, there is nothing to do: if a
+        * thread accessed objects from the domain it was aborted, so any
+        * threads left alive cannot have any handles that point into the
+        * unloading domain.  However if there is a handle leak, the handle stack is not */
+       if (!stack)
+               return;
+       /* Root domain only unloaded when mono is shutting down, don't need to check anything */
+       if (domain == mono_get_root_domain () || mono_runtime_is_shutting_down ())
+               return;
+       HandleChunk *cur = stack->bottom;
+       HandleChunk *last = stack->top;
+       if (!cur)
+               return;
+       while (cur) {
+               for (int idx = 0; idx < cur->size; ++idx) {
+                       HandleChunkElem *elem = &cur->elems[idx];
+                       if (!elem->o)
+                               continue;
+                       g_assert (mono_object_domain (elem->o) != domain);
+               }
+               if (cur == last)
+                       break;
+               cur = cur->next;
+       }
+       /* We don't examine the interior pointers here because the GC treats
+        * them conservatively and anyway we don't have enough information here to
+        * find the object's vtable.
+        */
 }
 
 static void
@@ -362,46 +413,32 @@ mono_handle_stack_scan (HandleStack *stack, GcScanFunc func, gpointer gc_data, g
 
          Note that if we're running, we know the world is stopped.
        */
-       HandleChunk *cur = stack->bottom;
-       HandleChunk *last = stack->top;
+       if (precise) {
+               HandleChunk *cur = stack->bottom;
+               HandleChunk *last = stack->top;
 
-       if (!cur)
-               return;
-
-       while (cur) {
-               /* assume that object pointers will be much more common than interior pointers.
-                * scan the object pointers by iterating over the chunk elements.
-                * scan the interior pointers by iterating over the bitmap bits.
-                */
-               if (precise) {
+               while (cur) {
                        for (int i = 0; i < cur->size; ++i) {
                                HandleChunkElem* elem = chunk_element (cur, i);
-                               int kind = chunk_element_kind (cur, i);
                                gpointer* obj_slot = &elem->o;
-                               if (kind == HANDLE_CHUNK_PTR_OBJ && *obj_slot != NULL)
+                               if (*obj_slot != NULL)
                                        func (obj_slot, gc_data);
                        }
-               } else {
-                       int elem_idx = 0;
-                       for (int i = 0; i < INTERIOR_HANDLE_BITMAP_WORDS; ++i) {
-                               elem_idx = i * INTERIOR_HANDLE_BITMAP_BITS_PER_WORD;
-                               if (elem_idx >= cur->size)
-                                       break;
-                               /* no interior pointers in the range */ 
-                               if (cur->interior_bitmap [i] == 0)
-                                       continue;
-                               for (int j = 0; j < INTERIOR_HANDLE_BITMAP_BITS_PER_WORD && elem_idx < cur->size; ++j,++elem_idx) {
-                                       HandleChunkElem *elem = chunk_element (cur, elem_idx);
-                                       int kind = chunk_element_kind (cur, elem_idx);
-                                       gpointer *ptr_slot = &elem->o;
-                                       if (kind == HANDLE_CHUNK_PTR_INTERIOR && *ptr_slot != NULL)
-                                               func (ptr_slot, gc_data);
-                               }
-                       }            
+                       if (cur == last)
+                               break;
+                       cur = cur->next;
+               }
+       } else {
+               HandleChunk *cur = stack->interior;
+
+               if (!cur)
+                       return;
+               for (int i = 0; i < cur->size; ++i) {
+                       HandleChunkElem* elem = chunk_element (cur, i);
+                       gpointer* ptr_slot = &elem->o;
+                       if (*ptr_slot != NULL)
+                               func (ptr_slot, gc_data);
                }
-               if (cur == last)
-                       break;
-               cur = cur->next;
        }
 }
 
@@ -488,7 +525,6 @@ mono_gchandle_from_handle (MonoObjectHandle handle, mono_bool pinned)
        HandleChunk *chunk = chunk_element_to_chunk_idx (stack, elem, &elem_idx);
        /* gchandles cannot deal with interior pointers */
        g_assert (chunk != NULL);
-       g_assert (chunk_element_kind (chunk, elem_idx) != HANDLE_CHUNK_PTR_INTERIOR);
        return mono_gchandle_new (MONO_HANDLE_RAW (handle), pinned);
 }
 
@@ -507,6 +543,15 @@ mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t idx
        return mono_array_addr_with_size (raw, size, idx);
 }
 
+gunichar2*
+mono_string_handle_pin_chars (MonoStringHandle handle, uint32_t *gchandle)
+{
+       g_assert (gchandle != NULL);
+       *gchandle = mono_gchandle_from_handle (MONO_HANDLE_CAST (MonoObject, handle), TRUE);
+       MonoString *raw = MONO_HANDLE_RAW (handle);
+       return mono_string_chars (raw);
+}
+
 void
 mono_array_handle_memcpy_refs (MonoArrayHandle dest, uintptr_t dest_idx, MonoArrayHandle src, uintptr_t src_idx, uintptr_t len)
 {
index fd6d0cfffee7cbd002523a8a2b2ee1bc06604140..eb3175a4f9aca0d9a7b0ddaa88a78775784f057d 100644 (file)
@@ -25,7 +25,6 @@
 
 G_BEGIN_DECLS
 
-
 /*
 Handle stack.
 
@@ -73,13 +72,8 @@ typedef struct {
 #endif
 } HandleChunkElem;
 
-/* number of guint32's needed to store the interior pointers bitmap */
-#define INTERIOR_HANDLE_BITMAP_WORDS ((OBJECTS_PER_HANDLES_CHUNK + 31) / 32)
-
 struct _HandleChunk {
        int size; //number of handles
-       /* bits in the range 0..size-1 of interior_bitmap are valid; rest are ignored. */
-       guint32 interior_bitmap [INTERIOR_HANDLE_BITMAP_WORDS];
        HandleChunk *prev, *next;
        HandleChunkElem elems [OBJECTS_PER_HANDLES_CHUNK];
 };
@@ -90,10 +84,13 @@ typedef struct {
 #ifdef MONO_HANDLE_TRACK_SP
        gpointer stackmark_sp; // C stack pointer top when from most recent mono_stack_mark_init
 #endif
+       /* Chunk for storing interior pointers. Not extended right now */
+       HandleChunk *interior;
 } HandleStack;
 
+// Keep this in sync with RuntimeStructs.cs
 typedef struct {
-       int size;
+       int size, interior_size;
        HandleChunk *chunk;
 #ifdef MONO_HANDLE_TRACK_SP
        gpointer prev_sp; // C stack pointer from prior mono_stack_mark_init
@@ -108,18 +105,20 @@ typedef void (*GcScanFunc) (gpointer*, gpointer);
 #ifndef MONO_HANDLE_TRACK_OWNER
 MonoRawHandle mono_handle_new (MonoObject *object);
 MonoRawHandle mono_handle_new_full (gpointer rawptr, gboolean interior);
+MonoRawHandle mono_handle_new_interior (gpointer rawptr);
 #else
 MonoRawHandle mono_handle_new (MonoObject *object, const char* owner);
 MonoRawHandle mono_handle_new_full (gpointer rawptr, gboolean interior, const char *owner);
+MonoRawHandle mono_handle_new_interior (gpointer rawptr, const char *owner);
 #endif
 
-
 void mono_handle_stack_scan (HandleStack *stack, GcScanFunc func, gpointer gc_data, gboolean precise);
 gboolean mono_handle_stack_is_empty (HandleStack *stack);
 HandleStack* mono_handle_stack_alloc (void);
 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);
+void mono_handle_stack_free_domain (HandleStack *stack, MonoDomain *domain);
 
 #ifdef MONO_HANDLE_TRACK_SP
 void mono_handle_chunk_leak_check (HandleStack *handles);
@@ -134,6 +133,7 @@ mono_stack_mark_init (MonoThreadInfo *info, HandleStackMark *stackmark)
        HandleStack *handles = (HandleStack *)info->handle_stack;
        stackmark->size = handles->top->size;
        stackmark->chunk = handles->top;
+       stackmark->interior_size = handles->interior->size;
 #ifdef MONO_HANDLE_TRACK_SP
        stackmark->prev_sp = handles->stackmark_sp;
        handles->stackmark_sp = sptop;
@@ -148,6 +148,7 @@ mono_stack_mark_pop (MonoThreadInfo *info, HandleStackMark *stackmark)
        old_top->size = stackmark->size;
        mono_memory_write_barrier ();
        handles->top = old_top;
+       handles->interior->size = stackmark->interior_size;
 #ifdef MONO_HANDLE_TRACK_SP
        mono_memory_write_barrier (); /* write to top before prev_sp */
        handles->stackmark_sp = stackmark->prev_sp;
@@ -403,25 +404,24 @@ This is why we evaluate index and value before any call to MONO_HANDLE_RAW or ot
                mono_handle_array_getref (MONO_HANDLE_CAST(MonoObject, (DEST)), (HANDLE), (IDX)); \
        } while (0)
 
-/* Handles into the interior of objects.
- *
- * Typically when working with value types, we pass them by reference.  In the case where the value type
- * is a field in a managed class, the reference will be a pointer into the middle of a managed object.
- * We need to identify such pointers in order for SGen to scan them correctly.
- */
-
-#ifndef MONO_HANDLE_TRACK_OWNER
-#define MONO_HANDLE_NEW_GET_VALPTR(HANDLE,TYPE,FIELD) (TYPE_VALUE_HANDLE_NAME(TYPE))(mono_handle_new_full (&(HANDLE)->__raw->FIELD), TRUE))
-#else
-#define MONO_HANDLE_NEW_GET_VALPTR(HANDLE,TYPE,FIELD) (TYPE_VALUE_HANDLE_NAME(TYPE))(mono_handle_new_full (&(HANDLE)->__raw->FIELD), TRUE, HANDLE_OWNER_STRINGIFY(__FILE__, __LINE__))
-#endif
-
-
 #define MONO_HANDLE_ASSIGN(DESTH, SRCH)                                \
        mono_handle_assign (MONO_HANDLE_CAST (MonoObject, (DESTH)), MONO_HANDLE_CAST(MonoObject, (SRCH)))
 
 #define MONO_HANDLE_DOMAIN(HANDLE) (mono_object_domain (MONO_HANDLE_RAW (MONO_HANDLE_CAST (MonoObject, HANDLE))))
 
+/* Given an object and a MonoClassField, return the value (must be non-object)
+ * of the field.  It's the caller's responsibility to check that the object is
+ * of the correct class. */
+#define MONO_HANDLE_GET_FIELD_VAL(HANDLE,TYPE,FIELD) *(TYPE *)(mono_handle_unsafe_field_addr (MONO_HANDLE_CAST (MonoObject, (HANDLE)), (FIELD)))
+
+#define MONO_HANDLE_NEW_GET_FIELD(HANDLE,TYPE,FIELD) MONO_HANDLE_NEW (TYPE, *(TYPE**)(mono_handle_unsafe_field_addr (MONO_HANDLE_CAST (MonoObject, (HANDLE)), (FIELD))))
+
+#define MONO_HANDLE_SET_FIELD_VAL(HANDLE,TYPE,FIELD,VAL) do {          \
+               MonoObjectHandle __obj = (HANDLE);                      \
+               MonoClassField *__field = (FIELD);                      \
+               TYPE __value = (VAL);                                   \
+               *(TYPE*)(mono_handle_unsafe_field_addr (__obj, __field)) = __value; \
+       } while (0)
 
 /* Baked typed handles we all want */
 TYPED_HANDLE_DECL (MonoString);
@@ -430,6 +430,12 @@ TYPED_HANDLE_DECL (MonoObject);
 TYPED_HANDLE_DECL (MonoException);
 TYPED_HANDLE_DECL (MonoAppContext);
 
+/* Unfortunately MonoThreadHandle is already a typedef used for something unrelated.  So
+ * the coop handle for MonoThread* is MonoThreadObjectHandle.
+ */
+typedef MonoThread MonoThreadObject;
+TYPED_HANDLE_DECL (MonoThreadObject);
+
 #define NULL_HANDLE_STRING MONO_HANDLE_CAST(MonoString, NULL_HANDLE)
 
 /*
@@ -444,6 +450,13 @@ mono_handle_assign (MonoObjectHandleOut dest, MonoObjectHandle src)
        mono_gc_wbarrier_generic_store (&dest->__raw, src ? MONO_HANDLE_RAW(src) : NULL);
 }
 
+/* It is unsafe to call this function directly - it does not pin the handle!  Use MONO_HANDLE_GET_FIELD_VAL(). */
+static inline gchar*
+mono_handle_unsafe_field_addr (MonoObjectHandle h, MonoClassField *field)
+{
+       return ((gchar *)MONO_HANDLE_RAW (h)) + field->offset;
+}
+
 //FIXME this should go somewhere else
 MonoStringHandle mono_string_new_handle (MonoDomain *domain, const char *data, MonoError *error);
 MonoArrayHandle mono_array_new_handle (MonoDomain *domain, MonoClass *eclass, uintptr_t n, MonoError *error);
@@ -481,6 +494,9 @@ mono_array_handle_pin_with_size (MonoArrayHandle handle, int size, uintptr_t ind
 
 #define MONO_ARRAY_HANDLE_PIN(handle,type,index,gchandle_out) mono_array_handle_pin_with_size (MONO_HANDLE_CAST(MonoArray,(handle)), sizeof (type), (index), (gchandle_out))
 
+gunichar2 *
+mono_string_handle_pin_chars (MonoStringHandle s, uint32_t *gchandle_out);
+
 void
 mono_error_set_exception_handle (MonoError *error, MonoExceptionHandle exc);
 
@@ -490,7 +506,6 @@ mono_context_get_handle (void);
 void
 mono_context_set_handle (MonoAppContextHandle new_context);
 
-
 G_END_DECLS
 
 #endif /* __MONO_HANDLE_H__ */
index b8d6b81b1e76643bf7ea75cdcdfba5500dd831d0..a77e1a7c00ed6589fb4456c37da2838fd4595154 100644 (file)
@@ -207,9 +207,9 @@ ICALL(DECIMAL_13, "ToSingle", mono_decimal_to_float)
 #endif
 
 ICALL_TYPE(DELEGATE, "System.Delegate", DELEGATE_1)
-ICALL(DELEGATE_1, "AllocDelegateLike_internal", ves_icall_System_Delegate_AllocDelegateLike_internal)
-ICALL(DELEGATE_2, "CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal)
-ICALL(DELEGATE_3, "GetVirtualMethod_internal", ves_icall_System_Delegate_GetVirtualMethod_internal)
+HANDLES(ICALL(DELEGATE_1, "AllocDelegateLike_internal", ves_icall_System_Delegate_AllocDelegateLike_internal))
+HANDLES(ICALL(DELEGATE_2, "CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal))
+HANDLES(ICALL(DELEGATE_3, "GetVirtualMethod_internal", ves_icall_System_Delegate_GetVirtualMethod_internal))
 
 ICALL_TYPE(DEBUGR, "System.Diagnostics.Debugger", DEBUGR_1)
 ICALL(DEBUGR_1, "IsAttached_internal", ves_icall_System_Diagnostics_Debugger_IsAttached_internal)
@@ -443,9 +443,9 @@ HANDLES(ICALL(MCATTR_3, "IsDefinedInternal", ves_icall_MonoCustomAttrs_IsDefined
 
 #ifndef DISABLE_SOCKETS
 ICALL_TYPE(NDNS, "System.Net.Dns", NDNS_1)
-ICALL(NDNS_1, "GetHostByAddr_internal(string,string&,string[]&,string[]&,int)", ves_icall_System_Net_Dns_GetHostByAddr_internal)
-ICALL(NDNS_2, "GetHostByName_internal(string,string&,string[]&,string[]&,int)", ves_icall_System_Net_Dns_GetHostByName_internal)
-ICALL(NDNS_3, "GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal)
+HANDLES(ICALL(NDNS_1, "GetHostByAddr_internal(string,string&,string[]&,string[]&,int)", ves_icall_System_Net_Dns_GetHostByAddr_internal))
+HANDLES(ICALL(NDNS_2, "GetHostByName_internal(string,string&,string[]&,string[]&,int)", ves_icall_System_Net_Dns_GetHostByName_internal))
+HANDLES(ICALL(NDNS_3, "GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal))
 
 #if defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD)
 ICALL_TYPE(MAC_IFACE_PROPS, "System.Net.NetworkInformation.MacOsIPInterfaceProperties", MAC_IFACE_PROPS_1)
@@ -453,33 +453,33 @@ ICALL(MAC_IFACE_PROPS_1, "ParseRouteInfo_internal", ves_icall_System_Net_Network
 #endif
 
 ICALL_TYPE(SOCK, "System.Net.Sockets.Socket", SOCK_1)
-ICALL(SOCK_1, "Accept_internal(intptr,int&,bool)", ves_icall_System_Net_Sockets_Socket_Accept_internal)
-ICALL(SOCK_2, "Available_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Available_internal)
-ICALL(SOCK_3, "Bind_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Bind_internal)
-ICALL(SOCK_4, "Blocking_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Blocking_internal)
-ICALL(SOCK_5, "Close_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Close_internal)
-ICALL(SOCK_6, "Connect_internal(intptr,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_Connect_internal)
-ICALL (SOCK_6a, "Disconnect_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Disconnect_internal)
-ICALL(SOCK_7, "GetSocketOption_arr_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,byte[]&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal)
-ICALL(SOCK_8, "GetSocketOption_obj_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal)
-ICALL(SOCK_21, "IOControl_internal(intptr,int,byte[],byte[],int&)", ves_icall_System_Net_Sockets_Socket_IOControl_internal)
-ICALL(SOCK_9, "Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal)
-ICALL(SOCK_10, "LocalEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal)
-ICALL(SOCK_11, "Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal)
-ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal)
-ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal)
-ICALL(SOCK_12, "Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal)
-ICALL(SOCK_14, "RemoteEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal)
-ICALL(SOCK_15, "Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal)
-ICALL(SOCK_15a, "SendFile_internal(intptr,string,byte[],byte[],System.Net.Sockets.TransmitFileOptions,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendFile_internal)
-ICALL(SOCK_16, "SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal)
-ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal)
-ICALL(SOCK_17, "Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal)
-ICALL(SOCK_18, "SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal)
-ICALL(SOCK_19, "Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal)
-ICALL(SOCK_20, "Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal)
-ICALL(SOCK_20a, "SupportsPortReuse", ves_icall_System_Net_Sockets_Socket_SupportPortReuse)
-ICALL(SOCK_21a, "cancel_blocking_socket_operation", icall_cancel_blocking_socket_operation)
+HANDLES(ICALL(SOCK_1, "Accept_internal(intptr,int&,bool)", ves_icall_System_Net_Sockets_Socket_Accept_internal))
+HANDLES(ICALL(SOCK_2, "Available_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Available_internal))
+HANDLES(ICALL(SOCK_3, "Bind_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Bind_internal))
+HANDLES(ICALL(SOCK_4, "Blocking_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Blocking_internal))
+HANDLES(ICALL(SOCK_5, "Close_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Close_internal))
+HANDLES(ICALL(SOCK_6, "Connect_internal(intptr,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_Connect_internal))
+HANDLES(ICALL (SOCK_6a, "Disconnect_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Disconnect_internal))
+HANDLES(ICALL(SOCK_7, "GetSocketOption_arr_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,byte[]&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal))
+HANDLES(ICALL(SOCK_8, "GetSocketOption_obj_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal))
+HANDLES(ICALL(SOCK_21, "IOControl_internal(intptr,int,byte[],byte[],int&)", ves_icall_System_Net_Sockets_Socket_IOControl_internal))
+HANDLES(ICALL(SOCK_9, "Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal))
+HANDLES(ICALL(SOCK_10, "LocalEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal))
+HANDLES(ICALL(SOCK_11, "Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal))
+HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
+HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
+HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
+HANDLES(ICALL(SOCK_14, "RemoteEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal))
+HANDLES(ICALL(SOCK_15, "Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal))
+HANDLES(ICALL(SOCK_15a, "SendFile_internal(intptr,string,byte[],byte[],System.Net.Sockets.TransmitFileOptions,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendFile_internal))
+HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
+HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
+HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
+HANDLES(ICALL(SOCK_18, "SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal))
+HANDLES(ICALL(SOCK_19, "Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal))
+HANDLES(ICALL(SOCK_20, "Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal))
+HANDLES(ICALL(SOCK_20a, "SupportsPortReuse", ves_icall_System_Net_Sockets_Socket_SupportPortReuse))
+HANDLES(ICALL(SOCK_21a, "cancel_blocking_socket_operation", icall_cancel_blocking_socket_operation))
 
 ICALL_TYPE(SOCKEX, "System.Net.Sockets.SocketException", SOCKEX_1)
 ICALL(SOCKEX_1, "WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal)
@@ -683,8 +683,8 @@ ICALL(MARSHAL_7, "FreeHGlobal", ves_icall_System_Runtime_InteropServices_Marshal
 ICALL(MARSHAL_44, "GetCCW", ves_icall_System_Runtime_InteropServices_Marshal_GetCCW)
 ICALL(MARSHAL_8, "GetComSlotForMethodInfoInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal)
 #endif
-ICALL(MARSHAL_9, "GetDelegateForFunctionPointerInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal)
-ICALL(MARSHAL_10, "GetFunctionPointerForDelegateInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal)
+HANDLES(ICALL(MARSHAL_9, "GetDelegateForFunctionPointerInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal))
+HANDLES(ICALL(MARSHAL_10, "GetFunctionPointerForDelegateInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal))
 #ifndef DISABLE_COM
 ICALL(MARSHAL_52, "GetHRForException_WinRT", ves_icall_System_Runtime_InteropServices_Marshal_GetHRForException_WinRT)
 ICALL(MARSHAL_45, "GetIDispatchForObjectInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetIDispatchForObjectInternal)
@@ -697,9 +697,9 @@ ICALL(MARSHAL_47, "GetObjectForCCW", ves_icall_System_Runtime_InteropServices_Ma
 ICALL(MARSHAL_54, "GetRawIUnknownForComObjectNoAddRef", ves_icall_System_Runtime_InteropServices_Marshal_GetRawIUnknownForComObjectNoAddRef)
 ICALL(MARSHAL_48, "IsComObject", ves_icall_System_Runtime_InteropServices_Marshal_IsComObject)
 #endif
-ICALL(MARSHAL_12, "OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf)
-ICALL(MARSHAL_13, "Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink)
-ICALL(MARSHAL_14, "PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll)
+HANDLES(ICALL(MARSHAL_12, "OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf))
+HANDLES(ICALL(MARSHAL_13, "Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink))
+HANDLES(ICALL(MARSHAL_14, "PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll))
 HANDLES(ICALL(MARSHAL_15, "PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi))
 ICALL(MARSHAL_16, "PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len)
 ICALL(MARSHAL_17, "PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR)
@@ -716,7 +716,7 @@ ICALL(MARSHAL_23, "ReAllocHGlobal", ves_icall_System_Runtime_InteropServices_Mar
 ICALL(MARSHAL_49, "ReleaseComObjectInternal", ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal)
 ICALL(MARSHAL_29, "ReleaseInternal", ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal)
 #endif
-ICALL(MARSHAL_30, "SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf)
+HANDLES(ICALL(MARSHAL_30, "SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf))
 ICALL(MARSHAL_31, "StringToBSTR", ves_icall_System_Runtime_InteropServices_Marshal_StringToBSTR)
 ICALL(MARSHAL_32, "StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi)
 ICALL(MARSHAL_33, "StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni)
@@ -737,8 +737,8 @@ ICALL(WINDOWSRUNTIME_UNM_5, "WindowsGetStringRawBuffer", ves_icall_System_Runtim
 #endif
 
 ICALL_TYPE(ACTS, "System.Runtime.Remoting.Activation.ActivationServices", ACTS_1)
-ICALL(ACTS_1, "AllocateUninitializedClassInstance", ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance)
-ICALL(ACTS_2, "EnableProxyActivation", ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation)
+HANDLES(ICALL(ACTS_1, "AllocateUninitializedClassInstance", ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance))
+HANDLES(ICALL(ACTS_2, "EnableProxyActivation", ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation))
 
 ICALL_TYPE(CONTEXT, "System.Runtime.Remoting.Contexts.Context", CONTEXT_1)
 HANDLES(ICALL(CONTEXT_1, "RegisterContext", ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext))
@@ -753,9 +753,9 @@ ICALL(REALP_1, "InternalGetProxyType", ves_icall_Remoting_RealProxy_InternalGetP
 HANDLES(ICALL(REALP_2, "InternalGetTransparentProxy", ves_icall_Remoting_RealProxy_GetTransparentProxy))
 
 ICALL_TYPE(REMSER, "System.Runtime.Remoting.RemotingServices", REMSER_0)
-ICALL(REMSER_0, "GetVirtualMethod", ves_icall_Remoting_RemotingServices_GetVirtualMethod)
+HANDLES(ICALL(REMSER_0, "GetVirtualMethod", ves_icall_Remoting_RemotingServices_GetVirtualMethod))
 ICALL(REMSER_1, "InternalExecute", ves_icall_InternalExecute)
-ICALL(REMSER_2, "IsTransparentProxy", ves_icall_IsTransparentProxy)
+HANDLES(ICALL(REMSER_2, "IsTransparentProxy", ves_icall_IsTransparentProxy))
 #endif
 
 ICALL_TYPE(RVH, "System.Runtime.Versioning.VersioningHelper", RVH_1)
@@ -912,14 +912,14 @@ ICALL(MONIT_7, "Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait)
 ICALL(MONIT_9, "try_enter_with_atomic_var", ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var)
 
 ICALL_TYPE(MUTEX, "System.Threading.Mutex", MUTEX_1)
-ICALL(MUTEX_1, "CreateMutex_internal(bool,string,bool&)", ves_icall_System_Threading_Mutex_CreateMutex_internal)
-ICALL(MUTEX_2, "OpenMutex_internal(string,System.Security.AccessControl.MutexRights,System.IO.MonoIOError&)", ves_icall_System_Threading_Mutex_OpenMutex_internal)
+HANDLES(ICALL(MUTEX_1, "CreateMutex_internal(bool,string,bool&)", ves_icall_System_Threading_Mutex_CreateMutex_internal))
+HANDLES(ICALL(MUTEX_2, "OpenMutex_internal(string,System.Security.AccessControl.MutexRights,System.IO.MonoIOError&)", ves_icall_System_Threading_Mutex_OpenMutex_internal))
 ICALL(MUTEX_3, "ReleaseMutex_internal(intptr)", ves_icall_System_Threading_Mutex_ReleaseMutex_internal)
 
 ICALL_TYPE(NATIVEC, "System.Threading.NativeEventCalls", NATIVEC_1)
 ICALL(NATIVEC_1, "CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal)
-ICALL(NATIVEC_2, "CreateEvent_internal(bool,bool,string,int&)", ves_icall_System_Threading_Events_CreateEvent_internal)
-ICALL(NATIVEC_3, "OpenEvent_internal(string,System.Security.AccessControl.EventWaitHandleRights,int&)", ves_icall_System_Threading_Events_OpenEvent_internal)
+HANDLES(ICALL(NATIVEC_2, "CreateEvent_internal(bool,bool,string,int&)", ves_icall_System_Threading_Events_CreateEvent_internal))
+HANDLES(ICALL(NATIVEC_3, "OpenEvent_internal(string,System.Security.AccessControl.EventWaitHandleRights,int&)", ves_icall_System_Threading_Events_OpenEvent_internal))
 ICALL(NATIVEC_4, "ResetEvent_internal",  ves_icall_System_Threading_Events_ResetEvent_internal)
 ICALL(NATIVEC_5, "SetEvent_internal",    ves_icall_System_Threading_Events_SetEvent_internal)
 
index 67acdcb521040d6570080ebe4d068ba3bae0648e..756f58f8062a0fe4032498e136eb6a9c94968924 100644 (file)
@@ -3295,110 +3295,123 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this_arg, Mo
 }
 
 #ifndef DISABLE_REMOTING
-ICALL_EXPORT MonoObject *
-ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this_arg, MonoArray *params, MonoArray **outArgs) 
+static void
+internal_execute_field_getter (MonoDomain *domain, MonoObject *this_arg, MonoArray *params, MonoArray **outArgs, MonoError *error)
 {
-       MonoError error;
-       MonoDomain *domain = mono_object_domain (method); 
-       MonoMethod *m = method->method;
-       MonoMethodSignature *sig = mono_method_signature (m);
+       error_init (error);
        MonoArray *out_args;
-       MonoObject *result;
-       int i, j, outarg_count = 0;
-
-       if (m->klass == mono_defaults.object_class) {
-               if (!strcmp (m->name, "FieldGetter")) {
-                       MonoClass *k = mono_object_class (this_arg);
-                       MonoString *name;
-                       char *str;
+       MonoClass *k = mono_object_class (this_arg);
+       MonoString *name;
+       char *str;
                        
-                       /* If this is a proxy, then it must be a CBO */
-                       if (mono_class_is_transparent_proxy (k)) {
-                               MonoTransparentProxy *tp = (MonoTransparentProxy*) this_arg;
-                               this_arg = tp->rp->unwrapped_server;
-                               g_assert (this_arg);
-                               k = mono_object_class (this_arg);
-                       }
+       /* If this is a proxy, then it must be a CBO */
+       if (mono_class_is_transparent_proxy (k)) {
+               MonoTransparentProxy *tp = (MonoTransparentProxy*) this_arg;
+               this_arg = tp->rp->unwrapped_server;
+               g_assert (this_arg);
+               k = mono_object_class (this_arg);
+       }
                        
-                       name = mono_array_get (params, MonoString *, 1);
-                       str = mono_string_to_utf8_checked (name, &error);
-                       if (mono_error_set_pending_exception (&error))
-                               return NULL;
+       name = mono_array_get (params, MonoString *, 1);
+       str = mono_string_to_utf8_checked (name, error);
+       return_if_nok (error);
                
-                       do {
-                               MonoClassField* field = mono_class_get_field_from_name (k, str);
-                               if (field) {
-                                       g_free (str);
-                                       MonoClass *field_klass =  mono_class_from_mono_type (field->type);
-                                       if (field_klass->valuetype) {
-                                               result = mono_value_box_checked (domain, field_klass, (char *)this_arg + field->offset, &error);
-                                               if (mono_error_set_pending_exception (&error))
-                                                       return NULL;
-                                       } else 
-                                               result = (MonoObject *)*((gpointer *)((char *)this_arg + field->offset));
-                               
-                                       out_args = mono_array_new_checked (domain, mono_defaults.object_class, 1, &error);
-                                       if (mono_error_set_pending_exception (&error))
-                                               return NULL;
-                                       mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
-                                       mono_array_setref (out_args, 0, result);
-                                       return NULL;
-                               }
-                               k = k->parent;
-                       } while (k);
-
+       do {
+               MonoClassField* field = mono_class_get_field_from_name (k, str);
+               if (field) {
                        g_free (str);
-                       g_assert_not_reached ();
+                       MonoClass *field_klass =  mono_class_from_mono_type (field->type);
+                       MonoObject *result;
+                       if (field_klass->valuetype) {
+                               result = mono_value_box_checked (domain, field_klass, (char *)this_arg + field->offset, error);
+                               return_if_nok (error);
+                       } else 
+                               result = (MonoObject *)*((gpointer *)((char *)this_arg + field->offset));
+
+                       out_args = mono_array_new_checked (domain, mono_defaults.object_class, 1, error);
+                       return_if_nok (error);
+                       mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
+                       mono_array_setref (out_args, 0, result);
+                       return;
+               }
+               k = k->parent;
+       } while (k);
 
-               } else if (!strcmp (m->name, "FieldSetter")) {
-                       MonoClass *k = mono_object_class (this_arg);
-                       MonoString *name;
-                       guint32 size;
-                       gint32 align;
-                       char *str;
+       g_free (str);
+       g_assert_not_reached ();
+}
+
+static void
+internal_execute_field_setter (MonoDomain *domain, MonoObject *this_arg, MonoArray *params, MonoArray **outArgs, MonoError *error)
+{
+       error_init (error);
+       MonoArray *out_args;
+       MonoClass *k = mono_object_class (this_arg);
+       MonoString *name;
+       guint32 size;
+       gint32 align;
+       char *str;
                        
-                       /* If this is a proxy, then it must be a CBO */
-                       if (mono_class_is_transparent_proxy (k)) {
-                               MonoTransparentProxy *tp = (MonoTransparentProxy*) this_arg;
-                               this_arg = tp->rp->unwrapped_server;
-                               g_assert (this_arg);
-                               k = mono_object_class (this_arg);
-                       }
+       /* If this is a proxy, then it must be a CBO */
+       if (mono_class_is_transparent_proxy (k)) {
+               MonoTransparentProxy *tp = (MonoTransparentProxy*) this_arg;
+               this_arg = tp->rp->unwrapped_server;
+               g_assert (this_arg);
+               k = mono_object_class (this_arg);
+       }
                        
-                       name = mono_array_get (params, MonoString *, 1);
-                       str = mono_string_to_utf8_checked (name, &error);
-                       if (mono_error_set_pending_exception (&error))
-                               return NULL;
+       name = mono_array_get (params, MonoString *, 1);
+       str = mono_string_to_utf8_checked (name, error);
+       return_if_nok (error);
                
-                       do {
-                               MonoClassField* field = mono_class_get_field_from_name (k, str);
-                               if (field) {
-                                       g_free (str);
-                                       MonoClass *field_klass =  mono_class_from_mono_type (field->type);
-                                       MonoObject *val = (MonoObject *)mono_array_get (params, gpointer, 2);
-
-                                       if (field_klass->valuetype) {
-                                               size = mono_type_size (field->type, &align);
-                                               g_assert (size == mono_class_value_size (field_klass, NULL));
-                                               mono_gc_wbarrier_value_copy ((char *)this_arg + field->offset, (char*)val + sizeof (MonoObject), 1, field_klass);
-                                       } else {
-                                               mono_gc_wbarrier_set_field (this_arg, (char*)this_arg + field->offset, val);
-                                       }
-                               
-                                       out_args = mono_array_new_checked (domain, mono_defaults.object_class, 0, &error);
-                                       if (mono_error_set_pending_exception (&error))
-                                               return NULL;
-                                       mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
+       do {
+               MonoClassField* field = mono_class_get_field_from_name (k, str);
+               if (field) {
+                       g_free (str);
+                       MonoClass *field_klass =  mono_class_from_mono_type (field->type);
+                       MonoObject *val = (MonoObject *)mono_array_get (params, gpointer, 2);
 
-                                       return NULL;
-                               }
+                       if (field_klass->valuetype) {
+                               size = mono_type_size (field->type, &align);
+                               g_assert (size == mono_class_value_size (field_klass, NULL));
+                               mono_gc_wbarrier_value_copy ((char *)this_arg + field->offset, (char*)val + sizeof (MonoObject), 1, field_klass);
+                       } else {
+                               mono_gc_wbarrier_set_field (this_arg, (char*)this_arg + field->offset, val);
+                       }
+
+                       out_args = mono_array_new_checked (domain, mono_defaults.object_class, 0, error);
+                       return_if_nok (error);
+                       mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
+                       return;
+               }
                                
-                               k = k->parent;
-                       } while (k);
+               k = k->parent;
+       } while (k);
 
-                       g_free (str);
-                       g_assert_not_reached ();
+       g_free (str);
+       g_assert_not_reached ();
+}
+
+ICALL_EXPORT MonoObject *
+ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this_arg, MonoArray *params, MonoArray **outArgs) 
+{
+       MonoError error;
+       MonoDomain *domain = mono_object_domain (method); 
+       MonoMethod *m = method->method;
+       MonoMethodSignature *sig = mono_method_signature (m);
+       MonoArray *out_args;
+       MonoObject *result;
+       int i, j, outarg_count = 0;
 
+       if (m->klass == mono_defaults.object_class) {
+               if (!strcmp (m->name, "FieldGetter")) {
+                       internal_execute_field_getter (domain, this_arg, params, outArgs, &error);
+                       mono_error_set_pending_exception (&error);
+                       return NULL;
+               } else if (!strcmp (m->name, "FieldSetter")) {
+                       internal_execute_field_setter (domain, this_arg, params, outArgs, &error);
+                       mono_error_set_pending_exception (&error);
+                       return NULL;
                }
        }
 
@@ -6170,99 +6183,92 @@ ves_icall_RuntimeType_MakePointerType (MonoReflectionTypeHandle ref_type, MonoEr
        return mono_type_get_object_handle (domain, &pklass->byval_arg, error);
 }
 
-ICALL_EXPORT MonoObject *
-ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target,
-                                                  MonoReflectionMethod *info, MonoBoolean throwOnBindFailure)
+ICALL_EXPORT MonoObjectHandle
+ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionTypeHandle ref_type, MonoObjectHandle target,
+                                                  MonoReflectionMethodHandle info, MonoBoolean throwOnBindFailure, MonoError *error)
 {
-       MonoError error;
-       MonoClass *delegate_class = mono_class_from_mono_type (type->type);
-       MonoObject *delegate;
+       MonoType *type = MONO_HANDLE_GETVAL (ref_type, type);
+       MonoClass *delegate_class = mono_class_from_mono_type (type);
        gpointer func;
-       MonoMethod *method = info->method;
+       MonoMethod *method = MONO_HANDLE_GETVAL (info, method);
        MonoMethodSignature *sig = mono_method_signature(method);
 
-       mono_class_init_checked (delegate_class, &error);
-       if (mono_error_set_pending_exception (&error))
-               return NULL;
+       mono_class_init_checked (delegate_class, error);
+       return_val_if_nok (error, NULL_HANDLE);
 
        if (!(delegate_class->parent == mono_defaults.multicastdelegate_class)) {
                /* FIXME improve this exception message */
-               mono_error_set_execution_engine (&error, "file %s: line %d (%s): assertion failed: (%s)", __FILE__, __LINE__,
+               mono_error_set_execution_engine (error, "file %s: line %d (%s): assertion failed: (%s)", __FILE__, __LINE__,
                                                 __func__,
                                                 "delegate_class->parent == mono_defaults.multicastdelegate_class");
-               mono_error_set_pending_exception (&error);
-               return NULL;
+               return NULL_HANDLE;
        }
 
        if (mono_security_core_clr_enabled ()) {
-               if (!mono_security_core_clr_ensure_delegate_creation (method, &error)) {
+               MonoError security_error;
+               if (!mono_security_core_clr_ensure_delegate_creation (method, &security_error)) {
                        if (throwOnBindFailure)
-                               mono_error_set_pending_exception (&error);
+                               mono_error_move (error, &security_error);
                        else
-                               mono_error_cleanup (&error);
-                       return NULL;
+                               mono_error_cleanup (&security_error);
+                       return NULL_HANDLE;
                }
        }
 
        if (sig->generic_param_count && method->wrapper_type == MONO_WRAPPER_NONE) {
                if (!method->is_inflated) {
-                       mono_set_pending_exception(mono_get_exception_argument("method", " Cannot bind to the target method because its signature differs from that of the delegate type"));
-                       return NULL;
+                       mono_error_set_argument (error, "method", " Cannot bind to the target method because its signature differs from that of the delegate type");
+                       return NULL_HANDLE;
                }
        }
 
-       delegate = mono_object_new_checked (mono_object_domain (type), delegate_class, &error);
-       if (mono_error_set_pending_exception (&error))
-               return NULL;
+       MonoObjectHandle delegate = MONO_HANDLE_NEW (MonoObject, mono_object_new_checked (MONO_HANDLE_DOMAIN (ref_type), delegate_class, error));
+       return_val_if_nok (error, NULL_HANDLE);
 
        if (method_is_dynamic (method)) {
                /* Creating a trampoline would leak memory */
-               func = mono_compile_method_checked (method, &error);
-               if (mono_error_set_pending_exception (&error))
-                       return NULL;
+               func = mono_compile_method_checked (method, error);
+               return_val_if_nok (error, NULL_HANDLE);
        } else {
-               if (target && method->flags & METHOD_ATTRIBUTE_VIRTUAL && method->klass != mono_object_class (target))
-                       method = mono_object_get_virtual_method (target, method);
-               gpointer trampoline = mono_runtime_create_jump_trampoline (mono_domain_get (), method, TRUE, &error);
-               if (mono_error_set_pending_exception (&error))
-                       return NULL;
+               if (!MONO_HANDLE_IS_NULL (target) && method->flags & METHOD_ATTRIBUTE_VIRTUAL && method->klass != mono_handle_class (target)) {
+                       method = mono_object_handle_get_virtual_method (target, method, error);
+                       return_val_if_nok (error, NULL_HANDLE);
+               }
+               gpointer trampoline = mono_runtime_create_jump_trampoline (mono_domain_get (), method, TRUE, error);
+               return_val_if_nok (error, NULL_HANDLE);
                func = mono_create_ftnptr (mono_domain_get (), trampoline);
        }
 
-       mono_delegate_ctor_with_method (delegate, target, func, method, &error);
-       if (mono_error_set_pending_exception (&error))
-               return NULL;
+       mono_delegate_ctor_with_method (delegate, target, func, method, error);
+       return_val_if_nok (error, NULL_HANDLE);
        return delegate;
 }
 
-ICALL_EXPORT MonoMulticastDelegate *
-ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegate *delegate)
+ICALL_EXPORT MonoMulticastDelegateHandle
+ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegateHandle delegate, MonoError *error)
 {
-       MonoError error;
-       MonoMulticastDelegate *ret;
+       error_init (error);
 
-       g_assert (mono_class_has_parent (mono_object_class (delegate), mono_defaults.multicastdelegate_class));
+       MonoClass *klass = mono_handle_class (delegate);
+       g_assert (mono_class_has_parent (klass, mono_defaults.multicastdelegate_class));
 
-       ret = (MonoMulticastDelegate*) mono_object_new_checked (mono_object_domain (delegate), mono_object_class (delegate), &error);
-       if (mono_error_set_pending_exception (&error))
-               return NULL;
+       MonoMulticastDelegateHandle ret = MONO_HANDLE_NEW (MonoMulticastDelegate,  mono_object_new_checked (MONO_HANDLE_DOMAIN (delegate), klass, error));
+       return_val_if_nok (error, MONO_HANDLE_CAST (MonoMulticastDelegate, NULL_HANDLE));
 
-       ret->delegate.invoke_impl = mono_runtime_create_delegate_trampoline (mono_object_class (delegate));
+       MONO_HANDLE_SETVAL (MONO_HANDLE_CAST (MonoDelegate, ret), invoke_impl, gpointer, mono_runtime_create_delegate_trampoline (klass));
 
        return ret;
 }
 
-ICALL_EXPORT MonoReflectionMethod*
-ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegate *delegate)
+ICALL_EXPORT MonoReflectionMethodHandle
+ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegateHandle delegate, MonoError *error)
 {
-       MonoReflectionMethod *ret = NULL;
-       MonoError error;
-       MonoMethod *m;
+       error_init (error);
 
-       m = mono_object_get_virtual_method (delegate->target, delegate->method);
-       ret = mono_method_get_object_checked (mono_domain_get (), m, m->klass, &error);
-       mono_error_set_pending_exception (&error);
-       return ret;
+       MonoObjectHandle delegate_target = MONO_HANDLE_NEW_GET (MonoObject, delegate, target);
+       MonoMethod *m = mono_object_handle_get_virtual_method (delegate_target, MONO_HANDLE_GETVAL (delegate, method), error);
+       return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE));
+       return mono_method_get_object_handle (mono_domain_get (), m, m->klass, error);
 }
 
 /* System.Buffer */
@@ -6670,11 +6676,6 @@ ves_icall_System_Environment_Exit (int result)
 {
        mono_environment_exitcode_set (result);
 
-/* FIXME: There are some cleanup hangs that should be worked out, but
- * if the program is going to exit, everything will be cleaned up when
- * NaCl exits anyway.
- */
-#ifndef __native_client__
        if (!mono_runtime_try_shutdown ())
                mono_thread_exit ();
 
@@ -6682,7 +6683,6 @@ ves_icall_System_Environment_Exit (int result)
        mono_thread_suspend_all_other_threads ();
 
        mono_runtime_quit ();
-#endif
 
        /* we may need to do some cleanup here... */
        exit (result);
@@ -6918,54 +6918,56 @@ ves_icall_System_Runtime_Versioning_VersioningHelper_GetRuntimeId (void)
 
 #ifndef DISABLE_REMOTING
 ICALL_EXPORT MonoBoolean
-ves_icall_IsTransparentProxy (MonoObject *proxy)
+ves_icall_IsTransparentProxy (MonoObjectHandle proxy, MonoError *error)
 {
-       if (!proxy)
+       error_init (error);
+       if (MONO_HANDLE_IS_NULL (proxy))
                return 0;
 
-       if (mono_object_is_transparent_proxy (proxy))
+       if (mono_class_is_transparent_proxy (mono_handle_class (proxy)))
                return 1;
 
        return 0;
 }
 
-ICALL_EXPORT MonoReflectionMethod *
+ICALL_EXPORT MonoReflectionMethodHandle
 ves_icall_Remoting_RemotingServices_GetVirtualMethod (
-       MonoReflectionType *rtype, MonoReflectionMethod *rmethod)
+       MonoReflectionTypeHandle rtype, MonoReflectionMethodHandle rmethod, MonoError *error)
 {
-       MonoReflectionMethod *ret = NULL;
-       MonoError error;
-
-       MonoClass *klass;
-       MonoMethod *method;
-       MonoMethod **vtable;
-       MonoMethod *res = NULL;
+       MonoReflectionMethodHandle ret = MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE);
 
-       MONO_CHECK_ARG_NULL (rtype, NULL);
-       MONO_CHECK_ARG_NULL (rmethod, NULL);
+       error_init (error);
+       if (MONO_HANDLE_IS_NULL (rtype)) {
+               mono_error_set_argument_null (error, "type", "");
+               return ret;
+       }
+       if (MONO_HANDLE_IS_NULL (rmethod)) {
+               mono_error_set_argument_null (error, "method", "");
+               return ret;
+       }
 
-       method = rmethod->method;
-       klass = mono_class_from_mono_type (rtype->type);
-       mono_class_init_checked (klass, &error);
-       if (mono_error_set_pending_exception (&error))
-               return NULL;
+       MonoMethod *method = MONO_HANDLE_GETVAL (rmethod, method);
+       MonoType *type = MONO_HANDLE_GETVAL (rtype, type);
+       MonoClass *klass = mono_class_from_mono_type (type);
+       mono_class_init_checked (klass, error);
+       return_val_if_nok (error, ret);
 
        if (MONO_CLASS_IS_INTERFACE (klass))
-               return NULL;
+               return ret;
 
        if (method->flags & METHOD_ATTRIBUTE_STATIC)
-               return NULL;
+               return ret;
 
        if ((method->flags & METHOD_ATTRIBUTE_FINAL) || !(method->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
                if (klass == method->klass || mono_class_is_subclass_of (klass, method->klass, FALSE))
-                       return rmethod;
-               else
-                       return NULL;
+                       ret = rmethod;
+               return ret;
        }
 
        mono_class_setup_vtable (klass);
-       vtable = klass->vtable;
+       MonoMethod **vtable = klass->vtable;
 
+       MonoMethod *res = NULL;
        if (mono_class_is_interface (method->klass)) {
                gboolean variance_used = FALSE;
                /*MS fails with variant interfaces but it's the right thing to do anyway.*/
@@ -6974,33 +6976,27 @@ ves_icall_Remoting_RemotingServices_GetVirtualMethod (
                        res = vtable [offs + method->slot];
        } else {
                if (!(klass == method->klass || mono_class_is_subclass_of (klass, method->klass, FALSE)))
-                       return NULL;
+                       return ret;
 
                if (method->slot != -1)
                        res = vtable [method->slot];
        }
 
        if (!res)
-               return NULL;
+               return ret;
 
-       ret = mono_method_get_object_checked (mono_domain_get (), res, NULL, &error);
-       mono_error_set_pending_exception (&error);
+       ret = mono_method_get_object_handle (mono_domain_get (), res, NULL, error);
        return ret;
 }
 
 ICALL_EXPORT void
-ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable)
+ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionTypeHandle type, MonoBoolean enable, MonoError *error)
 {
-       MonoError error;
-       MonoClass *klass;
-       MonoVTable* vtable;
+       error_init (error);
 
-       klass = mono_class_from_mono_type (type->type);
-       vtable = mono_class_vtable_full (mono_domain_get (), klass, &error);
-       if (!is_ok (&error)) {
-               mono_error_set_pending_exception (&error);
-               return;
-       }
+       MonoClass *klass = mono_class_from_mono_type (MONO_HANDLE_GETVAL (type, type));
+       MonoVTable *vtable = mono_class_vtable_full (mono_domain_get (), klass, error);
+       return_if_nok (error);
 
        mono_vtable_set_is_remote (vtable, enable);
 }
@@ -7008,48 +7004,38 @@ ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (Mo
 #else /* DISABLE_REMOTING */
 
 ICALL_EXPORT void
-ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable)
+ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionTypeHandle type, MonoBoolean enable, MonoError *error)
 {
+       error_init (error);
        g_assert_not_reached ();
 }
 
 #endif
 
-ICALL_EXPORT MonoObject *
-ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType *type)
+ICALL_EXPORT MonoObjectHandle
+ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionTypeHandle type, MonoError *error)
 {
-       MonoError error;
-       MonoClass *klass;
-       MonoDomain *domain;
-       MonoObject *ret;
+       error_init (error);
        
-       domain = mono_object_domain (type);
-       klass = mono_class_from_mono_type (type->type);
-       mono_class_init_checked (klass, &error);
-       if (mono_error_set_pending_exception (&error))
-               return NULL;
+       MonoDomain *domain = MONO_HANDLE_DOMAIN (type);
+       MonoClass *klass = mono_class_from_mono_type (MONO_HANDLE_GETVAL (type, type));
+       mono_class_init_checked (klass, error);
+       return_val_if_nok (error, NULL_HANDLE);
 
        if (MONO_CLASS_IS_INTERFACE (klass) || mono_class_is_abstract (klass)) {
-               mono_set_pending_exception (mono_get_exception_argument ("type", "Type cannot be instantiated"));
-               return NULL;
+               mono_error_set_argument (error, "type", "Type cannot be instantiated");
+               return NULL_HANDLE;
        }
 
        if (klass->rank >= 1) {
                g_assert (klass->rank == 1);
-               ret = (MonoObject *) mono_array_new_checked (domain, klass->element_class, 0, &error);
-               mono_error_set_pending_exception (&error);
-               return ret;
+               return MONO_HANDLE_CAST (MonoObject, mono_array_new_handle (domain, klass->element_class, 0, error));
        } else {
-               MonoVTable *vtable = mono_class_vtable_full (domain, klass, &error);
-               if (!is_ok (&error)) {
-                       mono_error_set_pending_exception (&error);
-                       return NULL;
-               }
-               /* Bypass remoting object creation check */
-               ret = mono_object_new_alloc_specific_checked (vtable, &error);
-               mono_error_set_pending_exception (&error);
+               MonoVTable *vtable = mono_class_vtable_full (domain, klass, error);
+               return_val_if_nok (error, NULL_HANDLE);
 
-               return ret;
+               /* Bypass remoting object creation check */
+               return MONO_HANDLE_NEW (MonoObject, mono_object_new_alloc_specific_checked (vtable, error));
        }
 }
 
@@ -7373,12 +7359,6 @@ mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter)
        iter->args = (guint8*)(((gsize)iter->args + (align) - 1) & ~(align - 1));
 #endif
        res.value = iter->args;
-#if defined(__native_client__) && SIZEOF_REGISTER == 8
-       /* Values are stored as 8 byte register sized objects, but 'value'
-        * is dereferenced as a pointer in other routines.
-        */
-       res.value = (char*)res.value + 4;
-#endif
 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
        if (arg_size <= sizeof (gpointer)) {
                int dummy;
@@ -7508,38 +7488,34 @@ prelink_method (MonoMethod *method, MonoError *error)
                return;
        mono_lookup_pinvoke_call (method, &exc_class, &exc_arg);
        if (exc_class) {
-               mono_error_set_exception_instance (error,
-                       mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg));
+               mono_error_set_generic_error (error, "System", exc_class, "%s", exc_arg);
                return;
        }
        /* create the wrapper, too? */
 }
 
 ICALL_EXPORT void
-ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod *method)
+ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethodHandle method, MonoError *error)
 {
-       MonoError error;
+       error_init (error);
 
-       prelink_method (method->method, &error);
-       mono_error_set_pending_exception (&error);
+       prelink_method (MONO_HANDLE_GETVAL (method, method), error);
 }
 
 ICALL_EXPORT void
-ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType *type)
+ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionTypeHandle type, MonoError *error)
 {
-       MonoError error;
-       MonoClass *klass = mono_class_from_mono_type (type->type);
+       error_init (error);
+       MonoClass *klass = mono_class_from_mono_type (MONO_HANDLE_GETVAL (type, type));
        MonoMethod* m;
        gpointer iter = NULL;
 
-       mono_class_init_checked (klass, &error);
-       if (mono_error_set_pending_exception (&error))
-               return;
+       mono_class_init_checked (klass, error);
+       return_if_nok (error);
 
        while ((m = mono_class_get_methods (klass, &iter))) {
-               prelink_method (m, &error);
-               if (mono_error_set_pending_exception (&error))
-                       return;
+               prelink_method (m, error);
+               return_if_nok (error);
        }
 }
 
index cf9992615e836ad1ce9f8c074b9dfef1f59d5d7f..085fb67a3759d029dbfafca2fab6a61251d04c7c 100644 (file)
@@ -62,21 +62,7 @@ static MonoJitInfoFindInAot jit_info_find_in_aot_func = NULL;
 static int
 jit_info_table_num_elements (MonoJitInfoTable *table)
 {
-       int i;
-       int num_elements = 0;
-
-       for (i = 0; i < table->num_chunks; ++i) {
-               MonoJitInfoTableChunk *chunk = table->chunks [i];
-               int chunk_num_elements = chunk->num_elements;
-               int j;
-
-               for (j = 0; j < chunk_num_elements; ++j) {
-                       if (!IS_JIT_INFO_TOMBSTONE (chunk->data [j]))
-                               ++num_elements;
-               }
-       }
-
-       return num_elements;
+       return table->num_valid;
 }
 
 static MonoJitInfoTableChunk*
@@ -96,6 +82,7 @@ mono_jit_info_table_new (MonoDomain *domain)
        table->domain = domain;
        table->num_chunks = 1;
        table->chunks [0] = jit_info_table_new_chunk ();
+       table->num_valid = 0;
 
        return table;
 }
@@ -397,6 +384,7 @@ jit_info_table_realloc (MonoJitInfoTable *old)
        result = (MonoJitInfoTable *)g_malloc (MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * num_chunks);
        result->domain = old->domain;
        result->num_chunks = num_chunks;
+       result->num_valid = old->num_valid;
 
        for (i = 0; i < num_chunks; ++i)
                result->chunks [i] = jit_info_table_new_chunk ();
@@ -469,6 +457,7 @@ jit_info_table_copy_and_split_chunk (MonoJitInfoTable *table, MonoJitInfoTableCh
 
        new_table->domain = table->domain;
        new_table->num_chunks = table->num_chunks + 1;
+       new_table->num_valid = table->num_valid;
 
        j = 0;
        for (i = 0; i < table->num_chunks; ++i) {
@@ -517,6 +506,7 @@ jit_info_table_copy_and_purify_chunk (MonoJitInfoTable *table, MonoJitInfoTableC
 
        new_table->domain = table->domain;
        new_table->num_chunks = table->num_chunks;
+       new_table->num_valid = table->num_valid;
 
        j = 0;
        for (i = 0; i < table->num_chunks; ++i) {
@@ -651,6 +641,8 @@ jit_info_table_add (MonoDomain *domain, MonoJitInfoTable *volatile *table_ptr, M
        chunk->last_code_end = (gint8*)chunk->data [chunk->num_elements - 1]->code_start
                + chunk->data [chunk->num_elements - 1]->code_size;
 
+       ++table->num_valid;
+
        /* Debugging code, should be removed. */
        //jit_info_table_check (table);
 }
@@ -732,6 +724,7 @@ jit_info_table_remove (MonoJitInfoTable *table, MonoJitInfo *ji)
        g_assert (chunk->data [pos] == ji);
 
        chunk->data [pos] = mono_jit_info_make_tombstone (chunk, ji);
+       --table->num_valid;
 
        /* Debugging code, should be removed. */
        //jit_info_table_check (table);
index 214b81f1adff43d7ec83d935284c40bc8a9d94bd..29d03b8d7ac91338b11248723bbc155f3214c27d 100644 (file)
@@ -89,7 +89,7 @@ static void ftnptr_eh_callback_default (guint32 gchandle);
 static MonoFtnPtrEHCallback ftnptr_eh_callback = ftnptr_eh_callback_default;
 
 static void
-delegate_hash_table_add (MonoDelegate *d);
+delegate_hash_table_add (MonoDelegateHandle d);
 
 static void
 delegate_hash_table_remove (MonoDelegate *d);
@@ -179,9 +179,15 @@ mono_string_to_byvalwstr (gpointer dst, MonoString *src, int size);
 gpointer
 mono_delegate_to_ftnptr (MonoDelegate *delegate);
 
+gpointer
+mono_delegate_handle_to_ftnptr (MonoDelegateHandle delegate, MonoError *error);
+
 MonoDelegate*
 mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
 
+MonoDelegateHandle
+mono_ftnptr_to_delegate_handle (MonoClass *klass, gpointer ftn, MonoError *error);
+
 gpointer
 mono_array_to_savearray (MonoArray *array);
 
@@ -216,7 +222,10 @@ static void
 mono_icall_end (MonoThreadInfo *info, HandleStackMark *stackmark, MonoError *error);
 
 static MonoObjectHandle
-mono_icall_handle_new_full (gpointer rawobj, MonoBoolean interior);
+mono_icall_handle_new (gpointer rawobj);
+
+static MonoObjectHandle
+mono_icall_handle_new_interior (gpointer rawobj);
 
 /* Lazy class loading functions */
 static GENERATE_GET_CLASS_WITH_CACHE (string_builder, "System.Text", "StringBuilder");
@@ -276,6 +285,21 @@ mono_marshal_init_tls (void)
 static MonoObject*
 mono_object_isinst_icall (MonoObject *obj, MonoClass *klass)
 {
+       if (!klass)
+               return NULL;
+
+       /* This is called from stelemref so it is expected to succeed */
+       /* Fastpath */
+       if (mono_class_is_interface (klass)) {
+               MonoVTable *vt = obj->vtable;
+
+               if (!klass->inited)
+                       mono_class_init (klass);
+
+               if (MONO_VTABLE_IMPLEMENTS_INTERFACE (vt, klass->interface_id))
+                       return obj;
+       }
+
        MonoError error;
        MonoObject *result = mono_object_isinst_checked (obj, klass, &error);
        mono_error_set_pending_exception (&error);
@@ -376,7 +400,8 @@ mono_marshal_init (void)
                register_icall (mono_threads_detach_coop, "mono_threads_detach_coop", "void ptr ptr", TRUE);
                register_icall (mono_icall_start, "mono_icall_start", "ptr ptr ptr", TRUE);
                register_icall (mono_icall_end, "mono_icall_end", "void ptr ptr ptr", TRUE);
-               register_icall (mono_icall_handle_new_full, "mono_icall_handle_new_full", "ptr ptr bool", TRUE);
+               register_icall (mono_icall_handle_new, "mono_icall_handle_new", "ptr ptr", TRUE);
+               register_icall (mono_icall_handle_new_interior, "mono_icall_handle_new_interior", "ptr ptr", TRUE);
 
                mono_cominterop_init ();
                mono_remoting_init ();
@@ -412,25 +437,44 @@ mono_marshal_unlock_internal (void)
 
 /* This is a JIT icall, it sets the pending exception and return NULL on error */
 gpointer
-mono_delegate_to_ftnptr (MonoDelegate *delegate)
+mono_delegate_to_ftnptr (MonoDelegate *delegate_raw)
 {
+       HANDLE_FUNCTION_ENTER ();
        MonoError error;
+       MONO_HANDLE_DCL (MonoDelegate, delegate);
+       gpointer result = mono_delegate_handle_to_ftnptr (delegate, &error);
+       mono_error_set_pending_exception (&error);
+       HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+gpointer
+mono_delegate_handle_to_ftnptr (MonoDelegateHandle delegate, MonoError *error)
+{
+       HANDLE_FUNCTION_ENTER ();
+       gpointer result = NULL;
+       error_init (error);
        MonoMethod *method, *wrapper;
        MonoClass *klass;
        uint32_t target_handle = 0;
 
-       if (!delegate)
-               return NULL;
+       if (MONO_HANDLE_IS_NULL (delegate))
+               goto leave;
 
-       if (delegate->delegate_trampoline)
-               return delegate->delegate_trampoline;
+       if (MONO_HANDLE_GETVAL (delegate, delegate_trampoline)) {
+               result = MONO_HANDLE_GETVAL (delegate, delegate_trampoline);
+               goto leave;
+       }
 
-       klass = ((MonoObject *)delegate)->vtable->klass;
+       klass = mono_handle_class (delegate);
        g_assert (klass->delegate);
 
-       method = delegate->method;
-       if (delegate->method_is_virtual)
-               method = mono_object_get_virtual_method (delegate->target, method);
+       method = MONO_HANDLE_GETVAL (delegate, method);
+       if (MONO_HANDLE_GETVAL (delegate, method_is_virtual)) {
+               MonoObjectHandle delegate_target = MONO_HANDLE_NEW_GET (MonoObject, delegate, target);
+               method = mono_object_handle_get_virtual_method (delegate_target, method, error);
+               if (!is_ok (error))
+                       goto leave;
+       }
 
        if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
                const char *exc_class, *exc_arg;
@@ -439,38 +483,39 @@ mono_delegate_to_ftnptr (MonoDelegate *delegate)
                ftnptr = mono_lookup_pinvoke_call (method, &exc_class, &exc_arg);
                if (!ftnptr) {
                        g_assert (exc_class);
-                       mono_set_pending_exception (mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg));
-                       return NULL;
+                       mono_error_set_generic_error (error, "System", exc_class, "%s", exc_arg);
+                       goto leave;
                }
-               return ftnptr;
+               result = ftnptr;
+               goto leave;
        }
 
-       if (delegate->target) {
+       MonoObjectHandle delegate_target = MONO_HANDLE_NEW_GET (MonoObject, delegate, target);
+       if (!MONO_HANDLE_IS_NULL (delegate_target)) {
                /* Produce a location which can be embedded in JITted code */
-               target_handle = mono_gchandle_new_weakref (delegate->target, FALSE);
+               target_handle = mono_gchandle_new_weakref (MONO_HANDLE_RAW (delegate_target), FALSE); /* FIXME: a version of mono_gchandle_new_weakref that takes a coop handle */
        }
 
-       wrapper = mono_marshal_get_managed_wrapper (method, klass, target_handle, &error);
-       if (!is_ok (&error))
-               goto fail;
+       wrapper = mono_marshal_get_managed_wrapper (method, klass, target_handle, error);
+       if (!is_ok (error))
+               goto leave;
 
-       delegate->delegate_trampoline = mono_compile_method_checked (wrapper, &error);
-       if (!is_ok (&error))
-               goto fail;
+       MONO_HANDLE_SETVAL (delegate, delegate_trampoline, gpointer, mono_compile_method_checked (wrapper, error));
+       if (!is_ok (error))
+               goto leave;
 
        // Add the delegate to the delegate hash table
        delegate_hash_table_add (delegate);
 
        /* when the object is collected, collect the dynamic method, too */
-       mono_object_register_finalizer ((MonoObject*)delegate);
+       mono_object_register_finalizer ((MonoObject*) MONO_HANDLE_RAW (delegate));
 
-       return delegate->delegate_trampoline;
+       result = MONO_HANDLE_GETVAL (delegate, delegate_trampoline);
 
-fail:
-       if (target_handle != 0)
+leave:
+       if (!is_ok (error) && target_handle != 0)
                mono_gchandle_free (target_handle);
-       mono_error_set_pending_exception (&error);
-       return NULL;
+       HANDLE_FUNCTION_RETURN_VAL (result);
 }
 
 /* 
@@ -502,7 +547,7 @@ delegate_hash_table_remove (MonoDelegate *d)
 }
 
 static void
-delegate_hash_table_add (MonoDelegate *d)
+delegate_hash_table_add (MonoDelegateHandle d)
 {
        guint32 gchandle;
        guint32 old_gchandle;
@@ -510,14 +555,15 @@ delegate_hash_table_add (MonoDelegate *d)
        mono_marshal_lock ();
        if (delegate_hash_table == NULL)
                delegate_hash_table = delegate_hash_table_new ();
+       gpointer delegate_trampoline = MONO_HANDLE_GETVAL (d, delegate_trampoline);
        if (mono_gc_is_moving ()) {
-               gchandle = mono_gchandle_new_weakref ((MonoObject*)d, FALSE);
-               old_gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, d->delegate_trampoline));
-               g_hash_table_insert (delegate_hash_table, d->delegate_trampoline, GUINT_TO_POINTER (gchandle));
+               gchandle = mono_gchandle_new_weakref ((MonoObject*) MONO_HANDLE_RAW (d), FALSE);
+               old_gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, delegate_trampoline));
+               g_hash_table_insert (delegate_hash_table, delegate_trampoline, GUINT_TO_POINTER (gchandle));
                if (old_gchandle)
                        mono_gchandle_free (old_gchandle);
        } else {
-               g_hash_table_insert (delegate_hash_table, d->delegate_trampoline, d);
+               g_hash_table_insert (delegate_hash_table, delegate_trampoline, MONO_HANDLE_RAW (d));
        }
        mono_marshal_unlock ();
 }
@@ -571,12 +617,23 @@ parse_unmanaged_function_pointer_attr (MonoClass *klass, MonoMethodPInvoke *piin
 MonoDelegate*
 mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn)
 {
+       HANDLE_FUNCTION_ENTER ();
        MonoError error;
+       MonoDelegateHandle result = mono_ftnptr_to_delegate_handle (klass, ftn, &error);
+       mono_error_set_pending_exception (&error);
+       HANDLE_FUNCTION_RETURN_OBJ (result);
+}
+
+MonoDelegateHandle
+mono_ftnptr_to_delegate_handle (MonoClass *klass, gpointer ftn, MonoError *error)
+{
+       HANDLE_FUNCTION_ENTER ();
+       error_init (error);
        guint32 gchandle;
-       MonoDelegate *d;
+       MonoDelegateHandle d = MONO_HANDLE_NEW (MonoDelegate, NULL);
 
        if (ftn == NULL)
-               return NULL;
+               goto leave;
 
        mono_marshal_lock ();
        if (delegate_hash_table == NULL)
@@ -586,30 +643,26 @@ mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn)
                gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, ftn));
                mono_marshal_unlock ();
                if (gchandle)
-                       d = (MonoDelegate*)mono_gchandle_get_target (gchandle);
-               else
-                       d = NULL;
+                       MONO_HANDLE_ASSIGN (d, MONO_HANDLE_CAST (MonoDelegate, mono_gchandle_get_target_handle (gchandle)));
        } else {
-               d = (MonoDelegate *)g_hash_table_lookup (delegate_hash_table, ftn);
+               MONO_HANDLE_ASSIGN (d, MONO_HANDLE_NEW (MonoDelegate, g_hash_table_lookup (delegate_hash_table, ftn)));
                mono_marshal_unlock ();
        }
-       if (d == NULL) {
+       if (MONO_HANDLE_IS_NULL (d)) {
                /* This is a native function, so construct a delegate for it */
                MonoMethodSignature *sig;
                MonoMethod *wrapper;
                MonoMarshalSpec **mspecs;
                MonoMethod *invoke = mono_get_delegate_invoke (klass);
                MonoMethodPInvoke piinfo;
-               MonoObject *this_obj;
+               MonoObjectHandle  this_obj;
                int i;
 
                if (use_aot_wrappers) {
                        wrapper = mono_marshal_get_native_func_wrapper_aot (klass);
-                       this_obj = mono_value_box_checked (mono_domain_get (), mono_defaults.int_class, &ftn, &error);
-                       if (!is_ok (&error)) {
-                               mono_error_set_pending_exception (&error);
-                               return NULL;
-                       }
+                       this_obj = MONO_HANDLE_NEW (MonoObject, mono_value_box_checked (mono_domain_get (), mono_defaults.int_class, &ftn, error));
+                       if (!is_ok (error))
+                               goto leave;
                } else {
                        memset (&piinfo, 0, sizeof (piinfo));
                        parse_unmanaged_function_pointer_attr (klass, &piinfo);
@@ -621,7 +674,7 @@ mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn)
                        sig->hasthis = 0;
 
                        wrapper = mono_marshal_get_native_func_wrapper (klass->image, sig, &piinfo, mspecs, ftn);
-                       this_obj = NULL;
+                       this_obj = MONO_HANDLE_NEW (MonoObject, NULL);
 
                        for (i = mono_method_signature (invoke)->param_count; i >= 0; i--)
                                if (mspecs [i])
@@ -630,25 +683,24 @@ mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn)
                        g_free (sig);
                }
 
-               d = (MonoDelegate*)mono_object_new_checked (mono_domain_get (), klass, &error);
-               if (!mono_error_ok (&error)) {
-                       mono_error_set_pending_exception (&error);
-                       return NULL;
-               }
-               gpointer compiled_ptr = mono_compile_method_checked (wrapper, &error);
-               if (mono_error_set_pending_exception (&error))
-                       return NULL;
-               mono_delegate_ctor_with_method ((MonoObject*)d, this_obj, compiled_ptr, wrapper, &error);
-               if (mono_error_set_pending_exception (&error))
-                       return NULL;
-       }
+               MONO_HANDLE_ASSIGN (d, MONO_HANDLE_NEW (MonoDelegate, mono_object_new_checked (mono_domain_get (), klass, error)));
+               if (!is_ok (error))
+                       goto leave;
+               gpointer compiled_ptr = mono_compile_method_checked (wrapper, error);
+               if (!is_ok (error))
+                       goto leave;
 
-       if (d->object.vtable->domain != mono_domain_get ()) {
-               mono_set_pending_exception (mono_get_exception_not_supported ("Delegates cannot be marshalled from native code into a domain other than their home domain"));
-               return NULL;
+               mono_delegate_ctor_with_method (MONO_HANDLE_CAST (MonoObject, d), this_obj, compiled_ptr, wrapper, error);
+               if (!is_ok (error))
+                       goto leave;
        }
 
-       return d;
+       g_assert (!MONO_HANDLE_IS_NULL (d));
+       if (MONO_HANDLE_DOMAIN (d) != mono_domain_get ())
+               mono_error_set_not_supported (error, "Delegates cannot be marshalled from native code into a domain other than their home domain");
+
+leave:
+       HANDLE_FUNCTION_RETURN_REF (MonoDelegate, d);
 }
 
 void
@@ -1200,7 +1252,7 @@ mono_string_new_len_wrapper (const char *text, guint length)
        return result;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 /*
  * mono_mb_emit_exception_marshal_directive:
@@ -1220,8 +1272,7 @@ mono_mb_emit_exception_marshal_directive (MonoMethodBuilder *mb, char *msg)
        }
        mono_mb_emit_exception_full (mb, "System.Runtime.InteropServices", "MarshalDirectiveException", s);
 }
-
-#endif /* !DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 guint
 mono_type_to_ldind (MonoType *type)
@@ -1335,7 +1386,7 @@ handle_enum:
        return -1;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 static void
 emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
@@ -2412,7 +2463,7 @@ mono_marshal_emit_thread_force_interrupt_checkpoint (MonoMethodBuilder *mb)
        emit_thread_force_interrupt_checkpoint (mb);
 }
 
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 /* This is a JIT icall, it sets the pending exception and returns NULL on error. */
 static MonoAsyncResult *
@@ -2481,7 +2532,7 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params)
        return result;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 int
 mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolean save_this)
@@ -2525,7 +2576,7 @@ mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolea
        return params_var;
 }
 
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 static char*
 mono_signature_to_name (MonoMethodSignature *sig, const char *prefix)
@@ -3150,7 +3201,7 @@ mono_marshal_get_delegate_begin_invoke (MonoMethod *method)
                mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_BEGIN_INVOKE);
        g_free (name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        params_var = mono_mb_emit_save_args (mb, sig, FALSE);
 
        mono_mb_emit_ldarg (mb, 0);
@@ -3273,7 +3324,7 @@ mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params)
        return res;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 void
 mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type)
@@ -3336,7 +3387,7 @@ mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type)
        mono_mb_emit_byte (mb, CEE_RET);
 }
 
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 /**
  * mono_marshal_get_delegate_end_invoke:
@@ -3392,7 +3443,7 @@ mono_marshal_get_delegate_end_invoke (MonoMethod *method)
                mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_END_INVOKE);
        g_free (name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        params_var = mono_mb_emit_save_args (mb, sig, FALSE);
 
        mono_mb_emit_ldarg (mb, 0);
@@ -3594,7 +3645,7 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt
                mb = mono_mb_new (get_wrapper_target_class (method->klass->image), name, MONO_WRAPPER_DELEGATE_INVOKE);
        g_free (name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        void_ret = sig->ret->type == MONO_TYPE_VOID && !method->string_ctor;
 
        /* allocate local 0 (object) */
@@ -3761,7 +3812,7 @@ mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt
        mono_mb_emit_byte (mb, CEE_RET);
 
        mb->skip_visibility = 1;
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, subtype);
        info->d.delegate_invoke.method = method;
@@ -3956,7 +4007,7 @@ runtime_invoke_signature_equal (MonoMethodSignature *sig1, MonoMethodSignature *
                return mono_metadata_signature_equal (sig1, sig2);
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 /*
  * emit_invoke_call:
@@ -3977,8 +4028,10 @@ emit_invoke_call (MonoMethodBuilder *mb, MonoMethod *method,
 
        /* to make it work with our special string constructors */
        if (!string_dummy) {
+               MonoError error;
                MONO_GC_REGISTER_ROOT_SINGLE (string_dummy, MONO_ROOT_SOURCE_MARSHAL, "dummy marshal string");
-               string_dummy = mono_string_new_wrapper ("dummy");
+               string_dummy = mono_string_new_checked (mono_get_root_domain (), "dummy", &error);
+               mono_error_assert_ok (&error);
        }
 
        if (virtual_) {
@@ -4382,7 +4435,7 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_)
        mb = mono_mb_new (target_klass, name,  MONO_WRAPPER_RUNTIME_INVOKE);
        g_free (name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        param_names [0] = "this";
        param_names [1] = "params";
        param_names [2] = "exc";
@@ -4393,7 +4446,7 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_)
 #endif
 
        if (need_direct_wrapper) {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                mb->skip_visibility = 1;
 #endif
                info = mono_wrapper_info_create (mb, virtual_ ? WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL : WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT);
@@ -4477,7 +4530,7 @@ mono_marshal_get_runtime_invoke_dynamic (void)
        mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_RUNTIME_INVOKE);
        g_free (name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /* allocate local 0 (object) tmp */
        mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
        /* allocate local 1 (object) exc */
@@ -4538,7 +4591,7 @@ mono_marshal_get_runtime_invoke_dynamic (void)
        mono_mb_patch_branch (mb, pos);
        //mono_mb_emit_ldloc (mb, 0);
        mono_mb_emit_byte (mb, CEE_RET);
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC);
 
@@ -4612,7 +4665,7 @@ mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature *sig)
        mb = mono_mb_new (mono_defaults.object_class, name,  MONO_WRAPPER_RUNTIME_INVOKE);
        g_free (name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        param_names [0] = "this";
        param_names [1] = "params";
        param_names [2] = "exc";
@@ -4653,7 +4706,7 @@ mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature *sig)
        return res;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 static void
 mono_mb_emit_auto_layout_exception (MonoMethodBuilder *mb, MonoClass *klass)
 {
@@ -4694,7 +4747,7 @@ mono_marshal_get_icall_wrapper (MonoMethodSignature *sig, const char *name, gcon
        else
                csig2 = mono_metadata_signature_dup_full (mono_defaults.corlib, sig);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        if (sig->hasthis)
                mono_mb_emit_byte (mb, CEE_LDARG_0);
 
@@ -4728,7 +4781,7 @@ emit_marshal_custom (EmitMarshalContext *m, int argnum, MonoType *t,
                                         int conv_arg, MonoType **conv_arg_type, 
                                         MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN && t->type == MONO_TYPE_VALUETYPE)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
        return conv_arg;
@@ -5044,7 +5097,7 @@ emit_marshal_asany (EmitMarshalContext *m, int argnum, MonoType *t,
                                        int conv_arg, MonoType **conv_arg_type, 
                                        MarshalAction action)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -5091,7 +5144,7 @@ emit_marshal_vtype (EmitMarshalContext *m, int argnum, MonoType *t,
                                        int conv_arg, MonoType **conv_arg_type, 
                                        MarshalAction action)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
        MonoClass *klass, *date_time_class;
        int pos = 0, pos2;
@@ -5368,7 +5421,7 @@ emit_marshal_string (EmitMarshalContext *m, int argnum, MonoType *t,
                                         int conv_arg, MonoType **conv_arg_type, 
                                         MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        switch (action) {
        case MARSHAL_ACTION_CONV_IN:
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
@@ -5547,7 +5600,7 @@ emit_marshal_safehandle (EmitMarshalContext *m, int argnum, MonoType *t,
                         MonoMarshalSpec *spec, int conv_arg, 
                         MonoType **conv_arg_type, MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
 #else
@@ -5711,7 +5764,7 @@ emit_marshal_handleref (EmitMarshalContext *m, int argnum, MonoType *t,
                        MonoMarshalSpec *spec, int conv_arg, 
                        MonoType **conv_arg_type, MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
 #else
@@ -5778,7 +5831,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                     int conv_arg, MonoType **conv_arg_type, 
                     MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
 #else
@@ -6045,8 +6098,10 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                        mono_mb_emit_ldloc (mb, 0);
                        mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL, NULL));
                        mono_mb_emit_stloc (mb, 3);
-               } else if (klass == mono_defaults.stringbuilder_class){
-                       // FIXME: implement
+               } else if (klass == mono_defaults.stringbuilder_class) {
+                       // FIXME:
+                       char *msg = g_strdup_printf ("Return marshalling of stringbuilders is not implemented.");
+                       mono_mb_emit_exception_marshal_directive (mb, msg);
                } else {
                        /* set src */
                        mono_mb_emit_stloc (mb, 0);
@@ -6278,8 +6333,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
        return conv_arg;
 }
 
-#ifndef DISABLE_JIT
-
+#ifdef ENABLE_ILGEN
 #ifndef DISABLE_COM
 
 static int
@@ -6396,7 +6450,7 @@ emit_marshal_variant (EmitMarshalContext *m, int argnum, MonoType *t,
 }
 
 #endif /* DISABLE_COM */
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 static gboolean
 mono_pinvoke_is_unicode (MonoMethodPInvoke *piinfo)
@@ -6423,7 +6477,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                                        int conv_arg, MonoType **conv_arg_type, 
                                        MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        switch (action) {
        case MARSHAL_ACTION_CONV_IN:
                *conv_arg_type = &mono_defaults.object_class->byval_arg;
@@ -7192,7 +7246,7 @@ emit_marshal_boolean (EmitMarshalContext *m, int argnum, MonoType *t,
                      int conv_arg, MonoType **conv_arg_type, 
                      MarshalAction action)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        switch (action) {
        case MARSHAL_ACTION_CONV_IN:
                if (t->byref)
@@ -7361,7 +7415,7 @@ emit_marshal_ptr (EmitMarshalContext *m, int argnum, MonoType *t,
                  MonoMarshalSpec *spec, int conv_arg, 
                  MonoType **conv_arg_type, MarshalAction action)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -7396,7 +7450,7 @@ emit_marshal_char (EmitMarshalContext *m, int argnum, MonoType *t,
                   MonoMarshalSpec *spec, int conv_arg, 
                   MonoType **conv_arg_type, MarshalAction action)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -7424,7 +7478,7 @@ emit_marshal_scalar (EmitMarshalContext *m, int argnum, MonoType *t,
                     MonoMarshalSpec *spec, int conv_arg, 
                     MonoType **conv_arg_type, MarshalAction action)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -7468,7 +7522,7 @@ emit_marshal (EmitMarshalContext *m, int argnum, MonoType *t,
                return emit_marshal_string (m, argnum, t, spec, conv_arg, conv_arg_type, action);
        case MONO_TYPE_CLASS:
        case MONO_TYPE_OBJECT:
-#if !defined(DISABLE_COM) && !defined(DISABLE_JIT)
+#if !defined(DISABLE_COM) && defined(ENABLE_ILGEN)
                if (spec && spec->native == MONO_NATIVE_STRUCT)
                        return emit_marshal_variant (m, argnum, t, spec, conv_arg, conv_arg_type, action);
 #endif
@@ -7531,6 +7585,9 @@ typedef enum {
        /* Wrap the argument in an object handle, pass the handle to the icall,
           write the value out from the handle when the icall returns */
        ICALL_HANDLES_WRAP_OBJ_INOUT,
+       /* Initialized an object handle to null, pass to the icalls,
+          write the value out from the handle when the icall returns */
+       ICALL_HANDLES_WRAP_OBJ_OUT,
        /* Wrap the argument (a valuetype reference) in a handle to pin its enclosing object,
           but pass the raw reference to the icall */
        ICALL_HANDLES_WRAP_VALUETYPE_REF,
@@ -7552,7 +7609,12 @@ static IcallHandlesWrap
 signature_param_uses_handles (MonoMethodSignature *sig, int param)
 {
        if (MONO_TYPE_IS_REFERENCE (sig->params [param])) {
-               return mono_signature_param_is_out (sig, param) ? ICALL_HANDLES_WRAP_OBJ_INOUT : ICALL_HANDLES_WRAP_OBJ;
+               if (mono_signature_param_is_out (sig, param))
+                       return ICALL_HANDLES_WRAP_OBJ_OUT;
+               else if (mono_type_is_byref (sig->params [param]))
+                       return ICALL_HANDLES_WRAP_OBJ_INOUT;
+               else
+                       return ICALL_HANDLES_WRAP_OBJ;
        } else if (mono_type_is_byref (sig->params [param]))
                return ICALL_HANDLES_WRAP_VALUETYPE_REF;
        else
@@ -7560,7 +7622,7 @@ signature_param_uses_handles (MonoMethodSignature *sig, int param)
 }
 
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 /**
  * mono_marshal_emit_native_wrapper:
  * \param image the image to use for looking up custom marshallers
@@ -7844,7 +7906,7 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
 
        mono_mb_emit_byte (mb, CEE_RET);
 }
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 /**
  * mono_marshal_get_native_wrapper:
@@ -7943,7 +8005,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                /* create a wrapper to preserve .ctor in stack trace */
                                mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_MANAGED);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                                mono_mb_emit_byte (mb, CEE_LDARG_0);
                                for (i = 1; i <= csig->param_count; i++)
                                        mono_mb_emit_ldarg (mb, i);
@@ -7977,7 +8039,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
         * registered in the runtime doing the AOT compilation.
         */
        if (!piinfo->addr && !aot) {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                mono_mb_emit_exception (mb, exc_class, exc_arg);
 #endif
                info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
@@ -8005,7 +8067,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                if (method->string_ctor)
                        csig->ret = &mono_defaults.string_class->byval_arg;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                // FIXME:
                MonoClass *handle_stack_mark_class;
                MonoClass *error_class;
@@ -8014,8 +8076,8 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                gboolean uses_handles = FALSE;
                gboolean save_handles_to_locals = FALSE;
                IcallHandlesLocal *handles_locals = NULL;
-               (void) mono_lookup_internal_call_full (method, &uses_handles);
 
+               (void) mono_lookup_internal_call_full (method, &uses_handles);
 
                /* If it uses handles and MonoError, it had better check exceptions */
                g_assert (!uses_handles || check_exceptions);
@@ -8037,8 +8099,9 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                switch (w) {
                                case ICALL_HANDLES_WRAP_OBJ:
                                case ICALL_HANDLES_WRAP_OBJ_INOUT:
+                               case ICALL_HANDLES_WRAP_OBJ_OUT:
                                        ret->params [i] = mono_class_get_byref_type (mono_class_from_mono_type(csig->params[i]));
-                                       if (w == ICALL_HANDLES_WRAP_OBJ_INOUT)
+                                       if (w == ICALL_HANDLES_WRAP_OBJ_OUT || w == ICALL_HANDLES_WRAP_OBJ_INOUT)
                                                save_handles_to_locals = TRUE;
                                        break;
                                case ICALL_HANDLES_WRAP_NONE:
@@ -8075,6 +8138,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                                handles_locals [j].handle = -1;
                                                break;
                                        case ICALL_HANDLES_WRAP_OBJ_INOUT:
+                                       case ICALL_HANDLES_WRAP_OBJ_OUT:
                                                handles_locals [j].handle = mono_mb_add_local (mb, sig->params [i]);
                                                break;
                                        default:
@@ -8107,8 +8171,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                mono_mb_emit_byte (mb, CEE_LDARG_0);
                                /* TODO support adding wrappers to non-static struct methods */
                                g_assert (!mono_class_is_valuetype(mono_method_get_class (method)));
-                               mono_mb_emit_byte (mb, CEE_LDC_I4_0);
-                               mono_mb_emit_icall (mb, mono_icall_handle_new_full);
+                               mono_mb_emit_icall (mb, mono_icall_handle_new);
                        }
                        for (i = 0; i < sig->param_count; i++) {
                                /* load each argument. references into the managed heap get wrapped in handles */
@@ -8118,27 +8181,33 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                        mono_mb_emit_ldarg (mb, j);
                                        break;
                                case ICALL_HANDLES_WRAP_OBJ:
-                                       /* argI = mono_handle_new_full (argI_raw, FALSE) */
+                                       /* argI = mono_handle_new (argI_raw) */
                                        mono_mb_emit_ldarg (mb, j);
-                                       mono_mb_emit_byte (mb, CEE_LDC_I4_0);
-                                       mono_mb_emit_icall (mb, mono_icall_handle_new_full);
+                                       mono_mb_emit_icall (mb, mono_icall_handle_new);
                                        break;
                                case ICALL_HANDLES_WRAP_OBJ_INOUT:
-                                       /* handleI = argI = mono_handle_new_full (NULL, FALSE) */
-                                       mono_mb_emit_byte (mb, CEE_LDNULL);
-                                       mono_mb_emit_byte (mb, CEE_LDC_I4_0);
-                                       mono_mb_emit_icall (mb, mono_icall_handle_new_full);
+                               case ICALL_HANDLES_WRAP_OBJ_OUT:
+                                       /* if inout:
+                                        *   handleI = argI = mono_handle_new (*argI_raw)
+                                        * otherwise:
+                                        *   handleI = argI = mono_handle_new (NULL)
+                                        */
+                                       if (handles_locals[j].wrap == ICALL_HANDLES_WRAP_OBJ_INOUT) {
+                                               mono_mb_emit_ldarg (mb, j);
+                                               mono_mb_emit_byte (mb, CEE_LDIND_REF);
+                                       } else
+                                               mono_mb_emit_byte (mb, CEE_LDNULL);
+                                       mono_mb_emit_icall (mb, mono_icall_handle_new);
                                        /* tmp = argI */
                                        mono_mb_emit_byte (mb, CEE_DUP);
                                        /* handleI = tmp */
                                        mono_mb_emit_stloc (mb, handles_locals[j].handle);
                                        break;
                                case ICALL_HANDLES_WRAP_VALUETYPE_REF:
-                                       /* (void) mono_handle_new_full (argI, TRUE); argI */
+                                       /* (void) mono_handle_new (argI); argI */
                                        mono_mb_emit_ldarg (mb, j);
                                        mono_mb_emit_byte (mb, CEE_DUP);
-                                       mono_mb_emit_byte (mb, CEE_LDC_I4_1);
-                                       mono_mb_emit_icall (mb, mono_icall_handle_new_full);
+                                       mono_mb_emit_icall (mb, mono_icall_handle_new_interior);
                                        mono_mb_emit_byte (mb, CEE_POP);
 #if 0
                                        fprintf (stderr, " Method %s.%s.%s has byref valuetype argument %d\n", method->klass->name_space, method->klass->name, method->name, i);
@@ -8185,6 +8254,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                        case ICALL_HANDLES_WRAP_VALUETYPE_REF:
                                                break;
                                        case ICALL_HANDLES_WRAP_OBJ_INOUT:
+                                       case ICALL_HANDLES_WRAP_OBJ_OUT:
                                                /* *argI_raw = MONO_HANDLE_RAW (handleI) */
 
                                                /* argI_raw */
@@ -8230,7 +8300,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
        if (!aot)
                g_assert (piinfo->addr);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mspecs = g_new (MonoMarshalSpec*, sig->param_count + 1);
        mono_method_get_marshal_info (method, mspecs);
 
@@ -8245,7 +8315,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                                                                 info, NULL);
        mono_mb_free (mb);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        for (i = sig->param_count; i >= 0; i--)
                if (mspecs [i])
                        mono_metadata_free_marshal_spec (mspecs [i]);
@@ -8293,7 +8363,7 @@ mono_marshal_get_native_func_wrapper (MonoImage *image, MonoMethodSignature *sig
        mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_MANAGED_TO_NATIVE);
        mb->method->save_lmf = 1;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, func, FALSE, TRUE, FALSE);
 #endif
 
@@ -8358,7 +8428,7 @@ mono_marshal_get_native_func_wrapper_aot (MonoClass *klass)
        mb = mono_mb_new (invoke->klass, name, MONO_WRAPPER_MANAGED_TO_NATIVE);
        mb->method->save_lmf = 1;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, NULL, FALSE, TRUE, TRUE);
 #endif
 
@@ -8393,7 +8463,7 @@ mono_marshal_get_native_func_wrapper_aot (MonoClass *klass)
 void
 mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
 {
-#ifdef DISABLE_JIT
+#ifndef ENABLE_ILGEN
        MonoMethodSignature *sig, *csig;
        int i;
 
@@ -8925,7 +8995,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
                                                                                         mb, csig, sig->param_count + 16,
                                                                                         info, NULL);
        } else {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                mb->dynamic = TRUE;
 #endif
                res = mono_mb_create (mb, csig, sig->param_count + 16, NULL);
@@ -8988,7 +9058,7 @@ mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
 
                mono_marshal_emit_managed_wrapper (mb, sig, mspecs, &m, method, 0);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                mb->dynamic = TRUE;
 #endif
                method = mono_mb_create (mb, csig, sig->param_count + 16, NULL);
@@ -9008,7 +9078,7 @@ mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_MANAGED);
 
        param_count = sig->param_count + sig->hasthis;
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        for (i = 0; i < param_count; i++)
                mono_mb_emit_ldarg (mb, i);
 
@@ -9029,7 +9099,7 @@ mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
        return compiled_ptr;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 /*
  * The code directly following this is the cache hit, value positive branch
@@ -9092,7 +9162,7 @@ generate_check_cache (int obj_arg_position, int class_arg_position, int cache_ar
        mono_mb_emit_icall (mb, mono_marshal_isinst_with_cache);
 }
 
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
 /**
  * mono_marshal_get_castclass_with_cache:
@@ -9123,7 +9193,7 @@ mono_marshal_get_castclass_with_cache (void)
        sig->ret = &mono_defaults.object_class->byval_arg;
        sig->pinvoke = 0;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        generate_check_cache (obj_arg_position, class_arg_position, cache_arg_position, 
                                                                                                &return_null_pos, &negative_cache_hit_pos, &positive_cache_hit_pos, mb);
        invalid_cast_pos = mono_mb_emit_branch (mb, CEE_BRFALSE);
@@ -9142,7 +9212,7 @@ mono_marshal_get_castclass_with_cache (void)
        mono_mb_patch_branch (mb, return_null_pos);
        mono_mb_emit_byte (mb, CEE_LDNULL);
        mono_mb_emit_byte (mb, CEE_RET);
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE);
        res = mono_mb_create (mb, sig, 8, info);
@@ -9210,7 +9280,7 @@ mono_marshal_get_isinst_with_cache (void)
        sig->ret = &mono_defaults.object_class->byval_arg;
        sig->pinvoke = 0;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        generate_check_cache (obj_arg_position, class_arg_position, cache_arg_position, 
                &return_null_pos, &negative_cache_hit_pos, &positive_cache_hit_pos, mb);
        // Return the object gotten via the slow path.
@@ -9269,7 +9339,7 @@ mono_marshal_get_struct_to_ptr (MonoClass *klass)
 
        mb = mono_mb_new (klass, stoptr->name, MONO_WRAPPER_UNKNOWN);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        if (klass->blittable) {
                mono_mb_emit_byte (mb, CEE_LDARG_1);
                mono_mb_emit_byte (mb, CEE_LDARG_0);
@@ -9351,7 +9421,7 @@ mono_marshal_get_ptr_to_struct (MonoClass *klass)
 
        mb = mono_mb_new (klass, "PtrToStructure", MONO_WRAPPER_UNKNOWN);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        if (klass->blittable) {
                mono_mb_emit_byte (mb, CEE_LDARG_1);
                mono_mb_emit_ldflda (mb, sizeof (MonoObject));
@@ -9419,7 +9489,7 @@ mono_marshal_get_synchronized_inner_wrapper (MonoMethod *method)
        }
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_UNKNOWN);
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mono_mb_emit_exception_full (mb, "System", "ExecutionEngineException", "Shouldn't be called.");
        mono_mb_emit_byte (mb, CEE_RET);
 #endif
@@ -9495,7 +9565,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
        info->d.synchronized.method = method;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mb->skip_visibility = 1;
        /* result */
        if (!MONO_TYPE_IS_VOID (sig->ret))
@@ -9505,7 +9575,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
        if (method->klass->valuetype && !(method->flags & MONO_METHOD_ATTR_STATIC)) {
                /* FIXME Is this really the best way to signal an error here?  Isn't this called much later after class setup? -AK */
                mono_class_set_type_load_failure (method->klass, "");
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                /* This will throw the type load exception when the wrapper is compiled */
                mono_mb_emit_byte (mb, CEE_LDNULL);
                mono_mb_emit_op (mb, CEE_ISINST, method->klass);
@@ -9523,7 +9593,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
                return res;
        }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /* this */
        this_local = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
        taken_local = mono_mb_add_local (mb, &mono_defaults.boolean_class->byval_arg);
@@ -9555,7 +9625,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
 
        mono_marshal_unlock ();
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /* Push this or the type object */
        if (method->flags & METHOD_ATTRIBUTE_STATIC) {
                /* We have special handling for this in the JIT */
@@ -9654,7 +9724,7 @@ mono_marshal_get_unbox_wrapper (MonoMethod *method)
 
        g_assert (sig->hasthis);
        
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mono_mb_emit_ldarg (mb, 0); 
        mono_mb_emit_icon (mb, sizeof (MonoObject));
        mono_mb_emit_byte (mb, CEE_ADD);
@@ -9726,7 +9796,7 @@ get_virtual_stelemref_kind (MonoClass *element_class)
        return STELEMREF_CLASS;
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 static void
 load_array_element_address (MonoMethodBuilder *mb)
@@ -9810,7 +9880,7 @@ get_virtual_stelemref_wrapper (int kind)
                signature = sig;
        }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        param_names [0] = "index";
        param_names [1] = "value";
        mono_mb_set_param_names (mb, param_names);
@@ -10210,7 +10280,7 @@ get_virtual_stelemref_wrapper (int kind)
                mono_mb_emit_byte (mb, CEE_RET);
                g_assert (0);
        }
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_VIRTUAL_STELEMREF);
        info->d.virtual_stelemref.kind = kind;
        res = mono_mb_create (mb, signature, 4, info);
@@ -10283,7 +10353,7 @@ mono_marshal_get_stelemref (void)
        sig->params [1] = &mono_defaults.int_class->byval_arg; /* this is a natural sized int */
        sig->params [2] = &mono_defaults.object_class->byval_arg;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        aklass = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
        vklass = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
        array_slot_addr = mono_mb_add_local (mb, &mono_defaults.object_class->this_arg);
@@ -10423,7 +10493,7 @@ mono_marshal_get_gsharedvt_in_wrapper (void)
        sig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
        sig->ret = &mono_defaults.void_class->byval_arg;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /*
         * The body is generated by the JIT, we use a wrapper instead of a trampoline so EH works.
         */
@@ -10457,7 +10527,7 @@ mono_marshal_get_gsharedvt_out_wrapper (void)
        sig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
        sig->ret = &mono_defaults.void_class->byval_arg;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /*
         * The body is generated by the JIT, we use a wrapper instead of a trampoline so EH works.
         */
@@ -10531,7 +10601,7 @@ mono_marshal_get_array_address (int rank, int elem_size)
        mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_MANAGED_TO_MANAGED);
        g_free (name);
        
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        bounds = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
        ind = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
        realidx = mono_mb_add_local (mb, &mono_defaults.int32_class->byval_arg);
@@ -10627,7 +10697,7 @@ mono_marshal_get_array_address (int rank, int elem_size)
        mono_mb_emit_exception (mb, "IndexOutOfRangeException", NULL);
 
        g_free (branch_positions);
-#endif /* DISABLE_JIT */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_ELEMENT_ADDR);
        info->d.element_addr.rank = rank;
@@ -10704,7 +10774,7 @@ mono_marshal_get_array_accessor_wrapper (MonoMethod *method)
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_UNKNOWN);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /* Call the method */
        if (sig->hasthis)
                mono_mb_emit_ldarg (mb, 0);
@@ -11008,18 +11078,23 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error (void)
 }
 
 guint32 
-ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionType *rtype)
+ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionTypeHandle rtype, MonoError *error)
 {
        MonoClass *klass;
        MonoType *type;
        guint32 layout;
 
-       MONO_CHECK_ARG_NULL (rtype, 0);
+       error_init (error);
+
+       if (MONO_HANDLE_IS_NULL (rtype)) {
+               mono_error_set_argument_null (error, "type", "");
+               return 0;
+       }
 
-       type = rtype->type;
+       type = MONO_HANDLE_GETVAL (rtype, type);
        klass = mono_class_from_mono_type (type);
        if (!mono_class_init (klass)) {
-               mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
+               mono_error_set_for_class_failure (error, klass);
                return 0;
        }
 
@@ -11028,13 +11103,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionType *rty
        if (type->type == MONO_TYPE_PTR || type->type == MONO_TYPE_FNPTR) {
                return sizeof (gpointer);
        } else if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) {
-               gchar *msg;
-               MonoException *exc;
-
-               msg = g_strdup_printf ("Type %s cannot be marshaled as an unmanaged structure.", klass->name);
-               exc = mono_get_exception_argument ("t", msg);
-               g_free (msg);
-               mono_set_pending_exception (exc);
+               mono_error_set_argument (error, "t", "Type %s cannot be marshaled as an unmanaged structure.", klass->name);
                return 0;
        }
 
@@ -11140,26 +11209,29 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type (gpointer s
 }
 
 int
-ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionType *type, MonoString *field_name)
+ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionTypeHandle ref_type, MonoStringHandle field_name, MonoError *error)
 {
-       MonoError error;
-       MonoMarshalType *info;
-       MonoClass *klass;
-       char *fname;
-       int match_index = -1;
-       
-       MONO_CHECK_ARG_NULL (type, 0);
-       MONO_CHECK_ARG_NULL (field_name, 0);
-
-       fname = mono_string_to_utf8_checked (field_name, &error);
-       if (mono_error_set_pending_exception (&error))
+       error_init (error);
+       if (MONO_HANDLE_IS_NULL (ref_type)) {
+               mono_error_set_argument_null (error, "type", "");
                return 0;
-       klass = mono_class_from_mono_type (type->type);
+       }
+       if (MONO_HANDLE_IS_NULL (field_name)) {
+               mono_error_set_argument_null (error, "fieldName", "");
+               return 0;
+       }
+
+       char *fname = mono_string_handle_to_utf8 (field_name, error);
+       return_val_if_nok (error, 0);
+
+       MonoType *type = MONO_HANDLE_GETVAL (ref_type, type);
+       MonoClass *klass = mono_class_from_mono_type (type);
        if (!mono_class_init (klass)) {
-               mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
+               mono_error_set_for_class_failure (error, klass);
                return 0;
        }
 
+       int match_index = -1;
        while (klass && match_index == -1) {
                MonoClassField* field;
                int i = 0;
@@ -11181,21 +11253,14 @@ ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionType *t
        g_free (fname);
 
        if(match_index == -1) {
-               MonoException* exc;
-               gchar *tmp;
-
                /* Get back original class instance */
-               klass = mono_class_from_mono_type (type->type);
+               klass = mono_class_from_mono_type (type);
 
-               tmp = g_strdup_printf ("Field passed in is not a marshaled member of the type %s", klass->name);
-               exc = mono_get_exception_argument ("fieldName", tmp);
-               g_free (tmp);
-               mono_set_pending_exception ((MonoException*)exc);
+               mono_error_set_argument (error, "fieldName", "Field passed in is not a marshaled member of the type %s", klass->name);
                return 0;
        }
 
-       info = mono_marshal_load_type_info (klass);     
+       MonoMarshalType *info = mono_marshal_load_type_info (klass);
        return info->fields [match_index].offset;
 }
 
@@ -11421,22 +11486,24 @@ ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement
        return mono_array_addr_with_size_fast (arrayobj, mono_array_element_size (arrayobj->obj.vtable->klass), index);
 }
 
-MonoDelegate*
-ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionType *type)
+MonoDelegateHandle
+ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionTypeHandle type, MonoError *error)
 {
-       MonoClass *klass = mono_type_get_class (type->type);
+       error_init (error);
+       MonoClass *klass = mono_type_get_class (MONO_HANDLE_GETVAL (type, type));
        if (!mono_class_init (klass)) {
-               mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
+               mono_error_set_for_class_failure (error, klass);
                return NULL;
        }
 
-       return mono_ftnptr_to_delegate (klass, ftn);
+       return mono_ftnptr_to_delegate_handle (klass, ftn, error);
 }
 
 gpointer
-ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal (MonoDelegate *delegate)
+ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal (MonoDelegateHandle delegate, MonoError *error)
 {
-       return mono_delegate_to_ftnptr (delegate);
+       error_init (error);
+       return mono_delegate_handle_to_ftnptr (delegate, error);
 }
 
 /**
@@ -12002,7 +12069,7 @@ mono_marshal_get_generic_array_helper (MonoClass *klass, gchar *name, MonoMethod
        csig = mono_metadata_signature_dup_full (method->klass->image, sig);
        csig->generic_param_count = 0;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mono_mb_emit_ldarg (mb, 0);
        for (i = 0; i < csig->param_count; i++)
                mono_mb_emit_ldarg (mb, i + 1);
@@ -12139,7 +12206,7 @@ mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method)
        if (MONO_TYPE_ISSTRUCT (sig->ret))
                csig->ret = &mono_defaults.object_class->byval_arg;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /* local 0 (temp for exception object) */
        mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
 
@@ -12317,11 +12384,21 @@ mono_icall_end (MonoThreadInfo *info, HandleStackMark *stackmark, MonoError *err
 }
 
 static MonoObjectHandle
-mono_icall_handle_new_full (gpointer rawobj, MonoBoolean interior)
+mono_icall_handle_new (gpointer rawobj)
+{
+#ifdef MONO_HANDLE_TRACK_OWNER
+       return mono_handle_new (rawobj, "<marshal args>");
+#else
+       return mono_handle_new (rawobj);
+#endif
+}
+
+static MonoObjectHandle
+mono_icall_handle_new_interior (gpointer rawobj)
 {
 #ifdef MONO_HANDLE_TRACK_OWNER
-       return mono_handle_new_full (rawobj, interior, "<marshal args>");
+       return mono_handle_new_interior (rawobj, "<marshal args>");
 #else
-       return mono_handle_new_full (rawobj, interior);
+       return mono_handle_new_interior (rawobj);
 #endif
 }
index 57018b828d41dbe1d0ee050ce98a27161586be3e..657193859061b252a75605813143c38043dd4af0 100644 (file)
@@ -458,7 +458,7 @@ guint32
 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error (void);
 
 guint32 
-ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionType *rtype);
+ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionTypeHandle rtype, MonoError *error);
 
 void
 ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr (MonoObject *obj, gpointer dst, MonoBoolean delete_old);
@@ -470,7 +470,7 @@ MonoObject *
 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type (gpointer src, MonoReflectionType *type);
 
 int
-ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionType *type, MonoString *field_name);
+ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionTypeHandle type, MonoStringHandle field_name, MonoError *error);
 
 gpointer
 ves_icall_System_Runtime_InteropServices_Marshal_StringToBSTR (MonoString *string);
@@ -514,11 +514,11 @@ ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (void *ptr);
 void*
 ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement (MonoArray *arrayobj, int index);
 
-MonoDelegate*
-ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionType *type);
+MonoDelegateHandle
+ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionTypeHandle type, MonoError *error);
 
 gpointer
-ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal (MonoDelegate *delegate);
+ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal (MonoDelegateHandle delegate, MonoError *error);
 
 int
 ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (gpointer pUnk);
index d2cf14781b077e8f00e6371770e1996bdb0c3f7f..3458232139c4d3a83dac251c024476ef30e19fd8 100644 (file)
@@ -61,6 +61,20 @@ g_slist_append_mempool (MonoMemPool *mp, GSList *list, gpointer data)
                return new_list;
 }
 
+static inline GList*
+g_list_append_mempool (MonoMemPool *mp, GList *list, gpointer data)
+{
+       GList *new_list;
+
+       new_list = (GList *) mono_mempool_alloc0 (mp, sizeof (GList));
+       new_list->data = data;
+       new_list->prev = g_list_last (list);
+       if (new_list->prev)
+               new_list->prev->next = new_list;
+
+       return list ? list : new_list;
+}
+
 char*
 mono_mempool_strdup_vprintf (MonoMemPool *pool, const char *format, va_list args);
 
index a6a936758e66e1794a69b848902a47c722075e89..895b29c926caa298a95fd22a300fadfde630c5f9 100644 (file)
@@ -51,6 +51,11 @@ struct _MonoType {
 #define MONO_PROCESSOR_ARCHITECTURE_AMD64 4
 #define MONO_PROCESSOR_ARCHITECTURE_ARM 5
 
+#if !defined(DISABLE_JIT) || defined(ENABLE_INTERPRETER)
+/* Some VES is available at runtime */
+#define ENABLE_ILGEN
+#endif
+
 struct _MonoAssemblyName {
        const char *name;
        const char *culture;
index 9ce5f04e8eb68ef4957988ca74b6b13458c361cc..a02312ab4723514308d97c0e0c40e7065a9dc733 100644 (file)
@@ -67,7 +67,7 @@ mono_mb_new_base (MonoClass *klass, MonoWrapperType type)
        m->inline_info = 1;
        m->wrapper_type = type;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mb->code_size = 40;
        mb->code = (unsigned char *)g_malloc (mb->code_size);
        mb->init_locals = TRUE;
@@ -104,7 +104,7 @@ mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type)
 void
 mono_mb_free (MonoMethodBuilder *mb)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        GList *l;
 
        for (l = mb->locals_list; l; l = l->next) {
@@ -134,7 +134,7 @@ mono_mb_free (MonoMethodBuilder *mb)
 MonoMethod *
 mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, int max_stack)
 {
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        MonoMethodHeader *header;
 #endif
        MonoMethodWrapper *mw;
@@ -147,7 +147,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 
        image = mb->method->klass->image;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        if (mb->dynamic) {
                method = mb->method;
                mw = (MonoMethodWrapper*)method;
@@ -177,7 +177,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
                else
                        method->name = mono_image_strdup (image, mb->name);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
                mw->header = header = (MonoMethodHeader *) 
                        mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
 
@@ -190,7 +190,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 #endif
        }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /* Free the locals list so mono_mb_free () doesn't free the types twice */
        g_list_free (mb->locals_list);
        mb->locals_list = NULL;
@@ -200,7 +200,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
        if (!signature->hasthis)
                method->flags |= METHOD_ATTRIBUTE_STATIC;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        if (max_stack < 8)
                max_stack = 8;
 
@@ -236,7 +236,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
                mw->method_data = data;
        }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        /*{
                static int total_code = 0;
                static int total_alloc = 0;
@@ -284,7 +284,7 @@ mono_mb_add_data (MonoMethodBuilder *mb, gpointer data)
        return g_list_length ((GList *)mw->method_data);
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 /**
  * mono_mb_add_local:
index b94abb0d64a87f9bb7e04cc2eac9f29968e0e878..26a53e1c34d46baad794158329fdc9a1b897083f 100644 (file)
@@ -25,7 +25,7 @@ typedef struct _MonoMethodBuilder {
        MonoMethod *method;
        char *name;
        gboolean no_dup_name;
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        GList *locals_list;
        int locals;
        gboolean dynamic;
@@ -53,7 +53,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
 guint32
 mono_mb_add_data (MonoMethodBuilder *mb, gpointer data);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 void
 mono_mb_patch_addr (MonoMethodBuilder *mb, int pos, int value);
 
diff --git a/mono/metadata/mono-conc-hash.c b/mono/metadata/mono-conc-hash.c
new file mode 100644 (file)
index 0000000..c0bdb02
--- /dev/null
@@ -0,0 +1,454 @@
+/**
+ * \file
+ * Conc GC aware Hashtable implementation
+ *
+ * Author:
+ *   Rodrigo Kumpera (kumpera@gmail.com)
+ *
+ */
+#include <config.h>
+#include <stdio.h>
+#include <math.h>
+#include <glib.h>
+#include "mono-conc-hash.h"
+#include "metadata/gc-internals.h"
+#include <mono/utils/checked-build.h>
+#include <mono/utils/mono-threads-coop.h>
+
+#ifdef HAVE_BOEHM_GC
+#define mg_new0(type,n)  ((type *) GC_MALLOC(sizeof(type) * (n)))
+#define mg_new(type,n)   ((type *) GC_MALLOC(sizeof(type) * (n)))
+#define mg_free(x)       do { } while (0)
+#else
+#define mg_new0(x,n)     g_new0(x,n)
+#define mg_new(type,n)   g_new(type,n)
+#define mg_free(x)       g_free(x)
+#endif
+
+#define INITIAL_SIZE 32
+#define LOAD_FACTOR 0.75f
+#define PTR_TOMBSTONE ((gpointer)(ssize_t)-1)
+/* Expand ration must be a power of two */
+#define EXPAND_RATIO 2
+
+typedef struct {
+       int table_size;
+       MonoGHashGCType gc_type;
+       void **keys;
+       void **values;
+} conc_table;
+
+struct _MonoConcGHashTable {
+       volatile conc_table *table; /* goes to HP0 */
+       GHashFunc hash_func;
+       GEqualFunc equal_func;
+       int element_count;
+       int overflow_count;
+       GDestroyNotify key_destroy_func;
+       GDestroyNotify value_destroy_func;
+       MonoGHashGCType gc_type;
+       MonoGCRootSource source;
+       const char *msg;
+};
+
+
+static conc_table*
+conc_table_new (MonoConcGHashTable *hash, int size)
+{
+#ifdef HAVE_SGEN_GC
+       conc_table *table = mg_new0 (conc_table, 1);
+#else
+       conc_table *table = mono_gc_alloc_fixed (sizeof (conc_table), MONO_GC_ROOT_DESCR_FOR_FIXED (sizeof (conc_table)), hash->source, hash->msg);
+#endif
+       
+       table->keys = mg_new0 (void*, size);
+       table->values = mg_new0 (void*, size);
+       table->table_size = size;
+       table->gc_type = hash->gc_type;
+
+#ifdef HAVE_SGEN_GC
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_register_root_wbarrier ((char*)table->keys, sizeof (MonoObject*) * size, mono_gc_make_vector_descr (), hash->source, hash->msg);
+       if (hash->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_register_root_wbarrier ((char*)table->values, sizeof (MonoObject*) * size, mono_gc_make_vector_descr (), hash->source, hash->msg);
+#endif
+
+       return table;
+}
+
+static void
+conc_table_free (gpointer ptr)
+{
+       conc_table *table = (conc_table *)ptr;
+#ifdef HAVE_SGEN_GC
+       if (table->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_deregister_root ((char*)table->keys);
+       if (table->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_deregister_root ((char*)table->values);
+#endif
+
+       mg_free (table->keys);
+       mg_free (table->values);
+#ifdef HAVE_SGEN_GC
+       mg_free (table);
+#else
+       mono_gc_free_fixed (table);
+#endif
+}
+
+static void
+conc_table_lf_free (conc_table *table)
+{
+       mono_thread_hazardous_try_free (table, conc_table_free);
+}
+
+
+static gboolean
+key_is_tombstone (MonoConcGHashTable *hash, gpointer ptr)
+{
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               return ptr == mono_domain_get()->ephemeron_tombstone;
+       return ptr == PTR_TOMBSTONE;
+}
+
+/*
+A common problem with power of two hashtables is that it leads of bad clustering when dealing
+with aligned numbers.
+
+The solution here is to mix the bits from two primes plus the hash itself, it produces a better spread
+than just the numbers.
+*/
+
+static MONO_ALWAYS_INLINE int
+mix_hash (int hash)
+{
+       return ((hash * 215497) >> 16) ^ (hash * 1823231 + hash);
+}
+
+
+static inline void
+set_key (conc_table *table, int slot, gpointer key)
+{
+       gpointer *key_addr = &table->keys [slot];
+       if (table->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_wbarrier_generic_store (key_addr, key);
+       else
+               *key_addr = key;
+}
+
+static inline void
+set_key_to_tombstone (conc_table *table, int slot)
+{
+       gpointer *key_addr = &table->keys [slot];
+       if (table->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_wbarrier_generic_store (key_addr, mono_domain_get()->ephemeron_tombstone);
+       else
+               *key_addr = PTR_TOMBSTONE;
+}
+
+static inline void
+set_value (conc_table *table, int slot, gpointer value)
+{
+       gpointer *value_addr = &table->values [slot];
+       if (table->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_wbarrier_generic_store (value_addr, value);
+       else
+               *value_addr = value;
+}
+
+static MONO_ALWAYS_INLINE void
+insert_one_local (conc_table *table, GHashFunc hash_func, gpointer key, gpointer value)
+{
+       int table_mask = table->table_size - 1;
+       int hash = mix_hash (hash_func (key));
+       int i = hash & table_mask;
+
+       while (table->keys [i])
+               i = (i + 1) & table_mask;
+
+       set_key (table, i, key);
+       set_value (table, i, value);
+}
+
+static void
+expand_table (MonoConcGHashTable *hash_table)
+{
+       conc_table *old_table = (conc_table*)hash_table->table;
+       conc_table *new_table = conc_table_new (hash_table, old_table->table_size * EXPAND_RATIO);
+       int i;
+
+       for (i = 0; i < old_table->table_size; ++i) {
+               if (old_table->keys [i] && !key_is_tombstone (hash_table, old_table->keys [i]))
+                       insert_one_local (new_table, hash_table->hash_func, old_table->keys [i], old_table->values [i]);
+       }
+
+       mono_memory_barrier ();
+       hash_table->table = new_table;
+       hash_table->overflow_count = (int)(new_table->table_size * LOAD_FACTOR);
+       conc_table_lf_free (old_table); 
+}
+
+
+MonoConcGHashTable *
+mono_conc_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type, MonoGCRootSource source, const char *msg)
+{
+       MonoConcGHashTable *hash;
+
+       if (!hash_func)
+               hash_func = g_direct_hash;
+
+       hash = g_new0 (MonoConcGHashTable, 1);
+       hash->hash_func = hash_func;
+       hash->equal_func = key_equal_func;
+
+       hash->element_count = 0;
+       hash->overflow_count = (int)(INITIAL_SIZE * LOAD_FACTOR);
+       hash->gc_type = type;
+       hash->source = source;
+       hash->msg = msg;
+
+       hash->table = conc_table_new (hash, INITIAL_SIZE);
+
+       if (type > MONO_HASH_KEY_VALUE_GC)
+               g_error ("wrong type for gc hashtable");
+
+       return hash;
+}
+
+gpointer
+mono_conc_g_hash_table_lookup (MonoConcGHashTable *hash, gconstpointer key)
+{
+       gpointer orig_key, value;
+
+       if (mono_conc_g_hash_table_lookup_extended (hash, key, &orig_key, &value))
+               return value;
+       else
+               return NULL;
+}
+
+gboolean
+mono_conc_g_hash_table_lookup_extended (MonoConcGHashTable *hash_table, gconstpointer key, gpointer *orig_key_ptr, gpointer *value_ptr)
+{
+       MonoThreadHazardPointers* hp;
+       conc_table *table;
+       int hash, i, table_mask;
+       hash = mix_hash (hash_table->hash_func (key));
+       hp = mono_hazard_pointer_get ();
+
+retry:
+       table = (conc_table *)mono_get_hazardous_pointer ((gpointer volatile*)&hash_table->table, hp, 0);
+       table_mask = table->table_size - 1;
+       i = hash & table_mask;
+
+       if (G_LIKELY (!hash_table->equal_func)) {
+               while (table->keys [i]) {
+                       gpointer orig_key = table->keys [i];
+                       if (key == orig_key) {
+                               gpointer value;
+                               /* The read of keys must happen before the read of values */
+                               mono_memory_barrier ();
+                               value = table->values [i];
+
+                               /* We just read a value been deleted, try again. */
+                               if (G_UNLIKELY (!value))
+                                       goto retry;
+
+                               mono_hazard_pointer_clear (hp, 0);
+
+                               *orig_key_ptr = orig_key;
+                               *value_ptr = value;
+                               return TRUE;
+                       }
+                       i = (i + 1) & table_mask;
+               }
+       } else {
+               GEqualFunc equal = hash_table->equal_func;
+
+               while (table->keys [i]) {
+                       gpointer orig_key = table->keys [i];
+                       if (!key_is_tombstone (hash_table, orig_key) && equal (key, orig_key)) {
+                               gpointer value;
+                               /* The read of keys must happen before the read of values */
+                               mono_memory_barrier ();
+                               value = table->values [i];
+
+                               /* We just read a value been deleted, try again. */
+                               if (G_UNLIKELY (!value))
+                                       goto retry;
+
+                               mono_hazard_pointer_clear (hp, 0);
+                               *orig_key_ptr = orig_key;
+                               *value_ptr = value;
+                               return TRUE;
+
+                       }
+                       i = (i + 1) & table_mask;
+               }
+       }
+
+       /* The table might have expanded and the value is now on the newer table */
+       mono_memory_barrier ();
+       if (hash_table->table != table)
+               goto retry;
+
+       mono_hazard_pointer_clear (hp, 0);
+
+       *orig_key_ptr = NULL;
+       *value_ptr = NULL;
+       return FALSE;
+}
+
+void
+mono_conc_g_hash_table_foreach (MonoConcGHashTable *hash_table, GHFunc func, gpointer user_data)
+{
+       int i;
+       conc_table *table = (conc_table*)hash_table->table;
+
+       for (i = 0; i < table->table_size; ++i) {
+               if (table->keys [i] && !key_is_tombstone (hash_table, table->keys [i])) {
+                       func (table->keys [i], table->values [i], user_data);
+               }
+       }       
+}
+
+void
+mono_conc_g_hash_table_destroy (MonoConcGHashTable *hash_table)
+{
+       if (hash_table->key_destroy_func || hash_table->value_destroy_func) {
+               int i;
+               conc_table *table = (conc_table*)hash_table->table;
+
+               for (i = 0; i < table->table_size; ++i) {
+                       if (table->keys [i] && !key_is_tombstone (hash_table, table->keys [i])) {
+                               if (hash_table->key_destroy_func)
+                                       (hash_table->key_destroy_func) (table->keys [i]);
+                               if (hash_table->value_destroy_func)
+                                       (hash_table->value_destroy_func) (table->values [i]);
+                       }
+               }
+       }
+       conc_table_free ((gpointer)hash_table->table);
+       g_free (hash_table);
+}
+
+/* Return NULL on success or the old value in failure */
+gpointer
+mono_conc_g_hash_table_insert (MonoConcGHashTable *hash_table, gpointer key, gpointer value)
+{
+       conc_table *table;
+       int hash, i, table_mask;
+
+       g_assert (key != NULL);
+       g_assert (value != NULL);
+
+       hash = mix_hash (hash_table->hash_func (key));
+
+       if (hash_table->element_count >= hash_table->overflow_count)
+               expand_table (hash_table);
+
+       table = (conc_table*)hash_table->table;
+       table_mask = table->table_size - 1;
+       i = hash & table_mask;
+
+       if (!hash_table->equal_func) {
+               for (;;) {
+                       gpointer cur_key = table->keys [i];
+                       if (!cur_key || key_is_tombstone (hash_table, cur_key)) {
+                               set_value (table, i, value);
+
+                               /* The write to values must happen after the write to keys */
+                               mono_memory_barrier ();
+                               set_key (table, i, key);
+                               ++hash_table->element_count;
+                               return NULL;
+                       }
+                       if (key == cur_key) {
+                               gpointer value = table->values [i];
+                               return value;
+                       }
+                       i = (i + 1) & table_mask;
+               }
+       } else {
+               GEqualFunc equal = hash_table->equal_func;
+               for (;;) {
+                       gpointer cur_key = table->keys [i];
+                       if (!cur_key || key_is_tombstone (hash_table, cur_key)) {
+                               set_value (table, i, value);
+                               /* The write to values must happen after the write to keys */
+                               mono_memory_barrier ();
+                               set_key (table, i, key);
+                               ++hash_table->element_count;
+                               return NULL;
+                       }
+                       if (equal (key, cur_key)) {
+                               gpointer value = table->values [i];
+                               return value;
+                       }
+                       i = (i + 1) & table_mask;
+               }
+       }
+}
+
+gpointer
+mono_conc_g_hash_table_remove (MonoConcGHashTable *hash_table, gconstpointer key)
+{
+       conc_table *table;
+       int hash, i, table_mask;
+
+       g_assert (key != NULL);
+
+       hash = mix_hash (hash_table->hash_func (key));
+
+       table = (conc_table*)hash_table->table;
+       table_mask = table->table_size - 1;
+       i = hash & table_mask;
+
+       if (!hash_table->equal_func) {
+               for (;;) {
+                       gpointer cur_key = table->keys [i];
+                       if (!cur_key) {
+                               return NULL; /*key not found*/
+                       }
+
+                       if (key == cur_key) {
+                               gpointer value = table->values [i];
+                               table->values [i] = NULL;
+                               mono_memory_barrier ();
+                               set_key_to_tombstone (table, i);
+
+                               --hash_table->element_count;
+
+                               if (hash_table->key_destroy_func != NULL)
+                                       (*hash_table->key_destroy_func) (cur_key);
+                               if (hash_table->value_destroy_func != NULL)
+                                       (*hash_table->value_destroy_func) (value);
+
+                               return value;
+                       }
+                       i = (i + 1) & table_mask;
+               }
+       } else {
+               GEqualFunc equal = hash_table->equal_func;
+               for (;;) {
+                       gpointer cur_key = table->keys [i];
+                       if (!cur_key) {
+                               return NULL; /*key not found*/
+                       }
+
+                       if (!key_is_tombstone (hash_table, cur_key) && equal (key, cur_key)) {
+                               gpointer value = table->values [i];
+                               table->values [i] = NULL;
+                               mono_memory_barrier ();
+                               set_key_to_tombstone (table, i);
+
+                               if (hash_table->key_destroy_func != NULL)
+                                       (*hash_table->key_destroy_func) (cur_key);
+                               if (hash_table->value_destroy_func != NULL)
+                                       (*hash_table->value_destroy_func) (value);
+                               return value;
+                       }
+
+                       i = (i + 1) & table_mask;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mono/metadata/mono-conc-hash.h b/mono/metadata/mono-conc-hash.h
new file mode 100644 (file)
index 0000000..67b77ef
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * \file
+ * GC-aware concurrent hashtable, based on utils/mono-conc-hashtable
+ */
+
+#ifndef __MONO_CONC_G_HASH_H__
+#define __MONO_CONC_G_HASH_H__
+
+#include <mono/metadata/mono-hash.h>
+
+
+typedef struct _MonoConcGHashTable MonoConcGHashTable;
+
+MonoConcGHashTable * mono_conc_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type, MonoGCRootSource source, const char *msg);
+gpointer mono_conc_g_hash_table_lookup (MonoConcGHashTable *hash, gconstpointer key);
+gboolean mono_conc_g_hash_table_lookup_extended (MonoConcGHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
+void mono_conc_g_hash_table_foreach (MonoConcGHashTable *hash, GHFunc func, gpointer user_data);
+void mono_conc_g_hash_table_destroy (MonoConcGHashTable *hash);
+gpointer mono_conc_g_hash_table_insert (MonoConcGHashTable *h, gpointer k, gpointer v);
+gpointer mono_conc_g_hash_table_remove (MonoConcGHashTable *hash, gconstpointer key);
+
+#endif /* __MONO_CONC_G_HASH_H__ */
index 7cff2952632bb4673e16069e807be67ed6b08122..e3d19ca7c130c3ef57cf87b841a6920a1712e55d 100644 (file)
@@ -668,7 +668,7 @@ mono_config_parse (const char *filename) {
        mono_config_parse_file (mono_cfg);
        g_free (mono_cfg);
 
-#if !defined(TARGET_WIN32) && !defined(__native_client__)
+#if !defined(TARGET_WIN32)
        home = g_get_home_dir ();
        user_cfg = g_strconcat (home, G_DIR_SEPARATOR_S, ".mono/config", NULL);
        mono_config_parse_file (user_cfg);
diff --git a/mono/metadata/nacl-stub.c b/mono/metadata/nacl-stub.c
deleted file mode 100644 (file)
index ca87582..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * \file
- */
-
-#if defined(__native_client__)
-
-#include "nacl-stub.h"
-
-struct group *getgrnam(const char *name)
-{
-       return NULL;
-}
-
-struct group *getgrgid(gid_t gid)
-{
-       errno = EIO;
-       return NULL;
-}
-
-int fsync(int fd)
-{
-       errno = EINVAL;
-       return -1;
-}
-
-#ifdef USE_NEWLIB
-dev_t makedev(int maj, int min)
-{
-       return (maj)*256+(min);
-}
-
-int utime(const char *filename, const void *times)
-{
-       errno = EACCES;
-       return -1;
-}
-
-int kill(pid_t pid, int sig)
-{
-       errno = EACCES;
-       return -1;
-}
-
-int getrusage(int who, void *usage)
-{
-       errno = EACCES;
-       return -1;
-}
-
-int lstat(const char *path, struct stat *buf)
-{
-       return stat (path, buf);
-}
-
-int getdtablesize(void)
-{
-#ifdef OPEN_MAX
-  return OPEN_MAX;
-#else
-  return 256;
-#endif
-}
-
-size_t getpagesize(void)
-{
-#ifdef PAGE_SIZE
-  return PAGE_SIZE;
-#else
-  return 4096;
-#endif
-}
-
-int sem_trywait(sem_t *sem) {
-  g_assert_not_reached ();
-  return -1;
-}
-
-int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout) {
-  g_assert_not_reached ();
-  return -1;
-}
-
-#endif
-
-#endif
index 59b1cc558995810ce60a38bd480b4515d0c5ccbc..0ff70982305f5ce6e10bac804d38af94b47a8189 100644 (file)
@@ -266,6 +266,10 @@ typedef enum {
        CallType_OneWay = 3
 } MonoCallType;
 
+/* MonoSafeHandle is in class-internals.h. */
+/* Safely access System.Net.Sockets.SafeSocketHandle from native code */
+TYPED_HANDLE_DECL (MonoSafeHandle);
+
 /* This corresponds to System.Type */
 struct _MonoReflectionType {
        MonoObject object;
@@ -417,6 +421,12 @@ struct _MonoInternalThread {
        gpointer last;
 };
 
+/* It's safe to access System.Threading.InternalThread from native code via a
+ * raw pointer because all instances should be pinned.  But for uniformity of
+ * icall wrapping, let's declare a MonoInternalThreadHandle anyway.
+ */
+TYPED_HANDLE_DECL (MonoInternalThread);
+
 struct _MonoThread {
        MonoObject obj;
        struct _MonoInternalThread *internal_thread;
@@ -655,10 +665,10 @@ void
 mono_method_return_message_restore (MonoMethod *method, gpointer *params, MonoArray *out_args, MonoError *error);
 
 gboolean
-mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpointer addr, MonoMethod *method, MonoError *error);
+mono_delegate_ctor_with_method (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoMethod *method, MonoError *error);
 
 gboolean
-mono_delegate_ctor         (MonoObject *this_obj, MonoObject *target, gpointer addr, MonoError *error);
+mono_delegate_ctor         (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoError *error);
 
 void*
 mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words);
@@ -768,12 +778,18 @@ struct _MonoDelegate {
        MonoBoolean method_is_virtual;
 };
 
+/* Safely access System.Delegate from native code */
+TYPED_HANDLE_DECL (MonoDelegate);
+
 typedef struct _MonoMulticastDelegate MonoMulticastDelegate;
 struct _MonoMulticastDelegate {
        MonoDelegate delegate;
        MonoArray *delegates;
 };
 
+/* Safely access System.MulticastDelegate from native code */
+TYPED_HANDLE_DECL (MonoMulticastDelegate);
+
 struct _MonoReflectionField {
        MonoObject object;
        MonoClass *klass;
@@ -1432,6 +1448,15 @@ typedef struct {
        MonoProperty *prop;
 } CattrNamedArg;
 
+/* All MonoInternalThread instances should be pinned, so it's safe to use the raw ptr.  However
+ * for uniformity, icall wrapping will make handles anyway.  So this is the method for getting the payload.
+ */
+static inline MonoInternalThread*
+mono_internal_thread_handle_ptr (MonoInternalThreadHandle h)
+{
+       return MONO_HANDLE_RAW (h); /* Safe */
+}
+
 gboolean          mono_image_create_pefile (MonoReflectionModuleBuilder *module, gpointer file, MonoError *error);
 guint32       mono_image_insert_string (MonoReflectionModuleBuilderHandle module, MonoStringHandle str, MonoError *error);
 guint32       mono_image_create_token  (MonoDynamicImage *assembly, MonoObjectHandle obj, gboolean create_methodspec, gboolean register_token, MonoError *error);
index 30d2a1f0c2320eaf8f8cb96950129a7cf57a1c70..375831531f6773464a0868363a37450985c6128c 100644 (file)
@@ -267,6 +267,15 @@ DECL_OFFSET(SeqPointInfo, ss_tramp_addr)
 DECL_OFFSET(SeqPointInfo, bp_addrs)
 #endif
 
+#ifdef ENABLE_INTERPRETER
+DECL_OFFSET(InterpMethodArguments, ilen)
+DECL_OFFSET(InterpMethodArguments, iargs)
+DECL_OFFSET(InterpMethodArguments, flen)
+DECL_OFFSET(InterpMethodArguments, fargs)
+DECL_OFFSET(InterpMethodArguments, retval)
+DECL_OFFSET(InterpMethodArguments, is_float_ret)
+#endif
+
 #endif //DISABLE_JIT_OFFSETS
 
 #endif //USED_CROSS_COMPILER_OFFSETS
index 92aa723f20a73f61c7ffec75631e46b6ee77ec94..d30f0413ac22f999432912235b52810720881244 100644 (file)
@@ -7817,43 +7817,44 @@ mono_print_unhandled_exception (MonoObject *exc)
  * On failure returns FALSE and sets \p error.
  */
 gboolean
-mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpointer addr, MonoMethod *method, MonoError *error)
+mono_delegate_ctor_with_method (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoMethod *method, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
        error_init (error);
-       MonoDelegate *delegate = (MonoDelegate *)this_obj;
+       MonoDelegateHandle delegate = MONO_HANDLE_CAST (MonoDelegate, this_obj);
 
-       g_assert (this_obj);
+       g_assert (!MONO_HANDLE_IS_NULL (this_obj));
        g_assert (addr);
 
-       g_assert (mono_class_has_parent (mono_object_class (this_obj), mono_defaults.multicastdelegate_class));
+       MonoClass *klass = mono_handle_class (this_obj);
+       g_assert (mono_class_has_parent (klass, mono_defaults.multicastdelegate_class));
 
        if (method)
-               delegate->method = method;
+               MONO_HANDLE_SETVAL (delegate, method, MonoMethod*, method);
 
        mono_stats.delegate_creations++;
 
 #ifndef DISABLE_REMOTING
-       if (target && mono_object_is_transparent_proxy (target)) {
+       if (!MONO_HANDLE_IS_NULL (target) && mono_class_is_transparent_proxy (mono_handle_class (target))) {
                g_assert (method);
                method = mono_marshal_get_remoting_invoke (method);
 #ifdef ENABLE_INTERPRETER
                //g_error ("need RuntimeMethod in method_ptr when using interpreter");
 #endif
-               delegate->method_ptr = mono_compile_method_checked (method, error);
+               MONO_HANDLE_SETVAL (delegate, method_ptr, gpointer, mono_compile_method_checked (method, error));
                return_val_if_nok (error, FALSE);
-               MONO_OBJECT_SETREF (delegate, target, target);
+               MONO_HANDLE_SET (delegate, target, target);
        } else
 #endif
        {
-               delegate->method_ptr = addr;
-               MONO_OBJECT_SETREF (delegate, target, target);
+               MONO_HANDLE_SETVAL (delegate, method_ptr, gpointer, addr);
+               MONO_HANDLE_SET (delegate, target, target);
        }
 
-       delegate->invoke_impl = callbacks.create_delegate_trampoline (delegate->object.vtable->domain, delegate->object.vtable->klass);
+       MONO_HANDLE_SETVAL (delegate, invoke_impl, gpointer, callbacks.create_delegate_trampoline (MONO_HANDLE_DOMAIN (delegate), mono_handle_class (delegate)));
        if (callbacks.init_delegate)
-               callbacks.init_delegate (delegate);
+               callbacks.init_delegate (MONO_HANDLE_RAW (delegate)); /* FIXME: update init_delegate callback to take a MonoDelegateHandle */
        return TRUE;
 }
 
@@ -7867,7 +7868,7 @@ mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpoint
  * On failure returns FALSE and sets \p error.
  */
 gboolean
-mono_delegate_ctor (MonoObject *this_obj, MonoObject *target, gpointer addr, MonoError *error)
+mono_delegate_ctor (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
index 5a0e06102b0f13916188cae94c77280996beaa7f..594556fb68a13421102fcc88566cb0dbc62c634d 100644 (file)
@@ -48,16 +48,17 @@ cache_object (MonoDomain *domain, MonoClass *klass, gpointer item, MonoObject* o
        ReflectedEntry pe;
        pe.item = item;
        pe.refclass = klass;
+
        mono_domain_lock (domain);
        if (!domain->refobject_hash)
-               domain->refobject_hash = mono_g_hash_table_new_type (reflected_hash, reflected_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain reflection objects table");
+               domain->refobject_hash = mono_conc_g_hash_table_new_type (reflected_hash, reflected_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain reflection objects table");
 
-       obj = (MonoObject*) mono_g_hash_table_lookup (domain->refobject_hash, &pe);
+       obj = (MonoObject*) mono_conc_g_hash_table_lookup (domain->refobject_hash, &pe);
        if (obj == NULL) {
                ReflectedEntry *e = ALLOC_REFENTRY;
                e->item = item;
                e->refclass = klass;
-               mono_g_hash_table_insert (domain->refobject_hash, e, o);
+               mono_conc_g_hash_table_insert (domain->refobject_hash, e, o);
                obj = o;
        }
        mono_domain_unlock (domain);
@@ -71,16 +72,17 @@ cache_object_handle (MonoDomain *domain, MonoClass *klass, gpointer item, MonoOb
        ReflectedEntry pe;
        pe.item = item;
        pe.refclass = klass;
+
        mono_domain_lock (domain);
        if (!domain->refobject_hash)
-               domain->refobject_hash = mono_g_hash_table_new_type (reflected_hash, reflected_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain reflection objects table");
+               domain->refobject_hash = mono_conc_g_hash_table_new_type (reflected_hash, reflected_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain reflection objects table");
 
-       MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, mono_g_hash_table_lookup (domain->refobject_hash, &pe));
+       MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, mono_conc_g_hash_table_lookup (domain->refobject_hash, &pe));
        if (MONO_HANDLE_IS_NULL (obj)) {
                ReflectedEntry *e = ALLOC_REFENTRY;
                e->item = item;
                e->refclass = klass;
-               mono_g_hash_table_insert (domain->refobject_hash, e, MONO_HANDLE_RAW (o));
+               mono_conc_g_hash_table_insert (domain->refobject_hash, e, MONO_HANDLE_RAW (o));
                MONO_HANDLE_ASSIGN (obj, o);
        }
        mono_domain_unlock (domain);
@@ -96,11 +98,11 @@ check_object_handle (MonoDomain* domain, MonoClass *klass, gpointer item)
        ReflectedEntry e;
        e.item = item;
        e.refclass = klass;
-       mono_domain_lock (domain);
-       if (!domain->refobject_hash)
-               domain->refobject_hash = mono_g_hash_table_new_type (reflected_hash, reflected_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, "domain reflection objects table");
-       MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, mono_g_hash_table_lookup (domain->refobject_hash, &e));
-       mono_domain_unlock (domain);
+       MonoConcGHashTable *hash = domain->refobject_hash;
+       if (!hash)
+               return MONO_HANDLE_NEW (MonoObject, NULL);
+
+       MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, mono_conc_g_hash_table_lookup (hash, &e));
        return obj;
 }
 
@@ -116,6 +118,8 @@ check_or_construct_handle (MonoDomain *domain, MonoClass *klass, gpointer item,
                return obj;
        MONO_HANDLE_ASSIGN (obj, construct (domain, klass, item, user_data, error));
        return_val_if_nok (error, NULL);
+       if (MONO_HANDLE_IS_NULL (obj))
+               return obj;
        /* note no caching if there was an error in construction */
        return cache_object_handle (domain, klass, item, obj);
 }
index fe80ea7027c03b5533976f925c5f114680c065d8..ee9681e1d27dce1033d9bcbe6b2867327c2f3801 100644 (file)
@@ -186,8 +186,9 @@ clear_cached_object (MonoDomain *domain, gpointer o, MonoClass *klass)
 
                pe.item = o;
                pe.refclass = klass;
-               if (mono_g_hash_table_lookup_extended (domain->refobject_hash, &pe, &orig_pe, &orig_value)) {
-                       mono_g_hash_table_remove (domain->refobject_hash, &pe);
+
+               if (mono_conc_g_hash_table_lookup_extended (domain->refobject_hash, &pe, &orig_pe, &orig_value)) {
+                       mono_conc_g_hash_table_remove (domain->refobject_hash, &pe);
                        FREE_REFENTRY (orig_pe);
                }
        }
@@ -208,9 +209,9 @@ mono_reflection_cleanup_domain (MonoDomain *domain)
        if (domain->refobject_hash) {
 /*let's avoid scanning the whole hashtable if not needed*/
 #ifdef REFENTRY_REQUIRES_CLEANUP
-               mono_g_hash_table_foreach (domain->refobject_hash, cleanup_refobject_hash, NULL);
+               mono_conc_g_hash_table_foreach (domain->refobject_hash, cleanup_refobject_hash, NULL);
 #endif
-               mono_g_hash_table_destroy (domain->refobject_hash);
+               mono_conc_g_hash_table_destroy (domain->refobject_hash);
                domain->refobject_hash = NULL;
        }
 }
@@ -1209,6 +1210,7 @@ mono_method_body_get_object (MonoDomain *domain, MonoMethod *method)
        HANDLE_FUNCTION_RETURN_OBJ (result);
 }
 
+/* WARNING: This method can return NULL on sucess */
 static MonoReflectionMethodBodyHandle
 method_body_object_construct (MonoDomain *domain, MonoClass *unused_class, MonoMethod *method, gpointer user_data, MonoError *error)
 {
index eac61f32577fa1ff64af811766f65449fed621f1..78c0126396cb308433c982290abedba0ba81b93a 100644 (file)
@@ -345,32 +345,24 @@ static void G_GNUC_UNUSED
 sgen_client_binary_protocol_world_stopping (int generation, long long timestamp, gpointer thread)
 {
        MONO_GC_WORLD_STOP_BEGIN ();
-
-       mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD, generation);
 }
 
 static void G_GNUC_UNUSED
 sgen_client_binary_protocol_world_stopped (int generation, long long timestamp, long long total_major_cards, long long marked_major_cards, long long total_los_cards, long long marked_los_cards)
 {
        MONO_GC_WORLD_STOP_END ();
-
-       mono_profiler_gc_event (MONO_GC_EVENT_POST_STOP_WORLD, generation);
 }
 
 static void G_GNUC_UNUSED
 sgen_client_binary_protocol_world_restarting (int generation, long long timestamp, long long total_major_cards, long long marked_major_cards, long long total_los_cards, long long marked_los_cards)
 {
        MONO_GC_WORLD_RESTART_BEGIN (generation);
-
-       mono_profiler_gc_event (MONO_GC_EVENT_PRE_START_WORLD, generation);
 }
 
 static void G_GNUC_UNUSED
 sgen_client_binary_protocol_world_restarted (int generation, long long timestamp)
 {
        MONO_GC_WORLD_RESTART_END (generation);
-
-       mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD, generation);
 }
 
 static void G_GNUC_UNUSED
index 44adebbc0039700d42ef2ce34d3f9fb5bfd90735..0314150604f207eb9bd6c48a6232521398abd376 100644 (file)
@@ -245,7 +245,7 @@ mono_gc_is_critical_method (MonoMethod *method)
        return sgen_is_critical_method (method);
 }
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 
 static void
 emit_nursery_check (MonoMethodBuilder *mb, int *nursery_check_return_labels, gboolean is_concurrent)
@@ -317,7 +317,7 @@ mono_gc_get_specific_write_barrier (gboolean is_concurrent)
        else
                mb = mono_mb_new (mono_defaults.object_class, "wbarrier_noconc", MONO_WRAPPER_WRITE_BARRIER);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
 #ifdef MANAGED_WBARRIER
        emit_nursery_check (mb, nursery_check_labels, is_concurrent);
        /*
@@ -893,6 +893,10 @@ mono_gc_clear_domain (MonoDomain * domain)
 
        sgen_clear_nursery_fragments ();
 
+       FOREACH_THREAD (info) {
+               mono_handle_stack_free_domain ((HandleStack*)info->client_info.info.handle_stack, domain);
+       } FOREACH_THREAD_END
+
        if (sgen_mono_xdomain_checks && domain != mono_get_root_domain ()) {
                sgen_scan_for_registered_roots_in_domain (domain, ROOT_TYPE_NORMAL);
                sgen_scan_for_registered_roots_in_domain (domain, ROOT_TYPE_WBARRIER);
@@ -1122,7 +1126,7 @@ create_allocator (int atype, ManagedAllocatorVariant variant)
 
        mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_ALLOC);
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        if (slowpath) {
                switch (atype) {
                case ATYPE_NORMAL:
@@ -1457,7 +1461,7 @@ create_allocator (int atype, ManagedAllocatorVariant variant)
        info->d.alloc.gc_name = "sgen";
        info->d.alloc.alloc_type = atype;
 
-#ifndef DISABLE_JIT
+#ifdef ENABLE_ILGEN
        mb->init_locals = FALSE;
 #endif
 
index fc1de7c25f87aa9759f19d52f0741c0b911fd71f..3bd1b3322866e140f65b45ba38b9e5a4a2b11b1b 100644 (file)
@@ -104,10 +104,7 @@ sgen_client_stop_world (int generation)
 {
        TV_DECLARE (end_handshake);
 
-       /* notify the profiler of the leftovers */
-       /* FIXME this is the wrong spot at we can STW for non collection reasons. */
-       if (G_UNLIKELY (mono_profiler_events & MONO_PROFILE_GC_MOVES))
-               mono_sgen_gc_event_moves ();
+       mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD, generation);
 
        acquire_gc_locks ();
 
@@ -126,6 +123,8 @@ sgen_client_stop_world (int generation)
 
        SGEN_LOG (3, "world stopped");
 
+       mono_profiler_gc_event (MONO_GC_EVENT_POST_STOP_WORLD, generation);
+
        TV_GETTIME (end_handshake);
        time_stop_world += TV_ELAPSED (stop_world_time, end_handshake);
 
@@ -147,6 +146,8 @@ sgen_client_restart_world (int generation, gint64 *stw_time)
        if (G_UNLIKELY (mono_profiler_events & MONO_PROFILE_GC_MOVES))
                mono_sgen_gc_event_moves ();
 
+       mono_profiler_gc_event (MONO_GC_EVENT_PRE_START_WORLD, generation);
+
        FOREACH_THREAD (info) {
                info->client_info.stack_start = NULL;
                memset (&info->client_info.ctx, 0, sizeof (MonoContext));
@@ -164,6 +165,8 @@ sgen_client_restart_world (int generation, gint64 *stw_time)
 
        SGEN_LOG (2, "restarted (pause time: %d usec, max: %d)", (int)usec, (int)max_pause_usec);
 
+       mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD, generation);
+
        /*
         * We must release the thread info suspend lock after doing
         * the thread handshake.  Otherwise, if the GC stops the world
index b50434bc1feca744de19cc559bf63b873dac06d3..63a9a99aaa3762e294aa6056cdf59769f25469ff 100644 (file)
@@ -1222,12 +1222,7 @@ mono_reflection_dynimage_basic_init (MonoReflectionAssemblyBuilder *assemblyb)
        if (assemblyb->dynamic_assembly)
                return;
 
-#if HAVE_BOEHM_GC
-       /* assembly->assembly.image might be GC allocated */
-       assembly = assemblyb->dynamic_assembly = (MonoDynamicAssembly *)GC_MALLOC (sizeof (MonoDynamicAssembly));
-#else
        assembly = assemblyb->dynamic_assembly = g_new0 (MonoDynamicAssembly, 1);
-#endif
 
        mono_profiler_assembly_event (&assembly->assembly, MONO_PROFILE_START_LOAD);
        
@@ -1650,10 +1645,18 @@ mono_reflection_type_handle_mono_type (MonoReflectionTypeHandle ref, MonoError *
                        goto leave;
                g_assert (base);
                gint32 rank = MONO_HANDLE_GETVAL (sre_array, rank);
-               if (rank == 0) //single dimentional array
-                       result = &mono_array_class_get (mono_class_from_mono_type (base), 1)->byval_arg;
-               else
-                       result = &mono_bounded_array_class_get (mono_class_from_mono_type (base), rank, TRUE)->byval_arg;
+               MonoClass *eclass = mono_class_from_mono_type (base);
+               result = mono_image_new0 (eclass->image, MonoType, 1);
+               if (rank == 0)  {
+                       result->type = MONO_TYPE_SZARRAY;
+                       result->data.klass = eclass;
+               } else {
+                       MonoArrayType *at = (MonoArrayType *)mono_image_alloc0 (eclass->image, sizeof (MonoArrayType));
+                       result->type = MONO_TYPE_ARRAY;
+                       result->data.array = at;
+                       at->eklass = eclass;
+                       at->rank = rank;
+               }
                MONO_HANDLE_SETVAL (ref, type, MonoType*, result);
        } else if (is_sre_byref (klass)) {
                MonoReflectionDerivedTypeHandle sre_byref = MONO_HANDLE_CAST (MonoReflectionDerivedType, ref);
index 5cc8e1d86f906d0541dff394a7f445f59fb8de8f..6f1a34e2dfc46b18eea5a8d7131ff418a934bcba 100644 (file)
@@ -3916,10 +3916,6 @@ collect_appdomain_thread (gpointer key, gpointer value, gpointer user_data)
 gboolean
 mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout)
 {
-#ifdef __native_client__
-       return FALSE;
-#endif
-
        abort_appdomain_data user_data;
        gint64 start_time;
        int orig_timeout = timeout;
index dbbc43bc6f86643cbc5ec0a5706a45490091dddc..df41473dfe896fbc0e1fbe07c82f20b00a360eeb 100644 (file)
@@ -65,7 +65,7 @@ mono_w32error_unix_to_win32 (guint32 error)
        case EIO: return ERROR_INVALID_HANDLE;
        case EINTR: return ERROR_IO_PENDING; /* best match I could find */
        case EPIPE: return ERROR_WRITE_FAULT;
-       case ELOOP: return ERROR_ACCESS_DENIED; /* Empirically found by testing desktop dotnet. */
+       case ELOOP: return ERROR_CANT_RESOLVE_FILENAME;
 
        default:
                g_error ("%s: unknown error (%d) \"%s\"", __FILE__, error, g_strerror (error));
index c8fb1717a52225a1bb1fda4186822b821fc2a1b0..439bdd81a2a0d366e5f1a3fec63ac8448cbfed49 100644 (file)
@@ -42,6 +42,7 @@
 #define ERROR_FILENAME_EXCED_RANGE 206
 #define ERROR_DIRECTORY            267
 #define ERROR_IO_PENDING           997
+#define ERROR_CANT_RESOLVE_FILENAME 1921
 #define ERROR_ENCRYPTION_FAILED    6000
 #define WSAEINTR                   10004
 #define WSAEBADF                   10009
index 246ddadf3f751a0e8b599a5b7b6f648891345f31..37ec577a6b02fb17f37d0a5f02813a867cb08f6a 100644 (file)
 
 #include "w32error.h"
 #include "w32handle-namespace.h"
+#include "mono/utils/mono-error-internals.h"
 #include "mono/utils/mono-logger-internals.h"
+#include "mono/metadata/handle.h"
+#include "mono/metadata/object-internals.h"
 #include "mono/metadata/w32handle.h"
 
 #define MAX_PATH 260
 
+static gpointer
+mono_w32event_create_full (MonoBoolean manual, MonoBoolean initial, const gchar *name, gint32 *err);
+
+static gpointer
+mono_w32event_open (const gchar *utf8_name, gint32 rights G_GNUC_UNUSED, gint32 *error);
+
 typedef struct {
        gboolean manual;
        guint32 set_count;
@@ -27,6 +36,19 @@ struct MonoW32HandleNamedEvent {
        MonoW32HandleNamespace sharedns;
 };
 
+static void event_handle_signal (gpointer handle, MonoW32HandleType type, MonoW32HandleEvent *event_handle)
+{
+       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: signalling %s handle %p",
+               __func__, mono_w32handle_get_typename (type), handle);
+
+       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);
+       }
+}
+
 static gboolean event_handle_own (gpointer handle, MonoW32HandleType type, gboolean *abandoned)
 {
        MonoW32HandleEvent *event_handle;
@@ -55,9 +77,9 @@ static gboolean event_handle_own (gpointer handle, MonoW32HandleType type, gbool
        return TRUE;
 }
 
-static void event_signal(gpointer handle)
+static void event_signal(gpointer handle, gpointer handle_specific)
 {
-       ves_icall_System_Threading_Events_SetEvent_internal (handle);
+       event_handle_signal (handle, MONO_W32HANDLE_EVENT, (MonoW32HandleEvent*) handle_specific);
 }
 
 static gboolean event_own (gpointer handle, gboolean *abandoned)
@@ -65,9 +87,9 @@ static gboolean event_own (gpointer handle, gboolean *abandoned)
        return event_handle_own (handle, MONO_W32HANDLE_EVENT, abandoned);
 }
 
-static void namedevent_signal (gpointer handle)
+static void namedevent_signal (gpointer handle, gpointer handle_specific)
 {
-       ves_icall_System_Threading_Events_SetEvent_internal (handle);
+       event_handle_signal (handle, MONO_W32HANDLE_NAMEDEVENT, (MonoW32HandleEvent*) handle_specific);
 }
 
 /* NB, always called with the shared handle lock held */
@@ -152,7 +174,7 @@ mono_w32event_create (gboolean manual, gboolean initial)
        gpointer handle;
        gint32 error;
 
-       handle = ves_icall_System_Threading_Events_CreateEvent_internal (manual, initial, NULL, &error);
+       handle = mono_w32event_create_full (manual, initial, NULL, &error);
        if (error != ERROR_SUCCESS)
                g_assert (!handle);
 
@@ -213,10 +235,9 @@ static gpointer event_create (gboolean manual, gboolean initial)
        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)
+static gpointer namedevent_create (gboolean manual, gboolean initial, const gchar *utf8_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_get_typename (MONO_W32HANDLE_NAMEDEVENT));
@@ -224,8 +245,7 @@ static gpointer namedevent_create (gboolean manual, gboolean initial, const guni
        /* w32 seems to guarantee that opening named objects can't race each other */
        mono_w32handle_namespace_lock ();
 
-       glong utf8_len = 0;
-       utf8_name = g_utf16_to_utf8 (name, -1, NULL, &utf8_len, NULL);
+       glong utf8_len = strlen (utf8_name);
 
        handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDEVENT, utf8_name);
        if (handle == INVALID_HANDLE_VALUE) {
@@ -248,15 +268,13 @@ static gpointer namedevent_create (gboolean manual, gboolean initial, const guni
                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)
+mono_w32event_create_full (MonoBoolean manual, MonoBoolean initial, const gchar *name, gint32 *error)
 {
        gpointer event;
 
@@ -265,13 +283,24 @@ ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, Mono
         * was freshly created */
        mono_w32error_set_last (ERROR_SUCCESS);
 
-       event = name ? namedevent_create (manual, initial, mono_string_chars (name)) : event_create (manual, initial);
+       event = name ? namedevent_create (manual, initial, name) : event_create (manual, initial);
 
        *error = mono_w32error_get_last ();
 
        return event;
 }
 
+gpointer
+ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoStringHandle name, gint32 *err, MonoError *error)
+{
+       error_init (error);
+       gchar *utf8_name = mono_string_handle_to_utf8 (name, error);
+       return_val_if_nok (error, NULL);
+       gpointer result = mono_w32event_create_full (manual, initial, utf8_name, err);
+       g_free (utf8_name);
+       return result;
+}
+
 gboolean
 ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle)
 {
@@ -372,18 +401,25 @@ ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle)
 }
 
 gpointer
-ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights G_GNUC_UNUSED, gint32 *error)
+ves_icall_System_Threading_Events_OpenEvent_internal (MonoStringHandle name, gint32 rights G_GNUC_UNUSED, gint32 *err, MonoError *error)
 {
-       gpointer handle;
-       gchar *utf8_name;
+       error_init (error);
+       gchar *utf8_name = mono_string_handle_to_utf8 (name, error);
+       return_val_if_nok (error, NULL);
+       gpointer handle = mono_w32event_open (utf8_name, rights, err);
+       g_free (utf8_name);
+       return handle;
+}
 
+gpointer
+mono_w32event_open (const gchar *utf8_name, gint32 rights G_GNUC_UNUSED, gint32 *error)
+{
+       gpointer handle;
        *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);
@@ -400,8 +436,6 @@ ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 r
        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;
index 792735b02687d3046fd65878a6e37f2ab09714af..9894053b617e4b08474bd2180fb06c06efc05da1 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <windows.h>
 #include <winbase.h>
+#include <mono/metadata/handle.h>
+#include <mono/utils/mono-error-internals.h>
 
 void
 mono_w32event_init (void)
@@ -43,13 +45,22 @@ mono_w32event_reset (gpointer handle)
 }
 
 gpointer
-ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error)
+ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoStringHandle name, gint32 *err, MonoError *error)
 {
        gpointer event;
 
-       event = CreateEvent (NULL, manual, initial, name ? mono_string_chars (name) : NULL);
-
-       *error = GetLastError ();
+       error_init (error);
+       
+       uint32_t gchandle = 0;
+       gunichar2 *uniname = NULL;
+       if (!MONO_HANDLE_IS_NULL (name))
+               uniname = mono_string_handle_pin_chars (name, &gchandle);
+       MONO_ENTER_GC_SAFE;
+       event = CreateEvent (NULL, manual, initial, uniname);
+       *err = GetLastError ();
+       MONO_EXIT_GC_SAFE;
+       if (gchandle)
+               mono_gchandle_free (gchandle);
 
        return event;
 }
@@ -73,15 +84,28 @@ ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle)
 }
 
 gpointer
-ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error)
+ves_icall_System_Threading_Events_OpenEvent_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error)
 {
        gpointer handle;
 
-       *error = ERROR_SUCCESS;
+       error_init (error);
+
+       *err = ERROR_SUCCESS;
+
+       uint32_t gchandle = 0;
+       gunichar2 *uniname = NULL;
 
-       handle = OpenEvent (rights, FALSE, mono_string_chars (name));
+       if (!MONO_HANDLE_IS_NULL (name))
+               uniname = mono_string_handle_pin_chars (name, &gchandle);
+
+       MONO_ENTER_GC_SAFE;
+       handle = OpenEvent (rights, FALSE, uniname);
        if (!handle)
-               *error = GetLastError ();
+               *err = GetLastError ();
+       MONO_EXIT_GC_SAFE;
+
+       if (gchandle)
+               mono_gchandle_free (gchandle);
 
        return handle;
 }
index 3e8d65de06ea8f608c00b39c4d91097d73de0dac..779407de845ae746dea928826b30cc4bb24085c7 100644 (file)
@@ -9,6 +9,7 @@
 #include <glib.h>
 
 #include "object.h"
+#include "object-internals.h"
 #include "w32handle-namespace.h"
 
 void
@@ -27,7 +28,7 @@ void
 mono_w32event_reset (gpointer handle);
 
 gpointer
-ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoString *name, gint32 *error);
+ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoStringHandle name, gint32 *err, MonoError *error);
 
 gboolean
 ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle);
@@ -39,7 +40,7 @@ void
 ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle);
 
 gpointer
-ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error);
+ves_icall_System_Threading_Events_OpenEvent_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error);
 
 typedef struct MonoW32HandleNamedEvent MonoW32HandleNamedEvent;
 
index f6e4d2df5138873927882d9bd3cda436dcba411b..38ca36a1a9eff4f07f8c468757c7d74c7278cb72 100644 (file)
@@ -721,11 +721,6 @@ _wapi_io_scandir (const gchar *dirname, const gchar *pattern, gchar ***namelist)
 static gboolean
 _wapi_lock_file_region (gint fd, off_t offset, off_t length)
 {
-#if defined(__native_client__)
-       printf("WARNING: %s: fcntl() not available on Native Client!\n", __func__);
-       // behave as below -- locks are not available
-       return TRUE;
-#else
        struct flock lock_data;
        gint ret;
 
@@ -766,16 +761,11 @@ _wapi_lock_file_region (gint fd, off_t offset, off_t length)
        }
 
        return TRUE;
-#endif /* __native_client__ */
 }
 
 static gboolean
 _wapi_unlock_file_region (gint fd, off_t offset, off_t length)
 {
-#if defined(__native_client__)
-       printf("WARNING: %s: fcntl() not available on Native Client!\n", __func__);
-       return TRUE;
-#else
        struct flock lock_data;
        gint ret;
 
@@ -811,7 +801,6 @@ _wapi_unlock_file_region (gint fd, off_t offset, off_t length)
        }
 
        return TRUE;
-#endif /* __native_client__ */
 }
 
 static void file_close (gpointer handle, gpointer data);
@@ -1529,8 +1518,6 @@ static gboolean file_setendoffile(gpointer handle)
        }
 #endif
 
-/* Native Client has no ftruncate function, even in standalone sel_ldr. */
-#ifndef __native_client__
        /* always truncate, because the extend write() adds an extra
         * byte to the end of the file
         */
@@ -1547,7 +1534,6 @@ static gboolean file_setendoffile(gpointer handle)
                _wapi_set_last_error_from_errno ();
                return(FALSE);
        }
-#endif
                
        return(TRUE);
 }
@@ -2407,13 +2393,6 @@ mono_w32file_create(const gunichar2 *name, guint32 fileaccess, guint32 sharemode
                
                return(INVALID_HANDLE_VALUE);
        }
-#ifdef __native_client__
-       /* Workaround: Native Client currently returns the same fake inode
-        * for all files, so do a simple hash on the filename so we don't
-        * use the same share info for each file.
-        */
-       statbuf.st_ino = g_str_hash(filename);
-#endif
 
        if (share_allows_open (&statbuf, sharemode, fileaccess,
                         &file_handle.share_info) == FALSE) {
@@ -2518,7 +2497,6 @@ gboolean mono_w32file_delete(const gunichar2 *name)
        gchar *filename;
        gint retval;
        gboolean ret = FALSE;
-       guint32 attrs;
 #if 0
        struct stat statbuf;
        FileShare *shareinfo;
@@ -2539,14 +2517,6 @@ gboolean mono_w32file_delete(const gunichar2 *name)
                return(FALSE);
        }
 
-       attrs = mono_w32file_get_attributes (name);
-       if (attrs == INVALID_FILE_ATTRIBUTES) {
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file attributes error", __func__);
-               /* Error set by mono_w32file_get_attributes() */
-               g_free (filename);
-               return(FALSE);
-       }
-
 #if 0
        /* Check to make sure sharing allows us to open the file for
         * writing.  See bug 323389.
@@ -2997,7 +2967,6 @@ _wapi_stdhandle_create (gint fd, const gchar *name)
 
        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating standard handle type %s, fd %d", __func__, name, fd);
 
-#if !defined(__native_client__)
        /* Check if fd is valid */
        do {
                flags = fcntl(fd, F_GETFL);
@@ -3028,13 +2997,6 @@ _wapi_stdhandle_create (gint fd, const gchar *name)
                file_handle.fileaccess = 0;
                break;
        }
-#else
-       /*
-        * fcntl will return -1 in nacl, as there is no real file system API.
-        * Yet, standard streams are available.
-        */
-       file_handle.fileaccess = (fd == STDIN_FILENO) ? GENERIC_READ : GENERIC_WRITE;
-#endif
 
        file_handle.fd = fd;
        file_handle.filename = g_strdup(name);
@@ -3538,7 +3500,6 @@ retry:
                goto retry;
        }
 
-#ifndef __native_client__
        result = _wapi_lstat (filename, &linkbuf);
        if (result != 0) {
                mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lstat failed: %s", __func__, filename);
@@ -3546,7 +3507,6 @@ retry:
                g_free (filename);
                goto retry;
        }
-#endif
 
        utf8_filename = mono_utf8_from_external (filename);
        if (utf8_filename == NULL) {
@@ -3570,11 +3530,7 @@ retry:
        else
                create_time = buf.st_ctime;
        
-#ifdef __native_client__
-       find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, NULL);
-#else
        find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
-#endif
 
        time_t_to_filetime (create_time, &find_data->ftCreationTime);
        time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
@@ -3748,7 +3704,7 @@ mono_w32file_get_attributes (const gunichar2 *name)
        }
 
        result = _wapi_stat (utf8_name, &buf);
-       if (result == -1 && errno == ENOENT) {
+       if (result == -1 && (errno == ENOENT || errno == ELOOP)) {
                /* Might be a dangling symlink... */
                result = _wapi_lstat (utf8_name, &buf);
        }
@@ -3759,20 +3715,14 @@ mono_w32file_get_attributes (const gunichar2 *name)
                return (INVALID_FILE_ATTRIBUTES);
        }
 
-#ifndef __native_client__
        result = _wapi_lstat (utf8_name, &linkbuf);
        if (result != 0) {
                _wapi_set_last_path_error_from_errno (NULL, utf8_name);
                g_free (utf8_name);
                return (INVALID_FILE_ATTRIBUTES);
        }
-#endif
        
-#ifdef __native_client__
-       ret = _wapi_stat_to_file_attributes (utf8_name, &buf, NULL);
-#else
        ret = _wapi_stat_to_file_attributes (utf8_name, &buf, &linkbuf);
-#endif
        
        g_free (utf8_name);
 
@@ -3917,12 +3867,6 @@ mono_w32file_get_cwd (guint32 length, gunichar2 *buffer)
        glong count;
        gsize bytes;
 
-#ifdef __native_client__
-       gchar *path = g_get_current_dir ();
-       if (length < strlen(path) + 1 || path == NULL)
-               return 0;
-       memcpy (buffer, path, strlen(path) + 1);
-#else
        if (getcwd ((gchar*)buffer, length) == NULL) {
                if (errno == ERANGE) { /*buffer length is not big enough */ 
                        gchar *path = g_get_current_dir (); /*FIXME g_get_current_dir doesn't work with broken paths and calling it just to know the path length is silly*/
@@ -3936,7 +3880,6 @@ mono_w32file_get_cwd (guint32 length, gunichar2 *buffer)
                _wapi_set_last_error_from_errno ();
                return 0;
        }
-#endif
 
        utf16_path = mono_unicode_from_external ((gchar*)buffer, &bytes);
        count = (bytes/2)+1;
@@ -4928,7 +4871,7 @@ mono_w32file_get_drive_type(const gunichar2 *root_path_name)
        return (drive_type);
 }
 
-#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__) || defined(__HAIKU__)
+#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__FreeBSD_kernel__) || defined(__HAIKU__)
 static gchar*
 get_fstypename (gchar *utfpath)
 {
index 50ca016f284c309976d362d269afa900fc5f43d9..6975c48934b2057e05085f0b65505247bcf934f0 100644 (file)
@@ -56,7 +56,7 @@ has_namespace (MonoW32HandleType type)
 typedef struct {
        gpointer ret;
        MonoW32HandleType type;
-       gchar *name;
+       const gchar *name;
 } NamespaceSearchHandleData;
 
 static gboolean
@@ -103,7 +103,7 @@ mono_w32handle_namespace_search_handle_callback (gpointer handle, gpointer data,
 }
 
 gpointer
-mono_w32handle_namespace_search_handle (MonoW32HandleType type, gchar *name)
+mono_w32handle_namespace_search_handle (MonoW32HandleType type, const gchar *name)
 {
        NamespaceSearchHandleData search_data;
 
index 6d9c4e6c7be4802ea46eb554ac8921899143fbd8..5fcc99fc4002a3c73ecc157fb152ff28d15d6eac 100644 (file)
@@ -26,6 +26,6 @@ void
 mono_w32handle_namespace_unlock (void);
 
 gpointer
-mono_w32handle_namespace_search_handle (MonoW32HandleType type, gchar *name);
+mono_w32handle_namespace_search_handle (MonoW32HandleType type, const gchar *name);
 
 #endif /* _MONO_METADATA_W32HANDLE_NAMESPACE_H_ */
index 6500ba7fcf0d9d75cd73253f349f8c7d4b5bac00..f6862a9a7dba737452b39cb840286b84d52883c1 100644 (file)
@@ -809,7 +809,7 @@ mono_w32handle_ops_signal (gpointer handle)
        type = handle_data->type;
 
        if (handle_ops[type] != NULL && handle_ops[type]->signal != NULL) {
-               handle_ops[type]->signal (handle);
+               handle_ops[type]->signal (handle, handle_data->specific);
        }
 }
 
index 741dd0832356212c99d603faf744da68e4ffc4cf..029f24dad82d3135cccc00d71e162b2d78d27424 100644 (file)
@@ -53,7 +53,7 @@ typedef struct
        void (*close)(gpointer handle, gpointer data);
 
        /* mono_w32handle_signal_and_wait */
-       void (*signal)(gpointer signal);
+       void (*signal)(gpointer signal, gpointer data);
 
        /* Called by mono_w32handle_wait_one and mono_w32handle_wait_multiple,
         * with the handle locked (shared handles aren't locked.)
index ee3ae7e740d24b3990dc2621f9f63fd536892252..189b808ba22436aace20b71b1449db5ca1838f88 100644 (file)
@@ -32,6 +32,9 @@ struct MonoW32HandleNamedMutex {
        MonoW32HandleNamespace sharedns;
 };
 
+gpointer
+mono_w32mutex_open (const gchar* utf8_name, gint32 right G_GNUC_UNUSED, gint32 *error);
+
 static void
 thread_own_mutex (MonoInternalThread *internal, gpointer handle)
 {
@@ -61,6 +64,38 @@ thread_disown_mutex (MonoInternalThread *internal, gpointer handle)
        mono_w32handle_unref (handle);
 }
 
+static void
+mutex_handle_signal (gpointer handle, MonoW32HandleType type, MonoW32HandleMutex *mutex_handle)
+{
+       pthread_t tid;
+
+       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: signalling %s handle %p, tid: %p recursion: %d",
+               __func__, mono_w32handle_get_typename (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion);
+
+       tid = pthread_self ();
+
+       if (mutex_handle->abandoned) {
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p is abandoned",
+                       __func__, mono_w32handle_get_typename (type), handle);
+       } else if (!pthread_equal (mutex_handle->tid, tid)) {
+               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_get_typename (type), handle, (long)mutex_handle->tid, (long)tid);
+       } else {
+               /* 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_get_typename (type), handle, (gpointer) mutex_handle->tid, mutex_handle->recursion);
+
+                       mutex_handle->tid = 0;
+                       mono_w32handle_set_signal_state (handle, TRUE, FALSE);
+               }
+       }
+}
+
 static gboolean
 mutex_handle_own (gpointer handle, MonoW32HandleType type, gboolean *abandoned)
 {
@@ -120,9 +155,9 @@ mutex_handle_is_owned (gpointer handle, MonoW32HandleType type)
        }
 }
 
-static void mutex_signal(gpointer handle)
+static void mutex_signal(gpointer handle, gpointer handle_specific)
 {
-       ves_icall_System_Threading_Mutex_ReleaseMutex_internal (handle);
+       mutex_handle_signal (handle, MONO_W32HANDLE_MUTEX, (MonoW32HandleMutex*) handle_specific);
 }
 
 static gboolean mutex_own (gpointer handle, gboolean *abandoned)
@@ -132,13 +167,12 @@ static gboolean mutex_own (gpointer handle, gboolean *abandoned)
 
 static gboolean mutex_is_owned (gpointer handle)
 {
-       
        return mutex_handle_is_owned (handle, MONO_W32HANDLE_MUTEX);
 }
 
-static void namedmutex_signal (gpointer handle)
+static void namedmutex_signal (gpointer handle, gpointer handle_specific)
 {
-       ves_icall_System_Threading_Mutex_ReleaseMutex_internal (handle);
+       mutex_handle_signal (handle, MONO_W32HANDLE_NAMEDMUTEX, (MonoW32HandleMutex*) handle_specific);
 }
 
 /* NB, always called with the shared handle lock held */
@@ -304,10 +338,9 @@ static gpointer mutex_create (gboolean owned)
        return mutex_handle_create (&mutex_handle, MONO_W32HANDLE_MUTEX, owned);
 }
 
-static gpointer namedmutex_create (gboolean owned, const gunichar2 *name)
+static gpointer namedmutex_create (gboolean owned, const gchar *utf8_name)
 {
        gpointer handle;
-       gchar *utf8_name;
 
        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating %s handle",
                __func__, mono_w32handle_get_typename (MONO_W32HANDLE_NAMEDMUTEX));
@@ -315,8 +348,7 @@ static gpointer namedmutex_create (gboolean owned, const gunichar2 *name)
        /* w32 seems to guarantee that opening named objects can't race each other */
        mono_w32handle_namespace_lock ();
 
-       glong utf8_len = 0;
-       utf8_name = g_utf16_to_utf8 (name, -1, NULL, &utf8_len, NULL);
+       glong utf8_len = strlen (utf8_name);
 
        handle = mono_w32handle_namespace_search_handle (MONO_W32HANDLE_NAMEDMUTEX, utf8_name);
        if (handle == INVALID_HANDLE_VALUE) {
@@ -339,18 +371,17 @@ static gpointer namedmutex_create (gboolean owned, const gunichar2 *name)
                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)
+ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoStringHandle name, MonoBoolean *created, MonoError *error)
 {
        gpointer mutex;
 
+       error_init (error);
        *created = TRUE;
 
        /* Need to blow away any old errors here, because code tests
@@ -358,13 +389,17 @@ ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoSt
         * was freshly created */
        mono_w32error_set_last (ERROR_SUCCESS);
 
-       if (!name) {
+       if (MONO_HANDLE_IS_NULL (name)) {
                mutex = mutex_create (owned);
        } else {
-               mutex = namedmutex_create (owned, mono_string_chars (name));
+               gchar *utf8_name = mono_string_handle_to_utf8 (name, error);
+               return_val_if_nok (error, NULL);
+
+               mutex = namedmutex_create (owned, utf8_name);
 
                if (mono_w32error_get_last () == ERROR_ALREADY_EXISTS)
                        *created = FALSE;
+               g_free (utf8_name);
        }
 
        return mutex;
@@ -436,18 +471,26 @@ ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
 }
 
 gpointer
-ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights G_GNUC_UNUSED, gint32 *error)
+ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoStringHandle name, gint32 rights G_GNUC_UNUSED, gint32 *err, MonoError *error)
+{
+       error_init (error);
+       gchar *utf8_name = mono_string_handle_to_utf8 (name, error);
+       return_val_if_nok (error, NULL);
+       gpointer handle = mono_w32mutex_open (utf8_name, rights, err);
+       g_free (utf8_name);
+       return handle;
+}
+
+gpointer
+mono_w32mutex_open (const gchar* utf8_name, gint32 right 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);
 
@@ -466,8 +509,6 @@ ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 ri
                __func__, handle);
 
 cleanup:
-       g_free (utf8_name);
-
        mono_w32handle_namespace_unlock ();
 
        return handle;
index 44b29b5c14bbf1e4175773710cb4c0f6319f7eb5..f7a68c5c74bced5032da9b71b667236a2dff5d71 100644 (file)
@@ -12,6 +12,9 @@
 
 #include <windows.h>
 #include <winbase.h>
+#include <mono/metadata/handle.h>
+#include <mono/utils/mono-error-internals.h>
+
 
 void
 mono_w32mutex_init (void)
@@ -19,19 +22,28 @@ mono_w32mutex_init (void)
 }
 
 gpointer
-ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
+ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoStringHandle name, MonoBoolean *created, MonoError *error)
 {
        HANDLE mutex;
 
+       error_init (error);
+
        *created = TRUE;
 
-       if (!name) {
+       if (MONO_HANDLE_IS_NULL (name)) {
+               MONO_ENTER_GC_SAFE;
                mutex = CreateMutex (NULL, owned, NULL);
+               MONO_EXIT_GC_SAFE;
        } else {
-               mutex = CreateMutex (NULL, owned, mono_string_chars (name));
+               uint32_t gchandle;
+               gunichar2 *uniname = mono_string_handle_pin_chars (name, &gchandle);
+               MONO_ENTER_GC_SAFE;
+               mutex = CreateMutex (NULL, owned, uniname);
 
                if (GetLastError () == ERROR_ALREADY_EXISTS)
                        *created = FALSE;
+               MONO_EXIT_GC_SAFE;
+               mono_gchandle_free (gchandle);
        }
 
        return mutex;
@@ -44,15 +56,24 @@ ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle)
 }
 
 gpointer
-ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights, gint32 *error)
+ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error)
 {
        HANDLE ret;
 
-       *error = ERROR_SUCCESS;
+       error_init (error);
+       *err = ERROR_SUCCESS;
 
-       ret = OpenMutex (rights, FALSE, mono_string_chars (name));
+       uint32_t gchandle = 0;
+       gunichar2 *uniname = NULL;
+       if (!MONO_HANDLE_IS_NULL (name))
+               uniname = mono_string_handle_pin_chars (name, &gchandle);
+       MONO_ENTER_GC_SAFE;
+       ret = OpenMutex (rights, FALSE, uniname);
        if (!ret)
-               *error = GetLastError ();
+               *err = GetLastError ();
+       MONO_EXIT_GC_SAFE;
+       if (gchandle != 0)
+               mono_gchandle_free (gchandle);
 
        return ret;
 }
index b80fd1c3ce24d98c9f141f91d35c07fcb94f3a72..375731591525d9e75d3b4658723e6308c0cd486d 100644 (file)
@@ -9,19 +9,20 @@
 #include <glib.h>
 
 #include "object.h"
+#include "object-internals.h"
 #include "w32handle-namespace.h"
 
 void
 mono_w32mutex_init (void);
 
 gpointer
-ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created);
+ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoStringHandle name, MonoBoolean *created, MonoError *error);
 
 MonoBoolean
 ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle);
 
 gpointer
-ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoString *name, gint32 rights, gint32 *error);
+ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error);
 
 typedef struct MonoW32HandleNamedMutex MonoW32HandleNamedMutex;
 
index 22336c2fd45e90ba75451c214541bf89e9439c3e..0db4d5946fdc9f854d0c465c0437e1c4fabb93dd 100644 (file)
@@ -27,6 +27,24 @@ struct MonoW32HandleNamedSemaphore {
        MonoW32HandleNamespace sharedns;
 };
 
+static void sem_handle_signal (gpointer handle, MonoW32HandleType type, MonoW32HandleSemaphore *sem_handle)
+{
+       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: signalling %s handle %p",
+               __func__, mono_w32handle_get_typename (type), handle);
+
+       /* No idea why max is signed, but thats the spec :-( */
+       if (sem_handle->val + 1 > (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_get_typename (type), handle, sem_handle->val, 1, sem_handle->max);
+       } else {
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s handle %p val %d count %d max %d",
+                       __func__, mono_w32handle_get_typename (type), handle, sem_handle->val, 1, sem_handle->max);
+
+               sem_handle->val += 1;
+               mono_w32handle_set_signal_state (handle, TRUE, TRUE);
+       }
+}
+
 static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type, gboolean *abandoned)
 {
        MonoW32HandleSemaphore *sem_handle;
@@ -50,9 +68,9 @@ static gboolean sem_handle_own (gpointer handle, MonoW32HandleType type, gboolea
        return TRUE;
 }
 
-static void sema_signal(gpointer handle)
+static void sema_signal(gpointer handle, gpointer handle_specific)
 {
-       ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal(handle, 1, NULL);
+       sem_handle_signal (handle, MONO_W32HANDLE_SEM, (MonoW32HandleSemaphore*) handle_specific);
 }
 
 static gboolean sema_own (gpointer handle, gboolean *abandoned)
@@ -60,9 +78,9 @@ static gboolean sema_own (gpointer handle, gboolean *abandoned)
        return sem_handle_own (handle, MONO_W32HANDLE_SEM, abandoned);
 }
 
-static void namedsema_signal (gpointer handle)
+static void namedsema_signal (gpointer handle, gpointer handle_specific)
 {
-       ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (handle, 1, NULL);
+       sem_handle_signal (handle, MONO_W32HANDLE_NAMEDSEM, (MonoW32HandleSemaphore*) handle_specific);
 }
 
 /* NB, always called with the shared handle lock held */
index 70b36ed2fa36feb4b22bd3579f3dc6e551a35207..87743377324bc01c406342ed181dd3d7229d36ff 100644 (file)
@@ -12,6 +12,7 @@
 #include <pthread.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <sys/socket.h>
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
@@ -27,7 +28,6 @@
 #endif
 #include <errno.h>
 #include <fcntl.h>
-#include <sys/types.h>
 #ifdef HAVE_SYS_UIO_H
 #include <sys/uio.h>
 #endif
@@ -1331,8 +1331,9 @@ mono_w32socket_convert_error (gint error)
 }
 
 gboolean
-ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError *error)
 {
+       error_init (error);
 #if defined (SO_REUSEPORT)
        return TRUE;
 #else
index e6a6f9713a42afb628240a0fc970286528629a0c..a3f8d410583248e150c7a930fa068255ad35624f 100644 (file)
@@ -310,7 +310,8 @@ mono_w32socket_convert_error (gint error)
 }
 
 gboolean
-ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto)
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError *error)
 {
+       error_init (error);
        return TRUE;
 }
index 0ce2b04e6258bdf10bcb66305f9285306ea4b134..bd802a67bb1c2c1f7c07a14c70e3b1e9f8a8c468 100644 (file)
 #define LOGDEBUG(...)  
 /* define LOGDEBUG(...) g_message(__VA_ARGS__)  */
 
+static gboolean
+addrinfo_to_IPHostEntry_handles (MonoAddressInfo *info, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gboolean add_local_ips, MonoError *error);
+
+static MonoObjectHandle
+create_object_handle_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror, MonoError *error);
+
+static struct sockaddr*
+create_sockaddr_from_handle (MonoObjectHandle saddr_obj, socklen_t *sa_size, gint32 *werror, MonoError *error);
+
 #ifdef HOST_WIN32
 
 static SOCKET
@@ -683,13 +692,14 @@ get_socket_assembly (void)
 }
 
 gpointer
-ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObject *this_obj, gint32 family, gint32 type, gint32 proto, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObjectHandle this_obj, gint32 family, gint32 type, gint32 proto, gint32 *werror, MonoError *error)
 {
        SOCKET sock;
        gint32 sock_family;
        gint32 sock_proto;
        gint32 sock_type;
        
+       error_init (error);
        *werror = 0;
        
        sock_family = convert_family ((MonoAddressFamily)family);
@@ -724,10 +734,11 @@ ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObject *this_obj, gint3
  * file) is really an IntPtr which needs to be converted to a guint32.
  */
 void
-ves_icall_System_Net_Sockets_Socket_Close_internal (gsize sock, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Close_internal (gsize sock, gint32 *werror, MonoError *error)
 {
        LOGDEBUG (g_message ("%s: closing 0x%x", __func__, sock));
 
+       error_init (error);
        *werror = 0;
 
        /* Clear any pending work item from this socket if the underlying
@@ -748,11 +759,12 @@ ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal (void)
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *werror, MonoError *error)
 {
        int ret;
        guint64 amount;
        
+       error_init (error);
        *werror = 0;
 
        /* FIXME: this might require amount to be unsigned long. */
@@ -766,10 +778,11 @@ ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *werr
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean block, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean block, gint32 *werror, MonoError *error)
 {
        int ret;
        
+       error_init (error);
        *werror = 0;
 
        ret = mono_w32socket_set_blocking (sock, block);
@@ -778,11 +791,12 @@ ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean bloc
 }
 
 gpointer
-ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *werror, gboolean blocking, MonoError *error)
 {
        gboolean interrupted;
        SOCKET newsock;
 
+       error_init (error);
        *werror = 0;
 
        mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
@@ -809,10 +823,11 @@ ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *werror,
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_Listen_internal(gsize sock, guint32 backlog, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Listen_internal(gsize sock, guint32 backlog, gint32 *werror, MonoError *error)
 {
        int ret;
        
+       error_init (error);
        *werror = 0;
 
        MONO_ENTER_GC_SAFE;
@@ -846,12 +861,10 @@ is_ipv4_mapped_any (const struct in6_addr *addr)
 }
 #endif
 
-static MonoObject*
-create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror, MonoError *error)
+static MonoObjectHandle
+create_object_handle_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror, MonoError *error)
 {
        MonoDomain *domain = mono_domain_get ();
-       MonoObject *sockaddr_obj;
-       MonoArray *data;
        MonoAddressFamily family;
 
        error_init (error);
@@ -859,8 +872,8 @@ create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror
        /* Build a System.Net.SocketAddress object instance */
        if (!domain->sockaddr_class)
                domain->sockaddr_class = mono_class_load_from_name (get_socket_assembly (), "System.Net", "SocketAddress");
-       sockaddr_obj = mono_object_new_checked (domain, domain->sockaddr_class, error);
-       return_val_if_nok (error, NULL);
+       MonoObjectHandle sockaddr_obj = MONO_HANDLE_NEW (MonoObject, mono_object_new_checked (domain, domain->sockaddr_class, error));
+       return_val_if_nok (error, MONO_HANDLE_NEW (MonoObject, NULL));
        
        /* Locate the SocketAddress data buffer in the object */
        if (!domain->sockaddr_data_field) {
@@ -878,8 +891,8 @@ create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror
         * the length of the entire sockaddr_in/in6, including
         * sizeof (unsigned short) of the family */
        /* We can't really avoid the +2 as all code below depends on this size - INCLUDING unix domain sockets.*/
-       data = mono_array_new_cached (domain, mono_get_byte_class (), sa_size + 2, error);
-       return_val_if_nok (error, NULL);
+       MonoArrayHandle data = mono_array_new_handle (domain, mono_get_byte_class (), sa_size + 2, error);
+       return_val_if_nok (error, MONO_HANDLE_NEW (MonoObject, NULL));
 
        /* The data buffer is laid out as follows:
         * bytes 0 and 1 are the address family
@@ -890,11 +903,11 @@ create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror
        family = convert_to_mono_family (saddr->sa_family);
        if (family == AddressFamily_Unknown) {
                *werror = WSAEAFNOSUPPORT;
-               return NULL;
+               return MONO_HANDLE_NEW (MonoObject, NULL);
        }
 
-       mono_array_set (data, guint8, 0, family & 0x0FF);
-       mono_array_set (data, guint8, 1, (family >> 8) & 0x0FF);
+       MONO_HANDLE_ARRAY_SETVAL (data, guint8, 0, family & 0x0FF);
+       MONO_HANDLE_ARRAY_SETVAL (data, guint8, 1, (family >> 8) & 0x0FF);
        
        if (saddr->sa_family == AF_INET) {
                struct sockaddr_in *sa_in = (struct sockaddr_in *)saddr;
@@ -903,19 +916,19 @@ create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror
                int buffer_size = 8;
                
                if (sa_size < buffer_size) {
-                       mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
-                       return NULL;
+                       mono_error_set_generic_error (error, "System", "SystemException", "");
+                       return MONO_HANDLE_NEW (MonoObject, NULL);
                }
                
-               mono_array_set (data, guint8, 2, (port>>8) & 0xff);
-               mono_array_set (data, guint8, 3, (port) & 0xff);
-               mono_array_set (data, guint8, 4, (address>>24) & 0xff);
-               mono_array_set (data, guint8, 5, (address>>16) & 0xff);
-               mono_array_set (data, guint8, 6, (address>>8) & 0xff);
-               mono_array_set (data, guint8, 7, (address) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 2, (port>>8) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 3, (port) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 4, (address>>24) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 5, (address>>16) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 6, (address>>8) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 7, (address) & 0xff);
        
-               mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
-               mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
+               mono_field_set_value (MONO_HANDLE_RAW (sockaddr_obj), domain->sockaddr_data_field, MONO_HANDLE_RAW (data)); /* FIXME: use handles for mono_field_set_value */
+               mono_field_set_value (MONO_HANDLE_RAW (sockaddr_obj), domain->sockaddr_data_length_field, &buffer_size); /* FIXME: use handles for mono_field_set_value */
 
                return sockaddr_obj;
        }
@@ -928,34 +941,34 @@ create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror
                guint16 port = ntohs (sa_in->sin6_port);
 
                if (sa_size < buffer_size) {
-                       mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
-                       return NULL;
+                       mono_error_set_generic_error (error, "System", "SystemException", "");
+                       return MONO_HANDLE_NEW (MonoObject, NULL);
                }
 
-               mono_array_set (data, guint8, 2, (port>>8) & 0xff);
-               mono_array_set (data, guint8, 3, (port) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 2, (port>>8) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 3, (port) & 0xff);
                
                if (is_ipv4_mapped_any (&sa_in->sin6_addr)) {
                        // Map ::ffff:0:0 to :: (bug #5502)
                        for (i = 0; i < 16; i++)
-                               mono_array_set (data, guint8, 8 + i, 0);
+                               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 8 + i, 0);
                } else {
                        for (i = 0; i < 16; i++) {
-                               mono_array_set (data, guint8, 8 + i,
-                                                               sa_in->sin6_addr.s6_addr [i]);
+                               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 8 + i,
+                                                         sa_in->sin6_addr.s6_addr [i]);
                        }
                }
 
-               mono_array_set (data, guint8, 24, sa_in->sin6_scope_id & 0xff);
-               mono_array_set (data, guint8, 25,
-                                               (sa_in->sin6_scope_id >> 8) & 0xff);
-               mono_array_set (data, guint8, 26,
-                                               (sa_in->sin6_scope_id >> 16) & 0xff);
-               mono_array_set (data, guint8, 27,
-                                               (sa_in->sin6_scope_id >> 24) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 24, sa_in->sin6_scope_id & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 25,
+                                         (sa_in->sin6_scope_id >> 8) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 26,
+                                         (sa_in->sin6_scope_id >> 16) & 0xff);
+               MONO_HANDLE_ARRAY_SETVAL (data, guint8, 27,
+                                         (sa_in->sin6_scope_id >> 24) & 0xff);
 
-               mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
-               mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
+               mono_field_set_value (MONO_HANDLE_RAW (sockaddr_obj), domain->sockaddr_data_field, MONO_HANDLE_RAW (data)); /* FIXME: use handles for mono_field_set_value */
+               mono_field_set_value (MONO_HANDLE_RAW (sockaddr_obj), domain->sockaddr_data_length_field, &buffer_size); /* FIXME: use handles for mono_field_set_value */
 
                return sockaddr_obj;
        }
@@ -966,17 +979,17 @@ create_object_from_sockaddr (struct sockaddr *saddr, int sa_size, gint32 *werror
                int buffer_size = sa_size + 2;
 
                for (i = 0; i < sa_size; i++)
-                       mono_array_set (data, guint8, i + 2, saddr->sa_data [i]);
+                       MONO_HANDLE_ARRAY_SETVAL (data, guint8, i + 2, saddr->sa_data [i]);
                
-               mono_field_set_value (sockaddr_obj, domain->sockaddr_data_field, data);
-               mono_field_set_value (sockaddr_obj, domain->sockaddr_data_length_field, &buffer_size);
+               mono_field_set_value (MONO_HANDLE_RAW (sockaddr_obj), domain->sockaddr_data_field, MONO_HANDLE_RAW (data)); /* FIXME: use handles for mono_field_set_value */
+               mono_field_set_value (MONO_HANDLE_RAW (sockaddr_obj), domain->sockaddr_data_length_field, &buffer_size); /* FIXME: use handles for mono_field_set_value */
 
                return sockaddr_obj;
        }
 #endif
        else {
                *werror = WSAEAFNOSUPPORT;
-               return NULL;
+               return MONO_HANDLE_NEW (MonoObject, NULL);
        }
 }
 
@@ -1002,14 +1015,12 @@ get_sockaddr_size (int family)
        return size;
 }
 
-MonoObject*
-ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 af, gint32 *werror)
+MonoObjectHandle
+ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 af, gint32 *werror, MonoError *error)
 {
        gchar *sa;
        socklen_t salen;
        int ret;
-       MonoObject *result;
-       MonoError error;
        
        *werror = 0;
        
@@ -1030,34 +1041,31 @@ ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 a
                *werror = mono_w32socket_get_last_error ();
                if (salen > 128)
                        g_free (sa);
-               return NULL;
+               return NULL_HANDLE;
        }
        
        LOGDEBUG (g_message("%s: bound to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)&sa)->sin_addr), ntohs (((struct sockaddr_in *)&sa)->sin_port)));
 
-       result = create_object_from_sockaddr ((struct sockaddr *)sa, salen, werror, &error);
+       MonoObjectHandle result = create_object_handle_from_sockaddr ((struct sockaddr *)sa, salen, werror, error);
        if (salen > 128)
                g_free (sa);
-       if (!mono_error_ok (&error))
-               mono_error_set_pending_exception (&error);
        return result;
 }
 
-MonoObject*
-ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32 af, gint32 *werror)
+MonoObjectHandle
+ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32 af, gint32 *werror, MonoError *error)
 {
        gchar *sa;
        socklen_t salen;
        int ret;
-       MonoObject *result;
-       MonoError error;
        
+       error_init (error);
        *werror = 0;
        
        salen = get_sockaddr_size (convert_family ((MonoAddressFamily)af));
        if (salen == 0) {
                *werror = WSAEAFNOSUPPORT;
-               return NULL;
+               return MONO_HANDLE_NEW (MonoObject, NULL);
        }
        sa = (salen <= 128) ? (gchar *)alloca (salen) : (gchar *)g_malloc0 (salen);
        /* Note: linux returns just 2 for AF_UNIX. Always. */
@@ -1072,24 +1080,21 @@ ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32
                *werror = mono_w32socket_get_last_error ();
                if (salen > 128)
                        g_free (sa);
-               return NULL;
+               return MONO_HANDLE_NEW (MonoObject, NULL);
        }
        
        LOGDEBUG (g_message("%s: connected to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)&sa)->sin_addr), ntohs (((struct sockaddr_in *)&sa)->sin_port)));
 
-       result = create_object_from_sockaddr ((struct sockaddr *)sa, salen, werror, &error);
+       MonoObjectHandle result = create_object_handle_from_sockaddr ((struct sockaddr *)sa, salen, werror, error);
        if (salen > 128)
                g_free (sa);
-       if (!mono_error_ok (&error))
-               mono_error_set_pending_exception (&error);
        return result;
 }
 
 static struct sockaddr*
-create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *werror, MonoError *error)
+create_sockaddr_from_handle (MonoObjectHandle saddr_obj, socklen_t *sa_size, gint32 *werror, MonoError *error)
 {
        MonoDomain *domain = mono_domain_get ();
-       MonoArray *data;
        gint32 family;
        int len;
 
@@ -1110,7 +1115,7 @@ create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *
                g_assert (domain->sockaddr_data_length_field);
        }
 
-       data = *(MonoArray **)(((char *)saddr_obj) + domain->sockaddr_data_field->offset);
+       MonoArrayHandle data = MONO_HANDLE_NEW_GET_FIELD (saddr_obj, MonoArray, domain->sockaddr_data_field);
 
        /* The data buffer is laid out as follows:
         * byte 0 is the address family low byte
@@ -1121,33 +1126,33 @@ create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *
         * UNIX:
         *      the rest is the file name
         */
-       len = *(int *)(((char *)saddr_obj) + domain->sockaddr_data_length_field->offset);
+       len = MONO_HANDLE_GET_FIELD_VAL (saddr_obj, int, domain->sockaddr_data_length_field);
        g_assert (len >= 2);
 
-       family = convert_family ((MonoAddressFamily)(mono_array_get (data, guint8, 0) + (mono_array_get (data, guint8, 1) << 8)));
+       uint32_t gchandle;
+       guint8 *buf = MONO_ARRAY_HANDLE_PIN (data, guint8, 0, &gchandle);
+       family = convert_family ((MonoAddressFamily)(buf[0] + (buf[1] << 8)));
        if (family == AF_INET) {
                struct sockaddr_in *sa;
                guint16 port;
                guint32 address;
                
                if (len < 8) {
-                       mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
+                       mono_error_set_generic_error (error, "System", "SystemException", "");
+                       mono_gchandle_free (gchandle);
                        return NULL;
                }
 
                sa = g_new0 (struct sockaddr_in, 1);
-               port = (mono_array_get (data, guint8, 2) << 8) +
-                       mono_array_get (data, guint8, 3);
-               address = (mono_array_get (data, guint8, 4) << 24) +
-                       (mono_array_get (data, guint8, 5) << 16 ) +
-                       (mono_array_get (data, guint8, 6) << 8) +
-                       mono_array_get (data, guint8, 7);
+               port = (buf[2] << 8) + buf[3];
+               address = (buf[4] << 24) + (buf[5] << 16) + (buf[6] << 8) + buf[7];
 
                sa->sin_family = family;
                sa->sin_addr.s_addr = htonl (address);
                sa->sin_port = htons (port);
 
                *sa_size = sizeof (struct sockaddr_in);
+               mono_gchandle_free (gchandle);
                return (struct sockaddr *)sa;
        }
 #ifdef HAVE_STRUCT_SOCKADDR_IN6
@@ -1158,26 +1163,24 @@ create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *
                guint32 scopeid;
                
                if (len < 28) {
-                       mono_error_set_exception_instance (error, mono_exception_from_name (mono_get_corlib (), "System", "SystemException"));
+                       mono_error_set_generic_error (error, "System", "SystemException", "");
+                       mono_gchandle_free (gchandle);
                        return NULL;
                }
 
                sa = g_new0 (struct sockaddr_in6, 1);
-               port = mono_array_get (data, guint8, 3) +
-                       (mono_array_get (data, guint8, 2) << 8);
-               scopeid = mono_array_get (data, guint8, 24) + 
-                       (mono_array_get (data, guint8, 25) << 8) + 
-                       (mono_array_get (data, guint8, 26) << 16) + 
-                       (mono_array_get (data, guint8, 27) << 24);
+               port = buf[3] + (buf[2] << 8);
+               scopeid = buf[24] + (buf[25] << 8) + (buf[26] << 16) + (buf[27] << 24);
 
                sa->sin6_family = family;
                sa->sin6_port = htons (port);
                sa->sin6_scope_id = scopeid;
 
                for (i = 0; i < 16; i++)
-                       sa->sin6_addr.s6_addr [i] = mono_array_get (data, guint8, 8 + i);
+                       sa->sin6_addr.s6_addr [i] = buf[8 + i];
 
                *sa_size = sizeof (struct sockaddr_in6);
+               mono_gchandle_free (gchandle);
                return (struct sockaddr *)sa;
        }
 #endif
@@ -1191,6 +1194,7 @@ create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *
                 */
                if (len - 2 >= sizeof (sock_un->sun_path)) {
                        mono_error_set_exception_instance (error, mono_get_exception_index_out_of_range ());
+                       mono_gchandle_free (gchandle);
                        return NULL;
                }
                
@@ -1198,35 +1202,34 @@ create_sockaddr_from_object (MonoObject *saddr_obj, socklen_t *sa_size, gint32 *
 
                sock_un->sun_family = family;
                for (i = 0; i < len - 2; i++)
-                       sock_un->sun_path [i] = mono_array_get (data, guint8, i + 2);
+                       sock_un->sun_path [i] = buf[i + 2];
                
                *sa_size = len;
+               mono_gchandle_free (gchandle);
                return (struct sockaddr *)sock_un;
        }
 #endif
        else {
                *werror = WSAEAFNOSUPPORT;
+               mono_gchandle_free (gchandle);
                return 0;
        }
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_Bind_internal (gsize sock, MonoObject *sockaddr, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Bind_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, MonoError *error)
 {
-       MonoError error;
        struct sockaddr *sa;
        socklen_t sa_size;
        int ret;
        
+       error_init (error);
        *werror = 0;
        
-       sa = create_sockaddr_from_object (sockaddr, &sa_size, werror, &error);
+       sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
        if (*werror != 0)
                return;
-       if (!mono_error_ok (&error)) {
-               mono_error_set_pending_exception (&error);
-               return;
-       }
+       return_if_nok (error);
 
        LOGDEBUG (g_message("%s: binding to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
 
@@ -1246,7 +1249,7 @@ enum {
 
 MonoBoolean
 ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode,
-                                                                                                  gint timeout, gint32 *werror)
+                                                  gint timeout, gint32 *werror, MonoError *error)
 {
        MonoInternalThread *thread = mono_thread_internal_current ();
        mono_pollfd *pfds;
@@ -1254,6 +1257,7 @@ ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode,
        gboolean interrupted;
        time_t start;
 
+       error_init (error);
        *werror = 0;
 
        pfds = g_new0 (mono_pollfd, 1);
@@ -1331,23 +1335,20 @@ ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode,
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObject *sockaddr, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
 {
-       MonoError error;
        struct sockaddr *sa;
        socklen_t sa_size;
        int ret;
        gboolean interrupted;
 
+       error_init  (error);
        *werror = 0;
 
-       sa = create_sockaddr_from_object (sockaddr, &sa_size, werror, &error);
+       sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
        if (*werror != 0)
                return;
-       if (!mono_error_ok (&error)) {
-               mono_error_set_pending_exception (&error);
-               return;
-       }
+       return_if_nok (error);
 
        LOGDEBUG (g_message("%s: connecting to %s port %d", __func__, inet_ntoa (((struct sockaddr_in *)sa)->sin_addr), ntohs (((struct sockaddr_in *)sa)->sin_port)));
 
@@ -1374,10 +1375,12 @@ ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObject *so
 #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
 
 void
-ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean reuse, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean reuse, gint32 *werror, MonoError *error)
 {
        gboolean interrupted;
 
+       error_init (error);
+
        LOGDEBUG (g_message("%s: disconnecting from socket %p (reuse %d)", __func__, sock, reuse));
 
        mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
@@ -1397,23 +1400,21 @@ ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean
 #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) */
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret;
-       gchar *buf;
        gint32 alen;
        int recvflags = 0;
        gboolean interrupted;
        MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
        
+       error_init (error);
        *werror = 0;
        
-       alen = mono_array_length (buffer);
+       alen = mono_array_handle_length (buffer);
        if (offset > alen - count)
                return 0;
        
-       buf = mono_array_addr (buffer, gchar, offset);
-       
        recvflags = convert_socketflags (flags);
        if (recvflags == -1) {
                *werror = WSAEOPNOTSUPP;
@@ -1424,10 +1425,15 @@ ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArray *buf
        if (interrupted)
                return 0;
 
+       uint32_t gchandle;
+       gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_recv (sock, buf, count, recvflags, blocking);
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+       
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 
@@ -1442,18 +1448,17 @@ ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArray *buf
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret, count;
        gboolean interrupted;
        guint32 recv;
-       WSABUF *wsabufs;
        guint32 recvflags = 0;
        
+       error_init (error);
        *werror = 0;
        
-       wsabufs = mono_array_addr (buffers, WSABUF, 0);
-       count = mono_array_length (buffers);
+       count = mono_array_handle_length (buffers);
        
        recvflags = convert_socketflags (flags);
        if (recvflags == -1) {
@@ -1467,10 +1472,15 @@ ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArra
                return 0;
        }
 
+       uint32_t gchandle;
+       WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_recvbuffers (sock, wsabufs, count, &recv, &recvflags, NULL, NULL, blocking);
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 
@@ -1485,9 +1495,8 @@ ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArra
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
 {
-       MonoError error;
        int ret;
        gchar *buf;
        gint32 alen;
@@ -1496,21 +1505,18 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray
        socklen_t sa_size;
        gboolean interrupted;
        
+       error_init (error);
        *werror = 0;
        
-       alen = mono_array_length (buffer);
+       alen = mono_array_handle_length (buffer);
        if (offset > alen - count)
                return 0;
 
-       sa = create_sockaddr_from_object (*sockaddr, &sa_size, werror, &error);
+       sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
        if (*werror != 0)
                return 0;
-       if (!mono_error_ok (&error)) {
-               mono_error_set_pending_exception (&error);
+       if (!is_ok (error))
                return 0;
-       }
-       
-       buf = mono_array_addr (buffer, gchar, offset);
        
        recvflags = convert_socketflags (flags);
        if (recvflags == -1) {
@@ -1525,10 +1531,15 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray
                return 0;
        }
 
+       uint32_t gchandle;
+       buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_recvfrom (sock, buf, count, recvflags, sa, &sa_size, blocking);
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 
@@ -1547,14 +1558,13 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray
         * returned the remote address. All we can do is return null.
         */
        if (sa_size) {
-               *sockaddr = create_object_from_sockaddr (sa, sa_size, werror, &error);
-               if (!mono_error_ok (&error)) {
-                       mono_error_set_pending_exception (&error);
+               MONO_HANDLE_ASSIGN (sockaddr, create_object_handle_from_sockaddr (sa, sa_size, werror, error));
+               if (!is_ok (error)) {
                        g_free (sa);
                        return 0;
                }
        } else {
-               *sockaddr = NULL;
+               MONO_HANDLE_ASSIGN (sockaddr, MONO_HANDLE_NEW (MonoObject, NULL));
        }
 
        g_free (sa);
@@ -1563,24 +1573,22 @@ ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret;
-       gchar *buf;
        gint32 alen;
        int sendflags = 0;
        gboolean interrupted;
        
+       error_init (error);
        *werror = 0;
        
-       alen = mono_array_length (buffer);
+       alen = mono_array_handle_length (buffer);
        if (offset > alen - count)
                return 0;
 
        LOGDEBUG (g_message("%s: alen: %d", __func__, alen));
        
-       buf = mono_array_addr (buffer, gchar, offset);
-
        LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
 
        sendflags = convert_socketflags (flags);
@@ -1595,10 +1603,15 @@ ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArray *buffer
                return 0;
        }
 
+       uint32_t gchandle;
+       gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_send (sock, buf, count, sendflags, blocking);
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 
@@ -1613,18 +1626,17 @@ ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArray *buffer
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        int ret, count;
        guint32 sent;
-       WSABUF *wsabufs;
        guint32 sendflags = 0;
        gboolean interrupted;
        
+       error_init (error);
        *werror = 0;
        
-       wsabufs = mono_array_addr (buffers, WSABUF, 0);
-       count = mono_array_length (buffers);
+       count = mono_array_handle_length (buffers);
        
        sendflags = convert_socketflags (flags);
        if (sendflags == -1) {
@@ -1638,10 +1650,15 @@ ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArray *
                return 0;
        }
 
+       uint32_t gchandle;
+       WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_sendbuffers (sock, wsabufs, count, &sent, sendflags, NULL, NULL, blocking);
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 
@@ -1656,11 +1673,9 @@ ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArray *
 }
 
 gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject *sockaddr, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
 {
-       MonoError error;
        int ret;
-       gchar *buf;
        gint32 alen;
        int sendflags = 0;
        struct sockaddr *sa;
@@ -1669,23 +1684,18 @@ ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buff
        
        *werror = 0;
        
-       alen = mono_array_length (buffer);
+       alen = mono_array_handle_length (buffer);
        if (offset > alen - count) {
                return 0;
        }
 
-       sa = create_sockaddr_from_object(sockaddr, &sa_size, werror, &error);
+       sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
        if (*werror != 0)
                return 0;
-       if (!mono_error_ok (&error)) {
-               mono_error_set_pending_exception (&error);
-               return 0;
-       }
+       return_val_if_nok (error, 0);
        
        LOGDEBUG (g_message ("%s: alen: %d", __func__, alen));
        
-       buf = mono_array_addr (buffer, gchar, offset);
-
        LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
 
        sendflags = convert_socketflags (flags);
@@ -1702,10 +1712,15 @@ ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buff
                return 0;
        }
 
+       uint32_t gchandle;
+       gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_sendto (sock, buf, count, sendflags, sa, sa_size, blocking);
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 
@@ -1722,63 +1737,103 @@ ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buff
 }
 
 static SOCKET
-Socket_to_SOCKET (MonoObject *sockobj)
+Socket_to_SOCKET (MonoObjectHandle sockobj)
 {
-       MonoSafeHandle *safe_handle;
        MonoClassField *field;
        
-       field = mono_class_get_field_from_name (sockobj->vtable->klass, "m_Handle");
-       safe_handle = ((MonoSafeHandle *)(*(gpointer *)(((char *)sockobj) + field->offset)));
+       field = mono_class_get_field_from_name (mono_handle_class (sockobj), "m_Handle");
+       MonoSafeHandleHandle safe_handle = MONO_HANDLE_NEW_GET_FIELD(sockobj, MonoSafeHandle, field);
 
-       if (safe_handle == NULL)
+       if (MONO_HANDLE_IS_NULL (safe_handle))
                return -1;
 
-       return (SOCKET)safe_handle->handle;
+       return (SOCKET)MONO_HANDLE_GETVAL (safe_handle, handle);
 }
 
 #define POLL_ERRORS (MONO_POLLERR | MONO_POLLHUP | MONO_POLLNVAL)
 
+static gboolean
+collect_pollfds_from_array (MonoArrayHandle sockets, int i, int nfds, mono_pollfd *pfds, int *idx, int *mode)
+{
+       HANDLE_FUNCTION_ENTER ();
+       gboolean result = TRUE;
+       MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, NULL);
+       MONO_HANDLE_ARRAY_GETREF (obj, sockets, i);
+       if (MONO_HANDLE_IS_NULL (obj)) {
+               (*mode)++;
+               goto leave;
+       }
+
+       if (*idx >= nfds) {
+               result = FALSE;
+               goto leave;
+       }
+
+       pfds [*idx].fd = Socket_to_SOCKET (obj);
+       pfds [*idx].events = (*mode == 0) ? MONO_POLLIN : (*mode == 1) ? MONO_POLLOUT : POLL_ERRORS;
+       (*idx)++;
+leave:
+       HANDLE_FUNCTION_RETURN_VAL (result);
+}
+
+static void
+set_socks_array_from_pollfds (MonoArrayHandle sockets, int i, mono_pollfd *pfds, int *ret, int *mode, MonoArrayHandle socks, int *idx)
+{
+       HANDLE_FUNCTION_ENTER ();
+       mono_pollfd *pfd;
+
+       MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, NULL);
+       MONO_HANDLE_ARRAY_GETREF (obj, sockets, i);
+       if (MONO_HANDLE_IS_NULL (obj)) {
+               (*mode)++;
+               (*idx)++;
+               goto leave;
+       }
+
+       pfd = &pfds [i - *mode];
+       if (pfd->revents == 0)
+               goto leave;
+
+       (*ret)--;
+       if (((*mode == 0 && (pfd->revents & (MONO_POLLIN | POLL_ERRORS)) != 0)) ||
+           ((*mode == 1 && (pfd->revents & (MONO_POLLOUT | POLL_ERRORS)) != 0)) ||
+           ((pfd->revents & POLL_ERRORS) != 0)) {
+               MONO_HANDLE_ARRAY_SETREF (socks, *idx, obj);
+               (*idx)++;
+       }
+leave:
+       HANDLE_FUNCTION_RETURN ();
+}
+
 void
-ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32 timeout, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArrayHandle sockets, gint32 timeout, gint32 *werror, MonoError *error)
 {
-       MonoError error;
        MonoInternalThread *thread = mono_thread_internal_current ();
-       MonoObject *obj;
        mono_pollfd *pfds;
        int nfds, idx;
        int ret;
        int i, count;
        int mode;
        MonoClass *sock_arr_class;
-       MonoArray *socks;
        time_t start;
        uintptr_t socks_size;
        gboolean interrupted;
 
+       error_init (error);
        *werror = 0;
 
        /* *sockets -> READ, null, WRITE, null, ERROR, null */
-       count = mono_array_length (*sockets);
+       count = mono_array_handle_length (sockets);
        nfds = count - 3; /* NULL separators */
        pfds = g_new0 (mono_pollfd, nfds);
        mode = idx = 0;
        for (i = 0; i < count; i++) {
-               obj = mono_array_get (*sockets, MonoObject *, i);
-               if (obj == NULL) {
-                       mode++;
-                       continue;
-               }
-
-               if (idx >= nfds) {
+               if (!collect_pollfds_from_array (sockets, i, nfds, pfds, &idx, &mode)) {
                        /* The socket array was bogus */
                        g_free (pfds);
                        *werror = WSAEFAULT;
                        return;
                }
-
-               pfds [idx].fd = Socket_to_SOCKET (obj);
-               pfds [idx].events = (mode == 0) ? MONO_POLLIN : (mode == 1) ? MONO_POLLOUT : POLL_ERRORS;
-               idx++;
        }
 
        timeout = (timeout >= 0) ? (timeout / 1000) : -1;
@@ -1817,7 +1872,7 @@ ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32
                if (ret == -1 && errno == EINTR) {
                        if (mono_thread_test_state (thread, ThreadState_AbortRequested)) {
                                g_free (pfds);
-                               *sockets = NULL;
+                               MONO_HANDLE_ASSIGN (sockets, MONO_HANDLE_NEW (MonoObject, NULL));
                                return;
                        }
 
@@ -1836,56 +1891,35 @@ ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32
 
        if (ret == 0) {
                g_free (pfds);
-               *sockets = NULL;
+               MONO_HANDLE_ASSIGN (sockets, MONO_HANDLE_NEW (MonoObject, NULL));
                return;
        }
 
-       sock_arr_class = ((MonoObject *)*sockets)->vtable->klass;
+       sock_arr_class = mono_handle_class (sockets);
        socks_size = ((uintptr_t)ret) + 3; /* space for the NULL delimiters */
-       socks = mono_array_new_full_checked (mono_domain_get (), sock_arr_class, &socks_size, NULL, &error);
-       if (!mono_error_ok (&error)) {
-               mono_error_set_pending_exception (&error);
+       MonoArrayHandle socks = MONO_HANDLE_NEW (MonoArray, mono_array_new_full_checked (mono_domain_get (), sock_arr_class, &socks_size, NULL, error));
+       if (!is_ok (error)) {
                g_free (pfds);
                return;
        }
 
        mode = idx = 0;
        for (i = 0; i < count && ret > 0; i++) {
-               mono_pollfd *pfd;
-
-               obj = mono_array_get (*sockets, MonoObject *, i);
-               if (obj == NULL) {
-                       mode++;
-                       idx++;
-                       continue;
-               }
-
-               pfd = &pfds [i - mode];
-               if (pfd->revents == 0)
-                       continue;
-
-               ret--;
-               if (mode == 0 && (pfd->revents & (MONO_POLLIN | POLL_ERRORS)) != 0) {
-                       mono_array_setref (socks, idx++, obj);
-               } else if (mode == 1 && (pfd->revents & (MONO_POLLOUT | POLL_ERRORS)) != 0) {
-                       mono_array_setref (socks, idx++, obj);
-               } else if ((pfd->revents & POLL_ERRORS) != 0) {
-                       mono_array_setref (socks, idx++, obj);
-               }
+               set_socks_array_from_pollfds (sockets, i, pfds, &ret, &mode, socks, &idx);
        }
 
-       *sockets = socks;
+       MONO_HANDLE_ASSIGN (sockets, socks);
        g_free (pfds);
 }
 
-static MonoObject*
-int_to_object (MonoDomain *domain, int val, MonoError *error)
+static MonoObjectHandle
+int_to_object_handle (MonoDomain *domain, int val, MonoError *error)
 {
-       return mono_value_box_checked (domain, mono_get_int32_class (), &val, error);
+       return MONO_HANDLE_NEW (MonoObject, mono_value_box_checked (domain, mono_get_int32_class (), &val, error));
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gint32 level, gint32 name, MonoObject **obj_val, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gint32 level, gint32 name, MonoObjectHandle obj_val, gint32 *werror, MonoError *error)
 {
        int system_level = 0;
        int system_name = 0;
@@ -1904,12 +1938,11 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gi
 #  endif
        socklen_t credsize = sizeof (cred);
 #endif
-       MonoError error;
        MonoDomain *domain = mono_domain_get ();
-       MonoObject *obj;
        MonoClass *obj_class;
        MonoClassField *field;
        
+       error_init (error);
        *werror = 0;
        
 #if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
@@ -1928,8 +1961,7 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gi
                return;
        }
        if (ret == -2) {
-               *obj_val = int_to_object (domain, 0, &error);
-               mono_error_set_pending_exception (&error);
+               MONO_HANDLE_ASSIGN (obj_val, int_to_object_handle (domain, 0, error));
                return;
        }
 
@@ -1968,36 +2000,42 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gi
        }
        
        switch (name) {
-       case SocketOptionName_Linger:
+       case SocketOptionName_Linger: {
                /* build a System.Net.Sockets.LingerOption */
                obj_class = mono_class_load_from_name (get_socket_assembly (),
                                                                                           "System.Net.Sockets",
                                                                                           "LingerOption");
-               obj = mono_object_new_checked (domain, obj_class, &error);
-               if (!mono_error_ok (&error)) {
-                       mono_error_set_pending_exception (&error);
-                       return;
-               }
+               MonoObjectHandle obj = MONO_HANDLE_NEW (MonoObject, mono_object_new_checked (domain, obj_class, error));
+               return_if_nok (error);
 
                /* Locate and set the fields "bool enabled" and "int
                 * lingerTime"
                 */
                field = mono_class_get_field_from_name(obj_class, "enabled");
-               *(guint8 *)(((char *)obj)+field->offset) = linger.l_onoff;
+               MONO_HANDLE_SET_FIELD_VAL (obj, guint8, field, linger.l_onoff);
 
                field = mono_class_get_field_from_name(obj_class, "lingerTime");
-               *(guint32 *)(((char *)obj)+field->offset)=linger.l_linger;
+               MONO_HANDLE_SET_FIELD_VAL (obj, guint32, field, linger.l_linger);
+
+               MONO_HANDLE_ASSIGN (obj_val, obj);
                break;
-       case SocketOptionName_DontLinger:
+       }
+       case SocketOptionName_DontLinger: {
                /* construct a bool int in val - true if linger is off */
-               obj = int_to_object (domain, !linger.l_onoff, &error);
-               mono_error_set_pending_exception (&error);
+               MonoObjectHandle obj = int_to_object_handle (domain, !linger.l_onoff, error);
+               return_if_nok (error);
+
+               MONO_HANDLE_ASSIGN (obj_val, obj);
                break;
+       }
        case SocketOptionName_SendTimeout:
-       case SocketOptionName_ReceiveTimeout:
-               obj = int_to_object (domain, time_ms, &error);
-               mono_error_set_pending_exception (&error);
+       case SocketOptionName_ReceiveTimeout: {
+               MonoObjectHandle obj = int_to_object_handle (domain, time_ms, error);
+               return_if_nok (error);
+
+               MONO_HANDLE_ASSIGN (obj_val, obj);
                break;
+       }
 
 #ifdef SO_PEERCRED
        case SocketOptionName_PeerCred:  {
@@ -2006,7 +2044,6 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gi
                 * possible
                 */
                static MonoImage *mono_posix_image = NULL;
-               MonoPeerCredData *cred_data;
                
                if (mono_posix_image == NULL) {
                        mono_posix_image = mono_image_loaded ("Mono.Posix");
@@ -2024,40 +2061,40 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gi
                obj_class = mono_class_load_from_name (mono_posix_image,
                                                 "Mono.Posix",
                                                 "PeerCredData");
-               obj = mono_object_new_checked (domain, obj_class, &error);
-               if (!mono_error_ok (&error)) {
-                       mono_error_set_pending_exception (&error);
-                       return;
-               }
-               cred_data = (MonoPeerCredData *)obj;
-               cred_data->pid = cred.pid;
-               cred_data->uid = cred.uid;
-               cred_data->gid = cred.gid;
+               MonoPeerCredDataHandle cred_data = MONO_HANDLE_NEW (MonoPeerCredData, mono_object_new_checked (domain, obj_class, error));
+               return_if_nok (error);
+
+               MONO_HANDLE_SETVAL (cred_data, pid, gint, cred.pid);
+               MONO_HANDLE_SETVAL (cred_data, uid, gint, cred.uid);
+               MONO_HANDLE_SETVAL (cred_data, gid, gint, cred.gid);
+
+               MONO_HANDLE_ASSIGN (obj_val, cred_data);
                break;
        }
 #endif
 
-       default:
+       default: {
 #if !defined(SO_EXCLUSIVEADDRUSE) && defined(SO_REUSEADDR)
                if (level == SocketOptionLevel_Socket && name == SocketOptionName_ExclusiveAddressUse)
                        val = val ? 0 : 1;
 #endif
-               obj = int_to_object (domain, val, &error);
-               mono_error_set_pending_exception (&error);
-       }
+               MonoObjectHandle obj = int_to_object_handle (domain, val, error);
+               return_if_nok (error);
 
-       *obj_val = obj;
+               MONO_HANDLE_ASSIGN (obj_val, obj);
+       }
+       }
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gint32 level, gint32 name, MonoArray **byte_val, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gint32 level, gint32 name, MonoArrayHandle byte_val, gint32 *werror, MonoError *error)
 {
        int system_level = 0;
        int system_name = 0;
        int ret;
-       guchar *buf;
        socklen_t valsize;
        
+       error_init (error);
        *werror = 0;
        
        ret = convert_sockopt_level_and_name((MonoSocketOptionLevel)level, (MonoSocketOptionName)name, &system_level,
@@ -2069,8 +2106,10 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gi
        if (ret == -2)
                return;
 
-       valsize = mono_array_length (*byte_val);
-       buf = mono_array_addr (*byte_val, guchar, 0);
+       valsize = mono_array_handle_length (byte_val);
+
+       uint32_t gchandle;
+       guchar *buf = MONO_ARRAY_HANDLE_PIN (byte_val, guchar, 0, &gchandle);
 
        MONO_ENTER_GC_SAFE;
 
@@ -2078,43 +2117,47 @@ ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gi
 
        MONO_EXIT_GC_SAFE;
 
+       mono_gchandle_free (gchandle);
+
        if (ret == SOCKET_ERROR)
                *werror = mono_w32socket_get_last_error ();
 }
 
 #if defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
 static struct in_addr
-ipaddress_to_struct_in_addr (MonoObject *ipaddr)
+ipaddress_handle_to_struct_in_addr (MonoObjectHandle ipaddr)
 {
        struct in_addr inaddr;
        MonoClassField *field;
        
-       field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Address");
+       field = mono_class_get_field_from_name (mono_handle_class (ipaddr), "m_Address");
+       g_assert (field);
 
        /* No idea why .net uses a 64bit type to hold a 32bit value...
         *
         * Internal value of IPAddess is in little-endian order
         */
-       inaddr.s_addr = GUINT_FROM_LE ((guint32)*(guint64 *)(((char *)ipaddr) + field->offset));
+       inaddr.s_addr = GUINT_FROM_LE ((guint32)MONO_HANDLE_GET_FIELD_VAL (ipaddr, guint64, field));
        
        return inaddr;
 }
 
 #ifdef HAVE_STRUCT_SOCKADDR_IN6
 static struct in6_addr
-ipaddress_to_struct_in6_addr (MonoObject *ipaddr)
+ipaddress_handle_to_struct_in6_addr (MonoObjectHandle ipaddr)
 {
        struct in6_addr in6addr;
        MonoClassField *field;
-       MonoArray *data;
        int i;
 
-       field = mono_class_get_field_from_name (ipaddr->vtable->klass, "m_Numbers");
+       field = mono_class_get_field_from_name (mono_handle_class (ipaddr), "m_Numbers");
        g_assert (field);
-       data = *(MonoArray **)(((char *)ipaddr) + field->offset);
+       MonoArrayHandle data = MONO_HANDLE_NEW_GET_FIELD (ipaddr, MonoArray, field);
 
        for (i = 0; i < 8; i++) {
-               const guint16 s = GUINT16_TO_BE (mono_array_get (data, guint16, i));
+               guint16 v;
+               MONO_HANDLE_ARRAY_GETVAL (v, data, guint16, i);
+               const guint16 s = GUINT16_TO_BE (v);
 
 /* Solaris/MacOS have only the 8 bit version. */
 #ifndef s6_addr16
@@ -2165,7 +2208,7 @@ get_local_interface_id (int family)
 #endif /* defined(__APPLE__) || defined(__FreeBSD__) */
 
 void
-ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32 level, gint32 name, MonoObjectHandle obj_val, MonoArrayHandle byte_val, gint32 int_val, gint32 *werror, MonoError *error)
 {
        struct linger linger;
        int system_level = 0;
@@ -2174,6 +2217,7 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
        int sol_ip;
        int sol_ipv6;
 
+       error_init (error);
        *werror = 0;
 
        sol_ipv6 = mono_networking_get_ipv6_protocol ();
@@ -2198,7 +2242,8 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                return;
 
        /* Only one of obj_val, byte_val or int_val has data */
-       if (obj_val) {
+       if (!MONO_HANDLE_IS_NULL (obj_val)) {
+               MonoClass *obj_class = mono_handle_class (obj_val);
                MonoClassField *field;
                int valsize;
                
@@ -2207,10 +2252,10 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                        /* Dig out "bool enabled" and "int lingerTime"
                         * fields
                         */
-                       field = mono_class_get_field_from_name (obj_val->vtable->klass, "enabled");
-                       linger.l_onoff = *(guint8 *)(((char *)obj_val) + field->offset);
-                       field = mono_class_get_field_from_name (obj_val->vtable->klass, "lingerTime");
-                       linger.l_linger = *(guint32 *)(((char *)obj_val) + field->offset);
+                       field = mono_class_get_field_from_name (obj_class, "enabled");
+                       linger.l_onoff = MONO_HANDLE_GET_FIELD_VAL (obj_val, guint8, field);
+                       field = mono_class_get_field_from_name (obj_class, "lingerTime");
+                       linger.l_linger = MONO_HANDLE_GET_FIELD_VAL (obj_val, guint32, field);
                        
                        valsize = sizeof (linger);
                        ret = mono_w32socket_setsockopt (sock, system_level, system_name, &linger, valsize);
@@ -2219,7 +2264,7 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                case SocketOptionName_DropMembership:
 #if defined(HAVE_STRUCT_IP_MREQN) || defined(HAVE_STRUCT_IP_MREQ)
                {
-                       MonoObject *address = NULL;
+                       MonoObjectHandle address = MONO_HANDLE_NEW (MonoObject, NULL);
 #ifdef HAVE_STRUCT_SOCKADDR_IN6
                        if (system_level == sol_ipv6) {
                                struct ipv6_mreq mreq6;
@@ -2227,15 +2272,15 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                                /*
                                 *      Get group address
                                 */
-                               field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Group");
+                               field = mono_class_get_field_from_name (obj_class, "m_Group");
                                g_assert (field);
-                               address = *(MonoObject **)(((char *)obj_val) + field->offset);
+                               MONO_HANDLE_ASSIGN (address, MONO_HANDLE_NEW_GET_FIELD (obj_val, MonoObject, field));
                                
-                               if (address)
-                                       mreq6.ipv6mr_multiaddr = ipaddress_to_struct_in6_addr (address);
+                               if (!MONO_HANDLE_IS_NULL (address))
+                                       mreq6.ipv6mr_multiaddr = ipaddress_handle_to_struct_in6_addr (address);
 
-                               field = mono_class_get_field_from_name (obj_val->vtable->klass, "m_Interface");
-                               mreq6.ipv6mr_interface = *(guint64 *)(((char *)obj_val) + field->offset);
+                               field = mono_class_get_field_from_name (obj_class, "m_Interface");
+                               mreq6.ipv6mr_interface = MONO_HANDLE_GET_FIELD_VAL (obj_val, guint64, field);
                                
 #if defined(__APPLE__) || defined(__FreeBSD__)
                                /*
@@ -2269,26 +2314,26 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                                 * members, so I have to dig the value out of
                                 * those :-(
                                 */
-                               field = mono_class_get_field_from_name (obj_val->vtable->klass, "group");
-                               address = *(MonoObject **)(((char *)obj_val) + field->offset);
+                               field = mono_class_get_field_from_name (obj_class, "group");
+                               MONO_HANDLE_ASSIGN (address, MONO_HANDLE_NEW_GET_FIELD (obj_val, MonoObject, field));
 
                                /* address might not be defined and if so, set the address to ADDR_ANY.
                                 */
-                               if (address)
-                                       mreq.imr_multiaddr = ipaddress_to_struct_in_addr (address);
+                               if (!MONO_HANDLE_IS_NULL (address))
+                                       mreq.imr_multiaddr = ipaddress_handle_to_struct_in_addr (address);
 
-                               field = mono_class_get_field_from_name (obj_val->vtable->klass, "localAddress");
-                               address = *(MonoObject **)(((char *)obj_val) + field->offset);
+                               field = mono_class_get_field_from_name (obj_class, "localAddress");
+                               MONO_HANDLE_ASSIGN (address, MONO_HANDLE_NEW_GET_FIELD (obj_val, MonoObject, field));
 
 #ifdef HAVE_STRUCT_IP_MREQN
-                               if (address)
-                                       mreq.imr_address = ipaddress_to_struct_in_addr (address);
+                               if (!MONO_HANDLE_IS_NULL (address))
+                                       mreq.imr_address = ipaddress_handle_to_struct_in_addr (address);
 
-                               field = mono_class_get_field_from_name (obj_val->vtable->klass, "ifIndex");
-                               mreq.imr_ifindex = *(gint32 *)(((char *)obj_val) + field->offset);
+                               field = mono_class_get_field_from_name (obj_class, "ifIndex");
+                               mreq.imr_ifindex = MONO_HANDLE_GET_FIELD_VAL (obj_val, gint32, field);
 #else
-                               if (address)
-                                       mreq.imr_interface = ipaddress_to_struct_in_addr (address);
+                               if (!MONO_HANDLE_IS_NULL (address))
+                                       mreq.imr_interface = ipaddress_handle_to_struct_in_addr (address);
 #endif /* HAVE_STRUCT_IP_MREQN */
 
                                ret = mono_w32socket_setsockopt (sock, system_level, system_name, &mreq, sizeof (mreq));
@@ -2301,9 +2346,10 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                        *werror = WSAEINVAL;
                        return;
                }
-       } else if (byte_val!=NULL) {
-               int valsize = mono_array_length (byte_val);
-               guchar *buf = mono_array_addr (byte_val, guchar, 0);
+       } else if (!MONO_HANDLE_IS_NULL (byte_val)) {
+               int valsize = mono_array_handle_length (byte_val);
+               uint32_t gchandle;
+               guchar *buf = MONO_ARRAY_HANDLE_PIN (byte_val, guchar, 0, &gchandle);
                
                switch(name) {
                case SocketOptionName_DontLinger:
@@ -2319,6 +2365,7 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
                        ret = mono_w32socket_setsockopt (sock, system_level, system_name, buf, valsize);
                        break;
                }
+               mono_gchandle_free (gchandle);
        } else {
                /* ReceiveTimeout/SendTimeout get here */
                switch (name) {
@@ -2364,11 +2411,12 @@ ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32
 }
 
 void
-ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, gint32 *werror, MonoError *error)
 {
        int ret;
        gboolean interrupted;
 
+       error_init (error);
        *werror = 0;
 
        mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
@@ -2395,33 +2443,37 @@ ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, g
 }
 
 gint
-ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code, MonoArray *input, MonoArray *output, gint32 *werror)
+ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code, MonoArrayHandle input, MonoArrayHandle output, gint32 *werror, MonoError *error)
 {
        glong output_bytes = 0;
        gchar *i_buffer, *o_buffer;
        gint i_len, o_len;
+       uint32_t i_gchandle, o_gchandle;
        gint ret;
 
+       error_init (error);
        *werror = 0;
        
        if ((guint32)code == FIONBIO)
                /* Invalid command. Must use Socket.Blocking */
                return -1;
 
-       if (input == NULL) {
+       if (MONO_HANDLE_IS_NULL (input)) {
                i_buffer = NULL;
                i_len = 0;
+               i_gchandle = 0;
        } else {
-               i_buffer = mono_array_addr (input, gchar, 0);
-               i_len = mono_array_length (input);
+               i_len = mono_array_handle_length (input);
+               i_buffer = MONO_ARRAY_HANDLE_PIN (input, gchar, 0, &i_gchandle);
        }
 
-       if (output == NULL) {
+       if (MONO_HANDLE_IS_NULL (output)) {
                o_buffer = NULL;
                o_len = 0;
+               o_gchandle = 0;
        } else {
-               o_buffer = mono_array_addr (output, gchar, 0);
-               o_len = mono_array_length (output);
+               o_len = mono_array_handle_length (output);
+               o_buffer = MONO_ARRAY_HANDLE_PIN (output, gchar, 0, &o_gchandle);
        }
 
        MONO_ENTER_GC_SAFE;
@@ -2430,6 +2482,11 @@ ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code,
 
        MONO_EXIT_GC_SAFE;
 
+       if (i_gchandle)
+               mono_gchandle_free (i_gchandle);
+       if (o_gchandle)
+               mono_gchandle_free (o_gchandle);
+
        if (ret == SOCKET_ERROR) {
                *werror = mono_w32socket_get_last_error ();
                return -1;
@@ -2438,147 +2495,162 @@ ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code,
        return (gint)output_bytes;
 }
 
-static gboolean 
-addrinfo_to_IPHostEntry (MonoAddressInfo *info, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gboolean add_local_ips, MonoError *error)
+static gboolean
+addrinfo_add_string (MonoDomain *domain, const char *s, MonoArrayHandle arr, int index, MonoError *error)
 {
-       gint32 count, i;
-       MonoAddressEntry *ai = NULL;
+       HANDLE_FUNCTION_ENTER ();
+       error_init (error);
+       MonoStringHandle str = mono_string_new_handle (domain, s, error);
+       if (!is_ok (error))
+               goto leave;
+       MONO_HANDLE_ARRAY_SETREF (arr, index, str);
+leave:
+       HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
+
+}
+
+static int
+addrinfo_add_local_ips (MonoDomain *domain, MonoArrayHandleOut h_addr_list, MonoError *error)
+{
+       HANDLE_FUNCTION_ENTER ();
        struct in_addr *local_in = NULL;
        int nlocal_in = 0;
        struct in6_addr *local_in6 = NULL;
        int nlocal_in6 = 0;
-       int addr_index;
-       MonoDomain *domain = mono_domain_get ();
+       int addr_index = 0;
 
        error_init (error);
-       addr_index = 0;
-       *h_aliases = mono_array_new_checked (domain, mono_get_string_class (), 0, error);
-       return_val_if_nok (error, FALSE);
-       if (add_local_ips) {
-               local_in = (struct in_addr *) mono_get_local_interfaces (AF_INET, &nlocal_in);
-               local_in6 = (struct in6_addr *) mono_get_local_interfaces (AF_INET6, &nlocal_in6);
-               if (nlocal_in || nlocal_in6) {
-                       char addr [INET6_ADDRSTRLEN];
-                       *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), nlocal_in + nlocal_in6, error);
-                       if (!is_ok (error))
-                               goto leave;
+       local_in = (struct in_addr *) mono_get_local_interfaces (AF_INET, &nlocal_in);
+       local_in6 = (struct in6_addr *) mono_get_local_interfaces (AF_INET6, &nlocal_in6);
+       if (nlocal_in || nlocal_in6) {
+               char addr [INET6_ADDRSTRLEN];
+               MONO_HANDLE_ASSIGN (h_addr_list,  mono_array_new_handle (domain, mono_get_string_class (), nlocal_in + nlocal_in6, error));
+               if (!is_ok (error))
+                       goto leave;
                        
-                       if (nlocal_in) {
-                               MonoString *addr_string;
-                               int i;
-
-                               for (i = 0; i < nlocal_in; i++) {
-                                       MonoAddress maddr;
-                                       mono_address_init (&maddr, AF_INET, &local_in [i]);
-                                       if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
-                                               addr_string = mono_string_new_checked (domain, addr, error);
-                                               if (!is_ok (error))
-                                                       goto leave;
-                                               mono_array_setref (*h_addr_list, addr_index, addr_string);
-                                               addr_index++;
-                                       }
+               if (nlocal_in) {
+                       int i;
+
+                       for (i = 0; i < nlocal_in; i++) {
+                               MonoAddress maddr;
+                               mono_address_init (&maddr, AF_INET, &local_in [i]);
+                               if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
+                                       if (!addrinfo_add_string (domain, addr, h_addr_list, addr_index, error))
+                                               goto leave;
+                                       addr_index++;
                                }
                        }
+               }
 #ifdef HAVE_STRUCT_SOCKADDR_IN6
-                       if (nlocal_in6) {
-                               MonoString *addr_string;
-                               int i;
-
-                               for (i = 0; i < nlocal_in6; i++) {
-                                       MonoAddress maddr;
-                                       mono_address_init (&maddr, AF_INET6, &local_in6 [i]);
-                                       if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
-                                               addr_string = mono_string_new_checked (domain, addr, error);
-                                               if (!is_ok (error))
-                                                       goto leave;
-                                               mono_array_setref (*h_addr_list, addr_index, addr_string);
-                                               addr_index++;
-                                       }
+               if (nlocal_in6) {
+                       int i;
+
+                       for (i = 0; i < nlocal_in6; i++) {
+                               MonoAddress maddr;
+                               mono_address_init (&maddr, AF_INET6, &local_in6 [i]);
+                               if (mono_networking_addr_to_str (&maddr, addr, sizeof (addr))) {
+                                       if (!addrinfo_add_string (domain, addr, h_addr_list, addr_index, error))
+                                               goto leave;
+                                       addr_index++;
                                }
                        }
-#endif
-               leave:
-                       g_free (local_in);
-                       g_free (local_in6);
-                       if (info)
-                               mono_free_address_info (info);
-                       return is_ok (error);;
                }
+#endif
+       }
 
-               g_free (local_in);
-               g_free (local_in6);
+leave:
+       g_free (local_in);
+       g_free (local_in6);
+       HANDLE_FUNCTION_RETURN_VAL (addr_index);
+}
+
+static gboolean 
+addrinfo_to_IPHostEntry_handles (MonoAddressInfo *info, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gboolean add_local_ips, MonoError *error)
+{
+       HANDLE_FUNCTION_ENTER ();
+       MonoAddressEntry *ai = NULL;
+       MonoDomain *domain = mono_domain_get ();
+
+       error_init (error);
+       MONO_HANDLE_ASSIGN (h_aliases, mono_array_new_handle (domain, mono_get_string_class (), 0, error));
+       if (!is_ok (error))
+               goto leave;
+       if (add_local_ips) {
+               int addr_index = addrinfo_add_local_ips (domain, h_addr_list, error);
+               if (!is_ok (error))
+                       goto leave;
+               if (addr_index > 0)
+                       goto leave;
        }
 
-       for (count = 0, ai = info->entries; ai != NULL; ai = ai->next) {
+       gint32 count = 0;
+       for (ai = info->entries; ai != NULL; ai = ai->next) {
                if (ai->family != AF_INET && ai->family != AF_INET6)
                        continue;
                count++;
        }
 
-       *h_addr_list = mono_array_new_checked (domain, mono_get_string_class (), count, error);
+       int addr_index = 0;
+       MONO_HANDLE_ASSIGN (h_addr_list, mono_array_new_handle (domain, mono_get_string_class (), count, error));
        if (!is_ok (error))
-               goto leave2;
+               goto leave;
 
-       for (ai = info->entries, i = 0; ai != NULL; ai = ai->next) {
+       gboolean name_assigned = FALSE;
+       for (ai = info->entries; ai != NULL; ai = ai->next) {
                MonoAddress maddr;
-               MonoString *addr_string;
                char buffer [INET6_ADDRSTRLEN]; /* Max. size for IPv6 */
 
                if ((ai->family != PF_INET) && (ai->family != PF_INET6))
                        continue;
 
                mono_address_init (&maddr, ai->family, &ai->address);
+               const char *addr = NULL;
                if (mono_networking_addr_to_str (&maddr, buffer, sizeof (buffer)))
-                       addr_string = mono_string_new_checked (domain, buffer, error);
+                       addr = buffer;
                else
-                       addr_string = mono_string_new_checked (domain, "", error);
-               if (!is_ok (error))
-                       goto leave2;
-
-               mono_array_setref (*h_addr_list, addr_index, addr_string);
-
-               if (!i) {
-                       i++;
-                       if (ai->canonical_name != NULL) {
-                               *h_name = mono_string_new_checked (domain, ai->canonical_name, error);
-                       } else {
-                               *h_name = mono_string_new_checked (domain, buffer, error);
-                       }
+                       addr = "";
+               if (!addrinfo_add_string (domain, addr, h_addr_list, addr_index, error))
+                       goto leave;
+
+               if (!name_assigned) {
+                       name_assigned = TRUE;
+                       const char *name = ai->canonical_name != NULL ? ai->canonical_name : buffer;
+                       MONO_HANDLE_ASSIGN (h_name, mono_string_new_handle (domain, name, error));
                        if (!is_ok (error))
-                               goto leave2;
+                               goto leave;
                }
 
                addr_index++;
        }
 
-leave2:
+leave:
        if (info)
                mono_free_address_info (info);
 
-       return is_ok (error);
+       HANDLE_FUNCTION_RETURN_VAL (is_ok (error));
 }
 
 MonoBoolean
-ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
+ves_icall_System_Net_Dns_GetHostByName_internal (MonoStringHandle host, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gint32 hint, MonoError *error)
 {
-       MonoError error;
        gboolean add_local_ips = FALSE, add_info_ok = TRUE;
        gchar this_hostname [256];
        MonoAddressInfo *info = NULL;
 
-       char *hostname = mono_string_to_utf8_checked (host, &error);
-       if (mono_error_set_pending_exception (&error))
-               return FALSE;
+       error_init (error);
+
+       char *hostname = mono_string_handle_to_utf8 (host, error);
+       return_val_if_nok (error, FALSE);
 
        if (*hostname == '\0') {
                add_local_ips = TRUE;
-               *h_name = host;
+               MONO_HANDLE_ASSIGN (h_name, host);
        }
 
        if (!add_local_ips && gethostname (this_hostname, sizeof (this_hostname)) != -1) {
                if (!strcmp (hostname, this_hostname)) {
                        add_local_ips = TRUE;
-                       *h_name = host;
+                       MONO_HANDLE_ASSIGN (h_name, host);
                }
        }
 
@@ -2596,15 +2668,14 @@ ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **
        g_free(hostname);
 
        if (add_info_ok) {
-               MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, add_local_ips, &error);
-               mono_error_set_pending_exception (&error);
+               MonoBoolean result = addrinfo_to_IPHostEntry_handles (info, h_name, h_aliases, h_addr_list, add_local_ips, error);
                return result;
        }
        return FALSE;
 }
 
 MonoBoolean
-ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint)
+ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoStringHandle addr, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gint32 hint, MonoError *error)
 {
        char *address;
        struct sockaddr_in saddr;
@@ -2612,14 +2683,14 @@ ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **
        struct sockaddr_in6 saddr6;
 #endif
        MonoAddressInfo *info = NULL;
-       MonoError error;
        gint32 family;
        gchar hostname [NI_MAXHOST] = { 0 };
        gboolean ret;
 
-       address = mono_string_to_utf8_checked (addr, &error);
-       if (mono_error_set_pending_exception (&error))
-               return FALSE;
+       error_init (error);
+
+       address = mono_string_handle_to_utf8 (addr, error);
+       return_val_if_nok (error, FALSE);
 
        if (inet_pton (AF_INET, address, &saddr.sin_addr ) == 1) {
                family = AF_INET;
@@ -2669,60 +2740,55 @@ ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **
        if (mono_get_address_info (hostname, 0, hint | MONO_HINT_CANONICAL_NAME | MONO_HINT_CONFIGURED_ONLY, &info) != 0)
                return FALSE;
 
-       MonoBoolean result = addrinfo_to_IPHostEntry (info, h_name, h_aliases, h_addr_list, FALSE, &error);
-       mono_error_set_pending_exception (&error);
+       MonoBoolean result = addrinfo_to_IPHostEntry_handles (info, h_name, h_aliases, h_addr_list, FALSE, error);
        return result;
 }
 
 MonoBoolean
-ves_icall_System_Net_Dns_GetHostName_internal (MonoString **h_name)
+ves_icall_System_Net_Dns_GetHostName_internal (MonoStringHandleOut h_name, MonoError *error)
 {
-       MonoError error;
        gchar hostname [NI_MAXHOST] = { 0 };
        int ret;
 
+       error_init (error);
+       MONO_ENTER_GC_SAFE;
        ret = gethostname (hostname, sizeof (hostname));
+       MONO_EXIT_GC_SAFE;
        if (ret == -1)
                return FALSE;
 
-       *h_name = mono_string_new_checked (mono_domain_get (), hostname, &error);
-       mono_error_set_pending_exception (&error);
-
+       MONO_HANDLE_ASSIGN (h_name, mono_string_new_handle (mono_domain_get (), hostname, error));
        return TRUE;
 }
 
 #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT)
 gboolean
-ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoString *filename, MonoArray *pre_buffer, MonoArray *post_buffer, gint flags, gint32 *werror, gboolean blocking)
+ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoStringHandle filename, MonoArrayHandle pre_buffer, MonoArrayHandle post_buffer, gint flags, gint32 *werror, gboolean blocking, MonoError *error)
 {
        HANDLE file;
        gboolean ret;
        gboolean interrupted;
        TRANSMIT_FILE_BUFFERS buffers;
+       uint32_t pre_buffer_gchandle = 0;
+       uint32_t post_buffer_gchandle = 0;
 
+       error_init (error);
        *werror = 0;
 
-       if (filename == NULL)
+       if (MONO_HANDLE_IS_NULL (filename))
                return FALSE;
 
        /* FIXME: replace file by a proper fd that we can call open and close on, as they are interruptible */
 
-       file = mono_w32file_create (mono_string_chars (filename), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0);
+       uint32_t filename_gchandle;
+       gunichar2 *filename_chars = mono_string_handle_pin_chars (filename, &filename_gchandle);
+       file = mono_w32file_create (filename_chars, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0);
+       mono_gchandle_free (filename_gchandle);
        if (file == INVALID_HANDLE_VALUE) {
                *werror = mono_w32error_get_last ();
                return FALSE;
        }
 
-       memset (&buffers, 0, sizeof (buffers));
-       if (pre_buffer != NULL) {
-               buffers.Head = mono_array_addr (pre_buffer, guchar, 0);
-               buffers.HeadLength = mono_array_length (pre_buffer);
-       }
-       if (post_buffer != NULL) {
-               buffers.Tail = mono_array_addr (post_buffer, guchar, 0);
-               buffers.TailLength = mono_array_length (post_buffer);
-       }
-
        mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted);
        if (interrupted) {
                mono_w32file_close (file);
@@ -2730,10 +2796,26 @@ ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoString *f
                return FALSE;
        }
 
+
+       memset (&buffers, 0, sizeof (buffers));
+       if (!MONO_HANDLE_IS_NULL (pre_buffer)) {
+               buffers.Head = MONO_ARRAY_HANDLE_PIN (pre_buffer, guchar, 0, &pre_buffer_gchandle);
+               buffers.HeadLength = mono_array_handle_length (pre_buffer);
+       }
+       if (!MONO_HANDLE_IS_NULL (post_buffer)) {
+               buffers.Tail = MONO_ARRAY_HANDLE_PIN (post_buffer, guchar, 0, &post_buffer_gchandle);
+               buffers.TailLength = mono_array_handle_length (post_buffer);
+       }
+
        MONO_ENTER_GC_SAFE;
        ret = mono_w32socket_transmit_file (sock, file, &buffers, flags, blocking);
        MONO_EXIT_GC_SAFE;
 
+       if (pre_buffer_gchandle)
+               mono_gchandle_free (pre_buffer_gchandle);
+       if (post_buffer_gchandle)
+               mono_gchandle_free (post_buffer_gchandle);
+
        if (!ret)
                *werror = mono_w32socket_get_last_error ();
 
@@ -2768,14 +2850,14 @@ mono_network_cleanup (void)
 }
 
 void
-icall_cancel_blocking_socket_operation (MonoThread *thread)
+icall_cancel_blocking_socket_operation (MonoThreadObjectHandle thread, MonoError *error)
 {
-       MonoInternalThread *internal;
-
-       internal = thread->internal_thread;
-       g_assert (internal);
+       error_init (error);
+       MonoInternalThreadHandle internal = MONO_HANDLE_NEW_GET (MonoInternalThread, thread, internal_thread);
+       g_assert (!MONO_HANDLE_IS_NULL (internal));
 
-       mono_thread_info_abort_socket_syscall_for_close (MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid));
+       guint64 tid = mono_internal_thread_handle_ptr (internal)->tid;
+       mono_thread_info_abort_socket_syscall_for_close (MONO_UINT_TO_NATIVE_THREAD_ID (tid));
 }
 
 #endif /* #ifndef DISABLE_SOCKETS */
index 58ef7079f0da4e01cb53ac09650b56ccaa26aeb2..1788e2175bd517655a0c2125a03587ec53b7b38d 100644 (file)
@@ -166,112 +166,128 @@ typedef struct
        gint gid;
 } MonoPeerCredData;
 
+/* Safely access Mono.Posix.PeerCredData from native code */
+TYPED_HANDLE_DECL (MonoPeerCredData);
+
 gpointer
-ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObject *this_obj, gint32 family, gint32 type, gint32 proto,
-       gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Socket_internal (MonoObjectHandle this_obj, gint32 family, gint32 type,
+                                                    gint32 proto, gint32 *werror, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Close_internal (gsize sock, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Close_internal (gsize sock, gint32 *werror, MonoError *error);
 
 gint32
 ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal (void);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Available_internal (gsize sock, gint32 *werror, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean block, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Blocking_internal (gsize sock, gboolean block, gint32 *werror, MonoError *error);
 
 gpointer
-ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_Accept_internal (gsize sock, gint32 *werror, gboolean blocking, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Listen_internal (gsize sock, guint32 backlog, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Listen_internal (gsize sock, guint32 backlog, gint32 *werror, MonoError *error);
 
-MonoObject*
-ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 af, gint32 *error);
+MonoObjectHandle
+ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal (gsize sock, gint32 af, gint32 *werror, MonoError *error);
 
-MonoObject*
-ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32 af, gint32 *error);
+MonoObjectHandle
+ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal (gsize sock, gint32 af, gint32 *werror, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Bind_internal (gsize sock, MonoObject *sockaddr, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Bind_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObject *sockaddr, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
-       gint32 flags, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+                                                     gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *error,
-       gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+                                                           gint32 *werror, gboolean blocking, MonoError *error);
+
+/* gint32 */
+/* ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, */
+/*                                                       gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking); */
 
 gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
-       gint32 flags, MonoObject **sockaddr, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+                                                         gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
+
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
-       gint32 flags, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+                                                  gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArray *buffers, gint32 flags, gint32 *error,
-       gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+                                                        gint32 *werror, gboolean blocking, MonoError *error);
 
 gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count,
-       gint32 flags, MonoObject *sockaddr, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+                                                    gint32 flags, MonoObjectHandle sockaddr, gint32 *werror,
+                                                    gboolean blocking, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArray **sockets, gint32 timeout, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Select_internal (MonoArrayHandle sockets, gint32 timeout, gint32 *werror, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Shutdown_internal (gsize sock, gint32 how, gint32 *werror, MonoError *error);
 
 void
 ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal (gsize sock, gint32 level, gint32 name,
-       MonoObject **obj_val, gint32 *error);
+                                                                 MonoObjectHandle obj_val, gint32 *werror,
+                                                                 MonoError *error);
 
 void
 ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal (gsize sock, gint32 level, gint32 name,
-       MonoArray **byte_val, gint32 *error);
+                                                                 MonoArrayHandle byte_val, gint32 *werror,
+                                                                 MonoError *error);
 
 void
 ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal (gsize sock, gint32 level, gint32 name,
-       MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error);
+                                                             MonoObjectHandle obj_val, MonoArrayHandle byte_val,
+                                                             gint32 int_val, gint32 *werror, MonoError *error);
 
 int
-ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code, MonoArray *input, MonoArray *output,
-       gint32 *error);
+ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code,
+                                                       MonoArrayHandle input, MonoArrayHandle output,
+                                                       gint32 *werror, MonoError *error);
 
 MonoBoolean
-ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases,
-       MonoArray **h_addr_list, gint32 hint);
+ves_icall_System_Net_Dns_GetHostByName_internal (MonoStringHandle host, MonoStringHandleOut h_name,
+                                                MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list,
+                                                gint32 hint, MonoError *error);
 
 MonoBoolean
-ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoString *addr, MonoString **h_name, MonoArray **h_aliases,
-       MonoArray **h_addr_list, gint32 hint);
+ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoStringHandle addr, MonoStringHandleOut h_name,
+                                                MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list,
+                                                gint32 hint, MonoError *error);
 
 MonoBoolean
-ves_icall_System_Net_Dns_GetHostName_internal (MonoString **h_name);
+ves_icall_System_Net_Dns_GetHostName_internal (MonoStringHandleOut h_name, MonoError *error);
 
 MonoBoolean
-ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode, gint timeout, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Poll_internal (gsize sock, gint mode, gint timeout, gint32 *werror, MonoError *error);
 
 void
-ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean reuse, gint32 *error);
+ves_icall_System_Net_Sockets_Socket_Disconnect_internal (gsize sock, MonoBoolean reuse, gint32 *werror, MonoError *error);
 
 gboolean
-ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoString *filename, MonoArray *pre_buffer,
-       MonoArray *post_buffer, gint flags, gint32 *error, gboolean blocking);
+ves_icall_System_Net_Sockets_Socket_SendFile_internal (gsize sock, MonoStringHandle filename,
+                                                      MonoArrayHandle pre_buffer, MonoArrayHandle post_buffer,
+                                                      gint flags, gint32 *werror, gboolean blocking, MonoError *error);
 
 void
-icall_cancel_blocking_socket_operation (MonoThread *thread);
+icall_cancel_blocking_socket_operation (MonoThreadObjectHandle thread, MonoError *error);
 
 gboolean
-ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto);
+ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError *error);
 
 void
 mono_network_init(void);
index e0db07a52b4a8042be12b8a32a6e8b42ae7826e1..b2107a6c524d8a33b267af7af06c601020fa2caf 100755 (executable)
@@ -401,6 +401,9 @@ interp_sources =    \
        interp/mintops.def      \
        interp/mintops.c        \
        interp/transform.c
+else
+interp_sources = \
+       interp/interp-stubs.c
 endif
 
 if ENABLE_LLVM
@@ -502,12 +505,10 @@ test_sources =                    \
        aot-tests.cs \
        gc-test.cs \
        gshared.cs \
+       unaligned.cs    \
+       MemoryIntrinsics.il     \
        mixed.cs
 
-if NACL_CODEGEN
-test_sources += nacl.cs
-endif
-
 regtests_UNIVERSAL = \
        basic.exe \
        basic-float.exe \
@@ -521,12 +522,9 @@ regtests_UNIVERSAL = \
        devirtualization.exe \
        generics.exe \
        basic-simd.exe \
+       unaligned.exe   \
        basic-vectors.exe
 
-if NACL_CODEGEN
-regtests_UNIVERSAL += nacl.exe
-endif
-
 regtests_DISABLED = 
 
 if FULL_AOT_TESTS
@@ -654,6 +652,9 @@ nacl.exe: nacl.cs TestDriver.dll
 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
        $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:generics-variant-types.dll -r:$(CLASS)/System.Core.dll
 
+unaligned.exe: unaligned.cs TestDriver.dll MemoryIntrinsics.dll
+       $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:MemoryIntrinsics.dll
+
 %.exe: %.cs TestDriver.dll
        $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll
 
@@ -666,11 +667,10 @@ TestDriver.dll: $(srcdir)/TestDriver.cs $(srcdir)/TestHelpers.cs
 generics-variant-types.dll: generics-variant-types.il
        $(ILASM) -dll -output=$@ $<
 
-if NACL_CODEGEN
-GENMDESC_OPTS=--nacl
-else !NACL_CODEGEN
+MemoryIntrinsics.dll: MemoryIntrinsics.il
+       $(ILASM) -dll -output=$@ $<
+
 GENMDESC_OPTS=
-endif !NACL_CODEGEN
 
 # we don't always use the perl impl because it's an additional
 # build dependency for the poor windows users
@@ -679,11 +679,7 @@ endif !NACL_CODEGEN
 if CROSS_COMPILING
 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
 else !CROSS_COMPILING
-if NACL_CODEGEN
-GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
-else
 GENMDESC_PRG=./genmdesc $(GENMDESC_OPTS)
-endif
 endif !CROSS_COMPILING
 
 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
@@ -770,6 +766,7 @@ gsharedvtcheck:
        $(MAKE) fullaotcheck GSHAREDVT=1
 
 fullaot_regtests = $(regtests) aot-tests.exe $(if $(GSHAREDVT),gshared.exe)
+fullaot_testing_deps = generics-variant-types.dll TestDriver.dll MemoryIntrinsics.dll
 
 FULLAOT_LIBS_UNIVERSAL = \
        mscorlib.dll \
@@ -795,17 +792,18 @@ FULLAOT_LIBS_DISABLED += \
        System.Configuration.dll
 endif
 
+
 FULLAOT_LIBS = $(filter-out $(FULLAOT_LIBS_DISABLED),$(FULLAOT_LIBS_UNIVERSAL))
 
 FULLAOT_TMP_DIR=$(top_builddir)/mono/mini/fullaot-tmp
 
 # This currently only works on amd64/arm
-fullaotcheck: $(mono) $(fullaot_regtests)
+fullaotcheck: $(mono) $(fullaot_regtests) $(fullaot_testing_deps)
        rm -rf $(FULLAOT_TMP_DIR)
        mkdir $(FULLAOT_TMP_DIR)
        $(MAKE) fullaot-libs AOT_FLAGS="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" GSHAREDVT=$(GSHAREDVT)
-       cp $(regtests) $(fullaot_regtests) generics-variant-types.dll TestDriver.dll $(FULLAOT_TMP_DIR)/
-       MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" $(FULLAOT_TMP_DIR)/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1
+       cp $(regtests) $(fullaot_regtests) $(fullaot_testing_deps) $(FULLAOT_TMP_DIR)/
+       MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" $(FULLAOT_TMP_DIR)/{*.dll,*.exe} || exit 1
        ln -s $(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),$$PWD/mono) $(FULLAOT_TMP_DIR)/
        for i in $(fullaot_regtests); do echo $$i; MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --full-aot $(FULLAOT_TMP_DIR)/$$i --exclude '!FULLAOT' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done
 
@@ -827,8 +825,8 @@ llvmonlycheck: mono $(llvmonly_regtests)
        rm -rf fullaot-tmp
        mkdir fullaot-tmp
        $(MAKE) fullaot-libs AOT_FLAGS="llvmonly,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)"
-       cp $(llvmonly_regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/
-       MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper  $(MOBILE_RUNTIME_ARG) --aot=llvmonly fullaot-tmp/{generics-variant-types.dll,TestDriver.dll,*.exe} || exit 1
+       cp $(llvmonly_regtests) $(fullaot_testing_deps) fullaot-tmp/
+       MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper  $(MOBILE_RUNTIME_ARG) --aot=llvmonly fullaot-tmp/{*.dll,*.exe} || exit 1
        ln -s $$PWD/mono fullaot-tmp/
        for i in $(llvmonly_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --llvmonly fullaot-tmp/$$i --exclude '!BITCODE' || exit 1; done
 
diff --git a/mono/mini/MemoryIntrinsics.il b/mono/mini/MemoryIntrinsics.il
new file mode 100644 (file)
index 0000000..dd4c9b5
--- /dev/null
@@ -0,0 +1,180 @@
+.assembly extern mscorlib
+{
+       .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
+       .ver 4:0:0:0
+}
+
+.assembly 'MemoryIntrinsics'
+{
+       .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78  63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )
+       .hash algorithm 0x00008004
+       .ver 0:0:0:0
+}
+.module 'instrics-lib.dll'
+.imagebase 0x00400000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003
+.corflags 0x00000001
+
+.namespace Mono {
+       .class public abstract auto ansi sealed beforefieldinit Intrinsics extends [mscorlib]System.Object
+       {
+               .method public hidebysig static void  Cpobj<T>(void* 'to', void* from) cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       cpobj !!T
+                       ret
+               }
+
+               .method public hidebysig static !!T Ldobj<T>(void* 'from') cil managed
+               {
+                       ldarg.0
+                       ldobj !!T
+                       ret
+               }
+
+               .method public hidebysig static void Stobj<T>(void* 'to', !!T 'value') cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       stobj !!T
+                       ret
+               }
+
+               .method public hidebysig static void LdobjStObjPair<T>(void* 'to', void* 'from') cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       ldobj !!T
+                       stobj !!T
+                       ret
+               }
+
+               .method public hidebysig static void Cpblk(void* 'to', void* 'from', int32 size) cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       ldarg.2
+                       cpblk
+                       ret
+               }
+
+               .method public hidebysig static void Initblk<T>(void* 'to', int32 'value', int32 'size') cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       ldarg.2
+                       initblk
+                       ret
+               }
+
+               //Unaligned intrinsics
+               .method public hidebysig static void UnalignedCpobj<T>(void* 'to', void* from) cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       unaligned. 1
+                       cpobj !!T
+                       ret
+               }
+
+               .method public hidebysig static !!T UnalignedLdobj<T>(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldobj !!T
+                       ret
+               }
+
+               .method public hidebysig static void UnalignedStobj<T>(void* 'to', !!T 'value') cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       unaligned. 1
+                       stobj !!T
+                       ret
+               }
+
+               .method public hidebysig static void UnalignedLdobjStObjPair<T>(void* 'to', void* 'from') cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       unaligned. 1
+                       ldobj !!T
+                       stobj !!T
+                       ret
+               }
+
+               .method public hidebysig static void UnalignedCpblk(void* 'to', void* 'from', int32 size) cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       ldarg.2
+                       unaligned. 1
+                       cpblk
+                       ret
+               }
+
+               .method public hidebysig static void UnalignedInit(void* 'to', int32 'value', int32 'size') cil managed
+               {
+                       ldarg.0
+                       ldarg.1
+                       ldarg.2
+                       unaligned. 1
+                       initblk
+                       ret
+               }
+
+               //Unaligned ldind
+               .method public hidebysig static int16 UnalignedLdInd2(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldind.i2
+                       ret
+               }
+
+               .method public hidebysig static int32 UnalignedLdInd4(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldind.i4
+                       ret
+               }
+
+               .method public hidebysig static int64 UnalignedLdInd8(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldind.i8
+                       ret
+               }
+
+               .method public hidebysig static float32 UnalignedLdIndR4(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldind.r4
+                       ret
+               }
+
+               .method public hidebysig static float64 UnalignedLdIndR8(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldind.r8
+                       ret
+               }
+
+               .method public hidebysig static native int UnalignedLdIndI(void* 'from') cil managed
+               {
+                       ldarg.0
+                       unaligned. 1
+                       ldind.i
+                       ret
+               }
+
+       }
+}
index 385a4d43dd1622f6ab21ae5f344c0fa4457ced88..61991b5eb0f523cdd02d11c2b03f8f0764003024 100644 (file)
@@ -56,7 +56,7 @@
 #include <mono/utils/mono-rand.h>
 #include <mono/utils/json.h>
 #include <mono/utils/mono-threads-coop.h>
-#include <mono/profiler/mono-profiler-aot.h>
+#include <mono/profiler/aot.h>
 #include <mono/utils/w32api.h>
 
 #include "aot-compiler.h"
@@ -78,7 +78,7 @@
 #define TARGET_WIN32_MSVC
 #endif
 
-#if defined(__linux__) || defined(__native_client_codegen__)
+#if defined(__linux__)
 #define RODATA_SECT ".rodata"
 #elif defined(TARGET_MACH)
 #define RODATA_SECT ".section __TEXT, __const"
@@ -953,10 +953,8 @@ emit_code_bytes (MonoAotCompile *acfg, const guint8* buf, int size)
 #ifdef TARGET_X86
 #ifdef TARGET_WIN32
 #define AOT_TARGET_STR "X86 (WIN32)"
-#elif defined(__native_client_codegen__)
-#define AOT_TARGET_STR "X86 (native client codegen)"
 #else
-#define AOT_TARGET_STR "X86 (!native client codegen)"
+#define AOT_TARGET_STR "X86"
 #endif
 #endif
 
@@ -4429,7 +4427,13 @@ method_has_type_vars (MonoMethod *method)
 static
 gboolean mono_aot_mode_is_full (MonoAotOptions *opts)
 {
-       return opts->mode == MONO_AOT_MODE_FULL;
+       return opts->mode == MONO_AOT_MODE_FULL || opts->mode == MONO_AOT_MODE_INTERP;
+}
+
+static
+gboolean mono_aot_mode_is_interp (MonoAotOptions *opts)
+{
+       return opts->mode == MONO_AOT_MODE_INTERP;
 }
 
 static
@@ -6821,6 +6825,11 @@ emit_trampolines (MonoAotCompile *acfg)
                emit_trampoline (acfg, acfg->got_offset, info);
 #endif
 
+               if (mono_aot_mode_is_interp (&acfg->aot_opts)) {
+                       mono_arch_get_enter_icall_trampoline (&info);
+                       emit_trampoline (acfg, acfg->got_offset, info);
+               }
+
 #endif /* #ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES */
 
                /* Emit trampolines which are numerous */
@@ -7163,6 +7172,8 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts)
                        opts->mode = MONO_AOT_MODE_FULL;
                } else if (str_begins_with (arg, "hybrid")) {
                        opts->mode = MONO_AOT_MODE_HYBRID;                      
+               } else if (str_begins_with (arg, "interp")) {
+                       opts->mode = MONO_AOT_MODE_INTERP;
                } else if (str_begins_with (arg, "threads=")) {
                        opts->nthreads = atoi (arg + strlen ("threads="));
                } else if (str_begins_with (arg, "static")) {
@@ -8639,7 +8650,7 @@ execute_system (const char * command)
 {
        int status = 0;
 
-#if defined(HOST_WIN32) && defined(HAVE_SYSTEM)
+#if defined(HOST_WIN32)
        // We need an extra set of quotes around the whole command to properly handle commands 
        // with spaces since internally the command is called through "cmd /c.
        char * quoted_command = g_strdup_printf ("\"%s\"", command);
@@ -10361,19 +10372,13 @@ compile_asm (MonoAotCompile *acfg)
 #define AS_OPTIONS "-a64 -mppc64"
 #elif defined(sparc) && SIZEOF_VOID_P == 8
 #define AS_OPTIONS "-xarch=v9"
-#elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__)
+#elif defined(TARGET_X86) && defined(TARGET_MACH)
 #define AS_OPTIONS "-arch i386"
 #else
 #define AS_OPTIONS ""
 #endif
 
-#ifdef __native_client_codegen__
-#if defined(TARGET_AMD64)
-#define AS_NAME "nacl64-as"
-#else
-#define AS_NAME "nacl-as"
-#endif
-#elif defined(TARGET_OSX)
+#if defined(TARGET_OSX)
 #define AS_NAME "clang"
 #elif defined(TARGET_WIN32_MSVC)
 #define AS_NAME "clang.exe"
@@ -10402,7 +10407,7 @@ compile_asm (MonoAotCompile *acfg)
 #elif defined(TARGET_WIN32) && !defined(TARGET_ANDROID)
 #define LD_NAME "gcc"
 #define LD_OPTIONS "-shared"
-#elif defined(TARGET_X86) && defined(TARGET_MACH) && !defined(__native_client_codegen__)
+#elif defined(TARGET_X86) && defined(TARGET_MACH)
 #define LD_NAME "clang"
 #define LD_OPTIONS "-m32 -dynamiclib"
 #elif defined(TARGET_ARM) && !defined(TARGET_ANDROID)
@@ -11525,7 +11530,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                }
        }
 
-       {
+       if (!mono_aot_mode_is_interp (&acfg->aot_opts)) {
                int method_index;
 
        for (method_index = 0; method_index < acfg->image->tables [MONO_TABLE_METHOD].rows; ++method_index) {
@@ -11588,9 +11593,12 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        if (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))
                mono_set_partial_sharing_supported (TRUE);
 
-       res = collect_methods (acfg);
-       if (!res)
-               return 1;
+       if (!mono_aot_mode_is_interp (&acfg->aot_opts)) {
+               res = collect_methods (acfg);
+
+               if (!res)
+                       return 1;
+       }
 
        {
                GList *l;
@@ -11615,6 +11623,26 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        }
 #endif
 
+       if (mono_aot_mode_is_interp (&acfg->aot_opts)) {
+               MonoMethod *wrapper;
+               MonoMethodSignature *sig;
+
+               /* object object:interp_in_static (object,intptr,intptr,intptr) */
+               sig = mono_create_icall_signature ("object object ptr ptr ptr");
+               wrapper = mini_get_interp_in_wrapper (sig);
+               add_method (acfg, wrapper);
+
+               /* int object:interp_in_static (intptr,int,intptr) */
+               sig = mono_create_icall_signature ("int32 ptr int32 ptr");
+               wrapper = mini_get_interp_in_wrapper (sig);
+               add_method (acfg, wrapper);
+
+               /* void object:interp_in_static (object,intptr,intptr,intptr) */
+               sig = mono_create_icall_signature ("void object ptr ptr ptr");
+               wrapper = mini_get_interp_in_wrapper (sig);
+               add_method (acfg, wrapper);
+       }
+
        TV_GETTIME (atv);
 
        compile_methods (acfg);
index 782106c45e17b519200a104fc6a09695e0e22758..a93776da15a6b4f6a3a024ab68856eb9cfdb8044 100644 (file)
@@ -1015,6 +1015,8 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
                                ref->method = mono_marshal_get_gsharedvt_in_wrapper ();
                        } else if (subtype == WRAPPER_SUBTYPE_GSHAREDVT_OUT) {
                                ref->method = mono_marshal_get_gsharedvt_out_wrapper ();
+                       } else if (subtype == WRAPPER_SUBTYPE_INTERP_IN) {
+                               ref->method = mini_get_interp_in_wrapper (target->signature);
                        } else if (subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG) {
                                MonoMethodSignature *sig = decode_signature (module, p, &p);
                                if (!sig)
@@ -2017,7 +2019,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                        }
                }
                if (!sofile) {
-                       if (mono_aot_only && assembly->image->tables [MONO_TABLE_METHOD].rows) {
+                       if (mono_aot_only && !mono_use_interpreter && assembly->image->tables [MONO_TABLE_METHOD].rows) {
                                aot_name = g_strdup_printf ("%s%s", assembly->image->name, MONO_SOLIB_EXT);
                                g_error ("Failed to load AOT module '%s' in aot-only mode.\n", aot_name);
                                g_free (aot_name);
@@ -2061,7 +2063,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        }
 
        if (!usable) {
-               if (mono_aot_only) {
+               if (mono_aot_only && !mono_use_interpreter) {
                        g_error ("Failed to load AOT module '%s' while running in aot-only mode: %s.\n", found_aot_name, msg);
                } else {
                        mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable: %s.", found_aot_name, msg);
@@ -2283,16 +2285,6 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
         * non-lazily, since we can't handle out-of-date errors later.
         * The cached class info also depends on the exact assemblies.
         */
-#if defined(__native_client__)
-       /* TODO: Don't 'load_image' on mscorlib due to a */
-       /* recursive loading problem.  This should be    */
-       /* removed if mscorlib is loaded from disk.      */
-       if (strncmp(assembly->aname.name, "mscorlib", 8)) {
-               do_load_image = TRUE;
-       } else {
-               do_load_image = FALSE;
-       }
-#endif
        if (do_load_image) {
                for (i = 0; i < amodule->image_table_len; ++i) {
                        MonoError error;
@@ -2353,9 +2345,7 @@ mono_aot_init (void)
        mono_os_mutex_init_recursive (&aot_page_mutex);
        aot_modules = g_hash_table_new (NULL, NULL);
 
-#ifndef __native_client__
        mono_install_assembly_load_hook (load_aot_module, NULL);
-#endif
        mono_counters_register ("Async JIT info size", MONO_COUNTER_INT|MONO_COUNTER_JIT, &async_jit_info_size);
 
        char *lastaot = g_getenv ("MONO_LASTAOT");
@@ -3941,9 +3931,11 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
                                        if (!method)
                                                return NULL;
                                }
-                               full_name = mono_method_full_name (method, TRUE);
-                               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: NOT FOUND: %s.", full_name);
-                               g_free (full_name);
+                               if (!(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
+                                       full_name = mono_method_full_name (method, TRUE);
+                                       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: NOT FOUND: %s.", full_name);
+                                       g_free (full_name);
+                               }
                        }
                        return NULL;
                }
index 2f964b4162f88a70a06caaf992da8b14db18bac2..0dab1240f8637cd2ac334e2b881124aeb441ca83 100644 (file)
@@ -819,17 +819,9 @@ replace_in_block (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl
 }
 
 static void
-replace_out_block_in_code (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl) {
+replace_out_block_in_code (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl)
+{
        MonoInst *ins;
-
-#if defined(__native_client_codegen__)
-       /* Need to maintain this flag for the new block because */
-       /* we can't jump indirectly to a non-aligned block.     */
-       if (orig->flags & BB_INDIRECT_JUMP_TARGET)
-       {
-               repl->flags |= BB_INDIRECT_JUMP_TARGET;
-       }
-#endif
        
        for (ins = bb->code; ins != NULL; ins = ins->next) {
                switch (ins->opcode) {
index c639fa9e756e5c095b0e73f81b1c78b94651d6a8..88b1b18b68b8e0492dc328d8b4347d14843a43b8 100644 (file)
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/networking.h>
 #include <mono/utils/mono-proclib.h>
+#include <mono/utils/w32api.h>
 #include "debugger-agent.h"
 #include "mini.h"
 #include "seq-points.h"
-#include <mono/utils/w32api.h>
+#include "interp/interp.h"
 
 /*
  * On iOS we can't use System.Environment.Exit () as it will do the wrong
@@ -137,6 +138,7 @@ typedef struct
        MonoContext ctx;
        MonoDebugMethodJitInfo *jit;
        MonoJitInfo *ji;
+       MonoInterpFrameHandle interp_frame;
        int flags;
        mgreg_t *reg_locations [MONO_MAX_IREGS];
        /*
@@ -2480,6 +2482,35 @@ static void invoke_method (void);
  * SUSPEND/RESUME
  */
 
+static MonoJitInfo*
+get_top_method_ji (gpointer ip, MonoDomain **domain, gpointer *out_ip)
+{
+       MonoJitInfo *ji;
+
+       if (out_ip)
+               *out_ip = ip;
+
+       ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, domain);
+       if (!ji) {
+               /* Could be an interpreter method */
+
+               MonoLMF *lmf = mono_get_lmf ();
+               MonoInterpFrameHandle *frame;
+
+               g_assert (((guint64)lmf->previous_lmf) & 2);
+               MonoLMFExt *ext = (MonoLMFExt*)lmf;
+
+               g_assert (ext->interp_exit);
+               frame = ext->interp_exit_data;
+               ji = mono_interp_frame_get_jit_info (frame);
+               if (domain)
+                       *domain = mono_domain_get ();
+               if (out_ip)
+                       *out_ip = mono_interp_frame_get_ip (frame);
+       }
+       return ji;
+}
+
 /*
  * save_thread_context:
  *
@@ -2619,13 +2650,23 @@ thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, MonoJitInfo *ji)
                         * suspended when it returns to managed code, so the parent's ctx should
                         * remain valid.
                         */
+                       MonoThreadUnwindState *state = mono_thread_info_get_suspend_state (info);
+
                        data.last_frame_set = FALSE;
-                       mono_get_eh_callbacks ()->mono_walk_stack_with_state (get_last_frame, mono_thread_info_get_suspend_state (info), MONO_UNWIND_SIGNAL_SAFE, &data);
+                       mono_get_eh_callbacks ()->mono_walk_stack_with_state (get_last_frame, state, MONO_UNWIND_SIGNAL_SAFE, &data);
                        if (data.last_frame_set) {
                                gpointer jit_tls = ((MonoThreadInfo*)tls->thread->thread_info)->jit_data;
 
                                memcpy (&tls->async_last_frame, &data.last_frame, sizeof (StackFrameInfo));
 
+                               if (data.last_frame.type == FRAME_TYPE_INTERP_TO_MANAGED) {
+                                       /*
+                                        * Store the current lmf instead of the parent one, since that
+                                        * contains the interp exit data.
+                                        */
+                                       data.lmf = state->unwind_data [MONO_UNWIND_DATA_LMF];
+                               }
+
                                copy_unwind_state_from_frame_data (&tls->async_state, &data, jit_tls);
                                copy_unwind_state_from_frame_data (&tls->context, &data, jit_tls);
                        } else {
@@ -2751,8 +2792,8 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx)
                return;
        }
 
-       ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, NULL);
-
+       ji = get_top_method_ji (ip, NULL, NULL);
+       g_assert (ji);
        /* Can't suspend in these methods */
        method = jinfo_get_method (ji);
        if (method->klass == mono_defaults.string_class && (!strcmp (method->name, "memset") || strstr (method->name, "memcpy")))
@@ -3051,7 +3092,7 @@ process_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data)
        SeqPoint sp;
        int flags = 0;
 
-       if (info->type != FRAME_TYPE_MANAGED) {
+       if (info->type != FRAME_TYPE_MANAGED && info->type != FRAME_TYPE_INTERP) {
                if (info->type == FRAME_TYPE_DEBUGGER_INVOKE) {
                        /* Mark the last frame as an invoke frame */
                        if (ud->frames)
@@ -3104,6 +3145,7 @@ process_frame (StackFrameInfo *info, MonoContext *ctx, gpointer user_data)
        frame->native_offset = info->native_offset;
        frame->flags = flags;
        frame->ji = info->ji;
+       frame->interp_frame = info->interp_frame;
        if (info->reg_locations)
                memcpy (frame->reg_locations, info->reg_locations, MONO_MAX_IREGS * sizeof (mgreg_t*));
        if (ctx) {
@@ -4096,7 +4138,7 @@ jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result)
 
        send_type_load (method->klass);
 
-       if (!result)
+       if (!result && jinfo)
                add_pending_breakpoints (method, jinfo);
 }
 
@@ -4229,11 +4271,15 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo
        if (it.seq_point.native_offset == SEQ_POINT_NATIVE_OFFSET_DEAD_CODE) {
                DEBUG_PRINTF (1, "[dbg] Attempting to insert seq point at dead IL offset %d, ignoring.\n", (int)bp->il_offset);
        } else if (count == 0) {
+               if (ji->is_interp) {
+                       mono_interp_set_breakpoint (ji, inst->ip);
+               } else {
 #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
-               mono_arch_set_breakpoint (ji, inst->ip);
+                       mono_arch_set_breakpoint (ji, inst->ip);
 #else
-               NOT_IMPLEMENTED;
+                       NOT_IMPLEMENTED;
 #endif
+               }
        }
 
        DEBUG_PRINTF (1, "[dbg] Inserted breakpoint at %s:[il=0x%x,native=0x%x] [%p](%d).\n", mono_method_full_name (jinfo_get_method (ji), TRUE), (int)it.seq_point.il_offset, (int)it.seq_point.native_offset, inst->ip, count);
@@ -4255,7 +4301,10 @@ remove_breakpoint (BreakpointInstance *inst)
        g_assert (count > 0);
 
        if (count == 1 && inst->native_offset != SEQ_POINT_NATIVE_OFFSET_DEAD_CODE) {
-               mono_arch_clear_breakpoint (ji, ip);
+               if (ji->is_interp)
+                       mono_interp_clear_breakpoint (ji, ip);
+               else
+                       mono_arch_clear_breakpoint (ji, ip);
                DEBUG_PRINTF (1, "[dbg] Clear breakpoint at %s [%p].\n", mono_method_full_name (jinfo_get_method (ji), TRUE), ip);
        }
 #else
@@ -4372,12 +4421,15 @@ set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_
                /* Might be AOTed code */
                mono_class_init (method->klass);
                code = mono_aot_get_method_checked (domain, method, &oerror);
-               g_assert (code);
-               mono_error_assert_ok (&oerror);
-               ji = mono_jit_info_table_find (domain, (char *)code);
+               if (code) {
+                       mono_error_assert_ok (&oerror);
+                       ji = mono_jit_info_table_find (domain, (char *)code);
+               } else {
+                       /* Might be interpreted */
+                       ji = mono_interp_find_jit_info (domain, method);
+               }
                g_assert (ji);
        }
-       g_assert (code);
 
        insert_breakpoint (seq_points, domain, ji, bp, error);
 }
@@ -4636,16 +4688,15 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t
                }
        }
 
-       MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method);
-       if (asyncMethod) {
-               for (int i = 0; i < asyncMethod->num_awaits; i++)
-               {
-                       if (asyncMethod->yield_offsets[i] == sp->il_offset || asyncMethod->resume_offsets[i] == sp->il_offset) {
-                               mono_debug_free_method_async_debug_info (asyncMethod);
+       MonoDebugMethodAsyncInfo* async_method = mono_debug_lookup_method_async_debug_info (method);
+       if (async_method) {
+               for (int i = 0; i < async_method->num_awaits; i++) {
+                       if (async_method->yield_offsets[i] == sp->il_offset || async_method->resume_offsets[i] == sp->il_offset) {
+                               mono_debug_free_method_async_debug_info (async_method);
                                return FALSE;
                        }
                }
-               mono_debug_free_method_async_debug_info (asyncMethod);
+               mono_debug_free_method_async_debug_info (async_method);
        }
 
        if (req->size != STEP_SIZE_LINE)
@@ -4756,7 +4807,7 @@ get_notify_debugger_of_wait_completion_method ()
 }
 
 static void
-process_breakpoint_inner (DebuggerTlsData *tls, gboolean from_signal)
+process_breakpoint (DebuggerTlsData *tls, gboolean from_signal)
 {
        MonoJitInfo *ji;
        guint8 *ip;
@@ -4777,11 +4828,27 @@ process_breakpoint_inner (DebuggerTlsData *tls, gboolean from_signal)
 
        ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
        ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, NULL);
+
+       if (!ji) {
+               /* Interpreter */
+               // FIXME: Pass a flag instead to detect this
+               MonoLMF *lmf = mono_get_lmf ();
+               MonoInterpFrameHandle *frame;
+
+               g_assert (((guint64)lmf->previous_lmf) & 2);
+               MonoLMFExt *ext = (MonoLMFExt*)lmf;
+
+               g_assert (ext->interp_exit);
+               frame = ext->interp_exit_data;
+               ji = mono_interp_frame_get_jit_info (frame);
+               ip = mono_interp_frame_get_ip (frame);
+       }
+
        g_assert (ji && !ji->is_trampoline);
        method = jinfo_get_method (ji);
 
        /* Compute the native offset of the breakpoint from the ip */
-       native_offset = ip - (guint8*)ji->code_start;   
+       native_offset = ip - (guint8*)ji->code_start;
 
        /* 
         * Skip the instruction causing the breakpoint signal.
@@ -4936,9 +5003,9 @@ process_signal_event (void (*func) (DebuggerTlsData*, gboolean))
 }
 
 static void
-process_breakpoint (void)
+process_breakpoint_from_signal (void)
 {
-       process_signal_event (process_breakpoint_inner);
+       process_signal_event (process_breakpoint);
 }
 
 static void
@@ -4980,19 +5047,30 @@ mono_debugger_agent_breakpoint_hit (void *sigctx)
         * problems, like the original signal is disabled, libgc can't handle altstack, etc.
         * So set up the signal context to return to the real breakpoint handler function.
         */
-       resume_from_signal_handler (sigctx, process_breakpoint);
+       resume_from_signal_handler (sigctx, process_breakpoint_from_signal);
 }
 
+typedef struct {
+       gboolean found;
+       MonoContext *ctx;
+} UserBreakCbData;
+
 static gboolean
-user_break_cb (StackFrameInfo *frame, MonoContext *ctx, gpointer data)
+user_break_cb (StackFrameInfo *frame, MonoContext *ctx, gpointer user_data)
 {
+       UserBreakCbData *data = user_data;
+
+       if (frame->type == FRAME_TYPE_INTERP_TO_MANAGED) {
+               data->found = TRUE;
+               return TRUE;
+       }
        if (frame->managed) {
-               *(MonoContext*)data = *ctx;
+               data->found = TRUE;
+               *data->ctx = *ctx;
 
                return TRUE;
-       } else {
-               return FALSE;
        }
+       return FALSE;
 }
 
 /*
@@ -5005,11 +5083,15 @@ mono_debugger_agent_user_break (void)
                MonoContext ctx;
                int suspend_policy;
                GSList *events;
+               UserBreakCbData data;
+
+               memset (&data, 0, sizeof (UserBreakCbData));
+               data.ctx = &ctx;
 
                /* Obtain a context */
                MONO_CONTEXT_SET_IP (&ctx, NULL);
-               mono_walk_stack_with_ctx (user_break_cb, NULL, (MonoUnwindOptions)0, &ctx);
-               g_assert (MONO_CONTEXT_GET_IP (&ctx) != NULL);
+               mono_walk_stack_with_ctx (user_break_cb, NULL, (MonoUnwindOptions)0, &data);
+               g_assert (data.found);
 
                mono_loader_lock ();
                events = create_event_list (EVENT_KIND_USER_BREAK, NULL, NULL, NULL, &suspend_policy);
@@ -5051,8 +5133,6 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal)
        SeqPoint sp;
        MonoSeqPointInfo *info;
 
-       ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
-
        /* Skip the instruction causing the single step */
        if (from_signal)
                mono_arch_skip_single_step (ctx);
@@ -5072,14 +5152,15 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal)
        if (mono_thread_internal_current () != ss_req->thread)
                return;
 
-       if (log_level > 0) {
-               ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, &domain);
+       ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx);
 
+       ji = get_top_method_ji (ip, &domain, (gpointer*)&ip);
+       g_assert (ji && !ji->is_trampoline);
+
+       if (log_level > 0) {
                DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer) (gsize) mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp);
        }
 
-       ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, &domain);
-       g_assert (ji && !ji->is_trampoline);
        method = jinfo_get_method (ji);
        g_assert (method);
 
@@ -5114,8 +5195,10 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal)
         * The ip points to the instruction causing the single step event, which is before
         * the offset recorded in the seq point map, so find the next seq point after ip.
         */
-       if (!mono_find_next_seq_point_for_native_offset (domain, method, (guint8*)ip - (guint8*)ji->code_start, &info, &sp))
+       if (!mono_find_next_seq_point_for_native_offset (domain, method, (guint8*)ip - (guint8*)ji->code_start, &info, &sp)) {
+               g_assert_not_reached ();
                return;
+       }
 
        il_offset = sp.il_offset;
 
@@ -5230,7 +5313,7 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx)
        mono_thread_state_init_from_monoctx (&tls->restore_state, ctx);
        memcpy (&tls->handler_ctx, ctx, sizeof (MonoContext));
 
-       process_breakpoint_inner (tls, FALSE);
+       process_breakpoint (tls, FALSE);
 
        memcpy (ctx, &tls->restore_state.ctx, sizeof (MonoContext));
        memcpy (&tls->restore_state, &orig_restore_state, sizeof (MonoThreadUnwindState));
@@ -5250,8 +5333,10 @@ start_single_stepping (void)
 #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
        int val = InterlockedIncrement (&ss_count);
 
-       if (val == 1)
+       if (val == 1) {
                mono_arch_start_single_stepping ();
+               mono_interp_start_single_stepping ();
+       }
 #else
        g_assert_not_reached ();
 #endif
@@ -5263,8 +5348,10 @@ stop_single_stepping (void)
 #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
        int val = InterlockedDecrement (&ss_count);
 
-       if (val == 0)
+       if (val == 0) {
                mono_arch_stop_single_stepping ();
+               mono_interp_stop_single_stepping ();
+       }
 #else
        g_assert_not_reached ();
 #endif
@@ -6707,6 +6794,24 @@ set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domai
        }
 }
 
+static void
+set_interp_var (MonoType *t, gpointer addr, guint8 *val_buf)
+{
+       int size;
+
+       if (t->byref) {
+               addr = *(gpointer*)addr;
+               g_assert (addr);
+       }
+
+       if (MONO_TYPE_IS_REFERENCE (t))
+               size = sizeof (gpointer);
+       else
+               size = mono_class_value_size (mono_class_from_mono_type (t), NULL);
+
+       memcpy (addr, val_buf, size);
+}
+
 static void
 clear_event_request (int req_id, int etype)
 {
@@ -6991,11 +7096,17 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
                                args [i] = arg_buf [i];
                        }
                } else {
-                       arg_buf [i] = (guint8 *)g_alloca (mono_class_instance_size (mono_class_from_mono_type (sig->params [i])));
+                       MonoClass *arg_class = mono_class_from_mono_type (sig->params [i]);
+                       arg_buf [i] = (guint8 *)g_alloca (mono_class_instance_size (arg_class));
                        err = decode_value (sig->params [i], domain, arg_buf [i], p, &p, end);
                        if (err != ERR_NONE)
                                break;
-                       args [i] = arg_buf [i];
+                       if (mono_class_is_nullable (arg_class)) {
+                               args [i] = mono_nullable_box (arg_buf [i], arg_class, &error);
+                               mono_error_assert_ok (&error);
+                       } else {
+                               args [i] = arg_buf [i];
+                       }
                }
        }
 
@@ -9376,7 +9487,13 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                // FIXME: Check that the ip change is safe
 
                DEBUG_PRINTF (1, "[dbg] Setting IP to %s:0x%0x(0x%0x)\n", tls->frames [0]->actual_method->name, (int)sp.il_offset, (int)sp.native_offset);
-               MONO_CONTEXT_SET_IP (&tls->restore_state.ctx, (guint8*)tls->frames [0]->ji->code_start + sp.native_offset);
+
+               if (tls->frames [0]->ji->is_interp) {
+                       MonoJitTlsData *jit_data = ((MonoThreadInfo*)thread->thread_info)->jit_data;
+                       mono_interp_set_resume_state (jit_data, NULL, tls->frames [0]->interp_frame, (guint8*)tls->frames [0]->ji->code_start + sp.native_offset);
+               } else {
+                       MONO_CONTEXT_SET_IP (&tls->restore_state.ctx, (guint8*)tls->frames [0]->ji->code_start + sp.native_offset);
+               }
                break;
        }
        default:
@@ -9442,7 +9559,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
 
        sig = mono_method_signature (frame->actual_method);
 
-       if (!jit->has_var_info || !mono_get_seq_points (frame->domain, frame->actual_method))
+       if (!(jit->has_var_info || frame->ji->is_interp) || !mono_get_seq_points (frame->domain, frame->actual_method))
                /*
                 * The method is probably from an aot image compiled without soft-debug, variables might be dead, etc.
                 */
@@ -9463,9 +9580,17 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
 
                                DEBUG_PRINTF (4, "[dbg]   send arg %d.\n", pos);
 
-                               g_assert (pos >= 0 && pos < jit->num_params);
+                               if (frame->ji->is_interp) {
+                                       guint8 *addr;
+
+                                       addr = mono_interp_frame_get_arg (frame->interp_frame, pos);
+
+                                       buffer_add_value_full (buf, sig->params [pos], addr, frame->domain, FALSE, NULL);
+                               } else {
+                                       g_assert (pos >= 0 && pos < jit->num_params);
 
-                               add_var (buf, jit, sig->params [pos], &jit->params [pos], &frame->ctx, frame->domain, FALSE);
+                                       add_var (buf, jit, sig->params [pos], &jit->params [pos], &frame->ctx, frame->domain, FALSE);
+                               }
                        } else {
                                MonoDebugLocalsInfo *locals;
 
@@ -9475,30 +9600,57 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                                        pos = locals->locals [pos].index;
                                        mono_debug_free_locals (locals);
                                }
-                               g_assert (pos >= 0 && pos < jit->num_locals);
 
                                DEBUG_PRINTF (4, "[dbg]   send local %d.\n", pos);
 
-                               add_var (buf, jit, header->locals [pos], &jit->locals [pos], &frame->ctx, frame->domain, FALSE);
+                               if (frame->ji->is_interp) {
+                                       guint8 *addr;
+
+                                       addr = mono_interp_frame_get_local (frame->interp_frame, pos);
+
+                                       buffer_add_value_full (buf, header->locals [pos], addr, frame->domain, FALSE, NULL);
+                               } else {
+                                       g_assert (pos >= 0 && pos < jit->num_locals);
+
+                                       add_var (buf, jit, header->locals [pos], &jit->locals [pos], &frame->ctx, frame->domain, FALSE);
+                               }
                        }
                }
                mono_metadata_free_mh (header);
                break;
        }
        case CMD_STACK_FRAME_GET_THIS: {
+               if (frame->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
+                       return ERR_ABSENT_INFORMATION;
                if (frame->api_method->klass->valuetype) {
                        if (!sig->hasthis) {
                                MonoObject *p = NULL;
                                buffer_add_value (buf, &mono_defaults.object_class->byval_arg, &p, frame->domain);
                        } else {
-                               add_var (buf, jit, &frame->actual_method->klass->this_arg, jit->this_var, &frame->ctx, frame->domain, TRUE);
+                               if (frame->ji->is_interp) {
+                                       guint8 *addr;
+
+                                       addr = mono_interp_frame_get_this (frame->interp_frame);
+
+                                       buffer_add_value_full (buf, &frame->actual_method->klass->this_arg, addr, frame->domain, FALSE, NULL);
+                               } else {
+                                       add_var (buf, jit, &frame->actual_method->klass->this_arg, jit->this_var, &frame->ctx, frame->domain, TRUE);
+                               }
                        }
                } else {
                        if (!sig->hasthis) {
                                MonoObject *p = NULL;
                                buffer_add_value (buf, &frame->actual_method->klass->byval_arg, &p, frame->domain);
                        } else {
-                               add_var (buf, jit, &frame->api_method->klass->byval_arg, jit->this_var, &frame->ctx, frame->domain, TRUE);
+                               if (frame->ji->is_interp) {
+                                       guint8 *addr;
+
+                                       addr = mono_interp_frame_get_this (frame->interp_frame);
+
+                                       buffer_add_value_full (buf, &frame->api_method->klass->byval_arg, addr, frame->domain, FALSE, NULL);
+                               } else {
+                                       add_var (buf, jit, &frame->api_method->klass->byval_arg, jit->this_var, &frame->ctx, frame->domain, TRUE);
+                               }
                        }
                }
                break;
@@ -9507,7 +9659,8 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                MonoError error;
                guint8 *val_buf;
                MonoType *t;
-               MonoDebugVarInfo *var;
+               MonoDebugVarInfo *var = NULL;
+               gboolean is_arg = FALSE;
 
                len = decode_int (p, &p, end);
                header = mono_method_get_header_checked (frame->actual_method, &error);
@@ -9523,6 +9676,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
 
                                t = sig->params [pos];
                                var = &jit->params [pos];
+                               is_arg = TRUE;
                        } else {
                                MonoDebugLocalsInfo *locals;
 
@@ -9546,7 +9700,17 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                        if (err != ERR_NONE)
                                return err;
 
-                       set_var (t, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx);
+                       if (frame->ji->is_interp) {
+                               guint8 *addr;
+
+                               if (is_arg)
+                                       addr = mono_interp_frame_get_arg (frame->interp_frame, pos);
+                               else
+                                       addr = mono_interp_frame_get_local (frame->interp_frame, pos);
+                               set_interp_var (t, addr, val_buf);
+                       } else {
+                               set_var (t, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx);
+                       }
                }
                mono_metadata_free_mh (header);
                break;
@@ -9564,15 +9728,23 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                t = &frame->actual_method->klass->byval_arg;
                /* Checked by the sender */
                g_assert (MONO_TYPE_ISSTRUCT (t));
-               var = jit->this_var;
-               g_assert (var);
 
                val_buf = (guint8 *)g_alloca (mono_class_instance_size (mono_class_from_mono_type (t)));
                err = decode_value (t, frame->domain, val_buf, p, &p, end);
                if (err != ERR_NONE)
                        return err;
 
-               set_var (&frame->actual_method->klass->this_arg, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx);
+               if (frame->ji->is_interp) {
+                       guint8 *addr;
+
+                       addr = mono_interp_frame_get_this (frame->interp_frame);
+                       set_interp_var (&frame->actual_method->klass->this_arg, addr, val_buf);
+               } else {
+                       var = jit->this_var;
+                       g_assert (var);
+
+                       set_var (&frame->actual_method->klass->this_arg, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx);
+               }
                break;
        }
        default:
index 1c3060f162477cc8db01fbc0c64c6eb2c6f3ebbb..93668ac852457377081ddd806f9b8f65ad75b32a 100644 (file)
@@ -1227,8 +1227,8 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
 
                                        EMIT_NEW_VARLOADA ((cfg), (src), src_var, src_var->inst_vtype);
                                        EMIT_NEW_VARLOADA ((cfg), (dest), dest_var, dest_var->inst_vtype);
+                                       mini_emit_memory_copy (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke, 0);
 
-                                       mini_emit_stobj (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke);
                                        break;
                                }
                                case OP_VZERO:
@@ -1273,7 +1273,7 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
 
                                        dreg = alloc_preg (cfg);
                                        EMIT_NEW_BIALU_IMM (cfg, dest, OP_ADD_IMM, dreg, ins->inst_destbasereg, ins->inst_offset);
-                                       mini_emit_stobj (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke);
+                                       mini_emit_memory_copy (cfg, dest, src, src_var->klass, src_var->backend.is_pinvoke, 0);
                                        break;
                                }
                                case OP_LOADV_MEMBASE: {
@@ -1290,7 +1290,7 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
                                        dreg = alloc_preg (cfg);
                                        EMIT_NEW_BIALU_IMM (cfg, src, OP_ADD_IMM, dreg, ins->inst_basereg, ins->inst_offset);
                                        EMIT_NEW_VARLOADA (cfg, dest, dest_var, dest_var->inst_vtype);
-                                       mini_emit_stobj (cfg, dest, src, dest_var->klass, dest_var->backend.is_pinvoke);
+                                       mini_emit_memory_copy (cfg, dest, src, dest_var->klass, dest_var->backend.is_pinvoke, 0);
                                        break;
                                }
                                case OP_OUTARG_VT: {
index 8719a12994c8e3fa936f5c34277412141aa72953..934eb0a54a363138728a0bdc19f64f45e77df70b 100644 (file)
@@ -121,10 +121,6 @@ opt_names [] = {
 
 #endif
 
-#ifdef __native_client__
-extern char *nacl_mono_path;
-#endif
-
 #define DEFAULT_OPTIMIZATIONS (        \
        MONO_OPT_PEEPHOLE |     \
        MONO_OPT_CFOLD |        \
@@ -1603,9 +1599,6 @@ mono_main (int argc, char* argv[])
 #ifdef HOST_WIN32
        int mixed_mode = FALSE;
 #endif
-#ifdef __native_client__
-       gboolean nacl_null_checks_off = FALSE;
-#endif
 
 #ifdef MOONLIGHT
 #ifndef HOST_WIN32
@@ -1937,13 +1930,6 @@ mono_main (int argc, char* argv[])
 #else
                        fprintf (stderr, "Mono Warning: --interp= not enabled in this runtime.\n");
 #endif
-
-#ifdef __native_client__
-               } else if (strcmp (argv [i], "--nacl-mono-path") == 0){
-                       nacl_mono_path = g_strdup(argv[++i]);
-               } else if (strcmp (argv [i], "--nacl-null-checks-off") == 0){
-                       nacl_null_checks_off = TRUE;
-#endif
                } else if (strncmp (argv [i], "--assembly-loader=", strlen("--assembly-loader=")) == 0) {
                        gchar *arg = argv [i] + strlen ("--assembly-loader=");
                        if (strcmp (arg, "strict") == 0)
@@ -1968,13 +1954,6 @@ mono_main (int argc, char* argv[])
                }
        }
 
-#ifdef __native_client_codegen__
-       if (!nacl_null_checks_off) {
-               MonoDebugOptions *opt = mini_get_debug_options ();
-               opt->explicit_null_checks = TRUE;
-       }
-#endif
-
 #if defined(DISABLE_HW_TRAPS) || defined(MONO_ARCH_DISABLE_HW_TRAPS)
        // Signal handlers not available
        {
@@ -2397,6 +2376,10 @@ mono_jit_set_aot_mode (MonoAotMode mode)
                mono_set_generic_sharing_vt_supported (TRUE);
                mono_set_partial_sharing_supported (TRUE);
        }
+       if (mono_aot_mode == MONO_AOT_MODE_INTERP) {
+               mono_aot_only = TRUE;
+               mono_use_interpreter = TRUE;
+       }
 }
 
 /**
index f21ba2b5d18493d36caff6c2c3f4a94196963640..07f498e628ba1812082dbf0cb1d3a12b2d86245d 100644 (file)
@@ -1462,7 +1462,6 @@ class Tests
                return 0;
        }
        
-       [Category ("NaClDisable")]
        public static int test_0_div_zero () {
                int d = 1;
                int q = 0;
@@ -1633,7 +1632,6 @@ class Tests
                return 0;
        }
 
-       [Category ("NaClDisable")]
        public static int test_0_long_div_zero () {
                long d = 1;
                long q = 0;
index 357651ee64175b78d2d4ecb3fd1d88ee7b808853..60ff683a9af013b5e752fba402e179e89eb425d5 100644 (file)
 #include <string.h>
 #include <mono/metadata/opcodes.h>
 
-#if defined(__native_client__) || defined(__native_client_codegen__)
-volatile int __nacl_thread_suspension_needed = 0;
-void __nacl_suspend_thread_if_needed() {}
-#endif
-
 #define MINI_OP(a,b,dest,src1,src2) b,
 #define MINI_OP3(a,b,dest,src1,src2,src3) b,
 /* keep in sync with the enum in mini.h */
index 7f681b23bb5ba355da140cd5fb52c4b0fac81acb..6a741ca23b0ac313ca8be69ed98f7e507ebbebdf 100644 (file)
@@ -135,9 +135,6 @@ mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint
 void
 mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 {
-#if defined(__native_client__)
-       return;
-#endif
 #ifndef DISABLE_LOGGING
        GHashTable *offset_to_bb_hash = NULL;
        int i, cindex, bb_num;
index f381ac8358750ff78ef0ac55f11862c110b6442d..b5cf20dfde120e02d353ad7e69e64c3b82788dd6 100644 (file)
@@ -55,7 +55,7 @@
  * TARGET_ASM_GAS == GNU assembler
  */
 #if !defined(TARGET_ASM_APPLE) && !defined(TARGET_ASM_GAS)
-#if defined(TARGET_MACH) && !defined(__native_client_codegen__)
+#if defined(TARGET_MACH)
 #define TARGET_ASM_APPLE
 #else
 #define TARGET_ASM_GAS
@@ -329,11 +329,6 @@ bin_writer_emit_ensure_buffer (BinSection *section, int size)
                while (new_size <= new_offset)
                        new_size *= 2;
                data = (guint8 *)g_malloc0 (new_size);
-#ifdef __native_client_codegen__
-               /* for Native Client, fill empty space with HLT instruction */
-               /* instead of 00.                                           */
-               memset(data, 0xf4, new_size);
-#endif         
                memcpy (data, section->data, section->data_len);
                g_free (section->data);
                section->data = data;
index cc4cd237c677f3be75f9b93162979168aef28f7d..895ea8242bacaa448fb3195fe3230fbcb3d1cdcd 100644 (file)
@@ -94,6 +94,7 @@ typedef struct _RuntimeMethod
        MonoType *rtype;
        MonoType **param_types;
        MonoJitInfo *jinfo;
+       MonoDomain *domain;
 } RuntimeMethod;
 
 struct _MonoInvocation {
@@ -105,6 +106,7 @@ struct _MonoInvocation {
        stackval       *stack_args; /* parent */
        stackval       *stack;
        stackval       *sp; /* For GC stack marking */
+       unsigned char  *locals;
        /* exception info */
        unsigned char  invoke_trap;
        const unsigned short  *ip;
@@ -113,7 +115,6 @@ struct _MonoInvocation {
 };
 
 typedef struct {
-       MonoDomain *domain;
        MonoDomain *original_domain;
        MonoInvocation *base_frame;
        MonoInvocation *current_frame;
diff --git a/mono/mini/interp/interp-stubs.c b/mono/mini/interp/interp-stubs.c
new file mode 100644 (file)
index 0000000..176e45b
--- /dev/null
@@ -0,0 +1,98 @@
+#include <config.h>
+
+#ifndef ENABLE_INTERPRETER
+
+#include "interp.h"
+
+/* Dummy versions of interpreter functions to avoid ifdefs at call sites */
+
+MonoJitInfo*
+mono_interp_find_jit_info (MonoDomain *domain, MonoMethod *method)
+{
+       return NULL;
+}
+
+void
+mono_interp_set_breakpoint (MonoJitInfo *jinfo, gpointer ip)
+{
+       g_assert_not_reached ();
+}
+
+void
+mono_interp_clear_breakpoint (MonoJitInfo *jinfo, gpointer ip)
+{
+       g_assert_not_reached ();
+}
+
+MonoJitInfo*
+mono_interp_frame_get_jit_info (MonoInterpFrameHandle frame)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_interp_frame_get_ip (MonoInterpFrameHandle frame)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_interp_frame_get_arg (MonoInterpFrameHandle frame, int pos)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_interp_frame_get_local (MonoInterpFrameHandle frame, int pos)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_interp_frame_get_this (MonoInterpFrameHandle frame)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+void
+mono_interp_start_single_stepping (void)
+{
+}
+
+void
+mono_interp_stop_single_stepping (void)
+{
+}
+
+void
+mono_interp_set_resume_state (MonoJitTlsData *jit_tls, MonoException *ex, MonoInterpFrameHandle interp_frame, gpointer handler_ip)
+{
+       g_assert_not_reached ();
+}
+
+void
+mono_interp_run_finally (StackFrameInfo *frame, int clause_index, gpointer handler_ip)
+{
+       g_assert_not_reached ();
+}
+
+void
+mono_interp_frame_iter_init (MonoInterpStackIter *iter, gpointer interp_exit_data)
+{
+       g_assert_not_reached ();
+}
+
+gboolean
+mono_interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame)
+{
+       g_assert_not_reached ();
+       return FALSE;
+}
+
+#endif
+
index 68d3b3998a457502b485c9df372cd8aea54b47e9..a103ed22b6a851c332eed65ef8484189bd284847 100644 (file)
@@ -66,6 +66,7 @@
 
 #include <mono/mini/mini.h>
 #include <mono/mini/jit-icalls.h>
+#include <mono/mini/debugger-agent.h>
 
 #ifdef TARGET_ARM
 #include <mono/mini/mini-arm.h>
@@ -104,6 +105,8 @@ init_frame (MonoInvocation *frame, MonoInvocation *parent_frame, RuntimeMethod *
  * Used for testing.
  */
 GSList *jit_classes;
+/* If TRUE, interpreted code will be interrupted at function entry/backward branches */
+static gboolean ss_enabled;
 
 void ves_exec_method (MonoInvocation *frame);
 
@@ -204,14 +207,27 @@ static void debug_enter (MonoInvocation *frame, int *tracing)
 /* Set the current execution state to the resume state in context */
 #define SET_RESUME_STATE(context) do { \
                ip = (context)->handler_ip;                                             \
+               if (frame->ex) { \
                sp->data.p = frame->ex;                                                                                 \
                ++sp;                                                                                                                   \
+               } \
                frame->ex = NULL;                                                                                               \
                (context)->has_resume_state = 0;                                                                \
                (context)->handler_frame = NULL;                                                                \
                goto main_loop;                                                                                                 \
        } while (0)
 
+static void
+set_context (ThreadContext *context)
+{
+       MonoJitTlsData *jit_tls;
+
+       mono_native_tls_set_value (thread_context_id, context);
+       jit_tls = mono_tls_get_jit_tls ();
+       if (jit_tls)
+               jit_tls->interp_context = context;
+}
+
 static void
 ves_real_abort (int line, MonoMethod *mh,
                const unsigned short *ip, stackval *stack, stackval *sp)
@@ -234,6 +250,19 @@ ves_real_abort (int line, MonoMethod *mh,
                THROW_EX (mono_get_exception_execution_engine (NULL), ip); \
        } while (0);
 
+static RuntimeMethod*
+lookup_runtime_method (MonoDomain *domain, MonoMethod *method)
+{
+       RuntimeMethod *rtm;
+       MonoJitDomainInfo *info;
+
+       info = domain_jit_info (domain);
+       mono_domain_jit_code_hash_lock (domain);
+       rtm = mono_internal_hash_table_lookup (&info->interp_code_hash, method);
+       mono_domain_jit_code_hash_unlock (domain);
+       return rtm;
+}
+
 RuntimeMethod*
 mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error)
 {
@@ -255,6 +284,7 @@ mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoErro
 
        rtm = mono_domain_alloc0 (domain, sizeof (RuntimeMethod));
        rtm->method = method;
+       rtm->domain = domain;
        rtm->param_count = sig->param_count;
        rtm->hasthis = sig->hasthis;
        rtm->rtype = mini_get_underlying_type (sig->ret);
@@ -278,18 +308,48 @@ mono_interp_create_trampoline (MonoDomain *domain, MonoMethod *method, MonoError
        return mono_interp_get_runtime_method (domain, method, error);
 }
 
+/*
+ * interp_push_lmf:
+ *
+ * Push an LMF frame on the LMF stack
+ * to mark the transition to native code.
+ * This is needed for the native code to
+ * be able to do stack walks.
+ */
+static void
+interp_push_lmf (MonoLMFExt *ext, MonoInvocation *frame)
+{
+       memset (ext, 0, sizeof (MonoLMFExt));
+       ext->interp_exit = TRUE;
+       ext->interp_exit_data = frame;
+
+       mono_push_lmf (ext);
+}
+
+static void
+interp_pop_lmf (MonoLMFExt *ext)
+{
+       mono_pop_lmf (&ext->lmf);
+}
+
 static inline RuntimeMethod*
-get_virtual_method (MonoDomain *domain, RuntimeMethod *runtime_method, MonoObject *obj)
+get_virtual_method (RuntimeMethod *runtime_method, MonoObject *obj)
 {
        MonoMethod *m = runtime_method->method;
+       MonoDomain *domain = runtime_method->domain;
+       RuntimeMethod *ret = NULL;
        MonoError error;
 
+#ifndef DISABLE_REMOTING
+       if (mono_object_is_transparent_proxy (obj)) {
+               ret = mono_interp_get_runtime_method (domain, mono_marshal_get_remoting_invoke (m), &error);
+               mono_error_assert_ok (&error);
+               return ret;
+       }
+#endif
+
        if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
-               RuntimeMethod *ret = NULL;
-               if (mono_object_is_transparent_proxy (obj)) {
-                       ret = mono_interp_get_runtime_method (domain, mono_marshal_get_remoting_invoke (m), &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               } else if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
+               if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
                        ret = mono_interp_get_runtime_method (domain, mono_marshal_get_synchronized_wrapper (m), &error);
                        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                } else {
@@ -378,15 +438,19 @@ stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvo
        case MONO_TYPE_U4:
                result->data.i = *(guint32*)data;
                return;
-       case MONO_TYPE_R4:
-               result->data.f = *(float*)data;
+       case MONO_TYPE_R4: {
+               float tmp;
+               /* memmove handles unaligned case */
+               memmove (&tmp, data, sizeof (float));
+               result->data.f = tmp;
                return;
+    }
        case MONO_TYPE_I8:
        case MONO_TYPE_U8:
-               result->data.l = *(gint64*)data;
+               memmove (&result->data.l, data, sizeof (gint64));
                return;
        case MONO_TYPE_R8:
-               result->data.f = *(double*)data;
+               memmove (&result->data.f, data, sizeof (double));
                return;
        case MONO_TYPE_STRING:
        case MONO_TYPE_SZARRAY:
@@ -523,7 +587,7 @@ fill_in_trace (MonoException *exception, MonoInvocation *frame)
 {
        MonoError error;
        char *stack_trace = dump_frame (frame);
-       MonoDomain *domain = mono_domain_get();
+       MonoDomain *domain = frame->runtime_method->domain;
        (exception)->stack_trace = mono_string_new_checked (domain, stack_trace, &error);
        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
        (exception)->trace_ips = get_trace_ips (domain, frame);
@@ -928,10 +992,14 @@ ves_pinvoke_method (MonoInvocation *frame, MonoMethodSignature *sig, MonoFuncV a
 
        g_assert (!frame->runtime_method);
        if (!mono_interp_enter_icall_trampoline) {
-               MonoTrampInfo *info;
-               mono_interp_enter_icall_trampoline = mono_arch_get_enter_icall_trampoline (&info);
-               // TODO:
-               // mono_tramp_info_register (info, NULL);
+               if (mono_aot_only) {
+                       mono_interp_enter_icall_trampoline = mono_aot_get_trampoline ("enter_icall_trampoline");
+               } else {
+                       MonoTrampInfo *info;
+                       mono_interp_enter_icall_trampoline = mono_arch_get_enter_icall_trampoline (&info);
+                       // TODO:
+                       // mono_tramp_info_register (info, NULL);
+               }
        }
 
        InterpMethodArguments *margs = build_args_from_sig (sig, frame);
@@ -943,23 +1011,13 @@ ves_pinvoke_method (MonoInvocation *frame, MonoMethodSignature *sig, MonoFuncV a
        context->current_frame = frame;
        context->managed_code = 0;
 
-       /*
-        * Push an LMF frame on the LMF stack
-        * to mark the transition to native code.
-        */
-       memset (&ext, 0, sizeof (ext));
-       ext.interp_exit = TRUE;
-       ext.interp_exit_data = frame;
-
-       mono_push_lmf (&ext);
+       interp_push_lmf (&ext, frame);
 
        mono_interp_enter_icall_trampoline (addr, margs);
 
-       mono_pop_lmf (&ext.lmf);
+       interp_pop_lmf (&ext);
 
        context->managed_code = 1;
-       /* domain can only be changed by native code */
-       context->domain = mono_domain_get ();
 
        if (*mono_thread_interruption_request_flag ()) {
                MonoException *exc = mono_thread_interruption_checkpoint ();
@@ -1307,7 +1365,7 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
        int i, type, isobject = 0;
        void *ret = NULL;
        stackval result;
-       stackval *args = alloca (sizeof (stackval) * (sig->param_count + !!sig->hasthis));
+       stackval *args;
        ThreadContext context_struct;
        MonoInvocation *old_frame = NULL;
        jmp_buf env;
@@ -1320,11 +1378,10 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
 
        if (setjmp(env)) {
                if (context != &context_struct) {
-                       context->domain = mono_domain_get ();
                        context->current_frame = old_frame;
                        context->managed_code = 0;
-               } else 
-                       mono_native_tls_set_value (thread_context_id, NULL);
+               } else
+                       set_context (NULL);
                if (exc != NULL)
                        *exc = (MonoObject *)frame.ex;
                return retval;
@@ -1336,12 +1393,12 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
                context_struct.base_frame = &frame;
                context_struct.env_frame = &frame;
                context_struct.current_env = &env;
-               mono_native_tls_set_value (thread_context_id, context);
+               set_context (context);
        }
        else
                old_frame = context->current_frame;
 
-       context->domain = mono_domain_get ();
+       MonoDomain *domain = mono_domain_get ();
 
        switch (sig->ret->type) {
        case MONO_TYPE_VOID:
@@ -1354,7 +1411,7 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
                isobject = 1;
                break;
        case MONO_TYPE_VALUETYPE:
-               retval = mono_object_new_checked (context->domain, klass, error);
+               retval = mono_object_new_checked (domain, klass, error);
                ret = mono_object_unbox (retval);
                if (!sig->ret->data.klass->enumtype)
                        result.data.vt = ret;
@@ -1363,7 +1420,7 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
                break;
        case MONO_TYPE_GENERICINST:
                if (!MONO_TYPE_IS_REFERENCE (sig->ret)) {
-                       retval = mono_object_new_checked (context->domain, klass, error);
+                       retval = mono_object_new_checked (domain, klass, error);
                        ret = mono_object_unbox (retval);
                        if (!sig->ret->data.klass->enumtype)
                                result.data.vt = ret;
@@ -1375,15 +1432,16 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb
                break;
 
        case MONO_TYPE_PTR:
-               retval = mono_object_new_checked (context->domain, mono_defaults.int_class, error);
+               retval = mono_object_new_checked (domain, mono_defaults.int_class, error);
                ret = mono_object_unbox (retval);
                break;
        default:
-               retval = mono_object_new_checked (context->domain, klass, error);
+               retval = mono_object_new_checked (domain, klass, error);
                ret = mono_object_unbox (retval);
                break;
        }
 
+       args = alloca (sizeof (stackval) * (sig->param_count + !!sig->hasthis));
        if (sig->hasthis)
                args [0].data.p = obj;
 
@@ -1452,14 +1510,15 @@ handle_enum:
 
        if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
                method = mono_marshal_get_native_wrapper (method, FALSE, FALSE);
-       INIT_FRAME (&frame,context->current_frame,args,&result,mono_get_root_domain (),method,error);
+
+       INIT_FRAME (&frame,context->current_frame,args,&result,domain,method,error);
        if (exc)
                frame.invoke_trap = 1;
        context->managed_code = 1;
        ves_exec_method_with_context (&frame, context, NULL, NULL, -1);
        context->managed_code = 0;
        if (context == &context_struct)
-               mono_native_tls_set_value (thread_context_id, NULL);
+               set_context (NULL);
        else
                context->current_frame = old_frame;
        if (frame.ex != NULL) {
@@ -1519,11 +1578,10 @@ interp_entry (InterpEntryData *data)
                memset (context, 0, sizeof (ThreadContext));
                context_struct.base_frame = &frame;
                context_struct.env_frame = &frame;
-               mono_native_tls_set_value (thread_context_id, context);
-       }
-       else
+               set_context (context);
+       } else {
                old_frame = context->current_frame;
-       context->domain = mono_domain_get ();
+       }
 
        args = alloca (sizeof (stackval) * (sig->param_count + (sig->hasthis ? 1 : 0)));
        if (sig->hasthis)
@@ -1615,7 +1673,7 @@ interp_entry (InterpEntryData *data)
        ves_exec_method_with_context (&frame, context, NULL, NULL, -1);
        context->managed_code = 0;
        if (context == &context_struct)
-               mono_native_tls_set_value (thread_context_id, NULL);
+               set_context (NULL);
        else
                context->current_frame = old_frame;
 
@@ -1774,6 +1832,240 @@ do_icall (ThreadContext *context, int op, stackval *sp, gpointer ptr)
        return sp;
 }
 
+static stackval *
+do_jit_call (stackval *sp, unsigned char *vt_sp, ThreadContext *context, MonoInvocation *frame, RuntimeMethod *rmethod)
+{
+       MonoMethodSignature *sig;
+       MonoFtnDesc ftndesc;
+       guint8 res_buf [256];
+       MonoType *type;
+       MonoLMFExt ext;
+
+       //printf ("%s\n", mono_method_full_name (rmethod->method, 1));
+
+       /*
+        * Call JITted code through a gsharedvt_out wrapper. These wrappers receive every argument
+        * by ref and return a return value using an explicit return value argument.
+        */
+       if (!rmethod->jit_wrapper) {
+               MonoMethod *method = rmethod->method;
+               MonoError error;
+
+               sig = mono_method_signature (method);
+               g_assert (sig);
+
+               MonoMethod *wrapper = mini_get_gsharedvt_out_sig_wrapper (sig);
+               //printf ("J: %s %s\n", mono_method_full_name (method, 1), mono_method_full_name (wrapper, 1));
+
+               gpointer jit_wrapper = mono_jit_compile_method_jit_only (wrapper, &error);
+               mono_error_assert_ok (&error);
+
+               gpointer addr = mono_jit_compile_method_jit_only (method, &error);
+               g_assert (addr);
+               mono_error_assert_ok (&error);
+
+               rmethod->jit_addr = addr;
+               rmethod->jit_sig = sig;
+               mono_memory_barrier ();
+               rmethod->jit_wrapper = jit_wrapper;
+
+       } else {
+               sig = rmethod->jit_sig;
+       }
+
+       sp -= sig->param_count;
+       if (sig->hasthis)
+               --sp;
+
+       ftndesc.addr = rmethod->jit_addr;
+       ftndesc.arg = NULL;
+
+       // FIXME: Optimize this
+
+       gpointer args [32];
+       int pindex = 0;
+       int stack_index = 0;
+       if (rmethod->hasthis) {
+               args [pindex ++] = sp [0].data.p;
+               stack_index ++;
+       }
+       type = rmethod->rtype;
+       if (type->type != MONO_TYPE_VOID) {
+               if (MONO_TYPE_ISSTRUCT (type))
+                       args [pindex ++] = vt_sp;
+               else
+                       args [pindex ++] = res_buf;
+       }
+       for (int i = 0; i < rmethod->param_count; ++i) {
+               MonoType *t = rmethod->param_types [i];
+               stackval *sval = &sp [stack_index + i];
+               if (sig->params [i]->byref) {
+                       args [pindex ++] = sval->data.p;
+               } else if (MONO_TYPE_ISSTRUCT (t)) {
+                       args [pindex ++] = sval->data.p;
+               } else if (MONO_TYPE_IS_REFERENCE (t)) {
+                       args [pindex ++] = &sval->data.p;
+               } else {
+                       switch (t->type) {
+                       case MONO_TYPE_I1:
+                       case MONO_TYPE_U1:
+                       case MONO_TYPE_I2:
+                       case MONO_TYPE_U2:
+                       case MONO_TYPE_I4:
+                       case MONO_TYPE_U4:
+                       case MONO_TYPE_VALUETYPE:
+                               args [pindex ++] = &sval->data.i;
+                               break;
+                       case MONO_TYPE_PTR:
+                       case MONO_TYPE_FNPTR:
+                       case MONO_TYPE_I:
+                       case MONO_TYPE_U:
+                       case MONO_TYPE_OBJECT:
+                               args [pindex ++] = &sval->data.p;
+                               break;
+                       case MONO_TYPE_I8:
+                       case MONO_TYPE_U8:
+                               args [pindex ++] = &sval->data.l;
+                               break;
+                       default:
+                               printf ("%s\n", mono_type_full_name (t));
+                               g_assert_not_reached ();
+                       }
+               }
+       }
+
+       interp_push_lmf (&ext, frame);
+
+       switch (pindex) {
+       case 0: {
+               void (*func)(gpointer) = rmethod->jit_wrapper;
+
+               func (&ftndesc);
+               break;
+       }
+       case 1: {
+               void (*func)(gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], &ftndesc);
+               break;
+       }
+       case 2: {
+               void (*func)(gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], args [1], &ftndesc);
+               break;
+       }
+       case 3: {
+               void (*func)(gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], args [1], args [2], &ftndesc);
+               break;
+       }
+       case 4: {
+               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], args [1], args [2], args [3], &ftndesc);
+               break;
+       }
+       case 5: {
+               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], args [1], args [2], args [3], args [4], &ftndesc);
+               break;
+       }
+       case 6: {
+               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], args [1], args [2], args [3], args [4], args [5], &ftndesc);
+               break;
+       }
+       case 7: {
+               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
+
+               func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], &ftndesc);
+               break;
+       }
+       default:
+               g_assert_not_reached ();
+               break;
+       }
+
+       interp_pop_lmf (&ext);
+
+       MonoType *rtype = rmethod->rtype;
+       switch (rtype->type) {
+       case MONO_TYPE_VOID:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_ARRAY:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+               sp->data.p = *(gpointer*)res_buf;
+               break;
+       case MONO_TYPE_I1:
+               sp->data.i = *(gint8*)res_buf;
+               break;
+       case MONO_TYPE_U1:
+               sp->data.i = *(guint8*)res_buf;
+               break;
+       case MONO_TYPE_I2:
+               sp->data.i = *(gint16*)res_buf;
+               break;
+       case MONO_TYPE_U2:
+               sp->data.i = *(guint16*)res_buf;
+               break;
+       case MONO_TYPE_I4:
+               sp->data.i = *(gint32*)res_buf;
+               break;
+       case MONO_TYPE_U4:
+               sp->data.i = *(guint32*)res_buf;
+               break;
+       case MONO_TYPE_VALUETYPE:
+               /* The result was written to vt_sp */
+               sp->data.p = vt_sp;
+               break;
+       case MONO_TYPE_GENERICINST:
+               if (MONO_TYPE_IS_REFERENCE (rtype)) {
+                       sp->data.p = *(gpointer*)res_buf;
+               } else {
+                       /* The result was written to vt_sp */
+                       sp->data.p = vt_sp;
+               }
+               break;
+       default:
+               printf ("%s\n", mono_type_full_name (rtype));
+               g_assert_not_reached ();
+               break;
+       }
+
+       return sp;
+}
+
+static void
+do_debugger_tramp (void (*tramp) (void), MonoInvocation *frame)
+{
+       MonoLMFExt ext;
+       interp_push_lmf (&ext, frame);
+       tramp ();
+       interp_pop_lmf (&ext);
+}
+
+static void
+do_transform_method (MonoInvocation *frame, ThreadContext *context)
+{
+       MonoLMFExt ext;
+
+       /* Use the parent frame as the current frame is not complete yet */
+       interp_push_lmf (&ext, frame->parent);
+
+       frame->ex = mono_interp_transform_method (frame->runtime_method, context);
+       context->managed_code = 1;
+
+       interp_pop_lmf (&ext);
+}
+
 /*
  * These functions are the entry points into the interpreter from compiled code.
  * They are called by the interp_in wrappers. They have the following signature:
@@ -1941,13 +2233,12 @@ mono_interp_create_method_pointer (MonoMethod *method, MonoError *error)
        gpointer addr;
        MonoMethodSignature *sig = mono_method_signature (method);
        MonoMethod *wrapper;
-       RuntimeMethod *rmethod;
+       RuntimeMethod *rmethod = mono_interp_get_runtime_method (mono_domain_get (), method, error);
 
        /* HACK: method_ptr of delegate should point to a runtime method*/
        if (method->wrapper_type && method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD)
-               return mono_interp_get_runtime_method (mono_domain_get (), method, error);
+               return rmethod;
 
-       rmethod = mono_interp_get_runtime_method (mono_domain_get (), method, error);
        if (rmethod->jit_entry)
                return rmethod->jit_entry;
        wrapper = mini_get_interp_in_wrapper (sig);
@@ -1983,9 +2274,10 @@ mono_interp_create_method_pointer (MonoMethod *method, MonoError *error)
         * rgctx register using a trampoline.
         */
 
-       // FIXME: AOT
-       g_assert (!mono_aot_only);
-       addr = mono_arch_get_static_rgctx_trampoline (ftndesc, jit_wrapper);
+       if (mono_aot_only)
+               addr = mono_aot_get_static_rgctx_trampoline (ftndesc, jit_wrapper);
+       else
+               addr = mono_arch_get_static_rgctx_trampoline (ftndesc, jit_wrapper);
 
        mono_memory_barrier ();
        rmethod->jit_entry = addr;
@@ -2088,8 +2380,8 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                g_print ("(%p) Transforming %s\n", mono_thread_internal_current (), mn);
                g_free (mn);
 #endif
-               frame->ex = mono_interp_transform_method (frame->runtime_method, context);
-               context->managed_code = 1;
+
+               do_transform_method (frame, context);
                if (frame->ex) {
                        rtm = NULL;
                        ip = NULL;
@@ -2112,6 +2404,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
        vtalloc = vt_sp;
 #endif
        locals = (unsigned char *) vt_sp + rtm->vt_stack_size;
+       frame->locals = locals;
        child_frame.parent = frame;
 
        if (filter_exception) {
@@ -2138,7 +2431,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_BREAK)
                        ++ip;
-                       G_BREAKPOINT (); /* this is not portable... */
+                       do_debugger_tramp (mono_debugger_agent_user_break, frame);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_LDNULL) 
                        sp->data.p = NULL;
@@ -2257,6 +2550,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        vtalloc = vt_sp;
 #endif
                        locals = vt_sp + rtm->vt_stack_size;
+                       frame->locals = locals;
                        ip = rtm->new_body_start; /* bypass storing input args from callers frame */
                        MINT_IN_BREAK;
                }
@@ -2280,12 +2574,15 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                                --sp;
                        child_frame.stack_args = sp;
 
+#ifndef DISABLE_REMOTING
                        /* `this' can be NULL for string:.ctor */
                        if (csignature->hasthis && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
+                               child_frame.runtime_method = mono_interp_get_runtime_method (rtm->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_native_wrapper (child_frame.runtime_method->method, FALSE, FALSE), &error);
+                       } else
+#endif
+                       if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
+                               child_frame.runtime_method = mono_interp_get_runtime_method (rtm->domain, mono_marshal_get_native_wrapper (child_frame.runtime_method->method, FALSE, FALSE), &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        }
 
@@ -2390,11 +2687,13 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                                --sp;
                        child_frame.stack_args = sp;
 
+#ifndef DISABLE_REMOTING
                        /* `this' can be NULL for string:.ctor */
                        if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->method->klass->valuetype && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
+                               child_frame.runtime_method = mono_interp_get_runtime_method (rtm->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        }
+#endif
 
                        ves_exec_method_with_context (&child_frame, context, NULL, NULL, -1);
 
@@ -2438,10 +2737,12 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        }
                        child_frame.stack_args = sp;
 
+#ifndef DISABLE_REMOTING
                        if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->method->klass->valuetype && mono_object_is_transparent_proxy (sp->data.p)) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
+                               child_frame.runtime_method = mono_interp_get_runtime_method (rtm->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        }
+#endif
 
                        ves_exec_method_with_context (&child_frame, context, NULL, NULL, -1);
 
@@ -2465,173 +2766,10 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                }
 
                MINT_IN_CASE(MINT_JIT_CALL) {
-                       MonoMethodSignature *sig;
                        RuntimeMethod *rmethod = rtm->data_items [* (guint16 *)(ip + 1)];
-                       MonoFtnDesc ftndesc;
-                       guint8 res_buf [256];
-                       MonoType *type;
-                       MonoLMFExt ext;
-
-                       //printf ("%s\n", mono_method_full_name (rmethod->method, 1));
-
-                       /*
-                        * Call JITted code through a gsharedvt_out wrapper. These wrappers receive every argument
-                        * by ref and return a return value using an explicit return value argument.
-                        */
-                       if (!rmethod->jit_wrapper) {
-                               MonoMethod *method = rmethod->method;
-                               MonoError error;
-
-                               sig = mono_method_signature (method);
-                               g_assert (sig);
-
-                               MonoMethod *wrapper = mini_get_gsharedvt_out_sig_wrapper (sig);
-                               //printf ("J: %s %s\n", mono_method_full_name (method, 1), mono_method_full_name (wrapper, 1));
-
-                               gpointer jit_wrapper = mono_jit_compile_method_jit_only (wrapper, &error);
-                               mono_error_assert_ok (&error);
-
-                               gpointer addr = mono_jit_compile_method_jit_only (method, &error);
-                               g_assert (addr);
-                               mono_error_assert_ok (&error);
-
-                               rmethod->jit_addr = addr;
-                               rmethod->jit_sig = sig;
-                               mono_memory_barrier ();
-                               rmethod->jit_wrapper = jit_wrapper;
-
-                       } else {
-                               sig = rmethod->jit_sig;
-                       }
-
                        frame->ip = ip;
                        ip += 2;
-                       sp -= sig->param_count;
-                       if (sig->hasthis)
-                               --sp;
-
-                       ftndesc.addr = rmethod->jit_addr;
-                       ftndesc.arg = NULL;
-
-                       // FIXME: Optimize this
-
-                       gpointer args [32];
-                       int pindex = 0;
-                       int stack_index = 0;
-                       if (rmethod->hasthis) {
-                               args [pindex ++] = sp [0].data.p;
-                               stack_index ++;
-                       }
-                       type = rmethod->rtype;
-                       if (type->type != MONO_TYPE_VOID) {
-                               if (MONO_TYPE_ISSTRUCT (type))
-                                       args [pindex ++] = vt_sp;
-                               else
-                                       args [pindex ++] = res_buf;
-                       }
-                       for (int i = 0; i < rmethod->param_count; ++i) {
-                               MonoType *t = rmethod->param_types [i];
-                               stackval *sval = &sp [stack_index + i];
-                               if (sig->params [i]->byref) {
-                                       args [pindex ++] = sval->data.p;
-                               } else if (MONO_TYPE_ISSTRUCT (t)) {
-                                       args [pindex ++] = sval->data.p;
-                               } else if (MONO_TYPE_IS_REFERENCE (t)) {
-                                       args [pindex ++] = &sval->data.p;
-                               } else {
-                                       switch (t->type) {
-                                       case MONO_TYPE_I1:
-                                       case MONO_TYPE_U1:
-                                       case MONO_TYPE_I2:
-                                       case MONO_TYPE_U2:
-                                       case MONO_TYPE_I4:
-                                       case MONO_TYPE_U4:
-                                       case MONO_TYPE_VALUETYPE:
-                                               args [pindex ++] = &sval->data.i;
-                                               break;
-                                       case MONO_TYPE_PTR:
-                                       case MONO_TYPE_FNPTR:
-                                       case MONO_TYPE_I:
-                                       case MONO_TYPE_U:
-                                       case MONO_TYPE_OBJECT:
-                                               args [pindex ++] = &sval->data.p;
-                                               break;
-                                       case MONO_TYPE_I8:
-                                       case MONO_TYPE_U8:
-                                               args [pindex ++] = &sval->data.l;
-                                               break;
-                                       default:
-                                               printf ("%s\n", mono_type_full_name (t));
-                                               g_assert_not_reached ();
-                                       }
-                               }
-                       }
-
-                       /*
-                        * Push an LMF frame on the LMF stack
-                        * to mark the transition to compiled code.
-                        */
-                       memset (&ext, 0, sizeof (ext));
-                       ext.interp_exit = TRUE;
-                       ext.interp_exit_data = frame;
-
-                       mono_push_lmf (&ext);
-
-                       switch (pindex) {
-                       case 0: {
-                               void (*func)(gpointer) = rmethod->jit_wrapper;
-
-                               func (&ftndesc);
-                               break;
-                       }
-                       case 1: {
-                               void (*func)(gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], &ftndesc);
-                               break;
-                       }
-                       case 2: {
-                               void (*func)(gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], args [1], &ftndesc);
-                               break;
-                       }
-                       case 3: {
-                               void (*func)(gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], args [1], args [2], &ftndesc);
-                               break;
-                       }
-                       case 4: {
-                               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], args [1], args [2], args [3], &ftndesc);
-                               break;
-                       }
-                       case 5: {
-                               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], args [1], args [2], args [3], args [4], &ftndesc);
-                               break;
-                       }
-                       case 6: {
-                               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], args [1], args [2], args [3], args [4], args [5], &ftndesc);
-                               break;
-                       }
-                       case 7: {
-                               void (*func)(gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer, gpointer) = rmethod->jit_wrapper;
-
-                               func (args [0], args [1], args [2], args [3], args [4], args [5], args [6], &ftndesc);
-                               break;
-                       }
-                       default:
-                               g_assert_not_reached ();
-                               break;
-                       }
-
-                       mono_pop_lmf (&ext.lmf);
+                       sp = do_jit_call (sp, vt_sp, context, frame, rmethod);
 
                        if (context->has_resume_state) {
                                /*
@@ -2645,56 +2783,9 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                                else
                                        goto exit_frame;
                        }
-
-                       MonoType *rtype = rmethod->rtype;
-                       switch (rtype->type) {
-                       case MONO_TYPE_VOID:
-                       case MONO_TYPE_OBJECT:
-                       case MONO_TYPE_STRING:
-                       case MONO_TYPE_CLASS:
-                       case MONO_TYPE_ARRAY:
-                       case MONO_TYPE_SZARRAY:
-                       case MONO_TYPE_I:
-                       case MONO_TYPE_U:
-                               sp->data.p = *(gpointer*)res_buf;
-                               break;
-                       case MONO_TYPE_I1:
-                               sp->data.i = *(gint8*)res_buf;
-                               break;
-                       case MONO_TYPE_U1:
-                               sp->data.i = *(guint8*)res_buf;
-                               break;
-                       case MONO_TYPE_I2:
-                               sp->data.i = *(gint16*)res_buf;
-                               break;
-                       case MONO_TYPE_U2:
-                               sp->data.i = *(guint16*)res_buf;
-                               break;
-                       case MONO_TYPE_I4:
-                               sp->data.i = *(gint32*)res_buf;
-                               break;
-                       case MONO_TYPE_U4:
-                               sp->data.i = *(guint32*)res_buf;
-                               break;
-                       case MONO_TYPE_VALUETYPE:
-                               /* The result was written to vt_sp */
-                               sp->data.p = vt_sp;
-                               break;
-                       case MONO_TYPE_GENERICINST:
-                               if (MONO_TYPE_IS_REFERENCE (rtype)) {
-                                       sp->data.p = *(gpointer*)res_buf;
-                               } else {
-                                       /* The result was written to vt_sp */
-                                       sp->data.p = vt_sp;
-                               }
-                               break;
-                       default:
-                               printf ("%s\n", mono_type_full_name (rtype));
-                               g_assert_not_reached ();
-                               break;
-                       }
-                       if (rtype->type != MONO_TYPE_VOID)
+                       if (rmethod->rtype->type != MONO_TYPE_VOID)
                                sp++;
+
                        MINT_IN_BREAK;
                }
 
@@ -2717,7 +2808,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        this_arg = sp->data.p;
                        if (!this_arg)
                                THROW_EX (mono_get_exception_null_reference(), ip - 2);
-                       child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
+                       child_frame.runtime_method = get_virtual_method (child_frame.runtime_method, this_arg);
 
                        MonoClass *this_class = this_arg->vtable->klass;
                        if (this_class->valuetype && child_frame.runtime_method->method->klass->valuetype) {
@@ -2772,7 +2863,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        this_arg = sp->data.p;
                        if (!this_arg)
                                THROW_EX (mono_get_exception_null_reference(), ip - 2);
-                       child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
+                       child_frame.runtime_method = get_virtual_method (child_frame.runtime_method, this_arg);
 
                        MonoClass *this_class = this_arg->vtable->klass;
                        if (this_class->valuetype && child_frame.runtime_method->method->klass->valuetype) {
@@ -2819,7 +2910,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        goto exit_frame;
                MINT_IN_CASE(MINT_RET_VOID)
                        if (sp > frame->stack)
-                               g_warning ("ret.void: more values on stack: %d", sp-frame->stack);
+                               g_warning ("ret.void: more values on stack: %d %s", sp-frame->stack, mono_method_full_name (frame->runtime_method->method, TRUE));
                        goto exit_frame;
                MINT_IN_CASE(MINT_RET_VT)
                        i32 = READ32(ip + 1);
@@ -3110,7 +3201,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                                gint offset;
                                ip += 2 * (guint32)sp->data.i;
                                offset = READ32 (ip);
-                               ip = st + offset;
+                               ip = ip + offset;
                        } else {
                                ip = st;
                        }
@@ -3139,7 +3230,8 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_LDIND_I8)
                        ++ip;
-                       sp[-1].data.l = *(gint64*)sp[-1].data.p;
+                       /* memmove handles unaligned case */
+                       memmove (&sp [-1].data.l, sp [-1].data.p, sizeof (gint64));
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_LDIND_I) {
                        guint16 offset = * (guint16 *)(ip + 1);
@@ -3486,10 +3578,13 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CPOBJ) {
                        c = rtm->data_items[* (guint16 *)(ip + 1)];
-                       g_assert (c->byval_arg.type == MONO_TYPE_VALUETYPE);
+                       g_assert (c->valuetype);
                        /* if this assertion fails, we need to add a write barrier */
                        g_assert (!MONO_TYPE_IS_REFERENCE (&c->byval_arg));
-                       stackval_from_data (&c->byval_arg, &sp [-2], sp [-1].data.p, FALSE);
+                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE)
+                               stackval_from_data (&c->byval_arg, &sp [-2], sp [-1].data.p, FALSE);
+                       else
+                               stackval_from_data (&c->byval_arg, sp [-2].data.p, sp [-1].data.p, FALSE);
                        ip += 2;
                        sp -= 2;
                        MINT_IN_BREAK;
@@ -3539,7 +3634,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        if (newobj_class->parent == mono_defaults.array_class) {
                                sp -= csig->param_count;
                                child_frame.stack_args = sp;
-                               o = ves_array_create (&child_frame, context->domain, newobj_class, csig, sp);
+                               o = ves_array_create (&child_frame, rtm->domain, newobj_class, csig, sp);
                                if (child_frame.ex)
                                        THROW_EX (child_frame.ex, ip);
                                goto array_constructed;
@@ -3567,7 +3662,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context, uns
                        } else {
                                if (newobj_class != mono_defaults.string_class) {
                                        context->managed_code = 0;
-                                       o = mono_object_new_checked (context->domain, newobj_class, &error);
+                                       o = mono_object_new_checked (rtm->domain, newobj_class, &error);
                                        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                                        context->managed_code = 1;
                                        if (*mono_thread_interruption_request_flag ())
@@ -3661,6 +3756,7 @@ array_constructed:
                        frame->ex_handler = NULL;
                        if (!sp->data.p)
                                sp->data.p = mono_get_exception_null_reference ();
+
                        THROW_EX ((MonoException *)sp->data.p, ip);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_LDFLDA_UNSAFE)
@@ -3721,14 +3817,15 @@ array_constructed:
                                THROW_EX (mono_get_exception_null_reference (), ip);
                        field = rtm->data_items[* (guint16 *)(ip + 1)];
                        ip += 2;
+#ifndef DISABLE_REMOTING
                        if (mono_object_is_transparent_proxy (o)) {
                                MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
 
                                addr = mono_load_remote_field_checked (o, klass, field, &tmp, &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else {
+                       } else
+#endif
                                addr = (char*)o + field->offset;
-                       }                               
 
                        stackval_from_data (field->type, &sp [-1], addr, FALSE);
                        MINT_IN_BREAK;
@@ -3745,13 +3842,14 @@ array_constructed:
                        field = rtm->data_items[* (guint16 *)(ip + 1)];
                        i32 = READ32(ip + 2);
                        ip += 4;
+#ifndef DISABLE_REMOTING
                        if (mono_object_is_transparent_proxy (o)) {
                                MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
                                addr = mono_load_remote_field_checked (o, klass, field, &tmp, &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else {
+                       } else
+#endif
                                addr = (char*)o + field->offset;
-                       }                               
 
                        sp [-1].data.p = vt_sp;
                        memcpy(sp [-1].data.p, (char *)o + * (guint16 *)(ip + 1), i32);
@@ -3807,11 +3905,13 @@ array_constructed:
                        field = rtm->data_items[* (guint16 *)(ip + 1)];
                        ip += 2;
 
+#ifndef DISABLE_REMOTING
                        if (mono_object_is_transparent_proxy (o)) {
                                MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
                                mono_store_remote_field_checked (o, klass, field, &sp [-1].data, &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        } else
+#endif
                                stackval_to_data (field->type, &sp [-1], (char*)o + field->offset, FALSE);
 
                        sp -= 2;
@@ -3827,11 +3927,13 @@ array_constructed:
                        i32 = READ32(ip + 2);
                        ip += 4;
 
+#ifndef DISABLE_REMOTING
                        if (mono_object_is_transparent_proxy (o)) {
                                MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
                                mono_store_remote_field_checked (o, klass, field, &sp [-1].data, &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        } else
+#endif
                                memcpy((char*)o + field->offset, sp [-1].data.p, i32);
 
                        sp -= 2;
@@ -3840,14 +3942,14 @@ array_constructed:
                }
                MINT_IN_CASE(MINT_LDSFLDA) {
                        MonoClassField *field = rtm->data_items[*(guint16 *)(ip + 1)];
-                       sp->data.p = mono_class_static_field_address (context->domain, field);
+                       sp->data.p = mono_class_static_field_address (rtm->domain, field);
                        ip += 2;
                        ++sp;
                        MINT_IN_BREAK;
                }
                MINT_IN_CASE(MINT_LDSFLD) {
                        MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       gpointer addr = mono_class_static_field_address (rtm->domain, field);
                        stackval_from_data (field->type, sp, addr, FALSE);
                        ip += 2;
                        ++sp;
@@ -3855,7 +3957,7 @@ array_constructed:
                }
                MINT_IN_CASE(MINT_LDSFLD_VT) {
                        MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       gpointer addr = mono_class_static_field_address (rtm->domain, field);
                        int size = READ32 (ip + 2);
                        ip += 4;
 
@@ -3867,7 +3969,7 @@ array_constructed:
                }
                MINT_IN_CASE(MINT_STSFLD) {
                        MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       gpointer addr = mono_class_static_field_address (rtm->domain, field);
                        ip += 2;
                        --sp;
                        stackval_to_data (field->type, sp, addr, FALSE);
@@ -3875,7 +3977,7 @@ array_constructed:
                }
                MINT_IN_CASE(MINT_STSFLD_VT) {
                        MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       gpointer addr = mono_class_static_field_address (rtm->domain, field);
                        int size = READ32 (ip + 2);
                        ip += 4;
 
@@ -3953,20 +4055,20 @@ array_constructed:
 
                        if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
                                int size = mono_class_value_size (c, NULL);
-                               sp [-1 - offset].data.p = mono_value_box_checked (context->domain, c, sp [-1 - offset].data.p, &error);
+                               sp [-1 - offset].data.p = mono_value_box_checked (rtm->domain, c, sp [-1 - offset].data.p, &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                                size = (size + 7) & ~7;
                                vt_sp -= size;
                        } else {
                                stackval_to_data (&c->byval_arg, &sp [-1 - offset], (char *) &sp [-1 - offset], FALSE);
-                               sp [-1 - offset].data.p = mono_value_box_checked (context->domain, c, &sp [-1 - offset], &error);
+                               sp [-1 - offset].data.p = mono_value_box_checked (rtm->domain, c, &sp [-1 - offset], &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        }
                        ip += 3;
                        MINT_IN_BREAK;
                }
                MINT_IN_CASE(MINT_NEWARR)
-                       sp [-1].data.p = (MonoObject*) mono_array_new_checked (context->domain, rtm->data_items[*(guint16 *)(ip + 1)], sp [-1].data.i, &error);
+                       sp [-1].data.p = (MonoObject*) mono_array_new_checked (rtm->domain, rtm->data_items[*(guint16 *)(ip + 1)], sp [-1].data.i, &error);
                        if (!mono_error_ok (&error)) {
                                THROW_EX (mono_error_convert_to_exception (&error), ip);
                        }
@@ -4472,7 +4574,7 @@ array_constructed:
                        ++sp;
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_MONO_NEWOBJ)
-                       sp->data.p = mono_object_new_checked (context->domain, rtm->data_items [*(guint16 *)(ip + 1)], &error);
+                       sp->data.p = mono_object_new_checked (rtm->domain, rtm->data_items [*(guint16 *)(ip + 1)], &error);
                        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                        ip += 2;
                        sp++;
@@ -4505,14 +4607,73 @@ array_constructed:
                        MonoDomain *tls_domain = (MonoDomain *) ((gpointer (*)()) mono_tls_get_tls_getter (TLS_KEY_DOMAIN, FALSE)) ();
                        gpointer tls_jit = ((gpointer (*)()) mono_tls_get_tls_getter (TLS_KEY_DOMAIN, FALSE)) ();
 
-                       if (tls_domain != context->domain || !tls_jit)
-                               context->original_domain = mono_jit_thread_attach (context->domain);
+                       if (tls_domain != rtm->domain || !tls_jit)
+                               context->original_domain = mono_jit_thread_attach (rtm->domain);
                        MINT_IN_BREAK;
                }
                MINT_IN_CASE(MINT_MONO_JIT_DETACH)
                        ++ip;
                        mono_jit_set_domain (context->original_domain);
                        MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SDB_INTR_LOC)
+                       if (G_UNLIKELY (ss_enabled)) {
+                               static void (*ss_tramp) (void);
+
+                               if (!ss_tramp) {
+                                       void *tramp = mini_get_single_step_trampoline ();
+                                       mono_memory_barrier ();
+                                       ss_tramp = tramp;
+                               }
+
+                               /*
+                                * Make this point to the MINT_SDB_SEQ_POINT instruction which follows this since
+                                * the address of that instruction is stored as the seq point address.
+                                */
+                               frame->ip = ip + 1;
+
+                               /*
+                                * Use the same trampoline as the JIT. This ensures that
+                                * the debugger has the context for the last interpreter
+                                * native frame.
+                                */
+                               do_debugger_tramp (ss_tramp, frame);
+
+                               if (context->has_resume_state) {
+                                       if (frame == context->handler_frame)
+                                               SET_RESUME_STATE (context);
+                                       else
+                                               goto exit_frame;
+                               }
+                       }
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SDB_SEQ_POINT)
+                       /* Just a placeholder for a breakpoint */
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SDB_BREAKPOINT) {
+                       static void (*bp_tramp) (void);
+                       if (!bp_tramp) {
+                               void *tramp = mini_get_breakpoint_trampoline ();
+                               mono_memory_barrier ();
+                               bp_tramp = tramp;
+                       }
+
+                       frame->ip = ip;
+
+                       /* Use the same trampoline as the JIT */
+                       do_debugger_tramp (bp_tramp, frame);
+
+                       if (context->has_resume_state) {
+                               if (frame == context->handler_frame)
+                                       SET_RESUME_STATE (context);
+                               else
+                                       goto exit_frame;
+                       }
+
+                       ++ip;
+                       MINT_IN_BREAK;
+               }
 
 #define RELOP(datamem, op) \
        --sp; \
@@ -4611,7 +4772,7 @@ array_constructed:
                        if (!sp->data.p)
                                THROW_EX (mono_get_exception_null_reference (), ip - 2);
                                
-                       sp->data.p = get_virtual_method (context->domain, m, sp->data.p);
+                       sp->data.p = get_virtual_method (m, sp->data.p);
                        ++sp;
                        MINT_IN_BREAK;
                }
@@ -5040,6 +5201,7 @@ ves_exec_method (MonoInvocation *frame)
 {
        ThreadContext *context = mono_native_tls_get_value (thread_context_id);
        ThreadContext context_struct;
+       MonoDomain *domain = frame->runtime_method->domain;
        MonoError error;
        jmp_buf env;
 
@@ -5051,18 +5213,17 @@ ves_exec_method (MonoInvocation *frame)
        }
        if (context == NULL) {
                context = &context_struct;
-               context_struct.domain = mono_domain_get ();
                context_struct.base_frame = frame;
                context_struct.current_frame = NULL;
                context_struct.env_frame = frame;
                context_struct.current_env = &env;
                context_struct.search_for_handler = 0;
                context_struct.managed_code = 0;
-               mono_native_tls_set_value (thread_context_id, context);
+               set_context (context);
        }
        frame->ip = NULL;
        frame->parent = context->current_frame;
-       frame->runtime_method = mono_interp_get_runtime_method (context->domain, frame->method, &error);
+       frame->runtime_method = mono_interp_get_runtime_method (domain, frame->method, &error);
        mono_error_cleanup (&error); /* FIXME: don't swallow the error */
        context->managed_code = 1;
        ves_exec_method_with_context (frame, context, NULL, NULL, -1);
@@ -5076,7 +5237,7 @@ ves_exec_method (MonoInvocation *frame)
                        mono_unhandled_exception ((MonoObject*)frame->ex);
        }
        if (context->base_frame == frame)
-               mono_native_tls_set_value (thread_context_id, NULL);
+               set_context (NULL);
        else
                context->current_frame = frame->parent;
 }
@@ -5099,7 +5260,7 @@ void
 mono_interp_init ()
 {
        mono_native_tls_alloc (&thread_context_id, NULL);
-       mono_native_tls_set_value (thread_context_id, NULL);
+       set_context (NULL);
 
        mono_interp_transform_init ();
 }
@@ -5275,12 +5436,16 @@ mono_interp_regression_list (int verbose, int count, char *images [])
  *   Set the state the interpeter will continue to execute from after execution returns to the interpreter.
  */
 void
-mono_interp_set_resume_state (MonoException *ex, StackFrameInfo *frame, gpointer handler_ip)
+mono_interp_set_resume_state (MonoJitTlsData *jit_tls, MonoException *ex, MonoInterpFrameHandle interp_frame, gpointer handler_ip)
 {
-       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
+       ThreadContext *context;
+
+       g_assert (jit_tls);
+       context = jit_tls->interp_context;
+       g_assert (context);
 
        context->has_resume_state = TRUE;
-       context->handler_frame = frame->interp_frame;
+       context->handler_frame = interp_frame;
        /* This is on the stack, so it doesn't need a wbarrier */
        context->handler_frame->ex = ex;
        context->handler_ip = handler_ip;
@@ -5326,20 +5491,115 @@ mono_interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame)
 
        memset (frame, 0, sizeof (StackFrameInfo));
        /* pinvoke frames doesn't have runtime_method set */
-       while (iframe && !iframe->runtime_method)
+       while (iframe && !(iframe->runtime_method && iframe->runtime_method->code))
                iframe = iframe->parent;
        if (!iframe)
                return FALSE;
 
        frame->type = FRAME_TYPE_INTERP;
+       // FIXME:
+       frame->domain = mono_domain_get ();
        frame->interp_frame = iframe;
        frame->method = iframe->runtime_method->method;
        frame->actual_method = frame->method;
        /* This is the offset in the interpreter IR */
-       frame->native_offset = iframe->ip - iframe->runtime_method->code;
+       frame->native_offset = (guint8*)iframe->ip - (guint8*)iframe->runtime_method->code;
        frame->ji = iframe->runtime_method->jinfo;
 
        stack_iter->current = iframe->parent;
 
        return TRUE;
 }
+
+MonoJitInfo*
+mono_interp_find_jit_info (MonoDomain *domain, MonoMethod *method)
+{
+       RuntimeMethod* rtm;
+
+       rtm = lookup_runtime_method (domain, method);
+       if (rtm)
+               return rtm->jinfo;
+       else
+               return NULL;
+}
+
+void
+mono_interp_set_breakpoint (MonoJitInfo *jinfo, gpointer ip)
+{
+       guint16 *code = (guint16*)ip;
+       g_assert (*code == MINT_SDB_SEQ_POINT);
+       *code = MINT_SDB_BREAKPOINT;
+}
+
+void
+mono_interp_clear_breakpoint (MonoJitInfo *jinfo, gpointer ip)
+{
+       guint16 *code = (guint16*)ip;
+       g_assert (*code == MINT_SDB_BREAKPOINT);
+       *code = MINT_SDB_SEQ_POINT;
+}
+
+MonoJitInfo*
+mono_interp_frame_get_jit_info (MonoInterpFrameHandle frame)
+{
+       MonoInvocation *iframe = (MonoInvocation*)frame;
+
+       g_assert (iframe->runtime_method);
+       return iframe->runtime_method->jinfo;
+}
+
+gpointer
+mono_interp_frame_get_ip (MonoInterpFrameHandle frame)
+{
+       MonoInvocation *iframe = (MonoInvocation*)frame;
+
+       g_assert (iframe->runtime_method);
+       return (gpointer)iframe->ip;
+}
+
+gpointer
+mono_interp_frame_get_arg (MonoInterpFrameHandle frame, int pos)
+{
+       MonoInvocation *iframe = (MonoInvocation*)frame;
+
+       g_assert (iframe->runtime_method);
+
+       int arg_offset = iframe->runtime_method->arg_offsets [pos + (iframe->runtime_method->hasthis ? 1 : 0)];
+
+       return iframe->args + arg_offset;
+}
+
+gpointer
+mono_interp_frame_get_local (MonoInterpFrameHandle frame, int pos)
+{
+       MonoInvocation *iframe = (MonoInvocation*)frame;
+
+       g_assert (iframe->runtime_method);
+
+       return iframe->locals + iframe->runtime_method->local_offsets [pos];
+}
+
+gpointer
+mono_interp_frame_get_this (MonoInterpFrameHandle frame)
+{
+       MonoInvocation *iframe = (MonoInvocation*)frame;
+
+       g_assert (iframe->runtime_method);
+       g_assert (iframe->runtime_method->hasthis);
+
+       int arg_offset = iframe->runtime_method->arg_offsets [0];
+
+       return iframe->args + arg_offset;
+}
+
+void
+mono_interp_start_single_stepping (void)
+{
+       ss_enabled = TRUE;
+}
+
+void
+mono_interp_stop_single_stepping (void)
+{
+       ss_enabled = FALSE;
+}
index cf922507500bc16adae32d32dd1ed0ccf0283c5f..6abf93a6f0a38c900820258f6b73859f2b35d048 100644 (file)
@@ -28,6 +28,8 @@ struct _MonoInterpStackIter {
        gpointer dummy [8];
 };
 
+typedef gpointer MonoInterpFrameHandle;
+
 int
 mono_interp_regression_list (int verbose, int count, char *images []);
 
@@ -53,7 +55,7 @@ void
 interp_walk_stack_with_ctx (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data);
 
 void
-mono_interp_set_resume_state (MonoException *ex, StackFrameInfo *frame, gpointer handler_ip);
+mono_interp_set_resume_state (MonoJitTlsData *jit_tls, MonoException *ex, MonoInterpFrameHandle interp_frame, gpointer handler_ip);
 
 void
 mono_interp_run_finally (StackFrameInfo *frame, int clause_index, gpointer handler_ip);
@@ -64,4 +66,34 @@ mono_interp_frame_iter_init (MonoInterpStackIter *iter, gpointer interp_exit_dat
 gboolean
 mono_interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame);
 
+MonoJitInfo*
+mono_interp_find_jit_info (MonoDomain *domain, MonoMethod *method);
+
+void
+mono_interp_set_breakpoint (MonoJitInfo *jinfo, gpointer ip);
+
+void
+mono_interp_clear_breakpoint (MonoJitInfo *jinfo, gpointer ip);
+
+MonoJitInfo*
+mono_interp_frame_get_jit_info (MonoInterpFrameHandle frame);
+
+gpointer
+mono_interp_frame_get_ip (MonoInterpFrameHandle frame);
+
+gpointer
+mono_interp_frame_get_arg (MonoInterpFrameHandle frame, int pos);
+
+gpointer
+mono_interp_frame_get_local (MonoInterpFrameHandle frame, int pos);
+
+gpointer
+mono_interp_frame_get_this (MonoInterpFrameHandle frame);
+
+void
+mono_interp_start_single_stepping (void);
+
+void
+mono_interp_stop_single_stepping (void);
+
 #endif /* __MONO_MINI_INTERPRETER_H__ */
index e1c58ecf7a968643c8ac0ae638088dfa4f4aea01..b0fa6358c894a4ea71e3611569634a8eee56c310 100644 (file)
@@ -106,7 +106,7 @@ mono_interp_dis_mintop(const guint16 *base, const guint16 *ip)
                        if (i > 0)
                                g_print (", ");
                        offset = (gint32)READ32 (p);
-                       g_print ("IL_%04x", ip - base + 3 + 2 * sval + offset);
+                       g_print ("IL_%04x", p + offset);
                        p += 2;
                }
                g_print (")");
index 190c6647d08adef26aee2599bfc0bbe2c2be21e1..647e5838607a5b02433365592919a620f745feb6 100644 (file)
@@ -521,3 +521,6 @@ OPDEF(MINT_MONO_JIT_DETACH, "mono_jit_detach", 1, MintOpNoArgs)
 
 // FIXME: MintOp
 OPDEF(MINT_JIT_CALL, "mono_jit_call", 2, MintOpNoArgs)
+OPDEF(MINT_SDB_INTR_LOC, "sdb_intr_loc", 1, MintOpNoArgs)
+OPDEF(MINT_SDB_SEQ_POINT, "sdb_seq_point", 1, MintOpNoArgs)
+OPDEF(MINT_SDB_BREAKPOINT, "sdb_breakpoint", 1, MintOpNoArgs)
index 9354aa8737c61109ddc52c4e8e9744d18e05b506..57b50650a7bd6525d669d4616715d2470b692e0a 100644 (file)
@@ -15,6 +15,7 @@
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/tabledefs.h>
+#include <mono/metadata/seq-points-data.h>
 
 #include <mono/mini/mini.h>
 
@@ -34,6 +35,31 @@ typedef struct
        unsigned char flags;
 } StackInfo;
 
+typedef struct {
+       guint8 *ip;
+       GSList *preds;
+       GSList *seq_points;
+       SeqPoint *last_seq_point;
+
+       // This will hold a list of last sequence points of incoming basic blocks
+       SeqPoint **pred_seq_points;
+       guint num_pred_seq_points;
+} InterpBasicBlock;
+
+typedef enum {
+       RELOC_SHORT_BRANCH,
+       RELOC_LONG_BRANCH,
+       RELOC_SWITCH
+} RelocType;
+
+typedef struct {
+       RelocType type;
+       /* In the interpreter IR */
+       int offset;
+       /* In the IL code */
+       int target;
+} Reloc;
+
 typedef struct
 {
        MonoMethod *method;
@@ -45,7 +71,6 @@ typedef struct
        const unsigned char *in_start;
        int code_size;
        int *in_offsets;
-       int *forward_refs;
        StackInfo **stack_state;
        int *stack_height;
        int *vt_stack_size;
@@ -65,6 +90,14 @@ typedef struct
        void **data_items;
        GHashTable *data_hash;
        int *clause_indexes;
+       gboolean gen_sdb_seq_points;
+       GPtrArray *seq_points;
+       InterpBasicBlock **offset_to_bb;
+       InterpBasicBlock *entry_bb;
+       MonoMemPool     *mempool;
+       GList *basic_blocks;
+       GPtrArray *relocs;
+       gboolean verbose_level;
 } TransformData;
 
 #define MINT_TYPE_I1 0
@@ -150,7 +183,7 @@ grow_code (TransformData *td)
        } while (0)
 
 static void 
-handle_branch(TransformData *td, int short_op, int long_op, int offset) 
+handle_branch (TransformData *td, int short_op, int long_op, int offset)
 {
        int shorten_branch = 0;
        int target = td->ip + offset - td->il_code;
@@ -168,12 +201,20 @@ handle_branch(TransformData *td, int short_op, int long_op, int offset)
                        shorten_branch = 1;
                }
        } else {
-               int prev = td->forward_refs [target];
-               td->forward_refs [td->ip - td->il_code] = prev;
-               td->forward_refs [target] = td->ip - td->il_code;
-               offset = 0;
                if (td->header->code_size <= 25000) /* FIX to be precise somehow? */
                        shorten_branch = 1;
+
+               Reloc *reloc = mono_mempool_alloc0 (td->mempool, sizeof (Reloc));
+               if (shorten_branch) {
+                       offset = 0xffff;
+                       reloc->type = RELOC_SHORT_BRANCH;
+               } else {
+                       offset = 0xdeadbeef;
+                       reloc->type = RELOC_LONG_BRANCH;
+               }
+               reloc->offset = td->new_ip - td->new_code;
+               reloc->target = target;
+               g_ptr_array_add (td->relocs, reloc);
        }
        if (shorten_branch) {
                ADD_CODE(td, short_op);
@@ -554,11 +595,13 @@ load_local(TransformData *td, int n)
                WRITE32(td, &size);
        } else {
                g_assert (mt < MINT_TYPE_VT);
-               if (mt == MINT_TYPE_I4 && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
+               if (!td->gen_sdb_seq_points &&
+                       mt == MINT_TYPE_I4 && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
                        td->last_new_ip [0] == MINT_STLOC_I4 && td->last_new_ip [1] == offset) {
                        td->last_new_ip [0] = MINT_STLOC_NP_I4;
-               } else if (mt == MINT_TYPE_O && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
-                       td->last_new_ip [0] == MINT_STLOC_O && td->last_new_ip [1] == offset) {
+               } else if (!td->gen_sdb_seq_points &&
+                                  mt == MINT_TYPE_O && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
+                                  td->last_new_ip [0] == MINT_STLOC_O && td->last_new_ip [1] == offset) {
                        td->last_new_ip [0] = MINT_STLOC_NP_O;
                } else {
                        ADD_CODE(td, MINT_LDLOC_I1 + (mt - MINT_TYPE_I1));
@@ -696,22 +739,8 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target
                        else
                                target_method = (MonoMethod *)mono_method_get_wrapper_data (method, token);
                        csignature = mono_method_signature (target_method);
-                       if (target_method->klass == mono_defaults.string_class) {
-                               if (target_method->name [0] == 'g') {
-                                       if (strcmp (target_method->name, "get_Chars") == 0)
-                                               op = MINT_GETCHR;
-                                       else if (strcmp (target_method->name, "get_Length") == 0)
-                                               op = MINT_STRLEN;
-                               }
-                       } else if (mono_class_is_subclass_of (target_method->klass, mono_defaults.array_class, FALSE)) {
-                               if (!strcmp (target_method->name, "get_Rank")) {
-                                       op = MINT_ARRAY_RANK;
-                               } else if (!strcmp (target_method->name, "get_Length")) {
-                                       op = MINT_LDLEN;
-                               } else if (!strcmp (target_method->name, "Address")) {
-                                       op = readonly ? MINT_LDELEMA : MINT_LDELEMA_TC;
-                               }
-                       } else if (target_method && generic_context) {
+
+                       if (generic_context) {
                                csignature = mono_inflate_generic_signature (csignature, generic_context, &error);
                                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
                                target_method = mono_class_inflate_generic_method_checked (target_method, generic_context, &error);
@@ -722,6 +751,33 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target
                csignature = mono_method_signature (target_method);
        }
 
+       /* Intrinsics */
+       if (target_method) {
+               if (target_method->klass == mono_defaults.string_class) {
+                       if (target_method->name [0] == 'g') {
+                               if (strcmp (target_method->name, "get_Chars") == 0)
+                                       op = MINT_GETCHR;
+                               else if (strcmp (target_method->name, "get_Length") == 0)
+                                       op = MINT_STRLEN;
+                       }
+               } else if (mono_class_is_subclass_of (target_method->klass, mono_defaults.array_class, FALSE)) {
+                       if (!strcmp (target_method->name, "get_Rank")) {
+                               op = MINT_ARRAY_RANK;
+                       } else if (!strcmp (target_method->name, "get_Length")) {
+                               op = MINT_LDLEN;
+                       } else if (!strcmp (target_method->name, "Address")) {
+                               op = readonly ? MINT_LDELEMA : MINT_LDELEMA_TC;
+                       }
+               } else if (target_method->klass->image == mono_defaults.corlib &&
+                                  (strcmp (target_method->klass->name_space, "System.Diagnostics") == 0) &&
+                                  (strcmp (target_method->klass->name, "Debugger") == 0)) {
+                       if (!strcmp (target_method->name, "Break") && csignature->param_count == 0) {
+                               if (mini_should_insert_breakpoint (method))
+                                       op = MINT_BREAK;
+                       }
+               }
+       }
+
        if (constrained_class) {
                if (constrained_class->enumtype && !strcmp (target_method->name, "GetHashCode")) {
                        /* Use the corresponding method from the base type to avoid boxing */
@@ -793,7 +849,7 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target
                mono_class_init (target_method->klass);
 
        CHECK_STACK (td, csignature->param_count + csignature->hasthis);
-       if (!calli && (!virtual || (target_method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
+       if (!calli && op == -1 && (!virtual || (target_method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
                (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 && 
                (target_method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) == 0 &&
                !(target_method->iflags & METHOD_IMPL_ATTRIBUTE_NOINLINING)) {
@@ -802,7 +858,7 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target
 
                if (/*mono_metadata_signature_equal (method->signature, target_method->signature) */ method == target_method && *(td->ip + 5) == CEE_RET) {
                        int offset;
-                       if (mono_interp_traceopt)
+                       if (td->verbose_level)
                                g_print ("Optimize tail call of %s.%s\n", target_method->klass->name, target_method->name);
 
                        for (i = csignature->param_count - 1 + !!csignature->hasthis; i >= 0; --i)
@@ -818,7 +874,7 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target
                } else {
                        /* mheader might not exist if this is a delegate invoc, etc */
                        if (mheader && *mheader->code == CEE_RET && called_inited) {
-                               if (mono_interp_traceopt)
+                               if (td->verbose_level)
                                        g_print ("Inline (empty) call of %s.%s\n", target_method->klass->name, target_method->name);
                                for (i = 0; i < csignature->param_count; i++) {
                                        ADD_CODE (td, MINT_POP); /*FIX: vt */
@@ -926,6 +982,109 @@ interp_field_from_token (MonoMethod *method, guint32 token, MonoClass **klass, M
        return field;
 }
 
+static InterpBasicBlock*
+get_bb (TransformData *td, InterpBasicBlock *cbb, unsigned char *ip)
+{
+       int offset = ip - td->il_code;
+       InterpBasicBlock *bb = td->offset_to_bb [offset];
+
+       if (!bb) {
+               bb = mono_mempool_alloc0 (td->mempool, sizeof (InterpBasicBlock));
+               bb->ip = ip;
+               td->offset_to_bb [offset] = bb;
+
+               td->basic_blocks = g_list_append_mempool (td->mempool, td->basic_blocks, bb);
+       }
+
+       if (cbb)
+               bb->preds = g_slist_prepend_mempool (td->mempool, bb->preds, cbb);
+       return bb;
+}
+
+/*
+ * get_basic_blocks:
+ *
+ *   Compute the set of IL level basic blocks.
+ */
+static void
+get_basic_blocks (TransformData *td)
+{
+       guint8 *start = (guint8*)td->il_code;
+       guint8 *end = (guint8*)td->il_code + td->code_size;
+       guint8 *ip = start;
+       unsigned char *target;
+       int i;
+       guint cli_addr;
+       const MonoOpcode *opcode;
+       InterpBasicBlock *cbb;
+
+       td->offset_to_bb = mono_mempool_alloc0 (td->mempool, sizeof (InterpBasicBlock*) * (end - start + 1));
+       td->entry_bb = cbb = get_bb (td, NULL, start);
+
+       while (ip < end) {
+               cli_addr = ip - start;
+               td->offset_to_bb [cli_addr] = cbb;
+               i = mono_opcode_value ((const guint8 **)&ip, end);
+               opcode = &mono_opcodes [i];
+               switch (opcode->argument) {
+               case MonoInlineNone:
+                       ip++;
+                       break;
+               case MonoInlineString:
+               case MonoInlineType:
+               case MonoInlineField:
+               case MonoInlineMethod:
+               case MonoInlineTok:
+               case MonoInlineSig:
+               case MonoShortInlineR:
+               case MonoInlineI:
+                       ip += 5;
+                       break;
+               case MonoInlineVar:
+                       ip += 3;
+                       break;
+               case MonoShortInlineVar:
+               case MonoShortInlineI:
+                       ip += 2;
+                       break;
+               case MonoShortInlineBrTarget:
+                       target = start + cli_addr + 2 + (signed char)ip [1];
+                       get_bb (td, cbb, target);
+                       ip += 2;
+                       cbb = get_bb (td, cbb, ip);
+                       break;
+               case MonoInlineBrTarget:
+                       target = start + cli_addr + 5 + (gint32)read32 (ip + 1);
+                       get_bb (td, cbb, target);
+                       ip += 5;
+                       cbb = get_bb (td, cbb, ip);
+                       break;
+               case MonoInlineSwitch: {
+                       guint32 n = read32 (ip + 1);
+                       guint32 j;
+                       ip += 5;
+                       cli_addr += 5 + 4 * n;
+                       target = start + cli_addr;
+                       get_bb (td, cbb, target);
+
+                       for (j = 0; j < n; ++j) {
+                               target = start + cli_addr + (gint32)read32 (ip);
+                               get_bb (td, cbb, target);
+                               ip += 4;
+                       }
+                       cbb = get_bb (td, cbb, ip);
+                       break;
+               }
+               case MonoInlineR:
+               case MonoInlineI8:
+                       ip += 9;
+                       break;
+               default:
+                       g_assert_not_reached ();
+               }
+       }
+}
+
 static void
 interp_save_debug_info (RuntimeMethod *rtm, MonoMethodHeader *header, TransformData *td, GArray *line_numbers)
 {
@@ -940,14 +1099,26 @@ interp_save_debug_info (RuntimeMethod *rtm, MonoMethodHeader *header, TransformD
         */
 
        dinfo = g_new0 (MonoDebugMethodJitInfo, 1);
+       dinfo->num_params = rtm->param_count;
+       dinfo->params = g_new0 (MonoDebugVarInfo, dinfo->num_params);
        dinfo->num_locals = header->num_locals;
        dinfo->locals = g_new0 (MonoDebugVarInfo, header->num_locals);
        dinfo->code_start = (guint8*)rtm->code;
        dinfo->code_size = td->new_ip - td->new_code;
        dinfo->epilogue_begin = 0;
-       dinfo->has_var_info = FALSE;
+       dinfo->has_var_info = TRUE;
        dinfo->num_line_numbers = line_numbers->len;
        dinfo->line_numbers = g_new0 (MonoDebugLineNumberEntry, dinfo->num_line_numbers);
+
+       for (i = 0; i < dinfo->num_params; i++) {
+               MonoDebugVarInfo *var = &dinfo->params [i];
+               var->type = rtm->param_types [i];
+       }
+       for (i = 0; i < dinfo->num_locals; i++) {
+               MonoDebugVarInfo *var = &dinfo->locals [i];
+               var->type = header->locals [i];
+       }
+
        for (i = 0; i < dinfo->num_line_numbers; i++)
                dinfo->line_numbers [i] = g_array_index (line_numbers, MonoDebugLineNumberEntry, i);
        mono_debug_add_method (rtm->method, dinfo, mono_domain_get ());
@@ -955,13 +1126,208 @@ interp_save_debug_info (RuntimeMethod *rtm, MonoMethodHeader *header, TransformD
        mono_debug_free_method_jit_info (dinfo);
 }
 
+/* Same as the code in seq-points.c */
+static void
+insert_pred_seq_point (SeqPoint *last_sp, SeqPoint *sp, GSList **next)
+{
+       GSList *l;
+       int src_index = last_sp->next_offset;
+       int dst_index = sp->next_offset;
+
+       /* bb->in_bb might contain duplicates */
+       for (l = next [src_index]; l; l = l->next)
+               if (GPOINTER_TO_UINT (l->data) == dst_index)
+                       break;
+       if (!l)
+               next [src_index] = g_slist_append (next [src_index], GUINT_TO_POINTER (dst_index));
+}
+
+static void
+recursively_make_pred_seq_points (TransformData *td, InterpBasicBlock *bb)
+{
+       const gpointer MONO_SEQ_SEEN_LOOP = GINT_TO_POINTER(-1);
+       GSList *l;
+
+       GArray *predecessors = g_array_new (FALSE, TRUE, sizeof (gpointer));
+       GHashTable *seen = g_hash_table_new_full (g_direct_hash, NULL, NULL, NULL);
+
+       // Insert/remove sentinel into the memoize table to detect loops containing bb
+       bb->pred_seq_points = MONO_SEQ_SEEN_LOOP;
+
+       for (l = bb->preds; l; l = l->next) {
+               InterpBasicBlock *in_bb = l->data;
+
+               // This bb has the last seq point, append it and continue
+               if (in_bb->last_seq_point != NULL) {
+                       predecessors = g_array_append_val (predecessors, in_bb->last_seq_point);
+                       continue;
+               }
+
+               // We've looped or handled this before, exit early.
+               // No last sequence points to find.
+               if (in_bb->pred_seq_points == MONO_SEQ_SEEN_LOOP)
+                       continue;
+
+               // Take sequence points from incoming basic blocks
+
+               if (in_bb == td->entry_bb)
+                       continue;
+
+               if (in_bb->pred_seq_points == NULL)
+                       recursively_make_pred_seq_points (td, in_bb);
+
+               // Union sequence points with incoming bb's
+               for (int i=0; i < in_bb->num_pred_seq_points; i++) {
+                       if (!g_hash_table_lookup (seen, in_bb->pred_seq_points [i])) {
+                               g_array_append_val (predecessors, in_bb->pred_seq_points [i]);
+                               g_hash_table_insert (seen, in_bb->pred_seq_points [i], (gpointer)&MONO_SEQ_SEEN_LOOP);
+                       }
+               }
+               // predecessors = g_array_append_vals (predecessors, in_bb->pred_seq_points, in_bb->num_pred_seq_points);
+       }
+
+       g_hash_table_destroy (seen);
+
+       if (predecessors->len != 0) {
+               bb->pred_seq_points = mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint *) * predecessors->len);
+               bb->num_pred_seq_points = predecessors->len;
+
+               for (int newer = 0; newer < bb->num_pred_seq_points; newer++) {
+                       bb->pred_seq_points [newer] = g_array_index (predecessors, gpointer, newer);
+               }
+       }
+
+       g_array_free (predecessors, TRUE);
+}
+
+static void
+collect_pred_seq_points (TransformData *td, InterpBasicBlock *bb, SeqPoint *seqp, GSList **next)
+{
+       // Doesn't have a last sequence point, must find from incoming basic blocks
+       if (bb->pred_seq_points == NULL && bb != td->entry_bb)
+               recursively_make_pred_seq_points (td, bb);
+
+       for (int i = 0; i < bb->num_pred_seq_points; i++)
+               insert_pred_seq_point (bb->pred_seq_points [i], seqp, next);
+
+       return;
+}
+
+static void
+save_seq_points (TransformData *td)
+{
+       RuntimeMethod *rtm = td->rtm;
+       GByteArray *array;
+       int i, seq_info_size;
+       MonoSeqPointInfo *info;
+       MonoDomain *domain = mono_domain_get ();
+       GSList **next = NULL;
+       GList *bblist;
+
+       if (!td->gen_sdb_seq_points)
+               return;
+
+       /*
+        * For each sequence point, compute the list of sequence points immediately
+        * following it, this is needed to implement 'step over' in the debugger agent.
+        * Similar to the code in mono_save_seq_point_info ().
+        */
+       for (i = 0; i < td->seq_points->len; ++i) {
+               SeqPoint *sp = g_ptr_array_index (td->seq_points, i);
+
+               /* Store the seq point index here temporarily */
+               sp->next_offset = i;
+       }
+       next = mono_mempool_alloc0 (td->mempool, sizeof (GList*) * td->seq_points->len);
+       for (bblist = td->basic_blocks; bblist; bblist = bblist->next) {
+               InterpBasicBlock *bb = bblist->data;
+
+               GSList *bb_seq_points = g_slist_reverse (bb->seq_points);
+               SeqPoint *last = NULL;
+               for (GSList *l = bb_seq_points; l; l = l->next) {
+                       SeqPoint *sp = l->data;
+
+                       if (sp->il_offset == METHOD_ENTRY_IL_OFFSET || sp->il_offset == METHOD_EXIT_IL_OFFSET)
+                               /* Used to implement method entry/exit events */
+                               continue;
+
+                       if (last != NULL) {
+                               /* Link with the previous seq point in the same bb */
+                               next [last->next_offset] = g_slist_append_mempool (td->mempool, next [last->next_offset], GINT_TO_POINTER (sp->next_offset));
+                       } else {
+                               /* Link with the last bb in the previous bblocks */
+                               collect_pred_seq_points (td, bb, sp, next);
+                       }
+                       last = sp;
+               }
+       }
+
+       /* Serialize the seq points into a byte array */
+       array = g_byte_array_new ();
+       SeqPoint zero_seq_point = {0};
+       SeqPoint* last_seq_point = &zero_seq_point;
+       for (i = 0; i < td->seq_points->len; ++i) {
+               SeqPoint *sp = (SeqPoint*)g_ptr_array_index (td->seq_points, i);
+
+               sp->next_offset = 0;
+               if (mono_seq_point_info_add_seq_point (array, sp, last_seq_point, next [i], TRUE))
+                       last_seq_point = sp;
+       }
+
+       if (td->verbose_level) {
+               g_print ("\nSEQ POINT MAP FOR %s: \n", td->method->name);
+
+               for (i = 0; i < td->seq_points->len; ++i) {
+                       SeqPoint *sp = (SeqPoint*)g_ptr_array_index (td->seq_points, i);
+                       GSList *l;
+
+                       if (!next [i])
+                               continue;
+
+                       g_print ("\tIL0x%x[0x%0x] ->", sp->il_offset, sp->native_offset);
+                       for (l = next [i]; l; l = l->next) {
+                               int next_index = GPOINTER_TO_UINT (l->data);
+                               g_print (" IL0x%x", ((SeqPoint*)g_ptr_array_index (td->seq_points, next_index))->il_offset);
+                       }
+                       g_print ("\n");
+               }
+       }
+
+       info = mono_seq_point_info_new (array->len, TRUE, array->data, TRUE, &seq_info_size);
+       mono_jit_stats.allocated_seq_points_size += seq_info_size;
+
+       g_byte_array_free (array, TRUE);
+
+       mono_domain_lock (domain);
+       g_hash_table_insert (domain_jit_info (domain)->seq_points, rtm->method, info);
+       mono_domain_unlock (domain);
+}
+
+static void
+emit_seq_point (TransformData *td, int il_offset, InterpBasicBlock *cbb, gboolean nonempty_stack)
+{
+       SeqPoint *seqp;
+
+       seqp = mono_mempool_alloc0 (td->mempool, sizeof (SeqPoint));
+       seqp->il_offset = il_offset;
+       seqp->native_offset = (guint8*)td->new_ip - (guint8*)td->new_code;
+       if (nonempty_stack)
+               seqp->flags |= MONO_SEQ_POINT_FLAG_NONEMPTY_STACK;
+
+       ADD_CODE (td, MINT_SDB_SEQ_POINT);
+       g_ptr_array_add (td->seq_points, seqp);
+
+       cbb->seq_points = g_slist_prepend_mempool (td->mempool, cbb->seq_points, seqp);
+       cbb->last_seq_point = seqp;
+}
+
 static void
 generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, MonoGenericContext *generic_context)
 {
        MonoMethodHeader *header = mono_method_get_header (method);
        MonoMethodSignature *signature = mono_method_signature (method);
        MonoImage *image = method->klass->image;
-       MonoDomain *domain = mono_domain_get ();
+       MonoDomain *domain = rtm->domain;
        MonoClass *constrained_class = NULL;
        MonoError error;
        int offset, mt, i, i32;
@@ -976,8 +1342,20 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
        TransformData td;
        int generating_code = 1;
        GArray *line_numbers;
+       MonoDebugMethodInfo *minfo;
+       MonoBitSet *seq_point_locs = NULL;
+       MonoBitSet *seq_point_set_locs = NULL;
+       gboolean sym_seq_points = FALSE;
+       InterpBasicBlock *bb_exit = NULL;
+       static gboolean verbose_method_inited;
+       static char* verbose_method_name;
+
+       if (!verbose_method_inited) {
+               verbose_method_name = getenv ("MONO_VERBOSE_METHOD");
+               verbose_method_inited = TRUE;
+       }
 
-       memset(&td, 0, sizeof(td));
+       memset (&td, 0, sizeof(td));
        td.method = method;
        td.rtm = rtm;
        td.is_bb_start = is_bb_start;
@@ -987,8 +1365,8 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
        td.max_code_size = td.code_size;
        td.new_code = (unsigned short *)g_malloc(td.max_code_size * sizeof(gushort));
        td.new_code_end = td.new_code + td.max_code_size;
+       td.mempool = mono_mempool_new ();
        td.in_offsets = g_malloc0(header->code_size * sizeof(int));
-       td.forward_refs = g_malloc(header->code_size * sizeof(int));
        td.stack_state = g_malloc0(header->code_size * sizeof(StackInfo *));
        td.stack_height = g_malloc(header->code_size * sizeof(int));
        td.vt_stack_size = g_malloc(header->code_size * sizeof(int));
@@ -997,12 +1375,61 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
        td.data_items = NULL;
        td.data_hash = g_hash_table_new (NULL, NULL);
        td.clause_indexes = g_malloc (header->code_size * sizeof (int));
+       td.gen_sdb_seq_points = debug_options.gen_sdb_seq_points;
+       td.seq_points = g_ptr_array_new ();
+       td.relocs = g_ptr_array_new ();
+       td.verbose_level = mono_interp_traceopt;
        rtm->data_items = td.data_items;
        for (i = 0; i < header->code_size; i++) {
-               td.forward_refs [i] = -1;
                td.stack_height [i] = -1;
                td.clause_indexes [i] = -1;
        }
+
+       if (verbose_method_name) {
+               const char *name = verbose_method_name;
+
+               if ((strchr (name, '.') > name) || strchr (name, ':')) {
+                       MonoMethodDesc *desc;
+
+                       desc = mono_method_desc_new (name, TRUE);
+                       if (mono_method_desc_full_match (desc, method)) {
+                               td.verbose_level = 4;
+                       }
+                       mono_method_desc_free (desc);
+               } else {
+                       if (strcmp (method->name, name) == 0)
+                               td.verbose_level = 4;
+               }
+       }
+
+       if (td.gen_sdb_seq_points) {
+               get_basic_blocks (&td);
+
+               minfo = mono_debug_lookup_method (method);
+
+               if (minfo) {
+                       MonoSymSeqPoint *sps;
+                       int i, n_il_offsets;
+
+                       mono_debug_get_seq_points (minfo, NULL, NULL, NULL, &sps, &n_il_offsets);
+                       // FIXME: Free
+                       seq_point_locs = mono_bitset_mem_new (mono_mempool_alloc0 (td.mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0);
+                       seq_point_set_locs = mono_bitset_mem_new (mono_mempool_alloc0 (td.mempool, mono_bitset_alloc_size (header->code_size, 0)), header->code_size, 0);
+                       sym_seq_points = TRUE;
+
+                       for (i = 0; i < n_il_offsets; ++i) {
+                               if (sps [i].il_offset < header->code_size)
+                                       mono_bitset_set_fast (seq_point_locs, sps [i].il_offset);
+                       }
+                       g_free (sps);
+               } else if (!method->wrapper_type && !method->dynamic && mono_debug_image_has_debug_info (method->klass->image)) {
+                       /* Methods without line number info like auto-generated property accessors */
+                       seq_point_locs = mono_bitset_new (header->code_size, 0);
+                       seq_point_set_locs = mono_bitset_new (header->code_size, 0);
+                       sym_seq_points = TRUE;
+               }
+       }
+
        td.new_ip = td.new_code;
        td.last_new_ip = NULL;
 
@@ -1045,7 +1472,7 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
        td.ip = header->code;
        end = td.ip + header->code_size;
 
-       if (mono_interp_traceopt) {
+       if (td.verbose_level) {
                char *tmp = mono_disasm_code (NULL, method, td.ip, end);
                char *name = mono_method_full_name (method, TRUE);
                g_print ("Method %s, original code:\n", name);
@@ -1069,6 +1496,12 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                }
        }
 
+       if (sym_seq_points) {
+               InterpBasicBlock *cbb = td.offset_to_bb [0];
+               g_assert (cbb);
+               emit_seq_point (&td, METHOD_ENTRY_IL_OFFSET, cbb, FALSE);
+       }
+
        while (td.ip < end) {
                int in_offset;
 
@@ -1080,38 +1513,10 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                td.in_start = td.ip;
 
                MonoDebugLineNumberEntry lne;
-               lne.native_offset = td.new_ip - td.new_code;
-               lne.il_offset = td.ip - header->code;
+               lne.native_offset = (guint8*)td.new_ip - (guint8*)td.new_code;
+               lne.il_offset = in_offset;
                g_array_append_val (line_numbers, lne);
 
-               while (td.forward_refs [in_offset] >= 0) {
-                       int j = td.forward_refs [in_offset];
-                       int slot;
-                       td.forward_refs [in_offset] = td.forward_refs [j];
-                       if (td.in_offsets [j] < 0) {                        
-                               int old_switch_offset = -td.in_offsets [j];
-                               int new_switch_offset = td.in_offsets [old_switch_offset];
-                               int switch_case = (j - old_switch_offset - 5) / 4;
-                               int n_cases = read32 (header->code + old_switch_offset + 1);
-                               offset = (td.new_ip - td.new_code) - (new_switch_offset + 2 * n_cases + 3);
-                               slot = new_switch_offset + 3 + 2 * switch_case;
-                               td.new_code [slot] = * (unsigned short *)(&offset);
-                               td.new_code [slot + 1] = * ((unsigned short *)&offset + 1);
-                       } else {
-                               int op = td.new_code [td.in_offsets [j]];
-                               if (mono_interp_opargtype [op] == MintOpShortBranch) {
-                                       offset = (td.new_ip - td.new_code) - td.in_offsets [j];
-                                       g_assert (offset <= 32767);
-                                       slot = td.in_offsets [j] + 1;
-                                       td.new_code [slot] = offset;
-                               } else {
-                                       offset = (td.new_ip - td.new_code) - td.in_offsets [j];
-                                       slot = td.in_offsets [j] + 1;
-                                       td.new_code [slot] = * (unsigned short *)(&offset);
-                                       td.new_code [slot + 1] = * ((unsigned short *)&offset + 1);
-                               }
-                       }
-               }
                if (td.stack_height [in_offset] >= 0) {
                        g_assert (is_bb_start [in_offset]);
                        if (td.stack_height [in_offset] > 0)
@@ -1127,7 +1532,7 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                ++td.ip;
                        continue;
                }
-               if (mono_interp_traceopt > 1) {
+               if (td.verbose_level > 1) {
                        printf("IL_%04lx %s %-10s -> IL_%04lx, sp %ld, %s %-12s vt_sp %u (max %u)\n", 
                                td.ip - td.il_code,
                                td.is_bb_start [td.ip - td.il_code] == 3 ? "<>" :
@@ -1138,6 +1543,26 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                (td.sp > td.stack && (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_VT)) ? (td.sp [-1].klass == NULL ? "?" : td.sp [-1].klass->name) : "",
                                td.vt_sp, td.max_vt_sp);
                }
+
+               if (sym_seq_points && mono_bitset_test_fast (seq_point_locs, td.ip - header->code)) {
+                       InterpBasicBlock *cbb = td.offset_to_bb [td.ip - header->code];
+                       g_assert (cbb);
+
+                       /*
+                        * Make methods interruptable at the beginning, and at the targets of
+                        * backward branches.
+                        */
+                       if (in_offset == 0 || g_slist_length (cbb->preds) > 1)
+                               ADD_CODE (&td, MINT_SDB_INTR_LOC);
+
+                       emit_seq_point (&td, in_offset, cbb, FALSE);
+
+                       mono_bitset_set_fast (seq_point_set_locs, td.ip - header->code);
+               }
+
+               if (sym_seq_points)
+                       bb_exit = td.offset_to_bb [td.ip - header->code];
+
                switch (*td.ip) {
                case CEE_NOP: 
                        /* lose it */
@@ -1318,7 +1743,20 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                case CEE_CALLVIRT: /* Fall through */
                case CEE_CALLI:    /* Fall through */
                case CEE_CALL: {
+                       gboolean need_seq_point = FALSE;
+
+                       if (sym_seq_points && !mono_bitset_test_fast (seq_point_locs, td.ip + 5 - header->code))
+                               need_seq_point = TRUE;
+
                        interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset, constrained_class, readonly);
+
+                       if (need_seq_point) {
+                               InterpBasicBlock *cbb = td.offset_to_bb [td.ip - header->code];
+                               g_assert (cbb);
+
+                               emit_seq_point (&td, td.ip - header->code, cbb, TRUE);
+                       }
+
                        constrained_class = NULL;
                        readonly = FALSE;
                        break;
@@ -1337,6 +1775,13 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                g_warning ("%s.%s: CEE_RET: more values on stack: %d", td.method->klass->name, td.method->name, td.sp - td.stack);
                        if (td.vt_sp != vt_size)
                                g_error ("%s.%s: CEE_RET: value type stack: %d vs. %d", td.method->klass->name, td.method->name, td.vt_sp, vt_size);
+
+                       if (sym_seq_points) {
+                               InterpBasicBlock *cbb = td.offset_to_bb [td.ip - header->code];
+                               g_assert (cbb);
+                               emit_seq_point (&td, METHOD_EXIT_IL_OFFSET, bb_exit, FALSE);
+                       }
+
                        if (vt_size == 0)
                                SIMPLE_OP(td, signature->ret->type == MONO_TYPE_VOID ? MINT_RET_VOID : MINT_RET);
                        else {
@@ -1456,15 +1901,12 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                case CEE_SWITCH: {
                        guint32 n;
                        const unsigned char *next_ip;
-                       const unsigned char *base_ip = td.ip;
-                       unsigned short *next_new_ip;
                        ++td.ip;
                        n = read32 (td.ip);
                        ADD_CODE (&td, MINT_SWITCH);
                        WRITE32 (&td, &n);
                        td.ip += 4;
                        next_ip = td.ip + n * 4;
-                       next_new_ip = td.new_ip + n * 2;
                        --td.sp;
                        int stack_height = td.sp - td.stack;
                        for (i = 0; i < n; i++) {
@@ -1475,16 +1917,19 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                        if (stack_height > 0 && stack_height != td.stack_height [target])
                                                g_warning ("SWITCH with back branch and non-empty stack");
 #endif
-                                       target = td.in_offsets [target] - (next_new_ip - td.new_code);
+                                       target = td.in_offsets [target] - (td.new_ip - td.new_code);
                                } else {
                                        td.stack_height [target] = stack_height;
                                        td.vt_stack_size [target] = td.vt_sp;
                                        if (stack_height > 0)
                                                td.stack_state [target] = g_memdup (td.stack, stack_height * sizeof (td.stack [0]));
-                                       int prev = td.forward_refs [target];
-                                       td.forward_refs [td.ip - td.il_code] = prev;
-                                       td.forward_refs [target] = td.ip - td.il_code;
-                                       td.in_offsets [td.ip - td.il_code] = - (base_ip - td.il_code);
+
+                                       Reloc *reloc = mono_mempool_alloc0 (td.mempool, sizeof (Reloc));
+                                       reloc->type = RELOC_SWITCH;
+                                       reloc->offset = td.new_ip - td.new_code;
+                                       reloc->target = target;
+                                       g_ptr_array_add (td.relocs, reloc);
+                                       target = 0xffff;
                                }
                                WRITE32 (&td, &target);
                                td.ip += 4;
@@ -1942,12 +2387,13 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                        MonoString *s;
                        token = mono_metadata_token_index (read32 (td.ip + 1));
                        td.ip += 5;
-                       if (method->wrapper_type != MONO_WRAPPER_NONE) {
-                               s = mono_string_new_wrapper(
-                                       mono_method_get_wrapper_data (method, token));
-                       }
-                       else
+                       if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
+                               s = mono_method_get_wrapper_data (method, token);
+                       } else if (method->wrapper_type != MONO_WRAPPER_NONE) {
+                               s = mono_string_new_wrapper (mono_method_get_wrapper_data (method, token));
+                       } else {
                                s = mono_ldstr (domain, image, token);
+                       }
                        ADD_CODE(&td, MINT_LDSTR);
                        ADD_CODE(&td, get_data_item_index (&td, s));
                        PUSH_TYPE(&td, STACK_TYPE_O, mono_defaults.string_class);
@@ -2119,11 +2565,14 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
 
                        MonoClass *field_klass = mono_class_from_mono_type (field->type);
                        mt = mint_type (&field_klass->byval_arg);
+#ifndef DISABLE_REMOTING
                        if (klass->marshalbyref) {
                                g_assert (!is_static);
                                ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_LDRMFLD_VT :  MINT_LDRMFLD);
                                ADD_CODE(&td, get_data_item_index (&td, field));
-                       } else  {
+                       } else
+#endif
+                       {
                                if (is_static) {
                                        ADD_CODE (&td, MINT_POP);
                                        ADD_CODE (&td, 0);
@@ -2159,11 +2608,14 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                        mono_class_init (klass);
                        mt = mint_type(field->type);
 
+#ifndef DISABLE_REMOTING
                        if (klass->marshalbyref) {
                                g_assert (!is_static);
                                ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_STRMFLD_VT : MINT_STRMFLD);
                                ADD_CODE(&td, get_data_item_index (&td, field));
-                       } else  {
+                       } else
+#endif
+                       {
                                if (is_static) {
                                        ADD_CODE (&td, MINT_POP);
                                        ADD_CODE (&td, 1);
@@ -3237,8 +3689,7 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                ++td.ip;
                                break;
                        case CEE_UNALIGNED_:
-                               ++td.ip;
-                               /* FIX: should do something? */;
+                               td.ip += 2;
                                break;
                        case CEE_VOLATILE_:
                                ++td.ip;
@@ -3342,9 +3793,40 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                td.last_ip = td.in_start;
        }
 
-       if (mono_interp_traceopt) {
+       /* Handle relocations */
+       for (int i = 0; i < td.relocs->len; ++i) {
+               Reloc *reloc = g_ptr_array_index (td.relocs, i);
+
+               int offset = td.in_offsets [reloc->target] - reloc->offset;
+
+               switch (reloc->type) {
+               case RELOC_SHORT_BRANCH:
+                       g_assert (td.new_code [reloc->offset + 1] == 0xffff);
+                       td.new_code [reloc->offset + 1] = offset;
+                       break;
+               case RELOC_LONG_BRANCH: {
+                       guint16 *v = (guint16 *) &offset;
+                       g_assert (td.new_code [reloc->offset + 1] == 0xbeef);
+                       g_assert (td.new_code [reloc->offset + 2] == 0xdead);
+                       td.new_code [reloc->offset + 1] = *(guint16 *) v;
+                       td.new_code [reloc->offset + 2] = *(guint16 *) (v + 1);
+                       break;
+               }
+               case RELOC_SWITCH: {
+                       guint16 *v = (guint16*)&offset;
+                       td.new_code [reloc->offset] = *(guint16*)v;
+                       td.new_code [reloc->offset + 1] = *(guint16*)(v + 1);
+                       break;
+               }
+               default:
+                       g_assert_not_reached ();
+                       break;
+               }
+       }
+
+       if (td.verbose_level) {
                const guint16 *p = td.new_code;
-               printf("Runtime method: %p, VT stack size: %d\n", rtm, td.max_vt_sp);
+               printf("Runtime method: %s %p, VT stack size: %d\n", mono_method_full_name (method, TRUE), rtm, td.max_vt_sp);
                printf("Calculated stack size: %d, stated size: %d\n", td.max_stack_height, header->max_stack);
                while (p < td.new_ip) {
                        p = mono_interp_dis_mintop(td.new_code, p);
@@ -3384,6 +3866,7 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
        /* Create a MonoJitInfo for the interpreted method by creating the interpreter IR as the native code. */
        int jinfo_len = mono_jit_info_size (0, header->num_clauses, 0);
        MonoJitInfo *jinfo = (MonoJitInfo *)mono_domain_alloc0 (domain, jinfo_len);
+       jinfo->is_interp = 1;
        rtm->jinfo = jinfo;
        mono_jit_info_init (jinfo, method, (guint8*)rtm->code, code_len, 0, header->num_clauses, 0);
        for (i = 0; i < jinfo->num_clauses; ++i) {
@@ -3391,17 +3874,18 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                MonoExceptionClause *c = rtm->clauses + i;
 
                ei->flags = c->flags;
-               ei->try_start = rtm->code + c->try_offset;
-               ei->try_end = rtm->code + c->try_offset + c->try_len;
-               ei->handler_start = rtm->code + c->handler_offset;
+               ei->try_start = (guint8*)(rtm->code + c->try_offset);
+               ei->try_end = (guint8*)(rtm->code + c->try_offset + c->try_len);
+               ei->handler_start = (guint8*)(rtm->code + c->handler_offset);
                if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER || ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY) {
                } else {
                        ei->data.catch_class = c->data.catch_class;
                }
        }
 
+       save_seq_points (&td);
+
        g_free (td.in_offsets);
-       g_free (td.forward_refs);
        for (i = 0; i < header->code_size; ++i)
                g_free (td.stack_state [i]);
        g_free (td.stack_state);
@@ -3411,7 +3895,10 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
        g_free (td.stack);
        g_hash_table_destroy (td.data_hash);
        g_free (td.clause_indexes);
+       g_ptr_array_free (td.seq_points, TRUE);
        g_array_free (line_numbers, TRUE);
+       g_ptr_array_free (td.relocs, TRUE);
+       mono_mempool_destroy (td.mempool);
 }
 
 static mono_mutex_t calc_section;
@@ -3434,12 +3921,12 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
        const MonoOpcode *opcode;
        MonoMethod *m;
        MonoClass *class;
-       MonoDomain *domain = mono_domain_get ();
        unsigned char *is_bb_start;
        int in;
        MonoVTable *method_class_vt;
        int backwards;
        MonoGenericContext *generic_context = NULL;
+       MonoDomain *domain = runtime_method->domain;
 
        // g_printerr ("TRANSFORM(0x%016lx): begin %s::%s\n", mono_thread_current (), method->klass->name, method->name);
        method_class_vt = mono_class_vtable (domain, runtime_method->method->klass);
@@ -3482,7 +3969,7 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
                mono_os_mutex_lock(&calc_section);
                if (runtime_method->transformed) {
                        mono_os_mutex_unlock(&calc_section);
-                       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+                       mono_profiler_method_end_jit (method, runtime_method->jinfo, MONO_PROFILE_OK);
                        return NULL;
                }
 
@@ -3657,7 +4144,7 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
        if (runtime_method->transformed) {
                mono_os_mutex_unlock(&calc_section);
                g_free (is_bb_start);
-               mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+               mono_profiler_method_end_jit (method, runtime_method->jinfo, MONO_PROFILE_OK);
                return NULL;
        }
 
@@ -3708,7 +4195,8 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
 
        g_free (is_bb_start);
 
-       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+       // FIXME: Add a different callback ?
+       mono_profiler_method_end_jit (method, runtime_method->jinfo, MONO_PROFILE_OK);
        runtime_method->transformed = TRUE;
        mono_os_mutex_unlock(&calc_section);
 
index 401ac247e2a0569fb100aa530f9df08cb1682c03..2b66be22f182a3b0b0289899dd46a4e02fe054bb 100644 (file)
@@ -1089,16 +1089,6 @@ mono_lconv_to_r8_un (guint64 a)
 }
 #endif
 
-#if defined(__native_client_codegen__) || defined(__native_client__)
-/* When we cross-compile to Native Client we can't directly embed calls */
-/* to the math library on the host. This will use the fmod on the target*/
-double
-mono_fmod(double a, double b)
-{
-       return fmod(a, b);
-}
-#endif
-
 gpointer
 mono_helper_compile_generic_method (MonoObject *obj, MonoMethod *method, gpointer *this_arg)
 {
@@ -1458,11 +1448,15 @@ mono_generic_class_init (MonoVTable *vtable)
 }
 
 void
-ves_icall_mono_delegate_ctor (MonoObject *this_obj, MonoObject *target, gpointer addr)
+ves_icall_mono_delegate_ctor (MonoObject *this_obj_raw, MonoObject *target_raw, gpointer addr)
 {
+       HANDLE_FUNCTION_ENTER ();
        MonoError error;
+       MONO_HANDLE_DCL (MonoObject, this_obj);
+       MONO_HANDLE_DCL (MonoObject, target);
        mono_delegate_ctor (this_obj, target, addr, &error);
        mono_error_set_pending_exception (&error);
+       HANDLE_FUNCTION_RETURN ();
 }
 
 gpointer
index f605a709507ac845e886240354877a313bd91c68..ffe4342d2398168fc42fde8ef57f2e2649eaf7f9 100644 (file)
@@ -99,10 +99,6 @@ double mono_conv_to_r8_un (guint32 a);
 
 double mono_lconv_to_r8_un (guint64 a);
 
-#if defined(__native_client_codegen__) || defined(__native_client__)
-double mono_fmod(double a, double b);
-#endif
-
 gpointer mono_helper_compile_generic_method (MonoObject *obj, MonoMethod *method, gpointer *this_arg);
 
 MonoString*
index 59e713da790443c5c6201607af18213f34d1351f..302b28b69e2d7393f036a55141ac6de893df55dc 100644 (file)
@@ -54,7 +54,10 @@ typedef enum {
         * equivalent to mono_jit_set_aot_only (true) */
        MONO_AOT_MODE_FULL,
        /* Same as full, but use only llvm compiled code */
-       MONO_AOT_MODE_LLVMONLY
+       MONO_AOT_MODE_LLVMONLY,
+       /* Uses Interpreter, JIT is disabled and not allowed,
+        * equivalent to "--full-aot --interpreter" */
+       MONO_AOT_MODE_INTERP
 } MonoAotMode;
 
 MONO_API void
index f20d6790eea5bb45770d5d44fab00404aedbbbcb..6a6e11006cc0d395d8cd093cb51f6f667547cc98 100644 (file)
@@ -8,22 +8,25 @@
 
 #ifndef DISABLE_JIT
 
+#include <mono/metadata/gc-internals.h>
 #include <mono/utils/mono-memory-model.h>
 
 #include "mini.h"
 #include "ir-emit.h"
+#include "jit-icalls.h"
 
 #define MAX_INLINE_COPIES 10
+#define MAX_INLINE_COPY_SIZE 10000
 
 void 
 mini_emit_memset (MonoCompile *cfg, int destreg, int offset, int size, int val, int align)
 {
        int val_reg;
 
+       /*FIXME arbitrary hack to avoid unbound code expansion.*/
+       g_assert (size < MAX_INLINE_COPY_SIZE);
        g_assert (val == 0);
-
-       if (align == 0)
-               align = 4;
+       g_assert (align > 0);
 
        if ((size <= SIZEOF_REGISTER) && (size <= align)) {
                switch (size) {
@@ -51,39 +54,51 @@ mini_emit_memset (MonoCompile *cfg, int destreg, int offset, int size, int val,
        else
                MONO_EMIT_NEW_ICONST (cfg, val_reg, val);
 
-       if (align < 4) {
-               /* This could be optimized further if neccesary */
-               while (size >= 1) {
-                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, destreg, offset, val_reg);
-                       offset += 1;
-                       size -= 1;
-               }
-               return;
-       }       
-
-       if (!cfg->backend->no_unaligned_access && SIZEOF_REGISTER == 8) {
-               if (offset % 8) {
-                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, destreg, offset, val_reg);
-                       offset += 4;
-                       size -= 4;
-               }
+       if (align < SIZEOF_VOID_P) {
+               if (align % 2 == 1)
+                       goto set_1;
+               if (align % 4 == 2)
+                       goto set_2;
+               if (SIZEOF_VOID_P == 8 && align % 8 == 4)
+                       goto set_4;
+       }
+
+       //Unaligned offsets don't naturaly happen in the runtime, so it's ok to be conservative in how we copy
+       //We assume that input src and dest are be aligned to `align` so offset just worsen it
+       int offsets_mask = offset & 0x7; //we only care about the misalignment part
+       if (offsets_mask) {
+               if (offsets_mask % 2 == 1)
+                       goto set_1;
+               if (offsets_mask % 4 == 2)
+                       goto set_2;
+               if (SIZEOF_VOID_P == 8 && offsets_mask % 8 == 4)
+                       goto set_4;
+       }
+
+       if (SIZEOF_REGISTER == 8) {
                while (size >= 8) {
                        MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI8_MEMBASE_REG, destreg, offset, val_reg);
                        offset += 8;
                        size -= 8;
                }
-       }       
+       }
 
+set_4:
        while (size >= 4) {
                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, destreg, offset, val_reg);
                offset += 4;
                size -= 4;
        }
+
+
+set_2:
        while (size >= 2) {
                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI2_MEMBASE_REG, destreg, offset, val_reg);
                offset += 2;
                size -= 2;
        }
+
+set_1:
        while (size >= 1) {
                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, destreg, offset, val_reg);
                offset += 1;
@@ -96,25 +111,32 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so
 {
        int cur_reg;
 
-       if (align == 0)
-               align = 4;
-
        /*FIXME arbitrary hack to avoid unbound code expansion.*/
-       g_assert (size < 10000);
+       g_assert (size < MAX_INLINE_COPY_SIZE);
+       g_assert (align > 0);
+
+       if (align < SIZEOF_VOID_P) {
+               if (align == 4)
+                       goto copy_4;
+               if (align == 2)
+                       goto copy_2;
+               goto copy_1;
+       }
 
-       if (align < 4) {
-               /* This could be optimized further if neccesary */
-               while (size >= 1) {
-                       cur_reg = alloc_preg (cfg);
-                       MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, cur_reg, srcreg, soffset);
-                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, destreg, doffset, cur_reg);
-                       doffset += 1;
-                       soffset += 1;
-                       size -= 1;
-               }
+       //Unaligned offsets don't naturaly happen in the runtime, so it's ok to be conservative in how we copy
+       //We assume that input src and dest are be aligned to `align` so offset just worsen it
+       int offsets_mask = (doffset | soffset) & 0x7; //we only care about the misalignment part
+       if (offsets_mask) {
+               if (offsets_mask % 2 == 1)
+                       goto copy_1;
+               if (offsets_mask % 4 == 2)
+                       goto copy_2;
+               if (SIZEOF_VOID_P == 8 && offsets_mask % 8 == 4)
+                       goto copy_4;
        }
 
-       if (!cfg->backend->no_unaligned_access && SIZEOF_REGISTER == 8) {
+
+       if (SIZEOF_REGISTER == 8) {
                while (size >= 8) {
                        cur_reg = alloc_preg (cfg);
                        MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI8_MEMBASE, cur_reg, srcreg, soffset);
@@ -123,8 +145,9 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so
                        soffset += 8;
                        size -= 8;
                }
-       }       
+       }
 
+copy_4:
        while (size >= 4) {
                cur_reg = alloc_preg (cfg);
                MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, cur_reg, srcreg, soffset);
@@ -133,6 +156,8 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so
                soffset += 4;
                size -= 4;
        }
+
+copy_2:
        while (size >= 2) {
                cur_reg = alloc_preg (cfg);
                MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI2_MEMBASE, cur_reg, srcreg, soffset);
@@ -141,6 +166,8 @@ mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int so
                soffset += 2;
                size -= 2;
        }
+
+copy_1:
        while (size >= 1) {
                cur_reg = alloc_preg (cfg);
                MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, cur_reg, srcreg, soffset);
@@ -157,7 +184,7 @@ mini_emit_memcpy_internal (MonoCompile *cfg, MonoInst *dest, MonoInst *src, Mono
        /* FIXME: Optimize the case when src/dest is OP_LDADDR */
 
        /* We can't do copies at a smaller granule than the provided alignment */
-       if (size_ins || ((size / align > MAX_INLINE_COPIES) && !(cfg->opt & MONO_OPT_INTRINS))) {
+       if (size_ins || (size / align > MAX_INLINE_COPIES) || !(cfg->opt & MONO_OPT_INTRINS)) {
                MonoInst *iargs [3];
                iargs [0] = dest;
                iargs [1] = src;
@@ -177,7 +204,7 @@ mini_emit_memset_internal (MonoCompile *cfg, MonoInst *dest, MonoInst *value_ins
        /* FIXME: Optimize the case when dest is OP_LDADDR */
 
        /* We can't do copies at a smaller granule than the provided alignment */
-       if (value_ins || size_ins || value != 0 || ((size / align > MAX_INLINE_COPIES) && !(cfg->opt & MONO_OPT_INTRINS))) {
+       if (value_ins || size_ins || value != 0 || (size / align > MAX_INLINE_COPIES) || !(cfg->opt & MONO_OPT_INTRINS)) {
                MonoInst *iargs [3];
                iargs [0] = dest;
 
@@ -207,12 +234,232 @@ mini_emit_memset_const_size (MonoCompile *cfg, MonoInst *dest, int value, int si
        mini_emit_memset_internal (cfg, dest, NULL, value, NULL, size, align);
 }
 
+
+static void
+create_write_barrier_bitmap (MonoCompile *cfg, MonoClass *klass, unsigned *wb_bitmap, int offset)
+{
+       MonoClassField *field;
+       gpointer iter = NULL;
+
+       while ((field = mono_class_get_fields (klass, &iter))) {
+               int foffset;
+
+               if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
+                       continue;
+               foffset = klass->valuetype ? field->offset - sizeof (MonoObject): field->offset;
+               if (mini_type_is_reference (mono_field_get_type (field))) {
+                       g_assert ((foffset % SIZEOF_VOID_P) == 0);
+                       *wb_bitmap |= 1 << ((offset + foffset) / SIZEOF_VOID_P);
+               } else {
+                       MonoClass *field_class = mono_class_from_mono_type (field->type);
+                       if (field_class->has_references)
+                               create_write_barrier_bitmap (cfg, field_class, wb_bitmap, offset + foffset);
+               }
+       }
+}
+
+static gboolean
+mini_emit_wb_aware_memcpy (MonoCompile *cfg, MonoClass *klass, MonoInst *iargs[4], int size, int align)
+{
+       int dest_ptr_reg, tmp_reg, destreg, srcreg, offset;
+       unsigned need_wb = 0;
+
+       if (align == 0)
+               align = 4;
+
+       /*types with references can't have alignment smaller than sizeof(void*) */
+       if (align < SIZEOF_VOID_P)
+               return FALSE;
+
+       if (size > 5 * SIZEOF_VOID_P)
+               return FALSE;
+
+       create_write_barrier_bitmap (cfg, klass, &need_wb, 0);
+
+       destreg = iargs [0]->dreg;
+       srcreg = iargs [1]->dreg;
+       offset = 0;
+
+       dest_ptr_reg = alloc_preg (cfg);
+       tmp_reg = alloc_preg (cfg);
+
+       /*tmp = dreg*/
+       EMIT_NEW_UNALU (cfg, iargs [0], OP_MOVE, dest_ptr_reg, destreg);
+
+       while (size >= SIZEOF_VOID_P) {
+               MonoInst *load_inst;
+               MONO_INST_NEW (cfg, load_inst, OP_LOAD_MEMBASE);
+               load_inst->dreg = tmp_reg;
+               load_inst->inst_basereg = srcreg;
+               load_inst->inst_offset = offset;
+               MONO_ADD_INS (cfg->cbb, load_inst);
+
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREP_MEMBASE_REG, dest_ptr_reg, 0, tmp_reg);
+
+               if (need_wb & 0x1)
+                       mini_emit_write_barrier (cfg, iargs [0], load_inst);
+
+               offset += SIZEOF_VOID_P;
+               size -= SIZEOF_VOID_P;
+               need_wb >>= 1;
+
+               /*tmp += sizeof (void*)*/
+               if (size >= SIZEOF_VOID_P) {
+                       NEW_BIALU_IMM (cfg, iargs [0], OP_PADD_IMM, dest_ptr_reg, dest_ptr_reg, SIZEOF_VOID_P);
+                       MONO_ADD_INS (cfg->cbb, iargs [0]);
+               }
+       }
+
+       /* Those cannot be references since size < sizeof (void*) */
+       while (size >= 4) {
+               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, tmp_reg, srcreg, offset);
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, destreg, offset, tmp_reg);
+               offset += 4;
+               size -= 4;
+       }
+
+       while (size >= 2) {
+               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI2_MEMBASE, tmp_reg, srcreg, offset);
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI2_MEMBASE_REG, destreg, offset, tmp_reg);
+               offset += 2;
+               size -= 2;
+       }
+
+       while (size >= 1) {
+               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, tmp_reg, srcreg, offset);
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, destreg, offset, tmp_reg);
+               offset += 1;
+               size -= 1;
+       }
+
+       return TRUE;
+}
+
+static void
+mini_emit_memory_copy_internal (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, int explicit_align, gboolean native)
+{
+       MonoInst *iargs [4];
+       int size;
+       guint32 align = 0;
+       MonoInst *size_ins = NULL;
+       MonoInst *memcpy_ins = NULL;
+
+       g_assert (klass);
+       /*
+       Fun fact about @native. It's false that @klass will have no ref when @native is true.
+       This happens in pinvoke2. What goes is that marshal.c uses CEE_MONO_LDOBJNATIVE and pass klass.
+       The actual stuff being copied will have no refs, but @klass might.
+       This means we can't assert !(klass->has_references && native).
+       */
+
+       if (cfg->gshared)
+               klass = mono_class_from_mono_type (mini_get_underlying_type (&klass->byval_arg));
+
+       /*
+        * This check breaks with spilled vars... need to handle it during verification anyway.
+        * g_assert (klass && klass == src->klass && klass == dest->klass);
+        */
+
+       if (mini_is_gsharedvt_klass (klass)) {
+               g_assert (!native);
+               size_ins = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_VALUE_SIZE);
+               memcpy_ins = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_MEMCPY);
+       }
+
+       if (native)
+               size = mono_class_native_size (klass, &align);
+       else
+               size = mono_class_value_size (klass, &align);
+
+       if (!align)
+               align = SIZEOF_VOID_P;
+       if (explicit_align)
+               align = explicit_align;
+
+       if (mini_type_is_reference (&klass->byval_arg)) { // Refs *MUST* be naturally aligned
+               MonoInst *store, *load;
+               int dreg = alloc_ireg_ref (cfg);
+
+               NEW_LOAD_MEMBASE (cfg, load, OP_LOAD_MEMBASE, dreg, src->dreg, 0);
+               MONO_ADD_INS (cfg->cbb, load);
+
+               NEW_STORE_MEMBASE (cfg, store, OP_STORE_MEMBASE_REG, dest->dreg, 0, dreg);
+               MONO_ADD_INS (cfg->cbb, store);
+
+               mini_emit_write_barrier (cfg, dest, src);
+       } else if (cfg->gen_write_barriers && (klass->has_references || size_ins) && !native) {         /* if native is true there should be no references in the struct */
+               /* Avoid barriers when storing to the stack */
+               if (!((dest->opcode == OP_ADD_IMM && dest->sreg1 == cfg->frame_reg) ||
+                         (dest->opcode == OP_LDADDR))) {
+                       int context_used;
+
+                       iargs [0] = dest;
+                       iargs [1] = src;
+
+                       context_used = mini_class_check_context_used (cfg, klass);
+
+                       /* It's ok to intrinsify under gsharing since shared code types are layout stable. */
+                       if (!size_ins && (cfg->opt & MONO_OPT_INTRINS) && mini_emit_wb_aware_memcpy (cfg, klass, iargs, size, align)) {
+                       } else if (size_ins || align < SIZEOF_VOID_P) {
+                               if (context_used) {
+                                       iargs [2] = mini_emit_get_rgctx_klass (cfg, context_used, klass, MONO_RGCTX_INFO_KLASS);
+                               }  else {
+                                       iargs [2] = mini_emit_runtime_constant (cfg, MONO_PATCH_INFO_CLASS, klass);
+                                       if (!cfg->compile_aot)
+                                               mono_class_compute_gc_descriptor (klass);
+                               }
+                               if (size_ins)
+                                       mono_emit_jit_icall (cfg, mono_gsharedvt_value_copy, iargs);
+                               else
+                                       mono_emit_jit_icall (cfg, mono_value_copy, iargs);
+                       } else {
+                               /* We don't unroll more than 5 stores to avoid code bloat. */
+                               /*This is harmless and simplify mono_gc_get_range_copy_func */
+                               size += (SIZEOF_VOID_P - 1);
+                               size &= ~(SIZEOF_VOID_P - 1);
+
+                               EMIT_NEW_ICONST (cfg, iargs [2], size);
+                               mono_emit_jit_icall (cfg, mono_gc_get_range_copy_func (), iargs);
+                       }
+                       return;
+               }
+       }
+
+       if (size_ins) {
+               iargs [0] = dest;
+               iargs [1] = src;
+               iargs [2] = size_ins;
+               mini_emit_calli (cfg, mono_method_signature (mini_get_memcpy_method ()), iargs, memcpy_ins, NULL, NULL);
+       } else {
+               mini_emit_memcpy_const_size (cfg, dest, src, size, align);
+       }
+}
+
 MonoInst*
 mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offset, int ins_flag)
 {
        MonoInst *ins;
 
-       EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, type, src->dreg, offset);
+       if (ins_flag & MONO_INST_UNALIGNED) {
+               MonoInst *addr, *tmp_var;
+               int align;
+               int size = mono_type_size (type, &align);
+
+               if (offset) {
+                       MonoInst *add_offset;
+                       NEW_BIALU_IMM (cfg, add_offset, OP_PADD_IMM, alloc_preg (cfg), src->dreg, offset);
+                       MONO_ADD_INS (cfg->cbb, add_offset);
+                       src = add_offset;
+               }
+
+               tmp_var = mono_compile_create_var (cfg, type, OP_LOCAL);
+               EMIT_NEW_VARLOADA (cfg, addr, tmp_var, tmp_var->inst_vtype);
+
+               mini_emit_memcpy_const_size (cfg, addr, src, size, 1);
+               EMIT_NEW_TEMPLOAD (cfg, ins, tmp_var->inst_c0);
+       } else {
+               EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, type, src->dreg, offset);
+       }
        ins->flags |= ins_flag;
 
        if (ins_flag & MONO_INST_VOLATILE) {
@@ -233,6 +480,16 @@ mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoIn
                /* Volatile stores have release semantics, see 12.6.7 in Ecma 335 */
                mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_REL);
        }
+
+       if (ins_flag & MONO_INST_UNALIGNED) {
+               MonoInst *addr, *mov, *tmp_var;
+
+               tmp_var = mono_compile_create_var (cfg, type, OP_LOCAL);
+               EMIT_NEW_TEMPSTORE (cfg, mov, tmp_var->inst_c0, value);
+               EMIT_NEW_VARLOADA (cfg, addr, tmp_var, tmp_var->inst_vtype);
+               mini_emit_memory_copy_internal (cfg, dest, addr, mono_class_from_mono_type (type), 1, FALSE);
+       }
+
        /* FIXME: should check item at sp [1] is compatible with the type of the store. */
 
        EMIT_NEW_STORE_MEMBASE_TYPE (cfg, ins, type, dest->dreg, 0, value->dreg);
@@ -247,7 +504,7 @@ mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoIn
 void
 mini_emit_memory_copy_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoInst *size, int ins_flag)
 {
-       int align = SIZEOF_VOID_P;
+       int align = (ins_flag & MONO_INST_UNALIGNED) ? 1 : SIZEOF_VOID_P;
 
        /*
         * FIXME: It's unclear whether we should be emitting both the acquire
@@ -262,11 +519,9 @@ mini_emit_memory_copy_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *src, Mo
                mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_SEQ);
        }
 
-       if ((cfg->opt & MONO_OPT_INTRINS) && (size->opcode == OP_ICONST) && size->inst_c0 < 10000) {
+       if ((cfg->opt & MONO_OPT_INTRINS) && (size->opcode == OP_ICONST)) {
                mini_emit_memcpy_const_size (cfg, dest, src, size->inst_c0, align);
        } else {
-               if (cfg->verbose_level > 3)
-                       printf ("EMITING REGULAR COPY\n");
                mini_emit_memcpy_internal (cfg, dest, src, size, 0, align);
        }
 
@@ -279,7 +534,7 @@ mini_emit_memory_copy_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *src, Mo
 void
 mini_emit_memory_init_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *value, MonoInst *size, int ins_flag)
 {
-       int align = SIZEOF_VOID_P;
+       int align = (ins_flag & MONO_INST_UNALIGNED) ? 1 : SIZEOF_VOID_P;
 
        if (ins_flag & MONO_INST_VOLATILE) {
                /* Volatile stores have release semantics, see 12.6.7 in Ecma 335 */
@@ -295,4 +550,37 @@ mini_emit_memory_init_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *value,
 
 }
 
+/*
+ * If @klass is a valuetype, emit code to copy a value with source address in @src and destination address in @dest.
+ * If @klass is a ref type, copy a pointer instead.
+ */
+
+void
+mini_emit_memory_copy (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native, int ins_flag)
+{
+       int explicit_align = 0;
+       if (ins_flag & MONO_INST_UNALIGNED)
+               explicit_align = 1;
+
+       /*
+        * FIXME: It's unclear whether we should be emitting both the acquire
+        * and release barriers for cpblk. It is technically both a load and
+        * store operation, so it seems like that's the sensible thing to do.
+        *
+        * FIXME: We emit full barriers on both sides of the operation for
+        * simplicity. We should have a separate atomic memcpy method instead.
+        */
+       if (ins_flag & MONO_INST_VOLATILE) {
+               /* Volatile loads have acquire semantics, see 12.6.7 in Ecma 335 */
+               mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_SEQ);
+       }
+
+       mini_emit_memory_copy_internal (cfg, dest, src, klass, explicit_align, native);
+
+       if (ins_flag & MONO_INST_VOLATILE) {
+               /* Volatile loads have acquire semantics, see 12.6.7 in Ecma 335 */
+               mini_emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_SEQ);
+       }
+}
+
 #endif
index 0a34f582c637abdd9d565e7ee08a6305f752c2f4..0c37dc1533c5b699e6444e144b806f9f8a7dfaed 100644 (file)
@@ -2827,29 +2827,6 @@ mini_get_memcpy_method (void)
        return memcpy_method;
 }
 
-static void
-create_write_barrier_bitmap (MonoCompile *cfg, MonoClass *klass, unsigned *wb_bitmap, int offset)
-{
-       MonoClassField *field;
-       gpointer iter = NULL;
-
-       while ((field = mono_class_get_fields (klass, &iter))) {
-               int foffset;
-
-               if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
-                       continue;
-               foffset = klass->valuetype ? field->offset - sizeof (MonoObject): field->offset;
-               if (mini_type_is_reference (mono_field_get_type (field))) {
-                       g_assert ((foffset % SIZEOF_VOID_P) == 0);
-                       *wb_bitmap |= 1 << ((offset + foffset) / SIZEOF_VOID_P);
-               } else {
-                       MonoClass *field_class = mono_class_from_mono_type (field->type);
-                       if (field_class->has_references)
-                               create_write_barrier_bitmap (cfg, field_class, wb_bitmap, offset + foffset);
-               }
-       }
-}
-
 void
 mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
 {
@@ -2863,6 +2840,8 @@ mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
        if (!cfg->gen_write_barriers)
                return;
 
+       //method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER && !MONO_INS_IS_PCONST_NULL (sp [1])
+
        card_table = mono_gc_get_card_table (&card_table_shift_bits, &card_table_mask);
 
        mono_gc_get_nursery (&nursery_shift_bits, &nursery_size);
@@ -2906,177 +2885,6 @@ mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
        EMIT_NEW_DUMMY_USE (cfg, dummy_use, value);
 }
 
-gboolean
-mini_emit_wb_aware_memcpy (MonoCompile *cfg, MonoClass *klass, MonoInst *iargs[4], int size, int align)
-{
-       int dest_ptr_reg, tmp_reg, destreg, srcreg, offset;
-       unsigned need_wb = 0;
-
-       if (align == 0)
-               align = 4;
-
-       /*types with references can't have alignment smaller than sizeof(void*) */
-       if (align < SIZEOF_VOID_P)
-               return FALSE;
-
-       if (size > 5 * SIZEOF_VOID_P)
-               return FALSE;
-
-       create_write_barrier_bitmap (cfg, klass, &need_wb, 0);
-
-       destreg = iargs [0]->dreg;
-       srcreg = iargs [1]->dreg;
-       offset = 0;
-
-       dest_ptr_reg = alloc_preg (cfg);
-       tmp_reg = alloc_preg (cfg);
-
-       /*tmp = dreg*/
-       EMIT_NEW_UNALU (cfg, iargs [0], OP_MOVE, dest_ptr_reg, destreg);
-
-       while (size >= SIZEOF_VOID_P) {
-               MonoInst *load_inst;
-               MONO_INST_NEW (cfg, load_inst, OP_LOAD_MEMBASE);
-               load_inst->dreg = tmp_reg;
-               load_inst->inst_basereg = srcreg;
-               load_inst->inst_offset = offset;
-               MONO_ADD_INS (cfg->cbb, load_inst);
-
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREP_MEMBASE_REG, dest_ptr_reg, 0, tmp_reg);
-
-               if (need_wb & 0x1)
-                       mini_emit_write_barrier (cfg, iargs [0], load_inst);
-
-               offset += SIZEOF_VOID_P;
-               size -= SIZEOF_VOID_P;
-               need_wb >>= 1;
-
-               /*tmp += sizeof (void*)*/
-               if (size >= SIZEOF_VOID_P) {
-                       NEW_BIALU_IMM (cfg, iargs [0], OP_PADD_IMM, dest_ptr_reg, dest_ptr_reg, SIZEOF_VOID_P);
-                       MONO_ADD_INS (cfg->cbb, iargs [0]);
-               }
-       }
-
-       /* Those cannot be references since size < sizeof (void*) */
-       while (size >= 4) {
-               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, tmp_reg, srcreg, offset);
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, destreg, offset, tmp_reg);
-               offset += 4;
-               size -= 4;
-       }
-
-       while (size >= 2) {
-               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI2_MEMBASE, tmp_reg, srcreg, offset);
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI2_MEMBASE_REG, destreg, offset, tmp_reg);
-               offset += 2;
-               size -= 2;
-       }
-
-       while (size >= 1) {
-               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, tmp_reg, srcreg, offset);
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, destreg, offset, tmp_reg);
-               offset += 1;
-               size -= 1;
-       }
-
-       return TRUE;
-}
-
-/*
- * Emit code to copy a valuetype of type @klass whose address is stored in
- * @src->dreg to memory whose address is stored at @dest->dreg.
- */
-void
-mini_emit_stobj (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native)
-{
-       MonoInst *iargs [4];
-       int n;
-       guint32 align = 0;
-       MonoMethod *memcpy_method;
-       MonoInst *size_ins = NULL;
-       MonoInst *memcpy_ins = NULL;
-
-       g_assert (klass);
-       if (cfg->gshared)
-               klass = mono_class_from_mono_type (mini_get_underlying_type (&klass->byval_arg));
-
-       /*
-        * This check breaks with spilled vars... need to handle it during verification anyway.
-        * g_assert (klass && klass == src->klass && klass == dest->klass);
-        */
-
-       if (mini_is_gsharedvt_klass (klass)) {
-               g_assert (!native);
-               size_ins = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_VALUE_SIZE);
-               memcpy_ins = mini_emit_get_gsharedvt_info_klass (cfg, klass, MONO_RGCTX_INFO_MEMCPY);
-       }
-
-       if (native)
-               n = mono_class_native_size (klass, &align);
-       else
-               n = mono_class_value_size (klass, &align);
-
-       if (!align)
-               align = SIZEOF_VOID_P;
-       /* if native is true there should be no references in the struct */
-       if (cfg->gen_write_barriers && (klass->has_references || size_ins) && !native) {
-               /* Avoid barriers when storing to the stack */
-               if (!((dest->opcode == OP_ADD_IMM && dest->sreg1 == cfg->frame_reg) ||
-                         (dest->opcode == OP_LDADDR))) {
-                       int context_used;
-
-                       iargs [0] = dest;
-                       iargs [1] = src;
-
-                       context_used = mini_class_check_context_used (cfg, klass);
-
-                       /* It's ok to intrinsify under gsharing since shared code types are layout stable. */
-                       if (!size_ins && (cfg->opt & MONO_OPT_INTRINS) && mini_emit_wb_aware_memcpy (cfg, klass, iargs, n, align)) {
-                               return;
-                       } else if (size_ins || align < SIZEOF_VOID_P) {
-                               if (context_used) {
-                                       iargs [2] = mini_emit_get_rgctx_klass (cfg, context_used, klass, MONO_RGCTX_INFO_KLASS);
-                               }  else {
-                                       iargs [2] = mini_emit_runtime_constant (cfg, MONO_PATCH_INFO_CLASS, klass);
-                                       if (!cfg->compile_aot)
-                                               mono_class_compute_gc_descriptor (klass);
-                               }
-                               if (size_ins)
-                                       mono_emit_jit_icall (cfg, mono_gsharedvt_value_copy, iargs);
-                               else
-                                       mono_emit_jit_icall (cfg, mono_value_copy, iargs);
-                       } else {
-                               /* We don't unroll more than 5 stores to avoid code bloat. */
-                               /*This is harmless and simplify mono_gc_get_range_copy_func */
-                               n += (SIZEOF_VOID_P - 1);
-                               n &= ~(SIZEOF_VOID_P - 1);
-
-                               EMIT_NEW_ICONST (cfg, iargs [2], n);
-                               mono_emit_jit_icall (cfg, mono_gc_get_range_copy_func (), iargs);
-                       }
-               }
-       }
-
-       if (!size_ins && (cfg->opt & MONO_OPT_INTRINS) && n <= sizeof (gpointer) * 8) {
-               /* FIXME: Optimize the case when src/dest is OP_LDADDR */
-               mini_emit_memcpy (cfg, dest->dreg, 0, src->dreg, 0, n, align);
-       } else {
-               iargs [0] = dest;
-               iargs [1] = src;
-               if (size_ins)
-                       iargs [2] = size_ins;
-               else
-                       EMIT_NEW_ICONST (cfg, iargs [2], n);
-               
-               memcpy_method = mini_get_memcpy_method ();
-               if (memcpy_ins)
-                       mini_emit_calli (cfg, mono_method_signature (memcpy_method), iargs, memcpy_ins, NULL, NULL);
-               else
-                       mono_emit_method_call (cfg, memcpy_method, iargs, NULL);
-       }
-}
-
 MonoMethod*
 mini_get_memset_method (void)
 {
@@ -4763,54 +4571,6 @@ mini_emit_ldelema_ins (MonoCompile *cfg, MonoMethod *cmethod, MonoInst **sp, uns
        return addr;
 }
 
-static MonoBreakPolicy
-always_insert_breakpoint (MonoMethod *method)
-{
-       return MONO_BREAK_POLICY_ALWAYS;
-}
-
-static MonoBreakPolicyFunc break_policy_func = always_insert_breakpoint;
-
-/**
- * mono_set_break_policy:
- * \param policy_callback the new callback function
- *
- * Allow embedders to decide wherther to actually obey breakpoint instructions
- * (both break IL instructions and \c Debugger.Break method calls), for example
- * to not allow an app to be aborted by a perfectly valid IL opcode when executing
- * untrusted or semi-trusted code.
- *
- * \p policy_callback will be called every time a break point instruction needs to
- * be inserted with the method argument being the method that calls \c Debugger.Break
- * or has the IL \c break instruction. The callback should return \c MONO_BREAK_POLICY_NEVER
- * if it wants the breakpoint to not be effective in the given method.
- * \c MONO_BREAK_POLICY_ALWAYS is the default.
- */
-void
-mono_set_break_policy (MonoBreakPolicyFunc policy_callback)
-{
-       if (policy_callback)
-               break_policy_func = policy_callback;
-       else
-               break_policy_func = always_insert_breakpoint;
-}
-
-static gboolean
-should_insert_brekpoint (MonoMethod *method) {
-       switch (break_policy_func (method)) {
-       case MONO_BREAK_POLICY_ALWAYS:
-               return TRUE;
-       case MONO_BREAK_POLICY_NEVER:
-               return FALSE;
-       case MONO_BREAK_POLICY_ON_DBG:
-               g_warning ("mdb no longer supported");
-               return FALSE;
-       default:
-               g_warning ("Incorrect value returned from break policy callback");
-               return FALSE;
-       }
-}
-
 /* optimize the simple GetGenericValueImpl/SetGenericValueImpl generic icalls */
 static MonoInst*
 emit_array_generic_access (MonoCompile *cfg, MonoMethodSignature *fsig, MonoInst **args, int is_set)
@@ -5114,6 +4874,31 @@ mini_emit_inst_for_sharable_method (MonoCompile *cfg, MonoMethod *cmethod, MonoM
        return NULL;
 }
 
+
+static gboolean
+mono_type_is_native_blittable (MonoType *t)
+{
+       if (MONO_TYPE_IS_REFERENCE (t))
+               return FALSE;
+
+       if (MONO_TYPE_IS_PRIMITIVE_SCALAR (t))
+               return TRUE;
+
+       MonoClass *klass = mono_class_from_mono_type (t);
+
+       //MonoClass::blitable depends on mono_class_setup_fields being done.
+       mono_class_setup_fields (klass);
+       if (!klass->blittable)
+               return FALSE;
+
+       // If the native marshal size is different we can't convert PtrToStructure to a type load
+       if (mono_class_native_size (klass, NULL) != mono_class_value_size (klass, NULL))
+               return FALSE;
+
+       return TRUE;
+}
+
+
 static MonoInst*
 mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args)
 {
@@ -5930,7 +5715,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                           (strcmp (cmethod->klass->name_space, "System.Diagnostics") == 0) &&
                           (strcmp (cmethod->klass->name, "Debugger") == 0)) {
                if (!strcmp (cmethod->name, "Break") && fsig->param_count == 0) {
-                       if (should_insert_brekpoint (cfg->method)) {
+                       if (mini_should_insert_breakpoint (cfg->method)) {
                                ins = mono_emit_jit_icall (cfg, mono_debugger_agent_user_break, NULL);
                        } else {
                                MONO_INST_NEW (cfg, ins, OP_NOP);
@@ -6029,6 +5814,20 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        MONO_ADD_INS (cfg->cbb, ins);
                        return ins;
                }
+       } else if (cmethod->klass->image == mono_defaults.corlib &&
+                       (strcmp (cmethod->klass->name_space, "System.Runtime.InteropServices") == 0) &&
+                       (strcmp (cmethod->klass->name, "Marshal") == 0)) {
+               //Convert Marshal.PtrToStructure<T> of blittable T to direct loads
+               if (strcmp (cmethod->name, "PtrToStructure") == 0 &&
+                               cmethod->is_inflated &&
+                               fsig->param_count == 1 &&
+                               !mini_method_check_context_used (cfg, cmethod)) {
+
+                       MonoGenericContext *method_context = mono_method_get_context (cmethod);
+                       MonoType *arg0 = method_context->method_inst->type_argv [0];
+                       if (mono_type_is_native_blittable (arg0))
+                               return mini_emit_memory_load (cfg, arg0, args [0], 0, 0);
+               }
        }
 
 #ifdef MONO_ARCH_SIMD_INTRINSICS
@@ -6646,27 +6445,6 @@ mini_get_method (MonoCompile *cfg, MonoMethod *m, guint32 token, MonoClass *klas
        return method;
 }
 
-MonoClass*
-mini_get_class (MonoMethod *method, guint32 token, MonoGenericContext *context)
-{
-       MonoError error;
-       MonoClass *klass;
-
-       if (method->wrapper_type != MONO_WRAPPER_NONE) {
-               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-               if (context) {
-                       klass = mono_class_inflate_generic_class_checked (klass, context, &error);
-                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
-               }
-       } else {
-               klass = mono_class_get_and_inflate_typespec_checked (method->klass->image, token, context, &error);
-               mono_error_cleanup (&error); /* FIXME don't swallow the error */
-       }
-       if (klass)
-               mono_class_init (klass);
-       return klass;
-}
-
 static inline MonoMethodSignature*
 mini_get_signature (MonoMethod *method, guint32 token, MonoGenericContext *context, MonoError *error)
 {
@@ -7958,7 +7736,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        MONO_ADD_INS (cfg->cbb, ins);
                        break;
                case CEE_BREAK:
-                       if (should_insert_brekpoint (cfg->method)) {
+                       if (mini_should_insert_breakpoint (cfg->method)) {
                                ins = mono_emit_jit_icall (cfg, mono_debugger_agent_user_break, NULL);
                        } else {
                                MONO_INST_NEW (cfg, ins, OP_NOP);
@@ -9853,23 +9631,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        klass = mini_get_class (method, token, generic_context);
                        CHECK_TYPELOAD (klass);
                        sp -= 2;
-                       if (generic_class_is_reference_type (cfg, klass)) {
-                               MonoInst *store, *load;
-                               int dreg = alloc_ireg_ref (cfg);
-
-                               NEW_LOAD_MEMBASE (cfg, load, OP_LOAD_MEMBASE, dreg, sp [1]->dreg, 0);
-                               load->flags |= ins_flag;
-                               MONO_ADD_INS (cfg->cbb, load);
-
-                               NEW_STORE_MEMBASE (cfg, store, OP_STORE_MEMBASE_REG, sp [0]->dreg, 0, dreg);
-                               store->flags |= ins_flag;
-                               MONO_ADD_INS (cfg->cbb, store);
-
-                               if (cfg->gen_write_barriers && cfg->method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER)
-                                       mini_emit_write_barrier (cfg, sp [0], sp [1]);
-                       } else {
-                               mini_emit_stobj (cfg, sp [0], sp [1], klass, FALSE);
-                       }
+                       mini_emit_memory_copy (cfg, sp [0], sp [1], klass, FALSE, ins_flag);
                        ins_flag = 0;
                        ip += 5;
                        break;
@@ -9918,14 +9680,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        }
 
                        /* Optimize the ldobj+stobj combination */
-                       /* The reference case ends up being a load+store anyway */
-                       /* Skip this if the operation is volatile. */
-                       if (((ip [5] == CEE_STOBJ) && ip_in_bb (cfg, cfg->cbb, ip + 5) && read32 (ip + 6) == token) && !generic_class_is_reference_type (cfg, klass) && !(ins_flag & MONO_INST_VOLATILE)) {
+                       if (((ip [5] == CEE_STOBJ) && ip_in_bb (cfg, cfg->cbb, ip + 5) && read32 (ip + 6) == token)) {
                                CHECK_STACK (1);
 
                                sp --;
 
-                               mini_emit_stobj (cfg, sp [0], sp [1], klass, FALSE);
+                               mini_emit_memory_copy (cfg, sp [0], sp [1], klass, FALSE, ins_flag);
 
                                ip += 5 + 5;
                                ins_flag = 0;
@@ -10596,7 +10356,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                                dreg = alloc_ireg_mp (cfg);
                                                EMIT_NEW_BIALU (cfg, ins, OP_PADD, dreg, sp [0]->dreg, offset_ins->dreg);
                                                wbarrier_ptr_ins = ins;
-                                               /* The decomposition will call mini_emit_stobj () which will emit a wbarrier if needed */
+                                               /* The decomposition will call mini_emit_memory_copy () which will emit a wbarrier if needed */
                                                EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, field->type, dreg, 0, sp [1]->dreg);
                                        } else {
                                                EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, field->type, sp [0]->dreg, foffset, sp [1]->dreg);
@@ -11857,7 +11617,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        temp = mono_compile_create_var (cfg, &klass->byval_arg, OP_LOCAL);
                                        temp->backend.is_pinvoke = 1;
                                        EMIT_NEW_TEMPLOADA (cfg, dest, temp->inst_c0);
-                                       mini_emit_stobj (cfg, dest, src, klass, TRUE);
+                                       mini_emit_memory_copy (cfg, dest, src, klass, TRUE, 0);
 
                                        EMIT_NEW_TEMPLOAD (cfg, dest, temp->inst_c0);
                                        dest->type = STACK_VTYPE;
@@ -11888,7 +11648,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                } else {
                                        EMIT_NEW_RETLOADA (cfg, ins);
                                }
-                               mini_emit_stobj (cfg, ins, sp [0], klass, TRUE);
+                               mini_emit_memory_copy (cfg, ins, sp [0], klass, TRUE, 0);
                                
                                if (sp != stack_start)
                                        UNVERIFIED;
@@ -14406,11 +14166,4 @@ NOTES
   the values on the stack before emitting the last instruction of the bb.
 */
 
-#else /* !DISABLE_JIT */
-
-void
-mono_set_break_policy (MonoBreakPolicyFunc policy_callback)
-{
-}
-
 #endif /* !DISABLE_JIT */
index 2978af64ecb07220ee87c0e7a8af7afb8f30c7f7..60bbd6807498d948f2a1b24ace680e6064e99e95 100644 (file)
@@ -3229,7 +3229,7 @@ mono_emit_stack_alloc (MonoCompile *cfg, guchar *code, MonoInst* tree)
 #if defined(TARGET_WIN32)
        need_touch = TRUE;
 #elif defined(MONO_ARCH_SIGSEGV_ON_ALTSTACK)
-       if (!tree->flags & MONO_INST_INIT)
+       if (!(tree->flags & MONO_INST_INIT))
                need_touch = TRUE;
 #endif
 
index 96c7d3a6adf2743440a7ef17e0a3a48ccba1b0ef..9f2be7efacc50d72195d484bcfcafa460ac77e44 100644 (file)
@@ -323,7 +323,7 @@ mono_arm_patchable_bl (guint8 *code, int cond)
        return code;
 }
 
-#if defined(__ARM_EABI__) && defined(__linux__) && !defined(PLATFORM_ANDROID) && !defined(__native_client__)
+#if defined(__ARM_EABI__) && defined(__linux__) && !defined(PLATFORM_ANDROID) && !defined(MONO_CROSS_COMPILE)
 #define HAVE_AEABI_READ_TP 1
 #endif
 
@@ -337,7 +337,6 @@ mono_arch_have_fast_tls (void)
 #ifdef HAVE_AEABI_READ_TP
        static gboolean have_fast_tls = FALSE;
         static gboolean inited = FALSE;
-       gpointer tp1, tp2;
 
        if (mini_get_debug_options ()->use_fallback_tls)
                return FALSE;
@@ -345,10 +344,14 @@ mono_arch_have_fast_tls (void)
        if (inited)
                return have_fast_tls;
 
-       tp1 = __aeabi_read_tp ();
-       asm volatile("mrc p15, 0, %0, c13, c0, 3" : "=r" (tp2));
+       if (v7_supported) {
+               gpointer tp1, tp2;
 
-       have_fast_tls = tp1 && tp1 == tp2;
+               tp1 = __aeabi_read_tp ();
+               asm volatile("mrc p15, 0, %0, c13, c0, 3" : "=r" (tp2));
+
+               have_fast_tls = tp1 && tp1 == tp2;
+       }
        inited = TRUE;
        return have_fast_tls;
 #else
@@ -359,6 +362,7 @@ mono_arch_have_fast_tls (void)
 static guint8*
 emit_tls_get (guint8 *code, int dreg, int tls_offset)
 {
+       g_assert (v7_supported);
        ARM_MRC (code, 15, 0, dreg, 13, 0, 3);
        ARM_LDR_IMM (code, dreg, dreg, tls_offset);
        return code;
@@ -368,6 +372,7 @@ static guint8*
 emit_tls_set (guint8 *code, int sreg, int tls_offset)
 {
        int tp_reg = (sreg != ARMREG_R0) ? ARMREG_R0 : ARMREG_R1;
+       g_assert (v7_supported);
        ARM_MRC (code, 15, 0, tp_reg, 13, 0, 3);
        ARM_STR_IMM (code, sreg, tp_reg, tls_offset);
        return code;
index 671014199b8be525e33d87a860309975b9e4df74..2e8914c395c6160462754e6c8c34155e31eb9079 100644 (file)
@@ -329,7 +329,7 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_DYN_CALL_SUPPORTED 1
 #define MONO_ARCH_DYN_CALL_PARAM_AREA (DYN_CALL_STACK_ARGS * sizeof (mgreg_t))
 
-#ifndef MONO_CROSS_COMPILE
+#if !(defined(TARGET_ANDROID) && defined(MONO_CROSS_COMPILE))
 #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
 #endif
 
index 65fd99f10506390cd425012bd357e59114507af2..7a189792a2c5d0e6a2f08655e1df538723950856 100644 (file)
@@ -995,7 +995,7 @@ mono_arch_patch_code_new (MonoCompile *cfg, MonoDomain *domain, guint8 *code, Mo
        switch (ji->type) {
        case MONO_PATCH_INFO_METHOD_JUMP:
                /* ji->relocation is not set by the caller */
-               arm_patch_rel (ip, (guint8*)target, MONO_R_ARM64_B);
+               arm_patch_full (cfg, domain, ip, (guint8*)target, MONO_R_ARM64_B);
                break;
        default:
                arm_patch_full (cfg, domain, ip, (guint8*)target, ji->relocation);
@@ -4138,6 +4138,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        } else {
                                mono_add_patch_info_rel (cfg, code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call->method, MONO_R_ARM64_B);
                                arm_b (code, code);
+                               cfg->thunk_area += THUNK_SIZE;
                        }
                        ins->flags |= MONO_INST_GC_CALLSITE;
                        ins->backend.pc_offset = code - cfg->native_code;
index 8aeb6ffb2f48e88b4a227ad352ad2b78a995d54c..e4cb111cc38994bdd1b10b5b9b7a1ac7bb93bb4c 100644 (file)
@@ -9,6 +9,9 @@
 #include "config.h"
 
 #include "mini.h"
+#ifdef ENABLE_INTERPRETER
+#include "interp/interp.h"
+#endif
 #include "tasklets.h"
 #include <mono/metadata/abi-details.h>
 
index b6b1d813399f21e758c9ff90188d8b3f9ddf139e..b1132f9f26176d6de99e1939b646e2c3ab9e4662 100644 (file)
 #define MONO_ARCH_STACK_GROWS_UP 0
 #endif
 
+/*
+ * Raw frame information is stored in MonoException.trace_ips as an IntPtr[].
+ * This structure represents one entry.
+ * This should consists of pointers only.
+ */
+typedef struct
+{
+       gpointer ip;
+       gpointer generic_info;
+}  ExceptionTraceIp;
+
+/* Number of words in trace_ips belonging to one entry */
+#define TRACE_IP_ENTRY_SIZE (sizeof (ExceptionTraceIp) / sizeof (gpointer))
+
 static gpointer restore_context_func, call_filter_func;
 static gpointer throw_exception_func, rethrow_exception_func;
 static gpointer throw_corlib_exception_func;
@@ -830,10 +844,13 @@ mono_exception_walk_trace (MonoException *ex, MonoExceptionFrameWalk func, gpoin
        if (ta == NULL)
                return FALSE;
 
-       len = mono_array_length (ta) >> 1;
+       len = mono_array_length (ta) / TRACE_IP_ENTRY_SIZE;
        for (i = 0; i < len; i++) {
-               gpointer ip = mono_array_get (ta, gpointer, i * 2 + 0);
-               gpointer generic_info = mono_array_get (ta, gpointer, i * 2 + 1);
+               ExceptionTraceIp trace_ip;
+
+               memcpy (&trace_ip, mono_array_addr_fast (ta, ExceptionTraceIp, i), sizeof (ExceptionTraceIp));
+               gpointer ip = trace_ip.ip;
+               gpointer generic_info = trace_ip.generic_info;
                MonoJitInfo *ji = mono_jit_info_table_find (domain, (char *)ip);
 
                if (ji == NULL) {
@@ -866,7 +883,7 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
                return res;
        }
 
-       len = mono_array_length (ta) >> 1;
+       len = mono_array_length (ta) / TRACE_IP_ENTRY_SIZE;
 
        res = mono_array_new_checked (domain, mono_defaults.stack_frame_class, len > skip ? len - skip : 0, &error);
        if (mono_error_set_pending_exception (&error))
@@ -879,8 +896,10 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
                        mono_error_set_pending_exception (&error);
                        return NULL;
                }
-               gpointer ip = mono_array_get (ta, gpointer, i * 2 + 0);
-               gpointer generic_info = mono_array_get (ta, gpointer, i * 2 + 1);
+               ExceptionTraceIp trace_ip;
+               memcpy (&trace_ip, mono_array_addr_fast (ta, ExceptionTraceIp, i), sizeof (ExceptionTraceIp));
+               gpointer ip = trace_ip.ip;
+               gpointer generic_info = trace_ip.generic_info;
                MonoMethod *method;
 
                ji = mono_jit_info_table_find (domain, (char *)ip);
@@ -1070,6 +1089,7 @@ mono_walk_stack_full (MonoJitStackWalk func, MonoContext *start_ctx, MonoDomain
        mgreg_t *new_reg_locations [MONO_MAX_IREGS];
        gboolean get_reg_locations = unwind_options & MONO_UNWIND_REG_LOCATIONS;
        gboolean async = mono_thread_info_is_async_context ();
+       Unwinder unwinder;
 
        if (mono_llvm_only) {
                GSList *l, *ips;
@@ -1114,9 +1134,11 @@ mono_walk_stack_full (MonoJitStackWalk func, MonoContext *start_ctx, MonoDomain
        memcpy (&ctx, start_ctx, sizeof (MonoContext));
        memset (reg_locations, 0, sizeof (reg_locations));
 
+       unwinder_init (&unwinder);
+
        while (MONO_CONTEXT_GET_SP (&ctx) < jit_tls->end_of_stack) {
                frame.lmf = lmf;
-               res = mono_find_jit_info_ext (domain, jit_tls, NULL, &ctx, &new_ctx, NULL, &lmf, get_reg_locations ? new_reg_locations : NULL, &frame);
+               res = unwinder_unwind_frame (&unwinder, domain, jit_tls, NULL, &ctx, &new_ctx, NULL, &lmf, get_reg_locations ? new_reg_locations : NULL, &frame);
                if (!res)
                        return;
 
@@ -1563,13 +1585,13 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, MonoObject *obj, gi
        mono_ex = (MonoException*)obj;
        MonoArray *initial_trace_ips = mono_ex->trace_ips;
        if (initial_trace_ips) {
-               int len = mono_array_length (initial_trace_ips) >> 1;
+               int len = mono_array_length (initial_trace_ips) / TRACE_IP_ENTRY_SIZE;
 
                for (i = 0; i < (len - 1); i++) {
-                       gpointer ip = mono_array_get (initial_trace_ips, gpointer, i * 2 + 0);
-                       gpointer generic_info = mono_array_get (initial_trace_ips, gpointer, i * 2 + 1);
-                       trace_ips = g_list_prepend (trace_ips, ip);
-                       trace_ips = g_list_prepend (trace_ips, generic_info);
+                       for (int j = 0; j < TRACE_IP_ENTRY_SIZE; ++j) {
+                               gpointer p = mono_array_get (initial_trace_ips, gpointer, (i * TRACE_IP_ENTRY_SIZE) + j);
+                               trace_ips = g_list_prepend (trace_ips, p);
+                       }
                }
        }
 
@@ -1633,7 +1655,7 @@ mono_handle_exception_internal_first_pass (MonoContext *ctx, MonoObject *obj, gi
 
                gpointer ip;
                if (in_interp)
-                       ip = (guint16*)ji->code_start + frame.native_offset;
+                       ip = (guint8*)ji->code_start + frame.native_offset;
                else
                        ip = MONO_CONTEXT_GET_IP (ctx);
 
@@ -2009,7 +2031,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                }
 
                if (in_interp)
-                       ip = (guint16*)ji->code_start + frame.native_offset;
+                       ip = (guint8*)ji->code_start + frame.native_offset;
                else
                        ip = MONO_CONTEXT_GET_IP (ctx);
 
@@ -2131,7 +2153,7 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu
                                                 * like the call which transitioned to JITted code has succeeded, but the
                                                 * return value register etc. is not set, so we have to be careful.
                                                 */
-                                               mono_interp_set_resume_state (mono_ex, &frame, ei->handler_start);
+                                               mono_interp_set_resume_state (jit_tls, mono_ex, frame.interp_frame, ei->handler_start);
                                                /* Undo the IP adjustment done by mono_arch_unwind_frame () */
 #if defined(TARGET_AMD64)
                                                ctx->gregs [AMD64_RIP] ++;
@@ -2260,6 +2282,9 @@ mono_debugger_run_finally (MonoContext *start_ctx)
  * mono_handle_exception:
  * \param ctx saved processor state
  * \param obj the exception object
+ *
+ *   Handle the exception OBJ starting from the state CTX. Modify CTX to point to the handler clause if the exception is caught, and
+ * return TRUE.
  */
 gboolean
 mono_handle_exception (MonoContext *ctx, MonoObject *obj)
@@ -2608,7 +2633,7 @@ static void print_process_map (void)
 #endif
 }
 
-static gboolean handling_sigsegv = FALSE;
+static gboolean handle_crash_loop = FALSE;
 
 /*
  * mono_handle_native_crash:
@@ -2624,9 +2649,7 @@ mono_handle_native_crash (const char *signal, void *ctx, MONO_SIG_HANDLER_INFO_T
 #endif
        MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls ();
 
-       gboolean is_sigsegv = !strcmp ("SIGSEGV", signal);
-
-       if (handling_sigsegv && is_sigsegv)
+       if (handle_crash_loop)
                return;
 
        if (mini_get_debug_options ()->suspend_on_native_crash) {
@@ -2641,9 +2664,8 @@ mono_handle_native_crash (const char *signal, void *ctx, MONO_SIG_HANDLER_INFO_T
 #endif
        }
 
-       /* To prevent infinite loops when the stack walk causes a crash */
-       if (is_sigsegv)
-               handling_sigsegv = TRUE;
+       /* prevent infinite loops in crash handling */
+       handle_crash_loop = TRUE;
 
        /* !jit_tls means the thread was not registered with the runtime */
        if (jit_tls && mono_thread_internal_current ()) {
@@ -3281,12 +3303,12 @@ mono_llvm_load_exception (void)
 
                size_t upper = mono_array_length (mono_ex->trace_ips);
 
-               for (int i = 0; i < upper; i+= 2) {
+               for (int i = 0; i < upper; i += TRACE_IP_ENTRY_SIZE) {
                        gpointer curr_ip = mono_array_get (mono_ex->trace_ips, gpointer, i);
-                       gpointer curr_info = mono_array_get (mono_ex->trace_ips, gpointer, i + 1);
-                       trace_ips = g_list_append (trace_ips, curr_ip);
-                       trace_ips = g_list_append (trace_ips, curr_info);
-
+                       for (int j = 0; j < TRACE_IP_ENTRY_SIZE; ++j) {
+                               gpointer p = mono_array_get (mono_ex->trace_ips, gpointer, i + j);
+                               trace_ips = g_list_append (trace_ips, p);
+                       }
                        if (ip == curr_ip)
                                break;
                }
@@ -3407,31 +3429,3 @@ mono_debug_personality (void)
        g_assert_not_reached ();
 }
 #endif
-
-#ifndef ENABLE_INTERPRETER
-/* Stubs of interpreter functions */
-void
-mono_interp_set_resume_state (MonoException *ex, StackFrameInfo *frame, gpointer handler_ip)
-{
-       g_assert_not_reached ();
-}
-
-void
-mono_interp_run_finally (StackFrameInfo *frame, int clause_index, gpointer handler_ip)
-{
-       g_assert_not_reached ();
-}
-
-void
-mono_interp_frame_iter_init (MonoInterpStackIter *iter, gpointer interp_exit_data)
-{
-       g_assert_not_reached ();
-}
-
-gboolean
-mono_interp_frame_iter_next (MonoInterpStackIter *iter, StackFrameInfo *frame)
-{
-       g_assert_not_reached ();
-       return FALSE;
-}
-#endif
index 5ef3b350bf065f713a12e9992a124a9d0c0b5b8f..9943d883966e1b74b6be10e1b515c3fbe945e0ba 100644 (file)
@@ -390,7 +390,17 @@ info_has_identity (MonoRgctxInfoType info_type)
 /*
  * LOCKING: loader lock
  */
+#if defined(PLATFORM_ANDROID) && defined(TARGET_ARM)
+/* work around for HW bug on Nexus9 when running on armv7 */
+#ifdef __clang__
+static __attribute__ ((optnone)) void
+#else
+/* gcc */
+static __attribute__ ((optimize("O0"))) void
+#endif
+#else
 static void
+#endif
 rgctx_template_set_slot (MonoImage *image, MonoRuntimeGenericContextTemplate *template_, int type_argc,
        int slot, gpointer data, MonoRgctxInfoType info_type)
 {
index c24bf22d601ac7040b1965ed698977fcb99c80fa..de4898bdd3e06cfce4162bfbce591c22bc293ff7 100644 (file)
@@ -282,6 +282,7 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1
 #define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
 #define MONO_ARCH_GSHARED_SUPPORTED 1
+#define MONO_ARCH_HAVE_INIT_LMF_EXT 1
 
 /* set the next to 0 once inssel-mips.brg is updated */
 #define MIPS_PASS_STRUCTS_BY_VALUE 1
index 0d1b11f3e45a95dabae4f05a33ff37576f11fef5..5bcf5435df0e2a65a9a2f154b6582c80f8f3674f 100644 (file)
@@ -75,7 +75,7 @@
 #include <mach/clock.h>
 #endif
 
-#if defined(__native_client__) || defined(HOST_WATCHOS)
+#if defined(HOST_WATCHOS)
 
 void
 mono_runtime_setup_stat_profiler (void)
@@ -581,16 +581,28 @@ static void
 clock_init (void)
 {
        switch (mono_profiler_get_sampling_mode ()) {
-       case MONO_PROFILER_STAT_MODE_PROCESS:
+       case MONO_PROFILER_STAT_MODE_PROCESS: {
+       /*
+        * If we don't have clock_nanosleep (), measuring the process time
+        * makes very little sense as we can only use nanosleep () to sleep on
+        * real time.
+        */
 #ifdef HAVE_CLOCK_NANOSLEEP
+               struct timespec ts = { 0 };
+
                /*
-                * If we don't have clock_nanosleep (), measuring the process time
-                * makes very little sense as we can only use nanosleep () to sleep on
-                * real time.
+                * Some systems (e.g. Windows Subsystem for Linux) declare the
+                * CLOCK_PROCESS_CPUTIME_ID clock but don't actually support it. For
+                * those systems, we fall back to CLOCK_MONOTONIC if we get EINVAL.
                 */
-               sampling_posix_clock = CLOCK_PROCESS_CPUTIME_ID;
-               break;
+               if (clock_nanosleep (CLOCK_PROCESS_CPUTIME_ID, TIMER_ABSTIME, &ts, NULL) != EINVAL) {
+                       sampling_posix_clock = CLOCK_PROCESS_CPUTIME_ID;
+                       break;
+               }
 #endif
+
+               // fallthrough
+       }
        case MONO_PROFILER_STAT_MODE_REAL: sampling_posix_clock = CLOCK_MONOTONIC; break;
        default: g_assert_not_reached (); break;
        }
@@ -828,16 +840,7 @@ mono_runtime_setup_stat_profiler (void)
 
 #endif
 
-#endif /* defined(__native_client__) || defined(HOST_WATCHOS) */
-
-#if defined(__native_client__)
-
-void
-mono_gdb_render_native_backtraces (pid_t crashed_pid)
-{
-}
-
-#else
+#endif /* defined(HOST_WATCHOS) */
 
 static gboolean
 native_stack_with_gdb (pid_t crashed_pid, const char **argv, FILE *commands, char* commands_filename)
@@ -934,8 +937,6 @@ exec:
 #endif // HAVE_EXECV
 }
 
-#endif /* defined(__native_client__) */
-
 #if !defined (__MACH__)
 
 gboolean
index aaa6ddda3ecf8a2310758f067c1a1eaa89911693..718bb98d6fa4077ed1e8179f5c3bbb419ca3c21e 100644 (file)
@@ -236,6 +236,7 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
 #endif
 #define MONO_ARCH_HAVE_OP_TAIL_CALL 1
+#define MONO_ARCH_HAVE_INIT_LMF_EXT 1
 
 #define PPC_NUM_REG_ARGS (PPC_LAST_ARG_REG-PPC_FIRST_ARG_REG+1)
 #define PPC_NUM_REG_FPARGS (PPC_LAST_FPARG_REG-PPC_FIRST_FPARG_REG+1)
index b5d79629a54132d93550187554ac8b08557f4815..f67497d6836e7989f6d9378287d704d08f1de5da 100644 (file)
@@ -372,16 +372,6 @@ mono_global_codeman_foreach (MonoCodeManagerFunc func, void *user_data)
        mono_jit_unlock ();
 }
 
-#if defined(__native_client_codegen__) && defined(__native_client__)
-void
-mono_nacl_gc()
-{
-#ifdef __native_client_gc__
-       __nacl_suspend_thread_if_needed();
-#endif
-}
-#endif /* __native_client__ */
-
 /**
  * mono_create_unwind_op:
  *
@@ -583,23 +573,23 @@ break_count (void)
 G_GNUC_UNUSED gboolean
 mono_debug_count (void)
 {
-       static int count = 0;
+       static int count = 0, int_val = 0;
        static gboolean inited;
-       static char *value;
 
        count ++;
 
        if (!inited) {
-               value = g_getenv ("COUNT");
+               char *value = g_getenv ("COUNT");
+               if (value) {
+                       int_val = atoi (value);
+                       g_free (value);
+               }
                inited = TRUE;
        }
 
-       if (!value)
+       if (!int_val)
                return TRUE;
 
-       int int_val = atoi (value);
-       g_free (value);
-
        if (count == int_val)
                break_count ();
 
@@ -1403,21 +1393,12 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
                break;
        }
        case MONO_PATCH_INFO_GC_SAFE_POINT_FLAG:
-#if defined(__native_client_codegen__)
-               target = (gpointer)&__nacl_thread_suspension_needed;
-#else
                g_assert (mono_threads_is_coop_enabled ());
                target = (gpointer)&mono_polling_required;
-#endif
                break;
        case MONO_PATCH_INFO_SWITCH: {
                gpointer *jump_table;
                int i;
-#if defined(__native_client__) && defined(__native_client_codegen__)
-               /* This memory will leak, but we don't care if we're */
-               /* not deleting JIT'd methods anyway                 */
-               jump_table = g_malloc0 (sizeof(gpointer) * patch_info->data.table->table_size);
-#else
                if (method && method->dynamic) {
                        jump_table = (void **)mono_code_manager_reserve (mono_dynamic_code_hash_lookup (domain, method)->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
                } else {
@@ -1427,7 +1408,6 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
                                jump_table = (void **)mono_domain_code_reserve (domain, sizeof (gpointer) * patch_info->data.table->table_size);
                        }
                }
-#endif
 
                for (i = 0; i < patch_info->data.table->table_size; i++) {
                        jump_table [i] = code + GPOINTER_TO_INT (patch_info->data.table->table [i]);
@@ -1757,6 +1737,27 @@ mono_get_jit_info_from_method (MonoDomain *domain, MonoMethod *method)
        return lookup_method (domain, method);
 }
 
+MonoClass*
+mini_get_class (MonoMethod *method, guint32 token, MonoGenericContext *context)
+{
+       MonoError error;
+       MonoClass *klass;
+
+       if (method->wrapper_type != MONO_WRAPPER_NONE) {
+               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+               if (context) {
+                       klass = mono_class_inflate_generic_class_checked (klass, context, &error);
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
+               }
+       } else {
+               klass = mono_class_get_and_inflate_typespec_checked (method->klass->image, token, context, &error);
+               mono_error_cleanup (&error); /* FIXME don't swallow the error */
+       }
+       if (klass)
+               mono_class_init (klass);
+       return klass;
+}
+
 #if ENABLE_JIT_MAP
 static FILE* perf_map_file;
 
@@ -2062,7 +2063,18 @@ lookup_start:
 
 #ifdef MONO_USE_AOT_COMPILER
        if (opt & MONO_OPT_AOT) {
-               MonoDomain *domain = mono_domain_get ();
+               MonoDomain *domain = NULL;
+
+               if (mono_aot_mode == MONO_AOT_MODE_INTERP && method->wrapper_type == MONO_WRAPPER_UNKNOWN) {
+                       WrapperInfo *info = mono_marshal_get_wrapper_info (method);
+                       g_assert (info);
+                       if (info->subtype == WRAPPER_SUBTYPE_INTERP_IN)
+                               /* AOT'd wrappers for interp must be owned by root domain */
+                               domain = mono_get_root_domain ();
+               }
+
+               if (!domain)
+                       domain = mono_domain_get ();
 
                mono_class_init (method->klass);
 
@@ -3763,7 +3775,7 @@ mini_init (const char *filename, const char *runtime_version)
 
        CHECKED_MONO_INIT ();
 
-#if defined(__linux__) && !defined(__native_client__)
+#if defined(__linux__)
        if (access ("/proc/self/maps", F_OK) != 0) {
                g_print ("Mono requires /proc to be mounted.\n");
                exit (1);
@@ -4067,10 +4079,6 @@ register_icalls (void)
        register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "object", FALSE);
        register_icall (mono_thread_force_interruption_checkpoint_noraise, "mono_thread_force_interruption_checkpoint_noraise", "object", FALSE);
 
-#if defined(__native_client__) || defined(__native_client_codegen__)
-       register_icall (mono_nacl_gc, "mono_nacl_gc", "void", FALSE);
-#endif
-
        if (mono_threads_is_coop_enabled ())
                register_icall (mono_threads_state_poll, "mono_threads_state_poll", "void", FALSE);
 
@@ -4139,12 +4147,8 @@ register_icalls (void)
        register_opcode_emulation (OP_LCONV_TO_R_UN, "__emul_lconv_to_r8_un", "double long", mono_lconv_to_r8_un, "mono_lconv_to_r8_un", FALSE);
 #endif
 #ifdef MONO_ARCH_EMULATE_FREM
-#if !defined(__native_client__)
        register_opcode_emulation (OP_FREM, "__emul_frem", "double double double", fmod, "fmod", FALSE);
        register_opcode_emulation (OP_RREM, "__emul_rrem", "float float float", fmodf, "fmodf", FALSE);
-#else
-       register_opcode_emulation (OP_FREM, "__emul_frem", "double double double", mono_fmod, "mono_fmod", FALSE);
-#endif
 #endif
 
 #ifdef MONO_ARCH_SOFT_FLOAT_FALLBACK
@@ -4547,6 +4551,56 @@ mono_personality (void)
        g_assert_not_reached ();
 }
 
+
+static MonoBreakPolicy
+always_insert_breakpoint (MonoMethod *method)
+{
+       return MONO_BREAK_POLICY_ALWAYS;
+}
+
+static MonoBreakPolicyFunc break_policy_func = always_insert_breakpoint;
+
+/**
+ * mono_set_break_policy:
+ * \param policy_callback the new callback function
+ *
+ * Allow embedders to decide whether to actually obey breakpoint instructions
+ * (both break IL instructions and \c Debugger.Break method calls), for example
+ * to not allow an app to be aborted by a perfectly valid IL opcode when executing
+ * untrusted or semi-trusted code.
+ *
+ * \p policy_callback will be called every time a break point instruction needs to
+ * be inserted with the method argument being the method that calls \c Debugger.Break
+ * or has the IL \c break instruction. The callback should return \c MONO_BREAK_POLICY_NEVER
+ * if it wants the breakpoint to not be effective in the given method.
+ * \c MONO_BREAK_POLICY_ALWAYS is the default.
+ */
+void
+mono_set_break_policy (MonoBreakPolicyFunc policy_callback)
+{
+       if (policy_callback)
+               break_policy_func = policy_callback;
+       else
+               break_policy_func = always_insert_breakpoint;
+}
+
+gboolean
+mini_should_insert_breakpoint (MonoMethod *method)
+{
+       switch (break_policy_func (method)) {
+       case MONO_BREAK_POLICY_ALWAYS:
+               return TRUE;
+       case MONO_BREAK_POLICY_NEVER:
+               return FALSE;
+       case MONO_BREAK_POLICY_ON_DBG:
+               g_warning ("mdb no longer supported");
+               return FALSE;
+       default:
+               g_warning ("Incorrect value returned from break policy callback");
+               return FALSE;
+       }
+}
+
 // Custom handlers currently only implemented by Windows.
 #ifndef HOST_WIN32
 gboolean
index 5c40278e39d373a23da950143ee37b14b4054685..a3d0a60000383c2ad3c790fdadd618b6ed149220 100644 (file)
@@ -237,6 +237,7 @@ typedef struct {
 #define MONO_ARCH_HAVE_DUMMY_INIT 1
 #define MONO_ARCH_HAVE_SDB_TRAMPOLINES 1
 #define MONO_ARCH_HAVE_PATCH_CODE_NEW 1
+#define MONO_ARCH_HAVE_INIT_LMF_EXT 1
 
 /* Used for optimization, not complete */
 #define MONO_ARCH_IS_OP_MEMBASE(opcode) ((opcode) == OP_X86_PUSH_MEMBASE)
index c81919ececada46517dc824b89e7a60219885640..10d6eac8b16d0b4a0306565c4a7642c07e5f1edd 100644 (file)
@@ -2152,18 +2152,11 @@ mono_postprocess_patches (MonoCompile *cfg)
                }
                case MONO_PATCH_INFO_SWITCH: {
                        gpointer *table;
-#if defined(__native_client__) && defined(__native_client_codegen__)
-                       /* This memory will leak.  */
-                       /* TODO: can we free this when  */
-                       /* making the final jump table? */
-                       table = g_malloc0 (sizeof(gpointer) * patch_info->data.table->table_size);
-#else
                        if (cfg->method->dynamic) {
                                table = (void **)mono_code_manager_reserve (cfg->dynamic_info->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
                        } else {
                                table = (void **)mono_domain_code_reserve (cfg->domain, sizeof (gpointer) * patch_info->data.table->table_size);
                        }
-#endif
 
                        for (i = 0; i < patch_info->data.table->table_size; i++) {
                                /* Might be NULL if the switch is eliminated */
@@ -2385,9 +2378,6 @@ mono_codegen (MonoCompile *cfg)
        } else {
                mono_domain_code_commit (code_domain, cfg->native_code, cfg->code_size, cfg->code_len);
        }
-#if defined(__native_client_codegen__) && defined(__native_client__)
-       cfg->native_code = code_dest;
-#endif
        mono_profiler_code_buffer_new (cfg->native_code, cfg->code_len, MONO_PROFILER_CODE_BUFFER_METHOD, cfg->method);
        
        mono_arch_flush_icache (cfg->native_code, cfg->code_len);
@@ -2869,12 +2859,8 @@ mono_create_gc_safepoint (MonoCompile *cfg, MonoBasicBlock *bblock)
        if (cfg->verbose_level > 1)
                printf ("ADDING SAFE POINT TO BB %d\n", bblock->block_num);
 
-#if defined(__native_client_codegen__)
-       NEW_AOTCONST (cfg, poll_addr, MONO_PATCH_INFO_GC_SAFE_POINT_FLAG, (gpointer)&__nacl_thread_suspension_needed);
-#else
        g_assert (mono_threads_is_coop_enabled ());
        NEW_AOTCONST (cfg, poll_addr, MONO_PATCH_INFO_GC_SAFE_POINT_FLAG, (gpointer)&mono_polling_required);
-#endif
 
        MONO_INST_NEW (cfg, ins, OP_GC_SAFE_POINT);
        ins->sreg1 = poll_addr->dreg;
@@ -2919,19 +2905,13 @@ mono_insert_safepoints (MonoCompile *cfg)
 {
        MonoBasicBlock *bb;
 
-#if !defined(__native_client_codegen__)
        if (!mono_threads_is_coop_enabled ())
                return;
-#endif
 
        if (cfg->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) {
                WrapperInfo *info = mono_marshal_get_wrapper_info (cfg->method);
-#if defined(__native_client__) || defined(__native_client_codegen__)
-               gpointer poll_func = &mono_nacl_gc;
-#else
                g_assert (mono_threads_is_coop_enabled ());
                gpointer poll_func = &mono_threads_state_poll;
-#endif
 
                if (info && info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER && info->d.icall.func == poll_func) {
                        if (cfg->verbose_level > 1)
@@ -3207,13 +3187,9 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
                cfg->gen_seq_points = FALSE;
                cfg->gen_sdb_seq_points = FALSE;
        }
-       /* coop / nacl requires loop detection to happen */
-#if defined(__native_client_codegen__)
-       cfg->opt |= MONO_OPT_LOOP;
-#else
+       /* coop requires loop detection to happen */
        if (mono_threads_is_coop_enabled ())
                cfg->opt |= MONO_OPT_LOOP;
-#endif
        cfg->explicit_null_checks = debug_options.explicit_null_checks || (flags & JIT_FLAG_EXPLICIT_NULL_CHECKS);
        cfg->soft_breakpoints = debug_options.soft_breakpoints;
        cfg->check_pinvoke_callconv = debug_options.check_pinvoke_callconv;
@@ -4359,8 +4335,12 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                }
        }
 
-       if (!mono_runtime_class_init_full (vtable, error))
-               return NULL;
+       if (!(method->wrapper_type == MONO_WRAPPER_REMOTING_INVOKE ||
+                 method->wrapper_type == MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK ||
+                 method->wrapper_type == MONO_WRAPPER_XDOMAIN_INVOKE)) {
+               if (!mono_runtime_class_init_full (vtable, error))
+                       return NULL;
+       }
        return code;
 }
 
index 6eb32809205aa44af20d634bfaf7607a344fa0e3..1fcb2f1d892789f35101633f0ec5c7a9f9498535 100644 (file)
 #include "mono/metadata/security-manager.h"
 #include "mono/metadata/exception.h"
 
-#ifdef __native_client_codegen__
-#include <nacl/nacl_dyncode.h>
-#endif
-
-
 /*
  * The mini code should not have any compile time dependencies on the GC being used, so the same object file from mini/
  * can be linked into both mono and mono-sgen.
@@ -1217,11 +1212,12 @@ typedef struct {
         */
        gpointer abort_exc_stack_threshold;
 
-
        /*
         * List of methods being JIT'd in the current thread.
         */
        int active_jit_methods;
+
+       gpointer interp_context;
 } MonoJitTlsData;
 
 /*
@@ -1678,11 +1674,6 @@ typedef struct {
        MonoInst *stack_inbalance_var;
 
        unsigned char   *cil_start;
-#ifdef __native_client_codegen__
-       /* this alloc is not aligned, native_code */
-       /* is the 32-byte aligned version of this */
-       unsigned char   *native_code_alloc;
-#endif
        unsigned char   *native_code;
        guint            code_size;
        guint            code_len;
@@ -2481,6 +2472,7 @@ MonoInst* mono_emit_jit_icall_by_info (MonoCompile *cfg, int il_offset, MonoJitI
 MonoInst* mono_emit_method_call (MonoCompile *cfg, MonoMethod *method, MonoInst **args, MonoInst *this_ins);
 void      mono_create_helper_signatures (void);
 MonoInst* mono_emit_native_call (MonoCompile *cfg, gconstpointer func, MonoMethodSignature *sig, MonoInst **args);
+gboolean  mini_should_insert_breakpoint (MonoMethod *method);
 
 gboolean  mini_class_is_system_array (MonoClass *klass);
 MonoMethodSignature *mono_get_element_address_signature (int arity);
@@ -2498,12 +2490,6 @@ void      mono_liveness_handle_exception_clauses (MonoCompile *cfg);
 /* Native Client functions */
 gpointer mono_realloc_native_code(MonoCompile *cfg);
 
-#if defined(__native_client__) || defined(__native_client_codegen__)
-extern volatile int __nacl_thread_suspension_needed;
-void __nacl_suspend_thread_if_needed(void);
-void mono_nacl_gc(void);
-#endif
-
 extern MonoDebugOptions debug_options;
 
 static inline MonoMethod*
@@ -2652,11 +2638,11 @@ MonoInst*         mini_emit_get_gsharedvt_info_klass (MonoCompile *cfg, MonoClas
 MonoInst*         mini_emit_calli (MonoCompile *cfg, MonoMethodSignature *sig, MonoInst **args, MonoInst *addr, MonoInst *imt_arg, MonoInst *rgctx_arg);
 MonoInst*         mini_emit_memory_barrier (MonoCompile *cfg, int kind);
 void              mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value);
-gboolean          mini_emit_wb_aware_memcpy (MonoCompile *cfg, MonoClass *klass, MonoInst *iargs[4], int size, int align);
 MonoInst*         mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offset, int ins_flag);
 void              mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoInst *value, int ins_flag);
 void              mini_emit_memory_copy_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoInst *size, int ins_flag);
 void              mini_emit_memory_init_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *value, MonoInst *size, int ins_flag);
+void              mini_emit_memory_copy (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native, int ins_flag);
 
 MonoMethod*       mini_get_memcpy_method (void);
 MonoMethod*       mini_get_memset_method (void);
@@ -2812,6 +2798,9 @@ gboolean  mono_arch_is_breakpoint_event         (void *info, void *sigctx);
 void     mono_arch_skip_breakpoint              (MonoContext *ctx, MonoJitInfo *ji);
 void     mono_arch_skip_single_step             (MonoContext *ctx);
 gpointer mono_arch_get_seq_point_info           (MonoDomain *domain, guint8 *code);
+#endif
+
+#ifdef MONO_ARCH_HAVE_INIT_LMF_EXT
 void     mono_arch_init_lmf_ext                 (MonoLMFExt *ext, gpointer prev_lmf);
 #endif
 
index e5d6ae6bdb82618cfa703fd77e2811170f68788e..c0aa5fdf64a8a37f27bbaced10183f224d0d42ed 100644 (file)
@@ -2,11 +2,7 @@
  * \file
  */
 
-#if defined(__native_client__) && defined(__x86_64__)
-typedef guint64 regmask_t;
-#else
 typedef size_t regmask_t;
-#endif
 
 enum {
        MONO_REG_INT,
index 51c0cac6de625a0579fd85b262059f98a9e3f1f2..13c09ac33a72ca821bbd6085e2568cf7596171d3 100644 (file)
@@ -847,26 +847,31 @@ mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
        guint8 *start = NULL, *code, *label_gexits [gregs_num], *label_fexits [fregs_num], *label_leave_tramp [3], *label_is_float_ret;
        MonoJumpInfo *ji = NULL;
        GSList *unwind_ops = NULL;
-       int buf_len, i, framesize = 0, off_methodargs, off_targetaddr;
+       int buf_len, i, framesize, off_methodargs, off_targetaddr;
        const int fp_reg = ARMREG_R7;
 
        buf_len = 512 + 1024;
        start = code = (guint8 *) mono_global_codeman_reserve (buf_len);
 
-       off_methodargs = framesize;
+       framesize = 5 * sizeof (mgreg_t); /* lr, r4, r8, r6 and plus one */
+
+       off_methodargs = -framesize;
        framesize += sizeof (mgreg_t);
 
-       off_targetaddr = framesize;
+       off_targetaddr = -framesize;
        framesize += sizeof (mgreg_t);
 
-       framesize = ALIGN_TO (framesize, MONO_ARCH_FRAME_ALIGNMENT);
+       framesize = ALIGN_TO (framesize + 4 * sizeof (mgreg_t), MONO_ARCH_FRAME_ALIGNMENT);
 
        /* allocate space on stack for argument passing */
        const int stack_space = ALIGN_TO (((gregs_num - ARMREG_R3) * sizeof (mgreg_t)), MONO_ARCH_FRAME_ALIGNMENT);
 
-       /* use r4, r5 and r6 as scratch registers */
-       ARM_PUSH (code, (1 << fp_reg) | (1 << ARMREG_LR) | (1 << ARMREG_R4) | (1 << ARMREG_R5) | (1 << ARMREG_R6));
+       /* iOS ABI */
+       ARM_PUSH (code, (1 << fp_reg) | (1 << ARMREG_LR));
        ARM_MOV_REG_REG (code, fp_reg, ARMREG_SP);
+
+       /* use r4, r8 and r6 as scratch registers */
+       ARM_PUSH (code, (1 << ARMREG_R4) | (1 << ARMREG_R8) | (1 << ARMREG_R6));
        ARM_SUB_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, stack_space + framesize);
 
        /* save InterpMethodArguments* onto stack */
@@ -878,32 +883,32 @@ mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
        /* load pointer to InterpMethodArguments* into r4 */
        ARM_MOV_REG_REG (code, ARMREG_R4, ARMREG_R1);
 
-       /* move flen into r5 */
-       ARM_LDR_IMM (code, ARMREG_R5, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, flen));
+       /* move flen into r8 */
+       ARM_LDR_IMM (code, ARMREG_R8, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, flen));
        /* load pointer to fargs into r6 */
        ARM_LDR_IMM (code, ARMREG_R6, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, fargs));
 
        for (i = 0; i < fregs_num; ++i) {
-               ARM_CMP_REG_IMM (code, ARMREG_R5, 0, 0);
+               ARM_CMP_REG_IMM (code, ARMREG_R8, 0, 0);
                label_fexits [i] = code;
                ARM_B_COND (code, ARMCOND_EQ, 0);
 
                g_assert (i <= ARM_VFP_D7); /* otherwise, need to pass args on stack */
                ARM_FLDD (code, i, ARMREG_R6, i * sizeof (double));
-               ARM_SUB_REG_IMM8 (code, ARMREG_R5, ARMREG_R5, 1);
+               ARM_SUB_REG_IMM8 (code, ARMREG_R8, ARMREG_R8, 1);
        }
 
        for (i = 0; i < fregs_num; i++)
                arm_patch (label_fexits [i], code);
 
-       /* move ilen into r5 */
-       ARM_LDR_IMM (code, ARMREG_R5, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, ilen));
+       /* move ilen into r8 */
+       ARM_LDR_IMM (code, ARMREG_R8, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, ilen));
        /* load pointer to iargs into r6 */
        ARM_LDR_IMM (code, ARMREG_R6, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, iargs));
 
        int stack_offset = 0;
        for (i = 0; i < gregs_num; i++) {
-               ARM_CMP_REG_IMM (code, ARMREG_R5, 0, 0);
+               ARM_CMP_REG_IMM (code, ARMREG_R8, 0, 0);
                label_gexits [i] = code;
                ARM_B_COND (code, ARMCOND_EQ, 0);
 
@@ -914,7 +919,7 @@ mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
                        ARM_STR_IMM (code, ARMREG_R4, ARMREG_SP, stack_offset);
                        stack_offset += sizeof (mgreg_t);
                }
-               ARM_SUB_REG_IMM8 (code, ARMREG_R5, ARMREG_R5, 1);
+               ARM_SUB_REG_IMM8 (code, ARMREG_R8, ARMREG_R8, 1);
        }
 
        for (i = 0; i < gregs_num; i++)
@@ -930,24 +935,24 @@ mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
        ARM_LDR_IMM (code, ARMREG_R4, fp_reg, off_methodargs);
 
        /* load is_float_ret */
-       ARM_LDR_IMM (code, ARMREG_R5, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, is_float_ret));
+       ARM_LDR_IMM (code, ARMREG_R8, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, is_float_ret));
 
        /* check if a float return value is expected */
-       ARM_CMP_REG_IMM (code, ARMREG_R5, 0, 0);
+       ARM_CMP_REG_IMM (code, ARMREG_R8, 0, 0);
        label_is_float_ret = code;
        ARM_B_COND (code, ARMCOND_NE, 0);
 
        /* greg return */
        /* load retval */
-       ARM_LDR_IMM (code, ARMREG_R5, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, retval));
+       ARM_LDR_IMM (code, ARMREG_R8, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, retval));
 
-       ARM_CMP_REG_IMM (code, ARMREG_R5, 0, 0);
+       ARM_CMP_REG_IMM (code, ARMREG_R8, 0, 0);
        label_leave_tramp [0] = code;
        ARM_B_COND (code, ARMCOND_EQ, 0);
 
        /* store greg result, always write back 64bit */
-       ARM_STR_IMM (code, ARMREG_R0, ARMREG_R5, 0);
-       ARM_STR_IMM (code, ARMREG_R1, ARMREG_R5, 4);
+       ARM_STR_IMM (code, ARMREG_R0, ARMREG_R8, 0);
+       ARM_STR_IMM (code, ARMREG_R1, ARMREG_R8, 4);
 
        label_leave_tramp [1] = code;
        ARM_B_COND (code, ARMCOND_AL, 0);
@@ -955,20 +960,22 @@ mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
        /* freg return */
        arm_patch (label_is_float_ret, code);
        /* load retval */
-       ARM_LDR_IMM (code, ARMREG_R5, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, retval));
+       ARM_LDR_IMM (code, ARMREG_R8, ARMREG_R4, MONO_STRUCT_OFFSET (InterpMethodArguments, retval));
 
-       ARM_CMP_REG_IMM (code, ARMREG_R5, 0, 0);
+       ARM_CMP_REG_IMM (code, ARMREG_R8, 0, 0);
        label_leave_tramp [2] = code;
        ARM_B_COND (code, ARMCOND_EQ, 0);
 
        /* store freg result */
-       ARM_FSTD (code, ARM_VFP_F0, ARMREG_R5, 0);
+       ARM_FSTD (code, ARM_VFP_F0, ARMREG_R8, 0);
 
        for (i = 0; i < 3; i++)
                arm_patch (label_leave_tramp [i], code);
 
+       ARM_ADD_REG_IMM8 (code, ARMREG_SP, ARMREG_SP, stack_space + framesize);
+       ARM_POP (code, (1 << ARMREG_R4) | (1 << ARMREG_R8) | (1 << ARMREG_R6));
        ARM_MOV_REG_REG (code, ARMREG_SP, fp_reg);
-       ARM_POP (code, (1 << fp_reg) | (1 << ARMREG_PC) | (1 << ARMREG_R4) | (1 << ARMREG_R5) | (1 << ARMREG_R6));
+       ARM_POP (code, (1 << fp_reg) | (1 << ARMREG_PC));
 
        g_assert (code - start < buf_len);
 
@@ -1035,7 +1042,13 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
        g_assert_not_reached ();
        return NULL;
 }
-       
+
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
 #endif /* DISABLE_JIT */
 
 guint8*
index da998d4b1aa72bf4197d648a21d7dea3d42d85ec..e8503e61c6c68da41fa2f9ef51cbd4db7e7f58d8 100644 (file)
@@ -877,4 +877,10 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
        return NULL;
 }
 
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
 #endif /* !DISABLE_JIT */
index 0e67d3d63c613675eadd855c134d887d123e9e3c..faecb47d4de845102c506bef722fab3652b24cd2 100644 (file)
@@ -633,3 +633,10 @@ mono_arch_get_plt_info_offset (guint8 *plt_entry, mgreg_t *regs, guint8 *code)
        return ((guint32*)plt_entry) [6];
 #endif
 }
+
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
index 89ae8d64281d6b3e412b04d0b165b17a0a8591c0..55a6d77191e6a34d30958724a11cb3950be2f46a 100644 (file)
@@ -818,3 +818,10 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
        return buf;
 }
 
+gpointer
+mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
diff --git a/mono/mini/unaligned.cs b/mono/mini/unaligned.cs
new file mode 100644 (file)
index 0000000..4ff899f
--- /dev/null
@@ -0,0 +1,308 @@
+using System;
+using System.Runtime.CompilerServices;
+using Mono;
+
+/*
+ * Regression tests for the mono JIT.
+ *
+ * Each test needs to be of the form:
+ *
+ * static int test_<result>_<name> ();
+ *
+ * where <result> is an integer (the value that needs to be returned by
+ * the method to make it pass.
+ * <name> is a user-displayed name used to identify the test.
+ *
+ * The tests can be driven in two ways:
+ * *) running the program directly: Main() uses reflection to find and invoke
+ *     the test methods (this is useful mostly to check that the tests are correct)
+ * *) with the --regression switch of the jit (this is the preferred way since
+ *     all the tests will be run with optimizations on and off)
+ *
+ * The reflection logic could be moved to a .dll since we need at least another
+ * regression test file written in IL code to have better control on how
+ * the IL code looks.
+ */
+
+#if __MOBILE__
+namespace UnalignedTests
+{
+#endif
+
+
+class Tests {
+
+#if !__MOBILE__
+       public static int Main (string[] args) {
+               return TestDriver.RunTests (typeof (Tests), args);
+       }
+#endif
+
+
+       public static unsafe int test_0_ldobj_r4 ()
+       {
+               byte *ptr = stackalloc byte [32];
+               float f = (float)123.44f;
+               *(float*)ptr = (float)f;
+
+               int expected = *(int*)ptr;
+
+               Intrinsics.UnalignedStobj<int> (ptr + 1, expected);
+               /* we can loose some precision due to r4<->r8 conversions */
+               if (Math.Abs (Intrinsics.UnalignedLdobj<float> (ptr + 1) - f) > 0.01f)
+                       return 1;
+
+               return 0;
+       }
+
+       public static unsafe int test_0_ldobj_r8 ()
+       {
+               byte *ptr = stackalloc byte [32];
+               double f = 34423.44f;
+               *(double*)ptr = (double)f;
+
+               long expected = *(long*)ptr;
+
+               Intrinsics.UnalignedStobj<long> (ptr + 3, expected);
+               if (Intrinsics.UnalignedLdobj<double> (ptr + 3) != f)
+                       return 1;
+
+               return 0;
+       }
+
+       public static unsafe int test_0_ldobj ()
+       {
+               byte *ptr = stackalloc byte [20];
+               for (int i = 0; i < 20; ++i)
+                       ptr [i] = (byte)i;
+
+
+               if (Intrinsics.UnalignedLdobj<short> (ptr + 0) != 0x0100)
+                       return 1;
+
+               if (Intrinsics.UnalignedLdobj<short> (ptr + 1) != 0x0201)
+                       return 2;
+
+               if (Intrinsics.UnalignedLdobj<short> (ptr + 2) != 0x0302)
+                       return 3;
+
+               if (Intrinsics.UnalignedLdobj<int> (ptr + 1) != 0x04030201)
+                       return 4;
+
+               if (Intrinsics.UnalignedLdobj<int> (ptr + 2) != 0x05040302)
+                       return 5;
+
+               if (Intrinsics.UnalignedLdobj<long> (ptr + 1) != 0x0807060504030201)
+                       return 6;
+
+               if (Intrinsics.UnalignedLdobj<long> (ptr + 6) != 0xD0C0B0A09080706)
+                       return 7;
+
+               return 0;
+       }
+
+       public static unsafe int test_0_ldind ()
+       {
+               byte *ptr = stackalloc byte [20];
+               for (int i = 0; i < 20; ++i)
+                       ptr [i] = (byte)i;
+
+
+               if (Intrinsics.UnalignedLdInd2 (ptr + 0) != 0x0100)
+                       return 1;
+
+               if (Intrinsics.UnalignedLdInd2 (ptr + 1) != 0x0201)
+                       return 2;
+
+               if (Intrinsics.UnalignedLdInd2 (ptr + 2) != 0x0302)
+                       return 3;
+
+               if (Intrinsics.UnalignedLdInd4 (ptr + 1) != 0x04030201)
+                       return 4;
+
+               if (Intrinsics.UnalignedLdInd4 (ptr + 2) != 0x05040302)
+                       return 5;
+
+               if (Intrinsics.UnalignedLdInd8 (ptr + 1) != 0x0807060504030201)
+                       return 6;
+
+               if (Intrinsics.UnalignedLdInd8 (ptr + 6) != 0xD0C0B0A09080706)
+                       return 7;
+
+               return 0;
+       }
+       public static unsafe int test_0_cpobj ()
+       {
+               byte *dest = stackalloc byte [20];
+               byte *src = stackalloc byte [20];
+               for (int i = 0; i < 20; ++i)
+                       src [i] = (byte)i;
+
+               Intrinsics.UnalignedCpobj<short> (dest + 0, src + 0);
+               if (dest [0] != src [0] || dest [1] != src [1])
+                       return 1;
+
+               Intrinsics.UnalignedCpobj<short> (dest + 1, src + 0);
+               if (dest [1] != src [0] || dest [2] != src [1])
+                       return 2;
+
+               Intrinsics.UnalignedCpobj<short> (dest + 0, src + 1);
+               if (dest [0] != src [1] || dest [1] != src [2])
+                       return 3;
+
+               Intrinsics.UnalignedCpobj<short> (dest + 1, src + 1);
+               if (dest [1] != src [1] || dest [2] != src [2])
+                       return 3;
+
+               Intrinsics.UnalignedCpobj<int> (dest + 3, src);
+               for (int i = 0; i < 4; ++i) {
+                       if (dest [i + 3] != src [i])
+                               return 4;
+               }
+
+               Intrinsics.UnalignedCpobj<int> (dest + 1, src + 2);
+               for (int i = 0; i < 4; ++i) {
+                       if (dest [i + 1] != src [i + 2])
+                               return 5;
+               }
+
+               Intrinsics.UnalignedCpobj<long> (dest + 1, src + 2);
+               for (int i = 0; i < 8; ++i) {
+                       if (dest [i + 1] != src [i + 2])
+                               return 6;
+               }
+
+               Intrinsics.UnalignedCpobj<long> (dest + 7, src + 2);
+               for (int i = 0; i < 8; ++i) {
+                       if (dest [i + 7] != src [i + 2])
+                               return 7;
+               }
+
+               return 0;
+       }
+
+       public static unsafe int test_0_stobj ()
+       {
+               byte *ptr = stackalloc byte [20];
+
+               Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
+               if (ptr [0] != 0x88 || ptr [1] != 0x66)
+                       return 1;
+
+               Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
+               if (ptr [1] != 0x89 || ptr [2] != 0x65)
+                       return 2;
+
+               Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
+               if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
+                       return 3;
+
+               Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
+               if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
+                       return 4;
+
+               return 0;
+       }
+
+       public static unsafe int test_0_ldobj_stobj ()
+       {
+               byte *dest = stackalloc byte [20];
+               byte *src = stackalloc byte [20];
+
+               for (int i = 0; i < 20; ++i)
+                       src [i] = (byte)i;
+
+               Intrinsics.UnalignedLdobjStObjPair<short> (dest + 0, src + 0);
+               if (dest [0] != src [0] || dest [1] != src [1])
+                       return 1;
+
+               Intrinsics.UnalignedLdobjStObjPair<short> (dest + 1, src + 0);
+               if (dest [1] != src [0] || dest [2] != src [1])
+                       return 2;
+
+               Intrinsics.UnalignedLdobjStObjPair<short> (dest + 0, src + 1);
+               if (dest [0] != src [1] || dest [1] != src [2])
+                       return 3;
+
+               Intrinsics.UnalignedLdobjStObjPair<short> (dest + 1, src + 1);
+               if (dest [1] != src [1] || dest [2] != src [2])
+                       return 3;
+
+               Intrinsics.UnalignedLdobjStObjPair<int> (dest + 1, src + 1);
+               if (dest [1] != src [1] || dest [2] != src [2])
+                       return 4;
+
+               Intrinsics.UnalignedLdobjStObjPair<long> (dest + 1, src + 1);
+               if (dest [1] != src [1] || dest [2] != src [2])
+                       return 5;
+
+
+               return 0;
+       }
+
+
+       public static unsafe int test_0_cpblk ()
+       {
+               byte *dest = stackalloc byte [20];
+               byte *src = stackalloc byte [20];
+               for (int i = 0; i < 20; ++i)
+                       src [i] = (byte)i;
+
+
+               Intrinsics.UnalignedCpblk (dest + 0, src + 0, 2);
+               if (dest [0] != src [0] || dest [1] != src [1])
+                       return 1;
+
+               Intrinsics.UnalignedCpblk (dest + 1, src + 0, 2);
+               if (dest [1] != src [0] || dest [2] != src [1])
+                       return 2;
+
+               Intrinsics.UnalignedCpblk (dest + 0, src + 1, 2);
+               if (dest [0] != src [1] || dest [1] != src [2])
+                       return 3;
+
+               Intrinsics.UnalignedCpblk (dest + 1, src + 1, 2);
+               if (dest [1] != src [1] || dest [2] != src [2])
+                       return 3;
+
+               Intrinsics.UnalignedCpblk (dest + 1, src + 1, 4);
+               for (int i = 0; i < 4; ++i) {
+                       if (dest [i + 1] != src [i + 1])
+                               return 4;
+               }
+
+               Intrinsics.UnalignedCpblk (dest + 1, src + 1, 8);
+               for (int i = 0; i < 8; ++i) {
+                       if (dest [i + 1] != src [i + 1])
+                               return 5;
+               }
+
+               return 0;
+       }
+
+
+       public static unsafe int test_0_initblk ()
+       {
+               byte *ptr = stackalloc byte [20];
+
+               for (int i = 0; i < 20; ++i)
+                       ptr [i] = (byte)i;
+
+               Intrinsics.UnalignedInit (ptr, 30, 2);
+               if (ptr [0] != 30 || ptr [1] != 30)
+                       return 1;
+
+               Intrinsics.UnalignedInit (ptr + 1, 31, 2);
+               if (ptr[0] != 30 || ptr [1] != 31 || ptr [2] != 31)
+                       return 2;
+
+               return 0;
+       }
+}
+
+#if __MOBILE__
+}
+#endif
+
+
+
index 9010ee26c787c49b1fda2a235ac0ebda605f8555..f96c8a3fcccfba10337d1c2c3597139df56c46c5 100644 (file)
@@ -50,10 +50,8 @@ endif
 
 # FIXME fix the profiler tests to work with coop.
 if !ENABLE_COOP
-if !NACL_CODEGEN
 check_targets = testlog
 endif
-endif
 
 endif
 endif
@@ -67,30 +65,30 @@ monodir=$(top_builddir)
 # also uses eglib (e.g. the runtime). Automake doesn't support this
 # functionality, so create a separate static version of the library.
 
-libmono_profiler_aot_la_SOURCES = mono-profiler-aot.c
+libmono_profiler_aot_la_SOURCES = aot.c
 libmono_profiler_aot_la_LIBADD =  $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
 libmono_profiler_aot_la_LDFLAGS = $(prof_ldflags)
-libmono_profiler_aot_static_la_SOURCES = mono-profiler-aot.c
+libmono_profiler_aot_static_la_SOURCES = aot.c
 libmono_profiler_aot_static_la_LDFLAGS = -static
 
-libmono_profiler_iomap_la_SOURCES = mono-profiler-iomap.c
+libmono_profiler_iomap_la_SOURCES = iomap.c
 libmono_profiler_iomap_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(LIBICONV)
 libmono_profiler_iomap_la_LDFLAGS = $(prof_ldflags)
-libmono_profiler_iomap_static_la_SOURCES = mono-profiler-iomap.c
+libmono_profiler_iomap_static_la_SOURCES = iomap.c
 libmono_profiler_iomap_static_la_LDFLAGS = -static
 
-libmono_profiler_log_la_SOURCES = mono-profiler-log.c
+libmono_profiler_log_la_SOURCES = log.c log-args.c
 libmono_profiler_log_la_LIBADD = $(libmono_dep) $(GLIB_LIBS) $(Z_LIBS)
 libmono_profiler_log_la_LDFLAGS = $(prof_ldflags)
-libmono_profiler_log_static_la_SOURCES = mono-profiler-log.c
+libmono_profiler_log_static_la_SOURCES = log.c log-args.c
 libmono_profiler_log_static_la_LDFLAGS = -static
 
 if HAVE_VTUNE
-libmono_profiler_vtune_la_SOURCES = mono-profiler-vtune.c
+libmono_profiler_vtune_la_SOURCES = vtune.c
 libmono_profiler_vtune_la_CFLAGS = $(VTUNE_CFLAGS)
 libmono_profiler_vtune_la_LIBADD = $(VTUNE_LIBS) $(LIBMONO) $(GLIB_LIBS) $(LIBICONV)
 libmono_profiler_vtune_la_LDFLAGS = $(prof_ldflags)
-libmono_profiler_vtune_static_la_SOURCES = mono-profiler-vtune.c
+libmono_profiler_vtune_static_la_SOURCES = vtune.c
 libmono_profiler_vtune_static_la_LDFLAGS = -static
 libmono_profiler_vtune_static_la_CFLAGS = $(VTUNE_CFLAGS)
 libmono_profiler_vtune_static_la_LIBADD = $(VTUNE_LIBS)
@@ -116,8 +114,8 @@ testlog: $(PLOG_TESTS)
 
 check-local: $(check_targets)
 
-EXTRA_DIST=mono-profiler-log.h \
-       mono-profiler-aot.h \
+EXTRA_DIST=log.h \
+       aot.h \
        $(PLOG_TESTS_SRC) \
        ptestrunner.pl \
        $(suppression_DATA)
diff --git a/mono/profiler/aot.c b/mono/profiler/aot.c
new file mode 100644 (file)
index 0000000..b5c2d47
--- /dev/null
@@ -0,0 +1,413 @@
+/*
+ * mono-profiler-aot.c: Ahead of Time Compiler Profiler for Mono.
+ *
+ *
+ * Copyright 2008-2009 Novell, Inc (http://www.novell.com)
+ *
+ * This profiler collects profiling information usable by the Mono AOT compiler
+ * to generate better code. It saves the information into files under ~/.mono. 
+ * The AOT compiler can load these files during compilation.
+ * Currently, only the order in which methods were compiled is saved, 
+ * allowing more efficient function ordering in the AOT files.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+
+#include "aot.h"
+
+#include <mono/metadata/profiler.h>
+#include <mono/metadata/tokentype.h>
+#include <mono/metadata/tabledefs.h>
+#include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/assembly.h>
+#include <mono/metadata/class-internals.h>
+#include <mono/utils/mono-os-mutex.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sys/stat.h>
+
+#ifdef HOST_WIN32
+#include <direct.h>
+#endif
+
+struct _MonoProfiler {
+       GHashTable *classes;
+       GHashTable *images;
+       GPtrArray *methods;
+       FILE *outfile;
+       int id;
+       char *outfile_name;
+};
+
+static mono_mutex_t mutex;
+static gboolean verbose;
+
+static void
+prof_jit_enter (MonoProfiler *prof, MonoMethod *method)
+{
+}
+
+static void
+prof_jit_leave (MonoProfiler *prof, MonoMethod *method, int result)
+{
+       MonoImage *image = mono_class_get_image (mono_method_get_class (method));
+
+       if (!image->assembly || method->wrapper_type)
+               return;
+
+       mono_os_mutex_lock (&mutex);
+       g_ptr_array_add (prof->methods, method);
+       mono_os_mutex_unlock (&mutex);
+}
+
+static void
+prof_shutdown (MonoProfiler *prof);
+
+static void
+usage (int do_exit)
+{
+       printf ("AOT profiler.\n");
+       printf ("Usage: mono --profile=aot[:OPTION1[,OPTION2...]] program.exe\n");
+       printf ("Options:\n");
+       printf ("\thelp                 show this usage info\n");
+       printf ("\toutput=FILENAME      write the data to file FILENAME (required)\n");
+       printf ("\tverbose              print diagnostic info\n");
+       if (do_exit)
+               exit (1);
+}
+
+static const char*
+match_option (const char* p, const char *opt, char **rval)
+{
+       int len = strlen (opt);
+       if (strncmp (p, opt, len) == 0) {
+               if (rval) {
+                       if (p [len] == '=' && p [len + 1]) {
+                               const char *opt = p + len + 1;
+                               const char *end = strchr (opt, ',');
+                               char *val;
+                               int l;
+                               if (end == NULL) {
+                                       l = strlen (opt);
+                               } else {
+                                       l = end - opt;
+                               }
+                               val = (char *) g_malloc (l + 1);
+                               memcpy (val, opt, l);
+                               val [l] = 0;
+                               *rval = val;
+                               return opt + l;
+                       }
+                       if (p [len] == 0 || p [len] == ',') {
+                               *rval = NULL;
+                               return p + len + (p [len] == ',');
+                       }
+                       usage (1);
+               } else {
+                       if (p [len] == 0)
+                               return p + len;
+                       if (p [len] == ',')
+                               return p + len + 1;
+               }
+       }
+       return p;
+}
+
+void
+mono_profiler_startup (const char *desc);
+
+/**
+ * mono_profiler_startup:
+ * the entry point
+ */
+void
+mono_profiler_startup (const char *desc)
+{
+       MonoProfiler *prof;
+       const char *p;
+       const char *opt;
+       char *outfile_name;
+
+       p = desc;
+       if (strncmp (p, "aot", 3))
+               usage (1);
+       p += 3;
+       if (*p == ':')
+               p++;
+       for (; *p; p = opt) {
+               char *val;
+               if (*p == ',') {
+                       opt = p + 1;
+                       continue;
+               }
+               if ((opt = match_option (p, "help", NULL)) != p) {
+                       usage (0);
+                       continue;
+               }
+               if ((opt = match_option (p, "verbose", NULL)) != p) {
+                       verbose = TRUE;
+                       continue;
+               }
+               if ((opt = match_option (p, "output", &val)) != p) {
+                       outfile_name = val;
+                       continue;
+               }
+               fprintf (stderr, "mono-profiler-aot: Unknown option: '%s'.\n", p);
+               exit (1);
+       }
+
+       if (!outfile_name) {
+               fprintf (stderr, "mono-profiler-aot: The 'output' argument is required.\n");
+               exit (1);
+       }
+
+       prof = g_new0 (MonoProfiler, 1);
+       prof->images = g_hash_table_new (NULL, NULL);
+       prof->classes = g_hash_table_new (NULL, NULL);
+       prof->methods = g_ptr_array_new ();
+       prof->outfile_name = outfile_name;
+
+       mono_os_mutex_init (&mutex);
+
+       mono_profiler_install (prof, prof_shutdown);
+
+       mono_profiler_install_jit_compile (prof_jit_enter, prof_jit_leave);
+
+       mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION);
+}
+
+static void
+emit_byte (MonoProfiler *prof, guint8 value)
+{
+       fwrite (&value, 1, 1, prof->outfile);
+}
+
+static void
+emit_int32 (MonoProfiler *prof, int value)
+{
+       // FIXME: Endianness
+       fwrite (&value, 4, 1, prof->outfile);
+}
+
+static void
+emit_string (MonoProfiler *prof, const char *str)
+{
+       int len = strlen (str);
+
+       emit_int32 (prof, len);
+       fwrite (str, len, 1, prof->outfile);
+}
+
+static void
+emit_record (MonoProfiler *prof, AotProfRecordType type, int id)
+{
+       emit_byte (prof, type);
+       emit_int32 (prof, id);
+}
+
+static int
+add_image (MonoProfiler *prof, MonoImage *image)
+{
+       int id = GPOINTER_TO_INT (g_hash_table_lookup (prof->images, image));
+       if (id)
+               return id - 1;
+
+       id = prof->id ++;
+       emit_record (prof, AOTPROF_RECORD_IMAGE, id);
+       emit_string (prof, image->assembly->aname.name);
+       emit_string (prof, image->guid);
+       g_hash_table_insert (prof->images, image, GINT_TO_POINTER (id + 1));
+       return id;
+}
+
+static int
+add_class (MonoProfiler *prof, MonoClass *klass);
+
+static int
+add_type (MonoProfiler *prof, MonoType *type)
+{
+       switch (type->type) {
+#if 0
+       case MONO_TYPE_SZARRAY: {
+               int eid = add_type (prof, &type->data.klass->byval_arg);
+               if (eid == -1)
+                       return -1;
+               int id = prof->id ++;
+               emit_record (prof, AOTPROF_RECORD_TYPE, id);
+               emit_byte (prof, MONO_TYPE_SZARRAY);
+               emit_int32 (prof, id);
+               return id;
+       }
+#endif
+       case MONO_TYPE_BOOLEAN:
+       case MONO_TYPE_CHAR:
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1:
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+       case MONO_TYPE_R4:
+       case MONO_TYPE_R8:
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_VALUETYPE:
+       case MONO_TYPE_GENERICINST:
+               return add_class (prof, mono_class_from_mono_type (type));
+       default:
+               return -1;
+       }
+}
+
+static int
+add_ginst (MonoProfiler *prof, MonoGenericInst *inst)
+{
+       int i, id;
+       int *ids;
+
+       // FIXME: Cache
+       ids = g_malloc0 (inst->type_argc * sizeof (int));
+       for (i = 0; i < inst->type_argc; ++i) {
+               MonoType *t = inst->type_argv [i];
+               ids [i] = add_type (prof, t);
+               if (ids [i] == -1) {
+                       g_free (ids);
+                       return -1;
+               }
+       }
+       id = prof->id ++;
+       emit_record (prof, AOTPROF_RECORD_GINST, id);
+       emit_int32 (prof, inst->type_argc);
+       for (i = 0; i < inst->type_argc; ++i)
+               emit_int32 (prof, ids [i]);
+       g_free (ids);
+
+       return id;
+}
+
+static int
+add_class (MonoProfiler *prof, MonoClass *klass)
+{
+       int id, inst_id = -1, image_id;
+       char *name;
+
+       id = GPOINTER_TO_INT (g_hash_table_lookup (prof->classes, klass));
+       if (id)
+               return id - 1;
+
+       image_id = add_image (prof, klass->image);
+
+       if (mono_class_is_ginst (klass)) {
+               MonoGenericContext *ctx = mono_class_get_context (klass);
+               inst_id = add_ginst (prof, ctx->class_inst);
+               if (inst_id == -1)
+                       return -1;
+       }
+
+       if (klass->nested_in)
+               name = g_strdup_printf ("%s.%s/%s", klass->nested_in->name_space, klass->nested_in->name, klass->name);
+       else
+               name = g_strdup_printf ("%s.%s", klass->name_space, klass->name);
+
+       id = prof->id ++;
+       emit_record (prof, AOTPROF_RECORD_TYPE, id);
+       emit_byte (prof, MONO_TYPE_CLASS);
+       emit_int32 (prof, image_id);
+       emit_int32 (prof, inst_id);
+       emit_string (prof, name);
+       g_free (name);
+       g_hash_table_insert (prof->classes, klass, GINT_TO_POINTER (id + 1));
+       return id;
+}
+
+static void
+add_method (MonoProfiler *prof, MonoMethod *m)
+{
+       MonoError error;
+       MonoMethodSignature *sig;
+       char *s;
+
+       sig = mono_method_signature_checked (m, &error);
+       g_assert (mono_error_ok (&error));
+
+       int class_id = add_class (prof, m->klass);
+       if (class_id == -1)
+               return;
+       int inst_id = -1;
+
+       if (m->is_inflated) {
+               MonoGenericContext *ctx = mono_method_get_context (m);
+               if (ctx->method_inst)
+                       inst_id = add_ginst (prof, ctx->method_inst);
+       }
+       int id = prof->id ++;
+       emit_record (prof, AOTPROF_RECORD_METHOD, id);
+       emit_int32 (prof, class_id);
+       emit_int32 (prof, inst_id);
+       emit_int32 (prof, sig->param_count);
+       emit_string (prof, m->name);
+       s = mono_signature_full_name (sig);
+       emit_string (prof, s);
+       g_free (s);
+       if (verbose)
+               printf ("%s %d\n", mono_method_full_name (m, 1), id);
+}
+
+/* called at the end of the program */
+static void
+prof_shutdown (MonoProfiler *prof)
+{
+       FILE *outfile;
+       int mindex;
+       char magic [32];
+
+       printf ("Creating output file: %s\n", prof->outfile_name);
+
+       if (prof->outfile_name [0] == '#') {
+               int fd = strtol (prof->outfile_name + 1, NULL, 10);
+               outfile = fdopen (fd, "a");
+       } else {
+               outfile = fopen (prof->outfile_name, "w+");
+       }
+       if (!outfile) {
+               fprintf (stderr, "Unable to create output file '%s': %s.\n", prof->outfile_name, strerror (errno));
+               return;
+       }
+       prof->outfile = outfile;
+
+       gint32 version = (AOT_PROFILER_MAJOR_VERSION << 16) | AOT_PROFILER_MINOR_VERSION;
+       sprintf (magic, AOT_PROFILER_MAGIC);
+       fwrite (magic, strlen (magic), 1, outfile);
+       emit_int32 (prof, version);
+
+       GHashTable *all_methods = g_hash_table_new (NULL, NULL);
+       for (mindex = 0; mindex < prof->methods->len; ++mindex) {
+           MonoMethod *m = (MonoMethod*)g_ptr_array_index (prof->methods, mindex);
+
+               if (!mono_method_get_token (m))
+                       continue;
+
+               if (g_hash_table_lookup (all_methods, m))
+                       continue;
+               g_hash_table_insert (all_methods, m, m);
+
+               add_method (prof, m);
+       }
+       emit_record (prof, AOTPROF_RECORD_NONE, 0);
+
+       fclose (outfile);
+
+       g_hash_table_destroy (all_methods);
+       g_hash_table_destroy (prof->classes);
+       g_hash_table_destroy (prof->images);
+       g_ptr_array_free (prof->methods, TRUE);
+       g_free (prof->outfile_name);
+}
diff --git a/mono/profiler/aot.h b/mono/profiler/aot.h
new file mode 100644 (file)
index 0000000..7663cab
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __MONO_PROFILER_AOT_H__
+#define __MONO_PROFILER_AOT_H__
+
+#include <config.h>
+
+/*
+ * File format:
+ * - magic
+ * - major/minor version as an int, i.e. 0x00010001
+ * - sequence of records terminated by a record with type TYPE_NONE
+ * Record format:
+ * - 1 byte record type (AotProfRecordType)
+ * - 1 int record id
+ * - record specific data
+ * Encoding rules:
+ * - int - 4 bytes little endian
+ * - string - int length followed by data
+ */
+
+typedef enum {
+       AOTPROF_RECORD_NONE,
+       AOTPROF_RECORD_IMAGE,
+       AOTPROF_RECORD_TYPE,
+       AOTPROF_RECORD_GINST,
+       AOTPROF_RECORD_METHOD
+} AotProfRecordType;
+
+#define AOT_PROFILER_MAGIC "AOTPROFILE"
+
+#define AOT_PROFILER_MAJOR_VERSION 1
+#define AOT_PROFILER_MINOR_VERSION 0
+
+#endif /* __MONO_PROFILER_AOT_H__ */
diff --git a/mono/profiler/iomap.c b/mono/profiler/iomap.c
new file mode 100644 (file)
index 0000000..15baec0
--- /dev/null
@@ -0,0 +1,549 @@
+/*
+ * mono-profiler-iomap.c: IOMAP string profiler for Mono.
+ *
+ * Authors:
+ *   Marek Habersack <mhabersack@novell.com>
+ *
+ * Copyright (c) 2009 Novell, Inc (http://novell.com)
+ *
+ * Note: this profiler is completely unsafe wrt handling managed objects,
+ * don't use and don't copy code from here.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+#include "config.h"
+
+#include <string.h>
+#include <mono/utils/mono-io-portability.h>
+#include <mono/metadata/metadata.h>
+#include <mono/metadata/metadata-internals.h>
+#include <mono/metadata/class.h>
+#include <mono/metadata/class-internals.h>
+#include <mono/metadata/object-internals.h>
+#include <mono/metadata/image.h>
+#include <mono/metadata/mono-debug.h>
+#include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/threads.h>
+#include <mono/metadata/profiler.h>
+#include <mono/metadata/loader.h>
+#include <mono/utils/mono-os-mutex.h>
+
+#define LOCATION_INDENT "        "
+#define BACKTRACE_SIZE 64
+
+typedef struct _MonoStackBacktraceInfo 
+{
+       MonoMethod *method;
+       gint native_offset;
+} MonoStackBacktraceInfo;
+
+typedef struct 
+{
+       guint32 count;
+       gchar *requestedName;
+       gchar *actualName;
+} MismatchedFilesStats;
+
+typedef struct _SavedString
+{
+       MonoString *string;
+       MonoDomain *domain;
+       void *stack [BACKTRACE_SIZE];
+       gint stack_entries;
+       struct _SavedString *next;
+} SavedString;
+
+typedef struct _SavedStringFindInfo
+{
+       guint32 hash;
+       size_t len;
+} SavedStringFindInfo;
+
+typedef struct _StringLocation
+{
+       gchar *hint;
+       struct _StringLocation *next;
+} StringLocation;
+
+struct _MonoProfiler
+{
+       GHashTable *mismatched_files_hash;
+       GHashTable *saved_strings_hash;
+       GHashTable *string_locations_hash;
+       gboolean may_have_locations;
+};
+
+typedef struct _StackWalkData
+{
+       MonoProfiler *prof;
+       void **stack;
+       int stack_size;
+       int frame_count;
+} StackWalkData;
+
+static mono_mutex_t mismatched_files_section;
+static gboolean runtime_initialized = FALSE;
+
+static inline void append_report (GString **report, const gchar *format, ...);
+static inline void print_report (const gchar *format, ...);
+static inline guint32 do_calc_string_hash (guint32 hash, const gchar *str);
+static inline guint32 calc_strings_hash (const gchar *str1, const gchar *str2, guint32 *str1hash);
+static void print_mismatched_stats (MonoProfiler *prof);
+static inline gchar *build_hint (SavedString *head);
+static inline gchar *build_hint_from_stack (MonoDomain *domain, void **stack, gint stack_entries);
+static inline void store_string_location (MonoProfiler *prof, const gchar *string, guint32 hash, size_t len);
+static void mono_portability_remember_string (MonoProfiler *prof, MonoDomain *domain, MonoString *str);
+void mono_profiler_startup (const char *desc);
+
+static void mismatched_stats_foreach_func (gpointer key, gpointer value, gpointer user_data)
+{
+       MismatchedFilesStats *stats = (MismatchedFilesStats*)value;
+       StringLocation *location;
+       MonoProfiler *prof = (MonoProfiler*)user_data;
+       guint32 hash;
+       gboolean bannerShown = FALSE;
+
+       hash = do_calc_string_hash (0, stats->requestedName);
+       fprintf (stdout,
+                "    Count: %u\n"
+                "Requested: %s\n"
+                "   Actual: %s\n",
+                stats->count, stats->requestedName, stats->actualName);
+
+       if (!prof->may_have_locations) {
+               fprintf (stdout, "\n");
+               return;
+       }
+
+       location = (StringLocation *)g_hash_table_lookup (prof->string_locations_hash, &hash);
+       while (location) {
+               if (location->hint && strlen (location->hint) > 0) {
+                       if (!bannerShown) {
+                               fprintf (stdout, "Locations:\n");
+                               bannerShown = TRUE;
+                       }
+                       fprintf (stdout, "%s", location->hint);
+               }
+               location = location->next;
+               if (location)
+                       fprintf (stdout, LOCATION_INDENT "--\n");
+       }
+
+       fprintf (stdout, "\n");
+}
+
+static void print_mismatched_stats (MonoProfiler *prof)
+{
+       if (!prof->mismatched_files_hash || g_hash_table_size (prof->mismatched_files_hash) == 0)
+               return;
+
+       prof->may_have_locations = g_hash_table_size (prof->string_locations_hash) > 0;
+
+       fprintf (stdout, "\n-=-=-=-=-=-=-= MONO_IOMAP Stats -=-=-=-=-=-=-=\n");
+       g_hash_table_foreach (prof->mismatched_files_hash, mismatched_stats_foreach_func, (gpointer)prof);
+       fflush (stdout);
+}
+
+static guint mismatched_files_guint32_hash (gconstpointer key)
+{
+       if (!key)
+               return 0;
+
+       return *((guint32*)key);
+}
+
+static gboolean mismatched_files_guint32_equal (gconstpointer key1, gconstpointer key2)
+{
+       if (!key1 || !key2)
+               return FALSE;
+
+       return (gboolean)(*((guint32*)key1) == *((guint32*)key2));
+}
+
+static inline guint32 do_calc_string_hash (guint32 hash, const gchar *str)
+{
+       guint32 ret = hash;
+       gchar *cc = (gchar*)str;
+       gchar *end = (gchar*)(str + strlen (str) - 1);
+
+       for (; cc < end; cc += 2) {
+               ret = (ret << 5) - ret + *cc;
+               ret = (ret << 5) - ret + cc [1];
+       }
+       end++;
+       if (cc < end)
+               ret = (ret << 5) - ret + *cc;
+
+       return ret;
+}
+
+static inline guint32 calc_strings_hash (const gchar *str1, const gchar *str2, guint32 *str1hash)
+{
+       guint32 hash = do_calc_string_hash (0, str1);
+       if (str1hash)
+               *str1hash = hash;
+       return do_calc_string_hash (hash, str2);
+}
+
+static inline void print_report (const gchar *format, ...)
+{
+       MonoError error;
+       MonoClass *klass;
+       MonoProperty *prop;
+       MonoString *str;
+       char *stack_trace;
+       va_list ap;
+
+       fprintf (stdout, "-=-=-=-=-=-=- MONO_IOMAP REPORT -=-=-=-=-=-=-\n");
+       va_start (ap, format);
+       vfprintf (stdout, format, ap);
+       fprintf (stdout, "\n");
+       va_end (ap);
+       klass = mono_class_load_from_name (mono_get_corlib (), "System", "Environment");
+       mono_class_init (klass);
+       prop = mono_class_get_property_from_name (klass, "StackTrace");
+       str = (MonoString*)mono_property_get_value_checked (prop, NULL, NULL, &error);
+       mono_error_assert_ok (&error);
+       stack_trace = mono_string_to_utf8_checked (str, &error);
+       mono_error_assert_ok (&error);
+
+       fprintf (stdout, "-= Stack Trace =-\n%s\n\n", stack_trace);
+       g_free (stack_trace);
+       fflush (stdout);
+}
+
+static inline void append_report (GString **report, const gchar *format, ...)
+{
+       va_list ap;
+       if (!*report)
+               *report = g_string_new ("");
+
+       va_start (ap, format);
+       g_string_append_vprintf (*report, format, ap);
+       va_end (ap);
+}
+
+static gboolean saved_strings_find_func (gpointer key, gpointer value, gpointer user_data)
+{
+       MonoError error;
+       SavedStringFindInfo *info = (SavedStringFindInfo*)user_data;
+       SavedString *saved = (SavedString*)value;
+       gchar *utf_str;
+       guint32 hash;
+
+       if (!info || !saved || mono_string_length (saved->string) != info->len)
+               return FALSE;
+
+       utf_str = mono_string_to_utf8_checked (saved->string, &error);
+       mono_error_assert_ok (&error);
+       hash = do_calc_string_hash (0, utf_str);
+       g_free (utf_str);
+
+       if (hash != info->hash)
+               return FALSE;
+
+       return TRUE;
+}
+
+static inline void store_string_location (MonoProfiler *prof, const gchar *string, guint32 hash, size_t len)
+{
+       StringLocation *location = (StringLocation *)g_hash_table_lookup (prof->string_locations_hash, &hash);
+       SavedString *saved;
+       SavedStringFindInfo info;
+       guint32 *hashptr;
+
+       if (location)
+               return;
+
+       info.hash = hash;
+       info.len = len;
+
+       /* Expensive but unavoidable... */
+       saved = (SavedString*)g_hash_table_find (prof->saved_strings_hash, saved_strings_find_func, &info);
+       hashptr = (guint32*)g_malloc (sizeof (guint32));
+       *hashptr = hash;
+       location = (StringLocation*)g_malloc0 (sizeof (location));
+
+       g_hash_table_insert (prof->string_locations_hash, hashptr, location);
+       if (!saved)
+               return;
+
+       g_hash_table_remove (prof->saved_strings_hash, saved->string);
+       location->hint = build_hint (saved);
+}
+
+static gboolean ignore_frame (MonoMethod *method)
+{
+       MonoClass *klass = method->klass;
+
+       if (method->wrapper_type != MONO_WRAPPER_NONE)
+               return TRUE;
+
+       /* Now ignore the assemblies we know shouldn't contain mixed-case names (only the most frequent cases) */
+       if (klass->image ) {
+               if (strcmp (klass->image->assembly_name, "mscorlib") == 0)
+                       return TRUE;
+               else if (strcmp (klass->image->assembly_name, "System") == 0)
+                       return TRUE;
+               else if (strncmp (klass->image->assembly_name, "Mono.", 5) == 0)
+                       return TRUE;
+               else if (strncmp (klass->image->assembly_name, "System.", 7) == 0)
+                       return TRUE;
+               else if (strcmp (klass->image->assembly_name, "PEAPI") == 0)
+                       return TRUE;
+       }
+
+       return FALSE;
+}
+
+static inline gchar *build_hint_from_stack (MonoDomain *domain, void **stack, gint stack_entries)
+{
+       gchar *hint;
+       MonoMethod *method, *selectedMethod;
+       MonoAssembly *assembly;
+       MonoImage *image;
+       MonoDebugSourceLocation *location;
+       MonoStackBacktraceInfo *info;
+       gboolean use_full_trace;
+       char *methodName;
+       gint i, native_offset, firstAvailable;
+
+       selectedMethod = NULL;
+       firstAvailable = -1;
+       use_full_trace = FALSE;
+       native_offset = -1;
+       for (i = 0; i < stack_entries; i++) {
+               info = (MonoStackBacktraceInfo*) stack [i];
+               method = info ? info->method : NULL;
+
+               if (!method || method->wrapper_type != MONO_WRAPPER_NONE)
+                       continue;
+
+               if (firstAvailable == -1)
+                       firstAvailable = i;
+
+               image = method->klass->image;
+               assembly = image->assembly;
+
+               if ((assembly && assembly->in_gac) || ignore_frame (method))
+                       continue;
+               selectedMethod = method;
+               native_offset = info->native_offset;
+               break;
+       }
+
+       if (!selectedMethod) {
+               /* All the frames were from assemblies installed in GAC. Find first frame that is
+                * not in the ignore list */
+               for (i = 0; i < stack_entries; i++) {
+                       info = (MonoStackBacktraceInfo*) stack [i];
+                       method = info ? info->method : NULL;
+
+                       if (!method || ignore_frame (method))
+                               continue;
+                       selectedMethod = method;
+                       native_offset = info->native_offset;
+                       break;
+               }
+
+               if (!selectedMethod)
+                       use_full_trace = TRUE;
+       }
+
+       hint = NULL;
+       if (use_full_trace) {
+               GString *trace = g_string_new ("Full trace:\n");
+               for (i = firstAvailable; i < stack_entries; i++) {
+                       info = (MonoStackBacktraceInfo*) stack [i];
+                       method = info ? info->method : NULL;
+                       if (!method || method->wrapper_type != MONO_WRAPPER_NONE)
+                               continue;
+
+                       location = mono_debug_lookup_source_location (method, info->native_offset, domain);
+                       methodName = mono_method_full_name (method, TRUE);
+
+                       if (location) {
+                               append_report (&trace, LOCATION_INDENT "%s in %s:%u\n", methodName, location->source_file, location->row);
+                               mono_debug_free_source_location (location);
+                       } else
+                               append_report (&trace, LOCATION_INDENT "%s\n", methodName);
+                       g_free (methodName);
+               }
+
+               if (trace) {
+                       if (trace->len)
+                               hint = g_string_free (trace, FALSE);
+                       else
+                               g_string_free (trace, TRUE);
+               }
+       } else {
+               location = mono_debug_lookup_source_location (selectedMethod, native_offset, domain);
+               methodName = mono_method_full_name (selectedMethod, TRUE);
+
+               if (location) {
+                       hint = g_strdup_printf (LOCATION_INDENT "%s in %s:%u\n", methodName, location->source_file, location->row);
+                       mono_debug_free_source_location (location);
+               } else
+                       hint = g_strdup_printf (LOCATION_INDENT "%s\n", methodName);
+               g_free (methodName);
+       }
+
+       return hint;
+}
+
+static inline gchar *build_hint (SavedString *head)
+{
+       SavedString *current;
+       gchar *tmp;
+       GString *hint = NULL;
+
+       current = head;
+       while (current) {
+               tmp = build_hint_from_stack (current->domain, current->stack, current->stack_entries);
+               current = current->next;
+               if (!tmp)
+                       continue;
+
+               append_report (&hint, tmp);
+       }
+
+       if (hint) {
+               if (hint->len)
+                       return g_string_free (hint, FALSE);
+               else {
+                       g_string_free (hint, FALSE);
+                       return NULL;
+               }
+       }
+
+       return NULL;
+}
+
+static gboolean stack_walk_func (MonoMethod *method, gint32 native_offset, gint32 il_offset, gboolean managed, gpointer data)
+{
+       StackWalkData *swdata = (StackWalkData*)data;
+       MonoStackBacktraceInfo *info;
+
+       if (swdata->frame_count >= swdata->stack_size)
+               return TRUE;
+
+       info = (MonoStackBacktraceInfo*)g_malloc (sizeof (*info));
+       info->method = method;
+       info->native_offset = native_offset;
+
+       swdata->stack [swdata->frame_count++] = info;
+       return FALSE;
+}
+
+static inline int mono_stack_backtrace (MonoProfiler *prof, MonoDomain *domain, void **stack, int size)
+{
+       StackWalkData data;
+
+       data.prof = prof;
+       data.stack = stack;
+       data.stack_size = size;
+       data.frame_count = 0;
+
+       mono_stack_walk_no_il (stack_walk_func, (gpointer)&data);
+
+       return data.frame_count;
+}
+
+static void mono_portability_remember_string (MonoProfiler *prof, MonoDomain *domain, MonoString *str)
+{
+       SavedString *head, *entry;
+
+       if (!str || !domain || !runtime_initialized)
+               return;
+
+       entry = (SavedString*)g_malloc0 (sizeof (SavedString));
+       entry->string = str;
+       entry->domain = domain;
+       entry->stack_entries = mono_stack_backtrace (prof, domain, entry->stack, BACKTRACE_SIZE);
+       if (entry->stack_entries == 0) {
+               g_free (entry);
+               return;
+       }
+
+       mono_os_mutex_lock (&mismatched_files_section);
+       head = (SavedString*)g_hash_table_lookup (prof->saved_strings_hash, (gpointer)str);
+       if (head) {
+               while (head->next)
+                       head = head->next;
+               head->next = entry;
+       } else
+               g_hash_table_insert (prof->saved_strings_hash, (gpointer)str, (gpointer)entry);
+       mono_os_mutex_unlock (&mismatched_files_section);
+}
+
+static MonoClass *string_class = NULL;
+
+static void mono_portability_remember_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
+{
+       if (klass != string_class)
+               return;
+       mono_portability_remember_string (prof, mono_object_get_domain (obj), (MonoString*)obj);
+}
+
+static void mono_portability_iomap_event (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname)
+{
+       guint32 hash, pathnameHash;
+       MismatchedFilesStats *stats;
+
+       if (!runtime_initialized)
+               return;
+
+       mono_os_mutex_lock (&mismatched_files_section);
+       hash = calc_strings_hash (pathname, new_pathname, &pathnameHash);
+       stats = (MismatchedFilesStats*)g_hash_table_lookup (prof->mismatched_files_hash, &hash);
+       if (stats == NULL) {
+               guint32 *hashptr;
+
+               stats = (MismatchedFilesStats*) g_malloc (sizeof (MismatchedFilesStats));
+               stats->count = 1;
+               stats->requestedName = g_strdup (pathname);
+               stats->actualName = g_strdup (new_pathname);
+               hashptr = (guint32*)g_malloc (sizeof (guint32));
+               if (hashptr) {
+                       *hashptr = hash;
+                       g_hash_table_insert (prof->mismatched_files_hash, (gpointer)hashptr, stats);
+               } else
+                       g_error ("Out of memory allocating integer pointer for mismatched files hash table.");
+
+               store_string_location (prof, (const gchar*)stats->requestedName, pathnameHash, strlen (stats->requestedName));
+               mono_os_mutex_unlock (&mismatched_files_section);
+
+               print_report ("%s -     Found file path: '%s'\n", report, new_pathname);
+       } else {
+               mono_os_mutex_unlock (&mismatched_files_section);
+               stats->count++;
+       }
+}
+
+static void runtime_initialized_cb (MonoProfiler *prof)
+{
+       runtime_initialized = TRUE;
+       string_class = mono_get_string_class ();
+}
+
+static void profiler_shutdown (MonoProfiler *prof)
+{
+       print_mismatched_stats (prof);
+       mono_os_mutex_destroy (&mismatched_files_section);
+}
+
+void mono_profiler_startup (const char *desc)
+{
+       MonoProfiler *prof = g_new0 (MonoProfiler, 1);
+
+       mono_os_mutex_init (&mismatched_files_section);
+       prof->mismatched_files_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal);
+       prof->saved_strings_hash = g_hash_table_new (NULL, NULL);
+       prof->string_locations_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal);
+
+       mono_profiler_install (prof, profiler_shutdown);
+       mono_profiler_install_runtime_initialized (runtime_initialized_cb);
+       mono_profiler_install_iomap (mono_portability_iomap_event);
+       mono_profiler_install_allocation (mono_portability_remember_alloc);
+
+       mono_profiler_set_events ((MonoProfileFlags)(MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_IOMAP_EVENTS));
+}
diff --git a/mono/profiler/log-args.c b/mono/profiler/log-args.c
new file mode 100644 (file)
index 0000000..fbbafd4
--- /dev/null
@@ -0,0 +1,408 @@
+#include <config.h>
+
+#include "log.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SCHED_GETAFFINITY
+#include <sched.h>
+
+#  ifndef GLIBC_HAS_CPU_COUNT
+static int
+CPU_COUNT(cpu_set_t *set)
+{
+       int i, count = 0;
+
+       for (int i = 0; i < CPU_SETSIZE; i++)
+               if (CPU_ISSET(i, set))
+                       count++;
+       return count;
+}
+#  endif
+#endif
+
+typedef struct {
+       const char *event_name;
+       const int mask;
+} NameAndMask;
+
+static NameAndMask event_list[] = {
+       { "domain", PROFLOG_DOMAIN_EVENTS },
+       { "assembly", PROFLOG_ASSEMBLY_EVENTS },
+       { "module", PROFLOG_MODULE_EVENTS },
+       { "class", PROFLOG_CLASS_EVENTS },
+       { "jit", PROFLOG_JIT_COMPILATION_EVENTS },
+       { "exception", PROFLOG_EXCEPTION_EVENTS },
+       { "gcalloc", PROFLOG_ALLOCATION_EVENTS },
+       { "gc", PROFLOG_GC_EVENTS },
+       { "thread", PROFLOG_THREAD_EVENTS },
+       { "calls", PROFLOG_CALL_EVENTS },
+       //{ "inscov", PROFLOG_INS_COVERAGE_EVENTS }, //this is a profiler API event, but there's no actual event for us to emit here
+       //{ "sampling", PROFLOG_SAMPLING_EVENTS }, //it makes no sense to enable/disable this event by itself
+       { "monitor", PROFLOG_MONITOR_EVENTS },
+       { "gcmove", PROFLOG_GC_MOVES_EVENTS },
+       { "gcroot", PROFLOG_GC_ROOT_EVENTS },
+       { "context", PROFLOG_CONTEXT_EVENTS },
+       { "finalization", PROFLOG_FINALIZATION_EVENTS },
+       { "counter", PROFLOG_COUNTER_EVENTS },
+       { "gchandle", PROFLOG_GC_HANDLE_EVENTS },
+
+       { "typesystem", PROFLOG_TYPELOADING_ALIAS },
+       { "coverage", PROFLOG_CODECOV_ALIAS },
+       //{ "sample", PROFLOG_PERF_SAMPLING_ALIAS }, //takes args, explicitly handles
+       { "alloc", PROFLOG_GC_ALLOC_ALIAS },
+       //{ "heapshot", PROFLOG_HEAPSHOT_ALIAS }, //takes args, explicitly handled
+       { "legacy", PROFLOG_LEGACY_ALIAS },
+};
+
+static void usage (void);
+static void set_hsmode (ProfilerConfig *config, const char* val);
+static void set_sample_freq (ProfilerConfig *config, const char *val);
+static int mono_cpu_count (void);
+
+
+static gboolean
+match_option (const char *arg, const char *opt_name, const char **rval)
+{
+       if (rval) {
+               const char *end = strchr (arg, '=');
+
+               *rval = NULL;
+               if (!end)
+                       return !strcmp (arg, opt_name);
+
+               if (strncmp (arg, opt_name, strlen (opt_name)) || (end - arg) > strlen (opt_name) + 1)
+                       return FALSE;
+               *rval = end + 1;
+               return TRUE;
+       } else {
+               //FIXME how should we handle passing a value to an arg that doesn't expect it?
+               return !strcmp (arg, opt_name);
+       }
+}
+
+static void
+parse_arg (const char *arg, ProfilerConfig *config)
+{
+       const char *val;
+
+       if (match_option (arg, "help", NULL)) {
+               usage ();
+       } else if (match_option (arg, "report", NULL)) {
+               config->do_report = TRUE;
+       } else if (match_option (arg, "debug", NULL)) {
+               config->do_debug = TRUE;
+       } else if (match_option (arg, "debug-coverage", NULL)) {
+               config->debug_coverage = TRUE;
+       } else if (match_option (arg, "sampling-real", NULL)) {
+               config->sampling_mode = MONO_PROFILER_STAT_MODE_REAL;
+       } else if (match_option (arg, "sampling-process", NULL)) {
+               config->sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
+       } else if (match_option (arg, "heapshot", &val)) {
+               config->enable_mask |= PROFLOG_HEAPSHOT_ALIAS;
+               set_hsmode (config, val);
+       } else if (match_option (arg, "sample", &val)) {
+               config->enable_mask |= PROFLOG_PERF_SAMPLING_ALIAS;
+               set_sample_freq (config, val);
+       } else if (match_option (arg, "zip", NULL)) {
+               config->use_zip = TRUE;
+       } else if (match_option (arg, "output", &val)) {
+               config->output_filename = g_strdup (val);
+       } else if (match_option (arg, "port", &val)) {
+               char *end;
+               config->command_port = strtoul (val, &end, 10);
+       } else if (match_option (arg, "maxframes", &val)) {
+               char *end;
+               int num_frames = strtoul (val, &end, 10);
+               if (num_frames > MAX_FRAMES)
+                       num_frames = MAX_FRAMES;
+               config->notraces = num_frames == 0;
+               config->num_frames = num_frames;
+       } else if (match_option (arg, "maxsamples", &val)) {
+               char *end;
+               int max_samples = strtoul (val, &end, 10);
+               if (max_samples)
+                       config->max_allocated_sample_hits = max_samples;
+       } else if (match_option (arg, "calldepth", &val)) {
+               char *end;
+               config->max_call_depth = strtoul (val, &end, 10);
+       } else if (match_option (arg, "covfilter-file", &val)) {
+               if (config->cov_filter_files == NULL)
+                       config->cov_filter_files = g_ptr_array_new ();
+               g_ptr_array_add (config->cov_filter_files, g_strdup (val));
+       } else if (match_option (arg, "onlycoverage", NULL)) {
+               config->only_coverage = TRUE;
+       } else {
+               int i;
+
+               for (i = 0; i < G_N_ELEMENTS (event_list); ++i){
+                       if (!strcmp (arg, event_list [i].event_name)) {
+                               config->enable_mask |= event_list [i].mask;
+                               break;
+                       } else if (arg [0] == 'n' && arg [1] == 'o' && !strcmp (arg + 2, event_list [i].event_name)) {
+                               config->disable_mask |= event_list [i].mask;
+                       }
+               }
+               if (i == G_N_ELEMENTS (event_list)) {
+                       printf ("Could not parse argument %s\n", arg);
+               }
+       }
+}
+
+static void
+load_args_from_env_or_default (ProfilerConfig *config)
+{
+       //XXX change this to header constants
+
+       config->max_allocated_sample_hits = mono_cpu_count () * 1000;
+       config->sample_freq = 100;
+       config->max_call_depth = 100;
+       config->num_frames = MAX_FRAMES;
+}
+
+
+void
+proflog_parse_args (ProfilerConfig *config, const char *desc)
+{
+       const char *p;
+       gboolean in_quotes = FALSE;
+       char quote_char = '\0';
+       char *buffer = malloc (strlen (desc));
+       int buffer_pos = 0;
+
+       load_args_from_env_or_default (config);
+
+       for (p = desc; *p; p++){
+               switch (*p){
+               case ',':
+                       if (!in_quotes) {
+                               if (buffer_pos != 0){
+                                       buffer [buffer_pos] = 0;
+                                       parse_arg (buffer, config);
+                                       buffer_pos = 0;
+                               }
+                       } else {
+                               buffer [buffer_pos++] = *p;
+                       }
+                       break;
+
+               case '\\':
+                       if (p [1]) {
+                               buffer [buffer_pos++] = p[1];
+                               p++;
+                       }
+                       break;
+               case '\'':
+               case '"':
+                       if (in_quotes) {
+                               if (quote_char == *p)
+                                       in_quotes = FALSE;
+                               else
+                                       buffer [buffer_pos++] = *p;
+                       } else {
+                               in_quotes = TRUE;
+                               quote_char = *p;
+                       }
+                       break;
+               default:
+                       buffer [buffer_pos++] = *p;
+                       break;
+               }
+       }
+               
+       if (buffer_pos != 0) {
+               buffer [buffer_pos] = 0;
+               parse_arg (buffer, config);
+       }
+
+       g_free (buffer);
+
+       //Compure config effective mask
+       config->effective_mask = config->enable_mask & ~config->disable_mask;
+}
+
+static void
+set_hsmode (ProfilerConfig *config, const char* val)
+{
+       char *end;
+       unsigned int count;
+       if (!val)
+               return;
+       if (strcmp (val, "ondemand") == 0) {
+               config->hs_mode_ondemand = TRUE;
+               return;
+       }
+
+       count = strtoul (val, &end, 10);
+       if (val == end) {
+               usage ();
+               return;
+       }
+
+       if (strcmp (end, "ms") == 0)
+               config->hs_mode_ms = count;
+       else if (strcmp (end, "gc") == 0)
+               config->hs_mode_gc = count;
+       else
+               usage ();
+}
+
+/*
+Sampling frequency allows for one undocumented, hidden and ignored argument. The sampling kind.
+Back in the day when this was done using perf, we could specify one of: cycles,instr,cacherefs,cachemiss,branches,branchmiss
+With us moving ot userland sampling, those options are now meaningless.
+*/
+static void
+set_sample_freq (ProfilerConfig *config, const char *val)
+{
+       if (!val)
+               return;
+
+       const char *p = val;
+
+       // Is it only the frequency (new option style)?
+       if (isdigit (*p))
+               goto parse;
+
+       // Skip the sample type for backwards compatibility.
+       while (isalpha (*p))
+               p++;
+
+       // Skip the forward slash only if we got a sample type.
+       if (p != val && *p == '/') {
+               p++;
+
+               char *end;
+
+       parse:
+               config->sample_freq = strtoul (p, &end, 10);
+
+               if (p == end) {
+                       usage ();
+                       return; 
+               }
+
+               p = end;
+       }
+
+       if (*p)
+               usage ();
+}
+
+static void
+usage (void)
+{
+       printf ("Log profiler version %d.%d (format: %d)\n", LOG_VERSION_MAJOR, LOG_VERSION_MINOR, LOG_DATA_VERSION);
+       printf ("Usage: mono --profile=log[:OPTION1[,OPTION2...]] program.exe\n");
+       printf ("Options:\n");
+       printf ("\thelp                 show this usage info\n");
+       printf ("\t[no]'event'          enable/disable a profiling event. Valid values: domain, assembly, module, class, jit, exception, gcalloc, gc, thread, monitor, gcmove, gcroot, context, finalization, counter, gchandle\n");
+       printf ("\t[no]typesystem       enable/disable typesystem related events such as class and assembly loading\n");
+       printf ("\t[no]alloc            enable/disable recording allocation info\n");
+       printf ("\t[no]calls            enable/disable recording enter/leave method events\n");
+       printf ("\t[no]legacy           enable/disable pre mono 5.4 default profiler events\n");
+       printf ("\tsample[=frequency]   enable/disable statistical sampling of threads (frequency in Hz, 100 by default)\n");
+       printf ("\theapshot[=MODE]      record heap shot info (by default at each major collection)\n");
+       printf ("\t                     MODE: every XXms milliseconds, every YYgc collections, ondemand\n");
+       printf ("\t[no]coverage         enable collection of code coverage data\n");
+       printf ("\tcovfilter=ASSEMBLY   add an assembly to the code coverage filters\n");
+       printf ("\t                     add a + to include the assembly or a - to exclude it\n");
+       printf ("\t                     covfilter=-mscorlib\n");
+       printf ("\tcovfilter-file=FILE  use FILE to generate the list of assemblies to be filtered\n");
+       printf ("\tmaxframes=NUM        collect up to NUM stack frames\n");
+       printf ("\tcalldepth=NUM        ignore method events for call chain depth bigger than NUM\n");
+       printf ("\toutput=FILENAME      write the data to file FILENAME (The file is always overwriten)\n");
+       printf ("\toutput=+FILENAME     write the data to file FILENAME.pid (The file is always overwriten)\n");
+       printf ("\toutput=|PROGRAM      write the data to the stdin of PROGRAM\n");
+       printf ("\t                     %%t is subtituted with date and time, %%p with the pid\n");
+       printf ("\treport               create a report instead of writing the raw data to a file\n");
+       printf ("\tzip                  compress the output data\n");
+       printf ("\tport=PORTNUM         use PORTNUM for the listening command server\n");
+}
+
+static int
+mono_cpu_count (void)
+{
+#ifdef PLATFORM_ANDROID
+       /* Android tries really hard to save power by powering off CPUs on SMP phones which
+        * means the normal way to query cpu count returns a wrong value with userspace API.
+        * Instead we use /sys entries to query the actual hardware CPU count.
+        */
+       int count = 0;
+       char buffer[8] = {'\0'};
+       int present = open ("/sys/devices/system/cpu/present", O_RDONLY);
+       /* Format of the /sys entry is a cpulist of indexes which in the case
+        * of present is always of the form "0-(n-1)" when there is more than
+        * 1 core, n being the number of CPU cores in the system. Otherwise
+        * the value is simply 0
+        */
+       if (present != -1 && read (present, (char*)buffer, sizeof (buffer)) > 3)
+               count = strtol (((char*)buffer) + 2, NULL, 10);
+       if (present != -1)
+               close (present);
+       if (count > 0)
+               return count + 1;
+#endif
+
+#if defined(HOST_ARM) || defined (HOST_ARM64)
+
+       /* ARM platforms tries really hard to save power by powering off CPUs on SMP phones which
+        * means the normal way to query cpu count returns a wrong value with userspace API. */
+
+#ifdef _SC_NPROCESSORS_CONF
+       {
+               int count = sysconf (_SC_NPROCESSORS_CONF);
+               if (count > 0)
+                       return count;
+       }
+#endif
+
+#else
+
+#ifdef HAVE_SCHED_GETAFFINITY
+       {
+               cpu_set_t set;
+               if (sched_getaffinity (getpid (), sizeof (set), &set) == 0)
+                       return CPU_COUNT (&set);
+       }
+#endif
+#ifdef _SC_NPROCESSORS_ONLN
+       {
+               int count = sysconf (_SC_NPROCESSORS_ONLN);
+               if (count > 0)
+                       return count;
+       }
+#endif
+
+#endif /* defined(HOST_ARM) || defined (HOST_ARM64) */
+
+#ifdef USE_SYSCTL
+       {
+               int count;
+               int mib [2];
+               size_t len = sizeof (int);
+               mib [0] = CTL_HW;
+               mib [1] = HW_NCPU;
+               if (sysctl (mib, 2, &count, &len, NULL, 0) == 0)
+                       return count;
+       }
+#endif
+#ifdef HOST_WIN32
+       {
+               SYSTEM_INFO info;
+               GetSystemInfo (&info);
+               return info.dwNumberOfProcessors;
+       }
+#endif
+
+       static gboolean warned;
+
+       if (!warned) {
+               g_warning ("Don't know how to determine CPU count on this platform; assuming 1");
+               warned = TRUE;
+       }
+
+       return 1;
+}
\ No newline at end of file
diff --git a/mono/profiler/log.c b/mono/profiler/log.c
new file mode 100644 (file)
index 0000000..817ea4d
--- /dev/null
@@ -0,0 +1,4777 @@
+/*
+ * mono-profiler-log.c: mono log profiler
+ *
+ * Authors:
+ *   Paolo Molaro (lupus@ximian.com)
+ *   Alex Rønne Petersen (alexrp@xamarin.com)
+ *
+ * Copyright 2010 Novell, Inc (http://www.novell.com)
+ * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include <config.h>
+#include <mono/metadata/assembly.h>
+#include <mono/metadata/debug-helpers.h>
+#include "../metadata/metadata-internals.h"
+#include <mono/metadata/mono-config.h>
+#include <mono/metadata/mono-gc.h>
+#include <mono/metadata/mono-perfcounters.h>
+#include <mono/utils/atomic.h>
+#include <mono/utils/hazard-pointer.h>
+#include <mono/utils/lock-free-alloc.h>
+#include <mono/utils/lock-free-queue.h>
+#include <mono/utils/mono-conc-hashtable.h>
+#include <mono/utils/mono-counters.h>
+#include <mono/utils/mono-linked-list-set.h>
+#include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-mmap.h>
+#include <mono/utils/mono-os-mutex.h>
+#include <mono/utils/mono-os-semaphore.h>
+#include <mono/utils/mono-threads.h>
+#include <mono/utils/mono-threads-api.h>
+#include "log.h"
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+#include <fcntl.h>
+#ifdef HAVE_LINK_H
+#include <link.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if defined(__APPLE__)
+#include <mach/mach_time.h>
+#endif
+#include <netinet/in.h>
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+#include <sys/socket.h>
+#if defined (HAVE_SYS_ZLIB)
+#include <zlib.h>
+#endif
+
+#define BUFFER_SIZE (4096 * 16)
+
+/* Worst-case size in bytes of a 64-bit value encoded with LEB128. */
+#define LEB128_SIZE 10
+
+/* Size of a value encoded as a single byte. */
+#undef BYTE_SIZE // mach/i386/vm_param.h on OS X defines this to 8, but it isn't used for anything.
+#define BYTE_SIZE 1
+
+/* Size in bytes of the event prefix (ID + time). */
+#define EVENT_SIZE (BYTE_SIZE + LEB128_SIZE)
+
+static volatile gint32 runtime_inited;
+static volatile gint32 in_shutdown;
+
+static ProfilerConfig config;
+static int nocalls = 0;
+static int notraces = 0;
+static int use_zip = 0;
+static int do_report = 0;
+static int do_heap_shot = 0;
+static int max_call_depth = 0;
+static int command_port = 0;
+static int heapshot_requested = 0;
+static int do_mono_sample = 0;
+static int do_debug = 0;
+static int do_coverage = 0;
+static gboolean no_counters = FALSE;
+static gboolean only_coverage = FALSE;
+static gboolean debug_coverage = FALSE;
+static int max_allocated_sample_hits;
+
+#define ENABLED(EVT) (config.effective_mask & (EVT))
+
+// Statistics for internal profiler data structures.
+static gint32 sample_allocations_ctr,
+              buffer_allocations_ctr;
+
+// Statistics for profiler events.
+static gint32 sync_points_ctr,
+              heap_objects_ctr,
+              heap_starts_ctr,
+              heap_ends_ctr,
+              heap_roots_ctr,
+              gc_events_ctr,
+              gc_resizes_ctr,
+              gc_allocs_ctr,
+              gc_moves_ctr,
+              gc_handle_creations_ctr,
+              gc_handle_deletions_ctr,
+              finalize_begins_ctr,
+              finalize_ends_ctr,
+              finalize_object_begins_ctr,
+              finalize_object_ends_ctr,
+              image_loads_ctr,
+              image_unloads_ctr,
+              assembly_loads_ctr,
+              assembly_unloads_ctr,
+              class_loads_ctr,
+              class_unloads_ctr,
+              method_entries_ctr,
+              method_exits_ctr,
+              method_exception_exits_ctr,
+              method_jits_ctr,
+              code_buffers_ctr,
+              exception_throws_ctr,
+              exception_clauses_ctr,
+              monitor_contentions_ctr,
+              monitor_acquisitions_ctr,
+              monitor_failures_ctr,
+              thread_starts_ctr,
+              thread_ends_ctr,
+              thread_names_ctr,
+              domain_loads_ctr,
+              domain_unloads_ctr,
+              domain_names_ctr,
+              context_loads_ctr,
+              context_unloads_ctr,
+              sample_ubins_ctr,
+              sample_usyms_ctr,
+              sample_hits_ctr,
+              counter_descriptors_ctr,
+              counter_samples_ctr,
+              perfcounter_descriptors_ctr,
+              perfcounter_samples_ctr,
+              coverage_methods_ctr,
+              coverage_statements_ctr,
+              coverage_classes_ctr,
+              coverage_assemblies_ctr;
+
+static MonoLinkedListSet profiler_thread_list;
+
+/*
+ * file format:
+ * [header] [buffer]*
+ *
+ * The file is composed by a header followed by 0 or more buffers.
+ * Each buffer contains events that happened on a thread: for a given thread
+ * buffers that appear later in the file are guaranteed to contain events
+ * that happened later in time. Buffers from separate threads could be interleaved,
+ * though.
+ * Buffers are not required to be aligned.
+ *
+ * header format:
+ * [id: 4 bytes] constant value: LOG_HEADER_ID
+ * [major: 1 byte] [minor: 1 byte] major and minor version of the log profiler
+ * [format: 1 byte] version of the data format for the rest of the file
+ * [ptrsize: 1 byte] size in bytes of a pointer in the profiled program
+ * [startup time: 8 bytes] time in milliseconds since the unix epoch when the program started
+ * [timer overhead: 4 bytes] approximate overhead in nanoseconds of the timer
+ * [flags: 4 bytes] file format flags, should be 0 for now
+ * [pid: 4 bytes] pid of the profiled process
+ * [port: 2 bytes] tcp port for server if != 0
+ * [args size: 4 bytes] size of args
+ * [args: string] arguments passed to the profiler
+ * [arch size: 4 bytes] size of arch
+ * [arch: string] architecture the profiler is running on
+ * [os size: 4 bytes] size of os
+ * [os: string] operating system the profiler is running on
+ *
+ * The multiple byte integers are in little-endian format.
+ *
+ * buffer format:
+ * [buffer header] [event]*
+ * Buffers have a fixed-size header followed by 0 or more bytes of event data.
+ * Timing information and other values in the event data are usually stored
+ * as uleb128 or sleb128 integers. To save space, as noted for each item below,
+ * some data is represented as a difference between the actual value and
+ * either the last value of the same type (like for timing information) or
+ * as the difference from a value stored in a buffer header.
+ *
+ * For timing information the data is stored as uleb128, since timing
+ * increases in a monotonic way in each thread: the value is the number of
+ * nanoseconds to add to the last seen timing data in a buffer. The first value
+ * in a buffer will be calculated from the time_base field in the buffer head.
+ *
+ * Object or heap sizes are stored as uleb128.
+ * Pointer differences are stored as sleb128, instead.
+ *
+ * If an unexpected value is found, the rest of the buffer should be ignored,
+ * as generally the later values need the former to be interpreted correctly.
+ *
+ * buffer header format:
+ * [bufid: 4 bytes] constant value: BUF_ID
+ * [len: 4 bytes] size of the data following the buffer header
+ * [time_base: 8 bytes] time base in nanoseconds since an unspecified epoch
+ * [ptr_base: 8 bytes] base value for pointers
+ * [obj_base: 8 bytes] base value for object addresses
+ * [thread id: 8 bytes] system-specific thread ID (pthread_t for example)
+ * [method_base: 8 bytes] base value for MonoMethod pointers
+ *
+ * event format:
+ * [extended info: upper 4 bits] [type: lower 4 bits]
+ * [time diff: uleb128] nanoseconds since last timing
+ * [data]*
+ * The data that follows depends on type and the extended info.
+ * Type is one of the enum values in mono-profiler-log.h: TYPE_ALLOC, TYPE_GC,
+ * TYPE_METADATA, TYPE_METHOD, TYPE_EXCEPTION, TYPE_MONITOR, TYPE_HEAP.
+ * The extended info bits are interpreted based on type, see
+ * each individual event description below.
+ * strings are represented as a 0-terminated utf8 sequence.
+ *
+ * backtrace format:
+ * [num: uleb128] number of frames following
+ * [frame: sleb128]* mum MonoMethod* as a pointer difference from the last such
+ * pointer or the buffer method_base
+ *
+ * type alloc format:
+ * type: TYPE_ALLOC
+ * exinfo: flags: TYPE_ALLOC_BT
+ * [ptr: sleb128] class as a byte difference from ptr_base
+ * [obj: sleb128] object address as a byte difference from obj_base
+ * [size: uleb128] size of the object in the heap
+ * If the TYPE_ALLOC_BT flag is set, a backtrace follows.
+ *
+ * type GC format:
+ * type: TYPE_GC
+ * exinfo: one of TYPE_GC_EVENT, TYPE_GC_RESIZE, TYPE_GC_MOVE, TYPE_GC_HANDLE_CREATED[_BT],
+ * TYPE_GC_HANDLE_DESTROYED[_BT], TYPE_GC_FINALIZE_START, TYPE_GC_FINALIZE_END,
+ * TYPE_GC_FINALIZE_OBJECT_START, TYPE_GC_FINALIZE_OBJECT_END
+ * if exinfo == TYPE_GC_RESIZE
+ *     [heap_size: uleb128] new heap size
+ * if exinfo == TYPE_GC_EVENT
+ *     [event type: byte] GC event (MONO_GC_EVENT_* from profiler.h)
+ *     [generation: byte] GC generation event refers to
+ * if exinfo == TYPE_GC_MOVE
+ *     [num_objects: uleb128] number of object moves that follow
+ *     [objaddr: sleb128]+ num_objects object pointer differences from obj_base
+ *     num is always an even number: the even items are the old
+ *     addresses, the odd numbers are the respective new object addresses
+ * if exinfo == TYPE_GC_HANDLE_CREATED[_BT]
+ *     [handle_type: uleb128] GC handle type (System.Runtime.InteropServices.GCHandleType)
+ *     upper bits reserved as flags
+ *     [handle: uleb128] GC handle value
+ *     [objaddr: sleb128] object pointer differences from obj_base
+ *     If exinfo == TYPE_GC_HANDLE_CREATED_BT, a backtrace follows.
+ * if exinfo == TYPE_GC_HANDLE_DESTROYED[_BT]
+ *     [handle_type: uleb128] GC handle type (System.Runtime.InteropServices.GCHandleType)
+ *     upper bits reserved as flags
+ *     [handle: uleb128] GC handle value
+ *     If exinfo == TYPE_GC_HANDLE_DESTROYED_BT, a backtrace follows.
+ * if exinfo == TYPE_GC_FINALIZE_OBJECT_{START,END}
+ *     [object: sleb128] the object as a difference from obj_base
+ *
+ * type metadata format:
+ * type: TYPE_METADATA
+ * exinfo: one of: TYPE_END_LOAD, TYPE_END_UNLOAD (optional for TYPE_THREAD and TYPE_DOMAIN)
+ * [mtype: byte] metadata type, one of: TYPE_CLASS, TYPE_IMAGE, TYPE_ASSEMBLY, TYPE_DOMAIN,
+ * TYPE_THREAD, TYPE_CONTEXT
+ * [pointer: sleb128] pointer of the metadata type depending on mtype
+ * if mtype == TYPE_CLASS
+ *     [image: sleb128] MonoImage* as a pointer difference from ptr_base
+ *     [name: string] full class name
+ * if mtype == TYPE_IMAGE
+ *     [name: string] image file name
+ * if mtype == TYPE_ASSEMBLY
+ *     [name: string] assembly name
+ * if mtype == TYPE_DOMAIN && exinfo == 0
+ *     [name: string] domain friendly name
+ * if mtype == TYPE_CONTEXT
+ *     [domain: sleb128] domain id as pointer
+ * if mtype == TYPE_THREAD && exinfo == 0
+ *     [name: string] thread name
+ *
+ * type method format:
+ * type: TYPE_METHOD
+ * exinfo: one of: TYPE_LEAVE, TYPE_ENTER, TYPE_EXC_LEAVE, TYPE_JIT
+ * [method: sleb128] MonoMethod* as a pointer difference from the last such
+ * pointer or the buffer method_base
+ * if exinfo == TYPE_JIT
+ *     [code address: sleb128] pointer to the native code as a diff from ptr_base
+ *     [code size: uleb128] size of the generated code
+ *     [name: string] full method name
+ *
+ * type exception format:
+ * type: TYPE_EXCEPTION
+ * exinfo: TYPE_THROW_BT flag or one of: TYPE_CLAUSE
+ * if exinfo == TYPE_CLAUSE
+ *     [clause type: byte] MonoExceptionEnum enum value
+ *     [clause index: uleb128] index of the current clause
+ *     [method: sleb128] MonoMethod* as a pointer difference from the last such
+ *     pointer or the buffer method_base
+ * else
+ *     [object: sleb128] the exception object as a difference from obj_base
+ *     if exinfo has TYPE_THROW_BT set, a backtrace follows.
+ *
+ * type runtime format:
+ * type: TYPE_RUNTIME
+ * exinfo: one of: TYPE_JITHELPER
+ * if exinfo == TYPE_JITHELPER
+ *     [type: byte] MonoProfilerCodeBufferType enum value
+ *     [buffer address: sleb128] pointer to the native code as a diff from ptr_base
+ *     [buffer size: uleb128] size of the generated code
+ *     if type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE
+ *             [name: string] buffer description name
+ *
+ * type monitor format:
+ * type: TYPE_MONITOR
+ * exinfo: TYPE_MONITOR_BT flag and one of: MONO_PROFILER_MONITOR_(CONTENTION|FAIL|DONE)
+ * [object: sleb128] the lock object as a difference from obj_base
+ * if exinfo.low3bits == MONO_PROFILER_MONITOR_CONTENTION
+ *     If the TYPE_MONITOR_BT flag is set, a backtrace follows.
+ *
+ * type heap format
+ * type: TYPE_HEAP
+ * exinfo: one of TYPE_HEAP_START, TYPE_HEAP_END, TYPE_HEAP_OBJECT, TYPE_HEAP_ROOT
+ * if exinfo == TYPE_HEAP_OBJECT
+ *     [object: sleb128] the object as a difference from obj_base
+ *     [class: sleb128] the object MonoClass* as a difference from ptr_base
+ *     [size: uleb128] size of the object on the heap
+ *     [num_refs: uleb128] number of object references
+ *     each referenced objref is preceded by a uleb128 encoded offset: the
+ *     first offset is from the object address and each next offset is relative
+ *     to the previous one
+ *     [objrefs: sleb128]+ object referenced as a difference from obj_base
+ *     The same object can appear multiple times, but only the first time
+ *     with size != 0: in the other cases this data will only be used to
+ *     provide additional referenced objects.
+ * if exinfo == TYPE_HEAP_ROOT
+ *     [num_roots: uleb128] number of root references
+ *     [num_gc: uleb128] number of major gcs
+ *     [object: sleb128] the object as a difference from obj_base
+ *     [root_type: byte] the root_type: MonoProfileGCRootType (profiler.h)
+ *     [extra_info: uleb128] the extra_info value
+ *     object, root_type and extra_info are repeated num_roots times
+ *
+ * type sample format
+ * type: TYPE_SAMPLE
+ * exinfo: one of TYPE_SAMPLE_HIT, TYPE_SAMPLE_USYM, TYPE_SAMPLE_UBIN, TYPE_SAMPLE_COUNTERS_DESC, TYPE_SAMPLE_COUNTERS
+ * if exinfo == TYPE_SAMPLE_HIT
+ *     [thread: sleb128] thread id as difference from ptr_base
+ *     [count: uleb128] number of following instruction addresses
+ *     [ip: sleb128]* instruction pointer as difference from ptr_base
+ *     [mbt_count: uleb128] number of managed backtrace frames
+ *     [method: sleb128]* MonoMethod* as a pointer difference from the last such
+ *     pointer or the buffer method_base (the first such method can be also indentified by ip, but this is not neccessarily true)
+ * if exinfo == TYPE_SAMPLE_USYM
+ *     [address: sleb128] symbol address as a difference from ptr_base
+ *     [size: uleb128] symbol size (may be 0 if unknown)
+ *     [name: string] symbol name
+ * if exinfo == TYPE_SAMPLE_UBIN
+ *     [address: sleb128] address where binary has been loaded
+ *     [offset: uleb128] file offset of mapping (the same file can be mapped multiple times)
+ *     [size: uleb128] memory size
+ *     [name: string] binary name
+ * if exinfo == TYPE_SAMPLE_COUNTERS_DESC
+ *     [len: uleb128] number of counters
+ *     for i = 0 to len
+ *             [section: uleb128] section of counter
+ *             if section == MONO_COUNTER_PERFCOUNTERS:
+ *                     [section_name: string] section name of counter
+ *             [name: string] name of counter
+ *             [type: byte] type of counter
+ *             [unit: byte] unit of counter
+ *             [variance: byte] variance of counter
+ *             [index: uleb128] unique index of counter
+ * if exinfo == TYPE_SAMPLE_COUNTERS
+ *     while true:
+ *             [index: uleb128] unique index of counter
+ *             if index == 0:
+ *                     break
+ *             [type: byte] type of counter value
+ *             if type == string:
+ *                     if value == null:
+ *                             [0: uleb128] 0 -> value is null
+ *                     else:
+ *                             [1: uleb128] 1 -> value is not null
+ *                             [value: string] counter value
+ *             else:
+ *                     [value: uleb128/sleb128/double] counter value, can be sleb128, uleb128 or double (determined by using type)
+ *
+ * type coverage format
+ * type: TYPE_COVERAGE
+ * exinfo: one of TYPE_COVERAGE_METHOD, TYPE_COVERAGE_STATEMENT, TYPE_COVERAGE_ASSEMBLY, TYPE_COVERAGE_CLASS
+ * if exinfo == TYPE_COVERAGE_METHOD
+ *  [assembly: string] name of assembly
+ *  [class: string] name of the class
+ *  [name: string] name of the method
+ *  [signature: string] the signature of the method
+ *  [filename: string] the file path of the file that contains this method
+ *  [token: uleb128] the method token
+ *  [method_id: uleb128] an ID for this data to associate with the buffers of TYPE_COVERAGE_STATEMENTS
+ *  [len: uleb128] the number of TYPE_COVERAGE_BUFFERS associated with this method
+ * if exinfo == TYPE_COVERAGE_STATEMENTS
+ *  [method_id: uleb128] an the TYPE_COVERAGE_METHOD buffer to associate this with
+ *  [offset: uleb128] the il offset relative to the previous offset
+ *  [counter: uleb128] the counter for this instruction
+ *  [line: uleb128] the line of filename containing this instruction
+ *  [column: uleb128] the column containing this instruction
+ * if exinfo == TYPE_COVERAGE_ASSEMBLY
+ *  [name: string] assembly name
+ *  [guid: string] assembly GUID
+ *  [filename: string] assembly filename
+ *  [number_of_methods: uleb128] the number of methods in this assembly
+ *  [fully_covered: uleb128] the number of fully covered methods
+ *  [partially_covered: uleb128] the number of partially covered methods
+ *    currently partially_covered will always be 0, and fully_covered is the
+ *    number of methods that are fully and partially covered.
+ * if exinfo == TYPE_COVERAGE_CLASS
+ *  [name: string] assembly name
+ *  [class: string] class name
+ *  [number_of_methods: uleb128] the number of methods in this class
+ *  [fully_covered: uleb128] the number of fully covered methods
+ *  [partially_covered: uleb128] the number of partially covered methods
+ *    currently partially_covered will always be 0, and fully_covered is the
+ *    number of methods that are fully and partially covered.
+ *
+ * type meta format:
+ * type: TYPE_META
+ * exinfo: one of: TYPE_SYNC_POINT
+ * if exinfo == TYPE_SYNC_POINT
+ *     [type: byte] MonoProfilerSyncPointType enum value
+ */
+
+// Pending data to be written to the log, for a single thread.
+// Threads periodically flush their own LogBuffers by calling safe_send
+typedef struct _LogBuffer LogBuffer;
+struct _LogBuffer {
+       // Next (older) LogBuffer in processing queue
+       LogBuffer *next;
+
+       uint64_t time_base;
+       uint64_t last_time;
+       uintptr_t ptr_base;
+       uintptr_t method_base;
+       uintptr_t last_method;
+       uintptr_t obj_base;
+       uintptr_t thread_id;
+
+       // Bytes allocated for this LogBuffer
+       int size;
+
+       // Start of currently unused space in buffer
+       unsigned char* cursor;
+
+       // Pointer to start-of-structure-plus-size (for convenience)
+       unsigned char* buf_end;
+
+       // Start of data in buffer. Contents follow "buffer format" described above.
+       unsigned char buf [1];
+};
+
+typedef struct {
+       MonoLinkedListSetNode node;
+
+       // Convenience pointer to the profiler structure.
+       MonoProfiler *profiler;
+
+       // Was this thread added to the LLS?
+       gboolean attached;
+
+       // The current log buffer for this thread.
+       LogBuffer *buffer;
+
+       // Methods referenced by events in `buffer`, see `MethodInfo`.
+       GPtrArray *methods;
+
+       // Current call depth for enter/leave events.
+       int call_depth;
+
+       // Indicates whether this thread is currently writing to its `buffer`.
+       gboolean busy;
+
+       // Has this thread written a thread end event to `buffer`?
+       gboolean ended;
+} MonoProfilerThread;
+
+static uintptr_t
+thread_id (void)
+{
+       return (uintptr_t) mono_native_thread_id_get ();
+}
+
+static uintptr_t
+process_id (void)
+{
+#ifdef HOST_WIN32
+       return (uintptr_t) GetCurrentProcessId ();
+#else
+       return (uintptr_t) getpid ();
+#endif
+}
+
+#ifdef __APPLE__
+static mach_timebase_info_data_t timebase_info;
+#elif defined (HOST_WIN32)
+static LARGE_INTEGER pcounter_freq;
+#endif
+
+#define TICKS_PER_SEC 1000000000LL
+
+static uint64_t
+current_time (void)
+{
+#ifdef __APPLE__
+       uint64_t time = mach_absolute_time ();
+
+       time *= timebase_info.numer;
+       time /= timebase_info.denom;
+
+       return time;
+#elif defined (HOST_WIN32)
+       LARGE_INTEGER value;
+
+       QueryPerformanceCounter (&value);
+
+       return value.QuadPart * TICKS_PER_SEC / pcounter_freq.QuadPart;
+#elif defined (CLOCK_MONOTONIC)
+       struct timespec tspec;
+
+       clock_gettime (CLOCK_MONOTONIC, &tspec);
+
+       return ((uint64_t) tspec.tv_sec * TICKS_PER_SEC + tspec.tv_nsec);
+#else
+       struct timeval tv;
+
+       gettimeofday (&tv, NULL);
+
+       return ((uint64_t) tv.tv_sec * TICKS_PER_SEC + tv.tv_usec * 1000);
+#endif
+}
+
+static int timer_overhead;
+
+static void
+init_time (void)
+{
+#ifdef __APPLE__
+       mach_timebase_info (&timebase_info);
+#elif defined (HOST_WIN32)
+       QueryPerformanceFrequency (&pcounter_freq);
+#endif
+
+       uint64_t time_start = current_time ();
+
+       for (int i = 0; i < 256; ++i)
+               current_time ();
+
+       uint64_t time_end = current_time ();
+
+       timer_overhead = (time_end - time_start) / 256;
+}
+
+/*
+ * These macros should be used when writing an event to a log buffer. They take
+ * care of a bunch of stuff that can be repetitive and error-prone, such as
+ * acquiring/releasing the buffer lock, incrementing the event counter,
+ * expanding the log buffer, processing requests, etc. They also create a scope
+ * so that it's harder to leak the LogBuffer pointer, which can be problematic
+ * as the pointer is unstable when the buffer lock isn't acquired.
+ */
+
+#define ENTER_LOG(COUNTER, BUFFER, SIZE) \
+       do { \
+               MonoProfilerThread *thread__ = PROF_TLS_GET (); \
+               if (thread__->attached) \
+                       buffer_lock (); \
+               g_assert (!thread__->busy && "Why are we trying to write a new event while already writing one?"); \
+               thread__->busy = TRUE; \
+               InterlockedIncrement ((COUNTER)); \
+               LogBuffer *BUFFER = ensure_logbuf_unsafe (thread__, (SIZE))
+
+#define EXIT_LOG_EXPLICIT(SEND) \
+               thread__->busy = FALSE; \
+               if ((SEND)) \
+                       send_log_unsafe (TRUE); \
+               if (thread__->attached) \
+                       buffer_unlock (); \
+       } while (0)
+
+// Pass these to EXIT_LOG_EXPLICIT () for easier reading.
+#define DO_SEND TRUE
+#define NO_SEND FALSE
+
+#define EXIT_LOG EXIT_LOG_EXPLICIT (DO_SEND)
+
+static volatile gint32 buffer_rwlock_count;
+static volatile gpointer buffer_rwlock_exclusive;
+
+// Can be used recursively.
+static void
+buffer_lock (void)
+{
+       /*
+        * If the thread holding the exclusive lock tries to modify the
+        * reader count, just make it a no-op. This way, we also avoid
+        * invoking the GC safe point macros below, which could break if
+        * done from a thread that is currently the initiator of STW.
+        *
+        * In other words, we rely on the fact that the GC thread takes
+        * the exclusive lock in the gc_event () callback when the world
+        * is about to stop.
+        */
+       if (InterlockedReadPointer (&buffer_rwlock_exclusive) != (gpointer) thread_id ()) {
+               MONO_ENTER_GC_SAFE;
+
+               while (InterlockedReadPointer (&buffer_rwlock_exclusive))
+                       mono_thread_info_yield ();
+
+               InterlockedIncrement (&buffer_rwlock_count);
+
+               MONO_EXIT_GC_SAFE;
+       }
+
+       mono_memory_barrier ();
+}
+
+static void
+buffer_unlock (void)
+{
+       mono_memory_barrier ();
+
+       // See the comment in buffer_lock ().
+       if (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id ())
+               return;
+
+       g_assert (InterlockedRead (&buffer_rwlock_count) && "Why are we trying to decrement a zero reader count?");
+
+       InterlockedDecrement (&buffer_rwlock_count);
+}
+
+// Cannot be used recursively.
+static void
+buffer_lock_excl (void)
+{
+       gpointer tid = (gpointer) thread_id ();
+
+       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) != tid && "Why are we taking the exclusive lock twice?");
+
+       MONO_ENTER_GC_SAFE;
+
+       while (InterlockedCompareExchangePointer (&buffer_rwlock_exclusive, tid, 0))
+               mono_thread_info_yield ();
+
+       while (InterlockedRead (&buffer_rwlock_count))
+               mono_thread_info_yield ();
+
+       MONO_EXIT_GC_SAFE;
+
+       mono_memory_barrier ();
+}
+
+static void
+buffer_unlock_excl (void)
+{
+       mono_memory_barrier ();
+
+       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) && "Why is the exclusive lock not held?");
+       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id () && "Why does another thread hold the exclusive lock?");
+       g_assert (!InterlockedRead (&buffer_rwlock_count) && "Why are there readers when the exclusive lock is held?");
+
+       InterlockedWritePointer (&buffer_rwlock_exclusive, NULL);
+}
+
+typedef struct _BinaryObject BinaryObject;
+struct _BinaryObject {
+       BinaryObject *next;
+       void *addr;
+       char *name;
+};
+
+struct _MonoProfiler {
+       FILE* file;
+#if defined (HAVE_SYS_ZLIB)
+       gzFile gzfile;
+#endif
+       char *args;
+       uint64_t startup_time;
+       int pipe_output;
+       int command_port;
+       int server_socket;
+       int pipes [2];
+       MonoNativeThreadId helper_thread;
+       MonoNativeThreadId writer_thread;
+       MonoNativeThreadId dumper_thread;
+       volatile gint32 run_writer_thread;
+       MonoLockFreeAllocSizeClass writer_entry_size_class;
+       MonoLockFreeAllocator writer_entry_allocator;
+       MonoLockFreeQueue writer_queue;
+       MonoSemType writer_queue_sem;
+       MonoConcurrentHashTable *method_table;
+       mono_mutex_t method_table_mutex;
+       volatile gint32 run_dumper_thread;
+       MonoLockFreeQueue dumper_queue;
+       MonoSemType dumper_queue_sem;
+       MonoLockFreeAllocSizeClass sample_size_class;
+       MonoLockFreeAllocator sample_allocator;
+       MonoLockFreeQueue sample_reuse_queue;
+       BinaryObject *binary_objects;
+       GPtrArray *coverage_filters;
+};
+
+typedef struct {
+       MonoLockFreeQueueNode node;
+       GPtrArray *methods;
+       LogBuffer *buffer;
+} WriterQueueEntry;
+
+#define WRITER_ENTRY_BLOCK_SIZE (mono_pagesize ())
+
+typedef struct {
+       MonoMethod *method;
+       MonoJitInfo *ji;
+       uint64_t time;
+} MethodInfo;
+
+#ifdef HOST_WIN32
+
+#define PROF_TLS_SET(VAL) (TlsSetValue (profiler_tls, (VAL)))
+#define PROF_TLS_GET() ((MonoProfilerThread *) TlsGetValue (profiler_tls))
+#define PROF_TLS_INIT() (profiler_tls = TlsAlloc ())
+#define PROF_TLS_FREE() (TlsFree (profiler_tls))
+
+static DWORD profiler_tls;
+
+#elif HAVE_KW_THREAD
+
+#define PROF_TLS_SET(VAL) (profiler_tls = (VAL))
+#define PROF_TLS_GET() (profiler_tls)
+#define PROF_TLS_INIT()
+#define PROF_TLS_FREE()
+
+static __thread MonoProfilerThread *profiler_tls;
+
+#else
+
+#define PROF_TLS_SET(VAL) (pthread_setspecific (profiler_tls, (VAL)))
+#define PROF_TLS_GET() ((MonoProfilerThread *) pthread_getspecific (profiler_tls))
+#define PROF_TLS_INIT() (pthread_key_create (&profiler_tls, NULL))
+#define PROF_TLS_FREE() (pthread_key_delete (profiler_tls))
+
+static pthread_key_t profiler_tls;
+
+#endif
+
+static char*
+pstrdup (const char *s)
+{
+       int len = strlen (s) + 1;
+       char *p = (char *) g_malloc (len);
+       memcpy (p, s, len);
+       return p;
+}
+
+static void *
+alloc_buffer (int size)
+{
+       return mono_valloc (NULL, size, MONO_MMAP_READ | MONO_MMAP_WRITE | MONO_MMAP_ANON | MONO_MMAP_PRIVATE, MONO_MEM_ACCOUNT_PROFILER);
+}
+
+static void
+free_buffer (void *buf, int size)
+{
+       mono_vfree (buf, size, MONO_MEM_ACCOUNT_PROFILER);
+}
+
+static LogBuffer*
+create_buffer (uintptr_t tid)
+{
+       LogBuffer* buf = (LogBuffer *) alloc_buffer (BUFFER_SIZE);
+
+       InterlockedIncrement (&buffer_allocations_ctr);
+
+       buf->size = BUFFER_SIZE;
+       buf->time_base = current_time ();
+       buf->last_time = buf->time_base;
+       buf->buf_end = (unsigned char *) buf + buf->size;
+       buf->cursor = buf->buf;
+       buf->thread_id = tid;
+
+       return buf;
+}
+
+/*
+ * Must be called with the reader lock held if thread is the current thread, or
+ * the exclusive lock if thread is a different thread. However, if thread is
+ * the current thread, and init_thread () was called with add_to_lls = FALSE,
+ * then no locking is necessary.
+ */
+static void
+init_buffer_state (MonoProfilerThread *thread)
+{
+       thread->buffer = create_buffer (thread->node.key);
+       thread->methods = NULL;
+}
+
+static void
+clear_hazard_pointers (MonoThreadHazardPointers *hp)
+{
+       mono_hazard_pointer_clear (hp, 0);
+       mono_hazard_pointer_clear (hp, 1);
+       mono_hazard_pointer_clear (hp, 2);
+}
+
+static MonoProfilerThread *
+init_thread (MonoProfiler *prof, gboolean add_to_lls)
+{
+       MonoProfilerThread *thread = PROF_TLS_GET ();
+
+       /*
+        * Sometimes we may try to initialize a thread twice. One example is the
+        * main thread: We initialize it when setting up the profiler, but we will
+        * also get a thread_start () callback for it. Another example is when
+        * attaching new threads to the runtime: We may get a gc_alloc () callback
+        * for that thread's thread object (where we initialize it), soon followed
+        * by a thread_start () callback.
+        *
+        * These cases are harmless anyhow. Just return if we've already done the
+        * initialization work.
+        */
+       if (thread)
+               return thread;
+
+       thread = g_malloc (sizeof (MonoProfilerThread));
+       thread->node.key = thread_id ();
+       thread->profiler = prof;
+       thread->attached = add_to_lls;
+       thread->call_depth = 0;
+       thread->busy = 0;
+       thread->ended = FALSE;
+
+       init_buffer_state (thread);
+
+       /*
+        * Some internal profiler threads don't need to be cleaned up
+        * by the main thread on shutdown.
+        */
+       if (add_to_lls) {
+               MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
+               g_assert (mono_lls_insert (&profiler_thread_list, hp, &thread->node) && "Why can't we insert the thread in the LLS?");
+               clear_hazard_pointers (hp);
+       }
+
+       PROF_TLS_SET (thread);
+
+       return thread;
+}
+
+// Only valid if init_thread () was called with add_to_lls = FALSE.
+static void
+deinit_thread (MonoProfilerThread *thread)
+{
+       g_assert (!thread->attached && "Why are we manually freeing an attached thread?");
+
+       g_free (thread);
+       PROF_TLS_SET (NULL);
+}
+
+// Only valid if init_thread () was called with add_to_lls = FALSE.
+static LogBuffer *
+ensure_logbuf_unsafe (MonoProfilerThread *thread, int bytes)
+{
+       LogBuffer *old = thread->buffer;
+
+       if (old && old->cursor + bytes + 100 < old->buf_end)
+               return old;
+
+       LogBuffer *new_ = create_buffer (thread->node.key);
+       new_->next = old;
+       thread->buffer = new_;
+
+       return new_;
+}
+
+static void
+encode_uleb128 (uint64_t value, uint8_t *buf, uint8_t **endbuf)
+{
+       uint8_t *p = buf;
+
+       do {
+               uint8_t b = value & 0x7f;
+               value >>= 7;
+
+               if (value != 0) /* more bytes to come */
+                       b |= 0x80;
+
+               *p ++ = b;
+       } while (value);
+
+       *endbuf = p;
+}
+
+static void
+encode_sleb128 (intptr_t value, uint8_t *buf, uint8_t **endbuf)
+{
+       int more = 1;
+       int negative = (value < 0);
+       unsigned int size = sizeof (intptr_t) * 8;
+       uint8_t byte;
+       uint8_t *p = buf;
+
+       while (more) {
+               byte = value & 0x7f;
+               value >>= 7;
+
+               /* the following is unnecessary if the
+                * implementation of >>= uses an arithmetic rather
+                * than logical shift for a signed left operand
+                */
+               if (negative)
+                       /* sign extend */
+                       value |= - ((intptr_t) 1 <<(size - 7));
+
+               /* sign bit of byte is second high order bit (0x40) */
+               if ((value == 0 && !(byte & 0x40)) ||
+                   (value == -1 && (byte & 0x40)))
+                       more = 0;
+               else
+                       byte |= 0x80;
+
+               *p ++= byte;
+       }
+
+       *endbuf = p;
+}
+
+static void
+emit_byte (LogBuffer *logbuffer, int value)
+{
+       logbuffer->cursor [0] = value;
+       logbuffer->cursor++;
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_value (LogBuffer *logbuffer, int value)
+{
+       encode_uleb128 (value, logbuffer->cursor, &logbuffer->cursor);
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_time (LogBuffer *logbuffer, uint64_t value)
+{
+       uint64_t tdiff = value - logbuffer->last_time;
+       encode_uleb128 (tdiff, logbuffer->cursor, &logbuffer->cursor);
+       logbuffer->last_time = value;
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_event_time (LogBuffer *logbuffer, int event, uint64_t time)
+{
+       emit_byte (logbuffer, event);
+       emit_time (logbuffer, time);
+}
+
+static void
+emit_event (LogBuffer *logbuffer, int event)
+{
+       emit_event_time (logbuffer, event, current_time ());
+}
+
+static void
+emit_svalue (LogBuffer *logbuffer, int64_t value)
+{
+       encode_sleb128 (value, logbuffer->cursor, &logbuffer->cursor);
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_uvalue (LogBuffer *logbuffer, uint64_t value)
+{
+       encode_uleb128 (value, logbuffer->cursor, &logbuffer->cursor);
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_ptr (LogBuffer *logbuffer, void *ptr)
+{
+       if (!logbuffer->ptr_base)
+               logbuffer->ptr_base = (uintptr_t) ptr;
+
+       emit_svalue (logbuffer, (intptr_t) ptr - logbuffer->ptr_base);
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_method_inner (LogBuffer *logbuffer, void *method)
+{
+       if (!logbuffer->method_base) {
+               logbuffer->method_base = (intptr_t) method;
+               logbuffer->last_method = (intptr_t) method;
+       }
+
+       encode_sleb128 ((intptr_t) ((char *) method - (char *) logbuffer->last_method), logbuffer->cursor, &logbuffer->cursor);
+       logbuffer->last_method = (intptr_t) method;
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+register_method_local (MonoMethod *method, MonoJitInfo *ji)
+{
+       MonoProfilerThread *thread = PROF_TLS_GET ();
+
+       if (!mono_conc_hashtable_lookup (thread->profiler->method_table, method)) {
+               MethodInfo *info = (MethodInfo *) g_malloc (sizeof (MethodInfo));
+
+               info->method = method;
+               info->ji = ji;
+               info->time = current_time ();
+
+               GPtrArray *arr = thread->methods ? thread->methods : (thread->methods = g_ptr_array_new ());
+               g_ptr_array_add (arr, info);
+       }
+}
+
+static void
+emit_method (LogBuffer *logbuffer, MonoMethod *method)
+{
+       register_method_local (method, NULL);
+       emit_method_inner (logbuffer, method);
+}
+
+static void
+emit_obj (LogBuffer *logbuffer, void *ptr)
+{
+       if (!logbuffer->obj_base)
+               logbuffer->obj_base = (uintptr_t) ptr >> 3;
+
+       emit_svalue (logbuffer, ((uintptr_t) ptr >> 3) - logbuffer->obj_base);
+
+       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
+}
+
+static void
+emit_string (LogBuffer *logbuffer, const char *str, size_t size)
+{
+       size_t i = 0;
+       if (str) {
+               for (; i < size; i++) {
+                       if (str[i] == '\0')
+                               break;
+                       emit_byte (logbuffer, str [i]);
+               }
+       }
+       emit_byte (logbuffer, '\0');
+}
+
+static void
+emit_double (LogBuffer *logbuffer, double value)
+{
+       int i;
+       unsigned char buffer[8];
+       memcpy (buffer, &value, 8);
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+       for (i = 7; i >= 0; i--)
+#else
+       for (i = 0; i < 8; i++)
+#endif
+               emit_byte (logbuffer, buffer[i]);
+}
+
+static char*
+write_int16 (char *buf, int32_t value)
+{
+       int i;
+       for (i = 0; i < 2; ++i) {
+               buf [i] = value;
+               value >>= 8;
+       }
+       return buf + 2;
+}
+
+static char*
+write_int32 (char *buf, int32_t value)
+{
+       int i;
+       for (i = 0; i < 4; ++i) {
+               buf [i] = value;
+               value >>= 8;
+       }
+       return buf + 4;
+}
+
+static char*
+write_int64 (char *buf, int64_t value)
+{
+       int i;
+       for (i = 0; i < 8; ++i) {
+               buf [i] = value;
+               value >>= 8;
+       }
+       return buf + 8;
+}
+
+static char *
+write_header_string (char *p, const char *str)
+{
+       size_t len = strlen (str) + 1;
+
+       p = write_int32 (p, len);
+       strcpy (p, str);
+
+       return p + len;
+}
+
+static void
+dump_header (MonoProfiler *profiler)
+{
+       const char *args = profiler->args;
+       const char *arch = mono_config_get_cpu ();
+       const char *os = mono_config_get_os ();
+
+       char *hbuf = g_malloc (
+               sizeof (gint32) /* header id */ +
+               sizeof (gint8) /* major version */ +
+               sizeof (gint8) /* minor version */ +
+               sizeof (gint8) /* data version */ +
+               sizeof (gint8) /* word size */ +
+               sizeof (gint64) /* startup time */ +
+               sizeof (gint32) /* timer overhead */ +
+               sizeof (gint32) /* flags */ +
+               sizeof (gint32) /* process id */ +
+               sizeof (gint16) /* command port */ +
+               sizeof (gint32) + strlen (args) + 1 /* arguments */ +
+               sizeof (gint32) + strlen (arch) + 1 /* architecture */ +
+               sizeof (gint32) + strlen (os) + 1 /* operating system */
+       );
+       char *p = hbuf;
+
+       p = write_int32 (p, LOG_HEADER_ID);
+       *p++ = LOG_VERSION_MAJOR;
+       *p++ = LOG_VERSION_MINOR;
+       *p++ = LOG_DATA_VERSION;
+       *p++ = sizeof (void *);
+       p = write_int64 (p, ((uint64_t) time (NULL)) * 1000);
+       p = write_int32 (p, timer_overhead);
+       p = write_int32 (p, 0); /* flags */
+       p = write_int32 (p, process_id ());
+       p = write_int16 (p, profiler->command_port);
+       p = write_header_string (p, args);
+       p = write_header_string (p, arch);
+       p = write_header_string (p, os);
+
+#if defined (HAVE_SYS_ZLIB)
+       if (profiler->gzfile) {
+               gzwrite (profiler->gzfile, hbuf, p - hbuf);
+       } else
+#endif
+       {
+               fwrite (hbuf, p - hbuf, 1, profiler->file);
+               fflush (profiler->file);
+       }
+
+       g_free (hbuf);
+}
+
+/*
+ * Must be called with the reader lock held if thread is the current thread, or
+ * the exclusive lock if thread is a different thread. However, if thread is
+ * the current thread, and init_thread () was called with add_to_lls = FALSE,
+ * then no locking is necessary.
+ */
+static void
+send_buffer (MonoProfilerThread *thread)
+{
+       WriterQueueEntry *entry = mono_lock_free_alloc (&thread->profiler->writer_entry_allocator);
+       entry->methods = thread->methods;
+       entry->buffer = thread->buffer;
+
+       mono_lock_free_queue_node_init (&entry->node, FALSE);
+
+       mono_lock_free_queue_enqueue (&thread->profiler->writer_queue, &entry->node);
+       mono_os_sem_post (&thread->profiler->writer_queue_sem);
+}
+
+static void
+free_thread (gpointer p)
+{
+       MonoProfilerThread *thread = p;
+
+       if (!thread->ended) {
+               /*
+                * The thread is being cleaned up by the main thread during
+                * shutdown. This typically happens for internal runtime
+                * threads. We need to synthesize a thread end event.
+                */
+
+               InterlockedIncrement (&thread_ends_ctr);
+
+               if (ENABLED (PROFLOG_THREAD_EVENTS)) {
+                       LogBuffer *buf = ensure_logbuf_unsafe (thread,
+                               EVENT_SIZE /* event */ +
+                               BYTE_SIZE /* type */ +
+                               LEB128_SIZE /* tid */
+                       );
+
+                       emit_event (buf, TYPE_END_UNLOAD | TYPE_METADATA);
+                       emit_byte (buf, TYPE_THREAD);
+                       emit_ptr (buf, (void *) thread->node.key);
+               }
+       }
+
+       send_buffer (thread);
+
+       g_free (thread);
+}
+
+static void
+remove_thread (MonoProfilerThread *thread)
+{
+       MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
+
+       if (mono_lls_remove (&profiler_thread_list, hp, &thread->node))
+               mono_thread_hazardous_try_free (thread, free_thread);
+
+       clear_hazard_pointers (hp);
+}
+
+static void
+dump_buffer (MonoProfiler *profiler, LogBuffer *buf)
+{
+       char hbuf [128];
+       char *p = hbuf;
+
+       if (buf->next)
+               dump_buffer (profiler, buf->next);
+
+       if (buf->cursor - buf->buf) {
+               p = write_int32 (p, BUF_ID);
+               p = write_int32 (p, buf->cursor - buf->buf);
+               p = write_int64 (p, buf->time_base);
+               p = write_int64 (p, buf->ptr_base);
+               p = write_int64 (p, buf->obj_base);
+               p = write_int64 (p, buf->thread_id);
+               p = write_int64 (p, buf->method_base);
+
+#if defined (HAVE_SYS_ZLIB)
+               if (profiler->gzfile) {
+                       gzwrite (profiler->gzfile, hbuf, p - hbuf);
+                       gzwrite (profiler->gzfile, buf->buf, buf->cursor - buf->buf);
+               } else
+#endif
+               {
+                       fwrite (hbuf, p - hbuf, 1, profiler->file);
+                       fwrite (buf->buf, buf->cursor - buf->buf, 1, profiler->file);
+                       fflush (profiler->file);
+               }
+       }
+
+       free_buffer (buf, buf->size);
+}
+
+static void
+dump_buffer_threadless (MonoProfiler *profiler, LogBuffer *buf)
+{
+       for (LogBuffer *iter = buf; iter; iter = iter->next)
+               iter->thread_id = 0;
+
+       dump_buffer (profiler, buf);
+}
+
+// Only valid if init_thread () was called with add_to_lls = FALSE.
+static void
+send_log_unsafe (gboolean if_needed)
+{
+       MonoProfilerThread *thread = PROF_TLS_GET ();
+
+       if (!if_needed || (if_needed && thread->buffer->next)) {
+               if (!thread->attached)
+                       for (LogBuffer *iter = thread->buffer; iter; iter = iter->next)
+                               iter->thread_id = 0;
+
+               send_buffer (thread);
+               init_buffer_state (thread);
+       }
+}
+
+// Assumes that the exclusive lock is held.
+static void
+sync_point_flush (void)
+{
+       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id () && "Why don't we hold the exclusive lock?");
+
+       MONO_LLS_FOREACH_SAFE (&profiler_thread_list, MonoProfilerThread, thread) {
+               g_assert (thread->attached && "Why is a thread in the LLS not attached?");
+
+               send_buffer (thread);
+               init_buffer_state (thread);
+       } MONO_LLS_FOREACH_SAFE_END
+}
+
+// Assumes that the exclusive lock is held.
+static void
+sync_point_mark (MonoProfilerSyncPointType type)
+{
+       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id () && "Why don't we hold the exclusive lock?");
+
+       ENTER_LOG (&sync_points_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* type */
+       );
+
+       emit_event (logbuffer, TYPE_META | TYPE_SYNC_POINT);
+       emit_byte (logbuffer, type);
+
+       EXIT_LOG_EXPLICIT (NO_SEND);
+
+       send_log_unsafe (FALSE);
+}
+
+// Assumes that the exclusive lock is held.
+static void
+sync_point (MonoProfilerSyncPointType type)
+{
+       sync_point_flush ();
+       sync_point_mark (type);
+}
+
+static int
+gc_reference (MonoObject *obj, MonoClass *klass, uintptr_t size, uintptr_t num, MonoObject **refs, uintptr_t *offsets, void *data)
+{
+       /* account for object alignment in the heap */
+       size += 7;
+       size &= ~7;
+
+       ENTER_LOG (&heap_objects_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* obj */ +
+               LEB128_SIZE /* klass */ +
+               LEB128_SIZE /* size */ +
+               LEB128_SIZE /* num */ +
+               num * (
+                       LEB128_SIZE /* offset */ +
+                       LEB128_SIZE /* ref */
+               )
+       );
+
+       emit_event (logbuffer, TYPE_HEAP_OBJECT | TYPE_HEAP);
+       emit_obj (logbuffer, obj);
+       emit_ptr (logbuffer, klass);
+       emit_value (logbuffer, size);
+       emit_value (logbuffer, num);
+
+       uintptr_t last_offset = 0;
+
+       for (int i = 0; i < num; ++i) {
+               emit_value (logbuffer, offsets [i] - last_offset);
+               last_offset = offsets [i];
+               emit_obj (logbuffer, refs [i]);
+       }
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+
+       return 0;
+}
+
+static unsigned int hs_mode_ms = 0;
+static unsigned int hs_mode_gc = 0;
+static unsigned int hs_mode_ondemand = 0;
+static unsigned int gc_count = 0;
+static uint64_t last_hs_time = 0;
+static gboolean do_heap_walk = FALSE;
+static gboolean ignore_heap_events;
+
+static void
+gc_roots (MonoProfiler *prof, int num, void **objects, int *root_types, uintptr_t *extra_info)
+{
+       if (ignore_heap_events)
+               return;
+
+       ENTER_LOG (&heap_roots_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* num */ +
+               LEB128_SIZE /* collections */ +
+               num * (
+                       LEB128_SIZE /* object */ +
+                       LEB128_SIZE /* root type */ +
+                       LEB128_SIZE /* extra info */
+               )
+       );
+
+       emit_event (logbuffer, TYPE_HEAP_ROOT | TYPE_HEAP);
+       emit_value (logbuffer, num);
+       emit_value (logbuffer, mono_gc_collection_count (mono_gc_max_generation ()));
+
+       for (int i = 0; i < num; ++i) {
+               emit_obj (logbuffer, objects [i]);
+               emit_byte (logbuffer, root_types [i]);
+               emit_value (logbuffer, extra_info [i]);
+       }
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+
+
+static void
+trigger_on_demand_heapshot (void)
+{
+       if (heapshot_requested)
+               mono_gc_collect (mono_gc_max_generation ());
+}
+
+#define ALL_GC_EVENTS_MASK (PROFLOG_GC_MOVES_EVENTS | PROFLOG_GC_ROOT_EVENTS | PROFLOG_GC_EVENTS | PROFLOG_HEAPSHOT_FEATURE)
+
+static void
+gc_event (MonoProfiler *profiler, MonoGCEvent ev, int generation)
+{
+       if (ev == MONO_GC_EVENT_START) {
+               uint64_t now = current_time ();
+
+               if (hs_mode_ms && (now - last_hs_time) / 1000 * 1000 >= hs_mode_ms)
+                       do_heap_walk = TRUE;
+               else if (hs_mode_gc && !(gc_count % hs_mode_gc))
+                       do_heap_walk = TRUE;
+               else if (hs_mode_ondemand)
+                       do_heap_walk = heapshot_requested;
+               else if (!hs_mode_ms && !hs_mode_gc && generation == mono_gc_max_generation ())
+                       do_heap_walk = TRUE;
+
+               //If using heapshot, ignore events for collections we don't care
+               if (ENABLED (PROFLOG_HEAPSHOT_FEATURE)) {
+                       // Ignore events generated during the collection itself (IE GC ROOTS)
+                       ignore_heap_events = !do_heap_walk;
+               }
+       }
+
+
+       if (ENABLED (PROFLOG_GC_EVENTS)) {
+               ENTER_LOG (&gc_events_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       BYTE_SIZE /* gc event */ +
+                       BYTE_SIZE /* generation */
+               );
+
+               emit_event (logbuffer, TYPE_GC_EVENT | TYPE_GC);
+               emit_byte (logbuffer, ev);
+               emit_byte (logbuffer, generation);
+
+               EXIT_LOG_EXPLICIT (NO_SEND);
+       }
+
+       switch (ev) {
+       case MONO_GC_EVENT_START:
+               if (generation == mono_gc_max_generation ())
+                       gc_count++;
+
+               break;
+       case MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED:
+               /*
+                * Ensure that no thread can be in the middle of writing to
+                * a buffer when the world stops...
+                */
+               buffer_lock_excl ();
+               break;
+       case MONO_GC_EVENT_POST_STOP_WORLD:
+               /*
+                * ... So that we now have a consistent view of all buffers.
+                * This allows us to flush them. We need to do this because
+                * they may contain object allocation events that need to be
+                * committed to the log file before any object move events
+                * that will be produced during this GC.
+                */
+               if (ENABLED (ALL_GC_EVENTS_MASK))
+                       sync_point (SYNC_POINT_WORLD_STOP);
+
+               /*
+                * All heap events are surrounded by a HEAP_START and a HEAP_ENV event.
+                * Right now, that's the case for GC Moves, GC Roots or heapshots.
+                */
+               if (ENABLED (PROFLOG_GC_MOVES_EVENTS | PROFLOG_GC_ROOT_EVENTS) || do_heap_walk) {
+                       ENTER_LOG (&heap_starts_ctr, logbuffer,
+                               EVENT_SIZE /* event */
+                       );
+
+                       emit_event (logbuffer, TYPE_HEAP_START | TYPE_HEAP);
+
+                       EXIT_LOG_EXPLICIT (DO_SEND);
+               }
+
+               break;
+       case MONO_GC_EVENT_PRE_START_WORLD:
+               if (do_heap_shot && do_heap_walk)
+                       mono_gc_walk_heap (0, gc_reference, NULL);
+
+               /* Matching HEAP_END to the HEAP_START from above */
+               if (ENABLED (PROFLOG_GC_MOVES_EVENTS | PROFLOG_GC_ROOT_EVENTS) || do_heap_walk) {
+                       ENTER_LOG (&heap_ends_ctr, logbuffer,
+                               EVENT_SIZE /* event */
+                       );
+
+                       emit_event (logbuffer, TYPE_HEAP_END | TYPE_HEAP);
+
+                       EXIT_LOG_EXPLICIT (DO_SEND);
+               }
+
+               if (do_heap_shot && do_heap_walk) {
+                       do_heap_walk = FALSE;
+                       heapshot_requested = 0;
+                       last_hs_time = current_time ();
+               }
+
+               /*
+                * Similarly, we must now make sure that any object moves
+                * written to the GC thread's buffer are flushed. Otherwise,
+                * object allocation events for certain addresses could come
+                * after the move events that made those addresses available.
+                */
+               if (ENABLED (ALL_GC_EVENTS_MASK))
+                       sync_point_mark (SYNC_POINT_WORLD_START);
+               break;
+       case MONO_GC_EVENT_POST_START_WORLD_UNLOCKED:
+               /*
+                * Finally, it is safe to allow other threads to write to
+                * their buffers again.
+                */
+               buffer_unlock_excl ();
+               break;
+       default:
+               break;
+       }
+}
+
+static void
+gc_resize (MonoProfiler *profiler, int64_t new_size)
+{
+       ENTER_LOG (&gc_resizes_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* new size */
+       );
+
+       emit_event (logbuffer, TYPE_GC_RESIZE | TYPE_GC);
+       emit_value (logbuffer, new_size);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+
+typedef struct {
+       int count;
+       MonoMethod* methods [MAX_FRAMES];
+       int32_t il_offsets [MAX_FRAMES];
+       int32_t native_offsets [MAX_FRAMES];
+} FrameData;
+
+static int num_frames = MAX_FRAMES;
+
+static mono_bool
+walk_stack (MonoMethod *method, int32_t native_offset, int32_t il_offset, mono_bool managed, void* data)
+{
+       FrameData *frame = (FrameData *)data;
+       if (method && frame->count < num_frames) {
+               frame->il_offsets [frame->count] = il_offset;
+               frame->native_offsets [frame->count] = native_offset;
+               frame->methods [frame->count++] = method;
+               //printf ("In %d %s at %d (native: %d)\n", frame->count, mono_method_get_name (method), il_offset, native_offset);
+       }
+       return frame->count == num_frames;
+}
+
+/*
+ * a note about stack walks: they can cause more profiler events to fire,
+ * so we need to make sure they don't happen after we started emitting an
+ * event, hence the collect_bt/emit_bt split.
+ */
+static void
+collect_bt (FrameData *data)
+{
+       data->count = 0;
+       mono_stack_walk_no_il (walk_stack, data);
+}
+
+static void
+emit_bt (MonoProfiler *prof, LogBuffer *logbuffer, FrameData *data)
+{
+       /* FIXME: this is actually tons of data and we should
+        * just output it the first time and use an id the next
+        */
+       if (data->count > num_frames)
+               printf ("bad num frames: %d\n", data->count);
+       emit_value (logbuffer, data->count);
+       //if (*p != data.count) {
+       //      printf ("bad num frames enc at %d: %d -> %d\n", count, data.count, *p); printf ("frames end: %p->%p\n", p, logbuffer->cursor); exit(0);}
+       while (data->count) {
+               emit_method (logbuffer, data->methods [--data->count]);
+       }
+}
+
+static void
+gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
+{
+       init_thread (prof, TRUE);
+
+       int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces) ? TYPE_ALLOC_BT : 0;
+       FrameData data;
+       uintptr_t len = mono_object_get_size (obj);
+       /* account for object alignment in the heap */
+       len += 7;
+       len &= ~7;
+
+       if (do_bt)
+               collect_bt (&data);
+
+       ENTER_LOG (&gc_allocs_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* klass */ +
+               LEB128_SIZE /* obj */ +
+               LEB128_SIZE /* size */ +
+               (do_bt ? (
+                       LEB128_SIZE /* count */ +
+                       data.count * (
+                               LEB128_SIZE /* method */
+                       )
+               ) : 0)
+       );
+
+       emit_event (logbuffer, do_bt | TYPE_ALLOC);
+       emit_ptr (logbuffer, klass);
+       emit_obj (logbuffer, obj);
+       emit_value (logbuffer, len);
+
+       if (do_bt)
+               emit_bt (prof, logbuffer, &data);
+
+       EXIT_LOG;
+}
+
+static void
+gc_moves (MonoProfiler *prof, void **objects, int num)
+{
+       ENTER_LOG (&gc_moves_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* num */ +
+               num * (
+                       LEB128_SIZE /* object */
+               )
+       );
+
+       emit_event (logbuffer, TYPE_GC_MOVE | TYPE_GC);
+       emit_value (logbuffer, num);
+
+       for (int i = 0; i < num; ++i)
+               emit_obj (logbuffer, objects [i]);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+
+static void
+gc_handle (MonoProfiler *prof, int op, int type, uintptr_t handle, MonoObject *obj)
+{
+       int do_bt = nocalls && InterlockedRead (&runtime_inited) && !notraces;
+       FrameData data;
+
+       if (do_bt)
+               collect_bt (&data);
+
+       gint32 *ctr = op == MONO_PROFILER_GC_HANDLE_CREATED ? &gc_handle_creations_ctr : &gc_handle_deletions_ctr;
+
+       ENTER_LOG (ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* type */ +
+               LEB128_SIZE /* handle */ +
+               (op == MONO_PROFILER_GC_HANDLE_CREATED ? (
+                       LEB128_SIZE /* obj */
+               ) : 0) +
+               (do_bt ? (
+                       LEB128_SIZE /* count */ +
+                       data.count * (
+                               LEB128_SIZE /* method */
+                       )
+               ) : 0)
+       );
+
+       if (op == MONO_PROFILER_GC_HANDLE_CREATED)
+               emit_event (logbuffer, (do_bt ? TYPE_GC_HANDLE_CREATED_BT : TYPE_GC_HANDLE_CREATED) | TYPE_GC);
+       else if (op == MONO_PROFILER_GC_HANDLE_DESTROYED)
+               emit_event (logbuffer, (do_bt ? TYPE_GC_HANDLE_DESTROYED_BT : TYPE_GC_HANDLE_DESTROYED) | TYPE_GC);
+       else
+               g_assert_not_reached ();
+
+       emit_value (logbuffer, type);
+       emit_value (logbuffer, handle);
+
+       if (op == MONO_PROFILER_GC_HANDLE_CREATED)
+               emit_obj (logbuffer, obj);
+
+       if (do_bt)
+               emit_bt (prof, logbuffer, &data);
+
+       EXIT_LOG;
+}
+
+static void
+finalize_begin (MonoProfiler *prof)
+{
+       ENTER_LOG (&finalize_begins_ctr, buf,
+               EVENT_SIZE /* event */
+       );
+
+       emit_event (buf, TYPE_GC_FINALIZE_START | TYPE_GC);
+
+       EXIT_LOG;
+}
+
+static void
+finalize_end (MonoProfiler *prof)
+{
+       trigger_on_demand_heapshot ();
+       if (ENABLED (PROFLOG_FINALIZATION_EVENTS)) {
+               ENTER_LOG (&finalize_ends_ctr, buf,
+                       EVENT_SIZE /* event */
+               );
+
+               emit_event (buf, TYPE_GC_FINALIZE_END | TYPE_GC);
+
+               EXIT_LOG;
+       }
+}
+
+static void
+finalize_object_begin (MonoProfiler *prof, MonoObject *obj)
+{
+       ENTER_LOG (&finalize_object_begins_ctr, buf,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* obj */
+       );
+
+       emit_event (buf, TYPE_GC_FINALIZE_OBJECT_START | TYPE_GC);
+       emit_obj (buf, obj);
+
+       EXIT_LOG;
+}
+
+static void
+finalize_object_end (MonoProfiler *prof, MonoObject *obj)
+{
+       ENTER_LOG (&finalize_object_ends_ctr, buf,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* obj */
+       );
+
+       emit_event (buf, TYPE_GC_FINALIZE_OBJECT_END | TYPE_GC);
+       emit_obj (buf, obj);
+
+       EXIT_LOG;
+}
+
+static char*
+push_nesting (char *p, MonoClass *klass)
+{
+       MonoClass *nesting;
+       const char *name;
+       const char *nspace;
+       nesting = mono_class_get_nesting_type (klass);
+       if (nesting) {
+               p = push_nesting (p, nesting);
+               *p++ = '/';
+               *p = 0;
+       }
+       name = mono_class_get_name (klass);
+       nspace = mono_class_get_namespace (klass);
+       if (*nspace) {
+               strcpy (p, nspace);
+               p += strlen (nspace);
+               *p++ = '.';
+               *p = 0;
+       }
+       strcpy (p, name);
+       p += strlen (name);
+       return p;
+}
+
+static char*
+type_name (MonoClass *klass)
+{
+       char buf [1024];
+       char *p;
+       push_nesting (buf, klass);
+       p = (char *) g_malloc (strlen (buf) + 1);
+       strcpy (p, buf);
+       return p;
+}
+
+static void
+image_loaded (MonoProfiler *prof, MonoImage *image, int result)
+{
+       if (result != MONO_PROFILE_OK)
+               return;
+
+       const char *name = mono_image_get_filename (image);
+       int nlen = strlen (name) + 1;
+
+       ENTER_LOG (&image_loads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* image */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_IMAGE);
+       emit_ptr (logbuffer, image);
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+}
+
+static void
+image_unloaded (MonoProfiler *prof, MonoImage *image)
+{
+       const char *name = mono_image_get_filename (image);
+       int nlen = strlen (name) + 1;
+
+       ENTER_LOG (&image_unloads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* image */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_IMAGE);
+       emit_ptr (logbuffer, image);
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+}
+
+static void
+assembly_loaded (MonoProfiler *prof, MonoAssembly *assembly, int result)
+{
+       if (result != MONO_PROFILE_OK)
+               return;
+
+       char *name = mono_stringify_assembly_name (mono_assembly_get_name (assembly));
+       int nlen = strlen (name) + 1;
+
+       ENTER_LOG (&assembly_loads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* assembly */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_ASSEMBLY);
+       emit_ptr (logbuffer, assembly);
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+
+       mono_free (name);
+}
+
+static void
+assembly_unloaded (MonoProfiler *prof, MonoAssembly *assembly)
+{
+       char *name = mono_stringify_assembly_name (mono_assembly_get_name (assembly));
+       int nlen = strlen (name) + 1;
+
+       ENTER_LOG (&assembly_unloads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* assembly */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_ASSEMBLY);
+       emit_ptr (logbuffer, assembly);
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+
+       mono_free (name);
+}
+
+static void
+class_loaded (MonoProfiler *prof, MonoClass *klass, int result)
+{
+       if (result != MONO_PROFILE_OK)
+               return;
+
+       char *name;
+
+       if (InterlockedRead (&runtime_inited))
+               name = mono_type_get_name (mono_class_get_type (klass));
+       else
+               name = type_name (klass);
+
+       int nlen = strlen (name) + 1;
+       MonoImage *image = mono_class_get_image (klass);
+
+       ENTER_LOG (&class_loads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* klass */ +
+               LEB128_SIZE /* image */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_CLASS);
+       emit_ptr (logbuffer, klass);
+       emit_ptr (logbuffer, image);
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+
+       if (runtime_inited)
+               mono_free (name);
+       else
+               g_free (name);
+}
+
+static void
+class_unloaded (MonoProfiler *prof, MonoClass *klass)
+{
+       char *name;
+
+       if (InterlockedRead (&runtime_inited))
+               name = mono_type_get_name (mono_class_get_type (klass));
+       else
+               name = type_name (klass);
+
+       int nlen = strlen (name) + 1;
+       MonoImage *image = mono_class_get_image (klass);
+
+       ENTER_LOG (&class_unloads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* klass */ +
+               LEB128_SIZE /* image */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_CLASS);
+       emit_ptr (logbuffer, klass);
+       emit_ptr (logbuffer, image);
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+
+       if (runtime_inited)
+               mono_free (name);
+       else
+               g_free (name);
+}
+
+static void process_method_enter_coverage (MonoProfiler *prof, MonoMethod *method);
+
+static void
+method_enter (MonoProfiler *prof, MonoMethod *method)
+{
+       process_method_enter_coverage (prof, method);
+
+       if (!only_coverage && PROF_TLS_GET ()->call_depth++ <= max_call_depth) {
+               ENTER_LOG (&method_entries_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       LEB128_SIZE /* method */
+               );
+
+               emit_event (logbuffer, TYPE_ENTER | TYPE_METHOD);
+               emit_method (logbuffer, method);
+
+               EXIT_LOG;
+       }
+}
+
+static void
+method_leave (MonoProfiler *prof, MonoMethod *method)
+{
+       if (!only_coverage && --PROF_TLS_GET ()->call_depth <= max_call_depth) {
+               ENTER_LOG (&method_exits_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       LEB128_SIZE /* method */
+               );
+
+               emit_event (logbuffer, TYPE_LEAVE | TYPE_METHOD);
+               emit_method (logbuffer, method);
+
+               EXIT_LOG;
+       }
+}
+
+static void
+method_exc_leave (MonoProfiler *prof, MonoMethod *method)
+{
+       if (!only_coverage && !nocalls && --PROF_TLS_GET ()->call_depth <= max_call_depth) {
+               ENTER_LOG (&method_exception_exits_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       LEB128_SIZE /* method */
+               );
+
+               emit_event (logbuffer, TYPE_EXC_LEAVE | TYPE_METHOD);
+               emit_method (logbuffer, method);
+
+               EXIT_LOG;
+       }
+}
+
+static void
+method_jitted (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *ji, int result)
+{
+       if (result != MONO_PROFILE_OK)
+               return;
+
+       register_method_local (method, ji);
+}
+
+static void
+code_buffer_new (MonoProfiler *prof, void *buffer, int size, MonoProfilerCodeBufferType type, void *data)
+{
+       char *name;
+       int nlen;
+
+       if (type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE) {
+               name = (char *) data;
+               nlen = strlen (name) + 1;
+       } else {
+               name = NULL;
+               nlen = 0;
+       }
+
+       ENTER_LOG (&code_buffers_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* buffer */ +
+               LEB128_SIZE /* size */ +
+               (name ? (
+                       nlen /* name */
+               ) : 0)
+       );
+
+       emit_event (logbuffer, TYPE_JITHELPER | TYPE_RUNTIME);
+       emit_byte (logbuffer, type);
+       emit_ptr (logbuffer, buffer);
+       emit_value (logbuffer, size);
+
+       if (name) {
+               memcpy (logbuffer->cursor, name, nlen);
+               logbuffer->cursor += nlen;
+       }
+
+       EXIT_LOG;
+}
+
+static void
+throw_exc (MonoProfiler *prof, MonoObject *object)
+{
+       int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces) ? TYPE_THROW_BT : 0;
+       FrameData data;
+
+       if (do_bt)
+               collect_bt (&data);
+
+       ENTER_LOG (&exception_throws_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* object */ +
+               (do_bt ? (
+                       LEB128_SIZE /* count */ +
+                       data.count * (
+                               LEB128_SIZE /* method */
+                       )
+               ) : 0)
+       );
+
+       emit_event (logbuffer, do_bt | TYPE_EXCEPTION);
+       emit_obj (logbuffer, object);
+
+       if (do_bt)
+               emit_bt (prof, logbuffer, &data);
+
+       EXIT_LOG;
+}
+
+static void
+clause_exc (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_num)
+{
+       ENTER_LOG (&exception_clauses_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* clause type */ +
+               LEB128_SIZE /* clause num */ +
+               LEB128_SIZE /* method */
+       );
+
+       emit_event (logbuffer, TYPE_EXCEPTION | TYPE_CLAUSE);
+       emit_byte (logbuffer, clause_type);
+       emit_value (logbuffer, clause_num);
+       emit_method (logbuffer, method);
+
+       EXIT_LOG;
+}
+
+static void
+monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEvent event)
+{
+       int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces && event == MONO_PROFILER_MONITOR_CONTENTION) ? TYPE_MONITOR_BT : 0;
+       FrameData data;
+
+       if (do_bt)
+               collect_bt (&data);
+
+       gint32 *ctr;
+
+       switch (event) {
+       case MONO_PROFILER_MONITOR_CONTENTION:
+               ctr = &monitor_contentions_ctr;
+               break;
+       case MONO_PROFILER_MONITOR_DONE:
+               ctr = &monitor_acquisitions_ctr;
+               break;
+       case MONO_PROFILER_MONITOR_FAIL:
+               ctr = &monitor_failures_ctr;
+               break;
+       default:
+               g_assert_not_reached ();
+               break;
+       }
+
+       ENTER_LOG (ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* object */ +
+               (do_bt ? (
+                       LEB128_SIZE /* count */ +
+                       data.count * (
+                               LEB128_SIZE /* method */
+                       )
+               ) : 0)
+       );
+
+       emit_event (logbuffer, (event << 4) | do_bt | TYPE_MONITOR);
+       emit_obj (logbuffer, object);
+
+       if (do_bt)
+               emit_bt (profiler, logbuffer, &data);
+
+       EXIT_LOG;
+}
+
+static void
+thread_start (MonoProfiler *prof, uintptr_t tid)
+{
+       init_thread (prof, TRUE);
+
+       if (ENABLED (PROFLOG_THREAD_EVENTS)) {
+               ENTER_LOG (&thread_starts_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       BYTE_SIZE /* type */ +
+                       LEB128_SIZE /* tid */
+               );
+
+               emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
+               emit_byte (logbuffer, TYPE_THREAD);
+               emit_ptr (logbuffer, (void*) tid);
+
+               EXIT_LOG;
+       }
+}
+
+static void
+thread_end (MonoProfiler *prof, uintptr_t tid)
+{
+       if (ENABLED (PROFLOG_THREAD_EVENTS)) {
+               ENTER_LOG (&thread_ends_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       BYTE_SIZE /* type */ +
+                       LEB128_SIZE /* tid */
+               );
+
+               emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
+               emit_byte (logbuffer, TYPE_THREAD);
+               emit_ptr (logbuffer, (void*) tid);
+
+               EXIT_LOG_EXPLICIT (NO_SEND);
+       }
+
+       MonoProfilerThread *thread = PROF_TLS_GET ();
+
+       thread->ended = TRUE;
+       remove_thread (thread);
+
+       PROF_TLS_SET (NULL);
+}
+
+static void
+thread_name (MonoProfiler *prof, uintptr_t tid, const char *name)
+{
+       int len = strlen (name) + 1;
+
+       if (ENABLED (PROFLOG_THREAD_EVENTS)) {
+               ENTER_LOG (&thread_names_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       BYTE_SIZE /* type */ +
+                       LEB128_SIZE /* tid */ +
+                       len /* name */
+               );
+
+               emit_event (logbuffer, TYPE_METADATA);
+               emit_byte (logbuffer, TYPE_THREAD);
+               emit_ptr (logbuffer, (void*)tid);
+               memcpy (logbuffer->cursor, name, len);
+               logbuffer->cursor += len;
+
+               EXIT_LOG;
+       }
+}
+
+static void
+domain_loaded (MonoProfiler *prof, MonoDomain *domain, int result)
+{
+       if (result != MONO_PROFILE_OK)
+               return;
+
+       ENTER_LOG (&domain_loads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* domain id */
+       );
+
+       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_DOMAIN);
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_domain_get_id (domain));
+
+       EXIT_LOG;
+}
+
+static void
+domain_unloaded (MonoProfiler *prof, MonoDomain *domain)
+{
+       ENTER_LOG (&domain_unloads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* domain id */
+       );
+
+       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_DOMAIN);
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_domain_get_id (domain));
+
+       EXIT_LOG;
+}
+
+static void
+domain_name (MonoProfiler *prof, MonoDomain *domain, const char *name)
+{
+       int nlen = strlen (name) + 1;
+
+       ENTER_LOG (&domain_names_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* domain id */ +
+               nlen /* name */
+       );
+
+       emit_event (logbuffer, TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_DOMAIN);
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_domain_get_id (domain));
+       memcpy (logbuffer->cursor, name, nlen);
+       logbuffer->cursor += nlen;
+
+       EXIT_LOG;
+}
+
+static void
+context_loaded (MonoProfiler *prof, MonoAppContext *context)
+{
+       ENTER_LOG (&context_loads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* context id */ +
+               LEB128_SIZE /* domain id */
+       );
+
+       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_CONTEXT);
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_id (context));
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_domain_id (context));
+
+       EXIT_LOG;
+}
+
+static void
+context_unloaded (MonoProfiler *prof, MonoAppContext *context)
+{
+       ENTER_LOG (&context_unloads_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               BYTE_SIZE /* type */ +
+               LEB128_SIZE /* context id */ +
+               LEB128_SIZE /* domain id */
+       );
+
+       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
+       emit_byte (logbuffer, TYPE_CONTEXT);
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_id (context));
+       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_domain_id (context));
+
+       EXIT_LOG;
+}
+
+typedef struct {
+       MonoMethod *method;
+       MonoDomain *domain;
+       void *base_address;
+       int offset;
+} AsyncFrameInfo;
+
+typedef struct {
+       MonoLockFreeQueueNode node;
+       MonoProfiler *prof;
+       uint64_t time;
+       uintptr_t tid;
+       void *ip;
+       int count;
+       AsyncFrameInfo frames [MONO_ZERO_LEN_ARRAY];
+} SampleHit;
+
+static mono_bool
+async_walk_stack (MonoMethod *method, MonoDomain *domain, void *base_address, int offset, void *data)
+{
+       SampleHit *sample = (SampleHit *) data;
+
+       if (sample->count < num_frames) {
+               int i = sample->count;
+
+               sample->frames [i].method = method;
+               sample->frames [i].domain = domain;
+               sample->frames [i].base_address = base_address;
+               sample->frames [i].offset = offset;
+
+               sample->count++;
+       }
+
+       return sample->count == num_frames;
+}
+
+#define SAMPLE_SLOT_SIZE(FRAMES) (sizeof (SampleHit) + sizeof (AsyncFrameInfo) * (FRAMES - MONO_ZERO_LEN_ARRAY))
+#define SAMPLE_BLOCK_SIZE (mono_pagesize ())
+
+static void
+enqueue_sample_hit (gpointer p)
+{
+       SampleHit *sample = p;
+
+       mono_lock_free_queue_node_unpoison (&sample->node);
+       mono_lock_free_queue_enqueue (&sample->prof->dumper_queue, &sample->node);
+       mono_os_sem_post (&sample->prof->dumper_queue_sem);
+}
+
+static void
+mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
+{
+       /*
+        * Please note: We rely on the runtime loading the profiler with
+        * MONO_DL_EAGER (RTLD_NOW) so that references to runtime functions within
+        * this function (and its siblings) are resolved when the profiler is
+        * loaded. Otherwise, we would potentially invoke the dynamic linker when
+        * invoking runtime functions, which is not async-signal-safe.
+        */
+
+       if (InterlockedRead (&in_shutdown))
+               return;
+
+       SampleHit *sample = (SampleHit *) mono_lock_free_queue_dequeue (&profiler->sample_reuse_queue);
+
+       if (!sample) {
+               /*
+                * If we're out of reusable sample events and we're not allowed to
+                * allocate more, we have no choice but to drop the event.
+                */
+               if (InterlockedRead (&sample_allocations_ctr) >= max_allocated_sample_hits)
+                       return;
+
+               sample = mono_lock_free_alloc (&profiler->sample_allocator);
+               sample->prof = profiler;
+               mono_lock_free_queue_node_init (&sample->node, TRUE);
+
+               InterlockedIncrement (&sample_allocations_ctr);
+       }
+
+       sample->count = 0;
+       mono_stack_walk_async_safe (&async_walk_stack, context, sample);
+
+       sample->time = current_time ();
+       sample->tid = thread_id ();
+       sample->ip = ip;
+
+       mono_thread_hazardous_try_free (sample, enqueue_sample_hit);
+}
+
+static uintptr_t *code_pages = 0;
+static int num_code_pages = 0;
+static int size_code_pages = 0;
+#define CPAGE_SHIFT (9)
+#define CPAGE_SIZE (1 << CPAGE_SHIFT)
+#define CPAGE_MASK (~(CPAGE_SIZE - 1))
+#define CPAGE_ADDR(p) ((p) & CPAGE_MASK)
+
+static uintptr_t
+add_code_page (uintptr_t *hash, uintptr_t hsize, uintptr_t page)
+{
+       uintptr_t i;
+       uintptr_t start_pos;
+       start_pos = (page >> CPAGE_SHIFT) % hsize;
+       i = start_pos;
+       do {
+               if (hash [i] && CPAGE_ADDR (hash [i]) == CPAGE_ADDR (page)) {
+                       return 0;
+               } else if (!hash [i]) {
+                       hash [i] = page;
+                       return 1;
+               }
+               /* wrap around */
+               if (++i == hsize)
+                       i = 0;
+       } while (i != start_pos);
+       /* should not happen */
+       printf ("failed code page store\n");
+       return 0;
+}
+
+static void
+add_code_pointer (uintptr_t ip)
+{
+       uintptr_t i;
+       if (num_code_pages * 2 >= size_code_pages) {
+               uintptr_t *n;
+               uintptr_t old_size = size_code_pages;
+               size_code_pages *= 2;
+               if (size_code_pages == 0)
+                       size_code_pages = 16;
+               n = (uintptr_t *) g_calloc (sizeof (uintptr_t) * size_code_pages, 1);
+               for (i = 0; i < old_size; ++i) {
+                       if (code_pages [i])
+                               add_code_page (n, size_code_pages, code_pages [i]);
+               }
+               if (code_pages)
+                       g_free (code_pages);
+               code_pages = n;
+       }
+       num_code_pages += add_code_page (code_pages, size_code_pages, ip & CPAGE_MASK);
+}
+
+/* ELF code crashes on some systems. */
+//#if defined(HAVE_DL_ITERATE_PHDR) && defined(ELFMAG0)
+#if 0
+static void
+dump_ubin (MonoProfiler *prof, const char *filename, uintptr_t load_addr, uint64_t offset, uintptr_t size)
+{
+       int len = strlen (filename) + 1;
+
+       ENTER_LOG (&sample_ubins_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* load address */ +
+               LEB128_SIZE /* offset */ +
+               LEB128_SIZE /* size */ +
+               nlen /* file name */
+       );
+
+       emit_event (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_UBIN);
+       emit_svalue (logbuffer, load_addr);
+       emit_uvalue (logbuffer, offset);
+       emit_uvalue (logbuffer, size);
+       memcpy (logbuffer->cursor, filename, len);
+       logbuffer->cursor += len;
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+#endif
+
+static void
+dump_usym (MonoProfiler *prof, const char *name, uintptr_t value, uintptr_t size)
+{
+       int len = strlen (name) + 1;
+
+       ENTER_LOG (&sample_usyms_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* value */ +
+               LEB128_SIZE /* size */ +
+               len /* name */
+       );
+
+       emit_event (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_USYM);
+       emit_ptr (logbuffer, (void*)value);
+       emit_value (logbuffer, size);
+       memcpy (logbuffer->cursor, name, len);
+       logbuffer->cursor += len;
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+
+/* ELF code crashes on some systems. */
+//#if defined(ELFMAG0)
+#if 0
+
+#if SIZEOF_VOID_P == 4
+#define ELF_WSIZE 32
+#else
+#define ELF_WSIZE 64
+#endif
+#ifndef ElfW
+#define ElfW(type)      _ElfW (Elf, ELF_WSIZE, type)
+#define _ElfW(e,w,t)    _ElfW_1 (e, w, _##t)
+#define _ElfW_1(e,w,t)  e##w##t
+#endif
+
+static void
+dump_elf_symbols (MonoProfiler *prof, ElfW(Sym) *symbols, int num_symbols, const char *strtab, void *load_addr)
+{
+       int i;
+       for (i = 0; i < num_symbols; ++i) {
+               const char* sym;
+               sym =  strtab + symbols [i].st_name;
+               if (!symbols [i].st_name || !symbols [i].st_size || (symbols [i].st_info & 0xf) != STT_FUNC)
+                       continue;
+               //printf ("symbol %s at %d\n", sym, symbols [i].st_value);
+               dump_usym (sym, (uintptr_t)load_addr + symbols [i].st_value, symbols [i].st_size);
+       }
+}
+
+static int
+read_elf_symbols (MonoProfiler *prof, const char *filename, void *load_addr)
+{
+       int fd, i;
+       void *data;
+       struct stat statb;
+       uint64_t file_size;
+       ElfW(Ehdr) *header;
+       ElfW(Shdr) *sheader;
+       ElfW(Shdr) *shstrtabh;
+       ElfW(Shdr) *symtabh = NULL;
+       ElfW(Shdr) *strtabh = NULL;
+       ElfW(Sym) *symbols = NULL;
+       const char *strtab;
+       int num_symbols;
+
+       fd = open (filename, O_RDONLY);
+       if (fd < 0)
+               return 0;
+       if (fstat (fd, &statb) != 0) {
+               close (fd);
+               return 0;
+       }
+       file_size = statb.st_size;
+       data = mmap (NULL, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
+       close (fd);
+       if (data == MAP_FAILED)
+               return 0;
+       header = data;
+       if (header->e_ident [EI_MAG0] != ELFMAG0 ||
+                       header->e_ident [EI_MAG1] != ELFMAG1 ||
+                       header->e_ident [EI_MAG2] != ELFMAG2 ||
+                       header->e_ident [EI_MAG3] != ELFMAG3 ) {
+               munmap (data, file_size);
+               return 0;
+       }
+       sheader = (void*)((char*)data + header->e_shoff);
+       shstrtabh = (void*)((char*)sheader + (header->e_shentsize * header->e_shstrndx));
+       strtab = (const char*)data + shstrtabh->sh_offset;
+       for (i = 0; i < header->e_shnum; ++i) {
+               //printf ("section header: %d\n", sheader->sh_type);
+               if (sheader->sh_type == SHT_SYMTAB) {
+                       symtabh = sheader;
+                       strtabh = (void*)((char*)data + header->e_shoff + sheader->sh_link * header->e_shentsize);
+                       /*printf ("symtab section header: %d, .strstr: %d\n", i, sheader->sh_link);*/
+                       break;
+               }
+               sheader = (void*)((char*)sheader + header->e_shentsize);
+       }
+       if (!symtabh || !strtabh) {
+               munmap (data, file_size);
+               return 0;
+       }
+       strtab = (const char*)data + strtabh->sh_offset;
+       num_symbols = symtabh->sh_size / symtabh->sh_entsize;
+       symbols = (void*)((char*)data + symtabh->sh_offset);
+       dump_elf_symbols (symbols, num_symbols, strtab, load_addr);
+       munmap (data, file_size);
+       return 1;
+}
+#endif
+
+/* ELF code crashes on some systems. */
+//#if defined(HAVE_DL_ITERATE_PHDR) && defined(ELFMAG0)
+#if 0
+static int
+elf_dl_callback (struct dl_phdr_info *info, size_t size, void *data)
+{
+       MonoProfiler *prof = data;
+       char buf [256];
+       const char *filename;
+       BinaryObject *obj;
+       char *a = (void*)info->dlpi_addr;
+       int i, num_sym;
+       ElfW(Dyn) *dyn = NULL;
+       ElfW(Sym) *symtab = NULL;
+       ElfW(Word) *hash_table = NULL;
+       ElfW(Ehdr) *header = NULL;
+       const char* strtab = NULL;
+       for (obj = prof->binary_objects; obj; obj = obj->next) {
+               if (obj->addr == a)
+                       return 0;
+       }
+       filename = info->dlpi_name;
+       if (!filename)
+               return 0;
+       if (!info->dlpi_addr && !filename [0]) {
+               int l = readlink ("/proc/self/exe", buf, sizeof (buf) - 1);
+               if (l > 0) {
+                       buf [l] = 0;
+                       filename = buf;
+               }
+       }
+       obj = g_calloc (sizeof (BinaryObject), 1);
+       obj->addr = (void*)info->dlpi_addr;
+       obj->name = pstrdup (filename);
+       obj->next = prof->binary_objects;
+       prof->binary_objects = obj;
+       //printf ("loaded file: %s at %p, segments: %d\n", filename, (void*)info->dlpi_addr, info->dlpi_phnum);
+       a = NULL;
+       for (i = 0; i < info->dlpi_phnum; ++i) {
+               //printf ("segment type %d file offset: %d, size: %d\n", info->dlpi_phdr[i].p_type, info->dlpi_phdr[i].p_offset, info->dlpi_phdr[i].p_memsz);
+               if (info->dlpi_phdr[i].p_type == PT_LOAD && !header) {
+                       header = (ElfW(Ehdr)*)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
+                       if (header->e_ident [EI_MAG0] != ELFMAG0 ||
+                                       header->e_ident [EI_MAG1] != ELFMAG1 ||
+                                       header->e_ident [EI_MAG2] != ELFMAG2 ||
+                                       header->e_ident [EI_MAG3] != ELFMAG3 ) {
+                               header = NULL;
+                       }
+                       dump_ubin (prof, filename, info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, info->dlpi_phdr[i].p_offset, info->dlpi_phdr[i].p_memsz);
+               } else if (info->dlpi_phdr[i].p_type == PT_DYNAMIC) {
+                       dyn = (ElfW(Dyn) *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
+               }
+       }
+       if (read_elf_symbols (prof, filename, (void*)info->dlpi_addr))
+               return 0;
+       if (!info->dlpi_name || !info->dlpi_name[0])
+               return 0;
+       if (!dyn)
+               return 0;
+       for (i = 0; dyn [i].d_tag != DT_NULL; ++i) {
+               if (dyn [i].d_tag == DT_SYMTAB) {
+                       if (symtab && do_debug)
+                               printf ("multiple symtabs: %d\n", i);
+                       symtab = (ElfW(Sym) *)(a + dyn [i].d_un.d_ptr);
+               } else if (dyn [i].d_tag == DT_HASH) {
+                       hash_table = (ElfW(Word) *)(a + dyn [i].d_un.d_ptr);
+               } else if (dyn [i].d_tag == DT_STRTAB) {
+                       strtab = (const char*)(a + dyn [i].d_un.d_ptr);
+               }
+       }
+       if (!hash_table)
+               return 0;
+       num_sym = hash_table [1];
+       dump_elf_symbols (prof, symtab, num_sym, strtab, (void*)info->dlpi_addr);
+       return 0;
+}
+
+static int
+load_binaries (MonoProfiler *prof)
+{
+       dl_iterate_phdr (elf_dl_callback, prof);
+       return 1;
+}
+#else
+static int
+load_binaries (MonoProfiler *prof)
+{
+       return 0;
+}
+#endif
+
+static const char*
+symbol_for (uintptr_t code)
+{
+#ifdef HAVE_DLADDR
+       void *ip = (void*)code;
+       Dl_info di;
+       if (dladdr (ip, &di)) {
+               if (di.dli_sname)
+                       return di.dli_sname;
+       } else {
+       /*      char **names;
+               names = backtrace_symbols (&ip, 1);
+               if (names) {
+                       const char* p = names [0];
+                       g_free (names);
+                       return p;
+               }
+               */
+       }
+#endif
+       return NULL;
+}
+
+static void
+dump_unmanaged_coderefs (MonoProfiler *prof)
+{
+       int i;
+       const char* last_symbol;
+       uintptr_t addr, page_end;
+
+       if (load_binaries (prof))
+               return;
+       for (i = 0; i < size_code_pages; ++i) {
+               const char* sym;
+               if (!code_pages [i] || code_pages [i] & 1)
+                       continue;
+               last_symbol = NULL;
+               addr = CPAGE_ADDR (code_pages [i]);
+               page_end = addr + CPAGE_SIZE;
+               code_pages [i] |= 1;
+               /* we dump the symbols for the whole page */
+               for (; addr < page_end; addr += 16) {
+                       sym = symbol_for (addr);
+                       if (sym && sym == last_symbol)
+                               continue;
+                       last_symbol = sym;
+                       if (!sym)
+                               continue;
+                       dump_usym (prof, sym, addr, 0); /* let's not guess the size */
+                       //printf ("found symbol at %p: %s\n", (void*)addr, sym);
+               }
+       }
+}
+
+typedef struct MonoCounterAgent {
+       MonoCounter *counter;
+       // MonoCounterAgent specific data :
+       void *value;
+       size_t value_size;
+       short index;
+       short emitted;
+       struct MonoCounterAgent *next;
+} MonoCounterAgent;
+
+static MonoCounterAgent* counters;
+static int counters_index = 1;
+static mono_mutex_t counters_mutex;
+
+static void
+counters_add_agent (MonoCounter *counter)
+{
+       if (InterlockedRead (&in_shutdown))
+               return;
+
+       MonoCounterAgent *agent, *item;
+
+       mono_os_mutex_lock (&counters_mutex);
+
+       for (agent = counters; agent; agent = agent->next) {
+               if (agent->counter == counter) {
+                       agent->value_size = 0;
+                       if (agent->value) {
+                               g_free (agent->value);
+                               agent->value = NULL;
+                       }
+                       goto done;
+               }
+       }
+
+       agent = (MonoCounterAgent *) g_malloc (sizeof (MonoCounterAgent));
+       agent->counter = counter;
+       agent->value = NULL;
+       agent->value_size = 0;
+       agent->index = counters_index++;
+       agent->emitted = 0;
+       agent->next = NULL;
+
+       if (!counters) {
+               counters = agent;
+       } else {
+               item = counters;
+               while (item->next)
+                       item = item->next;
+               item->next = agent;
+       }
+
+done:
+       mono_os_mutex_unlock (&counters_mutex);
+}
+
+static mono_bool
+counters_init_foreach_callback (MonoCounter *counter, gpointer data)
+{
+       counters_add_agent (counter);
+       return TRUE;
+}
+
+static void
+counters_init (MonoProfiler *profiler)
+{
+       mono_os_mutex_init (&counters_mutex);
+
+       mono_counters_on_register (&counters_add_agent);
+       mono_counters_foreach (counters_init_foreach_callback, NULL);
+}
+
+static void
+counters_emit (MonoProfiler *profiler)
+{
+       MonoCounterAgent *agent;
+       int len = 0;
+       int size =
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* len */
+       ;
+
+       mono_os_mutex_lock (&counters_mutex);
+
+       for (agent = counters; agent; agent = agent->next) {
+               if (agent->emitted)
+                       continue;
+
+               size +=
+                       LEB128_SIZE /* section */ +
+                       strlen (mono_counter_get_name (agent->counter)) + 1 /* name */ +
+                       BYTE_SIZE /* type */ +
+                       BYTE_SIZE /* unit */ +
+                       BYTE_SIZE /* variance */ +
+                       LEB128_SIZE /* index */
+               ;
+
+               len++;
+       }
+
+       if (!len)
+               goto done;
+
+       ENTER_LOG (&counter_descriptors_ctr, logbuffer, size);
+
+       emit_event (logbuffer, TYPE_SAMPLE_COUNTERS_DESC | TYPE_SAMPLE);
+       emit_value (logbuffer, len);
+
+       for (agent = counters; agent; agent = agent->next) {
+               const char *name;
+
+               if (agent->emitted)
+                       continue;
+
+               name = mono_counter_get_name (agent->counter);
+               emit_value (logbuffer, mono_counter_get_section (agent->counter));
+               emit_string (logbuffer, name, strlen (name) + 1);
+               emit_byte (logbuffer, mono_counter_get_type (agent->counter));
+               emit_byte (logbuffer, mono_counter_get_unit (agent->counter));
+               emit_byte (logbuffer, mono_counter_get_variance (agent->counter));
+               emit_value (logbuffer, agent->index);
+
+               agent->emitted = 1;
+       }
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+
+done:
+       mono_os_mutex_unlock (&counters_mutex);
+}
+
+static void
+counters_sample (MonoProfiler *profiler, uint64_t timestamp)
+{
+       MonoCounterAgent *agent;
+       MonoCounter *counter;
+       int type;
+       int buffer_size;
+       void *buffer;
+       int size;
+
+       counters_emit (profiler);
+
+       buffer_size = 8;
+       buffer = g_calloc (1, buffer_size);
+
+       mono_os_mutex_lock (&counters_mutex);
+
+       size =
+               EVENT_SIZE /* event */
+       ;
+
+       for (agent = counters; agent; agent = agent->next) {
+               size +=
+                       LEB128_SIZE /* index */ +
+                       BYTE_SIZE /* type */ +
+                       mono_counter_get_size (agent->counter) /* value */
+               ;
+       }
+
+       size +=
+               LEB128_SIZE /* stop marker */
+       ;
+
+       ENTER_LOG (&counter_samples_ctr, logbuffer, size);
+
+       emit_event_time (logbuffer, TYPE_SAMPLE_COUNTERS | TYPE_SAMPLE, timestamp);
+
+       for (agent = counters; agent; agent = agent->next) {
+               size_t size;
+
+               counter = agent->counter;
+
+               size = mono_counter_get_size (counter);
+
+               if (size > buffer_size) {
+                       buffer_size = size;
+                       buffer = g_realloc (buffer, buffer_size);
+               }
+
+               memset (buffer, 0, buffer_size);
+
+               g_assert (mono_counters_sample (counter, buffer, size));
+
+               type = mono_counter_get_type (counter);
+
+               if (!agent->value) {
+                       agent->value = g_calloc (1, size);
+                       agent->value_size = size;
+               } else {
+                       if (type == MONO_COUNTER_STRING) {
+                               if (strcmp (agent->value, buffer) == 0)
+                                       continue;
+                       } else {
+                               if (agent->value_size == size && memcmp (agent->value, buffer, size) == 0)
+                                       continue;
+                       }
+               }
+
+               emit_uvalue (logbuffer, agent->index);
+               emit_byte (logbuffer, type);
+               switch (type) {
+               case MONO_COUNTER_INT:
+#if SIZEOF_VOID_P == 4
+               case MONO_COUNTER_WORD:
+#endif
+                       emit_svalue (logbuffer, *(int*)buffer - *(int*)agent->value);
+                       break;
+               case MONO_COUNTER_UINT:
+                       emit_uvalue (logbuffer, *(guint*)buffer - *(guint*)agent->value);
+                       break;
+               case MONO_COUNTER_TIME_INTERVAL:
+               case MONO_COUNTER_LONG:
+#if SIZEOF_VOID_P == 8
+               case MONO_COUNTER_WORD:
+#endif
+                       emit_svalue (logbuffer, *(gint64*)buffer - *(gint64*)agent->value);
+                       break;
+               case MONO_COUNTER_ULONG:
+                       emit_uvalue (logbuffer, *(guint64*)buffer - *(guint64*)agent->value);
+                       break;
+               case MONO_COUNTER_DOUBLE:
+                       emit_double (logbuffer, *(double*)buffer);
+                       break;
+               case MONO_COUNTER_STRING:
+                       if (size == 0) {
+                               emit_byte (logbuffer, 0);
+                       } else {
+                               emit_byte (logbuffer, 1);
+                               emit_string (logbuffer, (char*)buffer, size);
+                       }
+                       break;
+               default:
+                       g_assert_not_reached ();
+               }
+
+               if (type == MONO_COUNTER_STRING && size > agent->value_size) {
+                       agent->value = g_realloc (agent->value, size);
+                       agent->value_size = size;
+               }
+
+               if (size > 0)
+                       memcpy (agent->value, buffer, size);
+       }
+       g_free (buffer);
+
+       emit_value (logbuffer, 0);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+
+       mono_os_mutex_unlock (&counters_mutex);
+}
+
+typedef struct _PerfCounterAgent PerfCounterAgent;
+struct _PerfCounterAgent {
+       PerfCounterAgent *next;
+       int index;
+       char *category_name;
+       char *name;
+       int type;
+       gint64 value;
+       guint8 emitted;
+       guint8 updated;
+       guint8 deleted;
+};
+
+static PerfCounterAgent *perfcounters = NULL;
+
+static void
+perfcounters_emit (MonoProfiler *profiler)
+{
+       PerfCounterAgent *pcagent;
+       int len = 0;
+       int size =
+               EVENT_SIZE /* event */ +
+               LEB128_SIZE /* len */
+       ;
+
+       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
+               if (pcagent->emitted)
+                       continue;
+
+               size +=
+                       LEB128_SIZE /* section */ +
+                       strlen (pcagent->category_name) + 1 /* category name */ +
+                       strlen (pcagent->name) + 1 /* name */ +
+                       BYTE_SIZE /* type */ +
+                       BYTE_SIZE /* unit */ +
+                       BYTE_SIZE /* variance */ +
+                       LEB128_SIZE /* index */
+               ;
+
+               len++;
+       }
+
+       if (!len)
+               return;
+
+       ENTER_LOG (&perfcounter_descriptors_ctr, logbuffer, size);
+
+       emit_event (logbuffer, TYPE_SAMPLE_COUNTERS_DESC | TYPE_SAMPLE);
+       emit_value (logbuffer, len);
+
+       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
+               if (pcagent->emitted)
+                       continue;
+
+               emit_value (logbuffer, MONO_COUNTER_PERFCOUNTERS);
+               emit_string (logbuffer, pcagent->category_name, strlen (pcagent->category_name) + 1);
+               emit_string (logbuffer, pcagent->name, strlen (pcagent->name) + 1);
+               emit_byte (logbuffer, MONO_COUNTER_LONG);
+               emit_byte (logbuffer, MONO_COUNTER_RAW);
+               emit_byte (logbuffer, MONO_COUNTER_VARIABLE);
+               emit_value (logbuffer, pcagent->index);
+
+               pcagent->emitted = 1;
+       }
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+
+static gboolean
+perfcounters_foreach (char *category_name, char *name, unsigned char type, gint64 value, gpointer user_data)
+{
+       PerfCounterAgent *pcagent;
+
+       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
+               if (strcmp (pcagent->category_name, category_name) != 0 || strcmp (pcagent->name, name) != 0)
+                       continue;
+               if (pcagent->value == value)
+                       return TRUE;
+
+               pcagent->value = value;
+               pcagent->updated = 1;
+               pcagent->deleted = 0;
+               return TRUE;
+       }
+
+       pcagent = g_new0 (PerfCounterAgent, 1);
+       pcagent->next = perfcounters;
+       pcagent->index = counters_index++;
+       pcagent->category_name = g_strdup (category_name);
+       pcagent->name = g_strdup (name);
+       pcagent->type = (int) type;
+       pcagent->value = value;
+       pcagent->emitted = 0;
+       pcagent->updated = 1;
+       pcagent->deleted = 0;
+
+       perfcounters = pcagent;
+
+       return TRUE;
+}
+
+static void
+perfcounters_sample (MonoProfiler *profiler, uint64_t timestamp)
+{
+       PerfCounterAgent *pcagent;
+       int len = 0;
+       int size;
+
+       mono_os_mutex_lock (&counters_mutex);
+
+       /* mark all perfcounters as deleted, foreach will unmark them as necessary */
+       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next)
+               pcagent->deleted = 1;
+
+       mono_perfcounter_foreach (perfcounters_foreach, perfcounters);
+
+       perfcounters_emit (profiler);
+
+       size =
+               EVENT_SIZE /* event */
+       ;
+
+       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
+               if (pcagent->deleted || !pcagent->updated)
+                       continue;
+
+               size +=
+                       LEB128_SIZE /* index */ +
+                       BYTE_SIZE /* type */ +
+                       LEB128_SIZE /* value */
+               ;
+
+               len++;
+       }
+
+       if (!len)
+               goto done;
+
+       size +=
+               LEB128_SIZE /* stop marker */
+       ;
+
+       ENTER_LOG (&perfcounter_samples_ctr, logbuffer, size);
+
+       emit_event_time (logbuffer, TYPE_SAMPLE_COUNTERS | TYPE_SAMPLE, timestamp);
+
+       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
+               if (pcagent->deleted || !pcagent->updated)
+                       continue;
+               emit_uvalue (logbuffer, pcagent->index);
+               emit_byte (logbuffer, MONO_COUNTER_LONG);
+               emit_svalue (logbuffer, pcagent->value);
+
+               pcagent->updated = 0;
+       }
+
+       emit_value (logbuffer, 0);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+
+done:
+       mono_os_mutex_unlock (&counters_mutex);
+}
+
+static void
+counters_and_perfcounters_sample (MonoProfiler *prof)
+{
+       uint64_t now = current_time ();
+
+       counters_sample (prof, now);
+       perfcounters_sample (prof, now);
+}
+
+#define COVERAGE_DEBUG(x) if (debug_coverage) {x}
+static mono_mutex_t coverage_mutex;
+static MonoConcurrentHashTable *coverage_methods = NULL;
+static MonoConcurrentHashTable *coverage_assemblies = NULL;
+static MonoConcurrentHashTable *coverage_classes = NULL;
+
+static MonoConcurrentHashTable *filtered_classes = NULL;
+static MonoConcurrentHashTable *entered_methods = NULL;
+static MonoConcurrentHashTable *image_to_methods = NULL;
+static MonoConcurrentHashTable *suppressed_assemblies = NULL;
+static gboolean coverage_initialized = FALSE;
+
+static GPtrArray *coverage_data = NULL;
+static int previous_offset = 0;
+
+typedef struct {
+       MonoLockFreeQueueNode node;
+       MonoMethod *method;
+} MethodNode;
+
+typedef struct {
+       int offset;
+       int counter;
+       char *filename;
+       int line;
+       int column;
+} CoverageEntry;
+
+static void
+free_coverage_entry (gpointer data, gpointer userdata)
+{
+       CoverageEntry *entry = (CoverageEntry *)data;
+       g_free (entry->filename);
+       g_free (entry);
+}
+
+static void
+obtain_coverage_for_method (MonoProfiler *prof, const MonoProfileCoverageEntry *entry)
+{
+       int offset = entry->iloffset - previous_offset;
+       CoverageEntry *e = g_new (CoverageEntry, 1);
+
+       previous_offset = entry->iloffset;
+
+       e->offset = offset;
+       e->counter = entry->counter;
+       e->filename = g_strdup(entry->filename ? entry->filename : "");
+       e->line = entry->line;
+       e->column = entry->col;
+
+       g_ptr_array_add (coverage_data, e);
+}
+
+static char *
+parse_generic_type_names(char *name)
+{
+       char *new_name, *ret;
+       int within_generic_declaration = 0, generic_members = 1;
+
+       if (name == NULL || *name == '\0')
+               return g_strdup ("");
+
+       if (!(ret = new_name = (char *) g_calloc (strlen (name) * 4 + 1, sizeof (char))))
+               return NULL;
+
+       do {
+               switch (*name) {
+                       case '<':
+                               within_generic_declaration = 1;
+                               break;
+
+                       case '>':
+                               within_generic_declaration = 0;
+
+                               if (*(name - 1) != '<') {
+                                       *new_name++ = '`';
+                                       *new_name++ = '0' + generic_members;
+                               } else {
+                                       memcpy (new_name, "&lt;&gt;", 8);
+                                       new_name += 8;
+                               }
+
+                               generic_members = 0;
+                               break;
+
+                       case ',':
+                               generic_members++;
+                               break;
+
+                       default:
+                               if (!within_generic_declaration)
+                                       *new_name++ = *name;
+
+                               break;
+               }
+       } while (*name++);
+
+       return ret;
+}
+
+static int method_id;
+static void
+build_method_buffer (gpointer key, gpointer value, gpointer userdata)
+{
+       MonoMethod *method = (MonoMethod *)value;
+       MonoProfiler *prof = (MonoProfiler *)userdata;
+       MonoClass *klass;
+       MonoImage *image;
+       char *class_name;
+       const char *image_name, *method_name, *sig, *first_filename;
+       guint i;
+
+       previous_offset = 0;
+       coverage_data = g_ptr_array_new ();
+
+       mono_profiler_coverage_get (prof, method, obtain_coverage_for_method);
+
+       klass = mono_method_get_class (method);
+       image = mono_class_get_image (klass);
+       image_name = mono_image_get_name (image);
+
+       sig = mono_signature_get_desc (mono_method_signature (method), TRUE);
+       class_name = parse_generic_type_names (mono_type_get_name (mono_class_get_type (klass)));
+       method_name = mono_method_get_name (method);
+
+       if (coverage_data->len != 0) {
+               CoverageEntry *entry = (CoverageEntry *)coverage_data->pdata[0];
+               first_filename = entry->filename ? entry->filename : "";
+       } else
+               first_filename = "";
+
+       image_name = image_name ? image_name : "";
+       sig = sig ? sig : "";
+       method_name = method_name ? method_name : "";
+
+       ENTER_LOG (&coverage_methods_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               strlen (image_name) + 1 /* image name */ +
+               strlen (class_name) + 1 /* class name */ +
+               strlen (method_name) + 1 /* method name */ +
+               strlen (sig) + 1 /* signature */ +
+               strlen (first_filename) + 1 /* first file name */ +
+               LEB128_SIZE /* token */ +
+               LEB128_SIZE /* method id */ +
+               LEB128_SIZE /* entries */
+       );
+
+       emit_event (logbuffer, TYPE_COVERAGE_METHOD | TYPE_COVERAGE);
+       emit_string (logbuffer, image_name, strlen (image_name) + 1);
+       emit_string (logbuffer, class_name, strlen (class_name) + 1);
+       emit_string (logbuffer, method_name, strlen (method_name) + 1);
+       emit_string (logbuffer, sig, strlen (sig) + 1);
+       emit_string (logbuffer, first_filename, strlen (first_filename) + 1);
+
+       emit_uvalue (logbuffer, mono_method_get_token (method));
+       emit_uvalue (logbuffer, method_id);
+       emit_value (logbuffer, coverage_data->len);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+
+       for (i = 0; i < coverage_data->len; i++) {
+               CoverageEntry *entry = (CoverageEntry *)coverage_data->pdata[i];
+
+               ENTER_LOG (&coverage_statements_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       LEB128_SIZE /* method id */ +
+                       LEB128_SIZE /* offset */ +
+                       LEB128_SIZE /* counter */ +
+                       LEB128_SIZE /* line */ +
+                       LEB128_SIZE /* column */
+               );
+
+               emit_event (logbuffer, TYPE_COVERAGE_STATEMENT | TYPE_COVERAGE);
+               emit_uvalue (logbuffer, method_id);
+               emit_uvalue (logbuffer, entry->offset);
+               emit_uvalue (logbuffer, entry->counter);
+               emit_uvalue (logbuffer, entry->line);
+               emit_uvalue (logbuffer, entry->column);
+
+               EXIT_LOG_EXPLICIT (DO_SEND);
+       }
+
+       method_id++;
+
+       g_free (class_name);
+
+       g_ptr_array_foreach (coverage_data, free_coverage_entry, NULL);
+       g_ptr_array_free (coverage_data, TRUE);
+       coverage_data = NULL;
+}
+
+/* This empties the queue */
+static guint
+count_queue (MonoLockFreeQueue *queue)
+{
+       MonoLockFreeQueueNode *node;
+       guint count = 0;
+
+       while ((node = mono_lock_free_queue_dequeue (queue))) {
+               count++;
+               mono_thread_hazardous_try_free (node, g_free);
+       }
+
+       return count;
+}
+
+static void
+build_class_buffer (gpointer key, gpointer value, gpointer userdata)
+{
+       MonoClass *klass = (MonoClass *)key;
+       MonoLockFreeQueue *class_methods = (MonoLockFreeQueue *)value;
+       MonoImage *image;
+       char *class_name;
+       const char *assembly_name;
+       int number_of_methods, partially_covered;
+       guint fully_covered;
+
+       image = mono_class_get_image (klass);
+       assembly_name = mono_image_get_name (image);
+       class_name = mono_type_get_name (mono_class_get_type (klass));
+
+       assembly_name = assembly_name ? assembly_name : "";
+       number_of_methods = mono_class_num_methods (klass);
+       fully_covered = count_queue (class_methods);
+       /* We don't handle partial covered yet */
+       partially_covered = 0;
+
+       ENTER_LOG (&coverage_classes_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               strlen (assembly_name) + 1 /* assembly name */ +
+               strlen (class_name) + 1 /* class name */ +
+               LEB128_SIZE /* no. methods */ +
+               LEB128_SIZE /* fully covered */ +
+               LEB128_SIZE /* partially covered */
+       );
+
+       emit_event (logbuffer, TYPE_COVERAGE_CLASS | TYPE_COVERAGE);
+       emit_string (logbuffer, assembly_name, strlen (assembly_name) + 1);
+       emit_string (logbuffer, class_name, strlen (class_name) + 1);
+       emit_uvalue (logbuffer, number_of_methods);
+       emit_uvalue (logbuffer, fully_covered);
+       emit_uvalue (logbuffer, partially_covered);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+
+       g_free (class_name);
+}
+
+static void
+get_coverage_for_image (MonoImage *image, int *number_of_methods, guint *fully_covered, int *partially_covered)
+{
+       MonoLockFreeQueue *image_methods = (MonoLockFreeQueue *)mono_conc_hashtable_lookup (image_to_methods, image);
+
+       *number_of_methods = mono_image_get_table_rows (image, MONO_TABLE_METHOD);
+       if (image_methods)
+               *fully_covered = count_queue (image_methods);
+       else
+               *fully_covered = 0;
+
+       // FIXME: We don't handle partially covered yet.
+       *partially_covered = 0;
+}
+
+static void
+build_assembly_buffer (gpointer key, gpointer value, gpointer userdata)
+{
+       MonoAssembly *assembly = (MonoAssembly *)value;
+       MonoImage *image = mono_assembly_get_image (assembly);
+       const char *name, *guid, *filename;
+       int number_of_methods = 0, partially_covered = 0;
+       guint fully_covered = 0;
+
+       name = mono_image_get_name (image);
+       guid = mono_image_get_guid (image);
+       filename = mono_image_get_filename (image);
+
+       name = name ? name : "";
+       guid = guid ? guid : "";
+       filename = filename ? filename : "";
+
+       get_coverage_for_image (image, &number_of_methods, &fully_covered, &partially_covered);
+
+       ENTER_LOG (&coverage_assemblies_ctr, logbuffer,
+               EVENT_SIZE /* event */ +
+               strlen (name) + 1 /* name */ +
+               strlen (guid) + 1 /* guid */ +
+               strlen (filename) + 1 /* file name */ +
+               LEB128_SIZE /* no. methods */ +
+               LEB128_SIZE /* fully covered */ +
+               LEB128_SIZE /* partially covered */
+       );
+
+       emit_event (logbuffer, TYPE_COVERAGE_ASSEMBLY | TYPE_COVERAGE);
+       emit_string (logbuffer, name, strlen (name) + 1);
+       emit_string (logbuffer, guid, strlen (guid) + 1);
+       emit_string (logbuffer, filename, strlen (filename) + 1);
+       emit_uvalue (logbuffer, number_of_methods);
+       emit_uvalue (logbuffer, fully_covered);
+       emit_uvalue (logbuffer, partially_covered);
+
+       EXIT_LOG_EXPLICIT (DO_SEND);
+}
+
+static void
+dump_coverage (MonoProfiler *prof)
+{
+       if (!coverage_initialized)
+               return;
+
+       COVERAGE_DEBUG(fprintf (stderr, "Coverage: Started dump\n");)
+       method_id = 0;
+
+       mono_os_mutex_lock (&coverage_mutex);
+       mono_conc_hashtable_foreach (coverage_assemblies, build_assembly_buffer, NULL);
+       mono_conc_hashtable_foreach (coverage_classes, build_class_buffer, NULL);
+       mono_conc_hashtable_foreach (coverage_methods, build_method_buffer, prof);
+       mono_os_mutex_unlock (&coverage_mutex);
+
+       COVERAGE_DEBUG(fprintf (stderr, "Coverage: Finished dump\n");)
+}
+
+static void
+process_method_enter_coverage (MonoProfiler *prof, MonoMethod *method)
+{
+       MonoClass *klass;
+       MonoImage *image;
+
+       if (!coverage_initialized)
+               return;
+
+       klass = mono_method_get_class (method);
+       image = mono_class_get_image (klass);
+
+       if (mono_conc_hashtable_lookup (suppressed_assemblies, (gpointer) mono_image_get_name (image)))
+               return;
+
+       mono_os_mutex_lock (&coverage_mutex);
+       mono_conc_hashtable_insert (entered_methods, method, method);
+       mono_os_mutex_unlock (&coverage_mutex);
+}
+
+static MonoLockFreeQueueNode *
+create_method_node (MonoMethod *method)
+{
+       MethodNode *node = (MethodNode *) g_malloc (sizeof (MethodNode));
+       mono_lock_free_queue_node_init ((MonoLockFreeQueueNode *) node, FALSE);
+       node->method = method;
+
+       return (MonoLockFreeQueueNode *) node;
+}
+
+static gboolean
+coverage_filter (MonoProfiler *prof, MonoMethod *method)
+{
+       MonoError error;
+       MonoClass *klass;
+       MonoImage *image;
+       MonoAssembly *assembly;
+       MonoMethodHeader *header;
+       guint32 iflags, flags, code_size;
+       char *fqn, *classname;
+       gboolean has_positive, found;
+       MonoLockFreeQueue *image_methods, *class_methods;
+       MonoLockFreeQueueNode *node;
+
+       g_assert (coverage_initialized && "Why are we being asked for coverage filter info when we're not doing coverage?");
+
+       COVERAGE_DEBUG(fprintf (stderr, "Coverage filter for %s\n", mono_method_get_name (method));)
+
+       flags = mono_method_get_flags (method, &iflags);
+       if ((iflags & 0x1000 /*METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL*/) ||
+           (flags & 0x2000 /*METHOD_ATTRIBUTE_PINVOKE_IMPL*/)) {
+               COVERAGE_DEBUG(fprintf (stderr, "   Internal call or pinvoke - ignoring\n");)
+               return FALSE;
+       }
+
+       // Don't need to do anything else if we're already tracking this method
+       if (mono_conc_hashtable_lookup (coverage_methods, method)) {
+               COVERAGE_DEBUG(fprintf (stderr, "   Already tracking\n");)
+               return TRUE;
+       }
+
+       klass = mono_method_get_class (method);
+       image = mono_class_get_image (klass);
+
+       // Don't handle coverage for the core assemblies
+       if (mono_conc_hashtable_lookup (suppressed_assemblies, (gpointer) mono_image_get_name (image)) != NULL)
+               return FALSE;
+
+       if (prof->coverage_filters) {
+               /* Check already filtered classes first */
+               if (mono_conc_hashtable_lookup (filtered_classes, klass)) {
+                       COVERAGE_DEBUG(fprintf (stderr, "   Already filtered\n");)
+                       return FALSE;
+               }
+
+               classname = mono_type_get_name (mono_class_get_type (klass));
+
+               fqn = g_strdup_printf ("[%s]%s", mono_image_get_name (image), classname);
+
+               COVERAGE_DEBUG(fprintf (stderr, "   Looking for %s in filter\n", fqn);)
+               // Check positive filters first
+               has_positive = FALSE;
+               found = FALSE;
+               for (guint i = 0; i < prof->coverage_filters->len; ++i) {
+                       char *filter = (char *)g_ptr_array_index (prof->coverage_filters, i);
+
+                       if (filter [0] == '+') {
+                               filter = &filter [1];
+
+                               COVERAGE_DEBUG(fprintf (stderr, "   Checking against +%s ...", filter);)
+
+                               if (strstr (fqn, filter) != NULL) {
+                                       COVERAGE_DEBUG(fprintf (stderr, "matched\n");)
+                                       found = TRUE;
+                               } else
+                                       COVERAGE_DEBUG(fprintf (stderr, "no match\n");)
+
+                               has_positive = TRUE;
+                       }
+               }
+
+               if (has_positive && !found) {
+                       COVERAGE_DEBUG(fprintf (stderr, "   Positive match was not found\n");)
+
+                       mono_os_mutex_lock (&coverage_mutex);
+                       mono_conc_hashtable_insert (filtered_classes, klass, klass);
+                       mono_os_mutex_unlock (&coverage_mutex);
+                       g_free (fqn);
+                       g_free (classname);
+
+                       return FALSE;
+               }
+
+               for (guint i = 0; i < prof->coverage_filters->len; ++i) {
+                       // FIXME: Is substring search sufficient?
+                       char *filter = (char *)g_ptr_array_index (prof->coverage_filters, i);
+                       if (filter [0] == '+')
+                               continue;
+
+                       // Skip '-'
+                       filter = &filter [1];
+                       COVERAGE_DEBUG(fprintf (stderr, "   Checking against -%s ...", filter);)
+
+                       if (strstr (fqn, filter) != NULL) {
+                               COVERAGE_DEBUG(fprintf (stderr, "matched\n");)
+
+                               mono_os_mutex_lock (&coverage_mutex);
+                               mono_conc_hashtable_insert (filtered_classes, klass, klass);
+                               mono_os_mutex_unlock (&coverage_mutex);
+                               g_free (fqn);
+                               g_free (classname);
+
+                               return FALSE;
+                       } else
+                               COVERAGE_DEBUG(fprintf (stderr, "no match\n");)
+
+               }
+
+               g_free (fqn);
+               g_free (classname);
+       }
+
+       COVERAGE_DEBUG(fprintf (stderr, "   Handling coverage for %s\n", mono_method_get_name (method));)
+       header = mono_method_get_header_checked (method, &error);
+       mono_error_cleanup (&error);
+
+       mono_method_header_get_code (header, &code_size, NULL);
+
+       assembly = mono_image_get_assembly (image);
+
+       // Need to keep the assemblies around for as long as they are kept in the hashtable
+       // Nunit, for example, has a habit of unloading them before the coverage statistics are
+       // generated causing a crash. See https://bugzilla.xamarin.com/show_bug.cgi?id=39325
+       mono_assembly_addref (assembly);
+
+       mono_os_mutex_lock (&coverage_mutex);
+       mono_conc_hashtable_insert (coverage_methods, method, method);
+       mono_conc_hashtable_insert (coverage_assemblies, assembly, assembly);
+       mono_os_mutex_unlock (&coverage_mutex);
+
+       image_methods = (MonoLockFreeQueue *)mono_conc_hashtable_lookup (image_to_methods, image);
+
+       if (image_methods == NULL) {
+               image_methods = (MonoLockFreeQueue *) g_malloc (sizeof (MonoLockFreeQueue));
+               mono_lock_free_queue_init (image_methods);
+               mono_os_mutex_lock (&coverage_mutex);
+               mono_conc_hashtable_insert (image_to_methods, image, image_methods);
+               mono_os_mutex_unlock (&coverage_mutex);
+       }
+
+       node = create_method_node (method);
+       mono_lock_free_queue_enqueue (image_methods, node);
+
+       class_methods = (MonoLockFreeQueue *)mono_conc_hashtable_lookup (coverage_classes, klass);
+
+       if (class_methods == NULL) {
+               class_methods = (MonoLockFreeQueue *) g_malloc (sizeof (MonoLockFreeQueue));
+               mono_lock_free_queue_init (class_methods);
+               mono_os_mutex_lock (&coverage_mutex);
+               mono_conc_hashtable_insert (coverage_classes, klass, class_methods);
+               mono_os_mutex_unlock (&coverage_mutex);
+       }
+
+       node = create_method_node (method);
+       mono_lock_free_queue_enqueue (class_methods, node);
+
+       return TRUE;
+}
+
+#define LINE_BUFFER_SIZE 4096
+/* Max file limit of 128KB */
+#define MAX_FILE_SIZE 128 * 1024
+static char *
+get_file_content (FILE *stream)
+{
+       char *buffer;
+       ssize_t bytes_read;
+       long filesize;
+       int res, offset = 0;
+
+       res = fseek (stream, 0, SEEK_END);
+       if (res < 0)
+         return NULL;
+
+       filesize = ftell (stream);
+       if (filesize < 0)
+         return NULL;
+
+       res = fseek (stream, 0, SEEK_SET);
+       if (res < 0)
+         return NULL;
+
+       if (filesize > MAX_FILE_SIZE)
+         return NULL;
+
+       buffer = (char *) g_malloc ((filesize + 1) * sizeof (char));
+       while ((bytes_read = fread (buffer + offset, 1, LINE_BUFFER_SIZE, stream)) > 0)
+               offset += bytes_read;
+
+       /* NULL terminate our buffer */
+       buffer[filesize] = '\0';
+       return buffer;
+}
+
+static char *
+get_next_line (char *contents, char **next_start)
+{
+       char *p = contents;
+
+       if (p == NULL || *p == '\0') {
+               *next_start = NULL;
+               return NULL;
+       }
+
+       while (*p != '\n' && *p != '\0')
+               p++;
+
+       if (*p == '\n') {
+               *p = '\0';
+               *next_start = p + 1;
+       } else
+               *next_start = NULL;
+
+       return contents;
+}
+
+static void
+init_suppressed_assemblies (void)
+{
+       char *content;
+       char *line;
+       FILE *sa_file;
+
+       suppressed_assemblies = mono_conc_hashtable_new (g_str_hash, g_str_equal);
+       sa_file = fopen (SUPPRESSION_DIR "/mono-profiler-log.suppression", "r");
+       if (sa_file == NULL)
+               return;
+
+       /* Don't need to free @content as it is referred to by the lines stored in @suppressed_assemblies */
+       content = get_file_content (sa_file);
+       if (content == NULL) {
+               g_error ("mono-profiler-log.suppression is greater than 128kb - aborting\n");
+       }
+
+       while ((line = get_next_line (content, &content))) {
+               line = g_strchomp (g_strchug (line));
+               /* No locking needed as we're doing initialization */
+               mono_conc_hashtable_insert (suppressed_assemblies, line, line);
+       }
+
+       fclose (sa_file);
+}
+
+static void
+parse_cov_filter_file (GPtrArray *filters, const char *file)
+{
+       FILE *filter_file;
+       char *line, *content;
+
+       filter_file = fopen (file, "r");
+       if (filter_file == NULL) {
+               fprintf (stderr, "Unable to open %s\n", file);
+               return;
+       }
+
+       /* Don't need to free content as it is referred to by the lines stored in @filters */
+       content = get_file_content (filter_file);
+       if (content == NULL)
+               fprintf (stderr, "WARNING: %s is greater than 128kb - ignoring\n", file);
+
+       while ((line = get_next_line (content, &content)))
+               g_ptr_array_add (filters, g_strchug (g_strchomp (line)));
+
+       fclose (filter_file);
+}
+
+static void
+coverage_init (MonoProfiler *prof)
+{
+       g_assert (!coverage_initialized && "Why are we initializing coverage twice?");
+
+       COVERAGE_DEBUG(fprintf (stderr, "Coverage initialized\n");)
+
+       mono_os_mutex_init (&coverage_mutex);
+       coverage_methods = mono_conc_hashtable_new (NULL, NULL);
+       coverage_assemblies = mono_conc_hashtable_new (NULL, NULL);
+       coverage_classes = mono_conc_hashtable_new (NULL, NULL);
+       filtered_classes = mono_conc_hashtable_new (NULL, NULL);
+       entered_methods = mono_conc_hashtable_new (NULL, NULL);
+       image_to_methods = mono_conc_hashtable_new (NULL, NULL);
+       init_suppressed_assemblies ();
+
+       coverage_initialized = TRUE;
+}
+
+static void
+unref_coverage_assemblies (gpointer key, gpointer value, gpointer userdata)
+{
+       MonoAssembly *assembly = (MonoAssembly *)value;
+       mono_assembly_close (assembly);
+}
+
+static void
+free_sample_hit (gpointer p)
+{
+       mono_lock_free_free (p, SAMPLE_BLOCK_SIZE);
+}
+
+static void
+cleanup_reusable_samples (MonoProfiler *prof)
+{
+       SampleHit *sample;
+
+       while ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->sample_reuse_queue)))
+               mono_thread_hazardous_try_free (sample, free_sample_hit);
+}
+
+static void
+log_shutdown (MonoProfiler *prof)
+{
+       InterlockedWrite (&in_shutdown, 1);
+
+       if (!no_counters)
+               counters_and_perfcounters_sample (prof);
+
+       dump_coverage (prof);
+
+       char c = 1;
+
+       if (write (prof->pipes [1], &c, 1) != 1) {
+               fprintf (stderr, "Could not write to pipe: %s\n", strerror (errno));
+               exit (1);
+       }
+
+       mono_native_thread_join (prof->helper_thread);
+
+       mono_os_mutex_destroy (&counters_mutex);
+
+       MonoCounterAgent *mc_next;
+
+       for (MonoCounterAgent *cur = counters; cur; cur = mc_next) {
+               mc_next = cur->next;
+               g_free (cur);
+       }
+
+       PerfCounterAgent *pc_next;
+
+       for (PerfCounterAgent *cur = perfcounters; cur; cur = pc_next) {
+               pc_next = cur->next;
+               g_free (cur);
+       }
+
+       /*
+        * Ensure that we empty the LLS completely, even if some nodes are
+        * not immediately removed upon calling mono_lls_remove (), by
+        * iterating until the head is NULL.
+        */
+       while (profiler_thread_list.head) {
+               MONO_LLS_FOREACH_SAFE (&profiler_thread_list, MonoProfilerThread, thread) {
+                       g_assert (thread->attached && "Why is a thread in the LLS not attached?");
+
+                       remove_thread (thread);
+               } MONO_LLS_FOREACH_SAFE_END
+       }
+
+       /*
+        * Ensure that all threads have been freed, so that we don't miss any
+        * buffers when we shut down the writer thread below.
+        */
+       mono_thread_hazardous_try_free_all ();
+
+       InterlockedWrite (&prof->run_dumper_thread, 0);
+       mono_os_sem_post (&prof->dumper_queue_sem);
+       mono_native_thread_join (prof->dumper_thread);
+       mono_os_sem_destroy (&prof->dumper_queue_sem);
+
+       InterlockedWrite (&prof->run_writer_thread, 0);
+       mono_os_sem_post (&prof->writer_queue_sem);
+       mono_native_thread_join (prof->writer_thread);
+       mono_os_sem_destroy (&prof->writer_queue_sem);
+
+       /*
+        * Free all writer queue entries, and ensure that all sample hits will be
+        * added to the sample reuse queue.
+        */
+       mono_thread_hazardous_try_free_all ();
+
+       cleanup_reusable_samples (prof);
+
+       /*
+        * Finally, make sure that all sample hits are freed. This should cover all
+        * hazardous data from the profiler. We can now be sure that the runtime
+        * won't later invoke free functions in the profiler library after it has
+        * been unloaded.
+        */
+       mono_thread_hazardous_try_free_all ();
+
+       g_assert (!InterlockedRead (&buffer_rwlock_count) && "Why is the reader count still non-zero?");
+       g_assert (!InterlockedReadPointer (&buffer_rwlock_exclusive) && "Why does someone still hold the exclusive lock?");
+
+#if defined (HAVE_SYS_ZLIB)
+       if (prof->gzfile)
+               gzclose (prof->gzfile);
+#endif
+       if (prof->pipe_output)
+               pclose (prof->file);
+       else
+               fclose (prof->file);
+
+       mono_conc_hashtable_destroy (prof->method_table);
+       mono_os_mutex_destroy (&prof->method_table_mutex);
+
+       if (coverage_initialized) {
+               mono_os_mutex_lock (&coverage_mutex);
+               mono_conc_hashtable_foreach (coverage_assemblies, unref_coverage_assemblies, prof);
+               mono_os_mutex_unlock (&coverage_mutex);
+
+               mono_conc_hashtable_destroy (coverage_methods);
+               mono_conc_hashtable_destroy (coverage_assemblies);
+               mono_conc_hashtable_destroy (coverage_classes);
+               mono_conc_hashtable_destroy (filtered_classes);
+
+               mono_conc_hashtable_destroy (entered_methods);
+               mono_conc_hashtable_destroy (image_to_methods);
+               mono_conc_hashtable_destroy (suppressed_assemblies);
+               mono_os_mutex_destroy (&coverage_mutex);
+       }
+
+       PROF_TLS_FREE ();
+
+       g_free (prof->args);
+       g_free (prof);
+}
+
+static char*
+new_filename (const char* filename)
+{
+       time_t t = time (NULL);
+       int pid = process_id ();
+       char pid_buf [16];
+       char time_buf [16];
+       char *res, *d;
+       const char *p;
+       int count_dates = 0;
+       int count_pids = 0;
+       int s_date, s_pid;
+       struct tm *ts;
+       for (p = filename; *p; p++) {
+               if (*p != '%')
+                       continue;
+               p++;
+               if (*p == 't')
+                       count_dates++;
+               else if (*p == 'p')
+                       count_pids++;
+               else if (*p == 0)
+                       break;
+       }
+       if (!count_dates && !count_pids)
+               return pstrdup (filename);
+       snprintf (pid_buf, sizeof (pid_buf), "%d", pid);
+       ts = gmtime (&t);
+       snprintf (time_buf, sizeof (time_buf), "%d%02d%02d%02d%02d%02d",
+               1900 + ts->tm_year, 1 + ts->tm_mon, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
+       s_date = strlen (time_buf);
+       s_pid = strlen (pid_buf);
+       d = res = (char *) g_malloc (strlen (filename) + s_date * count_dates + s_pid * count_pids);
+       for (p = filename; *p; p++) {
+               if (*p != '%') {
+                       *d++ = *p;
+                       continue;
+               }
+               p++;
+               if (*p == 't') {
+                       strcpy (d, time_buf);
+                       d += s_date;
+                       continue;
+               } else if (*p == 'p') {
+                       strcpy (d, pid_buf);
+                       d += s_pid;
+                       continue;
+               } else if (*p == '%') {
+                       *d++ = '%';
+                       continue;
+               } else if (*p == 0)
+                       break;
+               *d++ = '%';
+               *d++ = *p;
+       }
+       *d = 0;
+       return res;
+}
+
+static void
+add_to_fd_set (fd_set *set, int fd, int *max_fd)
+{
+       /*
+        * This should only trigger for the basic FDs (server socket, pipes) at
+        * startup if for some mysterious reason they're too large. In this case,
+        * the profiler really can't function, and we're better off printing an
+        * error and exiting.
+        */
+       if (fd >= FD_SETSIZE) {
+               fprintf (stderr, "File descriptor is out of bounds for fd_set: %d\n", fd);
+               exit (1);
+       }
+
+       FD_SET (fd, set);
+
+       if (*max_fd < fd)
+               *max_fd = fd;
+}
+
+static void *
+helper_thread (void *arg)
+{
+       MonoProfiler *prof = (MonoProfiler *) arg;
+
+       mono_threads_attach_tools_thread ();
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler helper");
+
+       MonoProfilerThread *thread = init_thread (prof, FALSE);
+
+       GArray *command_sockets = g_array_new (FALSE, FALSE, sizeof (int));
+
+       while (1) {
+               fd_set rfds;
+               int max_fd = -1;
+
+               FD_ZERO (&rfds);
+
+               add_to_fd_set (&rfds, prof->server_socket, &max_fd);
+               add_to_fd_set (&rfds, prof->pipes [0], &max_fd);
+
+               for (gint i = 0; i < command_sockets->len; i++)
+                       add_to_fd_set (&rfds, g_array_index (command_sockets, int, i), &max_fd);
+
+               struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };
+
+               // Sleep for 1sec or until a file descriptor has data.
+               if (select (max_fd + 1, &rfds, NULL, NULL, &tv) == -1) {
+                       if (errno == EINTR)
+                               continue;
+
+                       fprintf (stderr, "Error in mono-profiler-log server: %s", strerror (errno));
+                       exit (1);
+               }
+
+               if (!no_counters)
+                       counters_and_perfcounters_sample (prof);
+
+               buffer_lock_excl ();
+
+               sync_point (SYNC_POINT_PERIODIC);
+
+               buffer_unlock_excl ();
+
+               // Are we shutting down?
+               if (FD_ISSET (prof->pipes [0], &rfds)) {
+                       char c;
+                       read (prof->pipes [0], &c, 1);
+                       break;
+               }
+
+               for (gint i = 0; i < command_sockets->len; i++) {
+                       int fd = g_array_index (command_sockets, int, i);
+
+                       if (!FD_ISSET (fd, &rfds))
+                               continue;
+
+                       char buf [64];
+                       int len = read (fd, buf, sizeof (buf) - 1);
+
+                       if (len == -1)
+                               continue;
+
+                       if (!len) {
+                               // The other end disconnected.
+                               g_array_remove_index (command_sockets, i);
+                               close (fd);
+
+                               continue;
+                       }
+
+                       buf [len] = 0;
+
+                       if (!strcmp (buf, "heapshot\n") && hs_mode_ondemand) {
+                               // Rely on the finalization callback triggering a GC.
+                               heapshot_requested = 1;
+                               mono_gc_finalize_notify ();
+                       }
+               }
+
+               if (FD_ISSET (prof->server_socket, &rfds)) {
+                       int fd = accept (prof->server_socket, NULL, NULL);
+
+                       if (fd != -1) {
+                               if (fd >= FD_SETSIZE)
+                                       close (fd);
+                               else
+                                       g_array_append_val (command_sockets, fd);
+                       }
+               }
+       }
+
+       for (gint i = 0; i < command_sockets->len; i++)
+               close (g_array_index (command_sockets, int, i));
+
+       g_array_free (command_sockets, TRUE);
+
+       send_log_unsafe (FALSE);
+       deinit_thread (thread);
+
+       mono_thread_info_detach ();
+
+       return NULL;
+}
+
+static void
+start_helper_thread (MonoProfiler* prof)
+{
+       if (pipe (prof->pipes) == -1) {
+               fprintf (stderr, "Cannot create pipe: %s\n", strerror (errno));
+               exit (1);
+       }
+
+       prof->server_socket = socket (PF_INET, SOCK_STREAM, 0);
+
+       if (prof->server_socket == -1) {
+               fprintf (stderr, "Cannot create server socket: %s\n", strerror (errno));
+               exit (1);
+       }
+
+       struct sockaddr_in server_address;
+
+       memset (&server_address, 0, sizeof (server_address));
+       server_address.sin_family = AF_INET;
+       server_address.sin_addr.s_addr = INADDR_ANY;
+       server_address.sin_port = htons (prof->command_port);
+
+       if (bind (prof->server_socket, (struct sockaddr *) &server_address, sizeof (server_address)) == -1) {
+               fprintf (stderr, "Cannot bind server socket on port %d: %s\n", prof->command_port, strerror (errno));
+               close (prof->server_socket);
+               exit (1);
+       }
+
+       if (listen (prof->server_socket, 1) == -1) {
+               fprintf (stderr, "Cannot listen on server socket: %s\n", strerror (errno));
+               close (prof->server_socket);
+               exit (1);
+       }
+
+       socklen_t slen = sizeof (server_address);
+
+       if (getsockname (prof->server_socket, (struct sockaddr *) &server_address, &slen)) {
+               fprintf (stderr, "Could not get assigned port: %s\n", strerror (errno));
+               close (prof->server_socket);
+               exit (1);
+       }
+
+       prof->command_port = ntohs (server_address.sin_port);
+
+       if (!mono_native_thread_create (&prof->helper_thread, helper_thread, prof)) {
+               fprintf (stderr, "Could not start helper thread\n");
+               close (prof->server_socket);
+               exit (1);
+       }
+}
+
+static void
+free_writer_entry (gpointer p)
+{
+       mono_lock_free_free (p, WRITER_ENTRY_BLOCK_SIZE);
+}
+
+static gboolean
+handle_writer_queue_entry (MonoProfiler *prof)
+{
+       WriterQueueEntry *entry;
+
+       if ((entry = (WriterQueueEntry *) mono_lock_free_queue_dequeue (&prof->writer_queue))) {
+               if (!entry->methods)
+                       goto no_methods;
+
+               gboolean wrote_methods = FALSE;
+
+               /*
+                * Encode the method events in a temporary log buffer that we
+                * flush to disk before the main buffer, ensuring that all
+                * methods have metadata emitted before they're referenced.
+                *
+                * We use a 'proper' thread-local buffer for this as opposed
+                * to allocating and freeing a buffer by hand because the call
+                * to mono_method_full_name () below may trigger class load
+                * events when it retrieves the signature of the method. So a
+                * thread-local buffer needs to exist when such events occur.
+                */
+               for (guint i = 0; i < entry->methods->len; i++) {
+                       MethodInfo *info = (MethodInfo *) g_ptr_array_index (entry->methods, i);
+
+                       if (mono_conc_hashtable_lookup (prof->method_table, info->method))
+                               goto free_info; // This method already has metadata emitted.
+
+                       /*
+                        * Other threads use this hash table to get a general
+                        * idea of whether a method has already been emitted to
+                        * the stream. Due to the way we add to this table, it
+                        * can easily happen that multiple threads queue up the
+                        * same methods, but that's OK since eventually all
+                        * methods will be in this table and the thread-local
+                        * method lists will just be empty for the rest of the
+                        * app's lifetime.
+                        */
+                       mono_os_mutex_lock (&prof->method_table_mutex);
+                       mono_conc_hashtable_insert (prof->method_table, info->method, info->method);
+                       mono_os_mutex_unlock (&prof->method_table_mutex);
+
+                       char *name = mono_method_full_name (info->method, 1);
+                       int nlen = strlen (name) + 1;
+                       void *cstart = info->ji ? mono_jit_info_get_code_start (info->ji) : NULL;
+                       int csize = info->ji ? mono_jit_info_get_code_size (info->ji) : 0;
+
+                       ENTER_LOG (&method_jits_ctr, logbuffer,
+                               EVENT_SIZE /* event */ +
+                               LEB128_SIZE /* method */ +
+                               LEB128_SIZE /* start */ +
+                               LEB128_SIZE /* size */ +
+                               nlen /* name */
+                       );
+
+                       emit_event_time (logbuffer, TYPE_JIT | TYPE_METHOD, info->time);
+                       emit_method_inner (logbuffer, info->method);
+                       emit_ptr (logbuffer, cstart);
+                       emit_value (logbuffer, csize);
+
+                       memcpy (logbuffer->cursor, name, nlen);
+                       logbuffer->cursor += nlen;
+
+                       EXIT_LOG_EXPLICIT (NO_SEND);
+
+                       mono_free (name);
+
+                       wrote_methods = TRUE;
+
+               free_info:
+                       g_free (info);
+               }
+
+               g_ptr_array_free (entry->methods, TRUE);
+
+               if (wrote_methods) {
+                       dump_buffer_threadless (prof, PROF_TLS_GET ()->buffer);
+                       init_buffer_state (PROF_TLS_GET ());
+               }
+
+       no_methods:
+               dump_buffer (prof, entry->buffer);
+
+               mono_thread_hazardous_try_free (entry, free_writer_entry);
+
+               return TRUE;
+       }
+
+       return FALSE;
+}
+
+static void *
+writer_thread (void *arg)
+{
+       MonoProfiler *prof = (MonoProfiler *)arg;
+
+       mono_threads_attach_tools_thread ();
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler writer");
+
+       dump_header (prof);
+
+       MonoProfilerThread *thread = init_thread (prof, FALSE);
+
+       while (InterlockedRead (&prof->run_writer_thread)) {
+               mono_os_sem_wait (&prof->writer_queue_sem, MONO_SEM_FLAGS_NONE);
+               handle_writer_queue_entry (prof);
+       }
+
+       /* Drain any remaining entries on shutdown. */
+       while (handle_writer_queue_entry (prof));
+
+       free_buffer (thread->buffer, thread->buffer->size);
+       deinit_thread (thread);
+
+       mono_thread_info_detach ();
+
+       return NULL;
+}
+
+static void
+start_writer_thread (MonoProfiler* prof)
+{
+       InterlockedWrite (&prof->run_writer_thread, 1);
+
+       if (!mono_native_thread_create (&prof->writer_thread, writer_thread, prof)) {
+               fprintf (stderr, "Could not start writer thread\n");
+               exit (1);
+       }
+}
+
+static void
+reuse_sample_hit (gpointer p)
+{
+       SampleHit *sample = p;
+
+       mono_lock_free_queue_node_unpoison (&sample->node);
+       mono_lock_free_queue_enqueue (&sample->prof->sample_reuse_queue, &sample->node);
+}
+
+static gboolean
+handle_dumper_queue_entry (MonoProfiler *prof)
+{
+       SampleHit *sample;
+
+       if ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->dumper_queue))) {
+               for (int i = 0; i < sample->count; ++i) {
+                       MonoMethod *method = sample->frames [i].method;
+                       MonoDomain *domain = sample->frames [i].domain;
+                       void *address = sample->frames [i].base_address;
+
+                       if (!method) {
+                               g_assert (domain && "What happened to the domain pointer?");
+                               g_assert (address && "What happened to the instruction pointer?");
+
+                               MonoJitInfo *ji = mono_jit_info_table_find (domain, (char *) address);
+
+                               if (ji)
+                                       sample->frames [i].method = mono_jit_info_get_method (ji);
+                       }
+               }
+
+               ENTER_LOG (&sample_hits_ctr, logbuffer,
+                       EVENT_SIZE /* event */ +
+                       BYTE_SIZE /* type */ +
+                       LEB128_SIZE /* tid */ +
+                       LEB128_SIZE /* count */ +
+                       1 * (
+                               LEB128_SIZE /* ip */
+                       ) +
+                       LEB128_SIZE /* managed count */ +
+                       sample->count * (
+                               LEB128_SIZE /* method */
+                       )
+               );
+
+               emit_event_time (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_HIT, sample->time);
+               emit_byte (logbuffer, SAMPLE_CYCLES);
+               emit_ptr (logbuffer, (void *) sample->tid);
+               emit_value (logbuffer, 1);
+
+               // TODO: Actual native unwinding.
+               for (int i = 0; i < 1; ++i) {
+                       emit_ptr (logbuffer, sample->ip);
+                       add_code_pointer ((uintptr_t) sample->ip);
+               }
+
+               /* new in data version 6 */
+               emit_uvalue (logbuffer, sample->count);
+
+               for (int i = 0; i < sample->count; ++i)
+                       emit_method (logbuffer, sample->frames [i].method);
+
+               EXIT_LOG_EXPLICIT (DO_SEND);
+
+               mono_thread_hazardous_try_free (sample, reuse_sample_hit);
+
+               dump_unmanaged_coderefs (prof);
+       }
+
+       return FALSE;
+}
+
+static void *
+dumper_thread (void *arg)
+{
+       MonoProfiler *prof = (MonoProfiler *)arg;
+
+       mono_threads_attach_tools_thread ();
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler dumper");
+
+       MonoProfilerThread *thread = init_thread (prof, FALSE);
+
+       while (InterlockedRead (&prof->run_dumper_thread)) {
+               mono_os_sem_wait (&prof->dumper_queue_sem, MONO_SEM_FLAGS_NONE);
+               handle_dumper_queue_entry (prof);
+       }
+
+       /* Drain any remaining entries on shutdown. */
+       while (handle_dumper_queue_entry (prof));
+
+       send_log_unsafe (FALSE);
+       deinit_thread (thread);
+
+       mono_thread_info_detach ();
+
+       return NULL;
+}
+
+static void
+start_dumper_thread (MonoProfiler* prof)
+{
+       InterlockedWrite (&prof->run_dumper_thread, 1);
+
+       if (!mono_native_thread_create (&prof->dumper_thread, dumper_thread, prof)) {
+               fprintf (stderr, "Could not start dumper thread\n");
+               exit (1);
+       }
+}
+
+static void
+register_counter (const char *name, gint32 *counter)
+{
+       mono_counters_register (name, MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, counter);
+}
+
+static void
+runtime_initialized (MonoProfiler *profiler)
+{
+       InterlockedWrite (&runtime_inited, 1);
+
+       register_counter ("Sample events allocated", &sample_allocations_ctr);
+       register_counter ("Log buffers allocated", &buffer_allocations_ctr);
+
+       register_counter ("Event: Sync points", &sync_points_ctr);
+       register_counter ("Event: Heap objects", &heap_objects_ctr);
+       register_counter ("Event: Heap starts", &heap_starts_ctr);
+       register_counter ("Event: Heap ends", &heap_ends_ctr);
+       register_counter ("Event: Heap roots", &heap_roots_ctr);
+       register_counter ("Event: GC events", &gc_events_ctr);
+       register_counter ("Event: GC resizes", &gc_resizes_ctr);
+       register_counter ("Event: GC allocations", &gc_allocs_ctr);
+       register_counter ("Event: GC moves", &gc_moves_ctr);
+       register_counter ("Event: GC handle creations", &gc_handle_creations_ctr);
+       register_counter ("Event: GC handle deletions", &gc_handle_deletions_ctr);
+       register_counter ("Event: GC finalize starts", &finalize_begins_ctr);
+       register_counter ("Event: GC finalize ends", &finalize_ends_ctr);
+       register_counter ("Event: GC finalize object starts", &finalize_object_begins_ctr);
+       register_counter ("Event: GC finalize object ends", &finalize_object_ends_ctr);
+       register_counter ("Event: Image loads", &image_loads_ctr);
+       register_counter ("Event: Image unloads", &image_unloads_ctr);
+       register_counter ("Event: Assembly loads", &assembly_loads_ctr);
+       register_counter ("Event: Assembly unloads", &assembly_unloads_ctr);
+       register_counter ("Event: Class loads", &class_loads_ctr);
+       register_counter ("Event: Class unloads", &class_unloads_ctr);
+       register_counter ("Event: Method entries", &method_entries_ctr);
+       register_counter ("Event: Method exits", &method_exits_ctr);
+       register_counter ("Event: Method exception leaves", &method_exception_exits_ctr);
+       register_counter ("Event: Method JITs", &method_jits_ctr);
+       register_counter ("Event: Code buffers", &code_buffers_ctr);
+       register_counter ("Event: Exception throws", &exception_throws_ctr);
+       register_counter ("Event: Exception clauses", &exception_clauses_ctr);
+       register_counter ("Event: Monitor contentions", &monitor_contentions_ctr);
+       register_counter ("Event: Monitor acquisitions", &monitor_acquisitions_ctr);
+       register_counter ("Event: Monitor failures", &monitor_failures_ctr);
+       register_counter ("Event: Thread starts", &thread_starts_ctr);
+       register_counter ("Event: Thread ends", &thread_ends_ctr);
+       register_counter ("Event: Thread names", &thread_names_ctr);
+       register_counter ("Event: Domain loads", &domain_loads_ctr);
+       register_counter ("Event: Domain unloads", &domain_unloads_ctr);
+       register_counter ("Event: Domain names", &domain_names_ctr);
+       register_counter ("Event: Context loads", &context_loads_ctr);
+       register_counter ("Event: Context unloads", &context_unloads_ctr);
+       register_counter ("Event: Sample binaries", &sample_ubins_ctr);
+       register_counter ("Event: Sample symbols", &sample_usyms_ctr);
+       register_counter ("Event: Sample hits", &sample_hits_ctr);
+       register_counter ("Event: Counter descriptors", &counter_descriptors_ctr);
+       register_counter ("Event: Counter samples", &counter_samples_ctr);
+       register_counter ("Event: Performance counter descriptors", &perfcounter_descriptors_ctr);
+       register_counter ("Event: Performance counter samples", &perfcounter_samples_ctr);
+       register_counter ("Event: Coverage methods", &coverage_methods_ctr);
+       register_counter ("Event: Coverage statements", &coverage_statements_ctr);
+       register_counter ("Event: Coverage classes", &coverage_classes_ctr);
+       register_counter ("Event: Coverage assemblies", &coverage_assemblies_ctr);
+
+       counters_init (profiler);
+
+       /*
+        * We must start the helper thread before the writer thread. This is
+        * because the helper thread sets up the command port which is written to
+        * the log header by the writer thread.
+        */
+       start_helper_thread (profiler);
+       start_writer_thread (profiler);
+       start_dumper_thread (profiler);
+}
+
+static MonoProfiler*
+create_profiler (const char *args, const char *filename, GPtrArray *filters)
+{
+       MonoProfiler *prof;
+       char *nf;
+       int force_delete = 0;
+       prof = (MonoProfiler *) g_calloc (1, sizeof (MonoProfiler));
+
+       prof->args = pstrdup (args);
+       prof->command_port = command_port;
+       if (filename && *filename == '-') {
+               force_delete = 1;
+               filename++;
+               g_warning ("WARNING: the output:-FILENAME option is deprecated, the profiler now always overrides the output file\n");
+       }
+
+       //If filename begin with +, append the pid at the end
+       if (filename && *filename == '+')
+               filename = g_strdup_printf ("%s.%d", filename + 1, getpid ());
+
+
+       if (!filename) {
+               if (do_report)
+                       filename = "|mprof-report -";
+               else
+                       filename = "output.mlpd";
+               nf = (char*)filename;
+       } else {
+               nf = new_filename (filename);
+               if (do_report) {
+                       int s = strlen (nf) + 32;
+                       char *p = (char *) g_malloc (s);
+                       snprintf (p, s, "|mprof-report '--out=%s' -", nf);
+                       g_free (nf);
+                       nf = p;
+               }
+       }
+       if (*nf == '|') {
+               prof->file = popen (nf + 1, "w");
+               prof->pipe_output = 1;
+       } else if (*nf == '#') {
+               int fd = strtol (nf + 1, NULL, 10);
+               prof->file = fdopen (fd, "a");
+       } else {
+               if (force_delete)
+                       unlink (nf);
+               prof->file = fopen (nf, "wb");
+       }
+       if (!prof->file) {
+               fprintf (stderr, "Cannot create profiler output: %s\n", nf);
+               exit (1);
+       }
+
+#if defined (HAVE_SYS_ZLIB)
+       if (use_zip)
+               prof->gzfile = gzdopen (fileno (prof->file), "wb");
+#endif
+
+       /*
+        * If you hit this assert while increasing MAX_FRAMES, you need to increase
+        * SAMPLE_BLOCK_SIZE as well.
+        */
+       g_assert (SAMPLE_SLOT_SIZE (MAX_FRAMES) * 2 < LOCK_FREE_ALLOC_SB_USABLE_SIZE (SAMPLE_BLOCK_SIZE));
+
+       // 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_MEM_ACCOUNT_PROFILER);
+
+       mono_lock_free_queue_init (&prof->sample_reuse_queue);
+
+       g_assert (sizeof (WriterQueueEntry) * 2 < LOCK_FREE_ALLOC_SB_USABLE_SIZE (WRITER_ENTRY_BLOCK_SIZE));
+
+       // 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_MEM_ACCOUNT_PROFILER);
+
+       mono_lock_free_queue_init (&prof->writer_queue);
+       mono_os_sem_init (&prof->writer_queue_sem, 0);
+
+       mono_lock_free_queue_init (&prof->dumper_queue);
+       mono_os_sem_init (&prof->dumper_queue_sem, 0);
+
+       mono_os_mutex_init (&prof->method_table_mutex);
+       prof->method_table = mono_conc_hashtable_new (NULL, NULL);
+
+       if (do_coverage)
+               coverage_init (prof);
+       prof->coverage_filters = filters;
+
+       prof->startup_time = current_time ();
+       return prof;
+}
+
+/*
+ * declaration to silence the compiler: this is the entry point that
+ * mono will load from the shared library and call.
+ */
+extern void
+mono_profiler_startup (const char *desc);
+
+extern void
+mono_profiler_startup_log (const char *desc);
+
+/*
+ * this is the entry point that will be used when the profiler
+ * is embedded inside the main executable.
+ */
+void
+mono_profiler_startup_log (const char *desc)
+{
+       mono_profiler_startup (desc);
+}
+
+void
+mono_profiler_startup (const char *desc)
+{
+       GPtrArray *filters = NULL;
+       MonoProfiler *prof;
+
+       proflog_parse_args (&config, desc [3] == ':' ? desc + 4 : "");
+
+       //XXX maybe later cleanup to use config directly
+       nocalls = !(config.effective_mask & PROFLOG_CALL_EVENTS);
+       no_counters = !(config.effective_mask & PROFLOG_COUNTER_EVENTS);
+       do_report = config.do_report;
+       do_debug = config.do_debug;
+       do_heap_shot = (config.effective_mask & PROFLOG_HEAPSHOT_FEATURE);
+       hs_mode_ondemand = config.hs_mode_ondemand;
+       hs_mode_ms = config.hs_mode_ms;
+       hs_mode_gc = config.hs_mode_gc;
+       do_mono_sample = (config.effective_mask & PROFLOG_SAMPLING_FEATURE);
+       use_zip = config.use_zip;
+       command_port = config.command_port;
+       num_frames = config.num_frames;
+       notraces = config.notraces;
+       max_allocated_sample_hits = config.max_allocated_sample_hits;
+       max_call_depth = config.max_call_depth;
+       do_coverage = (config.effective_mask & PROFLOG_CODE_COV_FEATURE);
+       debug_coverage = config.debug_coverage;
+       only_coverage = config.only_coverage;
+
+       if (config.cov_filter_files) {
+               filters = g_ptr_array_new ();
+               int i;
+               for (i = 0; i < config.cov_filter_files->len; ++i) {
+                       const char *name = config.cov_filter_files->pdata [i];
+                       parse_cov_filter_file (filters, name);
+               }
+       }
+
+       init_time ();
+
+       PROF_TLS_INIT ();
+
+       prof = create_profiler (desc, config.output_filename, filters);
+       if (!prof) {
+               PROF_TLS_FREE ();
+               return;
+       }
+
+       mono_lls_init (&profiler_thread_list, NULL);
+
+       init_thread (prof, TRUE);
+
+       //This two events are required for the profiler to work
+       int events = MONO_PROFILE_THREADS | MONO_PROFILE_GC;
+
+       //Required callbacks
+       mono_profiler_install (prof, log_shutdown);
+       mono_profiler_install_runtime_initialized (runtime_initialized);
+
+       mono_profiler_install_gc (gc_event, gc_resize);
+       mono_profiler_install_thread (thread_start, thread_end);
+
+       //It's questionable whether we actually want this to be mandatory, maybe put it behind the actual event?
+       mono_profiler_install_thread_name (thread_name);
+
+
+       if (config.effective_mask & PROFLOG_DOMAIN_EVENTS) {
+               events |= MONO_PROFILE_APPDOMAIN_EVENTS;
+               mono_profiler_install_appdomain (NULL, domain_loaded, domain_unloaded, NULL);
+               mono_profiler_install_appdomain_name (domain_name);
+       }
+
+       if (config.effective_mask & PROFLOG_ASSEMBLY_EVENTS) {
+               events |= MONO_PROFILE_ASSEMBLY_EVENTS;
+               mono_profiler_install_assembly (NULL, assembly_loaded, assembly_unloaded, NULL);
+       }
+
+       if (config.effective_mask & PROFLOG_MODULE_EVENTS) {
+               events |= MONO_PROFILE_MODULE_EVENTS;
+               mono_profiler_install_module (NULL, image_loaded, image_unloaded, NULL);
+       }
+
+       if (config.effective_mask & PROFLOG_CLASS_EVENTS) {
+               events |= MONO_PROFILE_CLASS_EVENTS;
+               mono_profiler_install_class (NULL, class_loaded, class_unloaded, NULL);
+       }
+
+       if (config.effective_mask & PROFLOG_JIT_COMPILATION_EVENTS) {
+               events |= MONO_PROFILE_JIT_COMPILATION;
+               mono_profiler_install_jit_end (method_jitted);
+               mono_profiler_install_code_buffer_new (code_buffer_new);
+       }
+
+       if (config.effective_mask & PROFLOG_EXCEPTION_EVENTS) {
+               events |= MONO_PROFILE_EXCEPTIONS;
+               mono_profiler_install_exception (throw_exc, method_exc_leave, clause_exc);
+       }
+
+       if (config.effective_mask & PROFLOG_ALLOCATION_EVENTS) {
+               events |= MONO_PROFILE_ALLOCATIONS;
+               mono_profiler_install_allocation (gc_alloc);
+       }
+
+       //PROFLOG_GC_EVENTS is mandatory
+       //PROFLOG_THREAD_EVENTS is mandatory
+
+       if (config.effective_mask & PROFLOG_CALL_EVENTS) {
+               events |= MONO_PROFILE_ENTER_LEAVE;
+               mono_profiler_install_enter_leave (method_enter, method_leave);
+       }
+
+       if (config.effective_mask & PROFLOG_INS_COVERAGE_EVENTS) {
+               events |= MONO_PROFILE_INS_COVERAGE;
+               mono_profiler_install_coverage_filter (coverage_filter);
+       }
+
+       //XXX should we check for PROFLOG_SAMPLING_FEATURE instead??
+       if (config.effective_mask & PROFLOG_SAMPLING_EVENTS) {
+               events |= MONO_PROFILE_STATISTICAL;
+               mono_profiler_set_statistical_mode (config.sampling_mode, config.sample_freq);
+               mono_profiler_install_statistical (mono_sample_hit);
+       }
+
+       if (config.effective_mask & PROFLOG_MONITOR_EVENTS) {
+               events |= MONO_PROFILE_MONITOR_EVENTS;
+               mono_profiler_install_monitor (monitor_event);
+       }
+
+       if (config.effective_mask & PROFLOG_GC_MOVES_EVENTS) {
+               events |= MONO_PROFILE_GC_MOVES;
+               mono_profiler_install_gc_moves (gc_moves);
+       }
+
+       // TODO split those in two profiler events
+       if (config.effective_mask & (PROFLOG_GC_ROOT_EVENTS | PROFLOG_GC_HANDLE_EVENTS)) {
+               events |= MONO_PROFILE_GC_ROOTS;
+               mono_profiler_install_gc_roots (
+                       config.effective_mask & (PROFLOG_GC_HANDLE_EVENTS) ? gc_handle : NULL,
+                       (config.effective_mask & PROFLOG_GC_ROOT_EVENTS) ? gc_roots : NULL);
+       }
+
+       if (config.effective_mask & PROFLOG_CONTEXT_EVENTS) {
+               events |= MONO_PROFILE_CONTEXT_EVENTS;
+               mono_profiler_install_context (context_loaded, context_unloaded);
+       }
+
+       if (config.effective_mask & PROFLOG_FINALIZATION_EVENTS) {
+               events |= MONO_PROFILE_GC_FINALIZATION;
+               mono_profiler_install_gc_finalize (finalize_begin, finalize_object_begin, finalize_object_end, finalize_end);   
+       } else if (ENABLED (PROFLOG_HEAPSHOT_FEATURE) && config.hs_mode_ondemand) {
+               //On Demand heapshot uses the finalizer thread to force a collection and thus a heapshot
+               events |= MONO_PROFILE_GC_FINALIZATION;
+               mono_profiler_install_gc_finalize (NULL, NULL, NULL, finalize_end);
+       }
+
+       //PROFLOG_COUNTER_EVENTS is a pseudo event controled by the no_counters global var
+       //PROFLOG_GC_HANDLE_EVENTS is handled together with PROFLOG_GC_ROOT_EVENTS
+
+       mono_profiler_set_events ((MonoProfileFlags)events);
+}
diff --git a/mono/profiler/log.h b/mono/profiler/log.h
new file mode 100644 (file)
index 0000000..ee1d1d3
--- /dev/null
@@ -0,0 +1,267 @@
+#ifndef __MONO_PROFLOG_H__
+#define __MONO_PROFLOG_H__
+
+#include <glib.h>
+#include <mono/metadata/profiler.h>
+
+#define BUF_ID 0x4D504C01
+#define LOG_HEADER_ID 0x4D505A01
+#define LOG_VERSION_MAJOR 1
+#define LOG_VERSION_MINOR 1
+#define LOG_DATA_VERSION 13
+
+/*
+ * Changes in major/minor versions:
+ * version 1.0: removed sysid field from header
+ *              added args, arch, os fields to header
+ *
+ * Changes in data versions:
+ * version 2: added offsets in heap walk
+ * version 3: added GC roots
+ * version 4: added sample/statistical profiling
+ * version 5: added counters sampling
+ * version 6: added optional backtrace in sampling info
+ * version 8: added TYPE_RUNTIME and JIT helpers/trampolines
+ * version 9: added MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING
+ * version 10: added TYPE_COVERAGE
+ * version 11: added thread ID to TYPE_SAMPLE_HIT
+               added more load/unload events
+                   unload for class
+                   unload for image
+                   load/unload for appdomain
+                   load/unload for contexts
+                   load/unload/name for assemblies
+               removed TYPE_LOAD_ERR flag (profiler never generated it, now removed from the format itself)
+               added TYPE_GC_HANDLE_{CREATED,DESTROYED}_BT
+               TYPE_JIT events are no longer guaranteed to have code start/size info (can be zero)
+ * version 12: added MONO_COUNTER_PROFILER
+ * version 13: added MONO_GC_EVENT_{PRE_STOP_WORLD_LOCKED,POST_START_WORLD_UNLOCKED}
+               added TYPE_META + TYPE_SYNC_POINT
+               removed il and native offset in TYPE_SAMPLE_HIT
+               methods in backtraces are now encoded as proper method pointers
+               removed flags in backtrace format
+               removed flags in metadata events
+               changed the following fields to a single byte rather than leb128
+                   TYPE_GC_EVENT: event_type, generation
+                   TYPE_HEAP_ROOT: root_type
+                   TYPE_JITHELPER: type
+                   TYPE_SAMPLE_HIT: sample_type
+                   TYPE_CLAUSE: clause_type
+                   TYPE_SAMPLE_COUNTERS_DESC: type, unit, variance
+                   TYPE_SAMPLE_COUNTERS: type
+               added time fields to all events that were missing one
+                   TYPE_HEAP_OBJECT
+                   TYPE_HEAP_ROOT
+                   TYPE_SAMPLE_USYM
+                   TYPE_SAMPLE_COUNTERS_DESC
+                   TYPE_COVERAGE_METHOD
+                   TYPE_COVERAGE_STATEMENT
+                   TYPE_COVERAGE_CLASS
+                   TYPE_COVERAGE_ASSEMBLY
+               moved the time field in TYPE_SAMPLE_HIT to right after the event byte, now encoded as a regular time field
+               changed the time field in TYPE_SAMPLE_COUNTERS to be encoded as a regular time field (in nanoseconds)
+               added TYPE_GC_FINALIZE_{START,END,OBJECT_START,OBJECT_END}
+ */
+
+enum {
+       TYPE_ALLOC,
+       TYPE_GC,
+       TYPE_METADATA,
+       TYPE_METHOD,
+       TYPE_EXCEPTION,
+       TYPE_MONITOR,
+       TYPE_HEAP,
+       TYPE_SAMPLE,
+       TYPE_RUNTIME,
+       TYPE_COVERAGE,
+       TYPE_META,
+       /* extended type for TYPE_HEAP */
+       TYPE_HEAP_START  = 0 << 4,
+       TYPE_HEAP_END    = 1 << 4,
+       TYPE_HEAP_OBJECT = 2 << 4,
+       TYPE_HEAP_ROOT   = 3 << 4,
+       /* extended type for TYPE_METADATA */
+       TYPE_END_LOAD     = 2 << 4,
+       TYPE_END_UNLOAD   = 4 << 4,
+       /* extended type for TYPE_GC */
+       TYPE_GC_EVENT  = 1 << 4,
+       TYPE_GC_RESIZE = 2 << 4,
+       TYPE_GC_MOVE   = 3 << 4,
+       TYPE_GC_HANDLE_CREATED      = 4 << 4,
+       TYPE_GC_HANDLE_DESTROYED    = 5 << 4,
+       TYPE_GC_HANDLE_CREATED_BT   = 6 << 4,
+       TYPE_GC_HANDLE_DESTROYED_BT = 7 << 4,
+       TYPE_GC_FINALIZE_START = 8 << 4,
+       TYPE_GC_FINALIZE_END = 9 << 4,
+       TYPE_GC_FINALIZE_OBJECT_START = 10 << 4,
+       TYPE_GC_FINALIZE_OBJECT_END = 11 << 4,
+       /* extended type for TYPE_METHOD */
+       TYPE_LEAVE     = 1 << 4,
+       TYPE_ENTER     = 2 << 4,
+       TYPE_EXC_LEAVE = 3 << 4,
+       TYPE_JIT       = 4 << 4,
+       /* extended type for TYPE_EXCEPTION */
+       TYPE_THROW_NO_BT = 0 << 7,
+       TYPE_THROW_BT    = 1 << 7,
+       TYPE_CLAUSE      = 1 << 4,
+       /* extended type for TYPE_ALLOC */
+       TYPE_ALLOC_NO_BT  = 0 << 4,
+       TYPE_ALLOC_BT     = 1 << 4,
+       /* extended type for TYPE_MONITOR */
+       TYPE_MONITOR_NO_BT  = 0 << 7,
+       TYPE_MONITOR_BT     = 1 << 7,
+       /* extended type for TYPE_SAMPLE */
+       TYPE_SAMPLE_HIT           = 0 << 4,
+       TYPE_SAMPLE_USYM          = 1 << 4,
+       TYPE_SAMPLE_UBIN          = 2 << 4,
+       TYPE_SAMPLE_COUNTERS_DESC = 3 << 4,
+       TYPE_SAMPLE_COUNTERS      = 4 << 4,
+       /* extended type for TYPE_RUNTIME */
+       TYPE_JITHELPER = 1 << 4,
+       /* extended type for TYPE_COVERAGE */
+       TYPE_COVERAGE_ASSEMBLY = 0 << 4,
+       TYPE_COVERAGE_METHOD   = 1 << 4,
+       TYPE_COVERAGE_STATEMENT = 2 << 4,
+       TYPE_COVERAGE_CLASS = 3 << 4,
+       /* extended type for TYPE_META */
+       TYPE_SYNC_POINT = 0 << 4,
+       TYPE_END
+};
+
+enum {
+       /* metadata type byte for TYPE_METADATA */
+       TYPE_CLASS    = 1,
+       TYPE_IMAGE    = 2,
+       TYPE_ASSEMBLY = 3,
+       TYPE_DOMAIN   = 4,
+       TYPE_THREAD   = 5,
+       TYPE_CONTEXT  = 6,
+};
+
+typedef enum {
+       SYNC_POINT_PERIODIC,
+       SYNC_POINT_WORLD_STOP,
+       SYNC_POINT_WORLD_START
+} MonoProfilerSyncPointType;
+
+// Sampling sources
+// Unless you have compiled with --enable-perf-events, only SAMPLE_CYCLES is available
+enum {
+       SAMPLE_CYCLES = 1,
+       SAMPLE_INSTRUCTIONS,
+       SAMPLE_CACHE_MISSES,
+       SAMPLE_CACHE_REFS,
+       SAMPLE_BRANCHES,
+       SAMPLE_BRANCH_MISSES,
+       SAMPLE_LAST
+};
+
+
+// If you alter MAX_FRAMES, you may need to alter SAMPLE_BLOCK_SIZE too.
+#define MAX_FRAMES 32
+
+//The following flags control emitting individual events
+#define PROFLOG_DOMAIN_EVENTS (1 << 0)
+#define PROFLOG_ASSEMBLY_EVENTS        (1 << 1)
+#define PROFLOG_MODULE_EVENTS (1 << 2)
+#define PROFLOG_CLASS_EVENTS (1 << 3)
+#define PROFLOG_JIT_COMPILATION_EVENTS (1 << 4)
+#define PROFLOG_EXCEPTION_EVENTS (1 << 5)
+#define PROFLOG_ALLOCATION_EVENTS (1 << 6)
+#define PROFLOG_GC_EVENTS (1 << 7)
+#define PROFLOG_THREAD_EVENTS (1 << 8)
+//This generate enter/leave events
+#define PROFLOG_CALL_EVENTS (1 << 9)
+#define PROFLOG_INS_COVERAGE_EVENTS (1 << 10)
+#define PROFLOG_SAMPLING_EVENTS (1 << 11)
+#define PROFLOG_MONITOR_EVENTS (1 << 12)
+#define PROFLOG_GC_MOVES_EVENTS (1 << 13)
+
+#define PROFLOG_GC_ROOT_EVENTS (1 << 14)
+#define PROFLOG_CONTEXT_EVENTS (1 << 15)
+#define PROFLOG_FINALIZATION_EVENTS (1 << 16)
+#define PROFLOG_COUNTER_EVENTS (1 << 17)
+#define PROFLOG_GC_HANDLE_EVENTS (1 << 18)
+
+//The following flags control whole subsystems
+//Enables code coverage generation
+#define PROFLOG_CODE_COV_FEATURE (1 << 19)
+//This enables sampling to be generated
+#define PROFLOG_SAMPLING_FEATURE (1 << 20)
+//This enable heap dumping during GCs and filter GCRoots and GCHandle events outside of the dumped collections
+#define PROFLOG_HEAPSHOT_FEATURE (1 << 21)
+
+
+
+//The follow flags are the common aliases we want ppl to use
+#define PROFLOG_TYPELOADING_ALIAS (PROFLOG_DOMAIN_EVENTS | PROFLOG_ASSEMBLY_EVENTS | PROFLOG_MODULE_EVENTS | PROFLOG_CLASS_EVENTS)
+#define PROFLOG_CODECOV_ALIAS (PROFLOG_GC_EVENTS | PROFLOG_THREAD_EVENTS | PROFLOG_CALL_EVENTS | PROFLOG_INS_COVERAGE_EVENTS | PROFLOG_CODE_COV_FEATURE)
+#define PROFLOG_PERF_SAMPLING_ALIAS (PROFLOG_TYPELOADING_ALIAS | PROFLOG_THREAD_EVENTS | PROFLOG_SAMPLING_EVENTS | PROFLOG_SAMPLING_FEATURE)
+#define PROFLOG_GC_ALLOC_ALIAS (PROFLOG_TYPELOADING_ALIAS | PROFLOG_THREAD_EVENTS | PROFLOG_GC_EVENTS | PROFLOG_ALLOCATION_EVENTS)
+#define PROFLOG_HEAPSHOT_ALIAS (PROFLOG_TYPELOADING_ALIAS | PROFLOG_THREAD_EVENTS | PROFLOG_GC_EVENTS | PROFLOG_GC_ROOT_EVENTS | PROFLOG_HEAPSHOT_FEATURE)
+#define PROFLOG_LEGACY_ALIAS (PROFLOG_TYPELOADING_ALIAS | PROFLOG_GC_EVENTS | PROFLOG_THREAD_EVENTS | PROFLOG_JIT_COMPILATION_EVENTS | PROFLOG_EXCEPTION_EVENTS | PROFLOG_MONITOR_EVENTS | PROFLOG_GC_ROOT_EVENTS | PROFLOG_CONTEXT_EVENTS | PROFLOG_FINALIZATION_EVENTS | PROFLOG_COUNTER_EVENTS)
+
+
+typedef struct {
+       //Events explicitly enabled
+       int enable_mask;
+       //Events explicitly disabled
+       int disable_mask;
+
+       //Actual mask the profiler should use
+       int effective_mask;
+
+       //Emit a report at the end of execution
+       gboolean do_report;
+
+       //Enable profiler internal debugging
+       gboolean do_debug;
+
+       //Enable code coverage specific debugging
+       gboolean debug_coverage;
+
+       //Where to compress the output file
+       gboolean use_zip;
+
+       //If true, don't generate stacktraces
+       gboolean notraces;
+
+       //If true, emit coverage but don't emit enter/exit events - this happens cuz they share an event
+       gboolean only_coverage;
+
+       //If true, heapshots are generated on demand only
+       gboolean hs_mode_ondemand;
+
+       //HeapShort frequency in milliseconds
+       unsigned int hs_mode_ms;
+
+       //HeapShort frequency in number of collections
+       unsigned int hs_mode_gc;
+
+       //Sample frequency in Hertz
+       int sample_freq;
+
+       //Maximum number of frames to collect
+       int num_frames;
+
+       //Max depth to record enter/leave events
+       int max_call_depth;
+
+       //Name of the generated mlpd file
+       const char *output_filename;
+
+       //Filter files used by the code coverage mode
+       GPtrArray *cov_filter_files;
+
+       //Port to listen for profiling commands
+       int command_port;
+
+       //Max size of the sample hit buffer, we'll drop frames if it's reached
+       int max_allocated_sample_hits;
+
+       MonoProfileSamplingMode sampling_mode;
+} ProfilerConfig;
+
+void proflog_parse_args (ProfilerConfig *config, const char *desc);
+
+#endif /* __MONO_PROFLOG_H__ */
diff --git a/mono/profiler/mono-profiler-aot.c b/mono/profiler/mono-profiler-aot.c
deleted file mode 100644 (file)
index 384e624..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * mono-profiler-aot.c: Ahead of Time Compiler Profiler for Mono.
- *
- *
- * Copyright 2008-2009 Novell, Inc (http://www.novell.com)
- *
- * This profiler collects profiling information usable by the Mono AOT compiler
- * to generate better code. It saves the information into files under ~/.mono. 
- * The AOT compiler can load these files during compilation.
- * Currently, only the order in which methods were compiled is saved, 
- * allowing more efficient function ordering in the AOT files.
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-
-#include "mono-profiler-aot.h"
-
-#include <mono/metadata/profiler.h>
-#include <mono/metadata/tokentype.h>
-#include <mono/metadata/tabledefs.h>
-#include <mono/metadata/debug-helpers.h>
-#include <mono/metadata/assembly.h>
-#include <mono/metadata/class-internals.h>
-#include <mono/utils/mono-os-mutex.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <sys/stat.h>
-
-#ifdef HOST_WIN32
-#include <direct.h>
-#endif
-
-struct _MonoProfiler {
-       GHashTable *classes;
-       GHashTable *images;
-       GPtrArray *methods;
-       FILE *outfile;
-       int id;
-       char *outfile_name;
-};
-
-static mono_mutex_t mutex;
-static gboolean verbose;
-
-static void
-prof_jit_enter (MonoProfiler *prof, MonoMethod *method)
-{
-}
-
-static void
-prof_jit_leave (MonoProfiler *prof, MonoMethod *method, int result)
-{
-       MonoImage *image = mono_class_get_image (mono_method_get_class (method));
-
-       if (!image->assembly || method->wrapper_type)
-               return;
-
-       mono_os_mutex_lock (&mutex);
-       g_ptr_array_add (prof->methods, method);
-       mono_os_mutex_unlock (&mutex);
-}
-
-static void
-prof_shutdown (MonoProfiler *prof);
-
-static void
-usage (int do_exit)
-{
-       printf ("AOT profiler.\n");
-       printf ("Usage: mono --profile=aot[:OPTION1[,OPTION2...]] program.exe\n");
-       printf ("Options:\n");
-       printf ("\thelp                 show this usage info\n");
-       printf ("\toutput=FILENAME      write the data to file FILENAME (required)\n");
-       printf ("\tverbose              print diagnostic info\n");
-       if (do_exit)
-               exit (1);
-}
-
-static const char*
-match_option (const char* p, const char *opt, char **rval)
-{
-       int len = strlen (opt);
-       if (strncmp (p, opt, len) == 0) {
-               if (rval) {
-                       if (p [len] == '=' && p [len + 1]) {
-                               const char *opt = p + len + 1;
-                               const char *end = strchr (opt, ',');
-                               char *val;
-                               int l;
-                               if (end == NULL) {
-                                       l = strlen (opt);
-                               } else {
-                                       l = end - opt;
-                               }
-                               val = (char *) g_malloc (l + 1);
-                               memcpy (val, opt, l);
-                               val [l] = 0;
-                               *rval = val;
-                               return opt + l;
-                       }
-                       if (p [len] == 0 || p [len] == ',') {
-                               *rval = NULL;
-                               return p + len + (p [len] == ',');
-                       }
-                       usage (1);
-               } else {
-                       if (p [len] == 0)
-                               return p + len;
-                       if (p [len] == ',')
-                               return p + len + 1;
-               }
-       }
-       return p;
-}
-
-void
-mono_profiler_startup (const char *desc);
-
-/**
- * mono_profiler_startup:
- * the entry point
- */
-void
-mono_profiler_startup (const char *desc)
-{
-       MonoProfiler *prof;
-       const char *p;
-       const char *opt;
-       char *outfile_name;
-
-       p = desc;
-       if (strncmp (p, "aot", 3))
-               usage (1);
-       p += 3;
-       if (*p == ':')
-               p++;
-       for (; *p; p = opt) {
-               char *val;
-               if (*p == ',') {
-                       opt = p + 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "help", NULL)) != p) {
-                       usage (0);
-                       continue;
-               }
-               if ((opt = match_option (p, "verbose", NULL)) != p) {
-                       verbose = TRUE;
-                       continue;
-               }
-               if ((opt = match_option (p, "output", &val)) != p) {
-                       outfile_name = val;
-                       continue;
-               }
-               fprintf (stderr, "mono-profiler-aot: Unknown option: '%s'.\n", p);
-               exit (1);
-       }
-
-       if (!outfile_name) {
-               fprintf (stderr, "mono-profiler-aot: The 'output' argument is required.\n");
-               exit (1);
-       }
-
-       prof = g_new0 (MonoProfiler, 1);
-       prof->images = g_hash_table_new (NULL, NULL);
-       prof->classes = g_hash_table_new (NULL, NULL);
-       prof->methods = g_ptr_array_new ();
-       prof->outfile_name = outfile_name;
-
-       mono_os_mutex_init (&mutex);
-
-       mono_profiler_install (prof, prof_shutdown);
-
-       mono_profiler_install_jit_compile (prof_jit_enter, prof_jit_leave);
-
-       mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION);
-}
-
-static void
-emit_byte (MonoProfiler *prof, guint8 value)
-{
-       fwrite (&value, 1, 1, prof->outfile);
-}
-
-static void
-emit_int32 (MonoProfiler *prof, int value)
-{
-       // FIXME: Endianness
-       fwrite (&value, 4, 1, prof->outfile);
-}
-
-static void
-emit_string (MonoProfiler *prof, const char *str)
-{
-       int len = strlen (str);
-
-       emit_int32 (prof, len);
-       fwrite (str, len, 1, prof->outfile);
-}
-
-static void
-emit_record (MonoProfiler *prof, AotProfRecordType type, int id)
-{
-       emit_byte (prof, type);
-       emit_int32 (prof, id);
-}
-
-static int
-add_image (MonoProfiler *prof, MonoImage *image)
-{
-       int id = GPOINTER_TO_INT (g_hash_table_lookup (prof->images, image));
-       if (id)
-               return id - 1;
-
-       id = prof->id ++;
-       emit_record (prof, AOTPROF_RECORD_IMAGE, id);
-       emit_string (prof, image->assembly->aname.name);
-       emit_string (prof, image->guid);
-       g_hash_table_insert (prof->images, image, GINT_TO_POINTER (id + 1));
-       return id;
-}
-
-static int
-add_class (MonoProfiler *prof, MonoClass *klass);
-
-static int
-add_type (MonoProfiler *prof, MonoType *type)
-{
-       switch (type->type) {
-#if 0
-       case MONO_TYPE_SZARRAY: {
-               int eid = add_type (prof, &type->data.klass->byval_arg);
-               if (eid == -1)
-                       return -1;
-               int id = prof->id ++;
-               emit_record (prof, AOTPROF_RECORD_TYPE, id);
-               emit_byte (prof, MONO_TYPE_SZARRAY);
-               emit_int32 (prof, id);
-               return id;
-       }
-#endif
-       case MONO_TYPE_BOOLEAN:
-       case MONO_TYPE_CHAR:
-       case MONO_TYPE_I1:
-       case MONO_TYPE_U1:
-       case MONO_TYPE_I2:
-       case MONO_TYPE_U2:
-       case MONO_TYPE_I4:
-       case MONO_TYPE_U4:
-       case MONO_TYPE_I8:
-       case MONO_TYPE_U8:
-       case MONO_TYPE_R4:
-       case MONO_TYPE_R8:
-       case MONO_TYPE_I:
-       case MONO_TYPE_U:
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_VALUETYPE:
-       case MONO_TYPE_GENERICINST:
-               return add_class (prof, mono_class_from_mono_type (type));
-       default:
-               return -1;
-       }
-}
-
-static int
-add_ginst (MonoProfiler *prof, MonoGenericInst *inst)
-{
-       int i, id;
-       int *ids;
-
-       // FIXME: Cache
-       ids = g_malloc0 (inst->type_argc * sizeof (int));
-       for (i = 0; i < inst->type_argc; ++i) {
-               MonoType *t = inst->type_argv [i];
-               ids [i] = add_type (prof, t);
-               if (ids [i] == -1) {
-                       g_free (ids);
-                       return -1;
-               }
-       }
-       id = prof->id ++;
-       emit_record (prof, AOTPROF_RECORD_GINST, id);
-       emit_int32 (prof, inst->type_argc);
-       for (i = 0; i < inst->type_argc; ++i)
-               emit_int32 (prof, ids [i]);
-       g_free (ids);
-
-       return id;
-}
-
-static int
-add_class (MonoProfiler *prof, MonoClass *klass)
-{
-       int id, inst_id = -1, image_id;
-       char *name;
-
-       id = GPOINTER_TO_INT (g_hash_table_lookup (prof->classes, klass));
-       if (id)
-               return id - 1;
-
-       image_id = add_image (prof, klass->image);
-
-       if (mono_class_is_ginst (klass)) {
-               MonoGenericContext *ctx = mono_class_get_context (klass);
-               inst_id = add_ginst (prof, ctx->class_inst);
-               if (inst_id == -1)
-                       return -1;
-       }
-
-       if (klass->nested_in)
-               name = g_strdup_printf ("%s.%s/%s", klass->nested_in->name_space, klass->nested_in->name, klass->name);
-       else
-               name = g_strdup_printf ("%s.%s", klass->name_space, klass->name);
-
-       id = prof->id ++;
-       emit_record (prof, AOTPROF_RECORD_TYPE, id);
-       emit_byte (prof, MONO_TYPE_CLASS);
-       emit_int32 (prof, image_id);
-       emit_int32 (prof, inst_id);
-       emit_string (prof, name);
-       g_free (name);
-       g_hash_table_insert (prof->classes, klass, GINT_TO_POINTER (id + 1));
-       return id;
-}
-
-static void
-add_method (MonoProfiler *prof, MonoMethod *m)
-{
-       MonoError error;
-       MonoMethodSignature *sig;
-       char *s;
-
-       sig = mono_method_signature_checked (m, &error);
-       g_assert (mono_error_ok (&error));
-
-       int class_id = add_class (prof, m->klass);
-       if (class_id == -1)
-               return;
-       int inst_id = -1;
-
-       if (m->is_inflated) {
-               MonoGenericContext *ctx = mono_method_get_context (m);
-               if (ctx->method_inst)
-                       inst_id = add_ginst (prof, ctx->method_inst);
-       }
-       int id = prof->id ++;
-       emit_record (prof, AOTPROF_RECORD_METHOD, id);
-       emit_int32 (prof, class_id);
-       emit_int32 (prof, inst_id);
-       emit_int32 (prof, sig->param_count);
-       emit_string (prof, m->name);
-       s = mono_signature_full_name (sig);
-       emit_string (prof, s);
-       g_free (s);
-       if (verbose)
-               printf ("%s %d\n", mono_method_full_name (m, 1), id);
-}
-
-/* called at the end of the program */
-static void
-prof_shutdown (MonoProfiler *prof)
-{
-       FILE *outfile;
-       int mindex;
-       char magic [32];
-
-       printf ("Creating output file: %s\n", prof->outfile_name);
-
-       if (prof->outfile_name [0] == '#') {
-               int fd = strtol (prof->outfile_name + 1, NULL, 10);
-               outfile = fdopen (fd, "a");
-       } else {
-               outfile = fopen (prof->outfile_name, "w+");
-       }
-       if (!outfile) {
-               fprintf (stderr, "Unable to create output file '%s': %s.\n", prof->outfile_name, strerror (errno));
-               return;
-       }
-       prof->outfile = outfile;
-
-       gint32 version = (AOT_PROFILER_MAJOR_VERSION << 16) | AOT_PROFILER_MINOR_VERSION;
-       sprintf (magic, AOT_PROFILER_MAGIC);
-       fwrite (magic, strlen (magic), 1, outfile);
-       emit_int32 (prof, version);
-
-       GHashTable *all_methods = g_hash_table_new (NULL, NULL);
-       for (mindex = 0; mindex < prof->methods->len; ++mindex) {
-           MonoMethod *m = (MonoMethod*)g_ptr_array_index (prof->methods, mindex);
-
-               if (!mono_method_get_token (m))
-                       continue;
-
-               if (g_hash_table_lookup (all_methods, m))
-                       continue;
-               g_hash_table_insert (all_methods, m, m);
-
-               add_method (prof, m);
-       }
-       emit_record (prof, AOTPROF_RECORD_NONE, 0);
-
-       fclose (outfile);
-
-       g_hash_table_destroy (all_methods);
-       g_hash_table_destroy (prof->classes);
-       g_hash_table_destroy (prof->images);
-       g_ptr_array_free (prof->methods, TRUE);
-       g_free (prof->outfile_name);
-}
diff --git a/mono/profiler/mono-profiler-aot.h b/mono/profiler/mono-profiler-aot.h
deleted file mode 100644 (file)
index 7663cab..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __MONO_PROFILER_AOT_H__
-#define __MONO_PROFILER_AOT_H__
-
-#include <config.h>
-
-/*
- * File format:
- * - magic
- * - major/minor version as an int, i.e. 0x00010001
- * - sequence of records terminated by a record with type TYPE_NONE
- * Record format:
- * - 1 byte record type (AotProfRecordType)
- * - 1 int record id
- * - record specific data
- * Encoding rules:
- * - int - 4 bytes little endian
- * - string - int length followed by data
- */
-
-typedef enum {
-       AOTPROF_RECORD_NONE,
-       AOTPROF_RECORD_IMAGE,
-       AOTPROF_RECORD_TYPE,
-       AOTPROF_RECORD_GINST,
-       AOTPROF_RECORD_METHOD
-} AotProfRecordType;
-
-#define AOT_PROFILER_MAGIC "AOTPROFILE"
-
-#define AOT_PROFILER_MAJOR_VERSION 1
-#define AOT_PROFILER_MINOR_VERSION 0
-
-#endif /* __MONO_PROFILER_AOT_H__ */
diff --git a/mono/profiler/mono-profiler-iomap.c b/mono/profiler/mono-profiler-iomap.c
deleted file mode 100644 (file)
index 15baec0..0000000
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * mono-profiler-iomap.c: IOMAP string profiler for Mono.
- *
- * Authors:
- *   Marek Habersack <mhabersack@novell.com>
- *
- * Copyright (c) 2009 Novell, Inc (http://novell.com)
- *
- * Note: this profiler is completely unsafe wrt handling managed objects,
- * don't use and don't copy code from here.
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-#include "config.h"
-
-#include <string.h>
-#include <mono/utils/mono-io-portability.h>
-#include <mono/metadata/metadata.h>
-#include <mono/metadata/metadata-internals.h>
-#include <mono/metadata/class.h>
-#include <mono/metadata/class-internals.h>
-#include <mono/metadata/object-internals.h>
-#include <mono/metadata/image.h>
-#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/debug-helpers.h>
-#include <mono/metadata/threads.h>
-#include <mono/metadata/profiler.h>
-#include <mono/metadata/loader.h>
-#include <mono/utils/mono-os-mutex.h>
-
-#define LOCATION_INDENT "        "
-#define BACKTRACE_SIZE 64
-
-typedef struct _MonoStackBacktraceInfo 
-{
-       MonoMethod *method;
-       gint native_offset;
-} MonoStackBacktraceInfo;
-
-typedef struct 
-{
-       guint32 count;
-       gchar *requestedName;
-       gchar *actualName;
-} MismatchedFilesStats;
-
-typedef struct _SavedString
-{
-       MonoString *string;
-       MonoDomain *domain;
-       void *stack [BACKTRACE_SIZE];
-       gint stack_entries;
-       struct _SavedString *next;
-} SavedString;
-
-typedef struct _SavedStringFindInfo
-{
-       guint32 hash;
-       size_t len;
-} SavedStringFindInfo;
-
-typedef struct _StringLocation
-{
-       gchar *hint;
-       struct _StringLocation *next;
-} StringLocation;
-
-struct _MonoProfiler
-{
-       GHashTable *mismatched_files_hash;
-       GHashTable *saved_strings_hash;
-       GHashTable *string_locations_hash;
-       gboolean may_have_locations;
-};
-
-typedef struct _StackWalkData
-{
-       MonoProfiler *prof;
-       void **stack;
-       int stack_size;
-       int frame_count;
-} StackWalkData;
-
-static mono_mutex_t mismatched_files_section;
-static gboolean runtime_initialized = FALSE;
-
-static inline void append_report (GString **report, const gchar *format, ...);
-static inline void print_report (const gchar *format, ...);
-static inline guint32 do_calc_string_hash (guint32 hash, const gchar *str);
-static inline guint32 calc_strings_hash (const gchar *str1, const gchar *str2, guint32 *str1hash);
-static void print_mismatched_stats (MonoProfiler *prof);
-static inline gchar *build_hint (SavedString *head);
-static inline gchar *build_hint_from_stack (MonoDomain *domain, void **stack, gint stack_entries);
-static inline void store_string_location (MonoProfiler *prof, const gchar *string, guint32 hash, size_t len);
-static void mono_portability_remember_string (MonoProfiler *prof, MonoDomain *domain, MonoString *str);
-void mono_profiler_startup (const char *desc);
-
-static void mismatched_stats_foreach_func (gpointer key, gpointer value, gpointer user_data)
-{
-       MismatchedFilesStats *stats = (MismatchedFilesStats*)value;
-       StringLocation *location;
-       MonoProfiler *prof = (MonoProfiler*)user_data;
-       guint32 hash;
-       gboolean bannerShown = FALSE;
-
-       hash = do_calc_string_hash (0, stats->requestedName);
-       fprintf (stdout,
-                "    Count: %u\n"
-                "Requested: %s\n"
-                "   Actual: %s\n",
-                stats->count, stats->requestedName, stats->actualName);
-
-       if (!prof->may_have_locations) {
-               fprintf (stdout, "\n");
-               return;
-       }
-
-       location = (StringLocation *)g_hash_table_lookup (prof->string_locations_hash, &hash);
-       while (location) {
-               if (location->hint && strlen (location->hint) > 0) {
-                       if (!bannerShown) {
-                               fprintf (stdout, "Locations:\n");
-                               bannerShown = TRUE;
-                       }
-                       fprintf (stdout, "%s", location->hint);
-               }
-               location = location->next;
-               if (location)
-                       fprintf (stdout, LOCATION_INDENT "--\n");
-       }
-
-       fprintf (stdout, "\n");
-}
-
-static void print_mismatched_stats (MonoProfiler *prof)
-{
-       if (!prof->mismatched_files_hash || g_hash_table_size (prof->mismatched_files_hash) == 0)
-               return;
-
-       prof->may_have_locations = g_hash_table_size (prof->string_locations_hash) > 0;
-
-       fprintf (stdout, "\n-=-=-=-=-=-=-= MONO_IOMAP Stats -=-=-=-=-=-=-=\n");
-       g_hash_table_foreach (prof->mismatched_files_hash, mismatched_stats_foreach_func, (gpointer)prof);
-       fflush (stdout);
-}
-
-static guint mismatched_files_guint32_hash (gconstpointer key)
-{
-       if (!key)
-               return 0;
-
-       return *((guint32*)key);
-}
-
-static gboolean mismatched_files_guint32_equal (gconstpointer key1, gconstpointer key2)
-{
-       if (!key1 || !key2)
-               return FALSE;
-
-       return (gboolean)(*((guint32*)key1) == *((guint32*)key2));
-}
-
-static inline guint32 do_calc_string_hash (guint32 hash, const gchar *str)
-{
-       guint32 ret = hash;
-       gchar *cc = (gchar*)str;
-       gchar *end = (gchar*)(str + strlen (str) - 1);
-
-       for (; cc < end; cc += 2) {
-               ret = (ret << 5) - ret + *cc;
-               ret = (ret << 5) - ret + cc [1];
-       }
-       end++;
-       if (cc < end)
-               ret = (ret << 5) - ret + *cc;
-
-       return ret;
-}
-
-static inline guint32 calc_strings_hash (const gchar *str1, const gchar *str2, guint32 *str1hash)
-{
-       guint32 hash = do_calc_string_hash (0, str1);
-       if (str1hash)
-               *str1hash = hash;
-       return do_calc_string_hash (hash, str2);
-}
-
-static inline void print_report (const gchar *format, ...)
-{
-       MonoError error;
-       MonoClass *klass;
-       MonoProperty *prop;
-       MonoString *str;
-       char *stack_trace;
-       va_list ap;
-
-       fprintf (stdout, "-=-=-=-=-=-=- MONO_IOMAP REPORT -=-=-=-=-=-=-\n");
-       va_start (ap, format);
-       vfprintf (stdout, format, ap);
-       fprintf (stdout, "\n");
-       va_end (ap);
-       klass = mono_class_load_from_name (mono_get_corlib (), "System", "Environment");
-       mono_class_init (klass);
-       prop = mono_class_get_property_from_name (klass, "StackTrace");
-       str = (MonoString*)mono_property_get_value_checked (prop, NULL, NULL, &error);
-       mono_error_assert_ok (&error);
-       stack_trace = mono_string_to_utf8_checked (str, &error);
-       mono_error_assert_ok (&error);
-
-       fprintf (stdout, "-= Stack Trace =-\n%s\n\n", stack_trace);
-       g_free (stack_trace);
-       fflush (stdout);
-}
-
-static inline void append_report (GString **report, const gchar *format, ...)
-{
-       va_list ap;
-       if (!*report)
-               *report = g_string_new ("");
-
-       va_start (ap, format);
-       g_string_append_vprintf (*report, format, ap);
-       va_end (ap);
-}
-
-static gboolean saved_strings_find_func (gpointer key, gpointer value, gpointer user_data)
-{
-       MonoError error;
-       SavedStringFindInfo *info = (SavedStringFindInfo*)user_data;
-       SavedString *saved = (SavedString*)value;
-       gchar *utf_str;
-       guint32 hash;
-
-       if (!info || !saved || mono_string_length (saved->string) != info->len)
-               return FALSE;
-
-       utf_str = mono_string_to_utf8_checked (saved->string, &error);
-       mono_error_assert_ok (&error);
-       hash = do_calc_string_hash (0, utf_str);
-       g_free (utf_str);
-
-       if (hash != info->hash)
-               return FALSE;
-
-       return TRUE;
-}
-
-static inline void store_string_location (MonoProfiler *prof, const gchar *string, guint32 hash, size_t len)
-{
-       StringLocation *location = (StringLocation *)g_hash_table_lookup (prof->string_locations_hash, &hash);
-       SavedString *saved;
-       SavedStringFindInfo info;
-       guint32 *hashptr;
-
-       if (location)
-               return;
-
-       info.hash = hash;
-       info.len = len;
-
-       /* Expensive but unavoidable... */
-       saved = (SavedString*)g_hash_table_find (prof->saved_strings_hash, saved_strings_find_func, &info);
-       hashptr = (guint32*)g_malloc (sizeof (guint32));
-       *hashptr = hash;
-       location = (StringLocation*)g_malloc0 (sizeof (location));
-
-       g_hash_table_insert (prof->string_locations_hash, hashptr, location);
-       if (!saved)
-               return;
-
-       g_hash_table_remove (prof->saved_strings_hash, saved->string);
-       location->hint = build_hint (saved);
-}
-
-static gboolean ignore_frame (MonoMethod *method)
-{
-       MonoClass *klass = method->klass;
-
-       if (method->wrapper_type != MONO_WRAPPER_NONE)
-               return TRUE;
-
-       /* Now ignore the assemblies we know shouldn't contain mixed-case names (only the most frequent cases) */
-       if (klass->image ) {
-               if (strcmp (klass->image->assembly_name, "mscorlib") == 0)
-                       return TRUE;
-               else if (strcmp (klass->image->assembly_name, "System") == 0)
-                       return TRUE;
-               else if (strncmp (klass->image->assembly_name, "Mono.", 5) == 0)
-                       return TRUE;
-               else if (strncmp (klass->image->assembly_name, "System.", 7) == 0)
-                       return TRUE;
-               else if (strcmp (klass->image->assembly_name, "PEAPI") == 0)
-                       return TRUE;
-       }
-
-       return FALSE;
-}
-
-static inline gchar *build_hint_from_stack (MonoDomain *domain, void **stack, gint stack_entries)
-{
-       gchar *hint;
-       MonoMethod *method, *selectedMethod;
-       MonoAssembly *assembly;
-       MonoImage *image;
-       MonoDebugSourceLocation *location;
-       MonoStackBacktraceInfo *info;
-       gboolean use_full_trace;
-       char *methodName;
-       gint i, native_offset, firstAvailable;
-
-       selectedMethod = NULL;
-       firstAvailable = -1;
-       use_full_trace = FALSE;
-       native_offset = -1;
-       for (i = 0; i < stack_entries; i++) {
-               info = (MonoStackBacktraceInfo*) stack [i];
-               method = info ? info->method : NULL;
-
-               if (!method || method->wrapper_type != MONO_WRAPPER_NONE)
-                       continue;
-
-               if (firstAvailable == -1)
-                       firstAvailable = i;
-
-               image = method->klass->image;
-               assembly = image->assembly;
-
-               if ((assembly && assembly->in_gac) || ignore_frame (method))
-                       continue;
-               selectedMethod = method;
-               native_offset = info->native_offset;
-               break;
-       }
-
-       if (!selectedMethod) {
-               /* All the frames were from assemblies installed in GAC. Find first frame that is
-                * not in the ignore list */
-               for (i = 0; i < stack_entries; i++) {
-                       info = (MonoStackBacktraceInfo*) stack [i];
-                       method = info ? info->method : NULL;
-
-                       if (!method || ignore_frame (method))
-                               continue;
-                       selectedMethod = method;
-                       native_offset = info->native_offset;
-                       break;
-               }
-
-               if (!selectedMethod)
-                       use_full_trace = TRUE;
-       }
-
-       hint = NULL;
-       if (use_full_trace) {
-               GString *trace = g_string_new ("Full trace:\n");
-               for (i = firstAvailable; i < stack_entries; i++) {
-                       info = (MonoStackBacktraceInfo*) stack [i];
-                       method = info ? info->method : NULL;
-                       if (!method || method->wrapper_type != MONO_WRAPPER_NONE)
-                               continue;
-
-                       location = mono_debug_lookup_source_location (method, info->native_offset, domain);
-                       methodName = mono_method_full_name (method, TRUE);
-
-                       if (location) {
-                               append_report (&trace, LOCATION_INDENT "%s in %s:%u\n", methodName, location->source_file, location->row);
-                               mono_debug_free_source_location (location);
-                       } else
-                               append_report (&trace, LOCATION_INDENT "%s\n", methodName);
-                       g_free (methodName);
-               }
-
-               if (trace) {
-                       if (trace->len)
-                               hint = g_string_free (trace, FALSE);
-                       else
-                               g_string_free (trace, TRUE);
-               }
-       } else {
-               location = mono_debug_lookup_source_location (selectedMethod, native_offset, domain);
-               methodName = mono_method_full_name (selectedMethod, TRUE);
-
-               if (location) {
-                       hint = g_strdup_printf (LOCATION_INDENT "%s in %s:%u\n", methodName, location->source_file, location->row);
-                       mono_debug_free_source_location (location);
-               } else
-                       hint = g_strdup_printf (LOCATION_INDENT "%s\n", methodName);
-               g_free (methodName);
-       }
-
-       return hint;
-}
-
-static inline gchar *build_hint (SavedString *head)
-{
-       SavedString *current;
-       gchar *tmp;
-       GString *hint = NULL;
-
-       current = head;
-       while (current) {
-               tmp = build_hint_from_stack (current->domain, current->stack, current->stack_entries);
-               current = current->next;
-               if (!tmp)
-                       continue;
-
-               append_report (&hint, tmp);
-       }
-
-       if (hint) {
-               if (hint->len)
-                       return g_string_free (hint, FALSE);
-               else {
-                       g_string_free (hint, FALSE);
-                       return NULL;
-               }
-       }
-
-       return NULL;
-}
-
-static gboolean stack_walk_func (MonoMethod *method, gint32 native_offset, gint32 il_offset, gboolean managed, gpointer data)
-{
-       StackWalkData *swdata = (StackWalkData*)data;
-       MonoStackBacktraceInfo *info;
-
-       if (swdata->frame_count >= swdata->stack_size)
-               return TRUE;
-
-       info = (MonoStackBacktraceInfo*)g_malloc (sizeof (*info));
-       info->method = method;
-       info->native_offset = native_offset;
-
-       swdata->stack [swdata->frame_count++] = info;
-       return FALSE;
-}
-
-static inline int mono_stack_backtrace (MonoProfiler *prof, MonoDomain *domain, void **stack, int size)
-{
-       StackWalkData data;
-
-       data.prof = prof;
-       data.stack = stack;
-       data.stack_size = size;
-       data.frame_count = 0;
-
-       mono_stack_walk_no_il (stack_walk_func, (gpointer)&data);
-
-       return data.frame_count;
-}
-
-static void mono_portability_remember_string (MonoProfiler *prof, MonoDomain *domain, MonoString *str)
-{
-       SavedString *head, *entry;
-
-       if (!str || !domain || !runtime_initialized)
-               return;
-
-       entry = (SavedString*)g_malloc0 (sizeof (SavedString));
-       entry->string = str;
-       entry->domain = domain;
-       entry->stack_entries = mono_stack_backtrace (prof, domain, entry->stack, BACKTRACE_SIZE);
-       if (entry->stack_entries == 0) {
-               g_free (entry);
-               return;
-       }
-
-       mono_os_mutex_lock (&mismatched_files_section);
-       head = (SavedString*)g_hash_table_lookup (prof->saved_strings_hash, (gpointer)str);
-       if (head) {
-               while (head->next)
-                       head = head->next;
-               head->next = entry;
-       } else
-               g_hash_table_insert (prof->saved_strings_hash, (gpointer)str, (gpointer)entry);
-       mono_os_mutex_unlock (&mismatched_files_section);
-}
-
-static MonoClass *string_class = NULL;
-
-static void mono_portability_remember_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
-{
-       if (klass != string_class)
-               return;
-       mono_portability_remember_string (prof, mono_object_get_domain (obj), (MonoString*)obj);
-}
-
-static void mono_portability_iomap_event (MonoProfiler *prof, const char *report, const char *pathname, const char *new_pathname)
-{
-       guint32 hash, pathnameHash;
-       MismatchedFilesStats *stats;
-
-       if (!runtime_initialized)
-               return;
-
-       mono_os_mutex_lock (&mismatched_files_section);
-       hash = calc_strings_hash (pathname, new_pathname, &pathnameHash);
-       stats = (MismatchedFilesStats*)g_hash_table_lookup (prof->mismatched_files_hash, &hash);
-       if (stats == NULL) {
-               guint32 *hashptr;
-
-               stats = (MismatchedFilesStats*) g_malloc (sizeof (MismatchedFilesStats));
-               stats->count = 1;
-               stats->requestedName = g_strdup (pathname);
-               stats->actualName = g_strdup (new_pathname);
-               hashptr = (guint32*)g_malloc (sizeof (guint32));
-               if (hashptr) {
-                       *hashptr = hash;
-                       g_hash_table_insert (prof->mismatched_files_hash, (gpointer)hashptr, stats);
-               } else
-                       g_error ("Out of memory allocating integer pointer for mismatched files hash table.");
-
-               store_string_location (prof, (const gchar*)stats->requestedName, pathnameHash, strlen (stats->requestedName));
-               mono_os_mutex_unlock (&mismatched_files_section);
-
-               print_report ("%s -     Found file path: '%s'\n", report, new_pathname);
-       } else {
-               mono_os_mutex_unlock (&mismatched_files_section);
-               stats->count++;
-       }
-}
-
-static void runtime_initialized_cb (MonoProfiler *prof)
-{
-       runtime_initialized = TRUE;
-       string_class = mono_get_string_class ();
-}
-
-static void profiler_shutdown (MonoProfiler *prof)
-{
-       print_mismatched_stats (prof);
-       mono_os_mutex_destroy (&mismatched_files_section);
-}
-
-void mono_profiler_startup (const char *desc)
-{
-       MonoProfiler *prof = g_new0 (MonoProfiler, 1);
-
-       mono_os_mutex_init (&mismatched_files_section);
-       prof->mismatched_files_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal);
-       prof->saved_strings_hash = g_hash_table_new (NULL, NULL);
-       prof->string_locations_hash = g_hash_table_new (mismatched_files_guint32_hash, mismatched_files_guint32_equal);
-
-       mono_profiler_install (prof, profiler_shutdown);
-       mono_profiler_install_runtime_initialized (runtime_initialized_cb);
-       mono_profiler_install_iomap (mono_portability_iomap_event);
-       mono_profiler_install_allocation (mono_portability_remember_alloc);
-
-       mono_profiler_set_events ((MonoProfileFlags)(MONO_PROFILE_ALLOCATIONS | MONO_PROFILE_IOMAP_EVENTS));
-}
diff --git a/mono/profiler/mono-profiler-log.c b/mono/profiler/mono-profiler-log.c
deleted file mode 100644 (file)
index 3a7500e..0000000
+++ /dev/null
@@ -1,5044 +0,0 @@
-/*
- * mono-profiler-log.c: mono log profiler
- *
- * Authors:
- *   Paolo Molaro (lupus@ximian.com)
- *   Alex Rønne Petersen (alexrp@xamarin.com)
- *
- * Copyright 2010 Novell, Inc (http://www.novell.com)
- * Copyright 2011 Xamarin Inc (http://www.xamarin.com)
- * Licensed under the MIT license. See LICENSE file in the project root for full license information.
- */
-
-#include <config.h>
-#include <mono/metadata/assembly.h>
-#include <mono/metadata/debug-helpers.h>
-#include "../metadata/metadata-internals.h"
-#include <mono/metadata/mono-config.h>
-#include <mono/metadata/mono-gc.h>
-#include <mono/metadata/mono-perfcounters.h>
-#include <mono/metadata/profiler.h>
-#include <mono/utils/atomic.h>
-#include <mono/utils/hazard-pointer.h>
-#include <mono/utils/lock-free-alloc.h>
-#include <mono/utils/lock-free-queue.h>
-#include <mono/utils/mono-conc-hashtable.h>
-#include <mono/utils/mono-counters.h>
-#include <mono/utils/mono-linked-list-set.h>
-#include <mono/utils/mono-membar.h>
-#include <mono/utils/mono-mmap.h>
-#include <mono/utils/mono-os-mutex.h>
-#include <mono/utils/mono-os-semaphore.h>
-#include <mono/utils/mono-threads.h>
-#include <mono/utils/mono-threads-api.h>
-#include "mono-profiler-log.h"
-
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-#include <fcntl.h>
-#ifdef HAVE_LINK_H
-#include <link.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if defined(__APPLE__)
-#include <mach/mach_time.h>
-#endif
-#include <netinet/in.h>
-#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#endif
-#include <sys/socket.h>
-#if defined (HAVE_SYS_ZLIB)
-#include <zlib.h>
-#endif
-
-#ifdef HAVE_SCHED_GETAFFINITY
-#  ifndef GLIBC_HAS_CPU_COUNT
-static int
-CPU_COUNT(cpu_set_t *set)
-{
-       int i, count = 0;
-
-       for (int i = 0; i < CPU_SETSIZE; i++)
-               if (CPU_ISSET(i, set))
-                       count++;
-       return count;
-}
-#  endif
-#endif
-
-#define BUFFER_SIZE (4096 * 16)
-
-/* Worst-case size in bytes of a 64-bit value encoded with LEB128. */
-#define LEB128_SIZE 10
-
-/* Size of a value encoded as a single byte. */
-#undef BYTE_SIZE // mach/i386/vm_param.h on OS X defines this to 8, but it isn't used for anything.
-#define BYTE_SIZE 1
-
-/* Size in bytes of the event prefix (ID + time). */
-#define EVENT_SIZE (BYTE_SIZE + LEB128_SIZE)
-
-static volatile gint32 runtime_inited;
-static volatile gint32 in_shutdown;
-
-static gboolean no_counters;
-static int nocalls = 0;
-static int notraces = 0;
-static int use_zip = 0;
-static int do_report = 0;
-static int do_heap_shot = 0;
-static int max_call_depth = 100;
-static int command_port = 0;
-static int heapshot_requested = 0;
-static int sample_freq = 0;
-static int do_mono_sample = 0;
-static int do_debug = 0;
-static int do_coverage = 0;
-static gboolean only_coverage;
-static gboolean debug_coverage = FALSE;
-static MonoProfileSamplingMode sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
-static int max_allocated_sample_hits;
-
-// Statistics for internal profiler data structures.
-static gint32 sample_allocations_ctr,
-              buffer_allocations_ctr;
-
-// Statistics for profiler events.
-static gint32 sync_points_ctr,
-              heap_objects_ctr,
-              heap_starts_ctr,
-              heap_ends_ctr,
-              heap_roots_ctr,
-              gc_events_ctr,
-              gc_resizes_ctr,
-              gc_allocs_ctr,
-              gc_moves_ctr,
-              gc_handle_creations_ctr,
-              gc_handle_deletions_ctr,
-              finalize_begins_ctr,
-              finalize_ends_ctr,
-              finalize_object_begins_ctr,
-              finalize_object_ends_ctr,
-              image_loads_ctr,
-              image_unloads_ctr,
-              assembly_loads_ctr,
-              assembly_unloads_ctr,
-              class_loads_ctr,
-              class_unloads_ctr,
-              method_entries_ctr,
-              method_exits_ctr,
-              method_exception_exits_ctr,
-              method_jits_ctr,
-              code_buffers_ctr,
-              exception_throws_ctr,
-              exception_clauses_ctr,
-              monitor_contentions_ctr,
-              monitor_acquisitions_ctr,
-              monitor_failures_ctr,
-              thread_starts_ctr,
-              thread_ends_ctr,
-              thread_names_ctr,
-              domain_loads_ctr,
-              domain_unloads_ctr,
-              domain_names_ctr,
-              context_loads_ctr,
-              context_unloads_ctr,
-              sample_ubins_ctr,
-              sample_usyms_ctr,
-              sample_hits_ctr,
-              counter_descriptors_ctr,
-              counter_samples_ctr,
-              perfcounter_descriptors_ctr,
-              perfcounter_samples_ctr,
-              coverage_methods_ctr,
-              coverage_statements_ctr,
-              coverage_classes_ctr,
-              coverage_assemblies_ctr;
-
-static MonoLinkedListSet profiler_thread_list;
-
-/*
- * file format:
- * [header] [buffer]*
- *
- * The file is composed by a header followed by 0 or more buffers.
- * Each buffer contains events that happened on a thread: for a given thread
- * buffers that appear later in the file are guaranteed to contain events
- * that happened later in time. Buffers from separate threads could be interleaved,
- * though.
- * Buffers are not required to be aligned.
- *
- * header format:
- * [id: 4 bytes] constant value: LOG_HEADER_ID
- * [major: 1 byte] [minor: 1 byte] major and minor version of the log profiler
- * [format: 1 byte] version of the data format for the rest of the file
- * [ptrsize: 1 byte] size in bytes of a pointer in the profiled program
- * [startup time: 8 bytes] time in milliseconds since the unix epoch when the program started
- * [timer overhead: 4 bytes] approximate overhead in nanoseconds of the timer
- * [flags: 4 bytes] file format flags, should be 0 for now
- * [pid: 4 bytes] pid of the profiled process
- * [port: 2 bytes] tcp port for server if != 0
- * [args size: 4 bytes] size of args
- * [args: string] arguments passed to the profiler
- * [arch size: 4 bytes] size of arch
- * [arch: string] architecture the profiler is running on
- * [os size: 4 bytes] size of os
- * [os: string] operating system the profiler is running on
- *
- * The multiple byte integers are in little-endian format.
- *
- * buffer format:
- * [buffer header] [event]*
- * Buffers have a fixed-size header followed by 0 or more bytes of event data.
- * Timing information and other values in the event data are usually stored
- * as uleb128 or sleb128 integers. To save space, as noted for each item below,
- * some data is represented as a difference between the actual value and
- * either the last value of the same type (like for timing information) or
- * as the difference from a value stored in a buffer header.
- *
- * For timing information the data is stored as uleb128, since timing
- * increases in a monotonic way in each thread: the value is the number of
- * nanoseconds to add to the last seen timing data in a buffer. The first value
- * in a buffer will be calculated from the time_base field in the buffer head.
- *
- * Object or heap sizes are stored as uleb128.
- * Pointer differences are stored as sleb128, instead.
- *
- * If an unexpected value is found, the rest of the buffer should be ignored,
- * as generally the later values need the former to be interpreted correctly.
- *
- * buffer header format:
- * [bufid: 4 bytes] constant value: BUF_ID
- * [len: 4 bytes] size of the data following the buffer header
- * [time_base: 8 bytes] time base in nanoseconds since an unspecified epoch
- * [ptr_base: 8 bytes] base value for pointers
- * [obj_base: 8 bytes] base value for object addresses
- * [thread id: 8 bytes] system-specific thread ID (pthread_t for example)
- * [method_base: 8 bytes] base value for MonoMethod pointers
- *
- * event format:
- * [extended info: upper 4 bits] [type: lower 4 bits]
- * [time diff: uleb128] nanoseconds since last timing
- * [data]*
- * The data that follows depends on type and the extended info.
- * Type is one of the enum values in mono-profiler-log.h: TYPE_ALLOC, TYPE_GC,
- * TYPE_METADATA, TYPE_METHOD, TYPE_EXCEPTION, TYPE_MONITOR, TYPE_HEAP.
- * The extended info bits are interpreted based on type, see
- * each individual event description below.
- * strings are represented as a 0-terminated utf8 sequence.
- *
- * backtrace format:
- * [num: uleb128] number of frames following
- * [frame: sleb128]* mum MonoMethod* as a pointer difference from the last such
- * pointer or the buffer method_base
- *
- * type alloc format:
- * type: TYPE_ALLOC
- * exinfo: flags: TYPE_ALLOC_BT
- * [ptr: sleb128] class as a byte difference from ptr_base
- * [obj: sleb128] object address as a byte difference from obj_base
- * [size: uleb128] size of the object in the heap
- * If the TYPE_ALLOC_BT flag is set, a backtrace follows.
- *
- * type GC format:
- * type: TYPE_GC
- * exinfo: one of TYPE_GC_EVENT, TYPE_GC_RESIZE, TYPE_GC_MOVE, TYPE_GC_HANDLE_CREATED[_BT],
- * TYPE_GC_HANDLE_DESTROYED[_BT], TYPE_GC_FINALIZE_START, TYPE_GC_FINALIZE_END,
- * TYPE_GC_FINALIZE_OBJECT_START, TYPE_GC_FINALIZE_OBJECT_END
- * if exinfo == TYPE_GC_RESIZE
- *     [heap_size: uleb128] new heap size
- * if exinfo == TYPE_GC_EVENT
- *     [event type: byte] GC event (MONO_GC_EVENT_* from profiler.h)
- *     [generation: byte] GC generation event refers to
- * if exinfo == TYPE_GC_MOVE
- *     [num_objects: uleb128] number of object moves that follow
- *     [objaddr: sleb128]+ num_objects object pointer differences from obj_base
- *     num is always an even number: the even items are the old
- *     addresses, the odd numbers are the respective new object addresses
- * if exinfo == TYPE_GC_HANDLE_CREATED[_BT]
- *     [handle_type: uleb128] GC handle type (System.Runtime.InteropServices.GCHandleType)
- *     upper bits reserved as flags
- *     [handle: uleb128] GC handle value
- *     [objaddr: sleb128] object pointer differences from obj_base
- *     If exinfo == TYPE_GC_HANDLE_CREATED_BT, a backtrace follows.
- * if exinfo == TYPE_GC_HANDLE_DESTROYED[_BT]
- *     [handle_type: uleb128] GC handle type (System.Runtime.InteropServices.GCHandleType)
- *     upper bits reserved as flags
- *     [handle: uleb128] GC handle value
- *     If exinfo == TYPE_GC_HANDLE_DESTROYED_BT, a backtrace follows.
- * if exinfo == TYPE_GC_FINALIZE_OBJECT_{START,END}
- *     [object: sleb128] the object as a difference from obj_base
- *
- * type metadata format:
- * type: TYPE_METADATA
- * exinfo: one of: TYPE_END_LOAD, TYPE_END_UNLOAD (optional for TYPE_THREAD and TYPE_DOMAIN)
- * [mtype: byte] metadata type, one of: TYPE_CLASS, TYPE_IMAGE, TYPE_ASSEMBLY, TYPE_DOMAIN,
- * TYPE_THREAD, TYPE_CONTEXT
- * [pointer: sleb128] pointer of the metadata type depending on mtype
- * if mtype == TYPE_CLASS
- *     [image: sleb128] MonoImage* as a pointer difference from ptr_base
- *     [name: string] full class name
- * if mtype == TYPE_IMAGE
- *     [name: string] image file name
- * if mtype == TYPE_ASSEMBLY
- *     [name: string] assembly name
- * if mtype == TYPE_DOMAIN && exinfo == 0
- *     [name: string] domain friendly name
- * if mtype == TYPE_CONTEXT
- *     [domain: sleb128] domain id as pointer
- * if mtype == TYPE_THREAD && exinfo == 0
- *     [name: string] thread name
- *
- * type method format:
- * type: TYPE_METHOD
- * exinfo: one of: TYPE_LEAVE, TYPE_ENTER, TYPE_EXC_LEAVE, TYPE_JIT
- * [method: sleb128] MonoMethod* as a pointer difference from the last such
- * pointer or the buffer method_base
- * if exinfo == TYPE_JIT
- *     [code address: sleb128] pointer to the native code as a diff from ptr_base
- *     [code size: uleb128] size of the generated code
- *     [name: string] full method name
- *
- * type exception format:
- * type: TYPE_EXCEPTION
- * exinfo: TYPE_THROW_BT flag or one of: TYPE_CLAUSE
- * if exinfo == TYPE_CLAUSE
- *     [clause type: byte] MonoExceptionEnum enum value
- *     [clause index: uleb128] index of the current clause
- *     [method: sleb128] MonoMethod* as a pointer difference from the last such
- *     pointer or the buffer method_base
- * else
- *     [object: sleb128] the exception object as a difference from obj_base
- *     if exinfo has TYPE_THROW_BT set, a backtrace follows.
- *
- * type runtime format:
- * type: TYPE_RUNTIME
- * exinfo: one of: TYPE_JITHELPER
- * if exinfo == TYPE_JITHELPER
- *     [type: byte] MonoProfilerCodeBufferType enum value
- *     [buffer address: sleb128] pointer to the native code as a diff from ptr_base
- *     [buffer size: uleb128] size of the generated code
- *     if type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE
- *             [name: string] buffer description name
- *
- * type monitor format:
- * type: TYPE_MONITOR
- * exinfo: TYPE_MONITOR_BT flag and one of: MONO_PROFILER_MONITOR_(CONTENTION|FAIL|DONE)
- * [object: sleb128] the lock object as a difference from obj_base
- * if exinfo.low3bits == MONO_PROFILER_MONITOR_CONTENTION
- *     If the TYPE_MONITOR_BT flag is set, a backtrace follows.
- *
- * type heap format
- * type: TYPE_HEAP
- * exinfo: one of TYPE_HEAP_START, TYPE_HEAP_END, TYPE_HEAP_OBJECT, TYPE_HEAP_ROOT
- * if exinfo == TYPE_HEAP_OBJECT
- *     [object: sleb128] the object as a difference from obj_base
- *     [class: sleb128] the object MonoClass* as a difference from ptr_base
- *     [size: uleb128] size of the object on the heap
- *     [num_refs: uleb128] number of object references
- *     each referenced objref is preceded by a uleb128 encoded offset: the
- *     first offset is from the object address and each next offset is relative
- *     to the previous one
- *     [objrefs: sleb128]+ object referenced as a difference from obj_base
- *     The same object can appear multiple times, but only the first time
- *     with size != 0: in the other cases this data will only be used to
- *     provide additional referenced objects.
- * if exinfo == TYPE_HEAP_ROOT
- *     [num_roots: uleb128] number of root references
- *     [num_gc: uleb128] number of major gcs
- *     [object: sleb128] the object as a difference from obj_base
- *     [root_type: byte] the root_type: MonoProfileGCRootType (profiler.h)
- *     [extra_info: uleb128] the extra_info value
- *     object, root_type and extra_info are repeated num_roots times
- *
- * type sample format
- * type: TYPE_SAMPLE
- * exinfo: one of TYPE_SAMPLE_HIT, TYPE_SAMPLE_USYM, TYPE_SAMPLE_UBIN, TYPE_SAMPLE_COUNTERS_DESC, TYPE_SAMPLE_COUNTERS
- * if exinfo == TYPE_SAMPLE_HIT
- *     [thread: sleb128] thread id as difference from ptr_base
- *     [count: uleb128] number of following instruction addresses
- *     [ip: sleb128]* instruction pointer as difference from ptr_base
- *     [mbt_count: uleb128] number of managed backtrace frames
- *     [method: sleb128]* MonoMethod* as a pointer difference from the last such
- *     pointer or the buffer method_base (the first such method can be also indentified by ip, but this is not neccessarily true)
- * if exinfo == TYPE_SAMPLE_USYM
- *     [address: sleb128] symbol address as a difference from ptr_base
- *     [size: uleb128] symbol size (may be 0 if unknown)
- *     [name: string] symbol name
- * if exinfo == TYPE_SAMPLE_UBIN
- *     [address: sleb128] address where binary has been loaded
- *     [offset: uleb128] file offset of mapping (the same file can be mapped multiple times)
- *     [size: uleb128] memory size
- *     [name: string] binary name
- * if exinfo == TYPE_SAMPLE_COUNTERS_DESC
- *     [len: uleb128] number of counters
- *     for i = 0 to len
- *             [section: uleb128] section of counter
- *             if section == MONO_COUNTER_PERFCOUNTERS:
- *                     [section_name: string] section name of counter
- *             [name: string] name of counter
- *             [type: byte] type of counter
- *             [unit: byte] unit of counter
- *             [variance: byte] variance of counter
- *             [index: uleb128] unique index of counter
- * if exinfo == TYPE_SAMPLE_COUNTERS
- *     while true:
- *             [index: uleb128] unique index of counter
- *             if index == 0:
- *                     break
- *             [type: byte] type of counter value
- *             if type == string:
- *                     if value == null:
- *                             [0: uleb128] 0 -> value is null
- *                     else:
- *                             [1: uleb128] 1 -> value is not null
- *                             [value: string] counter value
- *             else:
- *                     [value: uleb128/sleb128/double] counter value, can be sleb128, uleb128 or double (determined by using type)
- *
- * type coverage format
- * type: TYPE_COVERAGE
- * exinfo: one of TYPE_COVERAGE_METHOD, TYPE_COVERAGE_STATEMENT, TYPE_COVERAGE_ASSEMBLY, TYPE_COVERAGE_CLASS
- * if exinfo == TYPE_COVERAGE_METHOD
- *  [assembly: string] name of assembly
- *  [class: string] name of the class
- *  [name: string] name of the method
- *  [signature: string] the signature of the method
- *  [filename: string] the file path of the file that contains this method
- *  [token: uleb128] the method token
- *  [method_id: uleb128] an ID for this data to associate with the buffers of TYPE_COVERAGE_STATEMENTS
- *  [len: uleb128] the number of TYPE_COVERAGE_BUFFERS associated with this method
- * if exinfo == TYPE_COVERAGE_STATEMENTS
- *  [method_id: uleb128] an the TYPE_COVERAGE_METHOD buffer to associate this with
- *  [offset: uleb128] the il offset relative to the previous offset
- *  [counter: uleb128] the counter for this instruction
- *  [line: uleb128] the line of filename containing this instruction
- *  [column: uleb128] the column containing this instruction
- * if exinfo == TYPE_COVERAGE_ASSEMBLY
- *  [name: string] assembly name
- *  [guid: string] assembly GUID
- *  [filename: string] assembly filename
- *  [number_of_methods: uleb128] the number of methods in this assembly
- *  [fully_covered: uleb128] the number of fully covered methods
- *  [partially_covered: uleb128] the number of partially covered methods
- *    currently partially_covered will always be 0, and fully_covered is the
- *    number of methods that are fully and partially covered.
- * if exinfo == TYPE_COVERAGE_CLASS
- *  [name: string] assembly name
- *  [class: string] class name
- *  [number_of_methods: uleb128] the number of methods in this class
- *  [fully_covered: uleb128] the number of fully covered methods
- *  [partially_covered: uleb128] the number of partially covered methods
- *    currently partially_covered will always be 0, and fully_covered is the
- *    number of methods that are fully and partially covered.
- *
- * type meta format:
- * type: TYPE_META
- * exinfo: one of: TYPE_SYNC_POINT
- * if exinfo == TYPE_SYNC_POINT
- *     [type: byte] MonoProfilerSyncPointType enum value
- */
-
-// Pending data to be written to the log, for a single thread.
-// Threads periodically flush their own LogBuffers by calling safe_send
-typedef struct _LogBuffer LogBuffer;
-struct _LogBuffer {
-       // Next (older) LogBuffer in processing queue
-       LogBuffer *next;
-
-       uint64_t time_base;
-       uint64_t last_time;
-       uintptr_t ptr_base;
-       uintptr_t method_base;
-       uintptr_t last_method;
-       uintptr_t obj_base;
-       uintptr_t thread_id;
-
-       // Bytes allocated for this LogBuffer
-       int size;
-
-       // Start of currently unused space in buffer
-       unsigned char* cursor;
-
-       // Pointer to start-of-structure-plus-size (for convenience)
-       unsigned char* buf_end;
-
-       // Start of data in buffer. Contents follow "buffer format" described above.
-       unsigned char buf [1];
-};
-
-typedef struct {
-       MonoLinkedListSetNode node;
-
-       // Convenience pointer to the profiler structure.
-       MonoProfiler *profiler;
-
-       // Was this thread added to the LLS?
-       gboolean attached;
-
-       // The current log buffer for this thread.
-       LogBuffer *buffer;
-
-       // Methods referenced by events in `buffer`, see `MethodInfo`.
-       GPtrArray *methods;
-
-       // Current call depth for enter/leave events.
-       int call_depth;
-
-       // Indicates whether this thread is currently writing to its `buffer`.
-       gboolean busy;
-
-       // Has this thread written a thread end event to `buffer`?
-       gboolean ended;
-} MonoProfilerThread;
-
-static uintptr_t
-thread_id (void)
-{
-       return (uintptr_t) mono_native_thread_id_get ();
-}
-
-static uintptr_t
-process_id (void)
-{
-#ifdef HOST_WIN32
-       return (uintptr_t) GetCurrentProcessId ();
-#else
-       return (uintptr_t) getpid ();
-#endif
-}
-
-#ifdef __APPLE__
-static mach_timebase_info_data_t timebase_info;
-#elif defined (HOST_WIN32)
-static LARGE_INTEGER pcounter_freq;
-#endif
-
-#define TICKS_PER_SEC 1000000000LL
-
-static uint64_t
-current_time (void)
-{
-#ifdef __APPLE__
-       uint64_t time = mach_absolute_time ();
-
-       time *= timebase_info.numer;
-       time /= timebase_info.denom;
-
-       return time;
-#elif defined (HOST_WIN32)
-       LARGE_INTEGER value;
-
-       QueryPerformanceCounter (&value);
-
-       return value.QuadPart * TICKS_PER_SEC / pcounter_freq.QuadPart;
-#elif defined (CLOCK_MONOTONIC)
-       struct timespec tspec;
-
-       clock_gettime (CLOCK_MONOTONIC, &tspec);
-
-       return ((uint64_t) tspec.tv_sec * TICKS_PER_SEC + tspec.tv_nsec);
-#else
-       struct timeval tv;
-
-       gettimeofday (&tv, NULL);
-
-       return ((uint64_t) tv.tv_sec * TICKS_PER_SEC + tv.tv_usec * 1000);
-#endif
-}
-
-static int timer_overhead;
-
-static void
-init_time (void)
-{
-#ifdef __APPLE__
-       mach_timebase_info (&timebase_info);
-#elif defined (HOST_WIN32)
-       QueryPerformanceFrequency (&pcounter_freq);
-#endif
-
-       uint64_t time_start = current_time ();
-
-       for (int i = 0; i < 256; ++i)
-               current_time ();
-
-       uint64_t time_end = current_time ();
-
-       timer_overhead = (time_end - time_start) / 256;
-}
-
-/*
- * These macros should be used when writing an event to a log buffer. They take
- * care of a bunch of stuff that can be repetitive and error-prone, such as
- * acquiring/releasing the buffer lock, incrementing the event counter,
- * expanding the log buffer, processing requests, etc. They also create a scope
- * so that it's harder to leak the LogBuffer pointer, which can be problematic
- * as the pointer is unstable when the buffer lock isn't acquired.
- */
-
-#define ENTER_LOG(COUNTER, BUFFER, SIZE) \
-       do { \
-               MonoProfilerThread *thread__ = PROF_TLS_GET (); \
-               if (thread__->attached) \
-                       buffer_lock (); \
-               g_assert (!thread__->busy && "Why are we trying to write a new event while already writing one?"); \
-               thread__->busy = TRUE; \
-               InterlockedIncrement ((COUNTER)); \
-               LogBuffer *BUFFER = ensure_logbuf_unsafe (thread__, (SIZE))
-
-#define EXIT_LOG_EXPLICIT(SEND, REQUESTS) \
-               thread__->busy = FALSE; \
-               if ((SEND)) \
-                       send_log_unsafe (TRUE); \
-               if (thread__->attached) \
-                       buffer_unlock (); \
-               if ((REQUESTS)) \
-                       process_requests (); \
-       } while (0)
-
-// Pass these to EXIT_LOG_EXPLICIT () for easier reading.
-#define DO_SEND TRUE
-#define NO_SEND FALSE
-#define DO_REQUESTS TRUE
-#define NO_REQUESTS FALSE
-
-#define EXIT_LOG EXIT_LOG_EXPLICIT (DO_SEND, DO_REQUESTS)
-
-static volatile gint32 buffer_rwlock_count;
-static volatile gpointer buffer_rwlock_exclusive;
-
-// Can be used recursively.
-static void
-buffer_lock (void)
-{
-       /*
-        * If the thread holding the exclusive lock tries to modify the
-        * reader count, just make it a no-op. This way, we also avoid
-        * invoking the GC safe point macros below, which could break if
-        * done from a thread that is currently the initiator of STW.
-        *
-        * In other words, we rely on the fact that the GC thread takes
-        * the exclusive lock in the gc_event () callback when the world
-        * is about to stop.
-        */
-       if (InterlockedReadPointer (&buffer_rwlock_exclusive) != (gpointer) thread_id ()) {
-               MONO_ENTER_GC_SAFE;
-
-               while (InterlockedReadPointer (&buffer_rwlock_exclusive))
-                       mono_thread_info_yield ();
-
-               InterlockedIncrement (&buffer_rwlock_count);
-
-               MONO_EXIT_GC_SAFE;
-       }
-
-       mono_memory_barrier ();
-}
-
-static void
-buffer_unlock (void)
-{
-       mono_memory_barrier ();
-
-       // See the comment in buffer_lock ().
-       if (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id ())
-               return;
-
-       g_assert (InterlockedRead (&buffer_rwlock_count) && "Why are we trying to decrement a zero reader count?");
-
-       InterlockedDecrement (&buffer_rwlock_count);
-}
-
-// Cannot be used recursively.
-static void
-buffer_lock_excl (void)
-{
-       gpointer tid = (gpointer) thread_id ();
-
-       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) != tid && "Why are we taking the exclusive lock twice?");
-
-       MONO_ENTER_GC_SAFE;
-
-       while (InterlockedCompareExchangePointer (&buffer_rwlock_exclusive, tid, 0))
-               mono_thread_info_yield ();
-
-       while (InterlockedRead (&buffer_rwlock_count))
-               mono_thread_info_yield ();
-
-       MONO_EXIT_GC_SAFE;
-
-       mono_memory_barrier ();
-}
-
-static void
-buffer_unlock_excl (void)
-{
-       mono_memory_barrier ();
-
-       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) && "Why is the exclusive lock not held?");
-       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id () && "Why does another thread hold the exclusive lock?");
-       g_assert (!InterlockedRead (&buffer_rwlock_count) && "Why are there readers when the exclusive lock is held?");
-
-       InterlockedWritePointer (&buffer_rwlock_exclusive, NULL);
-}
-
-typedef struct _BinaryObject BinaryObject;
-struct _BinaryObject {
-       BinaryObject *next;
-       void *addr;
-       char *name;
-};
-
-struct _MonoProfiler {
-       FILE* file;
-#if defined (HAVE_SYS_ZLIB)
-       gzFile gzfile;
-#endif
-       char *args;
-       uint64_t startup_time;
-       int pipe_output;
-       int command_port;
-       int server_socket;
-       int pipes [2];
-       MonoNativeThreadId helper_thread;
-       MonoNativeThreadId writer_thread;
-       MonoNativeThreadId dumper_thread;
-       volatile gint32 run_writer_thread;
-       MonoLockFreeAllocSizeClass writer_entry_size_class;
-       MonoLockFreeAllocator writer_entry_allocator;
-       MonoLockFreeQueue writer_queue;
-       MonoSemType writer_queue_sem;
-       MonoConcurrentHashTable *method_table;
-       mono_mutex_t method_table_mutex;
-       volatile gint32 run_dumper_thread;
-       MonoLockFreeQueue dumper_queue;
-       MonoSemType dumper_queue_sem;
-       MonoLockFreeAllocSizeClass sample_size_class;
-       MonoLockFreeAllocator sample_allocator;
-       MonoLockFreeQueue sample_reuse_queue;
-       BinaryObject *binary_objects;
-       GPtrArray *coverage_filters;
-};
-
-typedef struct {
-       MonoLockFreeQueueNode node;
-       GPtrArray *methods;
-       LogBuffer *buffer;
-} WriterQueueEntry;
-
-#define WRITER_ENTRY_BLOCK_SIZE (mono_pagesize ())
-
-typedef struct {
-       MonoMethod *method;
-       MonoJitInfo *ji;
-       uint64_t time;
-} MethodInfo;
-
-#ifdef HOST_WIN32
-
-#define PROF_TLS_SET(VAL) (TlsSetValue (profiler_tls, (VAL)))
-#define PROF_TLS_GET() ((MonoProfilerThread *) TlsGetValue (profiler_tls))
-#define PROF_TLS_INIT() (profiler_tls = TlsAlloc ())
-#define PROF_TLS_FREE() (TlsFree (profiler_tls))
-
-static DWORD profiler_tls;
-
-#elif HAVE_KW_THREAD
-
-#define PROF_TLS_SET(VAL) (profiler_tls = (VAL))
-#define PROF_TLS_GET() (profiler_tls)
-#define PROF_TLS_INIT()
-#define PROF_TLS_FREE()
-
-static __thread MonoProfilerThread *profiler_tls;
-
-#else
-
-#define PROF_TLS_SET(VAL) (pthread_setspecific (profiler_tls, (VAL)))
-#define PROF_TLS_GET() ((MonoProfilerThread *) pthread_getspecific (profiler_tls))
-#define PROF_TLS_INIT() (pthread_key_create (&profiler_tls, NULL))
-#define PROF_TLS_FREE() (pthread_key_delete (profiler_tls))
-
-static pthread_key_t profiler_tls;
-
-#endif
-
-static char*
-pstrdup (const char *s)
-{
-       int len = strlen (s) + 1;
-       char *p = (char *) g_malloc (len);
-       memcpy (p, s, len);
-       return p;
-}
-
-static void *
-alloc_buffer (int size)
-{
-       return mono_valloc (NULL, size, MONO_MMAP_READ | MONO_MMAP_WRITE | MONO_MMAP_ANON | MONO_MMAP_PRIVATE, MONO_MEM_ACCOUNT_PROFILER);
-}
-
-static void
-free_buffer (void *buf, int size)
-{
-       mono_vfree (buf, size, MONO_MEM_ACCOUNT_PROFILER);
-}
-
-static LogBuffer*
-create_buffer (uintptr_t tid)
-{
-       LogBuffer* buf = (LogBuffer *) alloc_buffer (BUFFER_SIZE);
-
-       InterlockedIncrement (&buffer_allocations_ctr);
-
-       buf->size = BUFFER_SIZE;
-       buf->time_base = current_time ();
-       buf->last_time = buf->time_base;
-       buf->buf_end = (unsigned char *) buf + buf->size;
-       buf->cursor = buf->buf;
-       buf->thread_id = tid;
-
-       return buf;
-}
-
-/*
- * Must be called with the reader lock held if thread is the current thread, or
- * the exclusive lock if thread is a different thread. However, if thread is
- * the current thread, and init_thread () was called with add_to_lls = FALSE,
- * then no locking is necessary.
- */
-static void
-init_buffer_state (MonoProfilerThread *thread)
-{
-       thread->buffer = create_buffer (thread->node.key);
-       thread->methods = NULL;
-}
-
-static void
-clear_hazard_pointers (MonoThreadHazardPointers *hp)
-{
-       mono_hazard_pointer_clear (hp, 0);
-       mono_hazard_pointer_clear (hp, 1);
-       mono_hazard_pointer_clear (hp, 2);
-}
-
-static MonoProfilerThread *
-init_thread (MonoProfiler *prof, gboolean add_to_lls)
-{
-       MonoProfilerThread *thread = PROF_TLS_GET ();
-
-       /*
-        * Sometimes we may try to initialize a thread twice. One example is the
-        * main thread: We initialize it when setting up the profiler, but we will
-        * also get a thread_start () callback for it. Another example is when
-        * attaching new threads to the runtime: We may get a gc_alloc () callback
-        * for that thread's thread object (where we initialize it), soon followed
-        * by a thread_start () callback.
-        *
-        * These cases are harmless anyhow. Just return if we've already done the
-        * initialization work.
-        */
-       if (thread)
-               return thread;
-
-       thread = g_malloc (sizeof (MonoProfilerThread));
-       thread->node.key = thread_id ();
-       thread->profiler = prof;
-       thread->attached = add_to_lls;
-       thread->call_depth = 0;
-       thread->busy = 0;
-       thread->ended = FALSE;
-
-       init_buffer_state (thread);
-
-       /*
-        * Some internal profiler threads don't need to be cleaned up
-        * by the main thread on shutdown.
-        */
-       if (add_to_lls) {
-               MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
-               g_assert (mono_lls_insert (&profiler_thread_list, hp, &thread->node) && "Why can't we insert the thread in the LLS?");
-               clear_hazard_pointers (hp);
-       }
-
-       PROF_TLS_SET (thread);
-
-       return thread;
-}
-
-// Only valid if init_thread () was called with add_to_lls = FALSE.
-static void
-deinit_thread (MonoProfilerThread *thread)
-{
-       g_assert (!thread->attached && "Why are we manually freeing an attached thread?");
-
-       g_free (thread);
-       PROF_TLS_SET (NULL);
-}
-
-// Only valid if init_thread () was called with add_to_lls = FALSE.
-static LogBuffer *
-ensure_logbuf_unsafe (MonoProfilerThread *thread, int bytes)
-{
-       LogBuffer *old = thread->buffer;
-
-       if (old && old->cursor + bytes + 100 < old->buf_end)
-               return old;
-
-       LogBuffer *new_ = create_buffer (thread->node.key);
-       new_->next = old;
-       thread->buffer = new_;
-
-       return new_;
-}
-
-static void
-encode_uleb128 (uint64_t value, uint8_t *buf, uint8_t **endbuf)
-{
-       uint8_t *p = buf;
-
-       do {
-               uint8_t b = value & 0x7f;
-               value >>= 7;
-
-               if (value != 0) /* more bytes to come */
-                       b |= 0x80;
-
-               *p ++ = b;
-       } while (value);
-
-       *endbuf = p;
-}
-
-static void
-encode_sleb128 (intptr_t value, uint8_t *buf, uint8_t **endbuf)
-{
-       int more = 1;
-       int negative = (value < 0);
-       unsigned int size = sizeof (intptr_t) * 8;
-       uint8_t byte;
-       uint8_t *p = buf;
-
-       while (more) {
-               byte = value & 0x7f;
-               value >>= 7;
-
-               /* the following is unnecessary if the
-                * implementation of >>= uses an arithmetic rather
-                * than logical shift for a signed left operand
-                */
-               if (negative)
-                       /* sign extend */
-                       value |= - ((intptr_t) 1 <<(size - 7));
-
-               /* sign bit of byte is second high order bit (0x40) */
-               if ((value == 0 && !(byte & 0x40)) ||
-                   (value == -1 && (byte & 0x40)))
-                       more = 0;
-               else
-                       byte |= 0x80;
-
-               *p ++= byte;
-       }
-
-       *endbuf = p;
-}
-
-static void
-emit_byte (LogBuffer *logbuffer, int value)
-{
-       logbuffer->cursor [0] = value;
-       logbuffer->cursor++;
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_value (LogBuffer *logbuffer, int value)
-{
-       encode_uleb128 (value, logbuffer->cursor, &logbuffer->cursor);
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_time (LogBuffer *logbuffer, uint64_t value)
-{
-       uint64_t tdiff = value - logbuffer->last_time;
-       encode_uleb128 (tdiff, logbuffer->cursor, &logbuffer->cursor);
-       logbuffer->last_time = value;
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_event_time (LogBuffer *logbuffer, int event, uint64_t time)
-{
-       emit_byte (logbuffer, event);
-       emit_time (logbuffer, time);
-}
-
-static void
-emit_event (LogBuffer *logbuffer, int event)
-{
-       emit_event_time (logbuffer, event, current_time ());
-}
-
-static void
-emit_svalue (LogBuffer *logbuffer, int64_t value)
-{
-       encode_sleb128 (value, logbuffer->cursor, &logbuffer->cursor);
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_uvalue (LogBuffer *logbuffer, uint64_t value)
-{
-       encode_uleb128 (value, logbuffer->cursor, &logbuffer->cursor);
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_ptr (LogBuffer *logbuffer, void *ptr)
-{
-       if (!logbuffer->ptr_base)
-               logbuffer->ptr_base = (uintptr_t) ptr;
-
-       emit_svalue (logbuffer, (intptr_t) ptr - logbuffer->ptr_base);
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_method_inner (LogBuffer *logbuffer, void *method)
-{
-       if (!logbuffer->method_base) {
-               logbuffer->method_base = (intptr_t) method;
-               logbuffer->last_method = (intptr_t) method;
-       }
-
-       encode_sleb128 ((intptr_t) ((char *) method - (char *) logbuffer->last_method), logbuffer->cursor, &logbuffer->cursor);
-       logbuffer->last_method = (intptr_t) method;
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-register_method_local (MonoMethod *method, MonoJitInfo *ji)
-{
-       MonoProfilerThread *thread = PROF_TLS_GET ();
-
-       if (!mono_conc_hashtable_lookup (thread->profiler->method_table, method)) {
-               MethodInfo *info = (MethodInfo *) g_malloc (sizeof (MethodInfo));
-
-               info->method = method;
-               info->ji = ji;
-               info->time = current_time ();
-
-               GPtrArray *arr = thread->methods ? thread->methods : (thread->methods = g_ptr_array_new ());
-               g_ptr_array_add (arr, info);
-       }
-}
-
-static void
-emit_method (LogBuffer *logbuffer, MonoMethod *method)
-{
-       register_method_local (method, NULL);
-       emit_method_inner (logbuffer, method);
-}
-
-static void
-emit_obj (LogBuffer *logbuffer, void *ptr)
-{
-       if (!logbuffer->obj_base)
-               logbuffer->obj_base = (uintptr_t) ptr >> 3;
-
-       emit_svalue (logbuffer, ((uintptr_t) ptr >> 3) - logbuffer->obj_base);
-
-       g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
-}
-
-static void
-emit_string (LogBuffer *logbuffer, const char *str, size_t size)
-{
-       size_t i = 0;
-       if (str) {
-               for (; i < size; i++) {
-                       if (str[i] == '\0')
-                               break;
-                       emit_byte (logbuffer, str [i]);
-               }
-       }
-       emit_byte (logbuffer, '\0');
-}
-
-static void
-emit_double (LogBuffer *logbuffer, double value)
-{
-       int i;
-       unsigned char buffer[8];
-       memcpy (buffer, &value, 8);
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-       for (i = 7; i >= 0; i--)
-#else
-       for (i = 0; i < 8; i++)
-#endif
-               emit_byte (logbuffer, buffer[i]);
-}
-
-static char*
-write_int16 (char *buf, int32_t value)
-{
-       int i;
-       for (i = 0; i < 2; ++i) {
-               buf [i] = value;
-               value >>= 8;
-       }
-       return buf + 2;
-}
-
-static char*
-write_int32 (char *buf, int32_t value)
-{
-       int i;
-       for (i = 0; i < 4; ++i) {
-               buf [i] = value;
-               value >>= 8;
-       }
-       return buf + 4;
-}
-
-static char*
-write_int64 (char *buf, int64_t value)
-{
-       int i;
-       for (i = 0; i < 8; ++i) {
-               buf [i] = value;
-               value >>= 8;
-       }
-       return buf + 8;
-}
-
-static char *
-write_header_string (char *p, const char *str)
-{
-       size_t len = strlen (str) + 1;
-
-       p = write_int32 (p, len);
-       strcpy (p, str);
-
-       return p + len;
-}
-
-static void
-dump_header (MonoProfiler *profiler)
-{
-       const char *args = profiler->args;
-       const char *arch = mono_config_get_cpu ();
-       const char *os = mono_config_get_os ();
-
-       char *hbuf = g_malloc (
-               sizeof (gint32) /* header id */ +
-               sizeof (gint8) /* major version */ +
-               sizeof (gint8) /* minor version */ +
-               sizeof (gint8) /* data version */ +
-               sizeof (gint8) /* word size */ +
-               sizeof (gint64) /* startup time */ +
-               sizeof (gint32) /* timer overhead */ +
-               sizeof (gint32) /* flags */ +
-               sizeof (gint32) /* process id */ +
-               sizeof (gint16) /* command port */ +
-               sizeof (gint32) + strlen (args) + 1 /* arguments */ +
-               sizeof (gint32) + strlen (arch) + 1 /* architecture */ +
-               sizeof (gint32) + strlen (os) + 1 /* operating system */
-       );
-       char *p = hbuf;
-
-       p = write_int32 (p, LOG_HEADER_ID);
-       *p++ = LOG_VERSION_MAJOR;
-       *p++ = LOG_VERSION_MINOR;
-       *p++ = LOG_DATA_VERSION;
-       *p++ = sizeof (void *);
-       p = write_int64 (p, ((uint64_t) time (NULL)) * 1000);
-       p = write_int32 (p, timer_overhead);
-       p = write_int32 (p, 0); /* flags */
-       p = write_int32 (p, process_id ());
-       p = write_int16 (p, profiler->command_port);
-       p = write_header_string (p, args);
-       p = write_header_string (p, arch);
-       p = write_header_string (p, os);
-
-#if defined (HAVE_SYS_ZLIB)
-       if (profiler->gzfile) {
-               gzwrite (profiler->gzfile, hbuf, p - hbuf);
-       } else
-#endif
-       {
-               fwrite (hbuf, p - hbuf, 1, profiler->file);
-               fflush (profiler->file);
-       }
-
-       g_free (hbuf);
-}
-
-/*
- * Must be called with the reader lock held if thread is the current thread, or
- * the exclusive lock if thread is a different thread. However, if thread is
- * the current thread, and init_thread () was called with add_to_lls = FALSE,
- * then no locking is necessary.
- */
-static void
-send_buffer (MonoProfilerThread *thread)
-{
-       WriterQueueEntry *entry = mono_lock_free_alloc (&thread->profiler->writer_entry_allocator);
-       entry->methods = thread->methods;
-       entry->buffer = thread->buffer;
-
-       mono_lock_free_queue_node_init (&entry->node, FALSE);
-
-       mono_lock_free_queue_enqueue (&thread->profiler->writer_queue, &entry->node);
-       mono_os_sem_post (&thread->profiler->writer_queue_sem);
-}
-
-static void
-free_thread (gpointer p)
-{
-       MonoProfilerThread *thread = p;
-
-       if (!thread->ended) {
-               /*
-                * The thread is being cleaned up by the main thread during
-                * shutdown. This typically happens for internal runtime
-                * threads. We need to synthesize a thread end event.
-                */
-
-               InterlockedIncrement (&thread_ends_ctr);
-
-               LogBuffer *buf = ensure_logbuf_unsafe (thread,
-                       EVENT_SIZE /* event */ +
-                       BYTE_SIZE /* type */ +
-                       LEB128_SIZE /* tid */
-               );
-
-               emit_event (buf, TYPE_END_UNLOAD | TYPE_METADATA);
-               emit_byte (buf, TYPE_THREAD);
-               emit_ptr (buf, (void *) thread->node.key);
-       }
-
-       send_buffer (thread);
-
-       g_free (thread);
-}
-
-static void
-remove_thread (MonoProfilerThread *thread)
-{
-       MonoThreadHazardPointers *hp = mono_hazard_pointer_get ();
-
-       if (mono_lls_remove (&profiler_thread_list, hp, &thread->node))
-               mono_thread_hazardous_try_free (thread, free_thread);
-
-       clear_hazard_pointers (hp);
-}
-
-static void
-dump_buffer (MonoProfiler *profiler, LogBuffer *buf)
-{
-       char hbuf [128];
-       char *p = hbuf;
-
-       if (buf->next)
-               dump_buffer (profiler, buf->next);
-
-       if (buf->cursor - buf->buf) {
-               p = write_int32 (p, BUF_ID);
-               p = write_int32 (p, buf->cursor - buf->buf);
-               p = write_int64 (p, buf->time_base);
-               p = write_int64 (p, buf->ptr_base);
-               p = write_int64 (p, buf->obj_base);
-               p = write_int64 (p, buf->thread_id);
-               p = write_int64 (p, buf->method_base);
-
-#if defined (HAVE_SYS_ZLIB)
-               if (profiler->gzfile) {
-                       gzwrite (profiler->gzfile, hbuf, p - hbuf);
-                       gzwrite (profiler->gzfile, buf->buf, buf->cursor - buf->buf);
-               } else
-#endif
-               {
-                       fwrite (hbuf, p - hbuf, 1, profiler->file);
-                       fwrite (buf->buf, buf->cursor - buf->buf, 1, profiler->file);
-                       fflush (profiler->file);
-               }
-       }
-
-       free_buffer (buf, buf->size);
-}
-
-static void
-dump_buffer_threadless (MonoProfiler *profiler, LogBuffer *buf)
-{
-       for (LogBuffer *iter = buf; iter; iter = iter->next)
-               iter->thread_id = 0;
-
-       dump_buffer (profiler, buf);
-}
-
-static void
-process_requests (void)
-{
-       if (heapshot_requested)
-               mono_gc_collect (mono_gc_max_generation ());
-}
-
-// Only valid if init_thread () was called with add_to_lls = FALSE.
-static void
-send_log_unsafe (gboolean if_needed)
-{
-       MonoProfilerThread *thread = PROF_TLS_GET ();
-
-       if (!if_needed || (if_needed && thread->buffer->next)) {
-               if (!thread->attached)
-                       for (LogBuffer *iter = thread->buffer; iter; iter = iter->next)
-                               iter->thread_id = 0;
-
-               send_buffer (thread);
-               init_buffer_state (thread);
-       }
-}
-
-// Assumes that the exclusive lock is held.
-static void
-sync_point_flush (void)
-{
-       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id () && "Why don't we hold the exclusive lock?");
-
-       MONO_LLS_FOREACH_SAFE (&profiler_thread_list, MonoProfilerThread, thread) {
-               g_assert (thread->attached && "Why is a thread in the LLS not attached?");
-
-               send_buffer (thread);
-               init_buffer_state (thread);
-       } MONO_LLS_FOREACH_SAFE_END
-}
-
-// Assumes that the exclusive lock is held.
-static void
-sync_point_mark (MonoProfilerSyncPointType type)
-{
-       g_assert (InterlockedReadPointer (&buffer_rwlock_exclusive) == (gpointer) thread_id () && "Why don't we hold the exclusive lock?");
-
-       ENTER_LOG (&sync_points_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* type */
-       );
-
-       emit_event (logbuffer, TYPE_META | TYPE_SYNC_POINT);
-       emit_byte (logbuffer, type);
-
-       EXIT_LOG_EXPLICIT (NO_SEND, NO_REQUESTS);
-
-       send_log_unsafe (FALSE);
-}
-
-// Assumes that the exclusive lock is held.
-static void
-sync_point (MonoProfilerSyncPointType type)
-{
-       sync_point_flush ();
-       sync_point_mark (type);
-}
-
-static int
-gc_reference (MonoObject *obj, MonoClass *klass, uintptr_t size, uintptr_t num, MonoObject **refs, uintptr_t *offsets, void *data)
-{
-       /* account for object alignment in the heap */
-       size += 7;
-       size &= ~7;
-
-       ENTER_LOG (&heap_objects_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* obj */ +
-               LEB128_SIZE /* klass */ +
-               LEB128_SIZE /* size */ +
-               LEB128_SIZE /* num */ +
-               num * (
-                       LEB128_SIZE /* offset */ +
-                       LEB128_SIZE /* ref */
-               )
-       );
-
-       emit_event (logbuffer, TYPE_HEAP_OBJECT | TYPE_HEAP);
-       emit_obj (logbuffer, obj);
-       emit_ptr (logbuffer, klass);
-       emit_value (logbuffer, size);
-       emit_value (logbuffer, num);
-
-       uintptr_t last_offset = 0;
-
-       for (int i = 0; i < num; ++i) {
-               emit_value (logbuffer, offsets [i] - last_offset);
-               last_offset = offsets [i];
-               emit_obj (logbuffer, refs [i]);
-       }
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-       return 0;
-}
-
-static unsigned int hs_mode_ms = 0;
-static unsigned int hs_mode_gc = 0;
-static unsigned int hs_mode_ondemand = 0;
-static unsigned int gc_count = 0;
-static uint64_t last_hs_time = 0;
-static gboolean do_heap_walk = FALSE;
-
-static void
-heap_walk (MonoProfiler *profiler)
-{
-       ENTER_LOG (&heap_starts_ctr, logbuffer,
-               EVENT_SIZE /* event */
-       );
-
-       emit_event (logbuffer, TYPE_HEAP_START | TYPE_HEAP);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-       mono_gc_walk_heap (0, gc_reference, NULL);
-
-       ENTER_LOG (&heap_ends_ctr, logbuffer,
-               EVENT_SIZE /* event */
-       );
-
-       emit_event (logbuffer, TYPE_HEAP_END | TYPE_HEAP);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-static void
-gc_roots (MonoProfiler *prof, int num, void **objects, int *root_types, uintptr_t *extra_info)
-{
-       ENTER_LOG (&heap_roots_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* num */ +
-               LEB128_SIZE /* collections */ +
-               num * (
-                       LEB128_SIZE /* object */ +
-                       LEB128_SIZE /* root type */ +
-                       LEB128_SIZE /* extra info */
-               )
-       );
-
-       emit_event (logbuffer, TYPE_HEAP_ROOT | TYPE_HEAP);
-       emit_value (logbuffer, num);
-       emit_value (logbuffer, mono_gc_collection_count (mono_gc_max_generation ()));
-
-       for (int i = 0; i < num; ++i) {
-               emit_obj (logbuffer, objects [i]);
-               emit_byte (logbuffer, root_types [i]);
-               emit_value (logbuffer, extra_info [i]);
-       }
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-static void
-gc_event (MonoProfiler *profiler, MonoGCEvent ev, int generation)
-{
-       ENTER_LOG (&gc_events_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* gc event */ +
-               BYTE_SIZE /* generation */
-       );
-
-       emit_event (logbuffer, TYPE_GC_EVENT | TYPE_GC);
-       emit_byte (logbuffer, ev);
-       emit_byte (logbuffer, generation);
-
-       EXIT_LOG_EXPLICIT (NO_SEND, NO_REQUESTS);
-
-       switch (ev) {
-       case MONO_GC_EVENT_START:
-               if (generation == mono_gc_max_generation ())
-                       gc_count++;
-
-               uint64_t now = current_time ();
-
-               if (hs_mode_ms && (now - last_hs_time) / 1000 * 1000 >= hs_mode_ms)
-                       do_heap_walk = TRUE;
-               else if (hs_mode_gc && !(gc_count % hs_mode_gc))
-                       do_heap_walk = TRUE;
-               else if (hs_mode_ondemand)
-                       do_heap_walk = heapshot_requested;
-               else if (!hs_mode_ms && !hs_mode_gc && generation == mono_gc_max_generation ())
-                       do_heap_walk = TRUE;
-               break;
-       case MONO_GC_EVENT_PRE_STOP_WORLD_LOCKED:
-               /*
-                * Ensure that no thread can be in the middle of writing to
-                * a buffer when the world stops...
-                */
-               buffer_lock_excl ();
-               break;
-       case MONO_GC_EVENT_POST_STOP_WORLD:
-               /*
-                * ... So that we now have a consistent view of all buffers.
-                * This allows us to flush them. We need to do this because
-                * they may contain object allocation events that need to be
-                * committed to the log file before any object move events
-                * that will be produced during this GC.
-                */
-               sync_point (SYNC_POINT_WORLD_STOP);
-               break;
-       case MONO_GC_EVENT_PRE_START_WORLD:
-               if (do_heap_shot && do_heap_walk) {
-                       heap_walk (profiler);
-
-                       do_heap_walk = FALSE;
-                       heapshot_requested = 0;
-                       last_hs_time = current_time ();
-               }
-               break;
-       case MONO_GC_EVENT_POST_START_WORLD_UNLOCKED:
-               /*
-                * Similarly, we must now make sure that any object moves
-                * written to the GC thread's buffer are flushed. Otherwise,
-                * object allocation events for certain addresses could come
-                * after the move events that made those addresses available.
-                */
-               sync_point_mark (SYNC_POINT_WORLD_START);
-
-               /*
-                * Finally, it is safe to allow other threads to write to
-                * their buffers again.
-                */
-               buffer_unlock_excl ();
-               break;
-       default:
-               break;
-       }
-}
-
-static void
-gc_resize (MonoProfiler *profiler, int64_t new_size)
-{
-       ENTER_LOG (&gc_resizes_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* new size */
-       );
-
-       emit_event (logbuffer, TYPE_GC_RESIZE | TYPE_GC);
-       emit_value (logbuffer, new_size);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-// If you alter MAX_FRAMES, you may need to alter SAMPLE_BLOCK_SIZE too.
-#define MAX_FRAMES 32
-
-typedef struct {
-       int count;
-       MonoMethod* methods [MAX_FRAMES];
-       int32_t il_offsets [MAX_FRAMES];
-       int32_t native_offsets [MAX_FRAMES];
-} FrameData;
-
-static int num_frames = MAX_FRAMES;
-
-static mono_bool
-walk_stack (MonoMethod *method, int32_t native_offset, int32_t il_offset, mono_bool managed, void* data)
-{
-       FrameData *frame = (FrameData *)data;
-       if (method && frame->count < num_frames) {
-               frame->il_offsets [frame->count] = il_offset;
-               frame->native_offsets [frame->count] = native_offset;
-               frame->methods [frame->count++] = method;
-               //printf ("In %d %s at %d (native: %d)\n", frame->count, mono_method_get_name (method), il_offset, native_offset);
-       }
-       return frame->count == num_frames;
-}
-
-/*
- * a note about stack walks: they can cause more profiler events to fire,
- * so we need to make sure they don't happen after we started emitting an
- * event, hence the collect_bt/emit_bt split.
- */
-static void
-collect_bt (FrameData *data)
-{
-       data->count = 0;
-       mono_stack_walk_no_il (walk_stack, data);
-}
-
-static void
-emit_bt (MonoProfiler *prof, LogBuffer *logbuffer, FrameData *data)
-{
-       /* FIXME: this is actually tons of data and we should
-        * just output it the first time and use an id the next
-        */
-       if (data->count > num_frames)
-               printf ("bad num frames: %d\n", data->count);
-       emit_value (logbuffer, data->count);
-       //if (*p != data.count) {
-       //      printf ("bad num frames enc at %d: %d -> %d\n", count, data.count, *p); printf ("frames end: %p->%p\n", p, logbuffer->cursor); exit(0);}
-       while (data->count) {
-               emit_method (logbuffer, data->methods [--data->count]);
-       }
-}
-
-static void
-gc_alloc (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
-{
-       init_thread (prof, TRUE);
-
-       int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces) ? TYPE_ALLOC_BT : 0;
-       FrameData data;
-       uintptr_t len = mono_object_get_size (obj);
-       /* account for object alignment in the heap */
-       len += 7;
-       len &= ~7;
-
-       if (do_bt)
-               collect_bt (&data);
-
-       ENTER_LOG (&gc_allocs_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* klass */ +
-               LEB128_SIZE /* obj */ +
-               LEB128_SIZE /* size */ +
-               (do_bt ? (
-                       LEB128_SIZE /* count */ +
-                       data.count * (
-                               LEB128_SIZE /* method */
-                       )
-               ) : 0)
-       );
-
-       emit_event (logbuffer, do_bt | TYPE_ALLOC);
-       emit_ptr (logbuffer, klass);
-       emit_obj (logbuffer, obj);
-       emit_value (logbuffer, len);
-
-       if (do_bt)
-               emit_bt (prof, logbuffer, &data);
-
-       EXIT_LOG;
-}
-
-static void
-gc_moves (MonoProfiler *prof, void **objects, int num)
-{
-       ENTER_LOG (&gc_moves_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* num */ +
-               num * (
-                       LEB128_SIZE /* object */
-               )
-       );
-
-       emit_event (logbuffer, TYPE_GC_MOVE | TYPE_GC);
-       emit_value (logbuffer, num);
-
-       for (int i = 0; i < num; ++i)
-               emit_obj (logbuffer, objects [i]);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-static void
-gc_handle (MonoProfiler *prof, int op, int type, uintptr_t handle, MonoObject *obj)
-{
-       int do_bt = nocalls && InterlockedRead (&runtime_inited) && !notraces;
-       FrameData data;
-
-       if (do_bt)
-               collect_bt (&data);
-
-       gint32 *ctr = op == MONO_PROFILER_GC_HANDLE_CREATED ? &gc_handle_creations_ctr : &gc_handle_deletions_ctr;
-
-       ENTER_LOG (ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* type */ +
-               LEB128_SIZE /* handle */ +
-               (op == MONO_PROFILER_GC_HANDLE_CREATED ? (
-                       LEB128_SIZE /* obj */
-               ) : 0) +
-               (do_bt ? (
-                       LEB128_SIZE /* count */ +
-                       data.count * (
-                               LEB128_SIZE /* method */
-                       )
-               ) : 0)
-       );
-
-       if (op == MONO_PROFILER_GC_HANDLE_CREATED)
-               emit_event (logbuffer, (do_bt ? TYPE_GC_HANDLE_CREATED_BT : TYPE_GC_HANDLE_CREATED) | TYPE_GC);
-       else if (op == MONO_PROFILER_GC_HANDLE_DESTROYED)
-               emit_event (logbuffer, (do_bt ? TYPE_GC_HANDLE_DESTROYED_BT : TYPE_GC_HANDLE_DESTROYED) | TYPE_GC);
-       else
-               g_assert_not_reached ();
-
-       emit_value (logbuffer, type);
-       emit_value (logbuffer, handle);
-
-       if (op == MONO_PROFILER_GC_HANDLE_CREATED)
-               emit_obj (logbuffer, obj);
-
-       if (do_bt)
-               emit_bt (prof, logbuffer, &data);
-
-       EXIT_LOG;
-}
-
-static void
-finalize_begin (MonoProfiler *prof)
-{
-       ENTER_LOG (&finalize_begins_ctr, buf,
-               EVENT_SIZE /* event */
-       );
-
-       emit_event (buf, TYPE_GC_FINALIZE_START | TYPE_GC);
-
-       EXIT_LOG;
-}
-
-static void
-finalize_end (MonoProfiler *prof)
-{
-       ENTER_LOG (&finalize_ends_ctr, buf,
-               EVENT_SIZE /* event */
-       );
-
-       emit_event (buf, TYPE_GC_FINALIZE_END | TYPE_GC);
-
-       EXIT_LOG;
-}
-
-static void
-finalize_object_begin (MonoProfiler *prof, MonoObject *obj)
-{
-       ENTER_LOG (&finalize_object_begins_ctr, buf,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* obj */
-       );
-
-       emit_event (buf, TYPE_GC_FINALIZE_OBJECT_START | TYPE_GC);
-       emit_obj (buf, obj);
-
-       EXIT_LOG;
-}
-
-static void
-finalize_object_end (MonoProfiler *prof, MonoObject *obj)
-{
-       ENTER_LOG (&finalize_object_ends_ctr, buf,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* obj */
-       );
-
-       emit_event (buf, TYPE_GC_FINALIZE_OBJECT_END | TYPE_GC);
-       emit_obj (buf, obj);
-
-       EXIT_LOG;
-}
-
-static char*
-push_nesting (char *p, MonoClass *klass)
-{
-       MonoClass *nesting;
-       const char *name;
-       const char *nspace;
-       nesting = mono_class_get_nesting_type (klass);
-       if (nesting) {
-               p = push_nesting (p, nesting);
-               *p++ = '/';
-               *p = 0;
-       }
-       name = mono_class_get_name (klass);
-       nspace = mono_class_get_namespace (klass);
-       if (*nspace) {
-               strcpy (p, nspace);
-               p += strlen (nspace);
-               *p++ = '.';
-               *p = 0;
-       }
-       strcpy (p, name);
-       p += strlen (name);
-       return p;
-}
-
-static char*
-type_name (MonoClass *klass)
-{
-       char buf [1024];
-       char *p;
-       push_nesting (buf, klass);
-       p = (char *) g_malloc (strlen (buf) + 1);
-       strcpy (p, buf);
-       return p;
-}
-
-static void
-image_loaded (MonoProfiler *prof, MonoImage *image, int result)
-{
-       if (result != MONO_PROFILE_OK)
-               return;
-
-       const char *name = mono_image_get_filename (image);
-       int nlen = strlen (name) + 1;
-
-       ENTER_LOG (&image_loads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* image */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_IMAGE);
-       emit_ptr (logbuffer, image);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-}
-
-static void
-image_unloaded (MonoProfiler *prof, MonoImage *image)
-{
-       const char *name = mono_image_get_filename (image);
-       int nlen = strlen (name) + 1;
-
-       ENTER_LOG (&image_unloads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* image */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_IMAGE);
-       emit_ptr (logbuffer, image);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-}
-
-static void
-assembly_loaded (MonoProfiler *prof, MonoAssembly *assembly, int result)
-{
-       if (result != MONO_PROFILE_OK)
-               return;
-
-       char *name = mono_stringify_assembly_name (mono_assembly_get_name (assembly));
-       int nlen = strlen (name) + 1;
-
-       ENTER_LOG (&assembly_loads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* assembly */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_ASSEMBLY);
-       emit_ptr (logbuffer, assembly);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-
-       mono_free (name);
-}
-
-static void
-assembly_unloaded (MonoProfiler *prof, MonoAssembly *assembly)
-{
-       char *name = mono_stringify_assembly_name (mono_assembly_get_name (assembly));
-       int nlen = strlen (name) + 1;
-
-       ENTER_LOG (&assembly_unloads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* assembly */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_ASSEMBLY);
-       emit_ptr (logbuffer, assembly);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-
-       mono_free (name);
-}
-
-static void
-class_loaded (MonoProfiler *prof, MonoClass *klass, int result)
-{
-       if (result != MONO_PROFILE_OK)
-               return;
-
-       char *name;
-
-       if (InterlockedRead (&runtime_inited))
-               name = mono_type_get_name (mono_class_get_type (klass));
-       else
-               name = type_name (klass);
-
-       int nlen = strlen (name) + 1;
-       MonoImage *image = mono_class_get_image (klass);
-
-       ENTER_LOG (&class_loads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* klass */ +
-               LEB128_SIZE /* image */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_CLASS);
-       emit_ptr (logbuffer, klass);
-       emit_ptr (logbuffer, image);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-
-       if (runtime_inited)
-               mono_free (name);
-       else
-               g_free (name);
-}
-
-static void
-class_unloaded (MonoProfiler *prof, MonoClass *klass)
-{
-       char *name;
-
-       if (InterlockedRead (&runtime_inited))
-               name = mono_type_get_name (mono_class_get_type (klass));
-       else
-               name = type_name (klass);
-
-       int nlen = strlen (name) + 1;
-       MonoImage *image = mono_class_get_image (klass);
-
-       ENTER_LOG (&class_unloads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* klass */ +
-               LEB128_SIZE /* image */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_CLASS);
-       emit_ptr (logbuffer, klass);
-       emit_ptr (logbuffer, image);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-
-       if (runtime_inited)
-               mono_free (name);
-       else
-               g_free (name);
-}
-
-static void process_method_enter_coverage (MonoProfiler *prof, MonoMethod *method);
-
-static void
-method_enter (MonoProfiler *prof, MonoMethod *method)
-{
-       process_method_enter_coverage (prof, method);
-
-       if (!only_coverage && PROF_TLS_GET ()->call_depth++ <= max_call_depth) {
-               ENTER_LOG (&method_entries_ctr, logbuffer,
-                       EVENT_SIZE /* event */ +
-                       LEB128_SIZE /* method */
-               );
-
-               emit_event (logbuffer, TYPE_ENTER | TYPE_METHOD);
-               emit_method (logbuffer, method);
-
-               EXIT_LOG;
-       }
-}
-
-static void
-method_leave (MonoProfiler *prof, MonoMethod *method)
-{
-       if (!only_coverage && --PROF_TLS_GET ()->call_depth <= max_call_depth) {
-               ENTER_LOG (&method_exits_ctr, logbuffer,
-                       EVENT_SIZE /* event */ +
-                       LEB128_SIZE /* method */
-               );
-
-               emit_event (logbuffer, TYPE_LEAVE | TYPE_METHOD);
-               emit_method (logbuffer, method);
-
-               EXIT_LOG;
-       }
-}
-
-static void
-method_exc_leave (MonoProfiler *prof, MonoMethod *method)
-{
-       if (!only_coverage && !nocalls && --PROF_TLS_GET ()->call_depth <= max_call_depth) {
-               ENTER_LOG (&method_exception_exits_ctr, logbuffer,
-                       EVENT_SIZE /* event */ +
-                       LEB128_SIZE /* method */
-               );
-
-               emit_event (logbuffer, TYPE_EXC_LEAVE | TYPE_METHOD);
-               emit_method (logbuffer, method);
-
-               EXIT_LOG;
-       }
-}
-
-static void
-method_jitted (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *ji, int result)
-{
-       if (result != MONO_PROFILE_OK)
-               return;
-
-       register_method_local (method, ji);
-
-       process_requests ();
-}
-
-static void
-code_buffer_new (MonoProfiler *prof, void *buffer, int size, MonoProfilerCodeBufferType type, void *data)
-{
-       char *name;
-       int nlen;
-
-       if (type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE) {
-               name = (char *) data;
-               nlen = strlen (name) + 1;
-       } else {
-               name = NULL;
-               nlen = 0;
-       }
-
-       ENTER_LOG (&code_buffers_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* buffer */ +
-               LEB128_SIZE /* size */ +
-               (name ? (
-                       nlen /* name */
-               ) : 0)
-       );
-
-       emit_event (logbuffer, TYPE_JITHELPER | TYPE_RUNTIME);
-       emit_byte (logbuffer, type);
-       emit_ptr (logbuffer, buffer);
-       emit_value (logbuffer, size);
-
-       if (name) {
-               memcpy (logbuffer->cursor, name, nlen);
-               logbuffer->cursor += nlen;
-       }
-
-       EXIT_LOG;
-}
-
-static void
-throw_exc (MonoProfiler *prof, MonoObject *object)
-{
-       int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces) ? TYPE_THROW_BT : 0;
-       FrameData data;
-
-       if (do_bt)
-               collect_bt (&data);
-
-       ENTER_LOG (&exception_throws_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* object */ +
-               (do_bt ? (
-                       LEB128_SIZE /* count */ +
-                       data.count * (
-                               LEB128_SIZE /* method */
-                       )
-               ) : 0)
-       );
-
-       emit_event (logbuffer, do_bt | TYPE_EXCEPTION);
-       emit_obj (logbuffer, object);
-
-       if (do_bt)
-               emit_bt (prof, logbuffer, &data);
-
-       EXIT_LOG;
-}
-
-static void
-clause_exc (MonoProfiler *prof, MonoMethod *method, int clause_type, int clause_num)
-{
-       ENTER_LOG (&exception_clauses_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* clause type */ +
-               LEB128_SIZE /* clause num */ +
-               LEB128_SIZE /* method */
-       );
-
-       emit_event (logbuffer, TYPE_EXCEPTION | TYPE_CLAUSE);
-       emit_byte (logbuffer, clause_type);
-       emit_value (logbuffer, clause_num);
-       emit_method (logbuffer, method);
-
-       EXIT_LOG;
-}
-
-static void
-monitor_event (MonoProfiler *profiler, MonoObject *object, MonoProfilerMonitorEvent event)
-{
-       int do_bt = (nocalls && InterlockedRead (&runtime_inited) && !notraces && event == MONO_PROFILER_MONITOR_CONTENTION) ? TYPE_MONITOR_BT : 0;
-       FrameData data;
-
-       if (do_bt)
-               collect_bt (&data);
-
-       gint32 *ctr;
-
-       switch (event) {
-       case MONO_PROFILER_MONITOR_CONTENTION:
-               ctr = &monitor_contentions_ctr;
-               break;
-       case MONO_PROFILER_MONITOR_DONE:
-               ctr = &monitor_acquisitions_ctr;
-               break;
-       case MONO_PROFILER_MONITOR_FAIL:
-               ctr = &monitor_failures_ctr;
-               break;
-       default:
-               g_assert_not_reached ();
-               break;
-       }
-
-       ENTER_LOG (ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* object */ +
-               (do_bt ? (
-                       LEB128_SIZE /* count */ +
-                       data.count * (
-                               LEB128_SIZE /* method */
-                       )
-               ) : 0)
-       );
-
-       emit_event (logbuffer, (event << 4) | do_bt | TYPE_MONITOR);
-       emit_obj (logbuffer, object);
-
-       if (do_bt)
-               emit_bt (profiler, logbuffer, &data);
-
-       EXIT_LOG;
-}
-
-static void
-thread_start (MonoProfiler *prof, uintptr_t tid)
-{
-       init_thread (prof, TRUE);
-
-       ENTER_LOG (&thread_starts_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* tid */
-       );
-
-       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_THREAD);
-       emit_ptr (logbuffer, (void*) tid);
-
-       EXIT_LOG;
-}
-
-static void
-thread_end (MonoProfiler *prof, uintptr_t tid)
-{
-       ENTER_LOG (&thread_ends_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* tid */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_THREAD);
-       emit_ptr (logbuffer, (void*) tid);
-
-       EXIT_LOG_EXPLICIT (NO_SEND, NO_REQUESTS);
-
-       MonoProfilerThread *thread = PROF_TLS_GET ();
-
-       thread->ended = TRUE;
-       remove_thread (thread);
-
-       PROF_TLS_SET (NULL);
-}
-
-static void
-thread_name (MonoProfiler *prof, uintptr_t tid, const char *name)
-{
-       int len = strlen (name) + 1;
-
-       ENTER_LOG (&thread_names_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* tid */ +
-               len /* name */
-       );
-
-       emit_event (logbuffer, TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_THREAD);
-       emit_ptr (logbuffer, (void*)tid);
-       memcpy (logbuffer->cursor, name, len);
-       logbuffer->cursor += len;
-
-       EXIT_LOG;
-}
-
-static void
-domain_loaded (MonoProfiler *prof, MonoDomain *domain, int result)
-{
-       if (result != MONO_PROFILE_OK)
-               return;
-
-       ENTER_LOG (&domain_loads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* domain id */
-       );
-
-       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_DOMAIN);
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_domain_get_id (domain));
-
-       EXIT_LOG;
-}
-
-static void
-domain_unloaded (MonoProfiler *prof, MonoDomain *domain)
-{
-       ENTER_LOG (&domain_unloads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* domain id */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_DOMAIN);
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_domain_get_id (domain));
-
-       EXIT_LOG;
-}
-
-static void
-domain_name (MonoProfiler *prof, MonoDomain *domain, const char *name)
-{
-       int nlen = strlen (name) + 1;
-
-       ENTER_LOG (&domain_names_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* domain id */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_DOMAIN);
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_domain_get_id (domain));
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-}
-
-static void
-context_loaded (MonoProfiler *prof, MonoAppContext *context)
-{
-       ENTER_LOG (&context_loads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* context id */ +
-               LEB128_SIZE /* domain id */
-       );
-
-       emit_event (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_CONTEXT);
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_id (context));
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_domain_id (context));
-
-       EXIT_LOG;
-}
-
-static void
-context_unloaded (MonoProfiler *prof, MonoAppContext *context)
-{
-       ENTER_LOG (&context_unloads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* context id */ +
-               LEB128_SIZE /* domain id */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_CONTEXT);
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_id (context));
-       emit_ptr (logbuffer, (void*)(uintptr_t) mono_context_get_domain_id (context));
-
-       EXIT_LOG;
-}
-
-typedef struct {
-       MonoMethod *method;
-       MonoDomain *domain;
-       void *base_address;
-       int offset;
-} AsyncFrameInfo;
-
-typedef struct {
-       MonoLockFreeQueueNode node;
-       MonoProfiler *prof;
-       uint64_t time;
-       uintptr_t tid;
-       void *ip;
-       int count;
-       AsyncFrameInfo frames [MONO_ZERO_LEN_ARRAY];
-} SampleHit;
-
-static mono_bool
-async_walk_stack (MonoMethod *method, MonoDomain *domain, void *base_address, int offset, void *data)
-{
-       SampleHit *sample = (SampleHit *) data;
-
-       if (sample->count < num_frames) {
-               int i = sample->count;
-
-               sample->frames [i].method = method;
-               sample->frames [i].domain = domain;
-               sample->frames [i].base_address = base_address;
-               sample->frames [i].offset = offset;
-
-               sample->count++;
-       }
-
-       return sample->count == num_frames;
-}
-
-#define SAMPLE_SLOT_SIZE(FRAMES) (sizeof (SampleHit) + sizeof (AsyncFrameInfo) * (FRAMES - MONO_ZERO_LEN_ARRAY))
-#define SAMPLE_BLOCK_SIZE (mono_pagesize ())
-
-static void
-enqueue_sample_hit (gpointer p)
-{
-       SampleHit *sample = p;
-
-       mono_lock_free_queue_node_unpoison (&sample->node);
-       mono_lock_free_queue_enqueue (&sample->prof->dumper_queue, &sample->node);
-       mono_os_sem_post (&sample->prof->dumper_queue_sem);
-}
-
-static void
-mono_sample_hit (MonoProfiler *profiler, unsigned char *ip, void *context)
-{
-       /*
-        * Please note: We rely on the runtime loading the profiler with
-        * MONO_DL_EAGER (RTLD_NOW) so that references to runtime functions within
-        * this function (and its siblings) are resolved when the profiler is
-        * loaded. Otherwise, we would potentially invoke the dynamic linker when
-        * invoking runtime functions, which is not async-signal-safe.
-        */
-
-       if (InterlockedRead (&in_shutdown))
-               return;
-
-       SampleHit *sample = (SampleHit *) mono_lock_free_queue_dequeue (&profiler->sample_reuse_queue);
-
-       if (!sample) {
-               /*
-                * If we're out of reusable sample events and we're not allowed to
-                * allocate more, we have no choice but to drop the event.
-                */
-               if (InterlockedRead (&sample_allocations_ctr) >= max_allocated_sample_hits)
-                       return;
-
-               sample = mono_lock_free_alloc (&profiler->sample_allocator);
-               sample->prof = profiler;
-               mono_lock_free_queue_node_init (&sample->node, TRUE);
-
-               InterlockedIncrement (&sample_allocations_ctr);
-       }
-
-       sample->count = 0;
-       mono_stack_walk_async_safe (&async_walk_stack, context, sample);
-
-       sample->time = current_time ();
-       sample->tid = thread_id ();
-       sample->ip = ip;
-
-       mono_thread_hazardous_try_free (sample, enqueue_sample_hit);
-}
-
-static uintptr_t *code_pages = 0;
-static int num_code_pages = 0;
-static int size_code_pages = 0;
-#define CPAGE_SHIFT (9)
-#define CPAGE_SIZE (1 << CPAGE_SHIFT)
-#define CPAGE_MASK (~(CPAGE_SIZE - 1))
-#define CPAGE_ADDR(p) ((p) & CPAGE_MASK)
-
-static uintptr_t
-add_code_page (uintptr_t *hash, uintptr_t hsize, uintptr_t page)
-{
-       uintptr_t i;
-       uintptr_t start_pos;
-       start_pos = (page >> CPAGE_SHIFT) % hsize;
-       i = start_pos;
-       do {
-               if (hash [i] && CPAGE_ADDR (hash [i]) == CPAGE_ADDR (page)) {
-                       return 0;
-               } else if (!hash [i]) {
-                       hash [i] = page;
-                       return 1;
-               }
-               /* wrap around */
-               if (++i == hsize)
-                       i = 0;
-       } while (i != start_pos);
-       /* should not happen */
-       printf ("failed code page store\n");
-       return 0;
-}
-
-static void
-add_code_pointer (uintptr_t ip)
-{
-       uintptr_t i;
-       if (num_code_pages * 2 >= size_code_pages) {
-               uintptr_t *n;
-               uintptr_t old_size = size_code_pages;
-               size_code_pages *= 2;
-               if (size_code_pages == 0)
-                       size_code_pages = 16;
-               n = (uintptr_t *) g_calloc (sizeof (uintptr_t) * size_code_pages, 1);
-               for (i = 0; i < old_size; ++i) {
-                       if (code_pages [i])
-                               add_code_page (n, size_code_pages, code_pages [i]);
-               }
-               if (code_pages)
-                       g_free (code_pages);
-               code_pages = n;
-       }
-       num_code_pages += add_code_page (code_pages, size_code_pages, ip & CPAGE_MASK);
-}
-
-/* ELF code crashes on some systems. */
-//#if defined(HAVE_DL_ITERATE_PHDR) && defined(ELFMAG0)
-#if 0
-static void
-dump_ubin (MonoProfiler *prof, const char *filename, uintptr_t load_addr, uint64_t offset, uintptr_t size)
-{
-       int len = strlen (filename) + 1;
-
-       ENTER_LOG (&sample_ubins_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* load address */ +
-               LEB128_SIZE /* offset */ +
-               LEB128_SIZE /* size */ +
-               nlen /* file name */
-       );
-
-       emit_event (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_UBIN);
-       emit_svalue (logbuffer, load_addr);
-       emit_uvalue (logbuffer, offset);
-       emit_uvalue (logbuffer, size);
-       memcpy (logbuffer->cursor, filename, len);
-       logbuffer->cursor += len;
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-#endif
-
-static void
-dump_usym (MonoProfiler *prof, const char *name, uintptr_t value, uintptr_t size)
-{
-       int len = strlen (name) + 1;
-
-       ENTER_LOG (&sample_usyms_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* value */ +
-               LEB128_SIZE /* size */ +
-               len /* name */
-       );
-
-       emit_event (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_USYM);
-       emit_ptr (logbuffer, (void*)value);
-       emit_value (logbuffer, size);
-       memcpy (logbuffer->cursor, name, len);
-       logbuffer->cursor += len;
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-/* ELF code crashes on some systems. */
-//#if defined(ELFMAG0)
-#if 0
-
-#if SIZEOF_VOID_P == 4
-#define ELF_WSIZE 32
-#else
-#define ELF_WSIZE 64
-#endif
-#ifndef ElfW
-#define ElfW(type)      _ElfW (Elf, ELF_WSIZE, type)
-#define _ElfW(e,w,t)    _ElfW_1 (e, w, _##t)
-#define _ElfW_1(e,w,t)  e##w##t
-#endif
-
-static void
-dump_elf_symbols (MonoProfiler *prof, ElfW(Sym) *symbols, int num_symbols, const char *strtab, void *load_addr)
-{
-       int i;
-       for (i = 0; i < num_symbols; ++i) {
-               const char* sym;
-               sym =  strtab + symbols [i].st_name;
-               if (!symbols [i].st_name || !symbols [i].st_size || (symbols [i].st_info & 0xf) != STT_FUNC)
-                       continue;
-               //printf ("symbol %s at %d\n", sym, symbols [i].st_value);
-               dump_usym (sym, (uintptr_t)load_addr + symbols [i].st_value, symbols [i].st_size);
-       }
-}
-
-static int
-read_elf_symbols (MonoProfiler *prof, const char *filename, void *load_addr)
-{
-       int fd, i;
-       void *data;
-       struct stat statb;
-       uint64_t file_size;
-       ElfW(Ehdr) *header;
-       ElfW(Shdr) *sheader;
-       ElfW(Shdr) *shstrtabh;
-       ElfW(Shdr) *symtabh = NULL;
-       ElfW(Shdr) *strtabh = NULL;
-       ElfW(Sym) *symbols = NULL;
-       const char *strtab;
-       int num_symbols;
-
-       fd = open (filename, O_RDONLY);
-       if (fd < 0)
-               return 0;
-       if (fstat (fd, &statb) != 0) {
-               close (fd);
-               return 0;
-       }
-       file_size = statb.st_size;
-       data = mmap (NULL, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
-       close (fd);
-       if (data == MAP_FAILED)
-               return 0;
-       header = data;
-       if (header->e_ident [EI_MAG0] != ELFMAG0 ||
-                       header->e_ident [EI_MAG1] != ELFMAG1 ||
-                       header->e_ident [EI_MAG2] != ELFMAG2 ||
-                       header->e_ident [EI_MAG3] != ELFMAG3 ) {
-               munmap (data, file_size);
-               return 0;
-       }
-       sheader = (void*)((char*)data + header->e_shoff);
-       shstrtabh = (void*)((char*)sheader + (header->e_shentsize * header->e_shstrndx));
-       strtab = (const char*)data + shstrtabh->sh_offset;
-       for (i = 0; i < header->e_shnum; ++i) {
-               //printf ("section header: %d\n", sheader->sh_type);
-               if (sheader->sh_type == SHT_SYMTAB) {
-                       symtabh = sheader;
-                       strtabh = (void*)((char*)data + header->e_shoff + sheader->sh_link * header->e_shentsize);
-                       /*printf ("symtab section header: %d, .strstr: %d\n", i, sheader->sh_link);*/
-                       break;
-               }
-               sheader = (void*)((char*)sheader + header->e_shentsize);
-       }
-       if (!symtabh || !strtabh) {
-               munmap (data, file_size);
-               return 0;
-       }
-       strtab = (const char*)data + strtabh->sh_offset;
-       num_symbols = symtabh->sh_size / symtabh->sh_entsize;
-       symbols = (void*)((char*)data + symtabh->sh_offset);
-       dump_elf_symbols (symbols, num_symbols, strtab, load_addr);
-       munmap (data, file_size);
-       return 1;
-}
-#endif
-
-/* ELF code crashes on some systems. */
-//#if defined(HAVE_DL_ITERATE_PHDR) && defined(ELFMAG0)
-#if 0
-static int
-elf_dl_callback (struct dl_phdr_info *info, size_t size, void *data)
-{
-       MonoProfiler *prof = data;
-       char buf [256];
-       const char *filename;
-       BinaryObject *obj;
-       char *a = (void*)info->dlpi_addr;
-       int i, num_sym;
-       ElfW(Dyn) *dyn = NULL;
-       ElfW(Sym) *symtab = NULL;
-       ElfW(Word) *hash_table = NULL;
-       ElfW(Ehdr) *header = NULL;
-       const char* strtab = NULL;
-       for (obj = prof->binary_objects; obj; obj = obj->next) {
-               if (obj->addr == a)
-                       return 0;
-       }
-       filename = info->dlpi_name;
-       if (!filename)
-               return 0;
-       if (!info->dlpi_addr && !filename [0]) {
-               int l = readlink ("/proc/self/exe", buf, sizeof (buf) - 1);
-               if (l > 0) {
-                       buf [l] = 0;
-                       filename = buf;
-               }
-       }
-       obj = g_calloc (sizeof (BinaryObject), 1);
-       obj->addr = (void*)info->dlpi_addr;
-       obj->name = pstrdup (filename);
-       obj->next = prof->binary_objects;
-       prof->binary_objects = obj;
-       //printf ("loaded file: %s at %p, segments: %d\n", filename, (void*)info->dlpi_addr, info->dlpi_phnum);
-       a = NULL;
-       for (i = 0; i < info->dlpi_phnum; ++i) {
-               //printf ("segment type %d file offset: %d, size: %d\n", info->dlpi_phdr[i].p_type, info->dlpi_phdr[i].p_offset, info->dlpi_phdr[i].p_memsz);
-               if (info->dlpi_phdr[i].p_type == PT_LOAD && !header) {
-                       header = (ElfW(Ehdr)*)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
-                       if (header->e_ident [EI_MAG0] != ELFMAG0 ||
-                                       header->e_ident [EI_MAG1] != ELFMAG1 ||
-                                       header->e_ident [EI_MAG2] != ELFMAG2 ||
-                                       header->e_ident [EI_MAG3] != ELFMAG3 ) {
-                               header = NULL;
-                       }
-                       dump_ubin (prof, filename, info->dlpi_addr + info->dlpi_phdr[i].p_vaddr, info->dlpi_phdr[i].p_offset, info->dlpi_phdr[i].p_memsz);
-               } else if (info->dlpi_phdr[i].p_type == PT_DYNAMIC) {
-                       dyn = (ElfW(Dyn) *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
-               }
-       }
-       if (read_elf_symbols (prof, filename, (void*)info->dlpi_addr))
-               return 0;
-       if (!info->dlpi_name || !info->dlpi_name[0])
-               return 0;
-       if (!dyn)
-               return 0;
-       for (i = 0; dyn [i].d_tag != DT_NULL; ++i) {
-               if (dyn [i].d_tag == DT_SYMTAB) {
-                       if (symtab && do_debug)
-                               printf ("multiple symtabs: %d\n", i);
-                       symtab = (ElfW(Sym) *)(a + dyn [i].d_un.d_ptr);
-               } else if (dyn [i].d_tag == DT_HASH) {
-                       hash_table = (ElfW(Word) *)(a + dyn [i].d_un.d_ptr);
-               } else if (dyn [i].d_tag == DT_STRTAB) {
-                       strtab = (const char*)(a + dyn [i].d_un.d_ptr);
-               }
-       }
-       if (!hash_table)
-               return 0;
-       num_sym = hash_table [1];
-       dump_elf_symbols (prof, symtab, num_sym, strtab, (void*)info->dlpi_addr);
-       return 0;
-}
-
-static int
-load_binaries (MonoProfiler *prof)
-{
-       dl_iterate_phdr (elf_dl_callback, prof);
-       return 1;
-}
-#else
-static int
-load_binaries (MonoProfiler *prof)
-{
-       return 0;
-}
-#endif
-
-static const char*
-symbol_for (uintptr_t code)
-{
-#ifdef HAVE_DLADDR
-       void *ip = (void*)code;
-       Dl_info di;
-       if (dladdr (ip, &di)) {
-               if (di.dli_sname)
-                       return di.dli_sname;
-       } else {
-       /*      char **names;
-               names = backtrace_symbols (&ip, 1);
-               if (names) {
-                       const char* p = names [0];
-                       g_free (names);
-                       return p;
-               }
-               */
-       }
-#endif
-       return NULL;
-}
-
-static void
-dump_unmanaged_coderefs (MonoProfiler *prof)
-{
-       int i;
-       const char* last_symbol;
-       uintptr_t addr, page_end;
-
-       if (load_binaries (prof))
-               return;
-       for (i = 0; i < size_code_pages; ++i) {
-               const char* sym;
-               if (!code_pages [i] || code_pages [i] & 1)
-                       continue;
-               last_symbol = NULL;
-               addr = CPAGE_ADDR (code_pages [i]);
-               page_end = addr + CPAGE_SIZE;
-               code_pages [i] |= 1;
-               /* we dump the symbols for the whole page */
-               for (; addr < page_end; addr += 16) {
-                       sym = symbol_for (addr);
-                       if (sym && sym == last_symbol)
-                               continue;
-                       last_symbol = sym;
-                       if (!sym)
-                               continue;
-                       dump_usym (prof, sym, addr, 0); /* let's not guess the size */
-                       //printf ("found symbol at %p: %s\n", (void*)addr, sym);
-               }
-       }
-}
-
-static int
-mono_cpu_count (void)
-{
-#ifdef PLATFORM_ANDROID
-       /* Android tries really hard to save power by powering off CPUs on SMP phones which
-        * means the normal way to query cpu count returns a wrong value with userspace API.
-        * Instead we use /sys entries to query the actual hardware CPU count.
-        */
-       int count = 0;
-       char buffer[8] = {'\0'};
-       int present = open ("/sys/devices/system/cpu/present", O_RDONLY);
-       /* Format of the /sys entry is a cpulist of indexes which in the case
-        * of present is always of the form "0-(n-1)" when there is more than
-        * 1 core, n being the number of CPU cores in the system. Otherwise
-        * the value is simply 0
-        */
-       if (present != -1 && read (present, (char*)buffer, sizeof (buffer)) > 3)
-               count = strtol (((char*)buffer) + 2, NULL, 10);
-       if (present != -1)
-               close (present);
-       if (count > 0)
-               return count + 1;
-#endif
-
-#if defined(HOST_ARM) || defined (HOST_ARM64)
-
-       /* ARM platforms tries really hard to save power by powering off CPUs on SMP phones which
-        * means the normal way to query cpu count returns a wrong value with userspace API. */
-
-#ifdef _SC_NPROCESSORS_CONF
-       {
-               int count = sysconf (_SC_NPROCESSORS_CONF);
-               if (count > 0)
-                       return count;
-       }
-#endif
-
-#else
-
-#ifdef HAVE_SCHED_GETAFFINITY
-       {
-               cpu_set_t set;
-               if (sched_getaffinity (getpid (), sizeof (set), &set) == 0)
-                       return CPU_COUNT (&set);
-       }
-#endif
-#ifdef _SC_NPROCESSORS_ONLN
-       {
-               int count = sysconf (_SC_NPROCESSORS_ONLN);
-               if (count > 0)
-                       return count;
-       }
-#endif
-
-#endif /* defined(HOST_ARM) || defined (HOST_ARM64) */
-
-#ifdef USE_SYSCTL
-       {
-               int count;
-               int mib [2];
-               size_t len = sizeof (int);
-               mib [0] = CTL_HW;
-               mib [1] = HW_NCPU;
-               if (sysctl (mib, 2, &count, &len, NULL, 0) == 0)
-                       return count;
-       }
-#endif
-#ifdef HOST_WIN32
-       {
-               SYSTEM_INFO info;
-               GetSystemInfo (&info);
-               return info.dwNumberOfProcessors;
-       }
-#endif
-
-       static gboolean warned;
-
-       if (!warned) {
-               g_warning ("Don't know how to determine CPU count on this platform; assuming 1");
-               warned = TRUE;
-       }
-
-       return 1;
-}
-
-typedef struct MonoCounterAgent {
-       MonoCounter *counter;
-       // MonoCounterAgent specific data :
-       void *value;
-       size_t value_size;
-       short index;
-       short emitted;
-       struct MonoCounterAgent *next;
-} MonoCounterAgent;
-
-static MonoCounterAgent* counters;
-static int counters_index = 1;
-static mono_mutex_t counters_mutex;
-
-static void
-counters_add_agent (MonoCounter *counter)
-{
-       if (InterlockedRead (&in_shutdown))
-               return;
-
-       MonoCounterAgent *agent, *item;
-
-       mono_os_mutex_lock (&counters_mutex);
-
-       for (agent = counters; agent; agent = agent->next) {
-               if (agent->counter == counter) {
-                       agent->value_size = 0;
-                       if (agent->value) {
-                               g_free (agent->value);
-                               agent->value = NULL;
-                       }
-                       goto done;
-               }
-       }
-
-       agent = (MonoCounterAgent *) g_malloc (sizeof (MonoCounterAgent));
-       agent->counter = counter;
-       agent->value = NULL;
-       agent->value_size = 0;
-       agent->index = counters_index++;
-       agent->emitted = 0;
-       agent->next = NULL;
-
-       if (!counters) {
-               counters = agent;
-       } else {
-               item = counters;
-               while (item->next)
-                       item = item->next;
-               item->next = agent;
-       }
-
-done:
-       mono_os_mutex_unlock (&counters_mutex);
-}
-
-static mono_bool
-counters_init_foreach_callback (MonoCounter *counter, gpointer data)
-{
-       counters_add_agent (counter);
-       return TRUE;
-}
-
-static void
-counters_init (MonoProfiler *profiler)
-{
-       mono_os_mutex_init (&counters_mutex);
-
-       mono_counters_on_register (&counters_add_agent);
-       mono_counters_foreach (counters_init_foreach_callback, NULL);
-}
-
-static void
-counters_emit (MonoProfiler *profiler)
-{
-       MonoCounterAgent *agent;
-       int len = 0;
-       int size =
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* len */
-       ;
-
-       mono_os_mutex_lock (&counters_mutex);
-
-       for (agent = counters; agent; agent = agent->next) {
-               if (agent->emitted)
-                       continue;
-
-               size +=
-                       LEB128_SIZE /* section */ +
-                       strlen (mono_counter_get_name (agent->counter)) + 1 /* name */ +
-                       BYTE_SIZE /* type */ +
-                       BYTE_SIZE /* unit */ +
-                       BYTE_SIZE /* variance */ +
-                       LEB128_SIZE /* index */
-               ;
-
-               len++;
-       }
-
-       if (!len)
-               goto done;
-
-       ENTER_LOG (&counter_descriptors_ctr, logbuffer, size);
-
-       emit_event (logbuffer, TYPE_SAMPLE_COUNTERS_DESC | TYPE_SAMPLE);
-       emit_value (logbuffer, len);
-
-       for (agent = counters; agent; agent = agent->next) {
-               const char *name;
-
-               if (agent->emitted)
-                       continue;
-
-               name = mono_counter_get_name (agent->counter);
-               emit_value (logbuffer, mono_counter_get_section (agent->counter));
-               emit_string (logbuffer, name, strlen (name) + 1);
-               emit_byte (logbuffer, mono_counter_get_type (agent->counter));
-               emit_byte (logbuffer, mono_counter_get_unit (agent->counter));
-               emit_byte (logbuffer, mono_counter_get_variance (agent->counter));
-               emit_value (logbuffer, agent->index);
-
-               agent->emitted = 1;
-       }
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-done:
-       mono_os_mutex_unlock (&counters_mutex);
-}
-
-static void
-counters_sample (MonoProfiler *profiler, uint64_t timestamp)
-{
-       MonoCounterAgent *agent;
-       MonoCounter *counter;
-       int type;
-       int buffer_size;
-       void *buffer;
-       int size;
-
-       counters_emit (profiler);
-
-       buffer_size = 8;
-       buffer = g_calloc (1, buffer_size);
-
-       mono_os_mutex_lock (&counters_mutex);
-
-       size =
-               EVENT_SIZE /* event */
-       ;
-
-       for (agent = counters; agent; agent = agent->next) {
-               size +=
-                       LEB128_SIZE /* index */ +
-                       BYTE_SIZE /* type */ +
-                       mono_counter_get_size (agent->counter) /* value */
-               ;
-       }
-
-       size +=
-               LEB128_SIZE /* stop marker */
-       ;
-
-       ENTER_LOG (&counter_samples_ctr, logbuffer, size);
-
-       emit_event_time (logbuffer, TYPE_SAMPLE_COUNTERS | TYPE_SAMPLE, timestamp);
-
-       for (agent = counters; agent; agent = agent->next) {
-               size_t size;
-
-               counter = agent->counter;
-
-               size = mono_counter_get_size (counter);
-
-               if (size > buffer_size) {
-                       buffer_size = size;
-                       buffer = g_realloc (buffer, buffer_size);
-               }
-
-               memset (buffer, 0, buffer_size);
-
-               g_assert (mono_counters_sample (counter, buffer, size));
-
-               type = mono_counter_get_type (counter);
-
-               if (!agent->value) {
-                       agent->value = g_calloc (1, size);
-                       agent->value_size = size;
-               } else {
-                       if (type == MONO_COUNTER_STRING) {
-                               if (strcmp (agent->value, buffer) == 0)
-                                       continue;
-                       } else {
-                               if (agent->value_size == size && memcmp (agent->value, buffer, size) == 0)
-                                       continue;
-                       }
-               }
-
-               emit_uvalue (logbuffer, agent->index);
-               emit_byte (logbuffer, type);
-               switch (type) {
-               case MONO_COUNTER_INT:
-#if SIZEOF_VOID_P == 4
-               case MONO_COUNTER_WORD:
-#endif
-                       emit_svalue (logbuffer, *(int*)buffer - *(int*)agent->value);
-                       break;
-               case MONO_COUNTER_UINT:
-                       emit_uvalue (logbuffer, *(guint*)buffer - *(guint*)agent->value);
-                       break;
-               case MONO_COUNTER_TIME_INTERVAL:
-               case MONO_COUNTER_LONG:
-#if SIZEOF_VOID_P == 8
-               case MONO_COUNTER_WORD:
-#endif
-                       emit_svalue (logbuffer, *(gint64*)buffer - *(gint64*)agent->value);
-                       break;
-               case MONO_COUNTER_ULONG:
-                       emit_uvalue (logbuffer, *(guint64*)buffer - *(guint64*)agent->value);
-                       break;
-               case MONO_COUNTER_DOUBLE:
-                       emit_double (logbuffer, *(double*)buffer);
-                       break;
-               case MONO_COUNTER_STRING:
-                       if (size == 0) {
-                               emit_byte (logbuffer, 0);
-                       } else {
-                               emit_byte (logbuffer, 1);
-                               emit_string (logbuffer, (char*)buffer, size);
-                       }
-                       break;
-               default:
-                       g_assert_not_reached ();
-               }
-
-               if (type == MONO_COUNTER_STRING && size > agent->value_size) {
-                       agent->value = g_realloc (agent->value, size);
-                       agent->value_size = size;
-               }
-
-               if (size > 0)
-                       memcpy (agent->value, buffer, size);
-       }
-       g_free (buffer);
-
-       emit_value (logbuffer, 0);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-       mono_os_mutex_unlock (&counters_mutex);
-}
-
-typedef struct _PerfCounterAgent PerfCounterAgent;
-struct _PerfCounterAgent {
-       PerfCounterAgent *next;
-       int index;
-       char *category_name;
-       char *name;
-       int type;
-       gint64 value;
-       guint8 emitted;
-       guint8 updated;
-       guint8 deleted;
-};
-
-static PerfCounterAgent *perfcounters = NULL;
-
-static void
-perfcounters_emit (MonoProfiler *profiler)
-{
-       PerfCounterAgent *pcagent;
-       int len = 0;
-       int size =
-               EVENT_SIZE /* event */ +
-               LEB128_SIZE /* len */
-       ;
-
-       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
-               if (pcagent->emitted)
-                       continue;
-
-               size +=
-                       LEB128_SIZE /* section */ +
-                       strlen (pcagent->category_name) + 1 /* category name */ +
-                       strlen (pcagent->name) + 1 /* name */ +
-                       BYTE_SIZE /* type */ +
-                       BYTE_SIZE /* unit */ +
-                       BYTE_SIZE /* variance */ +
-                       LEB128_SIZE /* index */
-               ;
-
-               len++;
-       }
-
-       if (!len)
-               return;
-
-       ENTER_LOG (&perfcounter_descriptors_ctr, logbuffer, size);
-
-       emit_event (logbuffer, TYPE_SAMPLE_COUNTERS_DESC | TYPE_SAMPLE);
-       emit_value (logbuffer, len);
-
-       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
-               if (pcagent->emitted)
-                       continue;
-
-               emit_value (logbuffer, MONO_COUNTER_PERFCOUNTERS);
-               emit_string (logbuffer, pcagent->category_name, strlen (pcagent->category_name) + 1);
-               emit_string (logbuffer, pcagent->name, strlen (pcagent->name) + 1);
-               emit_byte (logbuffer, MONO_COUNTER_LONG);
-               emit_byte (logbuffer, MONO_COUNTER_RAW);
-               emit_byte (logbuffer, MONO_COUNTER_VARIABLE);
-               emit_value (logbuffer, pcagent->index);
-
-               pcagent->emitted = 1;
-       }
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-static gboolean
-perfcounters_foreach (char *category_name, char *name, unsigned char type, gint64 value, gpointer user_data)
-{
-       PerfCounterAgent *pcagent;
-
-       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
-               if (strcmp (pcagent->category_name, category_name) != 0 || strcmp (pcagent->name, name) != 0)
-                       continue;
-               if (pcagent->value == value)
-                       return TRUE;
-
-               pcagent->value = value;
-               pcagent->updated = 1;
-               pcagent->deleted = 0;
-               return TRUE;
-       }
-
-       pcagent = g_new0 (PerfCounterAgent, 1);
-       pcagent->next = perfcounters;
-       pcagent->index = counters_index++;
-       pcagent->category_name = g_strdup (category_name);
-       pcagent->name = g_strdup (name);
-       pcagent->type = (int) type;
-       pcagent->value = value;
-       pcagent->emitted = 0;
-       pcagent->updated = 1;
-       pcagent->deleted = 0;
-
-       perfcounters = pcagent;
-
-       return TRUE;
-}
-
-static void
-perfcounters_sample (MonoProfiler *profiler, uint64_t timestamp)
-{
-       PerfCounterAgent *pcagent;
-       int len = 0;
-       int size;
-
-       mono_os_mutex_lock (&counters_mutex);
-
-       /* mark all perfcounters as deleted, foreach will unmark them as necessary */
-       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next)
-               pcagent->deleted = 1;
-
-       mono_perfcounter_foreach (perfcounters_foreach, perfcounters);
-
-       perfcounters_emit (profiler);
-
-       size =
-               EVENT_SIZE /* event */
-       ;
-
-       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
-               if (pcagent->deleted || !pcagent->updated)
-                       continue;
-
-               size +=
-                       LEB128_SIZE /* index */ +
-                       BYTE_SIZE /* type */ +
-                       LEB128_SIZE /* value */
-               ;
-
-               len++;
-       }
-
-       if (!len)
-               goto done;
-
-       size +=
-               LEB128_SIZE /* stop marker */
-       ;
-
-       ENTER_LOG (&perfcounter_samples_ctr, logbuffer, size);
-
-       emit_event_time (logbuffer, TYPE_SAMPLE_COUNTERS | TYPE_SAMPLE, timestamp);
-
-       for (pcagent = perfcounters; pcagent; pcagent = pcagent->next) {
-               if (pcagent->deleted || !pcagent->updated)
-                       continue;
-               emit_uvalue (logbuffer, pcagent->index);
-               emit_byte (logbuffer, MONO_COUNTER_LONG);
-               emit_svalue (logbuffer, pcagent->value);
-
-               pcagent->updated = 0;
-       }
-
-       emit_value (logbuffer, 0);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-done:
-       mono_os_mutex_unlock (&counters_mutex);
-}
-
-static void
-counters_and_perfcounters_sample (MonoProfiler *prof)
-{
-       uint64_t now = current_time ();
-
-       counters_sample (prof, now);
-       perfcounters_sample (prof, now);
-}
-
-#define COVERAGE_DEBUG(x) if (debug_coverage) {x}
-static mono_mutex_t coverage_mutex;
-static MonoConcurrentHashTable *coverage_methods = NULL;
-static MonoConcurrentHashTable *coverage_assemblies = NULL;
-static MonoConcurrentHashTable *coverage_classes = NULL;
-
-static MonoConcurrentHashTable *filtered_classes = NULL;
-static MonoConcurrentHashTable *entered_methods = NULL;
-static MonoConcurrentHashTable *image_to_methods = NULL;
-static MonoConcurrentHashTable *suppressed_assemblies = NULL;
-static gboolean coverage_initialized = FALSE;
-
-static GPtrArray *coverage_data = NULL;
-static int previous_offset = 0;
-
-typedef struct {
-       MonoLockFreeQueueNode node;
-       MonoMethod *method;
-} MethodNode;
-
-typedef struct {
-       int offset;
-       int counter;
-       char *filename;
-       int line;
-       int column;
-} CoverageEntry;
-
-static void
-free_coverage_entry (gpointer data, gpointer userdata)
-{
-       CoverageEntry *entry = (CoverageEntry *)data;
-       g_free (entry->filename);
-       g_free (entry);
-}
-
-static void
-obtain_coverage_for_method (MonoProfiler *prof, const MonoProfileCoverageEntry *entry)
-{
-       int offset = entry->iloffset - previous_offset;
-       CoverageEntry *e = g_new (CoverageEntry, 1);
-
-       previous_offset = entry->iloffset;
-
-       e->offset = offset;
-       e->counter = entry->counter;
-       e->filename = g_strdup(entry->filename ? entry->filename : "");
-       e->line = entry->line;
-       e->column = entry->col;
-
-       g_ptr_array_add (coverage_data, e);
-}
-
-static char *
-parse_generic_type_names(char *name)
-{
-       char *new_name, *ret;
-       int within_generic_declaration = 0, generic_members = 1;
-
-       if (name == NULL || *name == '\0')
-               return g_strdup ("");
-
-       if (!(ret = new_name = (char *) g_calloc (strlen (name) * 4 + 1, sizeof (char))))
-               return NULL;
-
-       do {
-               switch (*name) {
-                       case '<':
-                               within_generic_declaration = 1;
-                               break;
-
-                       case '>':
-                               within_generic_declaration = 0;
-
-                               if (*(name - 1) != '<') {
-                                       *new_name++ = '`';
-                                       *new_name++ = '0' + generic_members;
-                               } else {
-                                       memcpy (new_name, "&lt;&gt;", 8);
-                                       new_name += 8;
-                               }
-
-                               generic_members = 0;
-                               break;
-
-                       case ',':
-                               generic_members++;
-                               break;
-
-                       default:
-                               if (!within_generic_declaration)
-                                       *new_name++ = *name;
-
-                               break;
-               }
-       } while (*name++);
-
-       return ret;
-}
-
-static int method_id;
-static void
-build_method_buffer (gpointer key, gpointer value, gpointer userdata)
-{
-       MonoMethod *method = (MonoMethod *)value;
-       MonoProfiler *prof = (MonoProfiler *)userdata;
-       MonoClass *klass;
-       MonoImage *image;
-       char *class_name;
-       const char *image_name, *method_name, *sig, *first_filename;
-       guint i;
-
-       previous_offset = 0;
-       coverage_data = g_ptr_array_new ();
-
-       mono_profiler_coverage_get (prof, method, obtain_coverage_for_method);
-
-       klass = mono_method_get_class (method);
-       image = mono_class_get_image (klass);
-       image_name = mono_image_get_name (image);
-
-       sig = mono_signature_get_desc (mono_method_signature (method), TRUE);
-       class_name = parse_generic_type_names (mono_type_get_name (mono_class_get_type (klass)));
-       method_name = mono_method_get_name (method);
-
-       if (coverage_data->len != 0) {
-               CoverageEntry *entry = (CoverageEntry *)coverage_data->pdata[0];
-               first_filename = entry->filename ? entry->filename : "";
-       } else
-               first_filename = "";
-
-       image_name = image_name ? image_name : "";
-       sig = sig ? sig : "";
-       method_name = method_name ? method_name : "";
-
-       ENTER_LOG (&coverage_methods_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               strlen (image_name) + 1 /* image name */ +
-               strlen (class_name) + 1 /* class name */ +
-               strlen (method_name) + 1 /* method name */ +
-               strlen (sig) + 1 /* signature */ +
-               strlen (first_filename) + 1 /* first file name */ +
-               LEB128_SIZE /* token */ +
-               LEB128_SIZE /* method id */ +
-               LEB128_SIZE /* entries */
-       );
-
-       emit_event (logbuffer, TYPE_COVERAGE_METHOD | TYPE_COVERAGE);
-       emit_string (logbuffer, image_name, strlen (image_name) + 1);
-       emit_string (logbuffer, class_name, strlen (class_name) + 1);
-       emit_string (logbuffer, method_name, strlen (method_name) + 1);
-       emit_string (logbuffer, sig, strlen (sig) + 1);
-       emit_string (logbuffer, first_filename, strlen (first_filename) + 1);
-
-       emit_uvalue (logbuffer, mono_method_get_token (method));
-       emit_uvalue (logbuffer, method_id);
-       emit_value (logbuffer, coverage_data->len);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-       for (i = 0; i < coverage_data->len; i++) {
-               CoverageEntry *entry = (CoverageEntry *)coverage_data->pdata[i];
-
-               ENTER_LOG (&coverage_statements_ctr, logbuffer,
-                       EVENT_SIZE /* event */ +
-                       LEB128_SIZE /* method id */ +
-                       LEB128_SIZE /* offset */ +
-                       LEB128_SIZE /* counter */ +
-                       LEB128_SIZE /* line */ +
-                       LEB128_SIZE /* column */
-               );
-
-               emit_event (logbuffer, TYPE_COVERAGE_STATEMENT | TYPE_COVERAGE);
-               emit_uvalue (logbuffer, method_id);
-               emit_uvalue (logbuffer, entry->offset);
-               emit_uvalue (logbuffer, entry->counter);
-               emit_uvalue (logbuffer, entry->line);
-               emit_uvalue (logbuffer, entry->column);
-
-               EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-       }
-
-       method_id++;
-
-       g_free (class_name);
-
-       g_ptr_array_foreach (coverage_data, free_coverage_entry, NULL);
-       g_ptr_array_free (coverage_data, TRUE);
-       coverage_data = NULL;
-}
-
-/* This empties the queue */
-static guint
-count_queue (MonoLockFreeQueue *queue)
-{
-       MonoLockFreeQueueNode *node;
-       guint count = 0;
-
-       while ((node = mono_lock_free_queue_dequeue (queue))) {
-               count++;
-               mono_thread_hazardous_try_free (node, g_free);
-       }
-
-       return count;
-}
-
-static void
-build_class_buffer (gpointer key, gpointer value, gpointer userdata)
-{
-       MonoClass *klass = (MonoClass *)key;
-       MonoLockFreeQueue *class_methods = (MonoLockFreeQueue *)value;
-       MonoImage *image;
-       char *class_name;
-       const char *assembly_name;
-       int number_of_methods, partially_covered;
-       guint fully_covered;
-
-       image = mono_class_get_image (klass);
-       assembly_name = mono_image_get_name (image);
-       class_name = mono_type_get_name (mono_class_get_type (klass));
-
-       assembly_name = assembly_name ? assembly_name : "";
-       number_of_methods = mono_class_num_methods (klass);
-       fully_covered = count_queue (class_methods);
-       /* We don't handle partial covered yet */
-       partially_covered = 0;
-
-       ENTER_LOG (&coverage_classes_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               strlen (assembly_name) + 1 /* assembly name */ +
-               strlen (class_name) + 1 /* class name */ +
-               LEB128_SIZE /* no. methods */ +
-               LEB128_SIZE /* fully covered */ +
-               LEB128_SIZE /* partially covered */
-       );
-
-       emit_event (logbuffer, TYPE_COVERAGE_CLASS | TYPE_COVERAGE);
-       emit_string (logbuffer, assembly_name, strlen (assembly_name) + 1);
-       emit_string (logbuffer, class_name, strlen (class_name) + 1);
-       emit_uvalue (logbuffer, number_of_methods);
-       emit_uvalue (logbuffer, fully_covered);
-       emit_uvalue (logbuffer, partially_covered);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-       g_free (class_name);
-}
-
-static void
-get_coverage_for_image (MonoImage *image, int *number_of_methods, guint *fully_covered, int *partially_covered)
-{
-       MonoLockFreeQueue *image_methods = (MonoLockFreeQueue *)mono_conc_hashtable_lookup (image_to_methods, image);
-
-       *number_of_methods = mono_image_get_table_rows (image, MONO_TABLE_METHOD);
-       if (image_methods)
-               *fully_covered = count_queue (image_methods);
-       else
-               *fully_covered = 0;
-
-       // FIXME: We don't handle partially covered yet.
-       *partially_covered = 0;
-}
-
-static void
-build_assembly_buffer (gpointer key, gpointer value, gpointer userdata)
-{
-       MonoAssembly *assembly = (MonoAssembly *)value;
-       MonoImage *image = mono_assembly_get_image (assembly);
-       const char *name, *guid, *filename;
-       int number_of_methods = 0, partially_covered = 0;
-       guint fully_covered = 0;
-
-       name = mono_image_get_name (image);
-       guid = mono_image_get_guid (image);
-       filename = mono_image_get_filename (image);
-
-       name = name ? name : "";
-       guid = guid ? guid : "";
-       filename = filename ? filename : "";
-
-       get_coverage_for_image (image, &number_of_methods, &fully_covered, &partially_covered);
-
-       ENTER_LOG (&coverage_assemblies_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               strlen (name) + 1 /* name */ +
-               strlen (guid) + 1 /* guid */ +
-               strlen (filename) + 1 /* file name */ +
-               LEB128_SIZE /* no. methods */ +
-               LEB128_SIZE /* fully covered */ +
-               LEB128_SIZE /* partially covered */
-       );
-
-       emit_event (logbuffer, TYPE_COVERAGE_ASSEMBLY | TYPE_COVERAGE);
-       emit_string (logbuffer, name, strlen (name) + 1);
-       emit_string (logbuffer, guid, strlen (guid) + 1);
-       emit_string (logbuffer, filename, strlen (filename) + 1);
-       emit_uvalue (logbuffer, number_of_methods);
-       emit_uvalue (logbuffer, fully_covered);
-       emit_uvalue (logbuffer, partially_covered);
-
-       EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-}
-
-static void
-dump_coverage (MonoProfiler *prof)
-{
-       if (!coverage_initialized)
-               return;
-
-       COVERAGE_DEBUG(fprintf (stderr, "Coverage: Started dump\n");)
-       method_id = 0;
-
-       mono_os_mutex_lock (&coverage_mutex);
-       mono_conc_hashtable_foreach (coverage_assemblies, build_assembly_buffer, NULL);
-       mono_conc_hashtable_foreach (coverage_classes, build_class_buffer, NULL);
-       mono_conc_hashtable_foreach (coverage_methods, build_method_buffer, prof);
-       mono_os_mutex_unlock (&coverage_mutex);
-
-       COVERAGE_DEBUG(fprintf (stderr, "Coverage: Finished dump\n");)
-}
-
-static void
-process_method_enter_coverage (MonoProfiler *prof, MonoMethod *method)
-{
-       MonoClass *klass;
-       MonoImage *image;
-
-       if (!coverage_initialized)
-               return;
-
-       klass = mono_method_get_class (method);
-       image = mono_class_get_image (klass);
-
-       if (mono_conc_hashtable_lookup (suppressed_assemblies, (gpointer) mono_image_get_name (image)))
-               return;
-
-       mono_os_mutex_lock (&coverage_mutex);
-       mono_conc_hashtable_insert (entered_methods, method, method);
-       mono_os_mutex_unlock (&coverage_mutex);
-}
-
-static MonoLockFreeQueueNode *
-create_method_node (MonoMethod *method)
-{
-       MethodNode *node = (MethodNode *) g_malloc (sizeof (MethodNode));
-       mono_lock_free_queue_node_init ((MonoLockFreeQueueNode *) node, FALSE);
-       node->method = method;
-
-       return (MonoLockFreeQueueNode *) node;
-}
-
-static gboolean
-coverage_filter (MonoProfiler *prof, MonoMethod *method)
-{
-       MonoError error;
-       MonoClass *klass;
-       MonoImage *image;
-       MonoAssembly *assembly;
-       MonoMethodHeader *header;
-       guint32 iflags, flags, code_size;
-       char *fqn, *classname;
-       gboolean has_positive, found;
-       MonoLockFreeQueue *image_methods, *class_methods;
-       MonoLockFreeQueueNode *node;
-
-       g_assert (coverage_initialized && "Why are we being asked for coverage filter info when we're not doing coverage?");
-
-       COVERAGE_DEBUG(fprintf (stderr, "Coverage filter for %s\n", mono_method_get_name (method));)
-
-       flags = mono_method_get_flags (method, &iflags);
-       if ((iflags & 0x1000 /*METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL*/) ||
-           (flags & 0x2000 /*METHOD_ATTRIBUTE_PINVOKE_IMPL*/)) {
-               COVERAGE_DEBUG(fprintf (stderr, "   Internal call or pinvoke - ignoring\n");)
-               return FALSE;
-       }
-
-       // Don't need to do anything else if we're already tracking this method
-       if (mono_conc_hashtable_lookup (coverage_methods, method)) {
-               COVERAGE_DEBUG(fprintf (stderr, "   Already tracking\n");)
-               return TRUE;
-       }
-
-       klass = mono_method_get_class (method);
-       image = mono_class_get_image (klass);
-
-       // Don't handle coverage for the core assemblies
-       if (mono_conc_hashtable_lookup (suppressed_assemblies, (gpointer) mono_image_get_name (image)) != NULL)
-               return FALSE;
-
-       if (prof->coverage_filters) {
-               /* Check already filtered classes first */
-               if (mono_conc_hashtable_lookup (filtered_classes, klass)) {
-                       COVERAGE_DEBUG(fprintf (stderr, "   Already filtered\n");)
-                       return FALSE;
-               }
-
-               classname = mono_type_get_name (mono_class_get_type (klass));
-
-               fqn = g_strdup_printf ("[%s]%s", mono_image_get_name (image), classname);
-
-               COVERAGE_DEBUG(fprintf (stderr, "   Looking for %s in filter\n", fqn);)
-               // Check positive filters first
-               has_positive = FALSE;
-               found = FALSE;
-               for (guint i = 0; i < prof->coverage_filters->len; ++i) {
-                       char *filter = (char *)g_ptr_array_index (prof->coverage_filters, i);
-
-                       if (filter [0] == '+') {
-                               filter = &filter [1];
-
-                               COVERAGE_DEBUG(fprintf (stderr, "   Checking against +%s ...", filter);)
-
-                               if (strstr (fqn, filter) != NULL) {
-                                       COVERAGE_DEBUG(fprintf (stderr, "matched\n");)
-                                       found = TRUE;
-                               } else
-                                       COVERAGE_DEBUG(fprintf (stderr, "no match\n");)
-
-                               has_positive = TRUE;
-                       }
-               }
-
-               if (has_positive && !found) {
-                       COVERAGE_DEBUG(fprintf (stderr, "   Positive match was not found\n");)
-
-                       mono_os_mutex_lock (&coverage_mutex);
-                       mono_conc_hashtable_insert (filtered_classes, klass, klass);
-                       mono_os_mutex_unlock (&coverage_mutex);
-                       g_free (fqn);
-                       g_free (classname);
-
-                       return FALSE;
-               }
-
-               for (guint i = 0; i < prof->coverage_filters->len; ++i) {
-                       // FIXME: Is substring search sufficient?
-                       char *filter = (char *)g_ptr_array_index (prof->coverage_filters, i);
-                       if (filter [0] == '+')
-                               continue;
-
-                       // Skip '-'
-                       filter = &filter [1];
-                       COVERAGE_DEBUG(fprintf (stderr, "   Checking against -%s ...", filter);)
-
-                       if (strstr (fqn, filter) != NULL) {
-                               COVERAGE_DEBUG(fprintf (stderr, "matched\n");)
-
-                               mono_os_mutex_lock (&coverage_mutex);
-                               mono_conc_hashtable_insert (filtered_classes, klass, klass);
-                               mono_os_mutex_unlock (&coverage_mutex);
-                               g_free (fqn);
-                               g_free (classname);
-
-                               return FALSE;
-                       } else
-                               COVERAGE_DEBUG(fprintf (stderr, "no match\n");)
-
-               }
-
-               g_free (fqn);
-               g_free (classname);
-       }
-
-       COVERAGE_DEBUG(fprintf (stderr, "   Handling coverage for %s\n", mono_method_get_name (method));)
-       header = mono_method_get_header_checked (method, &error);
-       mono_error_cleanup (&error);
-
-       mono_method_header_get_code (header, &code_size, NULL);
-
-       assembly = mono_image_get_assembly (image);
-
-       // Need to keep the assemblies around for as long as they are kept in the hashtable
-       // Nunit, for example, has a habit of unloading them before the coverage statistics are
-       // generated causing a crash. See https://bugzilla.xamarin.com/show_bug.cgi?id=39325
-       mono_assembly_addref (assembly);
-
-       mono_os_mutex_lock (&coverage_mutex);
-       mono_conc_hashtable_insert (coverage_methods, method, method);
-       mono_conc_hashtable_insert (coverage_assemblies, assembly, assembly);
-       mono_os_mutex_unlock (&coverage_mutex);
-
-       image_methods = (MonoLockFreeQueue *)mono_conc_hashtable_lookup (image_to_methods, image);
-
-       if (image_methods == NULL) {
-               image_methods = (MonoLockFreeQueue *) g_malloc (sizeof (MonoLockFreeQueue));
-               mono_lock_free_queue_init (image_methods);
-               mono_os_mutex_lock (&coverage_mutex);
-               mono_conc_hashtable_insert (image_to_methods, image, image_methods);
-               mono_os_mutex_unlock (&coverage_mutex);
-       }
-
-       node = create_method_node (method);
-       mono_lock_free_queue_enqueue (image_methods, node);
-
-       class_methods = (MonoLockFreeQueue *)mono_conc_hashtable_lookup (coverage_classes, klass);
-
-       if (class_methods == NULL) {
-               class_methods = (MonoLockFreeQueue *) g_malloc (sizeof (MonoLockFreeQueue));
-               mono_lock_free_queue_init (class_methods);
-               mono_os_mutex_lock (&coverage_mutex);
-               mono_conc_hashtable_insert (coverage_classes, klass, class_methods);
-               mono_os_mutex_unlock (&coverage_mutex);
-       }
-
-       node = create_method_node (method);
-       mono_lock_free_queue_enqueue (class_methods, node);
-
-       return TRUE;
-}
-
-#define LINE_BUFFER_SIZE 4096
-/* Max file limit of 128KB */
-#define MAX_FILE_SIZE 128 * 1024
-static char *
-get_file_content (FILE *stream)
-{
-       char *buffer;
-       ssize_t bytes_read;
-       long filesize;
-       int res, offset = 0;
-
-       res = fseek (stream, 0, SEEK_END);
-       if (res < 0)
-         return NULL;
-
-       filesize = ftell (stream);
-       if (filesize < 0)
-         return NULL;
-
-       res = fseek (stream, 0, SEEK_SET);
-       if (res < 0)
-         return NULL;
-
-       if (filesize > MAX_FILE_SIZE)
-         return NULL;
-
-       buffer = (char *) g_malloc ((filesize + 1) * sizeof (char));
-       while ((bytes_read = fread (buffer + offset, 1, LINE_BUFFER_SIZE, stream)) > 0)
-               offset += bytes_read;
-
-       /* NULL terminate our buffer */
-       buffer[filesize] = '\0';
-       return buffer;
-}
-
-static char *
-get_next_line (char *contents, char **next_start)
-{
-       char *p = contents;
-
-       if (p == NULL || *p == '\0') {
-               *next_start = NULL;
-               return NULL;
-       }
-
-       while (*p != '\n' && *p != '\0')
-               p++;
-
-       if (*p == '\n') {
-               *p = '\0';
-               *next_start = p + 1;
-       } else
-               *next_start = NULL;
-
-       return contents;
-}
-
-static void
-init_suppressed_assemblies (void)
-{
-       char *content;
-       char *line;
-       FILE *sa_file;
-
-       suppressed_assemblies = mono_conc_hashtable_new (g_str_hash, g_str_equal);
-       sa_file = fopen (SUPPRESSION_DIR "/mono-profiler-log.suppression", "r");
-       if (sa_file == NULL)
-               return;
-
-       /* Don't need to free @content as it is referred to by the lines stored in @suppressed_assemblies */
-       content = get_file_content (sa_file);
-       if (content == NULL) {
-               g_error ("mono-profiler-log.suppression is greater than 128kb - aborting\n");
-       }
-
-       while ((line = get_next_line (content, &content))) {
-               line = g_strchomp (g_strchug (line));
-               /* No locking needed as we're doing initialization */
-               mono_conc_hashtable_insert (suppressed_assemblies, line, line);
-       }
-
-       fclose (sa_file);
-}
-
-static void
-coverage_init (MonoProfiler *prof)
-{
-       g_assert (!coverage_initialized && "Why are we initializing coverage twice?");
-
-       COVERAGE_DEBUG(fprintf (stderr, "Coverage initialized\n");)
-
-       mono_os_mutex_init (&coverage_mutex);
-       coverage_methods = mono_conc_hashtable_new (NULL, NULL);
-       coverage_assemblies = mono_conc_hashtable_new (NULL, NULL);
-       coverage_classes = mono_conc_hashtable_new (NULL, NULL);
-       filtered_classes = mono_conc_hashtable_new (NULL, NULL);
-       entered_methods = mono_conc_hashtable_new (NULL, NULL);
-       image_to_methods = mono_conc_hashtable_new (NULL, NULL);
-       init_suppressed_assemblies ();
-
-       coverage_initialized = TRUE;
-}
-
-static void
-unref_coverage_assemblies (gpointer key, gpointer value, gpointer userdata)
-{
-       MonoAssembly *assembly = (MonoAssembly *)value;
-       mono_assembly_close (assembly);
-}
-
-static void
-free_sample_hit (gpointer p)
-{
-       mono_lock_free_free (p, SAMPLE_BLOCK_SIZE);
-}
-
-static void
-cleanup_reusable_samples (MonoProfiler *prof)
-{
-       SampleHit *sample;
-
-       while ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->sample_reuse_queue)))
-               mono_thread_hazardous_try_free (sample, free_sample_hit);
-}
-
-static void
-log_shutdown (MonoProfiler *prof)
-{
-       InterlockedWrite (&in_shutdown, 1);
-
-       if (!no_counters)
-               counters_and_perfcounters_sample (prof);
-
-       dump_coverage (prof);
-
-       char c = 1;
-
-       if (write (prof->pipes [1], &c, 1) != 1) {
-               fprintf (stderr, "Could not write to pipe: %s\n", strerror (errno));
-               exit (1);
-       }
-
-       mono_native_thread_join (prof->helper_thread);
-
-       mono_os_mutex_destroy (&counters_mutex);
-
-       MonoCounterAgent *mc_next;
-
-       for (MonoCounterAgent *cur = counters; cur; cur = mc_next) {
-               mc_next = cur->next;
-               g_free (cur);
-       }
-
-       PerfCounterAgent *pc_next;
-
-       for (PerfCounterAgent *cur = perfcounters; cur; cur = pc_next) {
-               pc_next = cur->next;
-               g_free (cur);
-       }
-
-       /*
-        * Ensure that we empty the LLS completely, even if some nodes are
-        * not immediately removed upon calling mono_lls_remove (), by
-        * iterating until the head is NULL.
-        */
-       while (profiler_thread_list.head) {
-               MONO_LLS_FOREACH_SAFE (&profiler_thread_list, MonoProfilerThread, thread) {
-                       g_assert (thread->attached && "Why is a thread in the LLS not attached?");
-
-                       remove_thread (thread);
-               } MONO_LLS_FOREACH_SAFE_END
-       }
-
-       /*
-        * Ensure that all threads have been freed, so that we don't miss any
-        * buffers when we shut down the writer thread below.
-        */
-       mono_thread_hazardous_try_free_all ();
-
-       InterlockedWrite (&prof->run_dumper_thread, 0);
-       mono_os_sem_post (&prof->dumper_queue_sem);
-       mono_native_thread_join (prof->dumper_thread);
-       mono_os_sem_destroy (&prof->dumper_queue_sem);
-
-       InterlockedWrite (&prof->run_writer_thread, 0);
-       mono_os_sem_post (&prof->writer_queue_sem);
-       mono_native_thread_join (prof->writer_thread);
-       mono_os_sem_destroy (&prof->writer_queue_sem);
-
-       /*
-        * Free all writer queue entries, and ensure that all sample hits will be
-        * added to the sample reuse queue.
-        */
-       mono_thread_hazardous_try_free_all ();
-
-       cleanup_reusable_samples (prof);
-
-       /*
-        * Finally, make sure that all sample hits are freed. This should cover all
-        * hazardous data from the profiler. We can now be sure that the runtime
-        * won't later invoke free functions in the profiler library after it has
-        * been unloaded.
-        */
-       mono_thread_hazardous_try_free_all ();
-
-       g_assert (!InterlockedRead (&buffer_rwlock_count) && "Why is the reader count still non-zero?");
-       g_assert (!InterlockedReadPointer (&buffer_rwlock_exclusive) && "Why does someone still hold the exclusive lock?");
-
-#if defined (HAVE_SYS_ZLIB)
-       if (prof->gzfile)
-               gzclose (prof->gzfile);
-#endif
-       if (prof->pipe_output)
-               pclose (prof->file);
-       else
-               fclose (prof->file);
-
-       mono_conc_hashtable_destroy (prof->method_table);
-       mono_os_mutex_destroy (&prof->method_table_mutex);
-
-       if (coverage_initialized) {
-               mono_os_mutex_lock (&coverage_mutex);
-               mono_conc_hashtable_foreach (coverage_assemblies, unref_coverage_assemblies, prof);
-               mono_os_mutex_unlock (&coverage_mutex);
-
-               mono_conc_hashtable_destroy (coverage_methods);
-               mono_conc_hashtable_destroy (coverage_assemblies);
-               mono_conc_hashtable_destroy (coverage_classes);
-               mono_conc_hashtable_destroy (filtered_classes);
-
-               mono_conc_hashtable_destroy (entered_methods);
-               mono_conc_hashtable_destroy (image_to_methods);
-               mono_conc_hashtable_destroy (suppressed_assemblies);
-               mono_os_mutex_destroy (&coverage_mutex);
-       }
-
-       PROF_TLS_FREE ();
-
-       g_free (prof->args);
-       g_free (prof);
-}
-
-static char*
-new_filename (const char* filename)
-{
-       time_t t = time (NULL);
-       int pid = process_id ();
-       char pid_buf [16];
-       char time_buf [16];
-       char *res, *d;
-       const char *p;
-       int count_dates = 0;
-       int count_pids = 0;
-       int s_date, s_pid;
-       struct tm *ts;
-       for (p = filename; *p; p++) {
-               if (*p != '%')
-                       continue;
-               p++;
-               if (*p == 't')
-                       count_dates++;
-               else if (*p == 'p')
-                       count_pids++;
-               else if (*p == 0)
-                       break;
-       }
-       if (!count_dates && !count_pids)
-               return pstrdup (filename);
-       snprintf (pid_buf, sizeof (pid_buf), "%d", pid);
-       ts = gmtime (&t);
-       snprintf (time_buf, sizeof (time_buf), "%d%02d%02d%02d%02d%02d",
-               1900 + ts->tm_year, 1 + ts->tm_mon, ts->tm_mday, ts->tm_hour, ts->tm_min, ts->tm_sec);
-       s_date = strlen (time_buf);
-       s_pid = strlen (pid_buf);
-       d = res = (char *) g_malloc (strlen (filename) + s_date * count_dates + s_pid * count_pids);
-       for (p = filename; *p; p++) {
-               if (*p != '%') {
-                       *d++ = *p;
-                       continue;
-               }
-               p++;
-               if (*p == 't') {
-                       strcpy (d, time_buf);
-                       d += s_date;
-                       continue;
-               } else if (*p == 'p') {
-                       strcpy (d, pid_buf);
-                       d += s_pid;
-                       continue;
-               } else if (*p == '%') {
-                       *d++ = '%';
-                       continue;
-               } else if (*p == 0)
-                       break;
-               *d++ = '%';
-               *d++ = *p;
-       }
-       *d = 0;
-       return res;
-}
-
-static void
-add_to_fd_set (fd_set *set, int fd, int *max_fd)
-{
-       /*
-        * This should only trigger for the basic FDs (server socket, pipes) at
-        * startup if for some mysterious reason they're too large. In this case,
-        * the profiler really can't function, and we're better off printing an
-        * error and exiting.
-        */
-       if (fd >= FD_SETSIZE) {
-               fprintf (stderr, "File descriptor is out of bounds for fd_set: %d\n", fd);
-               exit (1);
-       }
-
-       FD_SET (fd, set);
-
-       if (*max_fd < fd)
-               *max_fd = fd;
-}
-
-static void *
-helper_thread (void *arg)
-{
-       MonoProfiler *prof = (MonoProfiler *) arg;
-
-       mono_threads_attach_tools_thread ();
-       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler helper");
-
-       MonoProfilerThread *thread = init_thread (prof, FALSE);
-
-       GArray *command_sockets = g_array_new (FALSE, FALSE, sizeof (int));
-
-       while (1) {
-               fd_set rfds;
-               int max_fd = -1;
-
-               FD_ZERO (&rfds);
-
-               add_to_fd_set (&rfds, prof->server_socket, &max_fd);
-               add_to_fd_set (&rfds, prof->pipes [0], &max_fd);
-
-               for (gint i = 0; i < command_sockets->len; i++)
-                       add_to_fd_set (&rfds, g_array_index (command_sockets, int, i), &max_fd);
-
-               struct timeval tv = { .tv_sec = 1, .tv_usec = 0 };
-
-               // Sleep for 1sec or until a file descriptor has data.
-               if (select (max_fd + 1, &rfds, NULL, NULL, &tv) == -1) {
-                       if (errno == EINTR)
-                               continue;
-
-                       fprintf (stderr, "Error in mono-profiler-log server: %s", strerror (errno));
-                       exit (1);
-               }
-
-               if (!no_counters)
-                       counters_and_perfcounters_sample (prof);
-
-               buffer_lock_excl ();
-
-               sync_point (SYNC_POINT_PERIODIC);
-
-               buffer_unlock_excl ();
-
-               // Are we shutting down?
-               if (FD_ISSET (prof->pipes [0], &rfds)) {
-                       char c;
-                       read (prof->pipes [0], &c, 1);
-                       break;
-               }
-
-               for (gint i = 0; i < command_sockets->len; i++) {
-                       int fd = g_array_index (command_sockets, int, i);
-
-                       if (!FD_ISSET (fd, &rfds))
-                               continue;
-
-                       char buf [64];
-                       int len = read (fd, buf, sizeof (buf) - 1);
-
-                       if (len == -1)
-                               continue;
-
-                       if (!len) {
-                               // The other end disconnected.
-                               g_array_remove_index (command_sockets, i);
-                               close (fd);
-
-                               continue;
-                       }
-
-                       buf [len] = 0;
-
-                       if (!strcmp (buf, "heapshot\n") && hs_mode_ondemand) {
-                               // Rely on the finalization callbacks invoking process_requests ().
-                               heapshot_requested = 1;
-                               mono_gc_finalize_notify ();
-                       }
-               }
-
-               if (FD_ISSET (prof->server_socket, &rfds)) {
-                       int fd = accept (prof->server_socket, NULL, NULL);
-
-                       if (fd != -1) {
-                               if (fd >= FD_SETSIZE)
-                                       close (fd);
-                               else
-                                       g_array_append_val (command_sockets, fd);
-                       }
-               }
-       }
-
-       for (gint i = 0; i < command_sockets->len; i++)
-               close (g_array_index (command_sockets, int, i));
-
-       g_array_free (command_sockets, TRUE);
-
-       send_log_unsafe (FALSE);
-       deinit_thread (thread);
-
-       mono_thread_info_detach ();
-
-       return NULL;
-}
-
-static void
-start_helper_thread (MonoProfiler* prof)
-{
-       if (pipe (prof->pipes) == -1) {
-               fprintf (stderr, "Cannot create pipe: %s\n", strerror (errno));
-               exit (1);
-       }
-
-       prof->server_socket = socket (PF_INET, SOCK_STREAM, 0);
-
-       if (prof->server_socket == -1) {
-               fprintf (stderr, "Cannot create server socket: %s\n", strerror (errno));
-               exit (1);
-       }
-
-       struct sockaddr_in server_address;
-
-       memset (&server_address, 0, sizeof (server_address));
-       server_address.sin_family = AF_INET;
-       server_address.sin_addr.s_addr = INADDR_ANY;
-       server_address.sin_port = htons (prof->command_port);
-
-       if (bind (prof->server_socket, (struct sockaddr *) &server_address, sizeof (server_address)) == -1) {
-               fprintf (stderr, "Cannot bind server socket on port %d: %s\n", prof->command_port, strerror (errno));
-               close (prof->server_socket);
-               exit (1);
-       }
-
-       if (listen (prof->server_socket, 1) == -1) {
-               fprintf (stderr, "Cannot listen on server socket: %s\n", strerror (errno));
-               close (prof->server_socket);
-               exit (1);
-       }
-
-       socklen_t slen = sizeof (server_address);
-
-       if (getsockname (prof->server_socket, (struct sockaddr *) &server_address, &slen)) {
-               fprintf (stderr, "Could not get assigned port: %s\n", strerror (errno));
-               close (prof->server_socket);
-               exit (1);
-       }
-
-       prof->command_port = ntohs (server_address.sin_port);
-
-       if (!mono_native_thread_create (&prof->helper_thread, helper_thread, prof)) {
-               fprintf (stderr, "Could not start helper thread\n");
-               close (prof->server_socket);
-               exit (1);
-       }
-}
-
-static void
-free_writer_entry (gpointer p)
-{
-       mono_lock_free_free (p, WRITER_ENTRY_BLOCK_SIZE);
-}
-
-static gboolean
-handle_writer_queue_entry (MonoProfiler *prof)
-{
-       WriterQueueEntry *entry;
-
-       if ((entry = (WriterQueueEntry *) mono_lock_free_queue_dequeue (&prof->writer_queue))) {
-               if (!entry->methods)
-                       goto no_methods;
-
-               gboolean wrote_methods = FALSE;
-
-               /*
-                * Encode the method events in a temporary log buffer that we
-                * flush to disk before the main buffer, ensuring that all
-                * methods have metadata emitted before they're referenced.
-                *
-                * We use a 'proper' thread-local buffer for this as opposed
-                * to allocating and freeing a buffer by hand because the call
-                * to mono_method_full_name () below may trigger class load
-                * events when it retrieves the signature of the method. So a
-                * thread-local buffer needs to exist when such events occur.
-                */
-               for (guint i = 0; i < entry->methods->len; i++) {
-                       MethodInfo *info = (MethodInfo *) g_ptr_array_index (entry->methods, i);
-
-                       if (mono_conc_hashtable_lookup (prof->method_table, info->method))
-                               goto free_info; // This method already has metadata emitted.
-
-                       /*
-                        * Other threads use this hash table to get a general
-                        * idea of whether a method has already been emitted to
-                        * the stream. Due to the way we add to this table, it
-                        * can easily happen that multiple threads queue up the
-                        * same methods, but that's OK since eventually all
-                        * methods will be in this table and the thread-local
-                        * method lists will just be empty for the rest of the
-                        * app's lifetime.
-                        */
-                       mono_os_mutex_lock (&prof->method_table_mutex);
-                       mono_conc_hashtable_insert (prof->method_table, info->method, info->method);
-                       mono_os_mutex_unlock (&prof->method_table_mutex);
-
-                       char *name = mono_method_full_name (info->method, 1);
-                       int nlen = strlen (name) + 1;
-                       void *cstart = info->ji ? mono_jit_info_get_code_start (info->ji) : NULL;
-                       int csize = info->ji ? mono_jit_info_get_code_size (info->ji) : 0;
-
-                       ENTER_LOG (&method_jits_ctr, logbuffer,
-                               EVENT_SIZE /* event */ +
-                               LEB128_SIZE /* method */ +
-                               LEB128_SIZE /* start */ +
-                               LEB128_SIZE /* size */ +
-                               nlen /* name */
-                       );
-
-                       emit_event_time (logbuffer, TYPE_JIT | TYPE_METHOD, info->time);
-                       emit_method_inner (logbuffer, info->method);
-                       emit_ptr (logbuffer, cstart);
-                       emit_value (logbuffer, csize);
-
-                       memcpy (logbuffer->cursor, name, nlen);
-                       logbuffer->cursor += nlen;
-
-                       EXIT_LOG_EXPLICIT (NO_SEND, NO_REQUESTS);
-
-                       mono_free (name);
-
-                       wrote_methods = TRUE;
-
-               free_info:
-                       g_free (info);
-               }
-
-               g_ptr_array_free (entry->methods, TRUE);
-
-               if (wrote_methods) {
-                       dump_buffer_threadless (prof, PROF_TLS_GET ()->buffer);
-                       init_buffer_state (PROF_TLS_GET ());
-               }
-
-       no_methods:
-               dump_buffer (prof, entry->buffer);
-
-               mono_thread_hazardous_try_free (entry, free_writer_entry);
-
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void *
-writer_thread (void *arg)
-{
-       MonoProfiler *prof = (MonoProfiler *)arg;
-
-       mono_threads_attach_tools_thread ();
-       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler writer");
-
-       dump_header (prof);
-
-       MonoProfilerThread *thread = init_thread (prof, FALSE);
-
-       while (InterlockedRead (&prof->run_writer_thread)) {
-               mono_os_sem_wait (&prof->writer_queue_sem, MONO_SEM_FLAGS_NONE);
-               handle_writer_queue_entry (prof);
-       }
-
-       /* Drain any remaining entries on shutdown. */
-       while (handle_writer_queue_entry (prof));
-
-       free_buffer (thread->buffer, thread->buffer->size);
-       deinit_thread (thread);
-
-       mono_thread_info_detach ();
-
-       return NULL;
-}
-
-static void
-start_writer_thread (MonoProfiler* prof)
-{
-       InterlockedWrite (&prof->run_writer_thread, 1);
-
-       if (!mono_native_thread_create (&prof->writer_thread, writer_thread, prof)) {
-               fprintf (stderr, "Could not start writer thread\n");
-               exit (1);
-       }
-}
-
-static void
-reuse_sample_hit (gpointer p)
-{
-       SampleHit *sample = p;
-
-       mono_lock_free_queue_node_unpoison (&sample->node);
-       mono_lock_free_queue_enqueue (&sample->prof->sample_reuse_queue, &sample->node);
-}
-
-static gboolean
-handle_dumper_queue_entry (MonoProfiler *prof)
-{
-       SampleHit *sample;
-
-       if ((sample = (SampleHit *) mono_lock_free_queue_dequeue (&prof->dumper_queue))) {
-               for (int i = 0; i < sample->count; ++i) {
-                       MonoMethod *method = sample->frames [i].method;
-                       MonoDomain *domain = sample->frames [i].domain;
-                       void *address = sample->frames [i].base_address;
-
-                       if (!method) {
-                               g_assert (domain && "What happened to the domain pointer?");
-                               g_assert (address && "What happened to the instruction pointer?");
-
-                               MonoJitInfo *ji = mono_jit_info_table_find (domain, (char *) address);
-
-                               if (ji)
-                                       sample->frames [i].method = mono_jit_info_get_method (ji);
-                       }
-               }
-
-               ENTER_LOG (&sample_hits_ctr, logbuffer,
-                       EVENT_SIZE /* event */ +
-                       BYTE_SIZE /* type */ +
-                       LEB128_SIZE /* tid */ +
-                       LEB128_SIZE /* count */ +
-                       1 * (
-                               LEB128_SIZE /* ip */
-                       ) +
-                       LEB128_SIZE /* managed count */ +
-                       sample->count * (
-                               LEB128_SIZE /* method */
-                       )
-               );
-
-               emit_event_time (logbuffer, TYPE_SAMPLE | TYPE_SAMPLE_HIT, sample->time);
-               emit_byte (logbuffer, SAMPLE_CYCLES);
-               emit_ptr (logbuffer, (void *) sample->tid);
-               emit_value (logbuffer, 1);
-
-               // TODO: Actual native unwinding.
-               for (int i = 0; i < 1; ++i) {
-                       emit_ptr (logbuffer, sample->ip);
-                       add_code_pointer ((uintptr_t) sample->ip);
-               }
-
-               /* new in data version 6 */
-               emit_uvalue (logbuffer, sample->count);
-
-               for (int i = 0; i < sample->count; ++i)
-                       emit_method (logbuffer, sample->frames [i].method);
-
-               EXIT_LOG_EXPLICIT (DO_SEND, NO_REQUESTS);
-
-               mono_thread_hazardous_try_free (sample, reuse_sample_hit);
-
-               dump_unmanaged_coderefs (prof);
-       }
-
-       return FALSE;
-}
-
-static void *
-dumper_thread (void *arg)
-{
-       MonoProfiler *prof = (MonoProfiler *)arg;
-
-       mono_threads_attach_tools_thread ();
-       mono_native_thread_set_name (mono_native_thread_id_get (), "Profiler dumper");
-
-       MonoProfilerThread *thread = init_thread (prof, FALSE);
-
-       while (InterlockedRead (&prof->run_dumper_thread)) {
-               mono_os_sem_wait (&prof->dumper_queue_sem, MONO_SEM_FLAGS_NONE);
-               handle_dumper_queue_entry (prof);
-       }
-
-       /* Drain any remaining entries on shutdown. */
-       while (handle_dumper_queue_entry (prof));
-
-       send_log_unsafe (FALSE);
-       deinit_thread (thread);
-
-       mono_thread_info_detach ();
-
-       return NULL;
-}
-
-static void
-start_dumper_thread (MonoProfiler* prof)
-{
-       InterlockedWrite (&prof->run_dumper_thread, 1);
-
-       if (!mono_native_thread_create (&prof->dumper_thread, dumper_thread, prof)) {
-               fprintf (stderr, "Could not start dumper thread\n");
-               exit (1);
-       }
-}
-
-static void
-register_counter (const char *name, gint32 *counter)
-{
-       mono_counters_register (name, MONO_COUNTER_UINT | MONO_COUNTER_PROFILER | MONO_COUNTER_MONOTONIC, counter);
-}
-
-static void
-runtime_initialized (MonoProfiler *profiler)
-{
-       InterlockedWrite (&runtime_inited, 1);
-
-       register_counter ("Sample events allocated", &sample_allocations_ctr);
-       register_counter ("Log buffers allocated", &buffer_allocations_ctr);
-
-       register_counter ("Event: Sync points", &sync_points_ctr);
-       register_counter ("Event: Heap objects", &heap_objects_ctr);
-       register_counter ("Event: Heap starts", &heap_starts_ctr);
-       register_counter ("Event: Heap ends", &heap_ends_ctr);
-       register_counter ("Event: Heap roots", &heap_roots_ctr);
-       register_counter ("Event: GC events", &gc_events_ctr);
-       register_counter ("Event: GC resizes", &gc_resizes_ctr);
-       register_counter ("Event: GC allocations", &gc_allocs_ctr);
-       register_counter ("Event: GC moves", &gc_moves_ctr);
-       register_counter ("Event: GC handle creations", &gc_handle_creations_ctr);
-       register_counter ("Event: GC handle deletions", &gc_handle_deletions_ctr);
-       register_counter ("Event: GC finalize starts", &finalize_begins_ctr);
-       register_counter ("Event: GC finalize ends", &finalize_ends_ctr);
-       register_counter ("Event: GC finalize object starts", &finalize_object_begins_ctr);
-       register_counter ("Event: GC finalize object ends", &finalize_object_ends_ctr);
-       register_counter ("Event: Image loads", &image_loads_ctr);
-       register_counter ("Event: Image unloads", &image_unloads_ctr);
-       register_counter ("Event: Assembly loads", &assembly_loads_ctr);
-       register_counter ("Event: Assembly unloads", &assembly_unloads_ctr);
-       register_counter ("Event: Class loads", &class_loads_ctr);
-       register_counter ("Event: Class unloads", &class_unloads_ctr);
-       register_counter ("Event: Method entries", &method_entries_ctr);
-       register_counter ("Event: Method exits", &method_exits_ctr);
-       register_counter ("Event: Method exception leaves", &method_exception_exits_ctr);
-       register_counter ("Event: Method JITs", &method_jits_ctr);
-       register_counter ("Event: Code buffers", &code_buffers_ctr);
-       register_counter ("Event: Exception throws", &exception_throws_ctr);
-       register_counter ("Event: Exception clauses", &exception_clauses_ctr);
-       register_counter ("Event: Monitor contentions", &monitor_contentions_ctr);
-       register_counter ("Event: Monitor acquisitions", &monitor_acquisitions_ctr);
-       register_counter ("Event: Monitor failures", &monitor_failures_ctr);
-       register_counter ("Event: Thread starts", &thread_starts_ctr);
-       register_counter ("Event: Thread ends", &thread_ends_ctr);
-       register_counter ("Event: Thread names", &thread_names_ctr);
-       register_counter ("Event: Domain loads", &domain_loads_ctr);
-       register_counter ("Event: Domain unloads", &domain_unloads_ctr);
-       register_counter ("Event: Domain names", &domain_names_ctr);
-       register_counter ("Event: Context loads", &context_loads_ctr);
-       register_counter ("Event: Context unloads", &context_unloads_ctr);
-       register_counter ("Event: Sample binaries", &sample_ubins_ctr);
-       register_counter ("Event: Sample symbols", &sample_usyms_ctr);
-       register_counter ("Event: Sample hits", &sample_hits_ctr);
-       register_counter ("Event: Counter descriptors", &counter_descriptors_ctr);
-       register_counter ("Event: Counter samples", &counter_samples_ctr);
-       register_counter ("Event: Performance counter descriptors", &perfcounter_descriptors_ctr);
-       register_counter ("Event: Performance counter samples", &perfcounter_samples_ctr);
-       register_counter ("Event: Coverage methods", &coverage_methods_ctr);
-       register_counter ("Event: Coverage statements", &coverage_statements_ctr);
-       register_counter ("Event: Coverage classes", &coverage_classes_ctr);
-       register_counter ("Event: Coverage assemblies", &coverage_assemblies_ctr);
-
-       counters_init (profiler);
-
-       /*
-        * We must start the helper thread before the writer thread. This is
-        * because the helper thread sets up the command port which is written to
-        * the log header by the writer thread.
-        */
-       start_helper_thread (profiler);
-       start_writer_thread (profiler);
-       start_dumper_thread (profiler);
-}
-
-static MonoProfiler*
-create_profiler (const char *args, const char *filename, GPtrArray *filters)
-{
-       MonoProfiler *prof;
-       char *nf;
-       int force_delete = 0;
-       prof = (MonoProfiler *) g_calloc (1, sizeof (MonoProfiler));
-
-       prof->args = pstrdup (args);
-       prof->command_port = command_port;
-       if (filename && *filename == '-') {
-               force_delete = 1;
-               filename++;
-       }
-       if (!filename) {
-               if (do_report)
-                       filename = "|mprof-report -";
-               else
-                       filename = "output.mlpd";
-               nf = (char*)filename;
-       } else {
-               nf = new_filename (filename);
-               if (do_report) {
-                       int s = strlen (nf) + 32;
-                       char *p = (char *) g_malloc (s);
-                       snprintf (p, s, "|mprof-report '--out=%s' -", nf);
-                       g_free (nf);
-                       nf = p;
-               }
-       }
-       if (*nf == '|') {
-               prof->file = popen (nf + 1, "w");
-               prof->pipe_output = 1;
-       } else if (*nf == '#') {
-               int fd = strtol (nf + 1, NULL, 10);
-               prof->file = fdopen (fd, "a");
-       } else {
-               if (force_delete)
-                       unlink (nf);
-               prof->file = fopen (nf, "wb");
-       }
-       if (!prof->file) {
-               fprintf (stderr, "Cannot create profiler output: %s\n", nf);
-               exit (1);
-       }
-
-#if defined (HAVE_SYS_ZLIB)
-       if (use_zip)
-               prof->gzfile = gzdopen (fileno (prof->file), "wb");
-#endif
-
-       /*
-        * If you hit this assert while increasing MAX_FRAMES, you need to increase
-        * SAMPLE_BLOCK_SIZE as well.
-        */
-       g_assert (SAMPLE_SLOT_SIZE (MAX_FRAMES) * 2 < LOCK_FREE_ALLOC_SB_USABLE_SIZE (SAMPLE_BLOCK_SIZE));
-
-       // 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_MEM_ACCOUNT_PROFILER);
-
-       mono_lock_free_queue_init (&prof->sample_reuse_queue);
-
-       g_assert (sizeof (WriterQueueEntry) * 2 < LOCK_FREE_ALLOC_SB_USABLE_SIZE (WRITER_ENTRY_BLOCK_SIZE));
-
-       // 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_MEM_ACCOUNT_PROFILER);
-
-       mono_lock_free_queue_init (&prof->writer_queue);
-       mono_os_sem_init (&prof->writer_queue_sem, 0);
-
-       mono_lock_free_queue_init (&prof->dumper_queue);
-       mono_os_sem_init (&prof->dumper_queue_sem, 0);
-
-       mono_os_mutex_init (&prof->method_table_mutex);
-       prof->method_table = mono_conc_hashtable_new (NULL, NULL);
-
-       if (do_coverage)
-               coverage_init (prof);
-       prof->coverage_filters = filters;
-
-       prof->startup_time = current_time ();
-       return prof;
-}
-
-static void
-usage (int do_exit)
-{
-       printf ("Log profiler version %d.%d (format: %d)\n", LOG_VERSION_MAJOR, LOG_VERSION_MINOR, LOG_DATA_VERSION);
-       printf ("Usage: mono --profile=log[:OPTION1[,OPTION2...]] program.exe\n");
-       printf ("Options:\n");
-       printf ("\thelp                 show this usage info\n");
-       printf ("\t[no]alloc            enable/disable recording allocation info\n");
-       printf ("\t[no]calls            enable/disable recording enter/leave method events\n");
-       printf ("\theapshot[=MODE]      record heap shot info (by default at each major collection)\n");
-       printf ("\t                     MODE: every XXms milliseconds, every YYgc collections, ondemand\n");
-       printf ("\tcounters             sample counters every 1s\n");
-       printf ("\tsample[=TYPE]        use statistical sampling mode (by default cycles/100)\n");
-       printf ("\t                     TYPE: cycles,instr,cacherefs,cachemiss,branches,branchmiss\n");
-       printf ("\t                     TYPE can be followed by /FREQUENCY\n");
-       printf ("\tmaxframes=NUM        collect up to NUM stack frames\n");
-       printf ("\tcalldepth=NUM        ignore method events for call chain depth bigger than NUM\n");
-       printf ("\toutput=FILENAME      write the data to file FILENAME (-FILENAME to overwrite)\n");
-       printf ("\toutput=|PROGRAM      write the data to the stdin of PROGRAM\n");
-       printf ("\t                     %%t is subtituted with date and time, %%p with the pid\n");
-       printf ("\treport               create a report instead of writing the raw data to a file\n");
-       printf ("\tzip                  compress the output data\n");
-       printf ("\tport=PORTNUM         use PORTNUM for the listening command server\n");
-       printf ("\tcoverage             enable collection of code coverage data\n");
-       printf ("\tcovfilter=ASSEMBLY   add an assembly to the code coverage filters\n");
-       printf ("\t                     add a + to include the assembly or a - to exclude it\n");
-       printf ("\t                     filter=-mscorlib\n");
-       printf ("\tcovfilter-file=FILE  use FILE to generate the list of assemblies to be filtered\n");
-       if (do_exit)
-               exit (1);
-}
-
-static const char*
-match_option (const char* p, const char *opt, char **rval)
-{
-       int len = strlen (opt);
-       if (strncmp (p, opt, len) == 0) {
-               if (rval) {
-                       if (p [len] == '=' && p [len + 1]) {
-                               const char *opt = p + len + 1;
-                               const char *end = strchr (opt, ',');
-                               char *val;
-                               int l;
-                               if (end == NULL) {
-                                       l = strlen (opt);
-                               } else {
-                                       l = end - opt;
-                               }
-                               val = (char *) g_malloc (l + 1);
-                               memcpy (val, opt, l);
-                               val [l] = 0;
-                               *rval = val;
-                               return opt + l;
-                       }
-                       if (p [len] == 0 || p [len] == ',') {
-                               *rval = NULL;
-                               return p + len + (p [len] == ',');
-                       }
-                       usage (1);
-               } else {
-                       if (p [len] == 0)
-                               return p + len;
-                       if (p [len] == ',')
-                               return p + len + 1;
-               }
-       }
-       return p;
-}
-
-static void
-set_sample_freq (char *val)
-{
-       do_mono_sample = 1;
-       sample_freq = 100;
-
-       if (!val)
-               return;
-
-       char *p = val;
-
-       // Is it only the frequency (new option style)?
-       if (isdigit (*p))
-               goto parse;
-
-       // Skip the sample type for backwards compatibility.
-       while (isalpha (*p))
-               p++;
-
-       // Skip the forward slash only if we got a sample type.
-       if (p != val && *p == '/') {
-               p++;
-
-               char *end;
-
-       parse:
-               sample_freq = strtoul (p, &end, 10);
-
-               if (p == end)
-                       usage (1);
-
-               p = end;
-       }
-
-       if (*p)
-               usage (1);
-
-       g_free (val);
-}
-
-static void
-set_hsmode (char* val, int allow_empty)
-{
-       char *end;
-       unsigned int count;
-       if (allow_empty && !val)
-               return;
-       if (strcmp (val, "ondemand") == 0) {
-               hs_mode_ondemand = 1;
-               g_free (val);
-               return;
-       }
-       count = strtoul (val, &end, 10);
-       if (val == end)
-               usage (1);
-       if (strcmp (end, "ms") == 0)
-               hs_mode_ms = count;
-       else if (strcmp (end, "gc") == 0)
-               hs_mode_gc = count;
-       else
-               usage (1);
-       g_free (val);
-}
-
-/*
- * declaration to silence the compiler: this is the entry point that
- * mono will load from the shared library and call.
- */
-extern void
-mono_profiler_startup (const char *desc);
-
-extern void
-mono_profiler_startup_log (const char *desc);
-
-/*
- * this is the entry point that will be used when the profiler
- * is embedded inside the main executable.
- */
-void
-mono_profiler_startup_log (const char *desc)
-{
-       mono_profiler_startup (desc);
-}
-
-void
-mono_profiler_startup (const char *desc)
-{
-       MonoProfiler *prof;
-       GPtrArray *filters = NULL;
-       char *filename = NULL;
-       const char *p;
-       const char *opt;
-       int calls_enabled = 0;
-       int allocs_enabled = 0;
-       int events = MONO_PROFILE_GC|MONO_PROFILE_ALLOCATIONS|
-               MONO_PROFILE_GC_MOVES|MONO_PROFILE_CLASS_EVENTS|MONO_PROFILE_THREADS|
-               MONO_PROFILE_ENTER_LEAVE|MONO_PROFILE_JIT_COMPILATION|MONO_PROFILE_EXCEPTIONS|
-               MONO_PROFILE_MONITOR_EVENTS|MONO_PROFILE_MODULE_EVENTS|MONO_PROFILE_GC_ROOTS|
-               MONO_PROFILE_INS_COVERAGE|MONO_PROFILE_APPDOMAIN_EVENTS|MONO_PROFILE_CONTEXT_EVENTS|
-               MONO_PROFILE_ASSEMBLY_EVENTS|MONO_PROFILE_GC_FINALIZATION;
-
-       max_allocated_sample_hits = mono_cpu_count () * 1000;
-
-       p = desc;
-       if (strncmp (p, "log", 3))
-               usage (1);
-       p += 3;
-       if (*p == ':')
-               p++;
-       for (; *p; p = opt) {
-               char *val;
-               if (*p == ',') {
-                       opt = p + 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "help", NULL)) != p) {
-                       usage (0);
-                       continue;
-               }
-               if ((opt = match_option (p, "calls", NULL)) != p) {
-                       calls_enabled = 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "nocalls", NULL)) != p) {
-                       events &= ~MONO_PROFILE_ENTER_LEAVE;
-                       nocalls = 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "alloc", NULL)) != p) {
-                       allocs_enabled = 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "noalloc", NULL)) != p) {
-                       events &= ~MONO_PROFILE_ALLOCATIONS;
-                       events &= ~MONO_PROFILE_GC_MOVES;
-                       continue;
-               }
-               if ((opt = match_option (p, "nocounters", NULL)) != p) {
-                       no_counters = TRUE;
-                       continue;
-               }
-               if ((opt = match_option (p, "time", &val)) != p) {
-                       // For backwards compatibility.
-                       if (strcmp (val, "fast") && strcmp (val, "null"))
-                               usage (1);
-                       g_free (val);
-                       continue;
-               }
-               if ((opt = match_option (p, "report", NULL)) != p) {
-                       do_report = 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "debug", NULL)) != p) {
-                       do_debug = 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "sampling-real", NULL)) != p) {
-                       sampling_mode = MONO_PROFILER_STAT_MODE_REAL;
-                       continue;
-               }
-               if ((opt = match_option (p, "sampling-process", NULL)) != p) {
-                       sampling_mode = MONO_PROFILER_STAT_MODE_PROCESS;
-                       continue;
-               }
-               if ((opt = match_option (p, "heapshot", &val)) != p) {
-                       events &= ~MONO_PROFILE_ALLOCATIONS;
-                       events &= ~MONO_PROFILE_GC_MOVES;
-                       events &= ~MONO_PROFILE_ENTER_LEAVE;
-                       nocalls = 1;
-                       do_heap_shot = 1;
-                       set_hsmode (val, 1);
-                       continue;
-               }
-               if ((opt = match_option (p, "sample", &val)) != p) {
-                       events &= ~MONO_PROFILE_ALLOCATIONS;
-                       events &= ~MONO_PROFILE_GC_MOVES;
-                       events &= ~MONO_PROFILE_ENTER_LEAVE;
-                       nocalls = 1;
-                       set_sample_freq (val);
-                       continue;
-               }
-               if ((opt = match_option (p, "zip", NULL)) != p) {
-                       use_zip = 1;
-                       continue;
-               }
-               if ((opt = match_option (p, "output", &val)) != p) {
-                       filename = val;
-                       continue;
-               }
-               if ((opt = match_option (p, "port", &val)) != p) {
-                       char *end;
-                       command_port = strtoul (val, &end, 10);
-                       g_free (val);
-                       continue;
-               }
-               if ((opt = match_option (p, "maxframes", &val)) != p) {
-                       char *end;
-                       num_frames = strtoul (val, &end, 10);
-                       if (num_frames > MAX_FRAMES)
-                               num_frames = MAX_FRAMES;
-                       g_free (val);
-                       notraces = num_frames == 0;
-                       continue;
-               }
-               if ((opt = match_option (p, "maxsamples", &val)) != p) {
-                       char *end;
-                       max_allocated_sample_hits = strtoul (val, &end, 10);
-                       if (!max_allocated_sample_hits)
-                               max_allocated_sample_hits = G_MAXINT32;
-                       g_free (val);
-                       continue;
-               }
-               if ((opt = match_option (p, "calldepth", &val)) != p) {
-                       char *end;
-                       max_call_depth = strtoul (val, &end, 10);
-                       g_free (val);
-                       continue;
-               }
-               if ((opt = match_option (p, "counters", NULL)) != p) {
-                       // For backwards compatibility.
-                       continue;
-               }
-               if ((opt = match_option (p, "coverage", NULL)) != p) {
-                       do_coverage = 1;
-                       events |= MONO_PROFILE_ENTER_LEAVE;
-                       debug_coverage = g_hasenv ("MONO_PROFILER_DEBUG_COVERAGE");
-                       continue;
-               }
-               if ((opt = match_option (p, "onlycoverage", NULL)) != p) {
-                       only_coverage = TRUE;
-                       continue;
-               }
-               if ((opt = match_option (p, "covfilter-file", &val)) != p) {
-                       FILE *filter_file;
-                       char *line, *content;
-
-                       if (filters == NULL)
-                               filters = g_ptr_array_new ();
-
-                       filter_file = fopen (val, "r");
-                       if (filter_file == NULL) {
-                               fprintf (stderr, "Unable to open %s\n", val);
-                               exit (0);
-                       }
-
-                       /* Don't need to free content as it is referred to by the lines stored in @filters */
-                       content = get_file_content (filter_file);
-                       if (content == NULL)
-                               fprintf (stderr, "WARNING: %s is greater than 128kb - ignoring\n", val);
-
-                       while ((line = get_next_line (content, &content)))
-                               g_ptr_array_add (filters, g_strchug (g_strchomp (line)));
-
-                       fclose (filter_file);
-                       continue;
-               }
-               if ((opt = match_option (p, "covfilter", &val)) != p) {
-                       if (filters == NULL)
-                               filters = g_ptr_array_new ();
-
-                       g_ptr_array_add (filters, val);
-                       continue;
-               }
-               if (opt == p) {
-                       usage (0);
-                       exit (0);
-               }
-       }
-
-       if (calls_enabled) {
-               events |= MONO_PROFILE_ENTER_LEAVE;
-               nocalls = 0;
-       }
-
-       if (allocs_enabled) {
-               events |= MONO_PROFILE_ALLOCATIONS;
-               events |= MONO_PROFILE_GC_MOVES;
-       }
-
-       // Only activate the bare minimum events the profiler needs to function.
-       if (only_coverage) {
-               if (!do_coverage) {
-                       fprintf (stderr, "The onlycoverage option is only valid when paired with the coverage option\n");
-                       exit (1);
-               }
-
-               no_counters = TRUE;
-               events = MONO_PROFILE_GC | MONO_PROFILE_THREADS | MONO_PROFILE_ENTER_LEAVE | MONO_PROFILE_INS_COVERAGE;
-       }
-
-       init_time ();
-
-       PROF_TLS_INIT ();
-
-       prof = create_profiler (desc, filename, filters);
-       if (!prof) {
-               PROF_TLS_FREE ();
-               return;
-       }
-
-       mono_lls_init (&profiler_thread_list, NULL);
-
-       init_thread (prof, TRUE);
-
-       mono_profiler_install (prof, log_shutdown);
-       mono_profiler_install_gc (gc_event, gc_resize);
-       mono_profiler_install_allocation (gc_alloc);
-       mono_profiler_install_gc_moves (gc_moves);
-       mono_profiler_install_gc_roots (gc_handle, gc_roots);
-       mono_profiler_install_gc_finalize (finalize_begin, finalize_object_begin, finalize_object_end, finalize_end);
-       mono_profiler_install_appdomain (NULL, domain_loaded, domain_unloaded, NULL);
-       mono_profiler_install_appdomain_name (domain_name);
-       mono_profiler_install_context (context_loaded, context_unloaded);
-       mono_profiler_install_class (NULL, class_loaded, class_unloaded, NULL);
-       mono_profiler_install_module (NULL, image_loaded, image_unloaded, NULL);
-       mono_profiler_install_assembly (NULL, assembly_loaded, assembly_unloaded, NULL);
-       mono_profiler_install_thread (thread_start, thread_end);
-       mono_profiler_install_thread_name (thread_name);
-       mono_profiler_install_enter_leave (method_enter, method_leave);
-       mono_profiler_install_jit_end (method_jitted);
-       mono_profiler_install_code_buffer_new (code_buffer_new);
-       mono_profiler_install_exception (throw_exc, method_exc_leave, clause_exc);
-       mono_profiler_install_monitor (monitor_event);
-       mono_profiler_install_runtime_initialized (runtime_initialized);
-       if (do_coverage)
-               mono_profiler_install_coverage_filter (coverage_filter);
-
-       if (do_mono_sample && sample_freq) {
-               events |= MONO_PROFILE_STATISTICAL;
-               mono_profiler_set_statistical_mode (sampling_mode, sample_freq);
-               mono_profiler_install_statistical (mono_sample_hit);
-       }
-
-       mono_profiler_set_events ((MonoProfileFlags)events);
-}
diff --git a/mono/profiler/mono-profiler-log.h b/mono/profiler/mono-profiler-log.h
deleted file mode 100644 (file)
index 99b5782..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-#ifndef __MONO_PROFLOG_H__
-#define __MONO_PROFLOG_H__
-
-#define BUF_ID 0x4D504C01
-#define LOG_HEADER_ID 0x4D505A01
-#define LOG_VERSION_MAJOR 1
-#define LOG_VERSION_MINOR 1
-#define LOG_DATA_VERSION 13
-
-/*
- * Changes in major/minor versions:
- * version 1.0: removed sysid field from header
- *              added args, arch, os fields to header
- *
- * Changes in data versions:
- * version 2: added offsets in heap walk
- * version 3: added GC roots
- * version 4: added sample/statistical profiling
- * version 5: added counters sampling
- * version 6: added optional backtrace in sampling info
- * version 8: added TYPE_RUNTIME and JIT helpers/trampolines
- * version 9: added MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING
- * version 10: added TYPE_COVERAGE
- * version 11: added thread ID to TYPE_SAMPLE_HIT
-               added more load/unload events
-                   unload for class
-                   unload for image
-                   load/unload for appdomain
-                   load/unload for contexts
-                   load/unload/name for assemblies
-               removed TYPE_LOAD_ERR flag (profiler never generated it, now removed from the format itself)
-               added TYPE_GC_HANDLE_{CREATED,DESTROYED}_BT
-               TYPE_JIT events are no longer guaranteed to have code start/size info (can be zero)
- * version 12: added MONO_COUNTER_PROFILER
- * version 13: added MONO_GC_EVENT_{PRE_STOP_WORLD_LOCKED,POST_START_WORLD_UNLOCKED}
-               added TYPE_META + TYPE_SYNC_POINT
-               removed il and native offset in TYPE_SAMPLE_HIT
-               methods in backtraces are now encoded as proper method pointers
-               removed flags in backtrace format
-               removed flags in metadata events
-               changed the following fields to a single byte rather than leb128
-                   TYPE_GC_EVENT: event_type, generation
-                   TYPE_HEAP_ROOT: root_type
-                   TYPE_JITHELPER: type
-                   TYPE_SAMPLE_HIT: sample_type
-                   TYPE_CLAUSE: clause_type
-                   TYPE_SAMPLE_COUNTERS_DESC: type, unit, variance
-                   TYPE_SAMPLE_COUNTERS: type
-               added time fields to all events that were missing one
-                   TYPE_HEAP_OBJECT
-                   TYPE_HEAP_ROOT
-                   TYPE_SAMPLE_USYM
-                   TYPE_SAMPLE_COUNTERS_DESC
-                   TYPE_COVERAGE_METHOD
-                   TYPE_COVERAGE_STATEMENT
-                   TYPE_COVERAGE_CLASS
-                   TYPE_COVERAGE_ASSEMBLY
-               moved the time field in TYPE_SAMPLE_HIT to right after the event byte, now encoded as a regular time field
-               changed the time field in TYPE_SAMPLE_COUNTERS to be encoded as a regular time field (in nanoseconds)
-               added TYPE_GC_FINALIZE_{START,END,OBJECT_START,OBJECT_END}
- */
-
-enum {
-       TYPE_ALLOC,
-       TYPE_GC,
-       TYPE_METADATA,
-       TYPE_METHOD,
-       TYPE_EXCEPTION,
-       TYPE_MONITOR,
-       TYPE_HEAP,
-       TYPE_SAMPLE,
-       TYPE_RUNTIME,
-       TYPE_COVERAGE,
-       TYPE_META,
-       /* extended type for TYPE_HEAP */
-       TYPE_HEAP_START  = 0 << 4,
-       TYPE_HEAP_END    = 1 << 4,
-       TYPE_HEAP_OBJECT = 2 << 4,
-       TYPE_HEAP_ROOT   = 3 << 4,
-       /* extended type for TYPE_METADATA */
-       TYPE_END_LOAD     = 2 << 4,
-       TYPE_END_UNLOAD   = 4 << 4,
-       /* extended type for TYPE_GC */
-       TYPE_GC_EVENT  = 1 << 4,
-       TYPE_GC_RESIZE = 2 << 4,
-       TYPE_GC_MOVE   = 3 << 4,
-       TYPE_GC_HANDLE_CREATED      = 4 << 4,
-       TYPE_GC_HANDLE_DESTROYED    = 5 << 4,
-       TYPE_GC_HANDLE_CREATED_BT   = 6 << 4,
-       TYPE_GC_HANDLE_DESTROYED_BT = 7 << 4,
-       TYPE_GC_FINALIZE_START = 8 << 4,
-       TYPE_GC_FINALIZE_END = 9 << 4,
-       TYPE_GC_FINALIZE_OBJECT_START = 10 << 4,
-       TYPE_GC_FINALIZE_OBJECT_END = 11 << 4,
-       /* extended type for TYPE_METHOD */
-       TYPE_LEAVE     = 1 << 4,
-       TYPE_ENTER     = 2 << 4,
-       TYPE_EXC_LEAVE = 3 << 4,
-       TYPE_JIT       = 4 << 4,
-       /* extended type for TYPE_EXCEPTION */
-       TYPE_THROW_NO_BT = 0 << 7,
-       TYPE_THROW_BT    = 1 << 7,
-       TYPE_CLAUSE      = 1 << 4,
-       /* extended type for TYPE_ALLOC */
-       TYPE_ALLOC_NO_BT  = 0 << 4,
-       TYPE_ALLOC_BT     = 1 << 4,
-       /* extended type for TYPE_MONITOR */
-       TYPE_MONITOR_NO_BT  = 0 << 7,
-       TYPE_MONITOR_BT     = 1 << 7,
-       /* extended type for TYPE_SAMPLE */
-       TYPE_SAMPLE_HIT           = 0 << 4,
-       TYPE_SAMPLE_USYM          = 1 << 4,
-       TYPE_SAMPLE_UBIN          = 2 << 4,
-       TYPE_SAMPLE_COUNTERS_DESC = 3 << 4,
-       TYPE_SAMPLE_COUNTERS      = 4 << 4,
-       /* extended type for TYPE_RUNTIME */
-       TYPE_JITHELPER = 1 << 4,
-       /* extended type for TYPE_COVERAGE */
-       TYPE_COVERAGE_ASSEMBLY = 0 << 4,
-       TYPE_COVERAGE_METHOD   = 1 << 4,
-       TYPE_COVERAGE_STATEMENT = 2 << 4,
-       TYPE_COVERAGE_CLASS = 3 << 4,
-       /* extended type for TYPE_META */
-       TYPE_SYNC_POINT = 0 << 4,
-       TYPE_END
-};
-
-enum {
-       /* metadata type byte for TYPE_METADATA */
-       TYPE_CLASS    = 1,
-       TYPE_IMAGE    = 2,
-       TYPE_ASSEMBLY = 3,
-       TYPE_DOMAIN   = 4,
-       TYPE_THREAD   = 5,
-       TYPE_CONTEXT  = 6,
-};
-
-typedef enum {
-       SYNC_POINT_PERIODIC,
-       SYNC_POINT_WORLD_STOP,
-       SYNC_POINT_WORLD_START
-} MonoProfilerSyncPointType;
-
-// Sampling sources
-// Unless you have compiled with --enable-perf-events, only SAMPLE_CYCLES is available
-enum {
-       SAMPLE_CYCLES = 1,
-       SAMPLE_INSTRUCTIONS,
-       SAMPLE_CACHE_MISSES,
-       SAMPLE_CACHE_REFS,
-       SAMPLE_BRANCHES,
-       SAMPLE_BRANCH_MISSES,
-       SAMPLE_LAST
-};
-
-#endif /* __MONO_PROFLOG_H__ */
diff --git a/mono/profiler/mono-profiler-vtune.c b/mono/profiler/mono-profiler-vtune.c
deleted file mode 100644 (file)
index 2ed52c5..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * mono-codeanalyst.c: VTune profiler
- *
- * Author:
- *   Virgile Bello (virgile.bello@gmail.com)
- *
- * (C) 2011 Virgile Bello
- *
- * 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.
- */
-#include <mono/metadata/profiler.h>
-#include <mono/metadata/tokentype.h>
-#include <mono/metadata/tabledefs.h>
-#include <mono/metadata/debug-helpers.h>
-#include <mono/metadata/assembly.h>
-#include <mono/metadata/mono-debug.h>
-#include <mono/metadata/debug-internals.h>
-#include <string.h>
-#include <glib.h>
-
-#define bool char
-
-#include <jitprofiling.h>
-
-static const char*
-code_buffer_desc (MonoProfilerCodeBufferType type)
-{
-       switch (type) {
-       case MONO_PROFILER_CODE_BUFFER_METHOD:
-               return "code_buffer_method";
-       case MONO_PROFILER_CODE_BUFFER_METHOD_TRAMPOLINE:
-               return "code_buffer_method_trampoline";
-       case MONO_PROFILER_CODE_BUFFER_UNBOX_TRAMPOLINE:
-               return "code_buffer_unbox_trampoline";
-       case MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE:
-               return "code_buffer_imt_trampoline";
-       case MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE:
-               return "code_buffer_generics_trampoline";
-       case MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE:
-               return "code_buffer_specific_trampoline";
-       case MONO_PROFILER_CODE_BUFFER_HELPER:
-               return "code_buffer_misc_helper";
-       case MONO_PROFILER_CODE_BUFFER_MONITOR:
-               return "code_buffer_monitor";
-       case MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE:
-               return "code_buffer_delegate_invoke";
-       case MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING:
-               return "code_buffer_exception_handling";
-       default:
-               return "unspecified";
-       }
-}
-
-/* called at the end of the program */
-static void
-codeanalyst_shutdown (MonoProfiler *prof)
-{
-       iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL);
-}
-
-static void
-method_jit_result (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result) {
-       if (result == MONO_PROFILE_OK) {
-               int i;
-               MonoDebugSourceLocation *sourceLoc;
-               MonoDebugMethodJitInfo *dmji;
-               MonoClass *klass = mono_method_get_class (method);
-               char *signature = mono_signature_get_desc (mono_method_signature (method), TRUE);
-               char *name = g_strdup_printf ("%s(%s)", mono_method_get_name (method), signature);
-               char *classname = g_strdup_printf ("%s%s%s", mono_class_get_namespace (klass), mono_class_get_namespace (klass)[0] != 0 ? "::" : "", mono_class_get_name (klass));
-               gpointer code_start = mono_jit_info_get_code_start (jinfo);
-               int code_size = mono_jit_info_get_code_size (jinfo);
-               
-               iJIT_Method_Load vtuneMethod;
-               memset(&vtuneMethod, 0, sizeof(vtuneMethod));
-               vtuneMethod.method_id = iJIT_GetNewMethodID();
-               vtuneMethod.method_name = name;
-               vtuneMethod.method_load_address = code_start;
-               vtuneMethod.method_size = code_size;
-               vtuneMethod.class_file_name = classname;
-
-               dmji = mono_debug_find_method (method, mono_domain_get());
-
-               if (dmji != NULL)
-               {
-                       vtuneMethod.line_number_size = dmji->num_line_numbers;
-                       vtuneMethod.line_number_table = (vtuneMethod.line_number_size != 0) ?
-                               (LineNumberInfo*)malloc(sizeof(LineNumberInfo) * vtuneMethod.line_number_size) : NULL;
-
-                       for (i = 0; i < dmji->num_line_numbers; ++i)
-                       {
-                               sourceLoc = mono_debug_lookup_source_location (method, dmji->line_numbers[i].native_offset, mono_domain_get());
-                               if (sourceLoc == NULL)
-                               {
-                                       g_free (vtuneMethod.line_number_table);
-                                       vtuneMethod.line_number_table = NULL;
-                                       vtuneMethod.line_number_size = 0;
-                                       break;
-                               }
-                               if (i == 0)
-                                       vtuneMethod.source_file_name = strdup(sourceLoc->source_file);
-                               vtuneMethod.line_number_table[i].Offset = dmji->line_numbers[i].native_offset;
-                               vtuneMethod.line_number_table[i].LineNumber = sourceLoc->row;
-                               mono_debug_free_source_location (sourceLoc);
-                       }
-                       mono_debug_free_method_jit_info (dmji);
-               }
-
-               iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &vtuneMethod);
-
-               if (vtuneMethod.source_file_name != NULL)
-                       g_free (vtuneMethod.source_file_name);
-               if (vtuneMethod.line_number_table != NULL)
-                       g_free (vtuneMethod.line_number_table);
-       
-               g_free (signature);
-               g_free (name);
-               g_free (classname);
-       }
-}
-
-static void
-code_buffer_new (MonoProfiler *prof, void *buffer, int size, MonoProfilerCodeBufferType type, void *data)
-{
-       char *name;
-       iJIT_Method_Load vtuneMethod;
-
-       if (type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE)
-               name = g_strdup_printf ("code_buffer_specific_trampoline_%s", (char*) data);
-       else
-               name = (char*) code_buffer_desc (type);
-
-       memset (&vtuneMethod, 0, sizeof (vtuneMethod));
-       vtuneMethod.method_id = iJIT_GetNewMethodID ();
-       vtuneMethod.method_name = name;
-       vtuneMethod.method_load_address = buffer;
-       vtuneMethod.method_size = size;
-
-       iJIT_NotifyEvent (iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &vtuneMethod);
-
-       if (type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE) {
-               g_free (name);
-       }
-}
-
-/* the entry point */
-void
-mono_profiler_startup (const char *desc)
-{
-       iJIT_IsProfilingActiveFlags flags = iJIT_IsProfilingActive();
-       if (flags == iJIT_SAMPLING_ON)
-       {
-               mono_profiler_install (NULL, codeanalyst_shutdown);
-               mono_profiler_install_jit_end (method_jit_result);
-               mono_profiler_install_code_buffer_new (code_buffer_new);
-               mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION);
-       }
-}
index 1017d1f8e6d4fb9e09b8f08fc4c7c8a976f35db6..322eb623b341bf7df3b025b51318955ff977a255 100644 (file)
@@ -54,7 +54,7 @@
  *                    - column: The column on the line
  */
 #include <config.h>
-#include "mono-profiler-log.h"
+#include "log.h"
 #include <string.h>
 #include <assert.h>
 #include <stdio.h>
 #define HASH_SIZE 9371
 #define SMALL_HASH_SIZE 31
 
-#if defined(__native_client__) || defined(__native_client_codegen__)
-volatile int __nacl_thread_suspension_needed = 0;
-void __nacl_suspend_thread_if_needed() {}
-#endif
-
 static int debug = 0;
 static int collect_traces = 0;
 static int show_traces = 0;
@@ -1243,6 +1238,8 @@ heap_shot_find_obj_slot (HeapShot *hs, uintptr_t objaddr)
        uintptr_t i;
        uintptr_t start_pos;
        HeapObjectDesc **hash = hs->objects_hash;
+       if (hs->objects_hash_size == 0)
+               return -1;
        start_pos = ((uintptr_t)objaddr >> 3) % hs->objects_hash_size;
        i = start_pos;
        do {
index e6323460651712aad82d05a0bb261ae9ba88f1e8..687f644e5e0aa3cc0098872106bfff11b3534326 100755 (executable)
@@ -20,20 +20,20 @@ append_path ("DYLD_LIBRARY_PATH", $minibuilddir . "/.libs");
 append_path ("PATH", $profbuilddir);
 
 # first a basic test
-$report = run_test ("test-alloc.exe");
+$report = run_test ("test-alloc.exe", "report,legacy,calls,alloc");
 check_report_basics ($report);
 check_report_calls ($report, "T:Main (string[])" => 1);
 check_report_allocation ($report, "System.Object" => 1000000);
 report_errors ();
 # test additional named threads and method calls
-$report = run_test ("test-busy.exe");
+$report = run_test ("test-busy.exe", "report,legacy,calls,alloc");
 check_report_basics ($report);
 check_report_calls ($report, "T:Main (string[])" => 1);
 check_report_threads ($report, "BusyHelper");
 check_report_calls ($report, "T:test ()" => 10, "T:test3 ()" => 10, "T:test2 ()" => 1);
 report_errors ();
 # test with the sampling profiler
-$report = run_test ("test-busy.exe", "report,sample");
+$report = run_test ("test-busy.exe", "report,legacy,sample");
 check_report_basics ($report);
 check_report_threads ($report, "BusyHelper");
 # at least 40% of the samples should hit each of the two busy methods
@@ -41,20 +41,20 @@ check_report_threads ($report, "BusyHelper");
 #check_report_samples ($report, "T:test ()" => 40, "T:test3 ()" => 40);
 report_errors ();
 # test lock events
-$report = run_test ("test-monitor.exe");
+$report = run_test ("test-monitor.exe", "report,legacy,calls,alloc");
 check_report_basics ($report);
 check_report_calls ($report, "T:Main (string[])" => 1);
 # we hope for at least some contention, this is not entirely reliable
 check_report_locks ($report, 1, 1);
 report_errors ();
 # test exceptions
-$report = run_test ("test-excleave.exe");
+$report = run_test ("test-excleave.exe", "report,legacy,calls");
 check_report_basics ($report);
 check_report_calls ($report, "T:Main (string[])" => 1, "T:throw_ex ()" => 1000);
 check_report_exceptions ($report, 1000, 1000, 1000);
 report_errors ();
 # test heapshot
-$report = run_test_sgen ("test-heapshot.exe", "report,heapshot");
+$report = run_test_sgen ("test-heapshot.exe", "report,heapshot,legacy");
 if ($report ne "missing binary") {
        check_report_basics ($report);
        check_report_heapshot ($report, 0, {"T" => 5000});
@@ -62,7 +62,7 @@ if ($report ne "missing binary") {
        report_errors ();
 }
 # test heapshot traces
-$report = run_test_sgen ("test-heapshot.exe", "heapshot,output=-traces.mlpd", "--traces traces.mlpd");
+$report = run_test_sgen ("test-heapshot.exe", "heapshot,output=-traces.mlpd,legacy", "--traces traces.mlpd");
 if ($report ne "missing binary") {
        check_report_basics ($report);
        check_report_heapshot ($report, 0, {"T" => 5000});
@@ -76,7 +76,7 @@ if ($report ne "missing binary") {
        report_errors ();
 }
 # test traces
-$report = run_test ("test-traces.exe", "output=-traces.mlpd", "--traces traces.mlpd");
+$report = run_test ("test-traces.exe", "legacy,calls,alloc,output=-traces.mlpd", "--traces traces.mlpd");
 check_report_basics ($report);
 check_call_traces ($report,
        "T:level3 (int)" => [2020, "T:Main (string[])"],
@@ -92,7 +92,7 @@ check_alloc_traces ($report,
 );
 report_errors ();
 # test traces without enter/leave events
-$report = run_test ("test-traces.exe", "nocalls,output=-traces.mlpd", "--traces traces.mlpd");
+$report = run_test ("test-traces.exe", "legacy,alloc,output=-traces.mlpd", "--traces traces.mlpd");
 check_report_basics ($report);
 # this has been broken recently
 check_exception_traces ($report,
diff --git a/mono/profiler/vtune.c b/mono/profiler/vtune.c
new file mode 100644 (file)
index 0000000..2ed52c5
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * mono-codeanalyst.c: VTune profiler
+ *
+ * Author:
+ *   Virgile Bello (virgile.bello@gmail.com)
+ *
+ * (C) 2011 Virgile Bello
+ *
+ * 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.
+ */
+#include <mono/metadata/profiler.h>
+#include <mono/metadata/tokentype.h>
+#include <mono/metadata/tabledefs.h>
+#include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/assembly.h>
+#include <mono/metadata/mono-debug.h>
+#include <mono/metadata/debug-internals.h>
+#include <string.h>
+#include <glib.h>
+
+#define bool char
+
+#include <jitprofiling.h>
+
+static const char*
+code_buffer_desc (MonoProfilerCodeBufferType type)
+{
+       switch (type) {
+       case MONO_PROFILER_CODE_BUFFER_METHOD:
+               return "code_buffer_method";
+       case MONO_PROFILER_CODE_BUFFER_METHOD_TRAMPOLINE:
+               return "code_buffer_method_trampoline";
+       case MONO_PROFILER_CODE_BUFFER_UNBOX_TRAMPOLINE:
+               return "code_buffer_unbox_trampoline";
+       case MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE:
+               return "code_buffer_imt_trampoline";
+       case MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE:
+               return "code_buffer_generics_trampoline";
+       case MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE:
+               return "code_buffer_specific_trampoline";
+       case MONO_PROFILER_CODE_BUFFER_HELPER:
+               return "code_buffer_misc_helper";
+       case MONO_PROFILER_CODE_BUFFER_MONITOR:
+               return "code_buffer_monitor";
+       case MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE:
+               return "code_buffer_delegate_invoke";
+       case MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING:
+               return "code_buffer_exception_handling";
+       default:
+               return "unspecified";
+       }
+}
+
+/* called at the end of the program */
+static void
+codeanalyst_shutdown (MonoProfiler *prof)
+{
+       iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL);
+}
+
+static void
+method_jit_result (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result) {
+       if (result == MONO_PROFILE_OK) {
+               int i;
+               MonoDebugSourceLocation *sourceLoc;
+               MonoDebugMethodJitInfo *dmji;
+               MonoClass *klass = mono_method_get_class (method);
+               char *signature = mono_signature_get_desc (mono_method_signature (method), TRUE);
+               char *name = g_strdup_printf ("%s(%s)", mono_method_get_name (method), signature);
+               char *classname = g_strdup_printf ("%s%s%s", mono_class_get_namespace (klass), mono_class_get_namespace (klass)[0] != 0 ? "::" : "", mono_class_get_name (klass));
+               gpointer code_start = mono_jit_info_get_code_start (jinfo);
+               int code_size = mono_jit_info_get_code_size (jinfo);
+               
+               iJIT_Method_Load vtuneMethod;
+               memset(&vtuneMethod, 0, sizeof(vtuneMethod));
+               vtuneMethod.method_id = iJIT_GetNewMethodID();
+               vtuneMethod.method_name = name;
+               vtuneMethod.method_load_address = code_start;
+               vtuneMethod.method_size = code_size;
+               vtuneMethod.class_file_name = classname;
+
+               dmji = mono_debug_find_method (method, mono_domain_get());
+
+               if (dmji != NULL)
+               {
+                       vtuneMethod.line_number_size = dmji->num_line_numbers;
+                       vtuneMethod.line_number_table = (vtuneMethod.line_number_size != 0) ?
+                               (LineNumberInfo*)malloc(sizeof(LineNumberInfo) * vtuneMethod.line_number_size) : NULL;
+
+                       for (i = 0; i < dmji->num_line_numbers; ++i)
+                       {
+                               sourceLoc = mono_debug_lookup_source_location (method, dmji->line_numbers[i].native_offset, mono_domain_get());
+                               if (sourceLoc == NULL)
+                               {
+                                       g_free (vtuneMethod.line_number_table);
+                                       vtuneMethod.line_number_table = NULL;
+                                       vtuneMethod.line_number_size = 0;
+                                       break;
+                               }
+                               if (i == 0)
+                                       vtuneMethod.source_file_name = strdup(sourceLoc->source_file);
+                               vtuneMethod.line_number_table[i].Offset = dmji->line_numbers[i].native_offset;
+                               vtuneMethod.line_number_table[i].LineNumber = sourceLoc->row;
+                               mono_debug_free_source_location (sourceLoc);
+                       }
+                       mono_debug_free_method_jit_info (dmji);
+               }
+
+               iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &vtuneMethod);
+
+               if (vtuneMethod.source_file_name != NULL)
+                       g_free (vtuneMethod.source_file_name);
+               if (vtuneMethod.line_number_table != NULL)
+                       g_free (vtuneMethod.line_number_table);
+       
+               g_free (signature);
+               g_free (name);
+               g_free (classname);
+       }
+}
+
+static void
+code_buffer_new (MonoProfiler *prof, void *buffer, int size, MonoProfilerCodeBufferType type, void *data)
+{
+       char *name;
+       iJIT_Method_Load vtuneMethod;
+
+       if (type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE)
+               name = g_strdup_printf ("code_buffer_specific_trampoline_%s", (char*) data);
+       else
+               name = (char*) code_buffer_desc (type);
+
+       memset (&vtuneMethod, 0, sizeof (vtuneMethod));
+       vtuneMethod.method_id = iJIT_GetNewMethodID ();
+       vtuneMethod.method_name = name;
+       vtuneMethod.method_load_address = buffer;
+       vtuneMethod.method_size = size;
+
+       iJIT_NotifyEvent (iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &vtuneMethod);
+
+       if (type == MONO_PROFILER_CODE_BUFFER_SPECIFIC_TRAMPOLINE) {
+               g_free (name);
+       }
+}
+
+/* the entry point */
+void
+mono_profiler_startup (const char *desc)
+{
+       iJIT_IsProfilingActiveFlags flags = iJIT_IsProfilingActive();
+       if (flags == iJIT_SAMPLING_ON)
+       {
+               mono_profiler_install (NULL, codeanalyst_shutdown);
+               mono_profiler_install_jit_end (method_jit_result);
+               mono_profiler_install_code_buffer_new (code_buffer_new);
+               mono_profiler_set_events (MONO_PROFILE_JIT_COMPILATION);
+       }
+}
index 63e922c470e0745f5e16340a858be806b08deb2b..53e962c2b702e7ea8a893dc940ea8d42d227b967 100644 (file)
@@ -216,7 +216,16 @@ typedef mword SgenDescriptor;
  * sizing heuristics. We are keeping leeway in order to be prepared for work-load
  * variations.
  */
-#define SGEN_MAX_PAUSE_TIME 30
-#define SGEN_MAX_PAUSE_MARGIN 0.66f
+#define SGEN_DEFAULT_MAX_PAUSE_TIME 30
+#define SGEN_DEFAULT_MAX_PAUSE_MARGIN 0.66f
+
+
+#define SGEN_PAUSE_MODE_MAX_PAUSE_MARGIN 0.5f
+
+/*
+ * In practice, for nurseries smaller than this, the parallel minor tends to be
+ * ineffective, even leading to regressions. Avoid using it for smaller nurseries.
+ */
+#define SGEN_PARALLEL_MINOR_MIN_NURSERY_SIZE (1 << 24)
 
 #endif
index 66eb9ab194bb76293336041dfca14767efe3fb3a..6cd939553a99cb91d0553e6a2e80e035fccbae43 100644 (file)
@@ -236,6 +236,9 @@ static gboolean do_dump_nursery_content = FALSE;
 static gboolean enable_nursery_canaries = FALSE;
 
 static gboolean precleaning_enabled = TRUE;
+static gboolean dynamic_nursery = FALSE;
+static size_t min_nursery_size = 0;
+static size_t max_nursery_size = 0;
 
 #ifdef HEAVY_STATISTICS
 guint64 stat_objects_alloced_degraded = 0;
@@ -288,8 +291,8 @@ static guint64 time_major_fragment_creation = 0;
 
 static guint64 time_max = 0;
 
-static int sgen_max_pause_time = SGEN_MAX_PAUSE_TIME;
-static float sgen_max_pause_margin = SGEN_MAX_PAUSE_MARGIN;
+static int sgen_max_pause_time = SGEN_DEFAULT_MAX_PAUSE_TIME;
+static float sgen_max_pause_margin = SGEN_DEFAULT_MAX_PAUSE_MARGIN;
 
 static SGEN_TV_DECLARE (time_major_conc_collection_start);
 static SGEN_TV_DECLARE (time_major_conc_collection_end);
@@ -333,13 +336,32 @@ nursery_canaries_enabled (void)
 
 #if defined(HAVE_CONC_GC_AS_DEFAULT)
 /* Use concurrent major on deskstop platforms */
-#define DEFAULT_MAJOR_INIT sgen_marksweep_conc_init
-#define DEFAULT_MAJOR_NAME "marksweep-conc"
+#define DEFAULT_MAJOR SGEN_MAJOR_CONCURRENT
 #else
-#define DEFAULT_MAJOR_INIT sgen_marksweep_init
-#define DEFAULT_MAJOR_NAME "marksweep"
+#define DEFAULT_MAJOR SGEN_MAJOR_SERIAL
 #endif
 
+typedef enum {
+       SGEN_MAJOR_DEFAULT,
+       SGEN_MAJOR_SERIAL,
+       SGEN_MAJOR_CONCURRENT,
+       SGEN_MAJOR_CONCURRENT_PARALLEL
+} SgenMajor;
+
+typedef enum {
+       SGEN_MINOR_DEFAULT,
+       SGEN_MINOR_SIMPLE,
+       SGEN_MINOR_SIMPLE_PARALLEL,
+       SGEN_MINOR_SPLIT
+} SgenMinor;
+
+typedef enum {
+       SGEN_MODE_NONE,
+       SGEN_MODE_BALANCED,
+       SGEN_MODE_THROUGHPUT,
+       SGEN_MODE_PAUSE
+} SgenMode;
+
 /*
  * ######################################################################
  * ########  Global data.
@@ -1622,7 +1644,6 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
        SgenGrayQueue gc_thread_gray_queue;
        SgenObjectOperations *object_ops_nopar, *object_ops_par = NULL;
        ScanCopyContext ctx;
-       int duration;
        TV_DECLARE (atv);
        TV_DECLARE (btv);
        SGEN_TV_DECLARE (last_minor_collection_start_tv);
@@ -1641,7 +1662,7 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
                object_ops_nopar = &sgen_minor_collector.serial_ops_with_concurrent_major;
        } else {
                object_ops_nopar = &sgen_minor_collector.serial_ops;
-               if (sgen_minor_collector.is_parallel) {
+               if (sgen_minor_collector.is_parallel && sgen_nursery_size >= SGEN_PARALLEL_MINOR_MIN_NURSERY_SIZE) {
                        object_ops_par = &sgen_minor_collector.parallel_ops;
                        is_parallel = TRUE;
                }
@@ -1755,12 +1776,18 @@ collect_nursery (const char *reason, gboolean is_overflow, SgenGrayQueue *unpin_
                sgen_check_remset_consistency ();
 
 
-       TV_GETTIME (btv);
-       duration = (int)(TV_ELAPSED (last_minor_collection_start_tv, btv) / 10000);
-       if (duration > (sgen_max_pause_time * sgen_max_pause_margin))
-               sgen_resize_nursery (TRUE);
-       else
-               sgen_resize_nursery (FALSE);
+       if (sgen_max_pause_time) {
+               int duration;
+
+               TV_GETTIME (btv);
+               duration = (int)(TV_ELAPSED (last_minor_collection_start_tv, btv) / 10000);
+               if (duration > (sgen_max_pause_time * sgen_max_pause_margin))
+                       sgen_resize_nursery (TRUE);
+               else
+                       sgen_resize_nursery (FALSE);
+       } else {
+                       sgen_resize_nursery (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
@@ -2999,13 +3026,162 @@ parse_double_in_interval (const char *env_var, const char *opt_name, const char
        return TRUE;
 }
 
+static SgenMinor
+parse_sgen_minor (const char *opt)
+{
+       if (!opt)
+               return SGEN_MINOR_DEFAULT;
+
+       if (!strcmp (opt, "simple")) {
+               return SGEN_MINOR_SIMPLE;
+       } else if (!strcmp (opt, "simple-par")) {
+               return SGEN_MINOR_SIMPLE_PARALLEL;
+       } else if (!strcmp (opt, "split")) {
+               return SGEN_MINOR_SPLIT;
+       } else {
+               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using default instead.", "Unknown minor collector `%s'.", opt);
+               return SGEN_MINOR_DEFAULT;
+       }
+}
+
+static SgenMajor
+parse_sgen_major (const char *opt)
+{
+       if (!opt)
+               return SGEN_MAJOR_DEFAULT;
+
+       if (!strcmp (opt, "marksweep")) {
+               return SGEN_MAJOR_SERIAL;
+       } else if (!strcmp (opt, "marksweep-conc")) {
+               return SGEN_MAJOR_CONCURRENT;
+       } else if (!strcmp (opt, "marksweep-conc-par")) {
+               return SGEN_MAJOR_CONCURRENT_PARALLEL;
+       } else {
+               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using default instead.", "Unknown major collector `%s'.", opt);
+               return SGEN_MAJOR_DEFAULT;
+       }
+
+}
+
+static SgenMode
+parse_sgen_mode (const char *opt)
+{
+       if (!opt)
+               return SGEN_MODE_NONE;
+
+       if (!strcmp (opt, "balanced")) {
+               return SGEN_MODE_BALANCED;
+       } else if (!strcmp (opt, "throughput")) {
+               return SGEN_MODE_THROUGHPUT;
+       } else if (!strcmp (opt, "pause") || g_str_has_prefix (opt, "pause:")) {
+               return SGEN_MODE_PAUSE;
+       } else {
+               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using default configurations.", "Unknown mode `%s'.", opt);
+               return SGEN_MODE_NONE;
+       }
+}
+
+static void
+init_sgen_minor (SgenMinor minor)
+{
+       switch (minor) {
+       case SGEN_MINOR_DEFAULT:
+       case SGEN_MINOR_SIMPLE:
+               sgen_simple_nursery_init (&sgen_minor_collector, FALSE);
+               break;
+       case SGEN_MINOR_SIMPLE_PARALLEL:
+               sgen_simple_nursery_init (&sgen_minor_collector, TRUE);
+               break;
+       case SGEN_MINOR_SPLIT:
+               sgen_split_nursery_init (&sgen_minor_collector);
+               break;
+       default:
+               g_assert_not_reached ();
+       }
+}
+
+static void
+init_sgen_major (SgenMajor major)
+{
+       if (major == SGEN_MAJOR_DEFAULT)
+               major = DEFAULT_MAJOR;
+
+       switch (major) {
+       case SGEN_MAJOR_SERIAL:
+               sgen_marksweep_init (&major_collector);
+               break;
+       case SGEN_MAJOR_CONCURRENT:
+               sgen_marksweep_conc_init (&major_collector);
+               break;
+       case SGEN_MAJOR_CONCURRENT_PARALLEL:
+               sgen_marksweep_conc_par_init (&major_collector);
+               break;
+       default:
+               g_assert_not_reached ();
+       }
+}
+
+/*
+ * If sgen mode is set, major/minor configuration is fixed. The other gc_params
+ * are parsed and processed after major/minor initialization, so it can potentially
+ * override some knobs set by the sgen mode. We can consider locking out additional
+ * configurations when gc_modes are used.
+ */
+static void
+init_sgen_mode (SgenMode mode)
+{
+       SgenMinor minor = SGEN_MINOR_DEFAULT;
+       SgenMajor major = SGEN_MAJOR_DEFAULT;
+
+       switch (mode) {
+       case SGEN_MODE_BALANCED:
+               /*
+                * Use a dynamic parallel nursery with a major concurrent collector.
+                * This uses the default values for max pause time and nursery size.
+                */
+               minor = SGEN_MINOR_SIMPLE;
+               major = SGEN_MAJOR_CONCURRENT;
+               dynamic_nursery = TRUE;
+               break;
+       case SGEN_MODE_THROUGHPUT:
+               /*
+                * Use concurrent major to let the mutator do more work. Use a larger
+                * nursery, without pause time constraints, in order to collect more
+                * objects in parallel and avoid repetitive collection tasks (pinning,
+                * root scanning etc)
+                */
+               minor = SGEN_MINOR_SIMPLE_PARALLEL;
+               major = SGEN_MAJOR_CONCURRENT;
+               dynamic_nursery = TRUE;
+               sgen_max_pause_time = 0;
+               break;
+       case SGEN_MODE_PAUSE:
+               /*
+                * Use concurrent major and dynamic nursery with a more
+                * aggressive shrinking relative to pause times.
+                * FIXME use parallel minors
+                */
+               minor = SGEN_MINOR_SIMPLE;
+               major = SGEN_MAJOR_CONCURRENT;
+               dynamic_nursery = TRUE;
+               sgen_max_pause_margin = SGEN_PAUSE_MODE_MAX_PAUSE_MARGIN;
+               break;
+       default:
+               g_assert_not_reached ();
+       }
+
+       init_sgen_minor (minor);
+       init_sgen_major (major);
+}
+
 void
 sgen_gc_init (void)
 {
        char *env;
        char **opts, **ptr;
-       char *major_collector_opt = NULL;
-       char *minor_collector_opt = NULL;
+       SgenMajor sgen_major = SGEN_MAJOR_DEFAULT;
+       SgenMinor sgen_minor = SGEN_MINOR_DEFAULT;
+       SgenMode sgen_mode = SGEN_MODE_NONE;
        char *params_opts = NULL;
        char *debug_opts = NULL;
        size_t max_heap = 0;
@@ -3014,8 +3190,6 @@ sgen_gc_init (void)
        gboolean debug_print_allowance = FALSE;
        double allowance_ratio = 0, save_target = 0;
        gboolean cement_enabled = TRUE;
-       gboolean dynamic_nursery = FALSE;
-       size_t min_nursery_size = 0, max_nursery_size = 0;
 
        do {
                result = InterlockedCompareExchange (&gc_initialized, -1, 0);
@@ -3058,10 +3232,13 @@ sgen_gc_init (void)
                        char *opt = *ptr;
                        if (g_str_has_prefix (opt, "major=")) {
                                opt = strchr (opt, '=') + 1;
-                               major_collector_opt = g_strdup (opt);
+                               sgen_major = parse_sgen_major (opt);
                        } else if (g_str_has_prefix (opt, "minor=")) {
                                opt = strchr (opt, '=') + 1;
-                               minor_collector_opt = g_strdup (opt);
+                               sgen_minor = parse_sgen_minor (opt);
+                       } else if (g_str_has_prefix (opt, "mode=")) {
+                               opt = strchr (opt, '=') + 1;
+                               sgen_mode = parse_sgen_mode (opt);
                        }
                }
        } else {
@@ -3083,34 +3260,13 @@ sgen_gc_init (void)
 
        sgen_client_init ();
 
-       if (!minor_collector_opt) {
-               sgen_simple_nursery_init (&sgen_minor_collector, FALSE);
+       if (sgen_mode != SGEN_MODE_NONE) {
+               if (sgen_minor != SGEN_MINOR_DEFAULT || sgen_major != SGEN_MAJOR_DEFAULT)
+                       sgen_env_var_error (MONO_GC_PARAMS_NAME, "Ignoring major/minor configuration", "Major/minor configurations cannot be used with sgen modes");
+               init_sgen_mode (sgen_mode);
        } else {
-               if (!strcmp (minor_collector_opt, "simple")) {
-               use_simple_nursery:
-                       sgen_simple_nursery_init (&sgen_minor_collector, FALSE);
-               } else if (!strcmp (minor_collector_opt, "simple-par")) {
-                       sgen_simple_nursery_init (&sgen_minor_collector, TRUE);
-               } else if (!strcmp (minor_collector_opt, "split")) {
-                       sgen_split_nursery_init (&sgen_minor_collector);
-               } else {
-                       sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using `simple` instead.", "Unknown minor collector `%s'.", minor_collector_opt);
-                       goto use_simple_nursery;
-               }
-       }
-
-       if (!major_collector_opt) {
-       use_default_major:
-               DEFAULT_MAJOR_INIT (&major_collector);
-       } else if (!strcmp (major_collector_opt, "marksweep")) {
-               sgen_marksweep_init (&major_collector);
-       } else if (!strcmp (major_collector_opt, "marksweep-conc")) {
-               sgen_marksweep_conc_init (&major_collector);
-       } else if (!strcmp (major_collector_opt, "marksweep-conc-par")) {
-               sgen_marksweep_conc_par_init (&major_collector);
-       } else {
-               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using `" DEFAULT_MAJOR_NAME "` instead.", "Unknown major collector `%s'.", major_collector_opt);
-               goto use_default_major;
+               init_sgen_minor (sgen_minor);
+               init_sgen_major (sgen_major);
        }
 
        if (opts) {
@@ -3124,6 +3280,17 @@ sgen_gc_init (void)
                                continue;
                        if (g_str_has_prefix (opt, "minor="))
                                continue;
+                       if (g_str_has_prefix (opt, "mode=")) {
+                               if (g_str_has_prefix (opt, "mode=pause:")) {
+                                       char *str_pause = strchr (opt, ':') + 1;
+                                       int pause = atoi (str_pause);
+                                       if (pause)
+                                               sgen_max_pause_time = pause;
+                                       else
+                                               sgen_env_var_error (MONO_GC_PARAMS_NAME, "Using default", "Invalid maximum pause time for `pause` sgen mode");
+                               }
+                               continue;
+                       }
                        if (g_str_has_prefix (opt, "max-heap-size=")) {
                                size_t page_size = mono_pagesize ();
                                size_t max_heap_candidate = 0;
@@ -3239,6 +3406,7 @@ sgen_gc_init (void)
                        fprintf (stderr, "\n%s must be a comma-delimited list of one or more of the following:\n", MONO_GC_PARAMS_NAME);
                        fprintf (stderr, "  max-heap-size=N (where N is an integer, possibly with a k, m or a g suffix)\n");
                        fprintf (stderr, "  soft-heap-limit=n (where N is an integer, possibly with a k, m or a g suffix)\n");
+                       fprintf (stderr, "  mode=MODE (where MODE is 'balanced', 'throughput' or 'pause[:N]' and N is maximum pause in milliseconds)\n");
                        fprintf (stderr, "  nursery-size=N (where N is an integer, possibly with a k, m or a g suffix)\n");
                        fprintf (stderr, "  major=COLLECTOR (where COLLECTOR is `marksweep', `marksweep-conc', `marksweep-par')\n");
                        fprintf (stderr, "  minor=COLLECTOR (where COLLECTOR is `simple' or `split')\n");
@@ -3260,12 +3428,6 @@ sgen_gc_init (void)
                g_strfreev (opts);
        }
 
-       if (major_collector_opt)
-               g_free (major_collector_opt);
-
-       if (minor_collector_opt)
-               g_free (minor_collector_opt);
-
        if (params_opts)
                g_free (params_opts);
 
@@ -3435,12 +3597,15 @@ sgen_gc_init (void)
        if (major_collector.is_concurrent || sgen_minor_collector.is_parallel) {
                int num_workers = 1;
                if (major_collector.is_parallel || sgen_minor_collector.is_parallel) {
-                       /* FIXME Detect the number of physical cores, instead of logical */
-                       num_workers = mono_cpu_count () / 2;
-                       if (num_workers < 1)
+                       num_workers = mono_cpu_count ();
+                       if (num_workers <= 1) {
                                num_workers = 1;
+                               major_collector.is_parallel = FALSE;
+                               sgen_minor_collector.is_parallel = FALSE;
+                       }
                }
-               sgen_workers_init (num_workers, (SgenWorkerCallback) major_collector.worker_init_cb);
+               if (major_collector.is_concurrent || sgen_minor_collector.is_parallel)
+                       sgen_workers_init (num_workers, (SgenWorkerCallback) major_collector.worker_init_cb);
        }
 
        sgen_memgov_init (max_heap, soft_limit, debug_print_allowance, allowance_ratio, save_target);
index 82d637d2b2674c12cca0fb0331d4966fe8085a6f..8d3252eb186d6879d8028a80f42acce32ba7d8ca 100644 (file)
@@ -314,7 +314,7 @@ should_work_func (void *data_untyped)
        WorkerData *data = (WorkerData*)data_untyped;
        int current_worker = (int) (data - workers_data);
 
-       return started && current_worker < active_workers_num;
+       return started && current_worker < active_workers_num && state_is_working_or_enqueued (data->state);
 }
 
 static void
index d9722a14c2a5a1d30076ba146c8d224ad4f303d7..351d439e3713b3fb4abea69087e30aed7ee7b077 100755 (executable)
@@ -463,6 +463,7 @@ TESTS_CS_SRC=               \
        assemblyresolve_event2.2.cs     \
        appdomain-unload-callback.cs    \
        appdomain-unload-doesnot-raise-pending-events.cs        \
+       appdomain-unload-asmload.cs     \
        unload-appdomain-on-shutdown.cs \
        bug-47295.cs    \
        loader.cs       \
@@ -706,92 +707,6 @@ PLATFORM_DISABLED_TESTS += \
        sgen-bridge-xref.exe
 endif
 
-if NACL_CODEGEN
-# Tests that use Thread.Abort()
-PLATFORM_DISABLED_TESTS= abort-stress-1.exe \
-                         abort-stress-2.exe \
-                         abort-stress-3.exe \
-                         appdomain-thread-abort.exe \
-                         async-exc-compilation.exe \
-                         bug-561239.exe \
-                         bug-70561.exe \
-                         finalizer-abort.exe \
-                         finally_guard.exe \
-                         finally_block_ending_in_dead_bb.exe \
-                         main-returns-abort-resetabort.exe \
-                         main-returns-background-abort-resetabort.exe \
-                         thread6.exe \
-                         threadpool-exceptions5.exe \
-                         threadpool-exceptions6.exe
-
-PLATFORM_DISABLED_TESTS+= w32message.exe
-
-# Tests that rely on AppDomain.Unload
-PLATFORM_DISABLED_TESTS+= appdomain-async-invoke.exe \
-                          appdomain-exit.exe \
-                          appdomain-unload-callback.exe \
-                          appdomain-unload.exe \
-                          domain-stress.exe \
-                          generic-unloading.2.exe \
-                          monitor.exe \
-                          remoting4.exe \
-                          threadpool-exceptions7.exe \
-                          xdomain-threads.exe
-
-# pinvoke2 attaches a thread to the runtime, but
-# doesn't 'unattach' it and it hangs in GC on exit
-PLATFORM_DISABLED_TESTS+= pinvoke2.exe
-
-# Tests that currently hang waiting for non-main threads
-# to exit in NaCl, need to investigate.  Most are AppDomain
-# creation and Delegate tests.
-PLATFORM_DISABLED_TESTS+= appdomain1.exe \
-                          delegate9.exe \
-                          marshal-valuetypes.exe \
-                          cross-domain.exe \
-                          stackframes-async.2.exe \
-                          generic-marshalbyref.2.exe \
-                          generic-xdomain.2.exe \
-                          bug-415577.exe
-
-# Tests that fail trying to write files (appdomain create mostly)
-PLATFORM_DISABLED_TESTS+= bug-335131.2.exe \
-                          bug-349190.2.exe \
-                          bug-80307.exe \
-                          bug-462592.exe
-
-# FIXME: don't know why delegate2.exe fails, it shouldn't
-PLATFORM_DISABLED_TESTS+= delegate2.exe
-
-# These tests newly fail with the latest revision. pinvoke3 fails because
-# of a thread attach, the others have not been investigated.  TODO revisit.
-PLATFORM_DISABLED_TESTS+= pinvoke3.exe \
-                          async_read.exe \
-                          async-with-cb-throws.exe \
-                          appdomain-unload-doesnot-raise-pending-events.exe \
-                          gsharing-valuetype-layout.exe
-
-if X86
-# FIXME: There are problems with async callbacks and results on NaCl 32-bit
-PLATFORM_DISABLED_TESTS+= delegate1.exe \
-                          delegate3.exe \
-                          delegate5.exe \
-                          delegate8.exe \
-                          threadpool.exe \
-                          threadpool1.exe \
-                          threadpool-exceptions3.exe \
-                          bug-323114.exe \
-                          delegate-exit.exe \
-                          bug-80392.2.exe
-
-# FIXME: These tests hang/fail for unknown reasons, deal with exiting
-PLATFORM_DISABLED_TESTS+= main-returns-background-resetabort.exe \
-                          main-returns-background.exe \
-                          main-returns-background-change.exe
-endif
-
-endif
-
 if ENABLE_COOP
 COOP_DISABLED_TESTS= thunks.exe
 else
@@ -820,7 +735,9 @@ PROFILE_DISABLED_TESTS += \
        vt-sync-method.exe \
        resolve_method_bug.2.exe \
        resolve_field_bug.2.exe \
-       resolve_type_bug.2.exe
+       resolve_type_bug.2.exe \
+       bug-81691.exe \
+       bug-327438.2.exe
 
 # Tests which rely on remoting
 PROFILE_DISABLED_TESTS += \
@@ -864,6 +781,7 @@ PROFILE_DISABLED_TESTS += \
        appdomain1.exe  \
        appdomain2.exe  \
        appdomain-exit.exe      \
+       appdomain-unload-asmload.exe \
        appdomain-unload-callback.exe   \
        appdomain-unload-doesnot-raise-pending-events.exe       \
        unload-appdomain-on-shutdown.exe        \
@@ -943,7 +861,9 @@ PROFILE_DISABLED_TESTS += \
        sgen-domain-unload-2.exe
 
 PROFILE_DISABLED_TESTS += \
-       appdomain-loader.exe
+       appdomain-loader.exe \
+       assemblyresolve_event3.exe \
+       appdomain-serialize-exception.exe
 endif
 
 if HYBRID_AOT_TESTS
@@ -981,7 +901,6 @@ LLVM = $(filter --llvm, $(MONO_ENV_OPTIONS))
 # delegate-invoke.exe depends on 929c6bc9b6d76a273f251e6f5dfacac36e9c38bd which was
 # reverted.
 # bug-Xamarin-5278.exe got broken by 5d26590e79da139a284459299aee95c25f4cd835
-# bug-45841-fpstack-exceptions.exe: https://bugzilla.xamarin.com/show_bug.cgi?id=47053
 # appdomain-thread-abort.exe: https://bugzilla.xamarin.com/show_bug.cgi?id=47054
 KNOWN_FAILING_TESTS = \
        delegate-async-exception.exe    \
@@ -989,7 +908,6 @@ KNOWN_FAILING_TESTS = \
        bug-459094.exe \
        delegate-invoke.exe \
        bug-Xamarin-5278.exe \
-       bug-45841-fpstack-exceptions.exe \
        appdomain-thread-abort.exe
 
 DISABLED_TESTS = \
@@ -1012,6 +930,7 @@ INTERP_DISABLED_TESTS = \
        appdomain-async-invoke.exe \
        appdomain-exit.exe \
        appdomain-serialize-exception.exe \
+       appdomain-unload-asmload.exe \
        appdomain-unload-callback.exe \
        appdomain-unload-doesnot-raise-pending-events.exe \
        appdomain-unload.exe \
@@ -1030,6 +949,7 @@ INTERP_DISABLED_TESTS = \
        bug-327438.2.exe \
        bug-335131.2.exe \
        bug-415577.exe \
+       bug-45841-fpstack-exceptions.exe \
        bug-461867.exe \
        bug-461941.exe \
        bug-46661.exe \
@@ -1214,8 +1134,6 @@ tests: compile-tests
 #
 # Test that no symbols are missed in eglib-remap.h
 #
-if NACL_CODEGEN
-else
 if PLATFORM_LINUX
 test-platform: test-eglib-remap
 else
@@ -1223,7 +1141,6 @@ if PLATFORM_DARWIN
 test-platform: test-eglib-remap
 endif
 endif
-endif
 # The following regexp describes all symbols that start with "g_" but are not part of eglibc.
 # The optional underscore prepending symbol names may or may not appear depending on the
 # system and the state of the leading-underscore compiler flag.
@@ -1922,12 +1839,8 @@ test-generic-sharing-normal: $(TESTS_GSHARED) $(TESTSAOT_GSHARED)
 test-generic-sharing-managed: test-runner.exe $(TESTS_GSHARED) $(TESTSAOT_GSHARED) 
        $(Q) $(TOOLS_RUNTIME) $(TEST_RUNNER) -j a --testsuite-name "gshared" --disabled "$(DISABLED_TESTS)" --opt-sets "gshared gshared,shared gshared,-inline gshared,-inline,shared" $(TESTS_GSHARED)
 
-if NACL_CODEGEN
-test-generic-sharing:
-else
 test-generic-sharing:
        @if test x$(M) != x0; then $(MAKE) test-generic-sharing-managed; else $(MAKE) test-generic-sharing-normal; fi
-endif
 
 EXTRA_DIST += async-exceptions.cs
 async-exceptions.exe : async-exceptions.cs
@@ -1950,16 +1863,12 @@ patch-libtool:
        touch libtest.c
 
 
-if NACL_CODEGEN
-test-process-exit:
-else
 EXTRA_DIST += threadpool-in-processexit.cs threadpool-in-processexit.exe.stdout.expected
 test-process-exit:
        @$(MCS) $(srcdir)/threadpool-in-processexit.cs -out:threadpool-in-processexit.exe
        @echo "Testing threadpool-in-processexit.exe..."
        @$(RUNTIME) threadpool-in-processexit.exe > threadpool-in-processexit.exe.stdout
        @diff -w threadpool-in-processexit.exe.stdout $(srcdir)/threadpool-in-processexit.exe.stdout.expected
-endif
 
 # tests that expect a 1 exit code
 TESTS_UNHANDLED_EXCEPTION_1_SRC =      \
diff --git a/mono/tests/appdomain-unload-asmload.cs b/mono/tests/appdomain-unload-asmload.cs
new file mode 100644 (file)
index 0000000..5f79890
--- /dev/null
@@ -0,0 +1,57 @@
+using System;
+using System.Threading.Tasks;
+
+/* This is a regression test that checks that after an AssemblyLoad event fires
+ * in a domain, the domain can be unloaded.  In bug # 56694, a
+ * System.Reflection.Assembly object from the unloaded domain was kept alive
+ * and crashed the GC.  */
+namespace AppDomainUnloadAsmLoad
+{
+       class Program
+       {
+               static void Main(string[] args)
+               {
+                       // Need some threads in play
+                       new Program().Run().Wait();
+               }
+
+               private async Task Run()
+               {
+                       var appDomain = AppDomain.CreateDomain("Test subdomain", null, AppDomain.CurrentDomain.SetupInformation);
+                       try
+                       {
+                               var driver = (AppDomainTestDriver)appDomain.CreateInstanceAndUnwrap(typeof(AppDomainTestDriver).Assembly.FullName,
+                                                                                                   typeof(AppDomainTestDriver).FullName);
+                               driver.Test();
+                       }
+                       finally
+                       {
+                               AppDomain.Unload(appDomain);
+                       }
+               }
+       }
+
+       class AppDomainTestDriver : MarshalByRefObject
+       {
+               static AppDomainTestDriver()
+               {
+                       // Needs a callback so that the runtime fires the
+                       // AssembyLoad event for this domain and materializes a System.Reflection.Assembly
+                       AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;
+               }
+
+               private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
+               {
+               }
+
+               internal void Test()
+               {
+                       /* this can be any class from any assembly that hasn't
+                        * already been loaded into the test domain.
+                        * System.Xml.dll is good because all the tests link
+                        * against it, but it's not otherwise used by this
+                        * domain. */
+                       var foo = default(System.Xml.XmlException);
+               }
+    }
+}
index d6574763760ba04232a3924b931ff059bb9caa38..74117c2ba7179430dfb3ff1e9f46ec1723cb232d 100644 (file)
@@ -41,7 +41,7 @@
     .locals init (valuetype [System.Data]System.Data.SqlTypes.SqlDecimal V_0)
     .try
     {
-               ldc.r8 5
+       ldstr "Exception 1"
        newobj     instance void [mscorlib]System.OverflowException::.ctor(string)
        throw
                          pop
@@ -57,7 +57,7 @@
     IL_0021:  nop
     .try
     {
-               ldc.r8 5
+       ldstr "Exception 2"
        newobj     instance void [mscorlib]System.OverflowException::.ctor(string)
        throw
                          pop
@@ -73,7 +73,7 @@
     IL_0033:  nop
     .try
     {
-               ldc.r8 5
+       ldstr "Exception 3"
        newobj     instance void [mscorlib]System.OverflowException::.ctor(string)
        throw
       IL_0044:  leave.s    IL_0049
@@ -88,7 +88,7 @@
     IL_0049:  nop
     .try
     {
-               ldc.r8 5
+       ldstr "Exception 4"
        newobj     instance void [mscorlib]System.OverflowException::.ctor(string)
        throw
                pop
     IL_005f:  nop
     .try
     {
-               ldc.r8 5
+       ldstr "Exception 5"
        newobj     instance void [mscorlib]System.OverflowException::.ctor(string)
        throw
                pop
     IL_0071:  nop
     .try
     {
-               ldc.r8 5
+       ldstr "Exception 6"
        newobj     instance void [mscorlib]System.OverflowException::.ctor(string)
        throw
                pop
index cc86c7387d0b7728ac01e1d8733786d3b6f4c907..aecae40401d0b921845a313fde973fe7d126c7cc 100644 (file)
@@ -533,6 +533,9 @@ public class Tests
                        if (TestITestDelegate (itest) != 0)
                                return 174;
 
+                       if (TestIfaceNoIcall (itest as ITestPresSig) != 0)
+                               return 201;
+
                        itest = new TestClass ();
 
                        if (TestITest (itest) != 0)
@@ -543,6 +546,7 @@ public class Tests
                        if (TestITest (itest) != 0)
                                return 176;
 
+
 #endif
 
                        #endregion // Runtime Callable Wrapper Tests
@@ -775,6 +779,7 @@ public class Tests
                void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val);
                [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
                void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val);
+               int Return22NoICall();
        }
 
        [ComImport ()]
@@ -826,6 +831,8 @@ public class Tests
                [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
                [PreserveSig ()]
                int ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITestPresSig val);
+               [PreserveSig ()]
+               int Return22NoICall();
        }
 
        [System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000002")]
@@ -865,6 +872,9 @@ public class Tests
                public virtual extern void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val);
                [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
                public virtual extern void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val);
+
+               [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+               public virtual extern int Return22NoICall();
        }
 
        [System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000002")]
@@ -1004,6 +1014,11 @@ public class Tests
                        val = new ManagedTestPresSig ();
                        return 0;
                }
+
+               public int Return22NoICall()
+               {
+                       return 88;
+               }
        }
 
        public class ManagedTest : ITest
@@ -1093,6 +1108,11 @@ public class Tests
                                return new ManagedTest ();
                        }
                }
+
+               public int Return22NoICall()
+               {
+                       return 99;
+               }
        }
 
        public static int mono_test_marshal_variant_in_callback (VarEnum vt, object obj)
@@ -1306,6 +1326,10 @@ public class Tests
                }
                return 0;
        }
+
+       public static int TestIfaceNoIcall (ITestPresSig itest) {
+               return itest.Return22NoICall () == 22 ? 0 : 1;
+       }
 }
 
 public class TestVisible
index 4517eda2f74f64ddc41f8e2453372f4b17e5fd12..b94b29d52fd8eae95c11e0877adcc1269a91093d 100644 (file)
@@ -3337,6 +3337,7 @@ typedef struct
        int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
        int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
        int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
+       int (STDCALL *Return22NoICall)(MonoComObject* pUnk);
 } MonoIUnknown;
 
 struct MonoComObject
@@ -3453,6 +3454,13 @@ ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
        return S_OK;
 }
 
+LIBTEST_API int STDCALL
+Return22NoICall(MonoComObject* pUnk)
+{
+       return 22;
+}
+
+
 static void create_com_object (MonoComObject** pOut);
 
 LIBTEST_API int STDCALL 
@@ -3484,6 +3492,7 @@ static void create_com_object (MonoComObject** pOut)
        (*pOut)->vtbl->ITestIn = ITestIn;
        (*pOut)->vtbl->ITestOut = ITestOut;
        (*pOut)->vtbl->get_ITest = get_ITest;
+       (*pOut)->vtbl->Return22NoICall = Return22NoICall;
 }
 
 static MonoComObject* same_object = NULL;
index 8a0d43f3a3660255097fa2cb59e9e21a2f399697..05550ac2277e360581cabe68284d821f3fd55787 100644 (file)
@@ -277,4 +277,20 @@ public class Tests {
                        return 1;
                return 0;
        }
+
+       public static int test_0_generic_ptr_to_struct () {
+               int size = Marshal.SizeOf (typeof (SimpleStruct2));
+               IntPtr p = Marshal.AllocHGlobal (size);
+
+               Marshal.WriteInt32 (p, 0, 1); //a
+               Marshal.WriteInt32 (p, 4, 2); //a
+
+               var s = Marshal.PtrToStructure<SimpleStruct2> (p);
+
+               if (s.a != 1)
+                       return 1;
+               if (s.b != 2)
+                       return 2;
+               return 0;
+       }
 }
index 1a4e30a68f3ed7cd3d522643eeb9c4ba993ad204..275f8c0153458a8db6f3c8c1d46e9167117bc61c 100644 (file)
@@ -59,6 +59,8 @@ APP_V1_SRC = v1/app.cs v1/app-refl-load.cs
 
 APP_SIGNED_V1_EXE = app-v1.exe app-refl-load-v1.exe
 
+APP_BOTH_EXE = app-both.exe
+
 UNSIGNED_V1_DLL= unsigned_v1/gactestlib.dll
 UNSIGNED_V2_DLL= unsigned_v2/gactestlib.dll
 
@@ -68,15 +70,15 @@ SIGNED_V2_DLL= signed_v2/gactestlib.dll
 GACTESTLIB_SRCS= $(V1_SRC) $(V2_SRC)
 GACTESTLIB_DLLS= $(SIGNED_V1_DLL) $(SIGNED_V2_DLL) $(UNSIGNED_V1_DLL) $(UNSIGNED_V2_DLL)
 
-if FULL_AOT_TESTS
-GACTESTLIB_DLLS_AOT=$(GACTESTLIB_DLLS:.dll=.dll$(PLATFORM_AOT_SUFFIX))
-APP_SIGNED_V1_AOT=$(APP_SIGNED_V1_EXE:.exe=.exe$(PLATFORM_AOT_SUFFIX))
-endif
+#if FULL_AOT_TESTS
+#GACTESTLIB_DLLS_AOT=$(GACTESTLIB_DLLS:.dll=.dll$(PLATFORM_AOT_SUFFIX))
+#APP_SIGNED_V1_AOT=$(APP_SIGNED_V1_EXE:.exe=.exe$(PLATFORM_AOT_SUFFIX))
+#endif
 
-if HYBRID_AOT_TESTS
-GACTESTLIB_DLLS_AOT=$(GACTESTLIB_DLLS:.dll=.dll$(PLATFORM_AOT_SUFFIX))
-APP_SIGNED_V1_AOT=$(APP_SIGNED_V1_EXE:.exe=.exe$(PLATFORM_AOT_SUFFIX))
-endif
+#if HYBRID_AOT_TESTS
+#GACTESTLIB_DLLS_AOT=$(GACTESTLIB_DLLS:.dll=.dll$(PLATFORM_AOT_SUFFIX))
+#APP_SIGNED_V1_AOT=$(APP_SIGNED_V1_EXE:.exe=.exe$(PLATFORM_AOT_SUFFIX))
+#endif
 
 
 SIGNING_KEY= $(srcdir)/testkey.snk
@@ -96,8 +98,10 @@ EXTRA_DIST= README $(SIGNING_KEY) $(GACTESTLIB_SRCS)
 .PHONY: runtest compile-tests prereqs
 
 runtest:
+       true
 if !FULL_AOT_TESTS
 if !HYBRID_AOT_TESTS
+       $(MAKE) test-app-both
        $(MAKE) test-signed-v1-app-mp-unsigned-v1
        $(MAKE) test-signed-v1-app-mp-signed-v1
        $(MAKE) test-signed-v1-app-mp-unsigned-v2-signed-v1
@@ -106,7 +110,7 @@ if !HYBRID_AOT_TESTS
 endif
 endif
 
-compile-tests: prereqs $(APP_SIGNED_V1_EXE) $(APP_SIGNED_V1_AOT)
+compile-tests: prereqs $(APP_SIGNED_V1_EXE) $(APP_BOTH_EXE) $(APP_SIGNED_V1_AOT)
 
 prereqs: $(GACTESTLIB_DLLS) $(GACTESTLIB_DLLS_AOT)
        $(MAKE) gacinstall
@@ -127,6 +131,9 @@ $(SIGNED_V2_DLL): $(V2_SRC) $(SIGNING_KEY)
        -mkdir -p $(@D)
        $(MCS) -out:$@ $(SIGN) $< && $(TOOLS_RUNTIME) $(SN) -R $@ $(SIGNING_KEY)
 
+app-both.exe: app-both.cs $(SIGNED_V1_DLL) $(SIGNED_V2_DLL)
+       $(MCS) -target:exe -out:$@ -r:V1=$(SIGNED_V1_DLL) /r:V2=$(SIGNED_V2_DLL) $<
+
 %-v1.exe: v1/%.cs $(SIGNED_V1_DLL)
        $(MCS) -target:exe -out:$@ -r:$(SIGNED_V1_DLL) $<
 
@@ -150,6 +157,10 @@ test-signed-v1-app-mp-unsigned-v2-signed-v1: $(APP_SIGNED_V1_EXE) prereqs
 test-signed-v1-app-mp-signed-v2-signed-v1: $(APP_SIGNED_V1_EXE) prereqs
        $(TOOLS_RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name "testing_gac_$@" --mono-path "signed_v2$(PLATFORM_PATH_SEPARATOR)signed_v1$(PLATFORM_PATH_SEPARATOR)$(BASE_MONO_PATH)" $(APP_SIGNED_V1_EXE)
 
+# N.B. the path order is important - the test needs to load v1 successfully and then try to load v2 from the v1 directory.
+test-app-both: $(APP_BOTH_EXE) prereqs
+       $(TOOLS_RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name "testing_gac_$@" --mono-path "signed_v1$(PLATFORM_PATH_SEPARATOR)signed_v2$(PLATFORM_PATH_SEPARATOR)$(BASE_MONO_PATH)" app-both.exe
+
 # MONO_GAC_PREFIX tests
 
 test-signed-v1-app-gac: $(APP_SIGNED_V1_EXE) gacinstall prereqs
diff --git a/mono/tests/testing_gac/app-both.cs b/mono/tests/testing_gac/app-both.cs
new file mode 100644 (file)
index 0000000..ae32d3e
--- /dev/null
@@ -0,0 +1,23 @@
+
+// reference both versions of gactestlib via extern aliases.
+
+// N.B. the order of the aliases is important - the compiler will emit
+// .assembly declarations in the IL file in order, and Mono will try to load the declarations in the same order.
+// The test relies on V1 being loaded first and then V2 being tried from V1's MONO_PATH directory.
+extern alias V1;
+extern alias V2;
+
+using System;
+
+public class AppBoth {
+       public static int Main (string[] args) {
+               // regression test that references two strongly named
+               // assemblies that have the same name but different versions.
+               V1.OnlyInV1.M ();
+               V2.OnlyInV2.M ();
+               if (typeof (V1.X).Assembly.GetName ().Version == typeof (V2.X).Assembly.GetName ().Version)
+                       return 1;
+
+               return 0;
+       }
+}
index 1ced863e6a7feeb9fb56bbe5e95c1a4caed9196b..fad4fbb0c1ce69b64b988eda42e332781fcec157 100644 (file)
@@ -13,3 +13,7 @@ public class X
        }
 
 }
+
+public class OnlyInV1 {
+       public static void M () { }
+}
index 85ae29627cf7b6a07c1df5fae6f56cc0050cbfe1..2cfa666bfcdc3802cf673f9da7183e50c6f6147f 100644 (file)
@@ -13,3 +13,7 @@ public class X
        // {
        // }
 }
+
+public class OnlyInV2 {
+       public static void M () { }
+}
index b2c969ba0bd0cbfd5a79ecebc4eeb6f8732856cb..ec04c4d1c5f17f5df5dab43b834893dc048783f1 100644 (file)
@@ -10,6 +10,7 @@ endif
 if !CROSS_COMPILE
 if !HOST_WIN32
 if SUPPORT_BOEHM
+if SUPPORT_SGEN
 
 noinst_LTLIBRARIES = libtestlib.la
 libtestlib_la_SOURCES =
@@ -54,6 +55,7 @@ check-local:
                echo "</test-case></results></test-suite></test-results>" >> TestResult-unit-tests.xml; \
        fi;
 
+endif SUPPORT_SGEN
 endif SUPPORT_BOEHM
 endif !HOST_WIN32
 endif !CROSS_COMPILE
index 3177f2d17a1194f5ebc59fbea7382990120a4db5..296893ff2e7f2a77a8e7b5e46f4684d45421b8a4 100644 (file)
@@ -484,13 +484,6 @@ DEFAULT_MMAP_THRESHOLD       default: 256K
 #endif  /* HAVE_MORECORE */
 #endif  /* DARWIN */
 
-#if defined(__native_client__)
-#undef HAVE_MMAP
-#undef HAVE_MREMAP
-#define HAVE_MMAP 0
-#define HAVE_MREMAP 0
-#endif
-
 #ifndef LACKS_SYS_TYPES_H
 #include <sys/types.h>  /* For size_t */
 #endif  /* LACKS_SYS_TYPES_H */
index efbe9f03e7a28eeed84c76c2c110f7ce3bf16f6e..3861e54f5e6a04b75c661be7308939c904008859 100644 (file)
@@ -36,7 +36,7 @@
 void
 mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 {
-#if defined (__native_client__) || defined (HOST_WATCHOS)
+#if defined (HOST_WATCHOS)
        printf("WARNING: mono_arch_sigctx_to_monoctx() called!\n");
        mctx->eax = 0xDEADBEEF;
        mctx->ebx = 0xDEADBEEF;
@@ -95,13 +95,13 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
        mctx->esi = ctx->SC_ESI;
        mctx->edi = ctx->SC_EDI;
        mctx->eip = ctx->SC_EIP;
-#endif /* if defined(__native_client__) */
+#endif
 }
 
 void
 mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 {
-#if defined(__native_client__) || defined(HOST_WATCHOS)
+#if defined(HOST_WATCHOS)
        printf("WARNING: mono_arch_monoctx_to_sigctx() called!\n");
 #elif MONO_CROSS_COMPILE
        g_assert_not_reached ();
@@ -151,7 +151,7 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
        ctx->SC_ESI = mctx->esi;
        ctx->SC_EDI = mctx->edi;
        ctx->SC_EIP = mctx->eip;
-#endif /* __native_client__ */
+#endif
 }
 
 #elif (defined(__x86_64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_AMD64)) /* defined(__i386__) */
@@ -165,10 +165,6 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 void
 mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 {
-#if defined(__native_client_codegen__) || defined(__native_client__)
-       printf("WARNING: mono_arch_sigctx_to_monoctx() called!\n");
-#endif
-
 #ifdef MONO_CROSS_COMPILE
        g_assert_not_reached ();
 #elif defined(MONO_SIGNAL_USE_UCONTEXT_T)
@@ -239,10 +235,6 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 void
 mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 {
-#if defined(__native_client__) || defined(__native_client_codegen__)
-  printf("WARNING: mono_arch_monoctx_to_sigctx() called!\n");
-#endif
-
 #ifdef MONO_CROSS_COMPILE
        g_assert_not_reached ();
 #elif defined(MONO_SIGNAL_USE_UCONTEXT_T)
@@ -358,8 +350,6 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 {
 #ifdef MONO_CROSS_COMPILE
        g_assert_not_reached ();
-#elif defined(__native_client__)
-       g_assert_not_reached ();
 #else
        arm_ucontext *my_uc = sigctx;
 
@@ -378,8 +368,6 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *ctx)
 {
 #ifdef MONO_CROSS_COMPILE
        g_assert_not_reached ();
-#elif defined(__native_client__)
-       g_assert_not_reached ();
 #else
        arm_ucontext *my_uc = ctx;
 
index 3cc722f0aae7d7909614be82bc9b3f14ab41b121..b26442f73f5c7897e5ec9da2bf1881399dacf2fa 100644 (file)
@@ -44,10 +44,6 @@ typedef struct __darwin_xmm_reg MonoContextSimdReg;
 #endif
 #endif
 
-#if defined(__native_client__)
-#undef MONO_SIGNAL_USE_UCONTEXT_T
-#endif
-
 #ifdef __HAIKU__
 /* sigcontext surrogate */
 struct sigcontext {
@@ -213,7 +209,7 @@ typedef struct {
 
 #include <mono/arch/amd64/amd64-codegen.h>
 
-#if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__)
+#if !defined( HOST_WIN32 )
 
 #if defined(HAVE_SIGACTION) || defined(__APPLE__)  // the __APPLE__ check is required for the tvos simulator, which has ucontext_t but not sigaction
 #define MONO_SIGNAL_USE_UCONTEXT_T 1
@@ -243,30 +239,6 @@ typedef struct {
 extern void mono_context_get_current (void *);
 #define MONO_CONTEXT_GET_CURRENT(ctx) do { mono_context_get_current((void*)&(ctx)); } while (0)
 
-#elif defined(__native_client__)
-#define MONO_CONTEXT_GET_CURRENT(ctx)  \
-       __asm__ __volatile__(   \
-               "movq $0x0,  %%nacl:0x00(%%r15, %0, 1)\n"       \
-               "movq %%rcx, %%nacl:0x08(%%r15, %0, 1)\n"       \
-               "movq %%rdx, %%nacl:0x10(%%r15, %0, 1)\n"       \
-               "movq %%rbx, %%nacl:0x18(%%r15, %0, 1)\n"       \
-               "movq %%rsp, %%nacl:0x20(%%r15, %0, 1)\n"       \
-               "movq %%rbp, %%nacl:0x28(%%r15, %0, 1)\n"       \
-               "movq %%rsi, %%nacl:0x30(%%r15, %0, 1)\n"       \
-               "movq %%rdi, %%nacl:0x38(%%r15, %0, 1)\n"       \
-               "movq %%r8,  %%nacl:0x40(%%r15, %0, 1)\n"       \
-               "movq %%r9,  %%nacl:0x48(%%r15, %0, 1)\n"       \
-               "movq %%r10, %%nacl:0x50(%%r15, %0, 1)\n"       \
-               "movq %%r11, %%nacl:0x58(%%r15, %0, 1)\n"       \
-               "movq %%r12, %%nacl:0x60(%%r15, %0, 1)\n"       \
-               "movq %%r13, %%nacl:0x68(%%r15, %0, 1)\n"       \
-               "movq %%r14, %%nacl:0x70(%%r15, %0, 1)\n"       \
-               "movq %%r15, %%nacl:0x78(%%r15, %0, 1)\n"       \
-               "leaq (%%rip), %%rdx\n" \
-               "movq %%rdx, %%nacl:0x80(%%r15, %0, 1)\n"       \
-               :       \
-               : "a" ((int64_t)&(ctx)) \
-               : "rdx", "memory")
 #else
 
 #define MONO_CONTEXT_GET_CURRENT_GREGS(ctx) \
index ac7747c8799f9f0f12b53613a2d9e45627d159fc..333617edc92d8a5d59cb359cc15e9fd25e3d7445 100644 (file)
@@ -12,9 +12,9 @@
 #define MONO_SOLIB_EXT ".dll"
 #elif defined(__ppc__) && defined(TARGET_MACH)
 #define MONO_SOLIB_EXT ".dylib"
-#elif defined(TARGET_MACH) && defined(TARGET_X86) && !defined(__native_client_codegen__)
+#elif defined(TARGET_MACH) && defined(TARGET_X86)
 #define MONO_SOLIB_EXT ".dylib"
-#elif defined(TARGET_MACH) && defined(TARGET_AMD64) && !defined(__native_client_codegen__)
+#elif defined(TARGET_MACH) && defined(TARGET_AMD64)
 #define MONO_SOLIB_EXT ".dylib"
 #else
 #define MONO_SOLIB_EXT ".so"
index 4bd214d4dddc26787ab4c8c702c5cf667f74a08e..f66ff902e1d6c90a0e0931559ac618b743a0ac29 100644 (file)
@@ -331,20 +331,6 @@ mono_file_unmap (void *addr, void *handle)
  * \p length must be a multiple of the page size.
  * \returns \c 0 on success.
  */
-#if defined(__native_client__)
-int
-mono_mprotect (void *addr, size_t length, int flags)
-{
-       int prot = prot_from_flags (flags);
-       void *new_addr;
-
-       if (flags & MONO_MMAP_DISCARD) memset (addr, 0, length);
-
-       new_addr = mmap(addr, length, prot, MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
-       if (new_addr == addr) return 0;
-        return -1;
-}
-#else
 int
 mono_mprotect (void *addr, size_t length, int flags)
 {
@@ -367,7 +353,6 @@ mono_mprotect (void *addr, size_t length, int flags)
        }
        return mprotect (addr, length, prot);
 }
-#endif // __native_client__
 
 #else
 
index f733896a6d73ae9a4997347724b5790488230aa4..5c5b891d607ab952d55bc3699d857566c6ce9c64 100644 (file)
@@ -131,11 +131,11 @@ mono_process_list (int *size)
                mib [2] = KERN_PROC_ALL;
                mib [3] = 0;
 
-               res = sysctl (mib, 4, NULL, &data_len, NULL, 0);
+               res = sysctl (mib, 3, NULL, &data_len, NULL, 0);
                if (res)
                        return NULL;
                processes = (struct kinfo_proc *) g_malloc (data_len);
-               res = sysctl (mib, 4, processes, &data_len, NULL, 0);
+               res = sysctl (mib, 3, processes, &data_len, NULL, 0);
                if (res < 0) {
                        g_free (processes);
                        if (errno != ENOMEM)
index 13b8a32393716ec9473ce9d9e4bbd9ef6e849087..fc6b61f2c4f35e07cb76b816c269411391dba48c 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifdef HOST_WIN32
 // Windows specific implementation in mono-rand-windows.c
-#elif defined (HAVE_SYS_UN_H) && !defined(__native_client__)
+#elif defined (HAVE_SYS_UN_H)
 
 #include <errno.h>
 #include <fcntl.h>
index 1dbb223608647398daaa6ff780b70fc868a889ad..289bd98cd66e2faa8c61063213ce5aba2de7d38e 100644 (file)
@@ -39,8 +39,6 @@ mono_threads_suspend_search_alternative_signal (void)
 #endif
 }
 
-#ifndef __native_client__
-
 static int suspend_signal_num = -1;
 static int restart_signal_num = -1;
 static int abort_signal_num = -1;
@@ -274,33 +272,4 @@ mono_threads_suspend_get_abort_signal (void)
        return abort_signal_num;
 }
 
-#else
-
-void
-mono_threads_suspend_init_signals (void)
-{
-       g_assert_not_reached ();
-}
-
-gint
-mono_threads_suspend_get_suspend_signal (void)
-{
-       return -1;
-}
-
-gint
-mono_threads_suspend_get_restart_signal (void)
-{
-       return -1;
-}
-
-gint
-mono_threads_suspend_get_abort_signal (void)
-{
-       return -1;
-}
-
-#endif /* __native_client__ */
-
-
 #endif /* defined(USE_POSIX_BACKEND) */
index 9ee2a77402de20bebbca6cabbd61ec0a3f7917bd..5d0e1ab29112e3e8b0ce624e2cbd257a6519f077 100644 (file)
@@ -30,7 +30,7 @@
 extern int tkill (pid_t tid, int signal);
 #endif
 
-#if defined(_POSIX_VERSION) || defined(__native_client__)
+#if defined(_POSIX_VERSION)
 
 #include <pthread.h>
 
@@ -150,9 +150,6 @@ mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
                errno = old_errno;
        }
        return result;
-#elif defined(__native_client__)
-       /* Workaround pthread_kill abort() in NaCl glibc. */
-       return 0;
 #elif !defined(HAVE_PTHREAD_KILL)
        g_error ("pthread_kill() is not supported by this platform");
 #else
@@ -234,7 +231,7 @@ mono_native_thread_join (MonoNativeThreadId tid)
        return !pthread_join (tid, &res);
 }
 
-#endif /* defined(_POSIX_VERSION) || defined(__native_client__) */
+#endif /* defined(_POSIX_VERSION) */
 
 #if defined(USE_POSIX_BACKEND)
 
index e6d151ce2566c841cfdba4ae8d1f083d30bfcfa6..6afb74daf8de35618dbe6a1374f9100aaf64c124 100644 (file)
@@ -1029,16 +1029,21 @@ STW to make sure no unsafe pending suspend is in progress.
 static void
 mono_thread_info_suspend_lock_with_info (MonoThreadInfo *info)
 {
-       g_assert (info);
-       g_assert (mono_thread_info_is_current (info));
-       g_assert (mono_thread_info_is_live (info));
+       if (mono_threads_is_coop_enabled ()) {
+               g_assert (info);
+               g_assert (mono_thread_info_is_current (info));
+               g_assert (mono_thread_info_is_live (info));
 
-       MONO_ENTER_GC_SAFE_WITH_INFO(info);
+               MONO_ENTER_GC_SAFE_WITH_INFO(info);
 
-       int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE);
-       g_assert (res != -1);
+               int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE);
+               g_assert (res != -1);
 
-       MONO_EXIT_GC_SAFE_WITH_INFO;
+               MONO_EXIT_GC_SAFE_WITH_INFO;
+       } else {
+               int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE);
+               g_assert (res != -1);
+       }
 }
 
 void
@@ -1310,10 +1315,6 @@ mono_thread_info_tls_set (THREAD_INFO_TYPE *info, MonoTlsKey key, gpointer value
        ((MonoThreadInfo*)info)->tls [key] = value;
 }
 
-#if defined(__native_client__)
-void nacl_shutdown_gc_thread(void);
-#endif
-
 /*
  * mono_thread_info_exit:
  *
@@ -1323,10 +1324,6 @@ void nacl_shutdown_gc_thread(void);
 void
 mono_thread_info_exit (gsize exit_code)
 {
-#if defined(__native_client__)
-       nacl_shutdown_gc_thread();
-#endif
-
        mono_thread_info_detach ();
 
        mono_threads_platform_exit (0);
index dc26a4ac42e8d8b4068467a2c90f92cab9025208..63cad57d86825aeaf3e3b15d60737fe9d5b252c2 100644 (file)
@@ -109,7 +109,7 @@ and reduce the number of casts drastically.
 /* If this is defined, use the signals backed on Mach. Debug only as signals can't be made usable on OSX. */
 // #define USE_SIGNALS_ON_MACH
 
-#if defined (_POSIX_VERSION) || defined (__native_client__)
+#if defined (_POSIX_VERSION)
 #if defined (__MACH__) && !defined (USE_SIGNALS_ON_MACH)
 #define USE_MACH_BACKEND
 #else
@@ -119,7 +119,7 @@ and reduce the number of casts drastically.
 #define USE_WINDOWS_BACKEND
 #else
 #error "no backend support for current platform"
-#endif /* defined (_POSIX_VERSION) || defined (__native_client__) */
+#endif /* defined (_POSIX_VERSION) */
 
 enum {
        STATE_STARTING                          = 0x00,
index 987689a9cd8e946671fd35f5ae4d42c39cc61a30..c3615d14bbedc53d4cabf12999b183a2f2a42ad9 100644 (file)
@@ -275,11 +275,7 @@ my_g_bit_nth_lsf (gsize mask, gint nth_bit)
        if ((mask == 0) || (nth_bit == BITS_PER_CHUNK))
                return -1;
 
-#if defined(__native_client__) && (defined(__i386__) || defined(__x86_64))
-#define USE_X86_32BIT_INSTRUCTIONS 1
-#endif
-
-#if (defined(__i386__) && defined(__GNUC__)) || defined(USE_X86_32BIT_INSTRUCTIONS)
+#if (defined(__i386__) && defined(__GNUC__))
  {
         int r;
         /* This depends on mask != 0 */
@@ -309,7 +305,7 @@ static inline gint
 my_g_bit_nth_lsf_nomask (gsize mask)
 {
        /* Mask is expected to be != 0 */
-#if (defined(__i386__) && defined(__GNUC__)) || defined(USE_X86_32BIT_INSTRUCTIONS)
+#if (defined(__i386__) && defined(__GNUC__))
        int r;
 
        __asm__("bsfl %1,%0\n\t"
index f5449aa086c20d8e6a2b95bcd9a3c28021cba134..70dc4b0554c6eb8d780d1a2c8dcd7feb348ab91a 100644 (file)
     <ClCompile Include="..\mono\mini\mini-native-types.c" />\r
     <ClCompile Include="..\mono\mini\type-checking.c" />\r
     <ClCompile Include="..\mono\mini\lldb.c" />\r
+    <ClCompile Include="..\mono\mini\interp\interp-stubs.c" />\r
   </ItemGroup>\r
   <PropertyGroup Label="Globals">\r
     <ProjectGuid>{CB0D9E92-293C-439C-9AC7-C5F59B6E0772}</ProjectGuid>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets">\r
   </ImportGroup>\r
-</Project>
\ No newline at end of file
+</Project>\r
index 3ff2406521426133728ed01ee90cfdaa43931fda..029b9d162c15144f2740162e2726bb56fb2572ac 100644 (file)
     <ClCompile Include="..\mono\mini\lldb.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\mono\mini\interp\interp-stubs.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\mono\mini\abcremoval.h">\r
       <Filter>Resource Files</Filter>\r
     </None>\r
   </ItemGroup>\r
-</Project>
\ No newline at end of file
+</Project>\r
index f97a30f3ad3272a71563edd11aa30c0d295676e4..904bb51f570fc0b934a3977016f1380de8f2fd7b 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
 <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
   <ItemGroup Label="ProjectConfigurations">\r
     <ProjectConfiguration Include="Debug|Win32">\r
@@ -75,9 +75,9 @@
     <ClCompile Include="..\mono\metadata\mono-debug.c" />\r
     <ClCompile Include="..\mono\metadata\mono-endian.c" />\r
     <ClCompile Include="..\mono\metadata\mono-hash.c" />\r
+    <ClCompile Include="..\mono\metadata\mono-conc-hash.c" />\r
     <ClCompile Include="..\mono\metadata\mono-mlist.c" />\r
     <ClCompile Include="..\mono\metadata\mono-perfcounters.c" />\r
-    <ClCompile Include="..\mono\metadata\nacl-stub.c" />\r
     <ClCompile Include="..\mono\metadata\null-gc.c" />\r
     <ClCompile Include="..\mono\metadata\number-ms.c" />\r
     <ClCompile Include="..\mono\metadata\object.c" />\r
     <ClInclude Include="..\mono\metadata\mono-debug.h" />\r
     <ClInclude Include="..\mono\metadata\mono-endian.h" />\r
     <ClInclude Include="..\mono\metadata\mono-hash.h" />\r
+    <ClInclude Include="..\mono\metadata\mono-conc-hash.h" />\r
     <ClInclude Include="..\mono\metadata\mono-mlist.h" />\r
     <ClInclude Include="..\mono\metadata\mono-perfcounters-def.h" />\r
     <ClInclude Include="..\mono\metadata\mono-perfcounters.h" />\r
index 6a76b77a4e9ccd2776decdcd439d1b4dd4d65d53..6c8dcdfb4fe6c64f05c3335567d566570843348a 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>\r
+<?xml version="1.0" encoding="utf-8"?>\r
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
   <ItemGroup>\r
     <ClCompile Include="..\mono\metadata\assembly.c">\r
     <ClCompile Include="..\mono\metadata\mono-security.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\mono\metadata\nacl-stub.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\mono\metadata\null-gc.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClCompile Include="..\mono\metadata\mono-hash.c">\r
       <Filter>Source Files\gc</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\mono\metadata\mono-conc-hash.c">\r
+      <Filter>Source Files\gc</Filter>\r
+    </ClCompile>\r
     <ClCompile Include="..\mono\metadata\object.c">\r
       <Filter>Source Files\gc</Filter>\r
     </ClCompile>\r
     <ClInclude Include="..\mono\metadata\mono-hash.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\mono\metadata\mono-conc-hash.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
     <ClInclude Include="..\mono\metadata\mono-mlist.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
diff --git a/nacl/README b/nacl/README
deleted file mode 100644 (file)
index 03a77ba..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Building NaCl Mono with glibc (newlib support is eliminated but should still be buildable with small effort) is complex.  Instructions live here for the adventurous: https://docs.google.com/a/google.com/document/d/1Jd_4M7mlmxF8daVbepAy_8RKYcRbhifXanRYyBKkVa4/pub
-
diff --git a/nacl/common.sh b/nacl/common.sh
deleted file mode 100644 (file)
index 65e7dc7..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-# Copyright (c) 2011 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that be
-# found in the LICENSE file.
-#
-
-set -o nounset
-set -o errexit
-
-# scripts that source this file must be run from within packages tree
-readonly SAVE_PWD=$(pwd)
-
-# Pick platform directory for compiler.
-readonly OS_NAME=$(uname -s)
-if [ $OS_NAME = "Darwin" ]; then
-  readonly OS_SUBDIR="mac"
-  readonly OS_SUBDIR_SHORT="mac"
-elif [ $OS_NAME = "Linux" ]; then
-  readonly OS_SUBDIR="linux"
-  readonly OS_SUBDIR_SHORT="linux"
-else
-  readonly OS_SUBDIR="windows"
-  readonly OS_SUBDIR_SHORT="win"
-fi
-
-readonly MACHINE=$(uname -m)
-if [ $MACHINE = "x86_64" ]; then
-  readonly TARGET_BITSIZE=${TARGET_BITSIZE:-"64"}
-  readonly HOST_BITSIZE=${HOST_BITSIZE:-"64"}
-else
-  # uname -m reports i686 on Linux and i386 on Mac
-  readonly TARGET_BITSIZE=${TARGET_BITSIZE:-"32"}
-  readonly HOST_BITSIZE=${HOST_BITSIZE:-"32"}
-fi
-
-if [ $TARGET_BITSIZE == "64" ]; then
-  readonly TARGET_BIT_PREFIX="64"
-  readonly CROSS_ID=x86_64
-else
-  readonly TARGET_BIT_PREFIX=""
-  readonly CROSS_ID=i686
-fi
-# we might want to override the detected host platform (e.g. on OSX 10.6)
-if [ $HOST_BITSIZE == "64" ]; then
-  readonly HOST_BIT_PREFIX="64"
-else
-  readonly HOST_BIT_PREFIX=""
-fi
-
-export NACL_CROSS_PREFIX=${CROSS_ID}-nacl
-export NACL_CROSS_PREFIX_DASH=${NACL_CROSS_PREFIX}-
-
-readonly NACL_NEWLIB=${NACL_NEWLIB:-"0"}
-
-if [ $NACL_NEWLIB = "1" ]; then
-  readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_newlib
-else
-case "${NACL_SDK_ROOT}" in
-*pepper_15* | *pepper_16* | *pepper_17*)
-  readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86
-  ;;
-*)
-  readonly NACL_SDK_BASE=${NACL_SDK_ROOT}/toolchain/${OS_SUBDIR_SHORT}_x86_glibc
-  ;;
-esac
-fi
-
-readonly NACL_BIN_PATH=${NACL_SDK_BASE}/bin
-export NACLCC=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}gcc
-export NACLCXX=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}g++
-export NACLAR=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ar
-export NACLRANLIB=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ranlib
-export NACLLD=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}ld
-export NACLAS=${NACL_BIN_PATH}/${NACL_CROSS_PREFIX_DASH}as
-
-# NACL_SDK_GCC_SPECS_PATH is where nacl-gcc 'specs' file will be installed
-readonly NACL_SDK_GCC_SPECS_PATH=${NACL_SDK_BASE}/lib/gcc/x86_64-nacl/4.4.3
-
-# NACL_SDK_USR is where the headers, libraries, etc. will be installed
-readonly NACL_SDK_USR=${NACL_SDK_BASE}/${NACL_CROSS_PREFIX}/usr
-readonly NACL_SDK_USR_INCLUDE=${NACL_SDK_USR}/include
-readonly NACL_SDK_USR_LIB=${NACL_SDK_USR}/lib
-
-
-######################################################################
-# Helper functions
-######################################################################
-
-Banner() {
-  echo "######################################################################"
-  echo $*
-  echo "######################################################################"
-}
-
-
-VerifyPath() {
-  # make sure path isn't all slashes (possibly from an unset variable)
-  local PATH=$1
-  local TRIM=${PATH##/}
-  if [ ${#TRIM} -ne 0 ]; then
-    return 0
-  else
-    return 1
-  fi
-}
-
-
-ChangeDir() {
-  local NAME=$1
-  if VerifyPath ${NAME}; then
-    cd ${NAME}
-  else
-    echo "ChangeDir called with bad path."
-    exit -1
-  fi
-}
-
-
-Remove() {
-  local NAME=$1
-  if VerifyPath ${NAME}; then
-    rm -rf ${NAME}
-  else
-    echo "Remove called with bad path."
-    exit -1
-  fi
-}
-
-
-MakeDir() {
-  local NAME=$1
-  if VerifyPath ${NAME}; then
-    mkdir -p ${NAME}
-  else
-    echo "MakeDir called with bad path."
-    exit -1
-  fi
-}
-
-
-PatchSpecFile() {
-  # fix up spaces so gcc sees entire path
-  local SED_SAFE_SPACES_USR_INCLUDE=${NACL_SDK_USR_INCLUDE/ /\ /}
-  local SED_SAFE_SPACES_USR_LIB=${NACL_SDK_USR_LIB/ /\ /}
-  # have nacl-gcc dump specs file & add include & lib search paths
-  ${NACL_SDK_BASE}/bin/x86_64-nacl-gcc -dumpspecs |\
-    sed "/*cpp:/{
-      N
-      s|$| -I${SED_SAFE_SPACES_USR_INCLUDE}|
-    }" |\
-    sed "/*link_libgcc:/{
-      N
-      s|$| -L${SED_SAFE_SPACES_USR_LIB}|
-    }" >${NACL_SDK_GCC_SPECS_PATH}/specs
-}
-
-
-DefaultConfigureStep() {
-  Banner "Configuring ${PACKAGE_NAME}"
-  # export the nacl tools
-  export CC=${NACLCC}
-  export CXX=${NACLCXX}
-  export AR=${NACLAR}
-  export RANLIB=${NACLRANLIB}
-  export PKG_CONFIG_PATH=${NACL_SDK_USR_LIB}/pkgconfig
-  export PKG_CONFIG_LIBDIR=${NACL_SDK_USR_LIB}
-  export PATH=${NACL_BIN_PATH}:${PATH};
-  ChangeDir ${NACL_PACKAGES_REPOSITORY}/${PACKAGE_NAME}
-  Remove ${PACKAGE_NAME}-build
-  MakeDir ${PACKAGE_NAME}-build
-  cd ${PACKAGE_NAME}-build
-  ../configure \
-    --host=nacl \
-    --disable-shared \
-    --prefix=${NACL_SDK_USR} \
-    --exec-prefix=${NACL_SDK_USR} \
-    --libdir=${NACL_SDK_USR_LIB} \
-    --oldincludedir=${NACL_SDK_USR_INCLUDE} \
-    --with-http=off \
-    --with-html=off \
-    --with-ftp=off \
-    --with-x=no
-}
-
-
-DefaultBuildStep() {
-  # assumes pwd has makefile
-  make clean
-if [ $TARGET_BITSIZE == "64" ]; then
-  make -j8
-else
-  make
-fi
-}
-
-
-DefaultInstallStep() {
-  # assumes pwd has makefile
-  make install
-}
-
-
-DefaultCleanUpStep() {
-  PatchSpecFile
-  ChangeDir ${SAVE_PWD}
-}
-
-
-DefaultPackageInstall() {
-  DefaultPreInstallStep
-  DefaultDownloadStep
-  DefaultExtractStep
-  DefaultPatchStep
-  DefaultConfigureStep
-  DefaultBuildStep
-  DefaultInstallStep
-  DefaultCleanUpStep
-}
diff --git a/nacl/config-nacl-runtime.cache b/nacl/config-nacl-runtime.cache
deleted file mode 100644 (file)
index 4bd26c4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-ac_cv_func_mmap=${ac_cv_func_mmap=no}
-ac_cv_var_timezone=${ac_cv_var_timezone=yes}
-ac_cv_host=${ac_cv_host=i686-pc-nacl}
-ac_cv_target=${ac_cv_target=i686-pc-nacl}
-ac_cv_func_backtrace_symbols=${ac_cv_func_backtrace_symbols=no}
-mono_cv_uscore=${mono_cv_uscore=no}
diff --git a/nacl/config-nacl-runtime64.cache b/nacl/config-nacl-runtime64.cache
deleted file mode 100644 (file)
index b952fef..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-ac_cv_func_mmap=${ac_cv_func_mmap=no}
-ac_cv_var_timezone=${ac_cv_var_timezone=yes}
-ac_cv_host=${ac_cv_host=x86_64-pc-nacl}
-ac_cv_target=${ac_cv_target=x86_64-pc-nacl}
-ac_cv_func_backtrace_symbols=${ac_cv_func_backtrace_symbols=no}
-mono_cv_uscore=${mono_cv_uscore=no}
diff --git a/nacl/nacl-runtime-mono.sh b/nacl/nacl-runtime-mono.sh
deleted file mode 100755 (executable)
index d93bb97..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2009 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that be
-# found in the LICENSE file.
-#
-
-# nacl-runtime-mono.sh
-#
-# usage:  nacl-runtime-mono.sh
-#
-# this script builds mono runtime for Native Client 
-#
-
-readonly MONO_TRUNK_NACL=$(pwd)
-
-source common.sh
-
-readonly PACKAGE_NAME=runtime${TARGET_BIT_PREFIX}-build
-readonly INSTALL_PATH=${MONO_TRUNK_NACL}/naclmono-${CROSS_ID}
-
-
-CustomConfigureStep() {
-  Banner "Configuring ${PACKAGE_NAME}"
-  # export the nacl tools
-  set +e
-  if [ -f ${PACKAGE_NAME}/Makefile ]
-  then
-    cd ${PACKAGE_NAME}
-  fi
-  make distclean
-  cd ${MONO_TRUNK_NACL}
-  set -e
-  if [ $TARGET_BITSIZE == "32" ]; then
-    CONFIG_OPTS="--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu"
-  else
-    CONFIG_OPTS="--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu"
-  fi
-  # UGLY hack to allow dynamic linking
-  sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ ../configure
-  sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ ../libgc/configure
-  sed -i -e s/elf_i386/elf_nacl/ -e s/elf_x86_64/elf64_nacl/ ../eglib/configure
-  Remove ${PACKAGE_NAME}
-  MakeDir ${PACKAGE_NAME}
-  cd ${PACKAGE_NAME}
-  CC=${NACLCC} CXX=${NACLCXX} AR=${NACLAR} RANLIB=${NACLRANLIB} PKG_CONFIG_PATH=${NACL_SDK_USR_LIB}/pkgconfig LD="${NACLLD}" \
-  PKG_CONFIG_LIBDIR=${NACL_SDK_USR_LIB} PATH=${NACL_BIN_PATH}:${PATH} LIBS="-lnacl_dyncode -lc -lg -lnosys -lnacl" \
-  CFLAGS="-g -O2 -D_POSIX_PATH_MAX=256 -DPATH_MAX=256" ../../configure \
-    ${CONFIG_OPTS} \
-    --exec-prefix=${INSTALL_PATH} \
-    --libdir=${INSTALL_PATH}/lib \
-    --prefix=${INSTALL_PATH} \
-    --program-prefix="" \
-    --oldincludedir=${INSTALL_PATH}/include \
-    --with-glib=embedded \
-    --with-tls=pthread \
-    --enable-threads=posix \
-    --without-sigaltstack \
-    --without-mmap \
-    --with-gc=included \
-    --enable-nacl-gc \
-    --with-sgen=no \
-    --enable-nls=no \
-    --enable-nacl-codegen \
-    --disable-system-aot \
-    --enable-shared \
-    --disable-parallel-mark \
-    --with-static-mono=no
-
-}
-
-CustomInstallStep() {
-  make install
-}
-
-CustomPackageInstall() {
-  CustomConfigureStep
-  DefaultBuildStep
-  CustomInstallStep
-}
-
-CustomPackageInstall
-exit 0
diff --git a/nacl/nacl_interp_loader_sdk.sh b/nacl/nacl_interp_loader_sdk.sh
deleted file mode 100755 (executable)
index 1e4bd31..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2012 The Native Client Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Usage: nacl_interp_loader.sh PLATFORM NEXE ARGS...
-
-# Assumes this file is sitting in the source tree.
-# This should be changed for some proper SDK installation setup.
-NACL_SDK_ROOT=${NACL_SDK_ROOT:-/path/to/naclsdk/pepper_XX}
-
-case "$1" in
-i?86)
-  arch=x86_32
-  libdir=lib32
-  ;;
-x86_64)
-  arch=x86_64
-  libdir=lib64
-  ;;
-arm|v7l)
-  arch=arm
-  libdir=lib32
-  ;;
-*)
-  echo >&2 "$0: Do not recognize architecture \"$1\""
-  exit 127
-  ;;
-esac
-
-shift
-
-case "${NACL_SDK_ROOT}" in
-*pepper_15* | *pepper_16* | *pepper_17*)
-  SEL_LDR="$NACL_SDK_ROOT/toolchain/linux_x86/bin/sel_ldr_${arch}"
-  IRT="$NACL_SDK_ROOT/toolchain/linux_x86/runtime/irt_core_${arch}.nexe"
-  RTLD="$NACL_SDK_ROOT/toolchain/linux_x86/x86_64-nacl/${libdir}/runnable-ld.so"
-  LIBDIR="$NACL_SDK_ROOT/toolchain/linux_x86/x86_64-nacl/${libdir}"
-  ;;
-*)
-  SEL_LDR="$NACL_SDK_ROOT/tools/sel_ldr_${arch}"
-  IRT="$NACL_SDK_ROOT/tools/irt_core_${arch}.nexe"
-  RTLD="$NACL_SDK_ROOT/toolchain/linux_x86_glibc/x86_64-nacl/${libdir}/runnable-ld.so"
-  LIBDIR="$NACL_SDK_ROOT/toolchain/linux_x86_glibc/x86_64-nacl/${libdir}"
-  ;;
-esac
-
-IGNORE_VALIDATOR_ARG=""
-if [ x"$NACL_IGNORE_VALIDATOR" == x"1" ]; then
-  IGNORE_VALIDATOR_ARG="-c"
-fi
-
-exec "$SEL_LDR" -E "NACL_PWD=`pwd`" -E "MONO_PATH=$MONO_PATH" \
-  -E "MONO_CFG_DIR=$MONO_CFG_DIR" -E "MONO_SHARED_DIR=$MONO_SHARED_DIR" \
-  -a $IGNORE_VALIDATOR_ARG -S -B "$IRT" -l /dev/null -- "$RTLD" \
-  --library-path $LIBDIR "$@"
index 9122ba00a96db0f1f351eef841acc39c1c8de562..a426ac95347631ffa09560ce45bc1fd64d9adc0a 100644 (file)
@@ -591,10 +591,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "commoncryptogenerator-net_4
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "resx2sr-net_4_x", "mcs/tools/resx2sr/resx2sr-net_4_x.csproj", "{07D30676-A919-4763-8C3C-B2C4DAFFC662}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "al-net_4_x", "mcs/tools/al/al-net_4_x.csproj", "{D237CE6E-EA8F-4E8E-8413-295B27714AC6}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "monolinker-net_4_x", "mcs/tools/linker/monolinker-net_4_x.csproj", "{FA920637-C202-4E75-AC0F-1A8DBD631DF1}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "al-net_4_x", "mcs/tools/al/al-net_4_x.csproj", "{D237CE6E-EA8F-4E8E-8413-295B27714AC6}"
+EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "genxs-net_4_x", "mcs/tools/genxs/genxs-net_4_x.csproj", "{DCD2613C-B1A0-489B-BCA1-79BEBB9B9541}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mkbundle-net_4_x", "mcs/tools/mkbundle/mkbundle-net_4_x.csproj", "{3A3DAEC2-3DF4-4968-A191-8D6F207ABA5E}"
@@ -1865,14 +1865,14 @@ Global
                {07D30676-A919-4763-8C3C-B2C4DAFFC662}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {07D30676-A919-4763-8C3C-B2C4DAFFC662}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {07D30676-A919-4763-8C3C-B2C4DAFFC662}.Release|Any CPU.Build.0 = Release|Any CPU
-               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Release|Any CPU.Build.0 = Release|Any CPU
                {FA920637-C202-4E75-AC0F-1A8DBD631DF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {FA920637-C202-4E75-AC0F-1A8DBD631DF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {FA920637-C202-4E75-AC0F-1A8DBD631DF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {FA920637-C202-4E75-AC0F-1A8DBD631DF1}.Release|Any CPU.Build.0 = Release|Any CPU
+               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {D237CE6E-EA8F-4E8E-8413-295B27714AC6}.Release|Any CPU.Build.0 = Release|Any CPU
                {DCD2613C-B1A0-489B-BCA1-79BEBB9B9541}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {DCD2613C-B1A0-489B-BCA1-79BEBB9B9541}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {DCD2613C-B1A0-489B-BCA1-79BEBB9B9541}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/packaging/.gitignore b/packaging/.gitignore
new file mode 100644 (file)
index 0000000..be1aeeb
--- /dev/null
@@ -0,0 +1,2 @@
+*.pyo
+
index e40baac24a60de35f24de559a598a2f68e7ad6ab..bfb2c70ddbb74ec79e952a456fe2f6893be02da9 100644 (file)
@@ -1,8 +1,8 @@
 GitHubTarballPackage(
     'mono',
     'libgdiplus',
-    '2.11',
-    '4e7ab0f555a13a6b2f954c714c4ee5213954ff79',
+    '5.4',
+    '350eb49a45ca5a7383c01d49df72438347a5dbc9',
     configure='CFLAGS="%{gcc_flags} %{local_gcc_flags} -I/opt/X11/include" ./autogen.sh --prefix="%{package_prefix}"',
     override_properties={
         'make': 'C_INCLUDE_PATH="" make'})
index ed9de8174840f455d66a849a89cb377b9086b268..34f7afe3107adc49b5e64a6826bf9dbba2b59bdd 100644 (file)
@@ -85,16 +85,16 @@ class MonoMasterPackage(Package):
             "LocalMachine")
         ensure_dir(registry_dir)
 
-        # Add ImportBefore/ImportAfter files from xbuild to the msbuild
-        # directories
+        # Add ImportBefore files from xbuild 14.0 toolsVersion directory to msbuild's
+        # 15.0 directory
         xbuild_dir = os.path.join(self.staged_prefix, 'lib/mono/xbuild')
-        new_xbuild_tv_dir = os.path.join(xbuild_dir, self.version)
+        new_xbuild_tv_dir = os.path.join(xbuild_dir, '15.0')
         os.makedirs(new_xbuild_tv_dir)
 
         self.sh('cp -R %s/14.0/Imports %s' % (xbuild_dir, new_xbuild_tv_dir))
-        self.sh(
-            'cp -R %s/14.0/Microsoft.Common.targets %s' %
-            (xbuild_dir, new_xbuild_tv_dir))
+
+        for dep in glob.glob("%s/Microsoft/NuGet/*" % xbuild_dir):
+            self.sh('ln -s %s %s' % (dep, xbuild_dir))
 
     def deploy(self):
         if bockbuild.cmd_options.arch == 'darwin-universal':
index 09cacd29d87d14ce5699c848d135a41e8585394c..fd05dcb18d7da0901c48e892863dc9278a81af02 100644 (file)
@@ -2,7 +2,7 @@ import fileinput
 
 class MSBuild (GitHubPackage):
        def __init__ (self):
-               GitHubPackage.__init__ (self, 'mono', 'msbuild', '15.0',
+               GitHubPackage.__init__ (self, 'mono', 'msbuild', '15.3',
                        git_branch = 'xplat-master')
 
        def build (self):
index 321bedfa12d6ea59649e87b6dba9020e98f10df3..a28b37c0a07b0cb1c751d8609805712c93f7e6df 100644 (file)
@@ -1,18 +1,26 @@
+import fileinput
 
-class NuGetPackage(GitHubPackage):
+
+class NuGetBinary (Package):
 
     def __init__(self):
-        GitHubPackage.__init__(self,
-                               'mono', 'nuget',
-                               '2.12.0',
-                               '9e2d2c1cc09d2a40eeb72e8c5db789e3b9bf2586',
-                               configure='')
+        Package.__init__(self, name='NuGet', version='4.3.0-preview1', sources=[
+                         'https://dist.nuget.org/win-x86-commandline/v%{version}/nuget.exe'])
 
     def build(self):
-        self.sh('%{make} update_submodules')
-        self.sh('%{make} PREFIX=%{package_prefix}')
+        pass
 
     def install(self):
-        self.sh('%{makeinstall} PREFIX=%{staged_prefix}')
+        source = os.path.join(self.workspace, 'nuget.exe')
+        target = os.path.join(self.staged_prefix, 'lib/mono/nuget/nuget.exe')
+        ensure_dir(os.path.dirname(target))
+        shutil.move(source, target)
 
-NuGetPackage()
+        launcher = os.path.join(self.staged_prefix, "bin/nuget")
+        ensure_dir(os.path.dirname(launcher))
+        with open(launcher, "w") as output:
+            output.write("#!/bin/sh\n")
+            output.write(
+                'exec {0}/bin/mono $MONO_OPTIONS {1} "$@"\n'.format(self.staged_prefix, target))
+        os.chmod(launcher, 0o755)
+NuGetBinary()
index 34d3ae0c650bb0297bb8560c22e2e8ee8f3b0b72..6df28bc78390d0f3d7ce5f7456e9319c3fa13ab9 100644 (file)
@@ -4,7 +4,7 @@ class XamarinGtkThemePackage (Package):
         Package.__init__(self, 'xamarin-gtk-theme',
                          sources=[
                              'git://github.com/mono/xamarin-gtk-theme.git'],
-                         revision='cc3fb66e56d494e968be3a529a0737a60e31c1f3')
+                         revision='b7fe407d869dfeac4eacbcb82771f600e0bbaa83')
 
     def build(self):
         try:
index 2d52fdae9731b7685a601996c03c3c47e394418b..a1c6eeb7c36c83cd9b17f01bcde612ce6074c38a 100644 (file)
@@ -7,7 +7,8 @@ class MonoExtensionsPackage(Package):
         Package.__init__(self, 'mono-extensions', None,
                          sources=['git@github.com:xamarin/mono-extensions.git'],
                          git_branch=self.profile.release_packages[
-                             'mono'].git_branch
+                             'mono'].git_branch,
+                         revision='07ad37d63e0e9dcf7c879a72bc14c5d6c794f7b6'
                          )
         self.source_dir_name = 'mono-extensions'
 
diff --git a/packaging/Windows/.gitattributes b/packaging/Windows/.gitattributes
new file mode 100644 (file)
index 0000000..eefd12f
--- /dev/null
@@ -0,0 +1,6 @@
+mono-MDK-windows crlf=input
+mono-MDK-windows-x64 crlf=input
+defs/gtksharp crlf=input
+defs/managed-components crlf=input
+defs/mono crlf=input
+defs/mono64 crlf=input
diff --git a/packaging/Windows/defs/gtksharp b/packaging/Windows/defs/gtksharp
new file mode 100755 (executable)
index 0000000..8633d74
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash -xe
+
+REPO="https://dl.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.44.msi"
+REPODIR=$(dirname $(realpath $0))/../repos/gtksharp
+
+error()
+{
+    echo "$(date "+%F@%T") :: $1" 1>&2
+    exit 1
+}
+
+report()
+{
+    echo "$(date "+%F@%T") :: $1"
+}
+
+download()
+{
+       mkdir -p ${REPODIR}
+       if [ ! -d "${REPODIR}/lessmsi" ]
+               then report "Downloading LessMSIerables"
+               wget --quiet -O ${REPODIR}/lessmsi.zip https://github.com/activescott/lessmsi/releases/download/v1.2.0/lessmsi-v1.2.0.zip
+               mkdir -p ${REPODIR}/lessmsi
+               unzip -d ${REPODIR}/lessmsi ${REPODIR}/lessmsi.zip
+               chmod a+x ${REPODIR}/lessmsi/*.exe ${REPODIR}/lessmsi/*.dll
+       fi
+       report "Downloading GTK# for Windows - ${REPO}"
+       wget --quiet -O ${REPODIR}/gtksharp.msi ${REPO}
+}
+
+clean()
+{
+       pushd ${REPODIR}
+       report "Deleting interstitial output"
+       rm -rf  ${REPODIR}/gtksharp
+       popd
+}
+
+build()
+{
+       pushd ${REPODIR}
+       report "Unpacking GTK# for Windows"
+       mkdir -p gtksharp
+       pushd lessmsi
+       ./lessmsi.exe x ../gtksharp.msi
+       mv gtksharp/SourceDir/PFiles/GtkSharp/2.12/* ../gtksharp
+       rm -rf gtksharp
+       popd
+       popd
+}
+
+install()
+{
+       pushd ${REPODIR}
+       cp -r gtksharp/etc/* ../../tmp/mono/etc/
+       cp -r gtksharp/bin/* ../../tmp/mono/bin/
+       cp -r gtksharp/lib/* ../../tmp/mono/lib/
+       cp -r gtksharp/share/* ../../tmp/mono/share/
+       pushd ../../tmp/mono/
+       for i in lib/gtk-sharp-2.0/*.dll
+               do bin/gacutil -i $i
+       done
+       popd
+       cp -r ../../resources/pkgconfig ../../tmp/mono/lib/
+       popd
+}
+
+prerequisites()
+{
+       which wget              2>/dev/null || error "*** wget is not in \$PATH ***"
+}
+
+$@
diff --git a/packaging/Windows/defs/managed-components b/packaging/Windows/defs/managed-components
new file mode 100755 (executable)
index 0000000..3d94ec7
--- /dev/null
@@ -0,0 +1,133 @@
+#!/bin/bash -xe
+
+REPODIR=$(dirname $(realpath $0))/../repos/managed-components
+
+error()
+{
+    echo "$(date "+%F@%T") :: $1" 1>&2
+    exit 1
+}
+
+report()
+{
+    echo "$(date "+%F@%T") :: $1"
+}
+
+download()
+{
+       mkdir -p ${REPODIR}
+       report "Downloading Xar"
+       wget --quiet -O ${REPODIR}/xar.tar.gz https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/xar/xar-1.5.2.tar.gz || error "*** Could not download Xar ***"
+       report "Copying Mono MDK for Mac"
+       cp $1 ${REPODIR}/mono.xar
+}
+
+clean()
+{
+       pushd ${REPODIR}
+       report "Deleting interstitial output"
+       rm -rf  ${REPODIR}/mono-mac \
+               ${REPODIR}/xar \
+               ${REPODIR}/Distribution \
+               ${REPODIR}/mono.pkg \
+               ${REPODIR}/Resources \
+               ${REPODIR}/Library \
+               ${REPODIR}/../../tmp/mono-mac
+       popd
+}
+
+build()
+{
+       pushd ${REPODIR}
+       if [ ! -x "${REPODIR}/xar/src/xar" ]
+               then report "Building Xar"
+               mkdir -p xar
+               tar xf xar.tar.gz -C xar/ --strip-components=1
+               pushd xar/
+               ./configure
+               make
+               popd
+       fi
+       report "Unpacking Mono for Mac"
+       xar/src/xar -x -f mono.xar
+       zcat mono.pkg/Payload | bsdcpio -i
+       mv Library/Frameworks/Mono.framework/Versions/5.* mono-mac
+       popd
+}
+
+install()
+{
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/ironpython                                ${REPODIR}/../../tmp/mono/lib/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/ironruby                                  ${REPODIR}/../../tmp/mono/lib/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/xsp                                       ${REPODIR}/../../tmp/mono/lib/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/Microsoft*                           ${REPODIR}/../../tmp/mono/lib/mono/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/msbuild                              ${REPODIR}/../../tmp/mono/lib/mono/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/nuget                                ${REPODIR}/../../tmp/mono/lib/mono/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/xbuild-frameworks                    ${REPODIR}/../../tmp/mono/lib/mono/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/gac/FSharp.Core/4.4.1.0__b03f5f7f11d50a3a/FSharp*                            ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/gac/nunit*/2.4.8.0__96d09a1eb7f44a77/*.dll*                                  ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/4.5/Microsoft.VisualBasic.dll        ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/4.5/Mono.Cecil.VB*                   ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/4.5/Mono.WebServer2.dll              ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/4.5/vbnc.*                           ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/4.5/xsp4.exe                         ${REPODIR}/../../tmp/mono/lib/mono/4.5/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/fsharp                               ${REPODIR}/../../tmp/mono/lib/mono/
+       rsync -a --copy-links ${REPODIR}/mono-mac/lib/mono/4.0-api/Microsoft.VisualBasic.dll    ${REPODIR}/../../tmp/mono/lib/mono/4.0-api/
+       rsync -a --copy-links ${REPODIR}/mono-mac/bin/ir*                                       ${REPODIR}/../../tmp/mono/bin/
+       rsync -a --copy-links ${REPODIR}/mono-mac/bin/ipy*                                      ${REPODIR}/../../tmp/mono/bin/
+       rsync -a --copy-links ${REPODIR}/mono-mac/bin/fsharp*                                   ${REPODIR}/../../tmp/mono/bin/
+       rsync -a --copy-links ${REPODIR}/mono-mac/bin/xsp*                                      ${REPODIR}/../../tmp/mono/bin/
+       rsync -a --copy-links ${REPODIR}/mono-mac/bin/nuget                                     ${REPODIR}/../../tmp/mono/bin/
+       rsync -a --copy-links ${REPODIR}/mono-mac/bin/msbuild                                   ${REPODIR}/../../tmp/mono/bin/
+       sed -i 's#/Library.*mono#../..#' ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ F\#/v4.*/*
+       sed -i 's#/Library.*mono#../../../../..#' ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/3.*/Framework/v4.*/*
+       rsync -a --copy-links ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ F\#/v4.0/*          ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ F\#/v4.0/
+       rsync -a --copy-links ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/3.0/Framework/v4.0/*       ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/3.0/Framework/v4.0/
+       rsync -a --copy-links ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/3.1/Framework/v4.0/*       ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/3.1/Framework/v4.0/
+       rsync -a --copy-links ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/4.0/Framework/v4.0/*       ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/4.0/Framework/v4.0/
+       rsync -a --copy-links ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/4.1/Framework/v4.0/*       ${REPODIR}/../../tmp/mono/lib/mono/Microsoft\ SDKs/F\#/4.1/Framework/v4.0/
+       pushd ${REPODIR}/../../tmp/mono/bin
+       rm -f xsp
+       for i in ir ir64 irw irw64 xsp2 xsp4 fsharpc fsharpi fsharpiAnyCpu nuget msbuild ipy ipy64 ipyw ipyw64
+               do echo "Processing $i"
+               sed -i 's#/Library.*mono #\"\$\{BASH_SOURCE%/\*\}\"/mono #' $i
+               sed -i 's#/Library.*cli #\"\$\{BASH_SOURCE%/\*\}\"/cli #' $i
+               if [ -n "$(grep -hoE '[\" ]/Library.*\.(exe|dll)' $i)" ]
+                       then EXENAME=$(basename `grep -hoE -m 1 '[\" ]/Library.*\.(exe|dll)' $i | sed 's/^\"//'`)
+                       RUNTIME=$(dirname `grep -hoE -m 1 '[\" ]/Library.*\.(exe|dll)' $i` | sed 's/^\"//' | sed 's#/Library.*/[0-9]\+\.[0-9]\+\.[0-9]\+/lib/##' | sed '/^mono\//! s#^#..\\\\#' | sed 's#^mono/##')
+                       sed "s#@@RUNTIME@@#${RUNTIME}\\\\#g" ${REPODIR}/../../resources/wrapper.bat > $i.bat
+                       sed -i "s#@@COMMAND@@#${EXENAME}#g" $i.bat
+                       sed -i 's#/#\\#g' $i.bat
+               fi
+               sed -i 's#/Library.*/[0-9]\+\.[0-9]\+\.[0-9]\+/lib/#\"\$\(cygpath -w \"\$\{BASH_SOURCE%/\*\}\"/../lib/\)\"#g#' $i
+               sed -i 's#\"\"#\"#g' $i
+               sed -i 's#)\"#)#g' $i
+               sed -i 's#exe #exe\" #' $i
+               sed -i 's#dll #dll\" #' $i
+               sed -i 's#basename \$0#basename \"\$0\"#' $i
+       done
+       cp xsp4 xsp
+       cp xsp4.bat xsp.bat
+       chmod a+x *
+       cd ..
+       for i in lib/mono/4.5/Mono.Cecil.VB*.dll lib/mono/4.5/Microsoft.VisualBasic.dll lib/mono/*/xsp*.exe lib/mono/*/FSharp*.dll lib/mono/*/Mono.WebServer*.dll ../../repos/managed-components/mono-mac/lib/mono/gac/FSharp.Core/4.3*/FSharp.Core.dll ../../repos/managed-components/mono-mac/lib/mono/gac/FSharp.Core/4.4.0*/FSharp.Core.dll
+               do bin/gacutil -i $i
+       done
+       rsync -a --copy-links lib/mono/4.5/FSharp.Core.*data lib/mono/gac/FSharp.Core/4.4.1.0__*/
+       rsync -a --copy-links lib/mono/4.5/FSharp.Core.*data lib/mono/gac/FSharp.Core/4.4.0.0__*/
+       rsync -a --copy-links lib/mono/4.5/FSharp.Core.*data lib/mono/gac/FSharp.Core/4.3.1.0__*/
+       rsync -a --copy-links lib/mono/4.5/FSharp.Core.*data lib/mono/gac/FSharp.Core/4.3.0.0__*/
+       popd
+}
+
+prerequisites()
+{
+       which bsdcpio           2>/dev/null || error "*** bsdcpio is not in \$PATH ***"
+       which wget              2>/dev/null || error "*** wget is not in \$PATH ***"
+       which xml2-config       2>/dev/null || error "*** xml2-config is not in \$PATH ***"
+       if [ ! -e "/usr/include/openssl/crypto.h" ]
+               then error "*** openssl-devel is not installed ***"
+       fi
+}
+
+$@
diff --git a/packaging/Windows/defs/mono b/packaging/Windows/defs/mono
new file mode 100755 (executable)
index 0000000..aa7f81f
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/bash -xe
+
+REPODIR=$(dirname $(realpath $0))/../../..
+INSTALLDIR=$(realpath -m $(dirname $0)/../tmp/mono)
+
+error()
+{
+    echo "$(date "+%F@%T") :: $1" 1>&2
+    exit 1
+}
+
+report()
+{
+    echo "$(date "+%F@%T") :: $1"
+}
+
+download()
+{
+       wget --quiet -O ${REPODIR}/pkgconfig.zip http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip
+}
+
+clean()
+{
+       rm -rf ${INSTALLDIR}
+}
+
+build()
+{
+       pushd ${REPODIR}
+       report "Building Mono"
+       mkdir -p ${INSTALLDIR}
+       EXTRA_CONF_FLAGS="--prefix=${INSTALLDIR}" CI_TAGS="no-tests" label="w32" scripts/ci/run-jenkins.sh || error "*** Could not run autogen ***"
+       popd
+}
+
+install()
+{
+       pushd ${REPODIR}
+       MONO_EXECUTABLE=${REPODIR}/msvc/build/sgen/Win32/bin/Release/mono-sgen.exe make install || error "*** Installing to temporary prefix failed ***"
+       rm -f   ${INSTALLDIR}/bin/mono-sgen.* \
+               ${INSTALLDIR}/bin/mono-boehm.* \
+               ${INSTALLDIR}/lib/libmono-2.0.* \
+               ${INSTALLDIR}/lib/libmonoboehm-2.0.* \
+               ${INSTALLDIR}/lib/libmonosgen-2.0.* \
+               ${INSTALLDIR}/bin/MonoPosixHelper.* \
+               ${INSTALLDIR}/lib/MonoPosixHelper.* \
+               ${INSTALLDIR}/bin/mono \
+               ${INSTALLDIR}/bin/pedump \
+               ${INSTALLDIR}/bin/mono-package-runtime \
+               ${INSTALLDIR}/bin/monodis*
+       pushd ${REPODIR}
+       cp -a msvc/build/sgen/Win32/bin/Release/monodis-sgen.exe        ${INSTALLDIR}/bin/monodis.exe
+       cp -a msvc/build/sgen/Win32/bin/Release/monodis-sgen.pdb        ${INSTALLDIR}/bin/monodis.pdb
+       cp -a msvc/build/sgen/Win32/bin/Release/mono-sgen.exe   ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/Win32/bin/Release/mono-sgen.pdb   ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/Win32/bin/Release/mono-2.0-sgen.dll       ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/Win32/lib/Release/mono-2.0-sgen.lib       ${INSTALLDIR}/lib/
+       cp -a msvc/build/sgen/Win32/bin/Release/mono-2.0-sgen.pdb       ${INSTALLDIR}/lib/
+       cp -a msvc/build/sgen/Win32/bin/Release/MonoPosixHelper.dll     ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/Win32/lib/Release/MonoPosixHelper.lib     ${INSTALLDIR}/lib/
+       cp -a msvc/build/sgen/Win32/bin/Release/MonoPosixHelper.pdb     ${INSTALLDIR}/lib/
+       cp -a msvc/build/boehm/Win32/bin/Release/mono-boehm.exe         ${INSTALLDIR}/bin/
+       cp -a msvc/build/boehm/Win32/bin/Release/mono-boehm.pdb         ${INSTALLDIR}/bin/
+       cp -a msvc/build/boehm/Win32/bin/Release/mono-2.0-boehm.dll     ${INSTALLDIR}/bin/
+       cp -a msvc/build/boehm/Win32/lib/Release/mono-2.0-boehm.lib     ${INSTALLDIR}/lib/
+       cp -a msvc/build/boehm/Win32/bin/Release/mono-2.0-boehm.pdb     ${INSTALLDIR}/lib/
+       cp -a ${INSTALLDIR}/bin/mono-sgen.exe   ${INSTALLDIR}/bin/mono.exe
+       cp -a ${INSTALLDIR}/bin/mono-sgen.pdb   ${INSTALLDIR}/bin/mono.pdb
+       popd
+       pushd ${INSTALLDIR}/bin
+       for i in *
+               do if [[ "`file -b $i`" == "POSIX shell script, ASCII text"* ]]
+                       then RUNTIME=`grep -ho -m 1 "xbuild/.*/bin/\|[2,3,4]\.[0,5]/" $i | sed 's#/$##'`
+                       if [ -n "$(grep -ho '.:/.*\.exe' $i)" ]
+                               then EXENAME=$(basename `grep -ho '.:/.*\.exe' $i`)
+                       fi
+                       if [ -f "../lib/mono/${RUNTIME}/${EXENAME}" ]
+                               then sed "s#@@RUNTIME@@#${RUNTIME}#g" ${REPODIR}/packaging/Windows/resources/wrapper.bat > $i.bat
+                               sed -i "s#@@COMMAND@@#${EXENAME}#g" $i.bat
+                               sed -i 's#/#\\#g' $i.bat
+                       fi
+                       sed -i "s#.:/.*/#\"\$\(cygpath -w \"\$\{BASH_SOURCE%/\*\}\"/../lib/mono/${RUNTIME}/\)\"#g" $i
+                       sed -i 's#/.*/tmp/mono/bin#\"\$\{BASH_SOURCE%/\*\}\"#g' $i
+               fi
+       done
+       unzip -jd . ${REPODIR}/pkgconfig.zip bin/pkg-config.exe
+       chmod a+x *.bat *.exe
+       popd
+       popd
+}
+
+prerequisites()
+{
+       which mcs 2>/dev/null || error "*** mcs is not in \$PATH ***"
+}
+
+$@
diff --git a/packaging/Windows/defs/mono64 b/packaging/Windows/defs/mono64
new file mode 100755 (executable)
index 0000000..2d7dcc5
--- /dev/null
@@ -0,0 +1,92 @@
+#!/bin/bash -xe
+
+REPODIR=$(dirname $(realpath $0))/../../..
+INSTALLDIR=$(realpath -m $(dirname $0)/../tmp/mono)
+
+error()
+{
+    echo "$(date "+%F@%T") :: $1" 1>&2
+    exit 1
+}
+
+report()
+{
+    echo "$(date "+%F@%T") :: $1"
+}
+
+download()
+{
+       wget --quiet -O ${REPODIR}/pkgconfig.zip http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip
+}
+
+clean()
+{
+       rm -rf ${INSTALLDIR}
+}
+
+build()
+{
+       pushd ${REPODIR}
+       report "Building Mono"
+       mkdir -p ${INSTALLDIR}
+       EXTRA_CONF_FLAGS="--prefix=${INSTALLDIR}" CI_TAGS="no-tests" label="w64" scripts/ci/run-jenkins.sh || error "*** Could not run autogen ***"
+       popd
+}
+
+install()
+{
+       pushd ${REPODIR}
+       MONO_EXECUTABLE=${REPODIR}/msvc/build/sgen/x64/bin/Release/mono-sgen.exe make install || error "*** Installing to temporary prefix failed ***"
+       rm -f   ${INSTALLDIR}/bin/mono-sgen.* \
+               ${INSTALLDIR}/bin/mono-boehm.* \
+               ${INSTALLDIR}/lib/libmono-2.0.* \
+               ${INSTALLDIR}/lib/libmonoboehm-2.0.* \
+               ${INSTALLDIR}/lib/libmonosgen-2.0.* \
+               ${INSTALLDIR}/bin/MonoPosixHelper.* \
+               ${INSTALLDIR}/lib/MonoPosixHelper.* \
+               ${INSTALLDIR}/bin/mono \
+               ${INSTALLDIR}/bin/pedump \
+               ${INSTALLDIR}/bin/mono-package-runtime \
+               ${INSTALLDIR}/bin/monodis*
+       pushd ${REPODIR}
+       cp -a msvc/build/sgen/x64/bin/Release/monodis-sgen.exe  ${INSTALLDIR}/bin/monodis.exe
+       cp -a msvc/build/sgen/x64/bin/Release/monodis-sgen.pdb  ${INSTALLDIR}/bin/monodis.pdb
+       cp -a msvc/build/sgen/x64/bin/Release/mono-sgen.exe             ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/x64/bin/Release/mono-sgen.pdb             ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/x64/bin/Release/mono-2.0-sgen.dll ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/x64/lib/Release/mono-2.0-sgen.lib ${INSTALLDIR}/lib/
+       cp -a msvc/build/sgen/x64/bin/Release/mono-2.0-sgen.pdb ${INSTALLDIR}/lib/
+       cp -a msvc/build/sgen/x64/bin/Release/MonoPosixHelper.dll       ${INSTALLDIR}/bin/
+       cp -a msvc/build/sgen/x64/lib/Release/MonoPosixHelper.lib       ${INSTALLDIR}/lib/
+       cp -a msvc/build/sgen/x64/bin/Release/MonoPosixHelper.pdb       ${INSTALLDIR}/lib/
+       cp -a ${INSTALLDIR}/bin/mono-sgen.exe   ${INSTALLDIR}/bin/mono.exe
+       cp -a ${INSTALLDIR}/bin/mono-sgen.pdb   ${INSTALLDIR}/bin/mono.pdb
+       popd
+       pushd ${INSTALLDIR}/bin
+       for i in *
+               do if [[ "`file -b $i`" == "POSIX shell script, ASCII text"* ]]
+                       then RUNTIME=`grep -ho -m 1 "xbuild/.*/bin/\|[2,3,4]\.[0,5]/" $i | sed 's#/$##'`
+                       if [ -n "$(grep -ho '.:/.*\.exe' $i)" ]
+                               then EXENAME=$(basename `grep -ho '.:/.*\.exe' $i`)
+                       fi
+                       if [ -f "../lib/mono/${RUNTIME}/${EXENAME}" ]
+                               then sed "s#@@RUNTIME@@#${RUNTIME}#g" ${REPODIR}/packaging/Windows/resources/wrapper.bat > $i.bat
+                               sed -i "s#@@COMMAND@@#${EXENAME}#g" $i.bat
+                               sed -i 's#/#\\#g' $i.bat
+                       fi
+                       sed -i "s#.:/.*/#\"\$\(cygpath -w \"\$\{BASH_SOURCE%/\*\}\"/../lib/mono/${RUNTIME}/\)\"#g" $i
+                       sed -i 's#/.*/tmp/mono/bin#\"\$\{BASH_SOURCE%/\*\}\"#g' $i
+               fi
+       done
+       unzip -jd . ${REPODIR}/pkgconfig.zip bin/pkg-config.exe
+       chmod a+x *.bat *.exe
+       popd
+       popd
+}
+
+prerequisites()
+{
+       which mcs 2>/dev/null || error "*** mcs is not in \$PATH ***"
+}
+
+$@
diff --git a/packaging/Windows/mono-MDK-windows b/packaging/Windows/mono-MDK-windows
new file mode 100755 (executable)
index 0000000..3a181ae
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash -xe
+COMPONENTS="mono gtksharp managed-components"
+for i in ${COMPONENTS}
+       do defs/$i prerequisites
+done
+COMPONENTS="gtksharp managed-components"
+defs/mono download
+defs/gtksharp download
+defs/managed-components download "${mdk}"
+COMPONENTS="mono gtksharp managed-components"
+for i in ${COMPONENTS}
+       do defs/$i clean
+       defs/$i build
+       defs/$i install
+done
+resources/build.bat
diff --git a/packaging/Windows/mono-MDK-windows-x64 b/packaging/Windows/mono-MDK-windows-x64
new file mode 100755 (executable)
index 0000000..1cf3fac
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash -xe
+COMPONENTS="mono64 managed-components"
+for i in ${COMPONENTS}
+       do defs/$i prerequisites
+done
+COMPONENTS="managed-components"
+defs/mono64 download
+defs/managed-components download "${mdk}"
+COMPONENTS="mono64 managed-components"
+for i in ${COMPONENTS}
+       do defs/$i clean
+       defs/$i build
+       defs/$i install
+done
+resources/build64.bat
diff --git a/packaging/Windows/resources/MonoForWindows.wixproj b/packaging/Windows/resources/MonoForWindows.wixproj
new file mode 100644 (file)
index 0000000..c39e5db
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>3.9</ProductVersion>
+    <ProjectGuid>9f279b8c-fc0d-49d4-b5bd-ade0db0c3095</ProjectGuid>
+    <SchemaVersion>2.0</SchemaVersion>
+    <OutputName>MonoForWindows-$(Platform)</OutputName>
+    <OutputType>Package</OutputType>
+    <SuppressIces>ICE61;</SuppressIces>
+    <DefineSolutionProperties>false</DefineSolutionProperties>
+    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
+    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <OutputPath>bin\$(Configuration)\</OutputPath>
+    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
+    <DefineConstants>Debug</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <OutputPath>bin\$(Configuration)\</OutputPath>
+    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
+    <DefineConstants>
+    </DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
+    <OutputPath>bin\$(Configuration)\</OutputPath>
+    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
+    <DefineConstants>Debug</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
+    <OutputPath>bin\$(Configuration)\</OutputPath>
+    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
+    <DefineConstants>
+    </DefineConstants>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="mono.generated.wxs" />
+    <Compile Include="Product.wxs" />
+  </ItemGroup>
+  <ItemGroup>
+    <WixExtension Include="WixUIExtension">
+      <HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
+      <Name>WixUIExtension</Name>
+    </WixExtension>
+  </ItemGroup>
+  <Import Project="$(WixTargetsPath)" />
+  <Target Name="BeforeBuild">
+    <HeatDirectory OutputFile="mono.generated.wxs" Directory="$(MONO_FILES_DIR)" DirectoryRefId="INSTALLFOLDER" ComponentGroupName="MonoFiles" PreprocessorVariable="env.MONO_FILES_DIR" ToolPath="$(WixToolPath)" GenerateGuidsNow="true" SuppressCom="true" SuppressRegistry="true" SuppressFragments="true" SuppressRootDirectory="true" />
+  </Target>
+</Project>
diff --git a/packaging/Windows/resources/Product.wxs b/packaging/Windows/resources/Product.wxs
new file mode 100644 (file)
index 0000000..f717f31
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+
+<?if $(sys.BUILDARCH)=x86 ?>
+  <?define UpgradeCode="177a37ab-9354-487f-ac97-8407195c3043" ?>
+  <?define ProgramFilesX86orX64="ProgramFilesFolder" ?>
+  <?define SystemFolderX86orX64="SystemFolder" ?>
+  <?define MonoProgramFilesGuid="9B7A0108-39DA-4332-AE40-545E28919736" ?>
+  <?define ApplicationShortcutsGuid="CF93ABFD-416B-4C10-9126-EA93BC1D7154" ?>
+<?elseif $(sys.BUILDARCH)=x64 ?>
+  <?define UpgradeCode="1f58e2dd-d88a-402d-a67f-a27e1efaaf48" ?>
+  <?define ProgramFilesX86orX64="ProgramFiles64Folder" ?>
+  <?define SystemFolderX86orX64="System64Folder" ?>
+  <?define MonoProgramFilesGuid="b4d95bcc-9fa9-48c4-a2d0-1d83f031e974" ?>
+  <?define ApplicationShortcutsGuid="8a74633a-86bb-4891-b9aa-1e7aaf7597c6" ?>
+<?else?>
+  <?error $(sys.BUILDARCH) is not supported ?>
+<?endif?>
+
+  <Product Id="*"
+           Name="Mono for Windows ($(sys.BUILDARCH))"
+           Language="1033"
+           Version="$(env.MONO_VERSION)"
+           Manufacturer="Xamarin, Inc."
+           UpgradeCode="$(var.UpgradeCode)">
+    <Package InstallerVersion="405" Compressed="yes" InstallScope="perMachine" Platform="$(sys.BUILDARCH)" />
+
+
+    <MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
+    <MediaTemplate EmbedCab="yes" />
+
+    <Icon Id="app.ico" SourceFile="setup-files\app.ico"/>
+
+    <!-- Entries for the 'Add & Remove Programs' section in control panel -->
+    <Property Id="ARPPRODUCTICON" Value="app.ico" />
+    <Property Id="ARPHELPLINK" Value="http://www.mono-project.com/" />
+    <Property Id="ARPURLINFOABOUT" Value="http://www.mono-project.com/" />
+    <Property Id="ARPURLUPDATEINFO" Value="http://www.mono-project.com/docs/about-mono/releases/" />
+
+    <Property Id="MSIFASTINSTALL" Value="7" />
+
+    <Condition Message="This application is only supported on Windows Vista or higher.">
+      <![CDATA[Installed OR (VersionNT >= 600)]]>
+    </Condition>
+
+    <UIRef Id="WixUI_Minimal" />
+    <WixVariable Id="WixUILicenseRtf" Value="setup-files\license.rtf" />
+    <WixVariable Id="WixUIBannerBmp" Value="setup-files\banner.bmp" />
+    <WixVariable Id="WixUIDialogBmp" Value="setup-files\dialog.bmp" />
+
+    <Feature Id="ProductFeature" Title="Mono" Level="1">
+      <ComponentGroupRef Id="ProductComponents" />
+    </Feature>
+    <DirectoryRef Id="TARGETDIR">
+      <Merge Id="VCRedist2013" SourceFile="$(env.CommonProgramFiles(x86))\Merge Modules\Microsoft_VC120_CRT_x86.msm" DiskId="1" Language="0"/>
+      <Merge Id="VCRedist2015" SourceFile="$(env.CommonProgramFiles(x86))\Merge Modules\Microsoft_VC140_CRT_$(sys.BUILDARCH).msm" DiskId="1" Language="0"/>
+    </DirectoryRef>
+    <Feature Id="VCRedist2013" Title="Visual C++ 12.0 Runtime (x86)" AllowAdvertise="no" Display="hidden" Level="1">
+      <MergeRef Id="VCRedist2013"/>
+    </Feature>
+    <Feature Id="VCRedist2015" Title="Visual C++ 14.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
+      <MergeRef Id="VCRedist2015"/>
+    </Feature>
+  </Product>
+
+  <Fragment>
+    <Directory Id="TARGETDIR" Name="SourceDir">
+      <Directory Id="$(var.ProgramFilesX86orX64)">
+        <Directory Id="INSTALLFOLDER" Name="Mono">
+          <Directory Id="binFolder" Name="bin">
+            <Component Id="MonoProgramFiles" Guid="$(var.MonoProgramFilesGuid)">
+              <File KeyPath="yes" Source="bat\setmonopath.bat" />
+              <RegistryValue Root="HKLM" Key="Software\Mono" Name="Installed" Type="integer" Value="1" />
+              <RegistryValue Root="HKLM" Key="Software\Mono" Name="Version" Type="string" Value="$(env.MONO_VERSION)" />
+              <RegistryValue Root="HKLM" Key="Software\Mono" Name="SdkInstallRoot" Type="string" Value="[INSTALLFOLDER]" />
+              <RegistryValue Root="HKLM" Key="Software\Mono" Name="FrameworkAssemblyDirectory" Type="string" Value="[INSTALLFOLDER]lib\" />
+              <RegistryValue Root="HKLM" Key="Software\Mono" Name="MonoConfigDir" Type="string" Value="[INSTALLFOLDER]etc\" />
+              <RegistryValue Root="HKLM" Key="Software\Mono" Name="Architecture" Type="string" Value="$(sys.BUILDARCH)" />
+            </Component>
+          </Directory>
+        </Directory>
+      </Directory>
+
+      <!-- Start Menu Shortcut -->
+      <Directory Id="ProgramMenuFolder">
+        <Directory Id="ApplicationProgramsFolder" Name="Mono">
+          <Component Id="ApplicationShortcuts" Guid="$(var.ApplicationShortcutsGuid)">
+            <Shortcut Id="ApplicationStartMenuShortcutMono"
+                      Name="Open Mono $(sys.BUILDARCH) Command Prompt"
+                      Target="[$(var.SystemFolderX86orX64)]cmd.exe"
+                      Arguments="/k &quot;[INSTALLFOLDER]\bin\setmonopath.bat&quot;"
+                      WorkingDirectory="INSTALLFOLDER"/>
+            <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
+            <RegistryValue Root="HKCU" Key="Software\Mono" Name="Installed" Type="integer" Value="1" KeyPath="yes"/>
+          </Component>
+        </Directory>
+      </Directory>
+    </Directory>
+  </Fragment>
+
+  <Fragment>
+    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
+      <ComponentGroupRef Id="MonoFiles" />
+      <ComponentRef Id="MonoProgramFiles" />
+      <ComponentRef Id="ApplicationShortcuts" />
+    </ComponentGroup>
+  </Fragment>
+</Wix>
diff --git a/packaging/Windows/resources/bat/setmonopath.bat b/packaging/Windows/resources/bat/setmonopath.bat
new file mode 100644 (file)
index 0000000..c140afe
--- /dev/null
@@ -0,0 +1,4 @@
+@echo off
+echo Mono version X.X.X
+echo Prepending '%~dp0' to PATH
+PATH=%~dp0;%PATH%
diff --git a/packaging/Windows/resources/build.bat b/packaging/Windows/resources/build.bat
new file mode 100755 (executable)
index 0000000..87d7523
--- /dev/null
@@ -0,0 +1,6 @@
+@echo off
+
+set MONO_VERSION=X.X.X
+set MONO_FILES_DIR=..\tmp\mono
+
+"%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" %~dp0\MonoForWindows.wixproj /p:Configuration=Release /p:DefaultCompressionLevel=high
diff --git a/packaging/Windows/resources/build64.bat b/packaging/Windows/resources/build64.bat
new file mode 100755 (executable)
index 0000000..c2b1f56
--- /dev/null
@@ -0,0 +1,6 @@
+@echo off
+
+set MONO_VERSION=X.X.X
+set MONO_FILES_DIR=..\tmp\mono
+
+"%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" %~dp0\MonoForWindows.wixproj /p:Configuration=Release /p:Platform=x64 /p:DefaultCompressionLevel=high
diff --git a/packaging/Windows/resources/pkgconfig/glade-sharp-2.0.pc b/packaging/Windows/resources/pkgconfig/glade-sharp-2.0.pc
new file mode 100644 (file)
index 0000000..a351c05
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=${pcfiledir}/../..
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+gapidir=${prefix}/share/gapi-2.0
+
+
+Name: Glade#
+Description: Glade# - Glade .NET Binding
+Version: 2.12.26
+Requires: gtk-sharp-2.0
+Cflags: -I:${gapidir}/glade-api.xml
+Libs: -r:${libdir}/gtk-sharp-2.0/glade-sharp.dll
diff --git a/packaging/Windows/resources/pkgconfig/glib-sharp-2.0.pc b/packaging/Windows/resources/pkgconfig/glib-sharp-2.0.pc
new file mode 100644 (file)
index 0000000..178026c
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=${pcfiledir}../..
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+gapidir=${prefix}/share/gapi-2.0
+
+
+Name: GLib#
+Description: GLib# - .NET Binding for the glib library.
+Version: 2.12.26
+Cflags: -I:${gapidir}/glib-api.xml
+Libs: -r:${libdir}/gtk-sharp-2.0/glib-sharp.dll
+
diff --git a/packaging/Windows/resources/pkgconfig/gtk-sharp-2.0.pc b/packaging/Windows/resources/pkgconfig/gtk-sharp-2.0.pc
new file mode 100644 (file)
index 0000000..7fafb1a
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=${pcfiledir}/../..
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+gapidir=${prefix}/share/gapi-2.0
+
+
+Name: Gtk#
+Description: Gtk# - GNOME .NET Binding
+Version: 2.12.26
+Cflags: -I:${gapidir}/pango-api.xml -I:${gapidir}/atk-api.xml -I:${gapidir}/gdk-api.xml -I:${gapidir}/gtk-api.xml
+Libs: -r:${libdir}/gtk-sharp-2.0/pango-sharp.dll -r:${libdir}/gtk-sharp-2.0/atk-sharp.dll -r:${libdir}/gtk-sharp-2.0/gdk-sharp.dll -r:${libdir}/gtk-sharp-2.0/gtk-sharp.dll
+Requires: glib-sharp-2.0
diff --git a/packaging/Windows/resources/setup-files/app.ico b/packaging/Windows/resources/setup-files/app.ico
new file mode 100644 (file)
index 0000000..9971c0b
Binary files /dev/null and b/packaging/Windows/resources/setup-files/app.ico differ
diff --git a/packaging/Windows/resources/setup-files/banner.bmp b/packaging/Windows/resources/setup-files/banner.bmp
new file mode 100644 (file)
index 0000000..ebb17d0
Binary files /dev/null and b/packaging/Windows/resources/setup-files/banner.bmp differ
diff --git a/packaging/Windows/resources/setup-files/dialog.bmp b/packaging/Windows/resources/setup-files/dialog.bmp
new file mode 100644 (file)
index 0000000..f37c56d
Binary files /dev/null and b/packaging/Windows/resources/setup-files/dialog.bmp differ
diff --git a/packaging/Windows/resources/setup-files/license.rtf b/packaging/Windows/resources/setup-files/license.rtf
new file mode 100644 (file)
index 0000000..c952a2e
--- /dev/null
@@ -0,0 +1,1447 @@
+{\rtf1\ansi\ansicpg10000\deff0\nouicompat{\fonttbl{\f0\fnil\fcharset77 Arial;}{\f1\fnil\fcharset0 Arial;}}
+{\colortbl ;\red0\green0\blue255;}
+{\*\generator Riched20 10.0.15063}\viewkind4\uc1 
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\f0\fs24\lang1033
+
+\f0\fs24 \cf0 In general, the runtime and its class libraries are licensed under the\
+terms of the MIT license, and some third party code is licensed under\
+the 3-clause BSD license.  See the file "PATENTS.TXT" for Microsoft's\
+patent grant on the Mono codebase.\
+\
+The Mono distribution does include a handful of pieces of code that\
+are used during the build system and are covered under different\
+licenses, those include:\
+\
+Build Time Code\
+===============\
+\
+This is code that is used at build time, or during the maintenance of\
+Mono itself, and does not end up in the redistributable part of Mono:\
+\
+* gettext\
+\
+  m4 source files used to probe features at build time: GPL\
+\
+* Benchmark Source Files\
+\
+  Logic.cs and zipmark.cs are GPL source files.\
+\
+* mono/docs/HtmlAgilityPack\
+\
+  MS-PL licensed\
+\
+* mcs/jay: 4-clause BSD licensed\
+\
+* mcs/nunit24: MS-PL\
+\
+* mcs/class/I18N/mklist.sh, tools/cvt.sh: GNU GPLv2\
+\
+Runtime Code\
+============\
+\
+The following code is linked with the final Mono runtime, the libmono\
+embeddable runtime:\
+\
+* support/minizip: BSD license.\
+\
+* mono/utils/memcheck.h: BSD license, used on debug builds that use Valgrind.\
+\
+* mono/utils/freebsd-dwarf.h, freebsd-elf_common.h, freebsd-elf64.h freebsd-elf32.h: BSD license.\
+\
+* mono/utils/bsearch.c: BSD license.\
+\
+* mono/io-layer/wapi_glob.h, wapi_glob.c: BSD license\
+\
+Class Library code\
+==================\
+\
+These are class libraries that can be loaded by your process:\
+\
+* mcs/class/RabbitMQ.Client: dual licensed in Apache v2, and Mozilla Public License 1.1\
+\
+* mcs/class/Compat.ICSharpCode.SharpZipLib and\
+  mcs/class/ICSharpCode.SharpZipLib are GPL with class-path exception.\
+  Originates with the SharpDevelop project.\
+\
+* mcs/class/System.Core/System/TimeZoneInfo.Android.cs\
+\
+  This is a port of Apache 2.0-licensed Android code, and thus is\
+  licensed under the Apache 2.0 license\
+\
+           http://www.apache.org/licenses/LICENSE-2.0\
+\
+API Documentation\
+=================\
+\
+The API documentation is licensed under the terms of the Creative\
+Commons Attribution 4.0 International Public License\
+\
+\
+The Licenses\
+============\
+\
+       These are the licenses used in Mono, the files are located:\
+\
+### MIT X11 License\
+\
+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.\
+\
+\
+### Mozilla.MPL\
+\
+                          MOZILLA PUBLIC LICENSE\
+                                Version 1.1\
+\
+                              ---------------\
+\
+1. Definitions.\
+\
+     1.0.1. "Commercial Use" means distribution or otherwise making the\
+     Covered Code available to a third party.\
+\
+     1.1. "Contributor" means each entity that creates or contributes to\
+     the creation of Modifications.\
+\
+     1.2. "Contributor Version" means the combination of the Original\
+     Code, prior Modifications used by a Contributor, and the Modifications\
+     made by that particular Contributor.\
+\
+     1.3. "Covered Code" means the Original Code or Modifications or the\
+     combination of the Original Code and Modifications, in each case\
+     including portions thereof.\
+\
+     1.4. "Electronic Distribution Mechanism" means a mechanism generally\
+     accepted in the software development community for the electronic\
+     transfer of data.\
+\
+     1.5. "Executable" means Covered Code in any form other than Source\
+     Code.\
+\
+     1.6. "Initial Developer" means the individual or entity identified\
+     as the Initial Developer in the Source Code notice required by Exhibit\
+     A.\
+\
+     1.7. "Larger Work" means a work which combines Covered Code or\
+     portions thereof with code not governed by the terms of this License.\
+\
+     1.8. "License" means this document.\
+\
+     1.8.1. "Licensable" means having the right to grant, to the maximum\
+     extent possible, whether at the time of the initial grant or\
+     subsequently acquired, any and all of the rights conveyed herein.\
+\
+     1.9. "Modifications" means any addition to or deletion from the\
+     substance or structure of either the Original Code or any previous\
+     Modifications. When Covered Code is released as a series of files, a\
+     Modification is:\
+          A. Any addition to or deletion from the contents of a file\
+          containing Original Code or previous Modifications.\
+\
+          B. Any new file that contains any part of the Original Code or\
+          previous Modifications.\
+\
+     1.10. "Original Code" means Source Code of computer software code\
+     which is described in the Source Code notice required by Exhibit A as\
+     Original Code, and which, at the time of its release under this\
+     License is not already Covered Code governed by this License.\
+\
+     1.10.1. "Patent Claims" means any patent claim(s), now owned or\
+     hereafter acquired, including without limitation,  method, process,\
+     and apparatus claims, in any patent Licensable by grantor.\
+\
+     1.11. "Source Code" means the preferred form of the Covered Code for\
+     making modifications to it, including all modules it contains, plus\
+     any associated interface definition files, scripts used to control\
+     compilation and installation of an Executable, or source code\
+     differential comparisons against either the Original Code or another\
+     well known, available Covered Code of the Contributor's choice. The\
+     Source Code can be in a compressed or archival form, provided the\
+     appropriate decompression or de-archiving software is widely available\
+     for no charge.\
+\
+     1.12. "You" (or "Your")  means an individual or a legal entity\
+     exercising rights under, and complying with all of the terms of, this\
+     License or a future version of this License issued under Section 6.1.\
+     For legal entities, "You" includes any entity which controls, is\
+     controlled by, or is under common control with You. For purposes of\
+     this definition, "control" means (a) the power, direct or indirect,\
+     to cause the direction or management of such entity, whether by\
+     contract or otherwise, or (b) ownership of more than fifty percent\
+     (50%) of the outstanding shares or beneficial ownership of such\
+     entity.\
+\
+2. Source Code License.\
+\
+     2.1. The Initial Developer Grant.\
+     The Initial Developer hereby grants You a world-wide, royalty-free,\
+     non-exclusive license, subject to third party intellectual property\
+     claims:\
+          (a)  under intellectual property rights (other than patent or\
+          trademark) Licensable by Initial Developer to use, reproduce,\
+          modify, display, perform, sublicense and distribute the Original\
+          Code (or portions thereof) with or without Modifications, and/or\
+          as part of a Larger Work; and\
+\
+          (b) under Patents Claims infringed by the making, using or\
+          selling of Original Code, to make, have made, use, practice,\
+          sell, and offer for sale, and/or otherwise dispose of the\
+          Original Code (or portions thereof).\
+\
+          (c) the licenses granted in this Section 2.1(a) and (b) are\
+          effective on the date Initial Developer first distributes\
+          Original Code under the terms of this License.\
+\
+          (d) Notwithstanding Section 2.1(b) above, no patent license is\
+          granted: 1) for code that You delete from the Original Code; 2)\
+          separate from the Original Code;  or 3) for infringements caused\
+          by: i) the modification of the Original Code or ii) the\
+          combination of the Original Code with other software or devices.\
+\
+     2.2. Contributor Grant.\
+     Subject to third party intellectual property claims, each Contributor\
+     hereby grants You a world-wide, royalty-free, non-exclusive license\
+\
+          (a)  under intellectual property rights (other than patent or\
+          trademark) Licensable by Contributor, to use, reproduce, modify,\
+          display, perform, sublicense and distribute the Modifications\
+          created by such Contributor (or portions thereof) either on an\
+          unmodified basis, with other Modifications, as Covered Code\
+          and/or as part of a Larger Work; and\
+\
+          (b) under Patent Claims infringed by the making, using, or\
+          selling of  Modifications made by that Contributor either alone\
+          and/or in combination with its Contributor Version (or portions\
+          of such combination), to make, use, sell, offer for sale, have\
+          made, and/or otherwise dispose of: 1) Modifications made by that\
+          Contributor (or portions thereof); and 2) the combination of\
+          Modifications made by that Contributor with its Contributor\
+          Version (or portions of such combination).\
+\
+          (c) the licenses granted in Sections 2.2(a) and 2.2(b) are\
+          effective on the date Contributor first makes Commercial Use of\
+          the Covered Code.\
+\
+          (d)    Notwithstanding Section 2.2(b) above, no patent license is\
+          granted: 1) for any code that Contributor has deleted from the\
+          Contributor Version; 2)  separate from the Contributor Version;\
+          3)  for infringements caused by: i) third party modifications of\
+          Contributor Version or ii)  the combination of Modifications made\
+          by that Contributor with other software  (except as part of the\
+          Contributor Version) or other devices; or 4) under Patent Claims\
+          infringed by Covered Code in the absence of Modifications made by\
+          that Contributor.\
+\
+3. Distribution Obligations.\
+\
+     3.1. Application of License.\
+     The Modifications which You create or to which You contribute are\
+     governed by the terms of this License, including without limitation\
+     Section 2.2. The Source Code version of Covered Code may be\
+     distributed only under the terms of this License or a future version\
+     of this License released under Section 6.1, and You must include a\
+     copy of this License with every copy of the Source Code You\
+     distribute. You may not offer or impose any terms on any Source Code\
+     version that alters or restricts the applicable version of this\
+     License or the recipients' rights hereunder. However, You may include\
+     an additional document offering the additional rights described in\
+     Section 3.5.\
+\
+     3.2. Availability of Source Code.\
+     Any Modification which You create or to which You contribute must be\
+     made available in Source Code form under the terms of this License\
+     either on the same media as an Executable version or via an accepted\
+     Electronic Distribution Mechanism to anyone to whom you made an\
+     Executable version available; and if made available via Electronic\
+     Distribution Mechanism, must remain available for at least twelve (12)\
+     months after the date it initially became available, or at least six\
+     (6) months after a subsequent version of that particular Modification\
+     has been made available to such recipients. You are responsible for\
+     ensuring that the Source Code version remains available even if the\
+     Electronic Distribution Mechanism is maintained by a third party.\
+\
+     3.3. Description of Modifications.\
+     You must cause all Covered Code to which You contribute to contain a\
+     file documenting the changes You made to create that Covered Code and\
+     the date of any change. You must include a prominent statement that\
+     the Modification is derived, directly or indirectly, from Original\
+     Code provided by the Initial Developer and including the name of the\
+     Initial Developer in (a) the Source Code, and (b) in any notice in an\
+     Executable version or related documentation in which You describe the\
+     origin or ownership of the Covered Code.\
+\
+     3.4. Intellectual Property Matters\
+          (a) Third Party Claims.\
+          If Contributor has knowledge that a license under a third party's\
+          intellectual property rights is required to exercise the rights\
+          granted by such Contributor under Sections 2.1 or 2.2,\
+          Contributor must include a text file with the Source Code\
+          distribution titled "LEGAL" which describes the claim and the\
+          party making the claim in sufficient detail that a recipient will\
+          know whom to contact. If Contributor obtains such knowledge after\
+          the Modification is made available as described in Section 3.2,\
+          Contributor shall promptly modify the LEGAL file in all copies\
+          Contributor makes available thereafter and shall take other steps\
+          (such as notifying appropriate mailing lists or newsgroups)\
+          reasonably calculated to inform those who received the Covered\
+          Code that new knowledge has been obtained.\
+\
+          (b) Contributor APIs.\
+          If Contributor's Modifications include an application programming\
+          interface and Contributor has knowledge of patent licenses which\
+          are reasonably necessary to implement that API, Contributor must\
+          also include this information in the LEGAL file.\
+\
+               (c)    Representations.\
+          Contributor represents that, except as disclosed pursuant to\
+          Section 3.4(a) above, Contributor believes that Contributor's\
+          Modifications are Contributor's original creation(s) and/or\
+          Contributor has sufficient rights to grant the rights conveyed by\
+          this License.\
+\
+     3.5. Required Notices.\
+     You must duplicate the notice in Exhibit A in each file of the Source\
+     Code.  If it is not possible to put such notice in a particular Source\
+     Code file due to its structure, then You must include such notice in a\
+     location (such as a relevant directory) where a user would be likely\
+     to look for such a notice.  If You created one or more Modification(s)\
+     You may add your name as a Contributor to the notice described in\
+     Exhibit A.  You must also duplicate this License in any documentation\
+     for the Source Code where You describe recipients' rights or ownership\
+     rights relating to Covered Code.  You may choose to offer, and to\
+     charge a fee for, warranty, support, indemnity or liability\
+     obligations to one or more recipients of Covered Code. However, You\
+     may do so only on Your own behalf, and not on behalf of the Initial\
+     Developer or any Contributor. You must make it absolutely clear than\
+     any such warranty, support, indemnity or liability obligation is\
+     offered by You alone, and You hereby agree to indemnify the Initial\
+     Developer and every Contributor for any liability incurred by the\
+     Initial Developer or such Contributor as a result of warranty,\
+     support, indemnity or liability terms You offer.\
+\
+     3.6. Distribution of Executable Versions.\
+     You may distribute Covered Code in Executable form only if the\
+     requirements of Section 3.1-3.5 have been met for that Covered Code,\
+     and if You include a notice stating that the Source Code version of\
+     the Covered Code is available under the terms of this License,\
+     including a description of how and where You have fulfilled the\
+     obligations of Section 3.2. The notice must be conspicuously included\
+     in any notice in an Executable version, related documentation or\
+     collateral in which You describe recipients' rights relating to the\
+     Covered Code. You may distribute the Executable version of Covered\
+     Code or ownership rights under a license of Your choice, which may\
+     contain terms different from this License, provided that You are in\
+     compliance with the terms of this License and that the license for the\
+     Executable version does not attempt to limit or alter the recipient's\
+     rights in the Source Code version from the rights set forth in this\
+     License. If You distribute the Executable version under a different\
+     license You must make it absolutely clear that any terms which differ\
+     from this License are offered by You alone, not by the Initial\
+     Developer or any Contributor. You hereby agree to indemnify the\
+     Initial Developer and every Contributor for any liability incurred by\
+     the Initial Developer or such Contributor as a result of any such\
+     terms You offer.\
+\
+     3.7. Larger Works.\
+     You may create a Larger Work by combining Covered Code with other code\
+     not governed by the terms of this License and distribute the Larger\
+     Work as a single product. In such a case, You must make sure the\
+     requirements of this License are fulfilled for the Covered Code.\
+\
+4. Inability to Comply Due to Statute or Regulation.\
+\
+     If it is impossible for You to comply with any of the terms of this\
+     License with respect to some or all of the Covered Code due to\
+     statute, judicial order, or regulation then You must: (a) comply with\
+     the terms of this License to the maximum extent possible; and (b)\
+     describe the limitations and the code they affect. Such description\
+     must be included in the LEGAL file described in Section 3.4 and must\
+     be included with all distributions of the Source Code. Except to the\
+     extent prohibited by statute or regulation, such description must be\
+     sufficiently detailed for a recipient of ordinary skill to be able to\
+     understand it.\
+\
+5. Application of this License.\
+\
+     This License applies to code to which the Initial Developer has\
+     attached the notice in Exhibit A and to related Covered Code.\
+\
+6. Versions of the License.\
+\
+     6.1. New Versions.\
+     Netscape Communications Corporation ("Netscape") may publish revised\
+     and/or new versions of the License from time to time. Each version\
+     will be given a distinguishing version number.\
+\
+     6.2. Effect of New Versions.\
+     Once Covered Code has been published under a particular version of the\
+     License, You may always continue to use it under the terms of that\
+     version. You may also choose to use such Covered Code under the terms\
+     of any subsequent version of the License published by Netscape. No one\
+     other than Netscape has the right to modify the terms applicable to\
+     Covered Code created under this License.\
+\
+     6.3. Derivative Works.\
+     If You create or use a modified version of this License (which you may\
+     only do in order to apply it to code which is not already Covered Code\
+     governed by this License), You must (a) rename Your license so that\
+     the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",\
+     "MPL", "NPL" or any confusingly similar phrase do not appear in your\
+     license (except to note that your license differs from this License)\
+     and (b) otherwise make it clear that Your version of the license\
+     contains terms which differ from the Mozilla Public License and\
+     Netscape Public License. (Filling in the name of the Initial\
+     Developer, Original Code or Contributor in the notice described in\
+     Exhibit A shall not of themselves be deemed to be modifications of\
+     this License.)\
+\
+7. DISCLAIMER OF WARRANTY.\
+\
+     COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,\
+     WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\
+     WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF\
+     DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.\
+     THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE\
+     IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,\
+     YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE\
+     COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER\
+     OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF\
+     ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.\
+\
+8. TERMINATION.\
+\
+     8.1.  This License and the rights granted hereunder will terminate\
+     automatically if You fail to comply with terms herein and fail to cure\
+     such breach within 30 days of becoming aware of the breach. All\
+     sublicenses to the Covered Code which are properly granted shall\
+     survive any termination of this License. Provisions which, by their\
+     nature, must remain in effect beyond the termination of this License\
+     shall survive.\
+\
+     8.2.  If You initiate litigation by asserting a patent infringement\
+     claim (excluding declatory judgment actions) against Initial Developer\
+     or a Contributor (the Initial Developer or Contributor against whom\
+     You file such action is referred to as "Participant")  alleging that:\
+\
+     (a)  such Participant's Contributor Version directly or indirectly\
+     infringes any patent, then any and all rights granted by such\
+     Participant to You under Sections 2.1 and/or 2.2 of this License\
+     shall, upon 60 days notice from Participant terminate prospectively,\
+     unless if within 60 days after receipt of notice You either: (i)\
+     agree in writing to pay Participant a mutually agreeable reasonable\
+     royalty for Your past and future use of Modifications made by such\
+     Participant, or (ii) withdraw Your litigation claim with respect to\
+     the Contributor Version against such Participant.  If within 60 days\
+     of notice, a reasonable royalty and payment arrangement are not\
+     mutually agreed upon in writing by the parties or the litigation claim\
+     is not withdrawn, the rights granted by Participant to You under\
+     Sections 2.1 and/or 2.2 automatically terminate at the expiration of\
+     the 60 day notice period specified above.\
+\
+     (b)  any software, hardware, or device, other than such Participant's\
+     Contributor Version, directly or indirectly infringes any patent, then\
+     any rights granted to You by such Participant under Sections 2.1(b)\
+     and 2.2(b) are revoked effective as of the date You first made, used,\
+     sold, distributed, or had made, Modifications made by that\
+     Participant.\
+\
+     8.3.  If You assert a patent infringement claim against Participant\
+     alleging that such Participant's Contributor Version directly or\
+     indirectly infringes any patent where such claim is resolved (such as\
+     by license or settlement) prior to the initiation of patent\
+     infringement litigation, then the reasonable value of the licenses\
+     granted by such Participant under Sections 2.1 or 2.2 shall be taken\
+     into account in determining the amount or value of any payment or\
+     license.\
+\
+     8.4.  In the event of termination under Sections 8.1 or 8.2 above,\
+     all end user license agreements (excluding distributors and resellers)\
+     which have been validly granted by You or any distributor hereunder\
+     prior to termination shall survive termination.\
+\
+9. LIMITATION OF LIABILITY.\
+\
+     UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT\
+     (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL\
+     DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,\
+     OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR\
+     ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY\
+     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,\
+     WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER\
+     COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN\
+     INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF\
+     LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY\
+     RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW\
+     PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE\
+     EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO\
+     THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.\
+\
+10. U.S. GOVERNMENT END USERS.\
+\
+     The Covered Code is a "commercial item," as that term is defined in\
+     48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer\
+     software" and "commercial computer software documentation," as such\
+     terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48\
+     C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),\
+     all U.S. Government End Users acquire Covered Code with only those\
+     rights set forth herein.\
+\
+11. MISCELLANEOUS.\
+\
+     This License represents the complete agreement concerning subject\
+     matter hereof. If any provision of this License is held to be\
+     unenforceable, such provision shall be reformed only to the extent\
+     necessary to make it enforceable. This License shall be governed by\
+     California law provisions (except to the extent applicable law, if\
+     any, provides otherwise), excluding its conflict-of-law provisions.\
+     With respect to disputes in which at least one party is a citizen of,\
+     or an entity chartered or registered to do business in the United\
+     States of America, any litigation relating to this License shall be\
+     subject to the jurisdiction of the Federal Courts of the Northern\
+     District of California, with venue lying in Santa Clara County,\
+     California, with the losing party responsible for costs, including\
+     without limitation, court costs and reasonable attorneys' fees and\
+     expenses. The application of the United Nations Convention on\
+     Contracts for the International Sale of Goods is expressly excluded.\
+     Any law or regulation which provides that the language of a contract\
+     shall be construed against the drafter shall not apply to this\
+     License.\
+\
+12. RESPONSIBILITY FOR CLAIMS.\
+\
+     As between Initial Developer and the Contributors, each party is\
+     responsible for claims and damages arising, directly or indirectly,\
+     out of its utilization of rights under this License and You agree to\
+     work with Initial Developer and Contributors to distribute such\
+     responsibility on an equitable basis. Nothing herein is intended or\
+     shall be deemed to constitute any admission of liability.\
+\
+13. MULTIPLE-LICENSED CODE.\
+\
+     Initial Developer may designate portions of the Covered Code as\
+     "Multiple-Licensed".  "Multiple-Licensed" means that the Initial\
+     Developer permits you to utilize portions of the Covered Code under\
+     Your choice of the NPL or the alternative licenses, if any, specified\
+     by the Initial Developer in the file described in Exhibit A.\
+\
+EXHIBIT A -Mozilla Public License.\
+\
+     ``The contents of this file are subject to the Mozilla Public License\
+     Version 1.1 (the "License"); you may not use this file except in\
+     compliance with the License. You may obtain a copy of the License at\
+     http://www.mozilla.org/MPL/\
+\
+     Software distributed under the License is distributed on an "AS IS"\
+     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the\
+     License for the specific language governing rights and limitations\
+     under the License.\
+\
+     The Original Code is ______________________________________.\
+\
+     The Initial Developer of the Original Code is ________________________.\
+     Portions created by ______________________ are Copyright (C) ______\
+     _______________________. All Rights Reserved.\
+\
+     Contributor(s): ______________________________________.\
+\
+     Alternatively, the contents of this file may be used under the terms\
+     of the _____ license (the  "[___] License"), in which case the\
+     provisions of [______] License are applicable instead of those\
+     above.  If you wish to allow use of your version of this file only\
+     under the terms of the [____] License and not to allow others to use\
+     your version of this file under the MPL, indicate your decision by\
+     deleting  the provisions above and replace  them with the notice and\
+     other provisions required by the [___] License.  If you do not delete\
+     the provisions above, a recipient may use your version of this file\
+     under either the MPL or the [___] License."\
+\
+     [NOTE: The text of this Exhibit A may differ slightly from the text of\
+     the notices in the Source Code files of the Original Code. You should\
+     use the text of this Exhibit A rather than the text found in the\
+     Original Code Source Code for Your Modifications.]\
+\
+### Microsoft Public License\
+\
+Microsoft Permissive License (Ms-PL)\
+ \
+       This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.\
+ \
+1. Definitions\
+\
+       The terms \uc0\u147 reproduce,\u148  \u147 reproduction,\u148  \u147 derivative works,\u148  and \u147 distribution\u148  have the same meaning here as under U.S. copyright law.\
+       A \uc0\u147 contribution\u148  is the original software, or any additions or changes to the software.\
+       A \uc0\u147 contributor\u148  is any person that distributes its contribution under this license.\
+        \uc0\u147 Licensed patents\u148  are a contributor\u146 s patent claims that read directly on its contribution.\
+ \
+2. Grant of Rights\
+\
+       (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.\
+       (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.\
+ \
+3. Conditions and Limitations\
+\
+       (A) No Trademark License- This license does not grant you rights to use any contributors\uc0\u146  name, logo, or trademarks.\
+       (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.\
+       (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.\
+       (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.\
+       (E) The software is licensed \uc0\u147 as-is.\u148  You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.\
+       (F) If you distribute the software or derivative works with programs you develop, you agree to indemnify, defend, and hold harmless all contributors from any claims, including attorneys\uc0\u146  fees, related to the distribution or use of your programs.  For clarity, you have no such obligations to a contributor for any claims based solely on the unmodified contributions of that contributor.\
+       (G) If you make any additions or changes to the original software, you may only distribute them under a new namespace.  In addition, you will clearly identify your changes or additions as your own.\
+\
+### Infozip BSD\
+\
+This is version 2009-Jan-02 of the Info-ZIP license. The definitive\
+version of this document should be available at\
+ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and a\
+copy at http://www.info-zip.org/pub/infozip/license.html.\
+\
+Copyright (c) 1990-2009 Info-ZIP. All rights reserved.\
+\
+For the purposes of this copyright and license, "Info-ZIP" is defined\
+as the following set of individuals: Mark Adler, John Bush, Karl\
+Davis, Harald Denker, Jean-Michel Dubois, Jean-loup Gailly, Hunter\
+Goatley, Ed Gordon, Ian Gorman, Chris Herborth, Dirk Haase, Greg\
+Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David\
+Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve\
+P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,\
+Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,\
+Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,\
+Rich Wales, Mike White.\
+\
+This software is provided "as is," without warranty of any kind,\
+express or implied. In no event shall Info-ZIP or its contributors be\
+held liable for any direct, indirect, incidental, special or\
+consequential damages arising out of the use of or inability to use\
+this software.\
+\
+Permission is granted to anyone to use this software for any purpose,\
+including commercial applications, and to alter it and redistribute it\
+freely, subject to the above disclaimer and the following\
+restrictions:\
+\
+Redistributions of source code (in whole or in part) must retain the\
+above copyright notice, definition, disclaimer, and this list of\
+conditions.\
+\
+Redistributions in binary form (compiled executables and libraries)\
+must reproduce the above copyright notice, definition, disclaimer, and\
+this list of conditions in documentation and/or other materials\
+provided with the distribution. Additional documentation is not needed\
+for executables where a command line license option provides these and\
+a note regarding this option is in the executable's startup\
+banner. The sole exception to this condition is redistribution of a\
+standard UnZipSFX binary (including SFXWiz) as part of a\
+self-extracting archive; that is permitted without inclusion of this\
+license, as long as the normal SFX banner has not been removed from\
+the binary or disabled.\
+\
+Altered versions--including, but not limited to, ports to new\
+operating systems, existing ports with new graphical interfaces,\
+versions with modified or added functionality, and dynamic, shared, or\
+static library versions not from Info-ZIP--must be plainly marked as\
+such and must not be misrepresented as being the original source or,\
+if binaries, compiled from the original source. Such altered versions\
+also must not be misrepresented as being Info-ZIP releases--including,\
+but not limited to, labeling of the altered versions with the names\
+"Info-ZIP" (or any variation thereof, including, but not limited to,\
+different capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without\
+the explicit permission of Info-ZIP. Such altered versions are further\
+prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP\
+e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP\
+will provide support for the altered versions.\
+\
+Info-ZIP retains the right to use the names "Info-ZIP," "Zip,"\
+"UnZip," "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip"\
+for its own source and binary releases.\
+\
+### License Creative Commons 2.5\
+\
+// Copyright 2006 James Newton-King\
+// http://www.newtonsoft.com\
+//\
+// This work is licensed under the Creative Commons Attribution 2.5 License\
+// http://creativecommons.org/licenses/by/2.5/\
+//\
+// You are free:\
+//    * to copy, distribute, display, and perform the work\
+//    * to make derivative works\
+//    * to make commercial use of the work\
+//\
+// Under the following conditions:\
+//    * For any reuse or distribution, you must make clear to others the license terms of this work.\
+//    * Any of these conditions can be waived if you get permission from the copyright holder.\
+\
+From: james.newtonking@gmail.com [mailto:james.newtonking@gmail.com] On Behalf Of James Newton-King\
+Sent: Tuesday, June 05, 2007 6:36 AM\
+To: Konstantin Triger\
+Subject: Re: Support request by Konstantin Triger for Json.NET\
+\
+Hey Kosta\
+\
+I think it would be awesome to use Json.NET in Mono for System.Web.Extensions.\
+\
+The CC license has the following clause: Any of the above conditions can be waived if you get permission from the copyright holder.\
+\
+I can waive that statement for you and Mono. Would that be acceptable?\
+\
+\
+Regards,\
+James\
+\
+### Creative Commons Attribution 4.0 International Public License\
+\
+Attribution 4.0 International\
+\
+=======================================================================\
+\
+Creative Commons Corporation ("Creative Commons") is not a law firm and\
+does not provide legal services or legal advice. Distribution of\
+Creative Commons public licenses does not create a lawyer-client or\
+other relationship. Creative Commons makes its licenses and related\
+information available on an "as-is" basis. Creative Commons gives no\
+warranties regarding its licenses, any material licensed under their\
+terms and conditions, or any related information. Creative Commons\
+disclaims all liability for damages resulting from their use to the\
+fullest extent possible.\
+\
+Using Creative Commons Public Licenses\
+\
+Creative Commons public licenses provide a standard set of terms and\
+conditions that creators and other rights holders may use to share\
+original works of authorship and other material subject to copyright\
+and certain other rights specified in the public license below. The\
+following considerations are for informational purposes only, are not\
+exhaustive, and do not form part of our licenses.\
+\
+     Considerations for licensors: Our public licenses are\
+     intended for use by those authorized to give the public\
+     permission to use material in ways otherwise restricted by\
+     copyright and certain other rights. Our licenses are\
+     irrevocable. Licensors should read and understand the terms\
+     and conditions of the license they choose before applying it.\
+     Licensors should also secure all rights necessary before\
+     applying our licenses so that the public can reuse the\
+     material as expected. Licensors should clearly mark any\
+     material not subject to the license. This includes other CC-\
+     licensed material, or material used under an exception or\
+     limitation to copyright. More considerations for licensors:\
+       wiki.creativecommons.org/Considerations_for_licensors\
+\
+     Considerations for the public: By using one of our public\
+     licenses, a licensor grants the public permission to use the\
+     licensed material under specified terms and conditions. If\
+     the licensor's permission is not necessary for any reason--for\
+     example, because of any applicable exception or limitation to\
+     copyright--then that use is not regulated by the license. Our\
+     licenses grant only permissions under copyright and certain\
+     other rights that a licensor has authority to grant. Use of\
+     the licensed material may still be restricted for other\
+     reasons, including because others have copyright or other\
+     rights in the material. A licensor may make special requests,\
+     such as asking that all changes be marked or described.\
+     Although not required by our licenses, you are encouraged to\
+     respect those requests where reasonable. More_considerations\
+     for the public: \
+       wiki.creativecommons.org/Considerations_for_licensees\
+\
+=======================================================================\
+\
+Creative Commons Attribution 4.0 International Public License\
+\
+By exercising the Licensed Rights (defined below), You accept and agree\
+to be bound by the terms and conditions of this Creative Commons\
+Attribution 4.0 International Public License ("Public License"). To the\
+extent this Public License may be interpreted as a contract, You are\
+granted the Licensed Rights in consideration of Your acceptance of\
+these terms and conditions, and the Licensor grants You such rights in\
+consideration of benefits the Licensor receives from making the\
+Licensed Material available under these terms and conditions.\
+\
+\
+Section 1 -- Definitions.\
+\
+  a. Adapted Material means material subject to Copyright and Similar\
+     Rights that is derived from or based upon the Licensed Material\
+     and in which the Licensed Material is translated, altered,\
+     arranged, transformed, or otherwise modified in a manner requiring\
+     permission under the Copyright and Similar Rights held by the\
+     Licensor. For purposes of this Public License, where the Licensed\
+     Material is a musical work, performance, or sound recording,\
+     Adapted Material is always produced where the Licensed Material is\
+     synched in timed relation with a moving image.\
+\
+  b. Adapter's License means the license You apply to Your Copyright\
+     and Similar Rights in Your contributions to Adapted Material in\
+     accordance with the terms and conditions of this Public License.\
+\
+  c. Copyright and Similar Rights means copyright and/or similar rights\
+     closely related to copyright including, without limitation,\
+     performance, broadcast, sound recording, and Sui Generis Database\
+     Rights, without regard to how the rights are labeled or\
+     categorized. For purposes of this Public License, the rights\
+     specified in Section 2(b)(1)-(2) are not Copyright and Similar\
+     Rights.\
+\
+  d. Effective Technological Measures means those measures that, in the\
+     absence of proper authority, may not be circumvented under laws\
+     fulfilling obligations under Article 11 of the WIPO Copyright\
+     Treaty adopted on December 20, 1996, and/or similar international\
+     agreements.\
+\
+  e. Exceptions and Limitations means fair use, fair dealing, and/or\
+     any other exception or limitation to Copyright and Similar Rights\
+     that applies to Your use of the Licensed Material.\
+\
+  f. Licensed Material means the artistic or literary work, database,\
+     or other material to which the Licensor applied this Public\
+     License.\
+\
+  g. Licensed Rights means the rights granted to You subject to the\
+     terms and conditions of this Public License, which are limited to\
+     all Copyright and Similar Rights that apply to Your use of the\
+     Licensed Material and that the Licensor has authority to license.\
+\
+  h. Licensor means the individual(s) or entity(ies) granting rights\
+     under this Public License.\
+\
+  i. Share means to provide material to the public by any means or\
+     process that requires permission under the Licensed Rights, such\
+     as reproduction, public display, public performance, distribution,\
+     dissemination, communication, or importation, and to make material\
+     available to the public including in ways that members of the\
+     public may access the material from a place and at a time\
+     individually chosen by them.\
+\
+  j. Sui Generis Database Rights means rights other than copyright\
+     resulting from Directive 96/9/EC of the European Parliament and of\
+     the Council of 11 March 1996 on the legal protection of databases,\
+     as amended and/or succeeded, as well as other essentially\
+     equivalent rights anywhere in the world.\
+\
+  k. You means the individual or entity exercising the Licensed Rights\
+     under this Public License. Your has a corresponding meaning.\
+\
+\
+Section 2 -- Scope.\
+\
+  a. License grant.\
+\
+       1. Subject to the terms and conditions of this Public License,\
+          the Licensor hereby grants You a worldwide, royalty-free,\
+          non-sublicensable, non-exclusive, irrevocable license to\
+          exercise the Licensed Rights in the Licensed Material to:\
+\
+            a. reproduce and Share the Licensed Material, in whole or\
+               in part; and\
+\
+            b. produce, reproduce, and Share Adapted Material.\
+\
+       2. Exceptions and Limitations. For the avoidance of doubt, where\
+          Exceptions and Limitations apply to Your use, this Public\
+          License does not apply, and You do not need to comply with\
+          its terms and conditions.\
+\
+       3. Term. The term of this Public License is specified in Section\
+          6(a).\
+\
+       4. Media and formats; technical modifications allowed. The\
+          Licensor authorizes You to exercise the Licensed Rights in\
+          all media and formats whether now known or hereafter created,\
+          and to make technical modifications necessary to do so. The\
+          Licensor waives and/or agrees not to assert any right or\
+          authority to forbid You from making technical modifications\
+          necessary to exercise the Licensed Rights, including\
+          technical modifications necessary to circumvent Effective\
+          Technological Measures. For purposes of this Public License,\
+          simply making modifications authorized by this Section 2(a)\
+          (4) never produces Adapted Material.\
+\
+       5. Downstream recipients.\
+\
+            a. Offer from the Licensor -- Licensed Material. Every\
+               recipient of the Licensed Material automatically\
+               receives an offer from the Licensor to exercise the\
+               Licensed Rights under the terms and conditions of this\
+               Public License.\
+\
+            b. No downstream restrictions. You may not offer or impose\
+               any additional or different terms or conditions on, or\
+               apply any Effective Technological Measures to, the\
+               Licensed Material if doing so restricts exercise of the\
+               Licensed Rights by any recipient of the Licensed\
+               Material.\
+\
+       6. No endorsement. Nothing in this Public License constitutes or\
+          may be construed as permission to assert or imply that You\
+          are, or that Your use of the Licensed Material is, connected\
+          with, or sponsored, endorsed, or granted official status by,\
+          the Licensor or others designated to receive attribution as\
+          provided in Section 3(a)(1)(A)(i).\
+\
+  b. Other rights.\
+\
+       1. Moral rights, such as the right of integrity, are not\
+          licensed under this Public License, nor are publicity,\
+          privacy, and/or other similar personality rights; however, to\
+          the extent possible, the Licensor waives and/or agrees not to\
+          assert any such rights held by the Licensor to the limited\
+          extent necessary to allow You to exercise the Licensed\
+          Rights, but not otherwise.\
+\
+       2. Patent and trademark rights are not licensed under this\
+          Public License.\
+\
+       3. To the extent possible, the Licensor waives any right to\
+          collect royalties from You for the exercise of the Licensed\
+          Rights, whether directly or through a collecting society\
+          under any voluntary or waivable statutory or compulsory\
+          licensing scheme. In all other cases the Licensor expressly\
+          reserves any right to collect such royalties.\
+\
+\
+Section 3 -- License Conditions.\
+\
+Your exercise of the Licensed Rights is expressly made subject to the\
+following conditions.\
+\
+  a. Attribution.\
+\
+       1. If You Share the Licensed Material (including in modified\
+          form), You must:\
+\
+            a. retain the following if it is supplied by the Licensor\
+               with the Licensed Material:\
+\
+                 i. identification of the creator(s) of the Licensed\
+                    Material and any others designated to receive\
+                    attribution, in any reasonable manner requested by\
+                    the Licensor (including by pseudonym if\
+                    designated);\
+\
+                ii. a copyright notice;\
+\
+               iii. a notice that refers to this Public License;\
+\
+                iv. a notice that refers to the disclaimer of\
+                    warranties;\
+\
+                 v. a URI or hyperlink to the Licensed Material to the\
+                    extent reasonably practicable;\
+\
+            b. indicate if You modified the Licensed Material and\
+               retain an indication of any previous modifications; and\
+\
+            c. indicate the Licensed Material is licensed under this\
+               Public License, and include the text of, or the URI or\
+               hyperlink to, this Public License.\
+\
+       2. You may satisfy the conditions in Section 3(a)(1) in any\
+          reasonable manner based on the medium, means, and context in\
+          which You Share the Licensed Material. For example, it may be\
+          reasonable to satisfy the conditions by providing a URI or\
+          hyperlink to a resource that includes the required\
+          information.\
+\
+       3. If requested by the Licensor, You must remove any of the\
+          information required by Section 3(a)(1)(A) to the extent\
+          reasonably practicable.\
+\
+       4. If You Share Adapted Material You produce, the Adapter's\
+          License You apply must not prevent recipients of the Adapted\
+          Material from complying with this Public License.\
+\
+\
+Section 4 -- Sui Generis Database Rights.\
+\
+Where the Licensed Rights include Sui Generis Database Rights that\
+apply to Your use of the Licensed Material:\
+\
+  a. for the avoidance of doubt, Section 2(a)(1) grants You the right\
+     to extract, reuse, reproduce, and Share all or a substantial\
+     portion of the contents of the database;\
+\
+  b. if You include all or a substantial portion of the database\
+     contents in a database in which You have Sui Generis Database\
+     Rights, then the database in which You have Sui Generis Database\
+     Rights (but not its individual contents) is Adapted Material; and\
+\
+  c. You must comply with the conditions in Section 3(a) if You Share\
+     all or a substantial portion of the contents of the database.\
+\
+For the avoidance of doubt, this Section 4 supplements and does not\
+replace Your obligations under this Public License where the Licensed\
+Rights include other Copyright and Similar Rights.\
+\
+\
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.\
+\
+  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\
+     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\
+     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\
+     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\
+     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\
+     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\
+     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\
+     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\
+     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\
+     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\
+\
+  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\
+     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\
+     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\
+     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\
+     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\
+     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\
+     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\
+     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\
+     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\
+\
+  c. The disclaimer of warranties and limitation of liability provided\
+     above shall be interpreted in a manner that, to the extent\
+     possible, most closely approximates an absolute disclaimer and\
+     waiver of all liability.\
+\
+\
+Section 6 -- Term and Termination.\
+\
+  a. This Public License applies for the term of the Copyright and\
+     Similar Rights licensed here. However, if You fail to comply with\
+     this Public License, then Your rights under this Public License\
+     terminate automatically.\
+\
+  b. Where Your right to use the Licensed Material has terminated under\
+     Section 6(a), it reinstates:\
+\
+       1. automatically as of the date the violation is cured, provided\
+          it is cured within 30 days of Your discovery of the\
+          violation; or\
+\
+       2. upon express reinstatement by the Licensor.\
+\
+     For the avoidance of doubt, this Section 6(b) does not affect any\
+     right the Licensor may have to seek remedies for Your violations\
+     of this Public License.\
+\
+  c. For the avoidance of doubt, the Licensor may also offer the\
+     Licensed Material under separate terms or conditions or stop\
+     distributing the Licensed Material at any time; however, doing so\
+     will not terminate this Public License.\
+\
+  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\
+     License.\
+\
+\
+Section 7 -- Other Terms and Conditions.\
+\
+  a. The Licensor shall not be bound by any additional or different\
+     terms or conditions communicated by You unless expressly agreed.\
+\
+  b. Any arrangements, understandings, or agreements regarding the\
+     Licensed Material not stated herein are separate from and\
+     independent of the terms and conditions of this Public License.\
+\
+\
+Section 8 -- Interpretation.\
+\
+  a. For the avoidance of doubt, this Public License does not, and\
+     shall not be interpreted to, reduce, limit, restrict, or impose\
+     conditions on any use of the Licensed Material that could lawfully\
+     be made without permission under this Public License.\
+\
+  b. To the extent possible, if any provision of this Public License is\
+     deemed unenforceable, it shall be automatically reformed to the\
+     minimum extent necessary to make it enforceable. If the provision\
+     cannot be reformed, it shall be severed from this Public License\
+     without affecting the enforceability of the remaining terms and\
+     conditions.\
+\
+  c. No term or condition of this Public License will be waived and no\
+     failure to comply consented to unless expressly agreed to by the\
+     Licensor.\
+\
+  d. Nothing in this Public License constitutes or may be interpreted\
+     as a limitation upon, or waiver of, any privileges and immunities\
+     that apply to the Licensor or You, including from the legal\
+     processes of any jurisdiction or authority.\
+\
+\
+=======================================================================\
+\
+Creative Commons is not a party to its public\
+licenses. Notwithstanding, Creative Commons may elect to apply one of\
+its public licenses to material it publishes and in those instances\
+will be considered the \'93Licensor.\'94 The text of the Creative Commons\
+public licenses is dedicated to the public domain under the CC0 Public\
+Domain Dedication. Except for the limited purpose of indicating that\
+material is shared under a Creative Commons public license or as\
+otherwise permitted by the Creative Commons policies published at\
+creativecommons.org/policies, Creative Commons does not authorize the\
+use of the trademark "Creative Commons" or any other trademark or logo\
+of Creative Commons without its prior written consent including,\
+without limitation, in connection with any unauthorized modifications\
+to any of its public licenses or any other arrangements,\
+understandings, or agreements concerning use of licensed material. For\
+the avoidance of doubt, this paragraph does not form part of the\
+public licenses.\
+\
+Creative Commons may be contacted at creativecommons.org.\
+\
+### GPL version 2\
+\
+                   GNU GENERAL PUBLIC LICENSE\
+                      Version 2, June 1991\
+\
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.\
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\
+ Everyone is permitted to copy and distribute verbatim copies\
+ of this license document, but changing it is not allowed.\
+\
+                           Preamble\
+\
+  The licenses for most software are designed to take away your\
+freedom to share and change it.  By contrast, the GNU General Public\
+License is intended to guarantee your freedom to share and change free\
+software--to make sure the software is free for all its users.  This\
+General Public License applies to most of the Free Software\
+Foundation's software and to any other program whose authors commit to\
+using it.  (Some other Free Software Foundation software is covered by\
+the GNU Library General Public License instead.)  You can apply it to\
+your programs, too.\
+\
+  When we speak of free software, we are referring to freedom, not\
+price.  Our General Public Licenses are designed to make sure that you\
+have the freedom to distribute copies of free software (and charge for\
+this service if you wish), that you receive source code or can get it\
+if you want it, that you can change the software or use pieces of it\
+in new free programs; and that you know you can do these things.\
+\
+  To protect your rights, we need to make restrictions that forbid\
+anyone to deny you these rights or to ask you to surrender the rights.\
+These restrictions translate to certain responsibilities for you if you\
+distribute copies of the software, or if you modify it.\
+\
+  For example, if you distribute copies of such a program, whether\
+gratis or for a fee, you must give the recipients all the rights that\
+you have.  You must make sure that they, too, receive or can get the\
+source code.  And you must show them these terms so they know their\
+rights.\
+\
+  We protect your rights with two steps: (1) copyright the software, and\
+(2) offer you this license which gives you legal permission to copy,\
+distribute and/or modify the software.\
+\
+  Also, for each author's protection and ours, we want to make certain\
+that everyone understands that there is no warranty for this free\
+software.  If the software is modified by someone else and passed on, we\
+want its recipients to know that what they have is not the original, so\
+that any problems introduced by others will not reflect on the original\
+authors' reputations.\
+\
+  Finally, any free program is threatened constantly by software\
+patents.  We wish to avoid the danger that redistributors of a free\
+program will individually obtain patent licenses, in effect making the\
+program proprietary.  To prevent this, we have made it clear that any\
+patent must be licensed for everyone's free use or not licensed at all.\
+\
+  The precise terms and conditions for copying, distribution and\
+modification follow.\
+\page \
+                   GNU GENERAL PUBLIC LICENSE\
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\
+\
+  0. This License applies to any program or other work which contains\
+a notice placed by the copyright holder saying it may be distributed\
+under the terms of this General Public License.  The "Program", below,\
+refers to any such program or work, and a "work based on the Program"\
+means either the Program or any derivative work under copyright law:\
+that is to say, a work containing the Program or a portion of it,\
+either verbatim or with modifications and/or translated into another\
+language.  (Hereinafter, translation is included without limitation in\
+the term "modification".)  Each licensee is addressed as "you".\
+\
+Activities other than copying, distribution and modification are not\
+covered by this License; they are outside its scope.  The act of\
+running the Program is not restricted, and the output from the Program\
+is covered only if its contents constitute a work based on the\
+Program (independent of having been made by running the Program).\
+Whether that is true depends on what the Program does.\
+\
+  1. You may copy and distribute verbatim copies of the Program's\
+source code as you receive it, in any medium, provided that you\
+conspicuously and appropriately publish on each copy an appropriate\
+copyright notice and disclaimer of warranty; keep intact all the\
+notices that refer to this License and to the absence of any warranty;\
+and give any other recipients of the Program a copy of this License\
+along with the Program.\
+\
+You may charge a fee for the physical act of transferring a copy, and\
+you may at your option offer warranty protection in exchange for a fee.\
+\
+  2. You may modify your copy or copies of the Program or any portion\
+of it, thus forming a work based on the Program, and copy and\
+distribute such modifications or work under the terms of Section 1\
+above, provided that you also meet all of these conditions:\
+\
+    a) You must cause the modified files to carry prominent notices\
+    stating that you changed the files and the date of any change.\
+\
+    b) You must cause any work that you distribute or publish, that in\
+    whole or in part contains or is derived from the Program or any\
+    part thereof, to be licensed as a whole at no charge to all third\
+    parties under the terms of this License.\
+\
+    c) If the modified program normally reads commands interactively\
+    when run, you must cause it, when started running for such\
+    interactive use in the most ordinary way, to print or display an\
+    announcement including an appropriate copyright notice and a\
+    notice that there is no warranty (or else, saying that you provide\
+    a warranty) and that users may redistribute the program under\
+    these conditions, and telling the user how to view a copy of this\
+    License.  (Exception: if the Program itself is interactive but\
+    does not normally print such an announcement, your work based on\
+    the Program is not required to print an announcement.)\
+\page \
+These requirements apply to the modified work as a whole.  If\
+identifiable sections of that work are not derived from the Program,\
+and can be reasonably considered independent and separate works in\
+themselves, then this License, and its terms, do not apply to those\
+sections when you distribute them as separate works.  But when you\
+distribute the same sections as part of a whole which is a work based\
+on the Program, the distribution of the whole must be on the terms of\
+this License, whose permissions for other licensees extend to the\
+entire whole, and thus to each and every part regardless of who wrote it.\
+\
+Thus, it is not the intent of this section to claim rights or contest\
+your rights to work written entirely by you; rather, the intent is to\
+exercise the right to control the distribution of derivative or\
+collective works based on the Program.\
+\
+In addition, mere aggregation of another work not based on the Program\
+with the Program (or with a work based on the Program) on a volume of\
+a storage or distribution medium does not bring the other work under\
+the scope of this License.\
+\
+  3. You may copy and distribute the Program (or a work based on it,\
+under Section 2) in object code or executable form under the terms of\
+Sections 1 and 2 above provided that you also do one of the following:\
+\
+    a) Accompany it with the complete corresponding machine-readable\
+    source code, which must be distributed under the terms of Sections\
+    1 and 2 above on a medium customarily used for software interchange; or,\
+\
+    b) Accompany it with a written offer, valid for at least three\
+    years, to give any third party, for a charge no more than your\
+    cost of physically performing source distribution, a complete\
+    machine-readable copy of the corresponding source code, to be\
+    distributed under the terms of Sections 1 and 2 above on a medium\
+    customarily used for software interchange; or,\
+\
+    c) Accompany it with the information you received as to the offer\
+    to distribute corresponding source code.  (This alternative is\
+    allowed only for noncommercial distribution and only if you\
+    received the program in object code or executable form with such\
+    an offer, in accord with Subsection b above.)\
+\
+The source code for a work means the preferred form of the work for\
+making modifications to it.  For an executable work, complete source\
+code means all the source code for all modules it contains, plus any\
+associated interface definition files, plus the scripts used to\
+control compilation and installation of the executable.  However, as a\
+special exception, the source code distributed need not include\
+anything that is normally distributed (in either source or binary\
+form) with the major components (compiler, kernel, and so on) of the\
+operating system on which the executable runs, unless that component\
+itself accompanies the executable.\
+\
+If distribution of executable or object code is made by offering\
+access to copy from a designated place, then offering equivalent\
+access to copy the source code from the same place counts as\
+distribution of the source code, even though third parties are not\
+compelled to copy the source along with the object code.\
+\page \
+  4. You may not copy, modify, sublicense, or distribute the Program\
+except as expressly provided under this License.  Any attempt\
+otherwise to copy, modify, sublicense or distribute the Program is\
+void, and will automatically terminate your rights under this License.\
+However, parties who have received copies, or rights, from you under\
+this License will not have their licenses terminated so long as such\
+parties remain in full compliance.\
+\
+  5. You are not required to accept this License, since you have not\
+signed it.  However, nothing else grants you permission to modify or\
+distribute the Program or its derivative works.  These actions are\
+prohibited by law if you do not accept this License.  Therefore, by\
+modifying or distributing the Program (or any work based on the\
+Program), you indicate your acceptance of this License to do so, and\
+all its terms and conditions for copying, distributing or modifying\
+the Program or works based on it.\
+\
+  6. Each time you redistribute the Program (or any work based on the\
+Program), the recipient automatically receives a license from the\
+original licensor to copy, distribute or modify the Program subject to\
+these terms and conditions.  You may not impose any further\
+restrictions on the recipients' exercise of the rights granted herein.\
+You are not responsible for enforcing compliance by third parties to\
+this License.\
+\
+  7. If, as a consequence of a court judgment or allegation of patent\
+infringement or for any other reason (not limited to patent issues),\
+conditions are imposed on you (whether by court order, agreement or\
+otherwise) that contradict the conditions of this License, they do not\
+excuse you from the conditions of this License.  If you cannot\
+distribute so as to satisfy simultaneously your obligations under this\
+License and any other pertinent obligations, then as a consequence you\
+may not distribute the Program at all.  For example, if a patent\
+license would not permit royalty-free redistribution of the Program by\
+all those who receive copies directly or indirectly through you, then\
+the only way you could satisfy both it and this License would be to\
+refrain entirely from distribution of the Program.\
+\
+If any portion of this section is held invalid or unenforceable under\
+any particular circumstance, the balance of the section is intended to\
+apply and the section as a whole is intended to apply in other\
+circumstances.\
+\
+It is not the purpose of this section to induce you to infringe any\
+patents or other property right claims or to contest validity of any\
+such claims; this section has the sole purpose of protecting the\
+integrity of the free software distribution system, which is\
+implemented by public license practices.  Many people have made\
+generous contributions to the wide range of software distributed\
+through that system in reliance on consistent application of that\
+system; it is up to the author/donor to decide if he or she is willing\
+to distribute software through any other system and a licensee cannot\
+impose that choice.\
+\
+This section is intended to make thoroughly clear what is believed to\
+be a consequence of the rest of this License.\
+\page \
+  8. If the distribution and/or use of the Program is restricted in\
+certain countries either by patents or by copyrighted interfaces, the\
+original copyright holder who places the Program under this License\
+may add an explicit geographical distribution limitation excluding\
+those countries, so that distribution is permitted only in or among\
+countries not thus excluded.  In such case, this License incorporates\
+the limitation as if written in the body of this License.\
+\
+  9. The Free Software Foundation may publish revised and/or new versions\
+of the General Public License from time to time.  Such new versions will\
+be similar in spirit to the present version, but may differ in detail to\
+address new problems or concerns.\
+\
+Each version is given a distinguishing version number.  If the Program\
+specifies a version number of this License which applies to it and "any\
+later version", you have the option of following the terms and conditions\
+either of that version or of any later version published by the Free\
+Software Foundation.  If the Program does not specify a version number of\
+this License, you may choose any version ever published by the Free Software\
+Foundation.\
+\
+  10. If you wish to incorporate parts of the Program into other free\
+programs whose distribution conditions are different, write to the author\
+to ask for permission.  For software which is copyrighted by the Free\
+Software Foundation, write to the Free Software Foundation; we sometimes\
+make exceptions for this.  Our decision will be guided by the two goals\
+of preserving the free status of all derivatives of our free software and\
+of promoting the sharing and reuse of software generally.\
+\
+                           NO WARRANTY\
+\
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\
+REPAIR OR CORRECTION.\
+\
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\
+POSSIBILITY OF SUCH DAMAGES.\
+\
+                    END OF TERMS AND CONDITIONS\
+\page \
+           How to Apply These Terms to Your New Programs\
+\
+  If you develop a new program, and you want it to be of the greatest\
+possible use to the public, the best way to achieve this is to make it\
+free software which everyone can redistribute and change under these terms.\
+\
+  To do so, attach the following notices to the program.  It is safest\
+to attach them to the start of each source file to most effectively\
+convey the exclusion of warranty; and each file should have at least\
+the "copyright" line and a pointer to where the full notice is found.\
+\
+    <one line to give the program's name and a brief idea of what it does.>\
+    Copyright (C) <year>  <name of author>\
+\
+    This program is free software; you can redistribute it and/or modify\
+    it under the terms of the GNU General Public License as published by\
+    the Free Software Foundation; either version 2 of the License, or\
+    (at your option) any later version.\
+\
+    This program is distributed in the hope that it will be useful,\
+    but WITHOUT ANY WARRANTY; without even the implied warranty of\
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\
+    GNU General Public License for more details.\
+\
+    You should have received a copy of the GNU General Public License\
+    along with this program; if not, write to the Free Software\
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\
+\
+\
+Also add information on how to contact you by electronic and paper mail.\
+\
+If the program is interactive, make it output a short notice like this\
+when it starts in an interactive mode:\
+\
+    Gnomovision version 69, Copyright (C) year  name of author\
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\
+    This is free software, and you are welcome to redistribute it\
+    under certain conditions; type `show c' for details.\
+\
+The hypothetical commands `show w' and `show c' should show the appropriate\
+parts of the General Public License.  Of course, the commands you use may\
+be called something other than `show w' and `show c'; they could even be\
+mouse-clicks or menu items--whatever suits your program.\
+\
+You should also get your employer (if you work as a programmer) or your\
+school, if any, to sign a "copyright disclaimer" for the program, if\
+necessary.  Here is a sample; alter the names:\
+\
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.\
+\
+  <signature of Ty Coon>, 1 April 1989\
+  Ty Coon, President of Vice\
+\
+This General Public License does not permit incorporating your program into\
+proprietary programs.  If your program is a subroutine library, you may\
+consider it more useful to permit linking proprietary applications with the\
+library.  If this is what you want to do, use the GNU Library General\
+Public License instead of this License.\
+}
diff --git a/packaging/Windows/resources/wrapper.bat b/packaging/Windows/resources/wrapper.bat
new file mode 100755 (executable)
index 0000000..e8d0688
--- /dev/null
@@ -0,0 +1,2 @@
+@echo off\r
+"%~dp0\mono.exe" %MONO_OPTIONS% "%~dp0\..\lib\mono\@@RUNTIME@@\@@COMMAND@@" %*\r
index ae87dfa88c37f436cff9022ff5b69127d58b7e8e..052a45eeaeb3bf235e56a49bec0550313c14c96e 100644 (file)
@@ -167,12 +167,8 @@ mcs-compileall: mono-wrapper etc/mono/config
        if [ "$$ok" = "false" ]; then echo "<?xml version='1.0' encoding='utf-8'?><test-results failures='1' total='1' not-run='0' name='verify' date='$$(date +%F)' time='$$(date +%T)'><test-suite name='mcs-compileall' success='False' time='0'><results><test-case name='fail' executed='True' success='False' time='0'><failure><message>Verifying framework assemblies failed. Check the log for more details.</message><stack-trace></stack-trace></failure></test-case></results></test-suite></test-results>" > TestResult-verify.xml; fi; \
        $$ok
 
-if NACL_CODEGEN
-check-local:
-else
 check-local: mcs-compileall mcs-do-test-profiles
        $(MAKE) mcs-do-run-test-profiles
-endif
 
 # Compile all mcs tests
 test: mcs-do-test-profiles
index 7c2822f4b996ef75426ccfdb805e0f56e6a5b8d7..33ff88d6f2143b1195c623b07b66c11a70a2fef9 100644 (file)
@@ -4,13 +4,4 @@ MONO_CFG_DIR='@mono_cfg_dir@'
 PATH="$r/runtime/_tmpinst/bin:$PATH"
 MONO_EXECUTABLE=${MONO_EXECUTABLE:-"$r/@mono_runtime@"}
 export MONO_CFG_DIR PATH
-if [ -n "@nacl_self_host@" ]; then
-  case "$@" in
-    # gacutil.exe and mdoc.exe require filesystem functionality not
-    # exposed in NaCl.
-    # mcs.exe was added to the list recently because mcs under NaCl
-    # no longer produces equivalent output. TODO: investigate
-    */mcs.exe* | */gacutil.exe* | */mdoc.exe* ) exec /usr/local/bin/mono "$@";;
-  esac
-fi
 exec "$r/libtool" --mode=execute "${MONO_EXECUTABLE}" --config "@mono_cfg_dir@/mono/config" "$@"
index e87ea8838ebd3797c40b857fd8c0667b4c7d1f98..a308f1b252b528b0c4c2ce34e8d0f042641c2136 100755 (executable)
@@ -5,7 +5,13 @@ export TESTCMD=${MONO_REPO_ROOT}/scripts/ci/run-step.sh
 
 export TEST_HARNESS_VERBOSE=1
 
-if [[ ${label} == w* ]]; then
+if [[ $CI_TAGS == *'collect-coverage'* ]]; then
+    # Collect coverage for further use by lcov and similar tools.
+    # Coverage must be collected with -O0 and debug information.
+    export CFLAGS="-ggdb3 --coverage -O0"
+    # Collect coverage on all optimizations
+    export MONO_ENV_OPTIONS="$MONO_ENV_OPTIONS -O=all"
+elif [[ ${label} == w* ]]; then
     # Passing -ggdb3 on Cygwin breaks linking against libmonosgen-x.y.dll
     export CFLAGS="-g -O2"
 else
index 91e16caf6b878bb836f8eeb9ced7f1c568adbb24..5b35712b610c206b725fbdd4ca833d15472da736 100755 (executable)
@@ -10,7 +10,7 @@ if [ "$total_tests" -lt "1600" ]
        exit 1
 fi
 
-${TESTCMD} --label=check-roslyn --timeout=30m make -C acceptance-tests check-roslyn PREFIX=${WORKSPACE}/tmp/mono-acceptance-tests
+${TESTCMD} --label=check-roslyn --timeout=30m make -C acceptance-tests check-roslyn PREFIX=${MONO_REPO_ROOT}/tmp/mono-acceptance-tests
 rm -rf ${MONO_REPO_ROOT}/tmp/mono-acceptance-tests  # cleanup the Mono installation used for Roslyn tests
 
 ${TESTCMD} --label=coreclr-compile-tests --timeout=80m --fatal make -C acceptance-tests coreclr-compile-tests
index 59dfb9121535523c69d85d2decf9a8360d0f02c9..9e41e894d5511b7bb505f473981ffd9813a8eaf6 100755 (executable)
@@ -50,6 +50,7 @@ ${TESTCMD} --label=Microsoft.Build.Framework --timeout=5m make -w -C mcs/class/M
 ${TESTCMD} --label=Microsoft.Build.Tasks --timeout=5m make -w -C mcs/class/Microsoft.Build.Tasks run-test
 ${TESTCMD} --label=Microsoft.Build.Utilities --timeout=5m make -w -C mcs/class/Microsoft.Build.Utilities run-test
 ${TESTCMD} --label=Mono.C5 --timeout=5m make -w -C mcs/class/Mono.C5 run-test
+${TESTCMD} --label=Mono.Options --timeout=5m make -w -C mcs/class/Mono.Options run-test
 ${TESTCMD} --label=Mono.Tasklets --timeout=5m make -w -C mcs/class/Mono.Tasklets run-test
 ${TESTCMD} --label=System.Configuration --timeout=5m make -w -C mcs/class/System.Configuration run-test
 ${TESTCMD} --label=System.Transactions --timeout=5m make -w -C mcs/class/System.Transactions run-test
@@ -72,6 +73,7 @@ ${TESTCMD} --label=System.Web.DynamicData --timeout=5m make -w -C mcs/class/Syst
 ${TESTCMD} --label=Mono.CSharp --timeout=5m make -w -C mcs/class/Mono.CSharp run-test
 ${TESTCMD} --label=WindowsBase --timeout=5m make -w -C mcs/class/WindowsBase run-test
 ${TESTCMD} --label=System.Numerics --timeout=5m make -w -C mcs/class/System.Numerics run-test
+if [[ ${label} == w* ]]; then ${TESTCMD} --label=System.Numerics-xunit --skip; else ${TESTCMD} --label=System.Numerics-xunit --timeout=5m make -w -C mcs/class/System.Numerics run-xunit-test; fi
 ${TESTCMD} --label=System.Runtime.DurableInstancing --timeout=5m make -w -C mcs/class/System.Runtime.DurableInstancing run-test
 ${TESTCMD} --label=System.ServiceModel.Discovery --timeout=5m make -w -C mcs/class/System.ServiceModel.Discovery run-test
 ${TESTCMD} --label=System.Xaml --timeout=5m make -w -C mcs/class/System.Xaml run-test
index 54016f99faabf8b5b3d422139a4207878a9c8a82..0de260a32377b2e456c9c8b30e65349195ee9a08 100644 (file)
@@ -809,6 +809,7 @@ namespace CppSharp
                 "SeqPointInfo",
                 "DynCallArgs", 
                 "MonoLMFTramp",
+                "InterpMethodArguments",
             };
 
             DumpClasses(writer, ctx, optionalTypes, optional: true);