Merge pull request #5010 from Unity-Technologies/boehm-gc-alloc-fixed-sre
authorAleksey Kliger (λgeek) <akliger@gmail.com>
Fri, 16 Jun 2017 14:38:37 +0000 (10:38 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Jun 2017 14:38:37 +0000 (10:38 -0400)
Boehm GC Fixes - SRE and Handle Stack

221 files changed:
.gitmodules
configure.ac
external/api-snapshot
external/bockbuild
external/buildtools [deleted submodule]
external/corefx
external/xunit-binaries
man/mono.1
mcs/build/common/basic-profile-check.cs
mcs/build/tests.make
mcs/class/Facades/System.Runtime.InteropServices.RuntimeInformation/Facades_System.Runtime.InteropServices.RuntimeInformation-net_4_x.csproj
mcs/class/Microsoft.CSharp/Microsoft.CSharp-net_4_x.csproj
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.Security/Mono.Security.X509/PKCS12.cs
mcs/class/System.Drawing/Makefile
mcs/class/System.Drawing/System.Drawing-net_4_x.csproj
mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.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/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/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/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.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/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/Image.cs
mcs/class/System.Drawing/System.Drawing/Pen.cs
mcs/class/System.Drawing/System.Drawing/Region.cs
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/System.Numerics_xtest.dll.sources
mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs
mcs/class/System/ReferenceSources/Win32Exception.cs
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/corlib/corlib-net_4_x.csproj
mcs/class/monodoc/Test/README.md [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/cs0165-56.cs [new file with mode: 0644]
mcs/errors/cs1644-52.cs [new file with mode: 0644]
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/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/cs8208.cs [new file with mode: 0644]
mcs/mcs/context.cs
mcs/mcs/cs-parser.jay
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/statement.cs
mcs/tests/known-issues-net_4_x
mcs/tests/test-pattern-01.cs
mcs/tests/test-pattern-02.cs
mcs/tests/ver-il-net_4_x.xml
mcs/tools/linker/monolinker-net_4_x.csproj
mono/metadata/assembly.c
mono/metadata/marshal.c
mono/metadata/metadata-internals.h
mono/metadata/method-builder.c
mono/metadata/method-builder.h
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/sgen-stw.c
mono/mini/aot-compiler.c
mono/mini/debugger-agent.c
mono/mini/mini-arm64.c
mono/mini/mini-exceptions.c
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/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
net_4_x.sln
packaging/MacSDK/nuget.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]
scripts/ci/run-test-acceptance-tests.sh
scripts/ci/run-test-default.sh
winconfig.h

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 6ee80da49b6c8eeab839abbda70da17c51212eb0..d0e93384fddb6e095b2508cd85fc6efa6120eb5d 100644 (file)
@@ -3534,12 +3534,6 @@ fi
 
 AM_CONDITIONAL(ENABLE_INTERPRETER, [test x$enable_interpreter = xyes])
 
-if test "x$enable_interpreter" = "xyes" || test "x$mono_feature_disable_jit" != "xyes"; then
-       AC_DEFINE(HAVE_ONLINE_VES, 1, [Some VES is available at runtime])
-fi
-
-AM_CONDITIONAL(HAVE_ONLINE_VES, [test x$enable_interpreter = xyes] || [test x$mono_feature_disable_jit != xyes])
-
 dnl 
 dnl Simple Generational checks (sgen)
 dnl
index 1563f6ea5ba2f4c6f3e9c6e625ee8b16e3a1d39e..032ea9507a680d80ba17c2594868647301d1893f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1563f6ea5ba2f4c6f3e9c6e625ee8b16e3a1d39e
+Subproject commit 032ea9507a680d80ba17c2594868647301d1893f
index fe467c0593d199e5d4d29be9c69c5d487449dd8b..58bf3183031479747adcceceb622aea3aa076e38 160000 (submodule)
@@ -1 +1 @@
-Subproject commit fe467c0593d199e5d4d29be9c69c5d487449dd8b
+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 eed0d37c001fdd17acf3dd33cacd4f66df5294c0..66465f7b9147ebbcb0fec50f4b538188627c2867 160000 (submodule)
@@ -1 +1 @@
-Subproject commit eed0d37c001fdd17acf3dd33cacd4f66df5294c0
+Subproject commit 66465f7b9147ebbcb0fec50f4b538188627c2867
index b8e20d265b368dd6252703d5afd038d0b028e388..d4433b0972f40cb3efaa3fbba52869bde5df8fa8 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b8e20d265b368dd6252703d5afd038d0b028e388
+Subproject commit d4433b0972f40cb3efaa3fbba52869bde5df8fa8
index e822ff94c89b2aa98b745633ab4fcff87fbdb2ba..89a051e250618a0df87ccdda255d69d6c35ebbc6 100644 (file)
@@ -1309,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
@@ -1375,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 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;
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 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 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 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 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 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..a66af25c3ccabf50d543d255c5b4445f709b91c9 100644 (file)
   </PropertyGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <ItemGroup>\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\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\UITypeEditorEditStyle.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\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\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\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\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\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\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\ImageCodecFlags.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\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\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\PrinterUnit.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\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\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\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\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\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/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.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/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/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);
-               }
-       }
-}
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.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 4a10fca499eedd7e153e9d3a9ef84a30c89b18bb..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
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSameAssemblyAttribute.cs
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
-System.Drawing/Brush.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
@@ -50,20 +64,20 @@ 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
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/UITypeEditorEditStyle.cs
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/IPropertyValueUIService.cs
@@ -81,115 +95,124 @@ System.Drawing/ToolboxBitmapAttribute.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
+       ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Design/UITypeEditor.cs
 ../../../external/corefx/src/System.Drawing.Common/src/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/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
+../../../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
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnit.cs
-System.Drawing.Printing/PrinterUnitConvert.cs
+../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnitConvert.cs
 System.Drawing.Printing/PrintEventArgs.cs
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintEventHandler.cs
-System.Drawing.Printing/PrintingPermissionAttribute.cs
-System.Drawing.Printing/PrintingPermission.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
 ../../../external/corefx/src/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventHandler.cs
-System.Drawing.Printing/PrintRange.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/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);
                }
 
index 528d91004faa7372446cc5bc9081f77be8a04a28..30ae8311b27c42a181ebda13387b4b387c9ed27d 100644 (file)
@@ -169,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;
@@ -325,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 {
@@ -451,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);
                }
@@ -478,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 ()) {
@@ -502,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);
@@ -512,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);
@@ -626,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;
                }
 
@@ -640,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;
                }
@@ -791,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/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 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 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";
diff --git a/mcs/class/Xunit.NetCore.Extensions/Makefile b/mcs/class/Xunit.NetCore.Extensions/Makefile
deleted file mode 100644 (file)
index 7ea0857..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 Facades/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 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
 
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/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/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/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/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/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/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 b36fc7aeaa1042af6b9772f1bd9d9d6b60cde98e..b7e773cffed98e88eb596dd77d51a3d06149de2a 100644 (file)
@@ -565,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 f505da1768599ccb6b44b9202205a55af2766385..2df53e916640209092711ab75dee2489d0e8f64d 100644 (file)
@@ -2642,15 +2642,10 @@ event_declarator
                $$ = new FieldDeclarator (new SimpleMemberName (lt.Value, lt.Location), null);
                lbag.AddLocation ($$, GetLocation ($1));
          }
-       | COMMA IDENTIFIER ASSIGN
-         {
-               ++lexer.parsing_block;
-         }
-         event_variable_initializer
+       | COMMA IDENTIFIER ASSIGN 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));
          }
        ;
@@ -2665,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;
          }
        ;
        
@@ -4464,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;
@@ -7702,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);
index a6c575ecc9e33267efd52365b2cc275d044cb915..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
index bb6255ce48740f0641084d38c0b30a7c82497e7f..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))
@@ -2568,11 +2620,7 @@ namespace Mono.CSharp
 
                bool DoResolveCommon (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");
-                       }
+                       CheckExpressionVariable (rc);
 
                        var var_expr = VariableType as VarExpr;
                        if (var_expr != null) {
index dd02d894a8b480a97188b3d7d53a33f88d17ad2b..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);
@@ -2433,6 +2435,12 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool Created {
+                       get {
+                               return builder != null;
+                       }
+               }
+
                public bool IsDeclared {
                        get {
                                return type != null;
index 51d0b2086fda73f48a672f0c03f5224f8d26104f..eac11ac15f91607127af3ecdd47cab1e7ce9215f 100644 (file)
@@ -5,3 +5,4 @@
 # csXXXX.cs IGNORE     : adds test to ignore list
 
 gtest-230.cs
+test-pattern-02.cs
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;
index fe7d9733555ec7a953d5e7666a97be586fdccfdf..5b1f686ddd765817d716aebf3bdc031df02dba1f 100644 (file)
   <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>
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 16c22c8fd10e8923ba813eea59aece7e0507bb22..86efc2999f6562594f0503e4a60d4461edc20a28 100644 (file)
@@ -1949,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);
index 968c34ec79c99490429e0578873a53f7892411bb..29d03b8d7ac91338b11248723bbc155f3214c27d 100644 (file)
@@ -1252,7 +1252,7 @@ mono_string_new_len_wrapper (const char *text, guint length)
        return result;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 /*
  * mono_mb_emit_exception_marshal_directive:
@@ -1272,7 +1272,7 @@ mono_mb_emit_exception_marshal_directive (MonoMethodBuilder *mb, char *msg)
        }
        mono_mb_emit_exception_full (mb, "System.Runtime.InteropServices", "MarshalDirectiveException", s);
 }
-#endif /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 guint
 mono_type_to_ldind (MonoType *type)
@@ -1386,7 +1386,7 @@ handle_enum:
        return -1;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 static void
 emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
@@ -2463,7 +2463,7 @@ mono_marshal_emit_thread_force_interrupt_checkpoint (MonoMethodBuilder *mb)
        emit_thread_force_interrupt_checkpoint (mb);
 }
 
-#endif /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 /* This is a JIT icall, it sets the pending exception and returns NULL on error. */
 static MonoAsyncResult *
@@ -2532,7 +2532,7 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params)
        return result;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 int
 mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolean save_this)
@@ -2576,7 +2576,7 @@ mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolea
        return params_var;
 }
 
-#endif /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 static char*
 mono_signature_to_name (MonoMethodSignature *sig, const char *prefix)
@@ -3201,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        params_var = mono_mb_emit_save_args (mb, sig, FALSE);
 
        mono_mb_emit_ldarg (mb, 0);
@@ -3324,7 +3324,7 @@ mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params)
        return res;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 void
 mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type)
@@ -3387,7 +3387,7 @@ mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type)
        mono_mb_emit_byte (mb, CEE_RET);
 }
 
-#endif /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 /**
  * mono_marshal_get_delegate_end_invoke:
@@ -3443,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        params_var = mono_mb_emit_save_args (mb, sig, FALSE);
 
        mono_mb_emit_ldarg (mb, 0);
@@ -3645,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        void_ret = sig->ret->type == MONO_TYPE_VOID && !method->string_ctor;
 
        /* allocate local 0 (object) */
@@ -3812,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 /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, subtype);
        info->d.delegate_invoke.method = method;
@@ -4007,7 +4007,7 @@ runtime_invoke_signature_equal (MonoMethodSignature *sig1, MonoMethodSignature *
                return mono_metadata_signature_equal (sig1, sig2);
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 /*
  * emit_invoke_call:
@@ -4435,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        param_names [0] = "this";
        param_names [1] = "params";
        param_names [2] = "exc";
@@ -4446,7 +4446,7 @@ mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean virtual_)
 #endif
 
        if (need_direct_wrapper) {
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -4530,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        /* allocate local 0 (object) tmp */
        mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
        /* allocate local 1 (object) exc */
@@ -4591,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 /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC);
 
@@ -4665,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        param_names [0] = "this";
        param_names [1] = "params";
        param_names [2] = "exc";
@@ -4706,7 +4706,7 @@ mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature *sig)
        return res;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 static void
 mono_mb_emit_auto_layout_exception (MonoMethodBuilder *mb, MonoClass *klass)
 {
@@ -4747,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        if (sig->hasthis)
                mono_mb_emit_byte (mb, CEE_LDARG_0);
 
@@ -4781,7 +4781,7 @@ emit_marshal_custom (EmitMarshalContext *m, int argnum, MonoType *t,
                                         int conv_arg, MonoType **conv_arg_type, 
                                         MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#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;
@@ -5097,7 +5097,7 @@ emit_marshal_asany (EmitMarshalContext *m, int argnum, MonoType *t,
                                        int conv_arg, MonoType **conv_arg_type, 
                                        MarshalAction action)
 {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -5144,7 +5144,7 @@ emit_marshal_vtype (EmitMarshalContext *m, int argnum, MonoType *t,
                                        int conv_arg, MonoType **conv_arg_type, 
                                        MarshalAction action)
 {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
        MonoClass *klass, *date_time_class;
        int pos = 0, pos2;
@@ -5421,7 +5421,7 @@ emit_marshal_string (EmitMarshalContext *m, int argnum, MonoType *t,
                                         int conv_arg, MonoType **conv_arg_type, 
                                         MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        switch (action) {
        case MARSHAL_ACTION_CONV_IN:
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
@@ -5600,7 +5600,7 @@ emit_marshal_safehandle (EmitMarshalContext *m, int argnum, MonoType *t,
                         MonoMarshalSpec *spec, int conv_arg, 
                         MonoType **conv_arg_type, MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
 #else
@@ -5764,7 +5764,7 @@ emit_marshal_handleref (EmitMarshalContext *m, int argnum, MonoType *t,
                        MonoMarshalSpec *spec, int conv_arg, 
                        MonoType **conv_arg_type, MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
 #else
@@ -5831,7 +5831,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                     int conv_arg, MonoType **conv_arg_type, 
                     MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        if (action == MARSHAL_ACTION_CONV_IN)
                *conv_arg_type = &mono_defaults.int_class->byval_arg;
 #else
@@ -6333,7 +6333,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
        return conv_arg;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 #ifndef DISABLE_COM
 
 static int
@@ -6450,7 +6450,7 @@ emit_marshal_variant (EmitMarshalContext *m, int argnum, MonoType *t,
 }
 
 #endif /* DISABLE_COM */
-#endif /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 static gboolean
 mono_pinvoke_is_unicode (MonoMethodPInvoke *piinfo)
@@ -6477,7 +6477,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                                        int conv_arg, MonoType **conv_arg_type, 
                                        MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        switch (action) {
        case MARSHAL_ACTION_CONV_IN:
                *conv_arg_type = &mono_defaults.object_class->byval_arg;
@@ -7246,7 +7246,7 @@ emit_marshal_boolean (EmitMarshalContext *m, int argnum, MonoType *t,
                      int conv_arg, MonoType **conv_arg_type, 
                      MarshalAction action)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        switch (action) {
        case MARSHAL_ACTION_CONV_IN:
                if (t->byref)
@@ -7415,7 +7415,7 @@ emit_marshal_ptr (EmitMarshalContext *m, int argnum, MonoType *t,
                  MonoMarshalSpec *spec, int conv_arg, 
                  MonoType **conv_arg_type, MarshalAction action)
 {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -7450,7 +7450,7 @@ emit_marshal_char (EmitMarshalContext *m, int argnum, MonoType *t,
                   MonoMarshalSpec *spec, int conv_arg, 
                   MonoType **conv_arg_type, MarshalAction action)
 {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -7478,7 +7478,7 @@ emit_marshal_scalar (EmitMarshalContext *m, int argnum, MonoType *t,
                     MonoMarshalSpec *spec, int conv_arg, 
                     MonoType **conv_arg_type, MarshalAction action)
 {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        MonoMethodBuilder *mb = m->mb;
 
        switch (action) {
@@ -7522,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(HAVE_ONLINE_VES)
+#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
@@ -7622,7 +7622,7 @@ signature_param_uses_handles (MonoMethodSignature *sig, int param)
 }
 
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 /**
  * mono_marshal_emit_native_wrapper:
  * \param image the image to use for looking up custom marshallers
@@ -7906,7 +7906,7 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
 
        mono_mb_emit_byte (mb, CEE_RET);
 }
-#endif /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 /**
  * mono_marshal_get_native_wrapper:
@@ -8005,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);
 
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -8039,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) {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
                mono_mb_emit_exception (mb, exc_class, exc_arg);
 #endif
                info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
@@ -8067,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
                // FIXME:
                MonoClass *handle_stack_mark_class;
                MonoClass *error_class;
@@ -8300,7 +8300,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
        if (!aot)
                g_assert (piinfo->addr);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mspecs = g_new (MonoMarshalSpec*, sig->param_count + 1);
        mono_method_get_marshal_info (method, mspecs);
 
@@ -8315,7 +8315,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
                                                                                 info, NULL);
        mono_mb_free (mb);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        for (i = sig->param_count; i >= 0; i--)
                if (mspecs [i])
                        mono_metadata_free_marshal_spec (mspecs [i]);
@@ -8363,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, func, FALSE, TRUE, FALSE);
 #endif
 
@@ -8428,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mono_marshal_emit_native_wrapper (image, mb, sig, piinfo, mspecs, NULL, FALSE, TRUE, TRUE);
 #endif
 
@@ -8463,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)
 {
-#ifndef HAVE_ONLINE_VES
+#ifndef ENABLE_ILGEN
        MonoMethodSignature *sig, *csig;
        int i;
 
@@ -8995,7 +8995,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
                                                                                         mb, csig, sig->param_count + 16,
                                                                                         info, NULL);
        } else {
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
                mb->dynamic = TRUE;
 #endif
                res = mono_mb_create (mb, csig, sig->param_count + 16, NULL);
@@ -9058,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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
                mb->dynamic = TRUE;
 #endif
                method = mono_mb_create (mb, csig, sig->param_count + 16, NULL);
@@ -9078,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;
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        for (i = 0; i < param_count; i++)
                mono_mb_emit_ldarg (mb, i);
 
@@ -9099,7 +9099,7 @@ mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
        return compiled_ptr;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 /*
  * The code directly following this is the cache hit, value positive branch
@@ -9162,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 /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
 /**
  * mono_marshal_get_castclass_with_cache:
@@ -9193,7 +9193,7 @@ mono_marshal_get_castclass_with_cache (void)
        sig->ret = &mono_defaults.object_class->byval_arg;
        sig->pinvoke = 0;
 
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -9212,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 /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE);
        res = mono_mb_create (mb, sig, 8, info);
@@ -9280,7 +9280,7 @@ mono_marshal_get_isinst_with_cache (void)
        sig->ret = &mono_defaults.object_class->byval_arg;
        sig->pinvoke = 0;
 
-#ifdef HAVE_ONLINE_VES
+#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.
@@ -9339,7 +9339,7 @@ mono_marshal_get_struct_to_ptr (MonoClass *klass)
 
        mb = mono_mb_new (klass, stoptr->name, MONO_WRAPPER_UNKNOWN);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        if (klass->blittable) {
                mono_mb_emit_byte (mb, CEE_LDARG_1);
                mono_mb_emit_byte (mb, CEE_LDARG_0);
@@ -9421,7 +9421,7 @@ mono_marshal_get_ptr_to_struct (MonoClass *klass)
 
        mb = mono_mb_new (klass, "PtrToStructure", MONO_WRAPPER_UNKNOWN);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        if (klass->blittable) {
                mono_mb_emit_byte (mb, CEE_LDARG_1);
                mono_mb_emit_ldflda (mb, sizeof (MonoObject));
@@ -9489,7 +9489,7 @@ mono_marshal_get_synchronized_inner_wrapper (MonoMethod *method)
        }
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_UNKNOWN);
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mono_mb_emit_exception_full (mb, "System", "ExecutionEngineException", "Shouldn't be called.");
        mono_mb_emit_byte (mb, CEE_RET);
 #endif
@@ -9565,7 +9565,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE);
        info->d.synchronized.method = method;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mb->skip_visibility = 1;
        /* result */
        if (!MONO_TYPE_IS_VOID (sig->ret))
@@ -9575,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, "");
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -9593,7 +9593,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
                return res;
        }
 
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -9625,7 +9625,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
 
        mono_marshal_unlock ();
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        /* Push this or the type object */
        if (method->flags & METHOD_ATTRIBUTE_STATIC) {
                /* We have special handling for this in the JIT */
@@ -9724,7 +9724,7 @@ mono_marshal_get_unbox_wrapper (MonoMethod *method)
 
        g_assert (sig->hasthis);
        
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mono_mb_emit_ldarg (mb, 0); 
        mono_mb_emit_icon (mb, sizeof (MonoObject));
        mono_mb_emit_byte (mb, CEE_ADD);
@@ -9796,7 +9796,7 @@ get_virtual_stelemref_kind (MonoClass *element_class)
        return STELEMREF_CLASS;
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 static void
 load_array_element_address (MonoMethodBuilder *mb)
@@ -9880,7 +9880,7 @@ get_virtual_stelemref_wrapper (int kind)
                signature = sig;
        }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        param_names [0] = "index";
        param_names [1] = "value";
        mono_mb_set_param_names (mb, param_names);
@@ -10280,7 +10280,7 @@ get_virtual_stelemref_wrapper (int kind)
                mono_mb_emit_byte (mb, CEE_RET);
                g_assert (0);
        }
-#endif /* HAVE_ONLINE_VES */
+#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);
@@ -10353,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;
 
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -10493,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        /*
         * The body is generated by the JIT, we use a wrapper instead of a trampoline so EH works.
         */
@@ -10527,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        /*
         * The body is generated by the JIT, we use a wrapper instead of a trampoline so EH works.
         */
@@ -10601,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);
        
-#ifdef HAVE_ONLINE_VES
+#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);
@@ -10697,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 /* HAVE_ONLINE_VES */
+#endif /* ENABLE_ILGEN */
 
        info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_ELEMENT_ADDR);
        info->d.element_addr.rank = rank;
@@ -10774,7 +10774,7 @@ mono_marshal_get_array_accessor_wrapper (MonoMethod *method)
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_UNKNOWN);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        /* Call the method */
        if (sig->hasthis)
                mono_mb_emit_ldarg (mb, 0);
@@ -12069,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        mono_mb_emit_ldarg (mb, 0);
        for (i = 0; i < csig->param_count; i++)
                mono_mb_emit_ldarg (mb, i + 1);
@@ -12206,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;
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        /* local 0 (temp for exception object) */
        mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
 
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 81d16ce4b2d48aee49ea5ef811744e95cce8016b..a02312ab4723514308d97c0e0c40e7065a9dc733 100644 (file)
@@ -67,7 +67,7 @@ mono_mb_new_base (MonoClass *klass, MonoWrapperType type)
        m->inline_info = 1;
        m->wrapper_type = type;
 
-#ifdef HAVE_ONLINE_VES
+#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)
 {
-#ifdef HAVE_ONLINE_VES
+#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)
 {
-#ifdef HAVE_ONLINE_VES
+#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;
 
-#ifdef HAVE_ONLINE_VES
+#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);
 
-#ifdef HAVE_ONLINE_VES
+#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
        }
 
-#ifdef HAVE_ONLINE_VES
+#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;
 
-#ifdef HAVE_ONLINE_VES
+#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;
        }
 
-#ifdef HAVE_ONLINE_VES
+#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);
 }
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 
 /**
  * mono_mb_add_local:
index b13416ffa2c7ad7d953b50ec0dac2b1018382f8b..26a53e1c34d46baad794158329fdc9a1b897083f 100644 (file)
@@ -25,7 +25,7 @@ typedef struct _MonoMethodBuilder {
        MonoMethod *method;
        char *name;
        gboolean no_dup_name;
-#ifdef HAVE_ONLINE_VES
+#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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 void
 mono_mb_patch_addr (MonoMethodBuilder *mb, int pos, int value);
 
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 b1897453b467043ae166a9085071157320bd438c..0314150604f207eb9bd6c48a6232521398abd376 100644 (file)
@@ -245,7 +245,7 @@ mono_gc_is_critical_method (MonoMethod *method)
        return sgen_is_critical_method (method);
 }
 
-#ifdef HAVE_ONLINE_VES
+#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);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
 #ifdef MANAGED_WBARRIER
        emit_nursery_check (mb, nursery_check_labels, is_concurrent);
        /*
@@ -1126,7 +1126,7 @@ create_allocator (int atype, ManagedAllocatorVariant variant)
 
        mb = mono_mb_new (mono_defaults.object_class, name, MONO_WRAPPER_ALLOC);
 
-#ifdef HAVE_ONLINE_VES
+#ifdef ENABLE_ILGEN
        if (slowpath) {
                switch (atype) {
                case ATYPE_NORMAL:
@@ -1461,7 +1461,7 @@ create_allocator (int atype, ManagedAllocatorVariant variant)
        info->d.alloc.gc_name = "sgen";
        info->d.alloc.alloc_type = atype;
 
-#ifdef HAVE_ONLINE_VES
+#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 fb372baa5e1b39852f89994e24211c5ea36fb2dd..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"
@@ -6825,13 +6825,13 @@ emit_trampolines (MonoAotCompile *acfg)
                emit_trampoline (acfg, acfg->got_offset, info);
 #endif
 
-#endif /* #ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES */
-
                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 */
 
                /*
index bfdddb37547e5dac5d9f4f094b1084d87b359826..88b1b18b68b8e0492dc328d8b4347d14843a43b8 100644 (file)
@@ -7096,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];
+                       }
                }
        }
 
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 7878372c10cd57257517b52809e147cb42c654bf..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);
@@ -1566,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);
+                       }
                }
        }
 
@@ -2614,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:
@@ -2630,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) {
@@ -2647,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 ()) {
@@ -3287,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;
                }
index d3dd15c3b2922cd7ebe7aeb3f229a26358962e59..f96c8a3fcccfba10337d1c2c3597139df56c46c5 100644 (file)
@@ -65,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)
@@ -114,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 3b5d170a694ac1385491fcb43d427c7ae48a33b9..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>
@@ -1238,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 a1fa3fe0325f20a69a57849c8092c1991b1b107c..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
 
@@ -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 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
index a2cd4ec5860561bdcca9be7514b1f8655ab48531..a28b37c0a07b0cb1c751d8609805712c93f7e6df 100644 (file)
@@ -21,6 +21,6 @@ class NuGetBinary (Package):
         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))
+                'exec {0}/bin/mono $MONO_OPTIONS {1} "$@"\n'.format(self.staged_prefix, target))
         os.chmod(launcher, 0o755)
 NuGetBinary()
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..b6f0659
--- /dev/null
@@ -0,0 +1,129 @@
+#!/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/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/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 xsp2 xsp4 fsharpc fsharpi fsharpiAnyCpu nuget msbuild
+               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 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 7ae3de5d0b6f7f69c317e29970ab1976d2501a9b..9e41e894d5511b7bb505f473981ffd9813a8eaf6 100755 (executable)
@@ -73,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 d279e1d3edad4d42ef488f543d23076e3bdf1bc7..bc9c003c0adf4d369086ca9dd28406f5df1c199f 100644 (file)
 /* Using the simple generational GC. */
 /* #undef HAVE_SGEN_GC */
 
-/* Some VES is available at runtime */
-#define HAVE_ONLINE_VES 1
-
  /* Have signal */
 #define HAVE_SIGNAL 1