Merge pull request #2429 from alexanderkyte/nunit_lite_integration
authorZoltan Varga <vargaz@gmail.com>
Mon, 25 Jan 2016 18:45:37 +0000 (13:45 -0500)
committerZoltan Varga <vargaz@gmail.com>
Mon, 25 Jan 2016 18:45:37 +0000 (13:45 -0500)
[nunit-lite] Add nunit-lite runner to build system

210 files changed:
configure.ac
external/referencesource
libgc/depcomp [deleted file]
libgc/missing [deleted file]
man/mono.1
mcs/class/Makefile
mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
mcs/class/Mono.Debugger.Soft/Test/dtest.cs
mcs/class/Mono.Posix/Makefile
mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.cs
mcs/class/Mono.Posix/Mono.Unix.Native/NativeConvert.generated.cs
mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs
mcs/class/Mono.Posix/Test/Mono.Unix.Native/SocketTest.cs
mcs/class/Mono.Posix/Test/Mono.Unix/UnixSignalTest.cs
mcs/class/Mono.Security.Providers.DotNet/Mono.Security.Providers.DotNet/DotNetTlsProvider.cs
mcs/class/Mono.Security.Providers.NewSystemSource/Mono.Security.Providers.NewSystemSource.dll.sources
mcs/class/Mono.Security.Providers.NewSystemSource/Properties/AssemblyInfo.cs
mcs/class/Mono.Security.Providers.NewTls/Makefile [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls.dll.sources [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsConfiguration.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsContext.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStream.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/NewTlsProvider.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsContextWrapper.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsProviderFactory.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/Properties/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/mobile_Mono.Security.Providers.NewTls.dll.sources [new file with mode: 0644]
mcs/class/Mono.Security.Providers.NewTls/mobile_static_Mono.Security.Providers.NewTls.dll.sources [new file with mode: 0644]
mcs/class/Mono.Security.Providers.OldTls/Mono.Security.Providers.OldTls/OldTlsProvider.cs
mcs/class/Mono.Security/Assembly/AssemblyInfo.cs
mcs/class/Mono.Security/Mono.Security.Interface/BufferOffsetSize.cs [new file with mode: 0644]
mcs/class/Mono.Security/Mono.Security.Interface/IMonoTlsContext.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProvider.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsSettings.cs
mcs/class/Mono.Security/Mono.Security.Interface/SecretParameters.cs [new file with mode: 0644]
mcs/class/Mono.Security/Mono.Security.Interface/SecureBuffer.cs [new file with mode: 0644]
mcs/class/Mono.Security/Mono.Security.Interface/TlsBuffer.cs [new file with mode: 0644]
mcs/class/Mono.Security/Mono.Security.Interface/TlsMultiBuffer.cs [new file with mode: 0644]
mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs
mcs/class/Mono.Security/Mono.Security.dll.sources
mcs/class/Mono.Security/mobile_Mono.Security.dll.sources
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Negate.cs
mcs/class/System.Drawing/System.Drawing.dll.sources
mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs [new file with mode: 0644]
mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs [new file with mode: 0644]
mcs/class/System.Web.Services/System.Web.Services_test.dll.sources
mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SoapHttpClientProtocolTest.cs
mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SocketResponder.cs [deleted file]
mcs/class/System/Assembly/AssemblyInfo.cs
mcs/class/System/Mono.Http/NtlmClient.cs
mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs
mcs/class/System/Mono.Net.Security/MonoTlsProviderImpl.cs
mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs
mcs/class/System/System.Diagnostics/Process.cs
mcs/class/System/System.Net.Sockets/UdpClient.cs
mcs/class/System/System.Net/MacProxy.cs
mcs/class/System/System.Net/WebConnection.cs
mcs/class/System/System.Net/WebRequest.cs
mcs/class/System/System.dll.sources
mcs/class/System/System_test.dll.sources
mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
mcs/class/System/Test/System.Net.Sockets/TcpClientTest.cs
mcs/class/System/Test/System.Net.Sockets/UdpClientTest.cs
mcs/class/System/Test/System.Net/SocketResponder.cs [deleted file]
mcs/class/System/mobile_System.dll.sources
mcs/class/corlib/Assembly/AssemblyInfo.cs
mcs/class/corlib/Linux/ChangeLog [deleted file]
mcs/class/corlib/Linux/Linux.cs [deleted file]
mcs/class/corlib/ReferenceSources/CLRConfig.cs
mcs/class/corlib/System.Globalization/CultureInfo.cs
mcs/class/corlib/System.PAL/.gitattributes [deleted file]
mcs/class/corlib/System.PAL/IOperatingSystem.cs [deleted file]
mcs/class/corlib/System.PAL/Platform.cs [deleted file]
mcs/class/corlib/System/Console.cs
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/Test/System.Globalization/CultureInfoTest.cs
mcs/class/corlib/Test/System.Threading/CancellationTokenSourceTest.cs
mcs/class/test-helpers/SocketResponder.cs [new file with mode: 0644]
mcs/mcs/complete.cs
mcs/mcs/expression.cs
mcs/mcs/settings.cs
mcs/tests/dtest-063.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_x.xml
mcs/tools/csharp/csharp.csproj
mcs/tools/csharp/getline.cs
mcs/tools/linker/Mono.Linker.Steps/MarkStep.cs
mcs/tools/tuner/Mono.Tuner/RemoveAttributesBase.cs
mono/io-layer/Makefile.am
mono/io-layer/events.c
mono/io-layer/handles.c
mono/io-layer/io-trace.h [new file with mode: 0644]
mono/io-layer/io.c
mono/io-layer/locking.c
mono/io-layer/mutexes.c
mono/io-layer/posix.c
mono/io-layer/processes.c
mono/io-layer/semaphores.c
mono/io-layer/sockets.c
mono/io-layer/versioninfo.c
mono/io-layer/wait.c
mono/io-layer/wthreads.c
mono/metadata/Makefile.am
mono/metadata/appdomain.c
mono/metadata/assembly.c
mono/metadata/boehm-gc.c
mono/metadata/class-internals.h
mono/metadata/cominterop.c
mono/metadata/console-unix.c
mono/metadata/culture-info-tables.h
mono/metadata/debug-helpers.c
mono/metadata/domain-internals.h
mono/metadata/gc-internals.h
mono/metadata/gc.c
mono/metadata/handle-private.h [deleted file]
mono/metadata/handle.c
mono/metadata/handle.h
mono/metadata/icall-def.h
mono/metadata/icall.c
mono/metadata/jit-info.c
mono/metadata/marshal.c
mono/metadata/marshal.h
mono/metadata/mono-mlist.c
mono/metadata/null-gc.c
mono/metadata/object-internals.h
mono/metadata/object.c
mono/metadata/reflection.c
mono/metadata/sgen-client-mono.h
mono/metadata/sgen-mono.c
mono/metadata/sgen-os-posix.c
mono/metadata/sgen-os-win32.c
mono/metadata/sgen-stw.c
mono/metadata/threads.c
mono/mini/Makefile.am.in
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/aot-tests.cs
mono/mini/debugger-agent.c
mono/mini/decompose.c
mono/mini/driver.c
mono/mini/exceptions.cs
mono/mini/generics.cs
mono/mini/gshared.cs
mono/mini/ir-emit.h
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/liveness.c
mono/mini/method-to-ir.c
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini-arm-tls.S
mono/mini/mini-arm-tls.h
mono/mini/mini-arm.c
mono/mini/mini-arm.h
mono/mini/mini-exceptions.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-ia64.c
mono/mini/mini-llvm.c
mono/mini/mini-llvm.h
mono/mini/mini-mips.c
mono/mini/mini-posix.c
mono/mini/mini-ppc.c
mono/mini/mini-runtime.c
mono/mini/mini-sparc.c
mono/mini/mini-trampolines.c
mono/mini/mini-x86.c
mono/mini/mini.c
mono/mini/mini.h
mono/mini/patch-info.h
mono/mini/seq-points.c
mono/mini/test_op_il_seq_point.sh
mono/mini/test_op_il_seq_point_headerfooter.sh
mono/mini/tramp-amd64.c
mono/mini/tramp-arm.c
mono/sgen/sgen-alloc.c
mono/sgen/sgen-cardtable.c
mono/sgen/sgen-client.h
mono/sgen/sgen-descriptor.c
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-los.c
mono/sgen/sgen-marksweep-drain-gray-stack.h
mono/sgen/sgen-marksweep.c
mono/tests/Makefile.am
mono/tests/console-output.cs [new file with mode: 0644]
mono/tests/console-output.exe.stderr.expected [new file with mode: 0644]
mono/tests/console-output.exe.stdout.expected [new file with mode: 0644]
mono/tests/libtest.c
mono/tests/pinvoke3.cs
mono/unit-tests/test-mono-handle.c
mono/utils/checked-build.c
mono/utils/checked-build.h
mono/utils/hazard-pointer.c
mono/utils/mono-context.c
mono/utils/mono-context.h
mono/utils/mono-error-internals.h
mono/utils/mono-error.c
mono/utils/mono-error.h
mono/utils/mono-logger-internals.h
mono/utils/mono-logger.c
mono/utils/mono-rand.c
mono/utils/mono-threads.h
msvc/libmonoruntime.vcxproj
support/Makefile.am
support/map.c
support/map.h
support/sys-socket.c
tools/locale-builder/Driver.cs

index 5da2a242f3a7c68dc908294676b129a701670c0f..9e6e66c189c4cdaaa37a47fcaecc0e4396d474a3 100644 (file)
@@ -2078,6 +2078,7 @@ if test x$host_win32 = xno; then
        AC_CHECK_FUNCS(setpgid)
        AC_CHECK_FUNCS(system)
        AC_CHECK_FUNCS(fork execv execve)
+       AC_CHECK_FUNCS(accept4)
        AC_CHECK_SIZEOF(size_t)
        AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , 
                [#include <sys/types.h>
@@ -2098,6 +2099,16 @@ if test x$host_win32 = xno; then
                [#include <sys/socket.h>])
        AC_CHECK_TYPES([struct pollfd], [AC_DEFINE(HAVE_STRUCT_POLLFD)], ,
                [#include <sys/poll.h>])
+       AC_CHECK_TYPES([struct sockaddr], [AC_DEFINE(HAVE_STRUCT_SOCKADDR)], ,
+               [#include <sys/socket.h>])
+       AC_CHECK_TYPES([struct sockaddr_storage], [AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)], ,
+               [#include <sys/socket.h>])
+       AC_CHECK_TYPES([struct sockaddr_in], [AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN)], ,
+               [#include <netinet/in.h>])
+       AC_CHECK_TYPES([struct sockaddr_in6], [AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)], ,
+               [#include <netinet/in.h>])
+       AC_CHECK_TYPES([struct sockaddr_un], [AC_DEFINE(HAVE_STRUCT_SOCKADDR_UN)], ,
+               [#include <sys/un.h>])
        AC_CHECK_TYPES([struct stat], [AC_DEFINE(HAVE_STRUCT_STAT)], ,
                [#include <sys/types.h>
                 #include <sys/stat.h>
@@ -3519,6 +3530,29 @@ AC_ARG_WITH(checked_build, [  --with-checked-build=yes|no      Enable checked bu
        fi
 ], [with_checked_build=no])
 
+if test x$with_checked_build != xno ; then
+       DISABLED_CHECKED_BUILD_TEST=none
+
+       AC_ARG_ENABLE(checked_build_test, [  --enable-checked-build-test=LIST      drop support for LIST checked build tests. LIST is a comma-separated list from: gc, metadata, thread.],
+       [
+               for feature in `echo "$enable_checked_build_test" | sed -e "s/,/ /g"`; do
+                       eval "mono_checked_build_test_disable_$feature='yes'"
+               done
+               DISABLED_CHECKED_BUILD_TEST=$enable_checked_build_test
+       ],[])
+
+       if test "x$mono_checked_build_test_disable_gc" = "xyes"; then
+               AC_DEFINE(DISABLE_CHECKED_BUILD_GC, 1, [Disable GC checked build])
+       fi
+
+       if test "x$mono_checked_build_test_disable_metadata" = "xyes"; then
+               AC_DEFINE(DISABLE_CHECKED_BUILD_METADATA, 1, [Disable metadata checked build])
+       fi
+
+       if test "x$mono_checked_build_test_disable_thread" = "xyes"; then
+               AC_DEFINE(DISABLE_CHECKED_BUILD_THREAD, 1, [Disable thread checked build])
+       fi
+fi
 
 AC_CHECK_HEADER([malloc.h], 
                [AC_DEFINE([HAVE_USR_INCLUDE_MALLOC_H], [1], 
index af10c8da53c277eebb42c597117560510dfce50c..b945d0b0a8a582e4d1ab581869b0c9215c7c3ca0 160000 (submodule)
@@ -1 +1 @@
-Subproject commit af10c8da53c277eebb42c597117560510dfce50c
+Subproject commit b945d0b0a8a582e4d1ab581869b0c9215c7c3ca0
diff --git a/libgc/depcomp b/libgc/depcomp
deleted file mode 100755 (executable)
index 3480ce4..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-#! /bin/sh
-
-# depcomp - compile a program generating dependencies as side-effects
-# Copyright 1999, 2000 Free Software Foundation, Inc.
-
-# 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, 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.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
-  echo "depcomp: Variables source, object and depmode must be set" 1>&2
-  exit 1
-fi
-# `libtool' can also be set to `yes' or `no'.
-
-if test -z "$depfile"; then
-   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
-   dir=`echo "$object" | sed 's,/.*$,/,'`
-   if test "$dir" = "$object"; then
-      dir=
-   fi
-   # FIXME: should be _deps on DOS.
-   depfile="$dir.deps/$base"
-fi
-
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags.  We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write.  Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
-  # HP compiler uses -M and no extra arg.
-  gccflag=-M
-  depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
-   # This is just like dashmstdout with a different argument.
-   dashmflag=-xM
-   depmode=dashmstdout
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff.  Hmm.
-  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  mv "$tmpdepfile" "$depfile"
-  ;;
-
-gcc)
-## There are various ways to get dependency output from gcc.  Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-##   up in a subdir.  Having to rename by hand is ugly.
-##   (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-##   -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-##   than renaming).
-  if test -z "$gccflag"; then
-    gccflag=-MD,
-  fi
-  "$@" -Wp,"$gccflag$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  rm -f "$depfile"
-  echo "$object : \\" > "$depfile"
-  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
-  sed -e 's/^[^:]*: / /' \
-      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header).  We avoid this by adding
-## dummy dependencies for each header file.  Too bad gcc doesn't do
-## this for us directly.
-  tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'.  On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-hp)
-  # This case exists only to let depend.m4 do its work.  It works by
-  # looking at the text of this script.  This case will never be run,
-  # since it is checked for above.
-  exit 1
-  ;;
-
-sgi)
-  if test "$libtool" = yes; then
-    "$@" "-Wp,-MDupdate,$tmpdepfile"
-  else
-    "$@" -MDupdate "$tmpdepfile"
-  fi
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  rm -f "$depfile"
-
-  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
-    echo "$object : \\" > "$depfile"
-
-    # Clip off the initial element (the dependent).  Don't try to be
-    # clever and replace this with sed code, as IRIX sed won't handle
-    # lines with more than a fixed number of characters (4096 in
-    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
-    # the IRIX cc adds comments like `#:fec' to the end of the
-    # dependency line.
-    tr ' ' '
-' < "$tmpdepfile" \
-    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
-    tr '
-' ' ' >> $depfile
-    echo >> $depfile
-
-    # The second pass generates a dummy entry for each header file.
-    tr ' ' '
-' < "$tmpdepfile" \
-   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
-   >> $depfile
-  else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
-  fi
-  rm -f "$tmpdepfile"
-  ;;
-
-aix)
-  # The C for AIX Compiler uses -M and outputs the dependencies
-  # in a .u file.  This file always lives in the current directory.
-  # Also, the AIX compiler puts `$object:' at the start of each line;
-  # $object doesn't have directory information.
-  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
-  tmpdepfile="$stripped.u"
-  outname="$stripped.o"
-  if test "$libtool" = yes; then
-    "$@" -Wc,-M
-  else
-    "$@" -M
-  fi
-
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-
-  if test -f "$tmpdepfile"; then
-    # Each line is of the form `foo.o: dependent.h'.
-    # Do two passes, one to just change these to
-    # `$object: dependent.h' and one to simply `dependent.h:'.
-    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
-    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
-  else
-    # The sourcefile does not contain any dependencies, so just
-    # store a dummy comment line, to avoid errors with the Makefile
-    # "include basename.Plo" scheme.
-    echo "#dummy" > "$depfile"
-  fi
-  rm -f "$tmpdepfile"
-  ;;
-
-tru64)
-   # The Tru64 compiler uses -MD to generate dependencies as a side
-   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
-   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 
-   # dependencies in `foo.d' instead, so we check for that too.
-   # Subdirectories are respected.
-
-   base=`echo "$object" | sed -e 's/\.o$//' -e 's/\.lo$//'`
-   tmpdepfile1="$base.o.d"
-   tmpdepfile2="$base.d"
-   if test "$libtool" = yes; then
-      "$@" -Wc,-MD
-   else
-      "$@" -MD
-   fi
-
-   stat=$?
-   if test $stat -eq 0; then :
-   else
-      rm -f "$tmpdepfile1" "$tmpdepfile2"
-      exit $stat
-   fi
-
-   if test -f "$tmpdepfile1"; then
-      tmpdepfile="$tmpdepfile1"
-   else
-      tmpdepfile="$tmpdepfile2"
-   fi
-   if test -f "$tmpdepfile"; then
-      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a space and a tab in the [].
-      sed -e 's,^.*\.[a-z]*:[  ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
-   else
-      echo "#dummy" > "$depfile"
-   fi
-   rm -f "$tmpdepfile"
-   ;;
-
-#nosideeffect)
-  # This comment above is used by automake to tell side-effect
-  # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
-  # Important note: in order to support this mode, a compiler *must*
-  # always write the proprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
-  test -z "$dashmflag" && dashmflag=-M
-  ( IFS=" "
-    case " $* " in
-    *" --mode=compile "*) # this is libtool, let us make it quiet
-      for arg
-      do # cycle over the arguments
-        case "$arg" in
-       "--mode=compile")
-         # insert --quiet before "--mode=compile"
-         set fnord "$@" --quiet
-         shift # fnord
-         ;;
-       esac
-       set fnord "$@" "$arg"
-       shift # fnord
-       shift # "$arg"
-      done
-      ;;
-    esac
-    "$@" $dashmflag | sed 's:^[^:]*\:[         ]*:'"$object"'\: :' > "$tmpdepfile"
-  ) &
-  proc=$!
-  "$@"
-  stat=$?
-  wait "$proc"
-  if test "$stat" != 0; then exit $stat; fi
-  rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-dashXmstdout)
-  # This case only exists to satisfy depend.m4.  It is never actually
-  # run, as this mode is specially recognized in the preamble.
-  exit 1
-  ;;
-
-makedepend)
-  # X makedepend
-  (
-    shift
-    cleared=no
-    for arg in "$@"; do
-      case $cleared in no)
-        set ""; shift
-       cleared=yes
-      esac
-      case "$arg" in
-        -D*|-I*)
-         set fnord "$@" "$arg"; shift;;
-       -*)
-         ;;
-       *)
-         set fnord "$@" "$arg"; shift;;
-      esac
-    done
-    obj_suffix="`echo $object | sed 's/^.*\././'`"
-    touch "$tmpdepfile"
-    ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
-  ) &
-  proc=$!
-  "$@"
-  stat=$?
-  wait "$proc"
-  if test "$stat" != 0; then exit $stat; fi
-  rm -f "$depfile"
-  cat < "$tmpdepfile" > "$depfile"
-  sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly.  Breaking it into two sed invocations is a workaround.
-    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile" "$tmpdepfile".bak
-  ;;
-
-cpp)
-  # Important note: in order to support this mode, a compiler *must*
-  # always write the proprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
-  ( IFS=" "
-    case " $* " in
-    *" --mode=compile "*)
-      for arg
-      do # cycle over the arguments
-        case $arg in
-       "--mode=compile")
-         # insert --quiet before "--mode=compile"
-         set fnord "$@" --quiet
-         shift # fnord
-         ;;
-       esac
-       set fnord "$@" "$arg"
-       shift # fnord
-       shift # "$arg"
-      done
-      ;;
-    esac
-    "$@" -E |
-    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
-    sed '$ s: \\$::' > "$tmpdepfile"
-  ) &
-  proc=$!
-  "$@"
-  stat=$?
-  wait "$proc"
-  if test "$stat" != 0; then exit $stat; fi
-  rm -f "$depfile"
-  echo "$object : \\" > "$depfile"
-  cat < "$tmpdepfile" >> "$depfile"
-  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-msvisualcpp)
-  # Important note: in order to support this mode, a compiler *must*
-  # always write the proprocessed file to stdout, regardless of -o,
-  # because we must use -o when running libtool.
-  ( IFS=" "
-    case " $* " in
-    *" --mode=compile "*)
-      for arg
-      do # cycle over the arguments
-        case $arg in
-       "--mode=compile")
-         # insert --quiet before "--mode=compile"
-         set fnord "$@" --quiet
-         shift # fnord
-         ;;
-       esac
-       set fnord "$@" "$arg"
-       shift # fnord
-       shift # "$arg"
-      done
-      ;;
-    esac
-    for arg
-    do
-      case "$arg" in
-      "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
-       set fnord "$@"
-       shift
-       shift
-       ;;
-      *)
-       set fnord "$@" "$arg"
-       shift
-       shift
-       ;;
-      esac
-    done
-    "$@" -E |
-    sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
-  ) &
-  proc=$!
-  "$@"
-  stat=$?
-  wait "$proc"
-  if test "$stat" != 0; then exit $stat; fi
-  rm -f "$depfile"
-  echo "$object : \\" > "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> "$depfile"
-  echo "       " >> "$depfile"
-  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
-none)
-  exec "$@"
-  ;;
-
-*)
-  echo "Unknown depmode $depmode" 1>&2
-  exit 1
-  ;;
-esac
-
-exit 0
diff --git a/libgc/missing b/libgc/missing
deleted file mode 100755 (executable)
index dd58370..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# 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, 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.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
-  echo 1>&2 "Try \`$0 --help' for more information"
-  exit 1
-fi
-
-run=:
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
-  configure_ac=configure.ac
-else
-  configure_ac=configure.in
-fi
-
-case "$1" in
---run)
-  # Try to run requested program, and just exit if it succeeds.
-  run=
-  shift
-  "$@" && exit 0
-  ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
-
-  -h|--h|--he|--hel|--help)
-    echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
-  -h, --help      display this help and exit
-  -v, --version   output version information and exit
-  --run           try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
-  aclocal      touch file \`aclocal.m4'
-  autoconf     touch file \`configure'
-  autoheader   touch file \`config.h.in'
-  automake     touch all \`Makefile.in' files
-  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
-  flex         create \`lex.yy.c', if possible, from existing .c
-  help2man     touch the output file
-  lex          create \`lex.yy.c', if possible, from existing .c
-  makeinfo     touch the output file
-  tar          try tar, gnutar, gtar, then tar without non-portable flags
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
-    ;;
-
-  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-    echo "missing 0.4 - GNU automake"
-    ;;
-
-  -*)
-    echo 1>&2 "$0: Unknown \`$1' option"
-    echo 1>&2 "Try \`$0 --help' for more information"
-    exit 1
-    ;;
-
-  aclocal*)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
-         to install the \`Automake' and \`Perl' packages.  Grab them from
-         any GNU archive site."
-    touch aclocal.m4
-    ;;
-
-  autoconf)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`${configure_ac}'.  You might want to install the
-         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
-         archive site."
-    touch configure
-    ;;
-
-  autoheader)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
-         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
-         from any GNU archive site."
-    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
-    test -z "$files" && files="config.h"
-    touch_files=
-    for f in $files; do
-      case "$f" in
-      *:*) touch_files="$touch_files "`echo "$f" |
-                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
-      *) touch_files="$touch_files $f.in";;
-      esac
-    done
-    touch $touch_files
-    ;;
-
-  automake*)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
-         You might want to install the \`Automake' and \`Perl' packages.
-         Grab them from any GNU archive site."
-    find . -type f -name Makefile.am -print |
-          sed 's/\.am$/.in/' |
-          while read f; do touch "$f"; done
-    ;;
-
-  autom4te)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
-         system.  You might have modified some files without having the
-         proper tools for further handling them.
-         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
-         archive site."
-
-    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
-    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
-    if test -f "$file"; then
-       touch $file
-    else
-       test -z "$file" || exec >$file
-       echo "#! /bin/sh"
-       echo "# Created by GNU Automake missing as a replacement of"
-       echo "#  $ $@"
-       echo "exit 0"
-       chmod +x $file
-       exit 1
-    fi
-    ;;
-
-  bison|yacc)
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified a \`.y' file.  You may need the \`Bison' package
-         in order for those modifications to take effect.  You can get
-         \`Bison' from any GNU archive site."
-    rm -f y.tab.c y.tab.h
-    if [ $# -ne 1 ]; then
-        eval LASTARG="\${$#}"
-       case "$LASTARG" in
-       *.y)
-           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
-           if [ -f "$SRCFILE" ]; then
-                cp "$SRCFILE" y.tab.c
-           fi
-           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
-           if [ -f "$SRCFILE" ]; then
-                cp "$SRCFILE" y.tab.h
-           fi
-         ;;
-       esac
-    fi
-    if [ ! -f y.tab.h ]; then
-       echo >y.tab.h
-    fi
-    if [ ! -f y.tab.c ]; then
-       echo 'main() { return 0; }' >y.tab.c
-    fi
-    ;;
-
-  lex|flex)
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified a \`.l' file.  You may need the \`Flex' package
-         in order for those modifications to take effect.  You can get
-         \`Flex' from any GNU archive site."
-    rm -f lex.yy.c
-    if [ $# -ne 1 ]; then
-        eval LASTARG="\${$#}"
-       case "$LASTARG" in
-       *.l)
-           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
-           if [ -f "$SRCFILE" ]; then
-                cp "$SRCFILE" lex.yy.c
-           fi
-         ;;
-       esac
-    fi
-    if [ ! -f lex.yy.c ]; then
-       echo 'main() { return 0; }' >lex.yy.c
-    fi
-    ;;
-
-  help2man)
-    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
-       # We have it, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-        you modified a dependency of a manual page.  You may need the
-        \`Help2man' package in order for those modifications to take
-        effect.  You can get \`Help2man' from any GNU archive site."
-
-    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
-    if test -z "$file"; then
-       file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
-    fi
-    if [ -f "$file" ]; then
-       touch $file
-    else
-       test -z "$file" || exec >$file
-       echo ".ab help2man is required to generate this page"
-       exit 1
-    fi
-    ;;
-
-  makeinfo)
-    if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
-       # We have makeinfo, but it failed.
-       exit 1
-    fi
-
-    echo 1>&2 "\
-WARNING: \`$1' is missing on your system.  You should only need it if
-         you modified a \`.texi' or \`.texinfo' file, or any other file
-         indirectly affecting the aspect of the manual.  The spurious
-         call might also be the consequence of using a buggy \`make' (AIX,
-         DU, IRIX).  You might want to install the \`Texinfo' package or
-         the \`GNU make' package.  Grab either from any GNU archive site."
-    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
-    if test -z "$file"; then
-      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
-      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
-    fi
-    touch $file
-    ;;
-
-  tar)
-    shift
-    if test -n "$run"; then
-      echo 1>&2 "ERROR: \`tar' requires --run"
-      exit 1
-    fi
-
-    # We have already tried tar in the generic part.
-    # Look for gnutar/gtar before invocation to avoid ugly error
-    # messages.
-    if (gnutar --version > /dev/null 2>&1); then
-       gnutar ${1+"$@"} && exit 0
-    fi
-    if (gtar --version > /dev/null 2>&1); then
-       gtar ${1+"$@"} && exit 0
-    fi
-    firstarg="$1"
-    if shift; then
-       case "$firstarg" in
-       *o*)
-           firstarg=`echo "$firstarg" | sed s/o//`
-           tar "$firstarg" ${1+"$@"} && exit 0
-           ;;
-       esac
-       case "$firstarg" in
-       *h*)
-           firstarg=`echo "$firstarg" | sed s/h//`
-           tar "$firstarg" ${1+"$@"} && exit 0
-           ;;
-       esac
-    fi
-
-    echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
-         You may want to install GNU tar or Free paxutils, or check the
-         command line arguments."
-    exit 1
-    ;;
-
-  *)
-    echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
-         system.  You might have modified some files without having the
-         proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequirements for installing
-         this package.  You may also peek at any GNU archive site, in case
-         some other package would contain this missing \`$1' program."
-    exit 1
-    ;;
-esac
-
-exit 0
index 5783b6860872225fb2571b8abcb51abb7867c3f6..51618f260cc8e9e1b5e23a82f796ab2830dff2d8 100644 (file)
@@ -149,8 +149,7 @@ only supported by the ARM backend. In LLVM mode, this triple is passed on to the
 llc compiler.
 .TP
 .I nimt-trampolines=[number]
-When compiling in full aot mthis data at startup
-usingode, the IMT trampolines must be precreated
+When compiling in full aot mode, the IMT trampolines must be precreated
 in the AOT image.  You can add additional method trampolines with this argument.
 Defaults to 128.
 .TP
@@ -889,7 +888,9 @@ environment variable to limit the extent of the messages you get:
 If set, the log mask is changed to the set value. Possible values are
 "asm" (assembly loader), "type", "dll" (native library loader), "gc"
 (garbage collector), "cfg" (config file loader), "aot" (precompiler),
-"security" (e.g. Moonlight CoreCLR support) and "all". 
+"security" (e.g. Moonlight CoreCLR support), "threadpool" (thread pool generic), 
+"io-threadpool" (thread pool I/O), "io-layer" (I/O layer - sockets, handles, shared memory etc) 
+and "all". 
 The default value is "all". Changing the mask value allows you to display only 
 messages for a certain component. You can use multiple masks by comma 
 separating them. For example to see config file messages and assembly loader
index 64790f2005f35d3b1e2fcc2b9500325668655ba9..a0dd126efacb776fefa47b3c8ff98cb1d107d0fc 100644 (file)
@@ -54,7 +54,8 @@ mobile_common_dirs := \
        Microsoft.CSharp \
        Mono.Security.Providers.DotNet  \
        Mono.Security.Providers.OldTls \
-       Mono.Security.Providers.NewSystemSource
+       Mono.Security.Providers.NewSystemSource \
+       Mono.Security.Providers.NewTls
 
 mobile_static_dirs := \
        $(mobile_common_dirs)   \
@@ -133,6 +134,7 @@ xammac_4_5_dirs := \
        Mono.Security.Providers.DotNet \
        Mono.Security.Providers.OldTls \
        Mono.Security.Providers.NewSystemSource \
+       Mono.Security.Providers.NewTls \
        $(pcl_facade_dirs)
 
 net_4_x_dirs := \
@@ -217,7 +219,9 @@ net_4_x_dirs := \
        System.Net.Http.Formatting \
        System.Web.Http \
        System.Web.Http.SelfHost \
-       System.Web.Http.WebHost
+       System.Web.Http.WebHost \
+       Mono.Security.Providers.NewSystemSource \
+       Mono.Security.Providers.NewTls
 
 # These are the subdirs which depends on libs in net_4_x_dirs
 # or have proper dependencies between each other
@@ -262,7 +266,6 @@ net_4_x_parallel_dirs := \
        System.Xml.Serialization \
        Mono.Security.Providers.DotNet \
        Mono.Security.Providers.OldTls \
-       Mono.Security.Providers.NewSystemSource \
        System.DirectoryServices.Protocols      \
        RabbitMQ.Client                 \
        Microsoft.VisualC               \
@@ -324,6 +327,7 @@ DISTFILES = \
        notes/BitVecto32.txt    \
        MicrosoftAjaxLibrary/License.htm        \
        test-helpers/NetworkHelpers.cs  \
+       test-helpers/SocketResponder.cs \
        $(monolite_files)
 
 .PHONY: all-local $(STD_TARGETS:=-local)
index 7b99f7b7e32ed594e92f9cb7da7abbaff676dc13..150738e6633c1a6e9473953105245bb0872e069f 100644 (file)
@@ -1200,6 +1200,8 @@ public class Tests : TestsBase, ITest2
                CrossDomain o = (CrossDomain)domain.CreateInstanceAndUnwrap (
                                   typeof (CrossDomain).Assembly.FullName, "CrossDomain");
 
+               domains_print_across (o);
+
                domains_2 (o, new CrossDomain ());
 
                o.invoke_2 ();
@@ -1223,6 +1225,10 @@ public class Tests : TestsBase, ITest2
        public static void domains_2 (object o, object o2) {
        }
 
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       public static void domains_print_across (object o) {
+       }
+
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        public static void domains_3 () {
        }
@@ -1454,8 +1460,13 @@ class TypeLoadClass {
 class TypeLoadClass2 {
 }
 
+public class SentinelClass : MarshalByRefObject {
+}
+
 public class CrossDomain : MarshalByRefObject
 {
+       SentinelClass printMe = new SentinelClass ();
+
        public void invoke () {
                Tests.invoke_in_domain ();
        }
index ff7b3616df855d53c0acc30c6f22b5e68b5e112c..c54baffecf94c174e38e13a24b9b26f32ded1c05 100644 (file)
@@ -2937,6 +2937,22 @@ public class DebuggerTests
                ex.InvokeMethod (e.Thread, tostring_method, null, InvokeOptions.SingleThreaded);
        }
 
+       [Test]
+       public void MemberInOtherDomain () {
+               vm.Detach ();
+
+               Start (new string [] { "dtest-app.exe", "domain-test" });
+
+               vm.EnableEvents (EventType.AppDomainCreate, EventType.AppDomainUnload, EventType.AssemblyUnload);
+
+               Event e = run_until ("domains_print_across");
+
+               var frame = e.Thread.GetFrames ()[0];
+               var inOtherDomain = frame.GetArgument (0) as ObjectMirror;
+               var crossDomainField = (ObjectMirror) inOtherDomain.GetValue (inOtherDomain.Type.GetField("printMe"));
+               Assert.AreEqual ("SentinelClass", crossDomainField.Type.Name);
+       }
+
        [Test]
        public void Domains () {
                vm.Detach ();
index fa0f5180187f518997f214be37011d62013b3fd5..9cde3498e4d17dde9a74721a7ad9a25052da0ec4 100644 (file)
@@ -7,7 +7,7 @@ LIBRARY = Mono.Posix.dll
 # members, generating volumes of output.
 LIB_REFS = System
 LIB_MCS_FLAGS = /unsafe /r:$(corlib) /nowarn:0618,612
-TEST_MCS_FLAGS = /r:Mono.Posix.dll /r:System.dll /nowarn:0219,0618
+TEST_MCS_FLAGS = /unsafe /r:Mono.Posix.dll /r:System.dll /nowarn:0219,0618
 
 LIBRARY_COMPILE = $(BOOT_COMPILE)
 
index 4e2613b127991263f8ba2d31fede7f7da2a99f1f..57c03140112b75746de381257b13e4b763886f5c 100644 (file)
@@ -359,7 +359,117 @@ namespace Mono.Unix.Native {
                {
                        return ToStatvfs (source, out destination) == 0;
                }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_FromInAddr")]
+               private static extern int FromInAddr (ref InAddr source, IntPtr destination);
+
+               public static bool TryCopy (ref InAddr source, IntPtr destination)
+               {
+                       return FromInAddr (ref source, destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_ToInAddr")]
+               private static extern int ToInAddr (IntPtr source, out InAddr destination);
+
+               public static bool TryCopy (IntPtr source, out InAddr destination)
+               {
+                       return ToInAddr (source, out destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_FromIn6Addr")]
+               private static extern int FromIn6Addr (ref In6Addr source, IntPtr destination);
+
+               public static bool TryCopy (ref In6Addr source, IntPtr destination)
+               {
+                       return FromIn6Addr (ref source, destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_ToIn6Addr")]
+               private static extern int ToIn6Addr (IntPtr source, out In6Addr destination);
+
+               public static bool TryCopy (IntPtr source, out In6Addr destination)
+               {
+                       return ToIn6Addr (source, out destination) == 0;
+               }
+
+               public static InAddr ToInAddr (System.Net.IPAddress address)
+               {
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+                       if (address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
+                               throw new ArgumentException ("address", "address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork");
+                       return new InAddr (address.GetAddressBytes ());
+               }
+
+               public static System.Net.IPAddress ToIPAddress (InAddr address)
+               {
+                       var bytes = new byte[4];
+                       address.CopyTo (bytes, 0);
+                       return new System.Net.IPAddress (bytes);
+               }
+
+               public static In6Addr ToIn6Addr (System.Net.IPAddress address)
+               {
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+                       if (address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
+                               throw new ArgumentException ("address", "address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6");
+                       return new In6Addr (address.GetAddressBytes ());
+               }
+
+               public static System.Net.IPAddress ToIPAddress (In6Addr address)
+               {
+                       var bytes = new byte[16];
+                       address.CopyTo (bytes, 0);
+                       return new System.Net.IPAddress (bytes);
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_FromSockaddr")]
+               private static extern unsafe int FromSockaddr (_SockaddrHeader* source, IntPtr destination);
+
+               public static unsafe bool TryCopy (Sockaddr source, IntPtr destination)
+               {
+                       if (source == null)
+                               throw new ArgumentNullException ("source");
+                       byte[] array = Sockaddr.GetDynamicData (source);
+                       // SockaddrStorage has to be handled extra because the native code assumes that SockaddrStorage input is used in-place
+                       if (source.type == (SockaddrType.SockaddrStorage | SockaddrType.MustBeWrapped)) {
+                               Marshal.Copy (array, 0, destination, (int) source.GetDynamicLength ());
+                               return true;
+                       }
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (source).type)
+                       fixed (byte* data = array) {
+                               var dyn = new _SockaddrDynamic (source, data, useMaxLength: false);
+                               return FromSockaddr (Sockaddr.GetNative (&dyn, addr), destination) == 0;
+                       }
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_ToSockaddr")]
+               private static extern unsafe int ToSockaddr (IntPtr source, long size, _SockaddrHeader* destination);
+
+               public static unsafe bool TryCopy (IntPtr source, long size, Sockaddr destination)
+               {
+                       if (destination == null)
+                               throw new ArgumentNullException ("destination");
+                       byte[] array = Sockaddr.GetDynamicData (destination);
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (destination).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (destination)) {
+                               var dyn = new _SockaddrDynamic (destination, data, useMaxLength: true);
+                               var r = ToSockaddr (source, size, Sockaddr.GetNative (&dyn, addr));
+                               dyn.Update (destination);
+                               // SockaddrStorage has to be handled extra because the native code assumes that SockaddrStorage input is used in-place
+                               if (r == 0 && destination.type == (SockaddrType.SockaddrStorage | SockaddrType.MustBeWrapped)) {
+                                       Marshal.Copy (source, array, 0, (int) destination.GetDynamicLength ());
+                               }
+                               return r == 0;
+                       }
+               }
        }
 }
 
 // vim: noexpandtab
+// Local Variables: 
+// tab-width: 4
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// End: 
index 2ac13c6677edd26437a6fc806df7cf3e12b6d027..436235334a157beb47b7831e0091fcc5b4e9eadf 100644 (file)
@@ -918,6 +918,70 @@ namespace Mono.Unix.Native {
                        return rval;
                }
 
+               [DllImport (LIB, EntryPoint="Mono_Posix_FromSockaddrIn")]
+               private static extern int FromSockaddrIn (SockaddrIn source, IntPtr destination);
+
+               public static bool TryCopy (SockaddrIn source, IntPtr destination)
+               {
+                       return FromSockaddrIn (source, destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_ToSockaddrIn")]
+               private static extern int ToSockaddrIn (IntPtr source, SockaddrIn destination);
+
+               public static bool TryCopy (IntPtr source, SockaddrIn destination)
+               {
+                       return ToSockaddrIn (source, destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_FromSockaddrIn6")]
+               private static extern int FromSockaddrIn6 (SockaddrIn6 source, IntPtr destination);
+
+               public static bool TryCopy (SockaddrIn6 source, IntPtr destination)
+               {
+                       return FromSockaddrIn6 (source, destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_ToSockaddrIn6")]
+               private static extern int ToSockaddrIn6 (IntPtr source, SockaddrIn6 destination);
+
+               public static bool TryCopy (IntPtr source, SockaddrIn6 destination)
+               {
+                       return ToSockaddrIn6 (source, destination) == 0;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_FromSockaddrType")]
+               private static extern int FromSockaddrType (SockaddrType value, out Int32 rval);
+
+               internal static bool TryFromSockaddrType (SockaddrType value, out Int32 rval)
+               {
+                       return FromSockaddrType (value, out rval) == 0;
+               }
+
+               internal static Int32 FromSockaddrType (SockaddrType value)
+               {
+                       Int32 rval;
+                       if (FromSockaddrType (value, out rval) == -1)
+                               ThrowArgumentException (value);
+                       return rval;
+               }
+
+               [DllImport (LIB, EntryPoint="Mono_Posix_ToSockaddrType")]
+               private static extern int ToSockaddrType (Int32 value, out SockaddrType rval);
+
+               internal static bool TryToSockaddrType (Int32 value, out SockaddrType rval)
+               {
+                       return ToSockaddrType (value, out rval) == 0;
+               }
+
+               internal static SockaddrType ToSockaddrType (Int32 value)
+               {
+                       SockaddrType rval;
+                       if (ToSockaddrType (value, out rval) == -1)
+                               ThrowArgumentException (value);
+                       return rval;
+               }
+
                [DllImport (LIB, EntryPoint="Mono_Posix_FromSysconfName")]
                private static extern int FromSysconfName (SysconfName value, out Int32 rval);
 
index 4125978df0c8371b3c21d2a86e7e00364e2f7e54..4ab7ed53ad6618270bc52ce8e03ee756e7935781 100644 (file)
@@ -821,6 +821,9 @@ namespace Mono.Unix.Native {
                AF_ALG        = 38,  /* Algorithm sockets. */
                AF_NFC        = 39,  /* NFC sockets. */
                AF_VSOCK      = 40,  /* vSockets. */
+
+               // Value used when a syscall returns an unknown address family value
+               Unknown       = 65536,
        }
 
        [Map]
@@ -907,6 +910,20 @@ namespace Mono.Unix.Native {
                SHUT_RDWR = 0x03,   /* No more receptions or transmissions. */
        }
 
+       // Used by libMonoPosixHelper to distinguish between different sockaddr types
+       [Map]
+       enum SockaddrType : int {
+               Invalid,
+               SockaddrStorage,
+               SockaddrUn,
+               Sockaddr,
+               SockaddrIn,
+               SockaddrIn6,
+
+               // Flag to indicate that this Sockaddr must be wrapped with a _SockaddrDynamic wrapper
+               MustBeWrapped = 0x8000,
+       }
+
        #endregion
 
        #region Structures
@@ -1421,6 +1438,144 @@ namespace Mono.Unix.Native {
                }
        }
 
+       [Map]
+       [StructLayout (LayoutKind.Sequential)]
+       [CLSCompliant (false)]
+       public struct InAddr : IEquatable<InAddr> {
+               public uint s_addr;
+
+               public unsafe InAddr (byte b0, byte b1, byte b2, byte b3)
+               {
+                       s_addr = 0;
+                       fixed (uint* ptr = &s_addr) {
+                               byte* bytePtr = (byte*) ptr;
+                               bytePtr[0] = b0;
+                               bytePtr[1] = b1;
+                               bytePtr[2] = b2;
+                               bytePtr[3] = b3;
+                       }
+               }
+
+               public unsafe InAddr (byte[] buffer)
+               {
+                       if (buffer.Length != 4)
+                               throw new ArgumentException ("buffer.Length != 4", "buffer");
+                       s_addr = 0;
+                       fixed (uint* ptr = &s_addr)
+                               Marshal.Copy (buffer, 0, (IntPtr) ptr, 4);
+               }
+
+               public unsafe void CopyFrom (byte[] source, int startIndex)
+               {
+                       fixed (uint* ptr = &s_addr)
+                               Marshal.Copy (source, startIndex, (IntPtr) ptr, 4);
+               }
+
+               public unsafe void CopyTo (byte[] destination, int startIndex)
+               {
+                       fixed (uint* ptr = &s_addr)
+                               Marshal.Copy ((IntPtr) ptr, destination, startIndex, 4);
+               }
+
+               public unsafe byte this[int index] {
+                       get {
+                               if (index < 0 || index >= 4)
+                                       throw new ArgumentOutOfRangeException ("index", "index < 0 || index >= 4");
+                               fixed (uint* ptr = &s_addr)
+                                       return ((byte*) ptr)[index];
+                       }
+                       set {
+                               if (index < 0 || index >= 4)
+                                       throw new ArgumentOutOfRangeException ("index", "index < 0 || index >= 4");
+                               fixed (uint* ptr = &s_addr)
+                                       ((byte*) ptr)[index] = value;
+                       }
+               }
+
+               public override string ToString ()
+               {
+                       return NativeConvert.ToIPAddress (this).ToString ();
+               }
+
+               public override int GetHashCode ()
+               {
+                       return s_addr.GetHashCode ();
+               }
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is InAddr))
+                               return false;
+                       return Equals ((InAddr) obj);
+               }
+               public bool Equals (InAddr value)
+               {
+                       return s_addr == value.s_addr;
+               }
+       }
+
+       [Map]
+       [StructLayout (LayoutKind.Sequential)]
+       public struct In6Addr : IEquatable<In6Addr> {
+               ulong addr0;
+               ulong addr1;
+
+               public unsafe In6Addr (byte[] buffer)
+               {
+                       if (buffer.Length != 16)
+                               throw new ArgumentException ("buffer.Length != 16", "buffer");
+                       addr0 = addr1 = 0;
+                       fixed (ulong* ptr = &addr0)
+                               Marshal.Copy (buffer, 0, (IntPtr) ptr, 16);
+               }
+
+               public unsafe void CopyFrom (byte[] source, int startIndex)
+               {
+                       fixed (ulong* ptr = &addr0)
+                               Marshal.Copy (source, startIndex, (IntPtr) ptr, 16);
+               }
+
+               public unsafe void CopyTo (byte[] destination, int startIndex)
+               {
+                       fixed (ulong* ptr = &addr0)
+                               Marshal.Copy ((IntPtr) ptr, destination, startIndex, 16);
+               }
+
+               public unsafe byte this[int index] {
+                       get {
+                               if (index < 0 || index >= 16)
+                                       throw new ArgumentOutOfRangeException ("index", "index < 0 || index >= 16");
+                               fixed (ulong* ptr = &addr0)
+                                       return ((byte*) ptr)[index];
+                       }
+                       set {
+                               if (index < 0 || index >= 16)
+                                       throw new ArgumentOutOfRangeException ("index", "index < 0 || index >= 16");
+                               fixed (ulong* ptr = &addr0)
+                                       ((byte*) ptr)[index] = value;
+                       }
+               }
+
+               public override string ToString ()
+               {
+                       return NativeConvert.ToIPAddress (this).ToString ();
+               }
+
+               public override int GetHashCode ()
+               {
+                       return addr0.GetHashCode () ^ addr1.GetHashCode ();
+               }
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is In6Addr))
+                               return false;
+                       return Equals ((In6Addr) obj);
+               }
+               public bool Equals (In6Addr value)
+               {
+                       return addr0 == value.addr0 && addr1 == value.addr1;
+               }
+       }
+
        #endregion
 
        #region Classes
@@ -1715,6 +1870,522 @@ namespace Mono.Unix.Native {
                }
        }
 
+       // This struct is used by the native code.
+       // Its layout must be the same as the start of the Sockaddr class and the start of the _SockaddrDynamic struct
+       [Map]
+       [StructLayout (LayoutKind.Sequential)]
+       internal struct _SockaddrHeader {
+               internal SockaddrType type;
+               internal UnixAddressFamily sa_family;
+       }
+
+       // Base class for all Sockaddr types.
+       // This class is not abstract, instances of this class can be used to determine the sa_family value.
+       // This class and all classes which are deriving from it and are passed to the native code have to be blittable.
+       [CLSCompliant (false)]
+       [StructLayout (LayoutKind.Sequential)]
+       public class Sockaddr {
+               // Note: the layout of the first members must match the layout of struct _SockaddrHeader
+               // 'type' must be the first field of the class as it is used to find the address of the class itself
+               internal SockaddrType type;
+               internal UnixAddressFamily _sa_family;
+
+               public UnixAddressFamily sa_family {
+                       get { return _sa_family; }
+                       set { _sa_family = value; }
+               }
+
+               public Sockaddr ()
+               {
+                       this.type = SockaddrType.Sockaddr;
+                       this.sa_family = UnixAddressFamily.AF_UNSPEC;
+               }
+
+               internal Sockaddr (SockaddrType type, UnixAddressFamily sa_family)
+               {
+                       this.type = type;
+                       this.sa_family = sa_family;
+               }
+
+               [DllImport (Syscall.MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Sockaddr_GetNativeSize")]
+               static extern unsafe int GetNativeSize (_SockaddrHeader* address, out long size);
+
+               internal unsafe long GetNativeSize ()
+               {
+                       long size;
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (this).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (this)) {
+                               var dyn = new _SockaddrDynamic (this, data, useMaxLength: false);
+                               if (GetNativeSize (Sockaddr.GetNative (&dyn, addr), out size) != 0)
+                                               throw new ArgumentException ("Failed to get size of native struct", "this");
+                       }
+                       return size;
+               }
+
+
+               // In order to create a wrapper for a syscall which accepts a "struct sockaddr" argument but does not modify it, use:
+
+               // fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+               // fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+               //     var dyn = new _SockaddrDynamic (address, data, useMaxLength: false);
+               //     return sys_syscall (..., Sockaddr.GetNative (&dyn, addr));
+               // }
+
+               // For syscalls which modify the argument, use:
+
+               // fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+               // fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+               //     var dyn = new _SockaddrDynamic (address, data, useMaxLength: true);
+               //     rettype r = sys_syscall (..., Sockaddr.GetNative (&dyn, addr));
+               //     dyn.Update (address);
+               //     return r;
+               // }
+
+               // This sequence will handle
+               // - normal Sockaddrs like SockaddrIn and SockaddrIn6 which will be passed directly,
+               // - sockaddrs like SockaddrUn and SockaddrStorage which need a wrapper and
+               // - null (which will be passed as null)
+               // without any heap memory allocations.
+
+
+               // This is a fake Sockaddr which is passed to the fixed() statement if the address was null.
+               // Sockaddr.GetNative() will return a null pointer for this Sockaddr.
+               static Sockaddr nullSockaddr = new Sockaddr ();
+
+               internal static Sockaddr GetAddress (Sockaddr address)
+               {
+                       if (address == null)
+                               return nullSockaddr;
+                       else
+                               return address;
+               }
+
+               internal static unsafe _SockaddrHeader* GetNative (_SockaddrDynamic* dyn, SockaddrType* addr)
+               {
+                       if (dyn->data != null) {
+                               return (_SockaddrHeader*) dyn;
+                       } else {
+                               fixed (SockaddrType* nullType = &nullSockaddr.type)
+                                       if (addr == nullType)
+                                               return null;
+                               return (_SockaddrHeader*) addr;
+                       }
+               }
+
+               // Return an array containing the dynamic data (for SockaddrStorage and SockaddrUn) or null
+               internal static byte[] GetDynamicData (Sockaddr addr)
+               {
+                       if (addr == null)
+                               return null;
+                       return addr.DynamicData ();
+               }
+
+               // This methods is overwritten in SockaddrStorage and SockaddrUn
+               internal virtual byte[] DynamicData ()
+               {
+                       return null;
+               }
+
+               // This methods should only be called for SockaddrStorage and SockaddrUn where they are overwritten
+               internal virtual long GetDynamicLength ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               internal virtual void SetDynamicLength (long value)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public SockaddrStorage ToSockaddrStorage ()
+               {
+                       var storage = new SockaddrStorage ((int) GetNativeSize ());
+                       storage.SetTo (this);
+                       return storage;
+               }
+
+               public static Sockaddr FromSockaddrStorage (SockaddrStorage storage)
+               {
+                       var ret = new Sockaddr ();
+                       storage.CopyTo (ret);
+                       return ret;
+               }
+       }
+
+       // This struct is required to manually marshal Sockaddr* classes which include an array (currently SockaddrStorage and SockaddrUn).
+       // This is needed because the marshalling code will not work if the classes derived from Sockaddr aren't blittable.
+       [Map]
+       unsafe struct _SockaddrDynamic {
+               // Note: the layout of the first members must match the layout of struct _SockaddrHeader
+               public SockaddrType type;
+               public UnixAddressFamily sa_family;
+               public byte* data;
+               public long len;
+
+               public _SockaddrDynamic (Sockaddr address, byte* data, bool useMaxLength)
+               {
+                       if (data == null) {
+                               // When data is null, no wrapper is needed.
+                               // Initialize everything to zero, Sockaddr.GetNative() will then
+                               // use the Sockaddr structure directly.
+                               this = new _SockaddrDynamic ();
+                               return;
+                       }
+
+                       var dynData = address.DynamicData ();
+
+                       type = address.type & ~SockaddrType.MustBeWrapped;
+                       sa_family = address.sa_family;
+                       this.data = data;
+                       if (useMaxLength) {
+                               len = dynData.Length;
+                       } else {
+                               len = address.GetDynamicLength ();
+                               if (len < 0 || len > dynData.Length)
+                                       throw new ArgumentException ("len < 0 || len > dynData.Length", "address");
+                       }
+               }
+
+               public void Update (Sockaddr address)
+               {
+                       // When data is null, no wrapper was needed.
+                       if (data == null)
+                               return;
+
+                       address.sa_family = sa_family;
+                       address.SetDynamicLength (len);
+               }
+       };
+
+       // This is a class which can store arbitrary sockaddrs, even if they are not known the the Mono.Unix wrapper or the family does not have a corresponding value in the UnixAddressFamily enumeration.
+       [CLSCompliant (false)]
+       public sealed class SockaddrStorage : Sockaddr, IEquatable<SockaddrStorage> {
+               // Note: The sa_family field is ignored when passing a SockaddrStorage to a syscall (but it will be set when a SockaddrStorage is returned from a syscall). Instead of the sa_family field, the value embedded in data is used.
+               public byte[] data { get; set; }
+               public long data_len { get; set; }
+
+               internal override byte[] DynamicData ()
+               {
+                       return data;
+               }
+
+               internal override long GetDynamicLength ()
+               {
+                       return data_len;
+               }
+
+               internal override void SetDynamicLength (long value)
+               {
+                       data_len = value;
+               }
+
+               [DllImport (Syscall.MPH, SetLastError=true,
+                               EntryPoint="Mono_Posix_SockaddrStorage_get_size")]
+               static extern int get_size ();
+               static readonly int default_size = get_size ();
+
+               public SockaddrStorage ()
+                       : base (SockaddrType.SockaddrStorage | SockaddrType.MustBeWrapped, UnixAddressFamily.AF_UNSPEC)
+               {
+                       data = new byte[default_size];
+                       data_len = 0;
+               }
+
+               public SockaddrStorage (int size)
+                       : base (SockaddrType.SockaddrStorage | SockaddrType.MustBeWrapped, UnixAddressFamily.AF_UNSPEC)
+               {
+                       data = new byte[size];
+                       data_len = 0;
+               }
+
+               public unsafe void SetTo (Sockaddr address)
+               {
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+
+                       var size = address.GetNativeSize ();
+                       if (size > data.Length)
+                               data = new byte[size];
+                       fixed (byte* ptr = data)
+                               if (!NativeConvert.TryCopy (address, (IntPtr) ptr))
+                                       throw new ArgumentException ("Failed to convert to native struct", "address");
+                       data_len = size;
+                       sa_family = address.sa_family;
+               }
+
+               public unsafe void CopyTo (Sockaddr address)
+               {
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+                       if (data_len < 0 || data_len > data.Length)
+                               throw new ArgumentException ("data_len < 0 || data_len > data.Length", "this");
+
+                       fixed (byte* ptr = data)
+                               if (!NativeConvert.TryCopy ((IntPtr) ptr, data_len, address))
+                                       throw new ArgumentException ("Failed to convert from native struct", "this");
+               }
+
+               public override string ToString ()
+               {
+                       var sb = new StringBuilder ();
+                       sb.AppendFormat ("{{sa_family={0}, data_len={1}, data=(", sa_family, data_len);
+                       for (int i = 0; i < data_len; i++) {
+                               if (i != 0)
+                                       sb.Append (" ");
+                               sb.Append (data[i].ToString ("x2"));
+                       }
+                       sb.Append (")");
+                       return sb.ToString ();
+               }
+
+               public override int GetHashCode ()
+               {
+                       unchecked {
+                               int hash = 0x1234;
+                               for (int i = 0; i < data_len; i++)
+                                       hash += i ^ data[i];
+                               return hash;
+                       }
+               }
+
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is SockaddrStorage))
+                               return false;
+                       return Equals ((SockaddrStorage) obj);
+               }
+
+               public bool Equals (SockaddrStorage value)
+               {
+                       if (value == null)
+                               return false;
+                       if (data_len != value.data_len)
+                               return false;
+                       for (int i = 0; i < data_len; i++)
+                               if (data[i] != value.data[i])
+                                       return false;
+                       return true;
+               }
+       }
+
+       [CLSCompliant (false)]
+       public sealed class SockaddrUn : Sockaddr, IEquatable<SockaddrUn> {
+               public UnixAddressFamily sun_family { // AF_UNIX
+                       get { return sa_family; }
+                       set { sa_family = value; }
+               }
+               public byte[] sun_path { get; set; }
+               public long sun_path_len { get; set; } // Indicates how many bytes of sun_path are valid. Must not be larger than sun_path.Length.
+
+               internal override byte[] DynamicData ()
+               {
+                       return sun_path;
+               }
+
+               internal override long GetDynamicLength ()
+               {
+                       return sun_path_len;
+               }
+
+               internal override void SetDynamicLength (long value)
+               {
+                       sun_path_len = value;
+               }
+
+               [DllImport (Syscall.MPH, SetLastError=true,
+                               EntryPoint="Mono_Posix_SockaddrUn_get_sizeof_sun_path")]
+               static extern int get_sizeof_sun_path ();
+               static readonly int sizeof_sun_path = get_sizeof_sun_path ();
+
+               public SockaddrUn ()
+                       : base (SockaddrType.SockaddrUn | SockaddrType.MustBeWrapped, UnixAddressFamily.AF_UNIX)
+               {
+                       sun_path = new byte[sizeof_sun_path];
+                       sun_path_len = 0;
+               }
+
+               public SockaddrUn (int size)
+                       : base (SockaddrType.SockaddrUn | SockaddrType.MustBeWrapped, UnixAddressFamily.AF_UNIX)
+               {
+                       sun_path = new byte[size];
+                       sun_path_len = 0;
+               }
+
+               public SockaddrUn (string path, bool linuxAbstractNamespace = false)
+                       : base (SockaddrType.SockaddrUn | SockaddrType.MustBeWrapped, UnixAddressFamily.AF_UNIX)
+               {
+                       if (path == null)
+                               throw new ArgumentNullException ("path");
+                       var bytes = UnixEncoding.Instance.GetBytes (path);
+                       if (linuxAbstractNamespace) {
+                               sun_path = new byte[1 + bytes.Length];
+                               Array.Copy (bytes, 0, sun_path, 1, bytes.Length);
+                       } else {
+                               sun_path = bytes;
+                       }
+                       sun_path_len = sun_path.Length;
+               }
+
+               public bool IsLinuxAbstractNamespace {
+                       get {
+                               return sun_path_len > 0 && sun_path[0] == 0;
+                       }
+               }
+
+               public string Path {
+                       get {
+                               var offset = IsLinuxAbstractNamespace ? 1 : 0;
+                               // Remove data after null terminator
+                               int length;
+                               for (length = 0; offset + length < sun_path_len; length++)
+                                       if (sun_path[offset + length] == 0)
+                                               break;
+                               return UnixEncoding.Instance.GetString (sun_path, offset, length);
+                       }
+               }
+
+               public override string ToString ()
+               {
+                       return string.Format ("{{sa_family={0}, sun_path=\"{1}{2}\"}}", sa_family, IsLinuxAbstractNamespace ? "\\0" : "", Path);
+               }
+
+               public static new SockaddrUn FromSockaddrStorage (SockaddrStorage storage)
+               {
+                       // This will make the SockaddrUn larger than it needs to be (because
+                       // storage.data_len includes the sun_family field), but it will be
+                       // large enough.
+                       var ret = new SockaddrUn ((int) storage.data_len);
+                       storage.CopyTo (ret);
+                       return ret;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return sun_family.GetHashCode () ^ IsLinuxAbstractNamespace.GetHashCode () ^ Path.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is SockaddrUn))
+                               return false;
+                       return Equals ((SockaddrUn) obj);
+               }
+
+               public bool Equals (SockaddrUn value)
+               {
+                       if (value == null)
+                               return false;
+                       return sun_family == value.sun_family
+                               && IsLinuxAbstractNamespace == value.IsLinuxAbstractNamespace
+                               && Path == value.Path;
+               }
+       }
+
+       [Map ("struct sockaddr_in")]
+       [CLSCompliant (false)]
+       [StructLayout (LayoutKind.Sequential)]
+       public sealed class SockaddrIn : Sockaddr, IEquatable<SockaddrIn> {
+               public UnixAddressFamily sin_family { // AF_INET
+                       get { return sa_family; }
+                       set { sa_family = value; }
+               }
+               public ushort sin_port;   // Port number.
+               public InAddr sin_addr;   // IP address.
+
+               public SockaddrIn ()
+                       : base (SockaddrType.SockaddrIn, UnixAddressFamily.AF_INET)
+               {
+               }
+
+               public override string ToString ()
+               {
+                       return string.Format ("{{sin_family={0}, sin_port=htons({1}), sin_addr={2}}}", sa_family, Syscall.ntohs(sin_port), sin_addr);
+               }
+
+               public static new SockaddrIn FromSockaddrStorage (SockaddrStorage storage)
+               {
+                       var ret = new SockaddrIn ();
+                       storage.CopyTo (ret);
+                       return ret;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return sin_family.GetHashCode () ^ sin_port.GetHashCode () ^ sin_addr.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is SockaddrIn))
+                               return false;
+                       return Equals ((SockaddrIn) obj);
+               }
+
+               public bool Equals (SockaddrIn value)
+               {
+                       if (value == null)
+                               return false;
+                       return sin_family == value.sin_family
+                               && sin_port == value.sin_port
+                               && sin_addr.Equals (value.sin_addr);
+               }
+       }
+
+       [Map ("struct sockaddr_in6")]
+       [CLSCompliant (false)]
+       [StructLayout (LayoutKind.Sequential)]
+       public sealed class SockaddrIn6 : Sockaddr, IEquatable<SockaddrIn6> {
+               public UnixAddressFamily sin6_family { // AF_INET6
+                       get { return sa_family; }
+                       set { sa_family = value; }
+               }
+               public ushort  sin6_port;     // Port number.
+               public uint    sin6_flowinfo; // IPv6 traffic class and flow information.
+               public In6Addr sin6_addr;     // IPv6 address.
+               public uint    sin6_scope_id; // Set of interfaces for a scope.
+
+               public SockaddrIn6 ()
+                       : base (SockaddrType.SockaddrIn6, UnixAddressFamily.AF_INET6)
+               {
+               }
+
+               public override string ToString ()
+               {
+                       return string.Format ("{{sin6_family={0}, sin6_port=htons({1}), sin6_flowinfo={2}, sin6_addr={3}, sin6_scope_id={4}}}", sa_family, Syscall.ntohs (sin6_port), sin6_flowinfo, sin6_addr, sin6_scope_id);
+               }
+
+               public static new SockaddrIn6 FromSockaddrStorage (SockaddrStorage storage)
+               {
+                       var ret = new SockaddrIn6 ();
+                       storage.CopyTo (ret);
+                       return ret;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return sin6_family.GetHashCode () ^ sin6_port.GetHashCode () ^ sin6_flowinfo.GetHashCode () ^ sin6_addr.GetHashCode () ^ sin6_scope_id.GetHashCode ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       if (!(obj is SockaddrIn6))
+                               return false;
+                       return Equals ((SockaddrIn6) obj);
+               }
+
+               public bool Equals (SockaddrIn6 value)
+               {
+                       if (value == null)
+                               return false;
+                       return sin6_family == value.sin6_family
+                               && sin6_port == value.sin6_port
+                               && sin6_flowinfo == value.sin6_flowinfo
+                               && sin6_addr.Equals (value.sin6_addr)
+                               && sin6_scope_id == value.sin6_scope_id;
+               }
+       }
+
        //
        // Convention: Functions *not* part of the standard C library AND part of
        // a POSIX and/or Unix standard (X/Open, SUS, XPG, etc.) go here.
@@ -4550,6 +5221,33 @@ namespace Mono.Unix.Native {
                }
                #endregion
 
+               #region <arpa/inet.h> Declarations
+               //
+               // <arpa/inet.h>
+               //
+
+               // htonl(3)
+               //    uint32_t htonl(uint32_t hostlong);
+               [DllImport (LIBC)]
+               public static extern uint htonl(uint hostlong);
+
+               // htons(3)
+               //    uint16_t htons(uint16_t hostshort);
+               [DllImport (LIBC)]
+               public static extern ushort htons(ushort hostshort);
+
+               // ntohl(3)
+               //    uint32_t ntohl(uint32_t netlong);
+               [DllImport (LIBC)]
+               public static extern uint ntohl(uint netlong);
+
+               // ntohs(3)
+               //    uint16_t ntohs(uint16_t netshort);
+               [DllImport (LIBC)]
+               public static extern ushort ntohs(ushort netshort);
+
+               #endregion
+
                #region <socket.h> Declarations
                //
                // <socket.h>
@@ -4785,6 +5483,165 @@ namespace Mono.Unix.Native {
                                return send (socket, ptr, length, flags);
                }
 
+               // bind(2)
+               //    int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_bind")]
+               static extern unsafe int sys_bind (int socket, _SockaddrHeader* address);
+
+               public static unsafe int bind (int socket, Sockaddr address)
+               {
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: false);
+                               return sys_bind (socket, Sockaddr.GetNative (&dyn, addr));
+                       }
+               }
+
+               // connect(2)
+               //    int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_connect")]
+               static extern unsafe int sys_connect (int socket, _SockaddrHeader* address);
+
+               public static unsafe int connect (int socket, Sockaddr address)
+               {
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: false);
+                               return sys_connect (socket, Sockaddr.GetNative (&dyn, addr));
+                       }
+               }
+
+               // accept(2)
+               //    int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_accept")]
+               static extern unsafe int sys_accept (int socket, _SockaddrHeader* address);
+
+               public static unsafe int accept (int socket, Sockaddr address)
+               {
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: true);
+                               int r = sys_accept (socket, Sockaddr.GetNative (&dyn, addr));
+                               dyn.Update (address);
+                               return r;
+                       }
+               }
+
+               // accept4(2)
+               //    int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_accept4")]
+               static extern unsafe int sys_accept4 (int socket, _SockaddrHeader* address, int flags);
+
+               public static unsafe int accept4 (int socket, Sockaddr address, UnixSocketFlags flags)
+               {
+                       var _flags = NativeConvert.FromUnixSocketFlags (flags);
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: true);
+                               int r = sys_accept4 (socket, Sockaddr.GetNative (&dyn, addr), _flags);
+                               dyn.Update (address);
+                               return r;
+                       }
+               }
+
+               // getpeername(2)
+               //    int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_getpeername")]
+               static extern unsafe int sys_getpeername (int socket, _SockaddrHeader* address);
+
+               public static unsafe int getpeername (int socket, Sockaddr address)
+               {
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: true);
+                               int r = sys_getpeername (socket, Sockaddr.GetNative (&dyn, addr));
+                               dyn.Update (address);
+                               return r;
+                       }
+               }
+
+               // getsockname(2)
+               //    int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_getsockname")]
+               static extern unsafe int sys_getsockname (int socket, _SockaddrHeader* address);
+
+               public static unsafe int getsockname (int socket, Sockaddr address)
+               {
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: true);
+                               int r = sys_getsockname (socket, Sockaddr.GetNative (&dyn, addr));
+                               dyn.Update (address);
+                               return r;
+                       }
+               }
+
+               // recvfrom(2)
+               //    ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_recvfrom")]
+               static extern unsafe long sys_recvfrom (int socket, void *buffer, ulong length, int flags, _SockaddrHeader* address);
+
+               public static unsafe long recvfrom (int socket, void *buffer, ulong length, MessageFlags flags, Sockaddr address)
+               {
+                       int _flags = NativeConvert.FromMessageFlags (flags);
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: true);
+                               long r = sys_recvfrom (socket, buffer, length, _flags, Sockaddr.GetNative (&dyn, addr));
+                               dyn.Update (address);
+                               return r;
+                       }
+               }
+
+               public static unsafe long recvfrom (int socket, IntPtr buffer, ulong length, MessageFlags flags, Sockaddr address)
+               {
+                       return recvfrom (socket, (void*) buffer, length, flags, address);
+               }
+
+               public static unsafe long recvfrom (int socket, byte[] buffer, ulong length, MessageFlags flags, Sockaddr address)
+               {
+                       if (length > (ulong) buffer.LongLength)
+                               throw new ArgumentOutOfRangeException ("length", "length > buffer.LongLength");
+                       fixed (byte* ptr = buffer)
+                               return recvfrom (socket, ptr, length, flags, address);
+               }
+
+               // sendto(2)
+               //    ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen);
+               [DllImport (MPH, SetLastError=true, 
+                               EntryPoint="Mono_Posix_Syscall_sendto")]
+               static extern unsafe long sys_sendto (int socket, void *message, ulong length, int flags, _SockaddrHeader* address);
+
+               public static unsafe long sendto (int socket, void *message, ulong length, MessageFlags flags, Sockaddr address)
+               {
+                       int _flags = NativeConvert.FromMessageFlags (flags);
+                       fixed (SockaddrType* addr = &Sockaddr.GetAddress (address).type)
+                       fixed (byte* data = Sockaddr.GetDynamicData (address)) {
+                               var dyn = new _SockaddrDynamic (address, data, useMaxLength: false);
+                               return sys_sendto (socket, message, length, _flags, Sockaddr.GetNative (&dyn, addr));
+                       }
+               }
+
+               public static unsafe long sendto (int socket, IntPtr message, ulong length, MessageFlags flags, Sockaddr address)
+               {
+                       return sendto (socket, (void*) message, length, flags, address);
+               }
+
+               public static unsafe long sendto (int socket, byte[] message, ulong length, MessageFlags flags, Sockaddr address)
+               {
+                       if (length > (ulong) message.LongLength)
+                               throw new ArgumentOutOfRangeException ("length", "length > message.LongLength");
+                       fixed (byte* ptr = message)
+                               return sendto (socket, ptr, length, flags, address);
+               }
+
                #endregion
        }
 
@@ -4792,3 +5649,8 @@ namespace Mono.Unix.Native {
 }
 
 // vim: noexpandtab
+// Local Variables: 
+// tab-width: 4
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// End: 
index a3891311dd562a6e4dfffc69fdfb2c2d7b4387df..dd5ed9bf40b775fa7721c5c439716c9a5b847f88 100644 (file)
@@ -98,7 +98,7 @@ namespace MonoTests.Mono.Unix.Native
                }
 
                [Test]
-               public void Socket ()
+               public void TestSocket ()
                {
                        int socket;
                        if ((socket = Syscall.socket (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0)) < 0)
@@ -212,6 +212,390 @@ namespace MonoTests.Mono.Unix.Native
                                Assert.AreEqual (ret, 0);
                        });
                }
+
+               [Test]
+               public unsafe void ByteOrder ()
+               {
+                       ushort val1 = Syscall.htons (0x1234);
+                       byte* ptr1 = (byte*) &val1;
+                       Assert.AreEqual (ptr1[0], 0x12);
+                       Assert.AreEqual (ptr1[1], 0x34);
+
+                       uint val2 = Syscall.htonl (0x6789abcd);
+                       byte* ptr2 = (byte*) &val2;
+                       Assert.AreEqual (ptr2[0], 0x67);
+                       Assert.AreEqual (ptr2[1], 0x89);
+                       Assert.AreEqual (ptr2[2], 0xab);
+                       Assert.AreEqual (ptr2[3], 0xcd);
+
+                       ptr1[0] = 0xfe;
+                       ptr1[1] = 0xdc;
+                       Assert.AreEqual (Syscall.ntohs (val1), 0xfedc);
+
+                       ptr2[0] = 0x76;
+                       ptr2[1] = 0x54;
+                       ptr2[2] = 0x32;
+                       ptr2[3] = 0x10;
+                       Assert.AreEqual (Syscall.ntohl (val2), 0x76543210);
+               }
+
+               [Test]
+               public void InAddr ()
+               {
+                       var ip = IPAddress.Loopback;
+                       var inAddr = NativeConvert.ToInAddr (ip);
+                       Assert.AreEqual (ip, NativeConvert.ToIPAddress (inAddr));
+                       Assert.AreEqual (0x7f000001, Syscall.ntohl (inAddr.s_addr));
+
+                       Assert.AreEqual ("127.0.0.1", inAddr.ToString ());
+               }
+
+               [Test]
+               public void In6Addr ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               Assert.Ignore ("OS does not support IPv6.");
+
+                       var ip6 = IPAddress.IPv6Loopback;
+                       var in6Addr = NativeConvert.ToIn6Addr (ip6);
+                       Assert.AreEqual (ip6, NativeConvert.ToIPAddress (in6Addr));
+                       Assert.AreEqual (1, in6Addr[15]);
+
+                       Assert.AreEqual ("::1", in6Addr.ToString ());
+               }
+
+               [Test]
+               public void SockaddrUnTest ()
+               {
+                       var address1 = new SockaddrUn ("/tmp/foo");
+                       Assert.AreEqual (address1.Path, "/tmp/foo");
+                       Assert.IsFalse (address1.IsLinuxAbstractNamespace);
+
+                       var storage = address1.ToSockaddrStorage ();
+                       var address2 = SockaddrUn.FromSockaddrStorage (storage);
+                       Assert.AreEqual (address1, address2);
+
+                       var sockaddr = Sockaddr.FromSockaddrStorage (storage);
+                       Assert.AreEqual (sockaddr.sa_family, address1.sa_family);
+
+                       var address3 = new SockaddrUn ("/tmp/bar", linuxAbstractNamespace:true);
+                       Assert.AreEqual (address3.Path, "/tmp/bar");
+                       Assert.IsTrue (address3.IsLinuxAbstractNamespace);
+
+                       var address4 = new SockaddrUn (new string ('X', 9000));
+                       Assert.AreEqual (address4.Path, new string ('X', 9000));
+                       Assert.IsFalse (address4.IsLinuxAbstractNamespace);
+                       var storage2 = address4.ToSockaddrStorage ();
+                       var address5 = SockaddrUn.FromSockaddrStorage (storage2);
+                       Assert.AreEqual (address4, address5);
+                       // Test the malloc() path for long SockaddrUn adresses (the syscalls will fail because the fd is invalid and because the path is too long)
+                       Syscall.bind (-1, address4);
+                       Syscall.getsockname (-1, address4);
+
+                       Assert.AreEqual ("{sa_family=AF_UNIX, sun_path=\"/tmp/foo\"}", address1.ToString ());
+                       Assert.AreEqual ("{sa_family=AF_UNIX, sun_path=\"\\0/tmp/bar\"}", address3.ToString ());
+               }
+
+               [Test]
+               public void SockaddrInTest ()
+               {
+                       var address1 = new SockaddrIn {
+                               sin_family = UnixAddressFamily.AF_INET,
+                               sin_port = Syscall.htons (5678),
+                               sin_addr = NativeConvert.ToInAddr (IPAddress.Loopback),
+                       };
+
+                       var storage = address1.ToSockaddrStorage ();
+                       var address2 = SockaddrIn.FromSockaddrStorage (storage);
+                       Assert.AreEqual (address1, address2);
+
+                       var sockaddr = Sockaddr.FromSockaddrStorage (storage);
+                       Assert.AreEqual (sockaddr.sa_family, address1.sa_family);
+
+                       var storage2 = storage.ToSockaddrStorage ();
+                       Assert.AreEqual (storage, storage2);
+
+                       var storage3 = new SockaddrStorage (123);
+                       storage2.CopyTo (storage3);
+                       Assert.AreEqual (storage, storage3);
+
+                       Assert.AreEqual ("{sin_family=AF_INET, sin_port=htons(5678), sin_addr=127.0.0.1}", address1.ToString ());
+               }
+
+               [Test]
+               public void SockaddrIn6Test ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               Assert.Ignore ("OS does not support IPv6.");
+
+                       var address1 = new SockaddrIn6 {
+                               sin6_family = UnixAddressFamily.AF_INET6,
+                               sin6_port = Syscall.htons (1234),
+                               sin6_flowinfo = 2,
+                               sin6_addr = NativeConvert.ToIn6Addr (IPAddress.IPv6Loopback),
+                               sin6_scope_id = 3
+                       };
+
+                       var storage = address1.ToSockaddrStorage ();
+                       var address2 = SockaddrIn6.FromSockaddrStorage (storage);
+                       Assert.AreEqual (address1, address2);
+
+                       var sockaddr = Sockaddr.FromSockaddrStorage (storage);
+                       Assert.AreEqual (sockaddr.sa_family, address1.sa_family);
+
+                       Assert.AreEqual ("{sin6_family=AF_INET6, sin6_port=htons(1234), sin6_flowinfo=2, sin6_addr=::1, sin6_scope_id=3}", address1.ToString ());
+               }
+
+               [Test]
+               public void BindConnect ()
+               {
+                       WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => {
+                               // Bind UDP socket so1 to 127.0.0.1 with dynamic port
+                               var address = new SockaddrIn {
+                                       sin_family = UnixAddressFamily.AF_INET,
+                                       sin_port = Syscall.htons (0),
+                                       sin_addr = new InAddr (127, 0, 0, 1),
+                               };
+                               if (Syscall.bind (so1, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               // Get actual port number using getsockname()
+                               var actualAddress = new SockaddrIn ();
+                               if (Syscall.getsockname (so1, actualAddress) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (actualAddress.sa_family, UnixAddressFamily.AF_INET);
+                               var port = Syscall.ntohs (actualAddress.sin_port);
+                               Assert.IsTrue (port != 0);
+
+
+                               // Connect so2 to so1
+                               var remoteAddress = new SockaddrIn {
+                                       sin_family = UnixAddressFamily.AF_INET,
+                                       sin_port = Syscall.htons (port),
+                                       sin_addr = new InAddr (127, 0, 0, 1),
+                               };
+                               if (Syscall.connect (so2, remoteAddress) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               // Verify peer address using getpeername()
+                               var address2 = new SockaddrIn ();
+                               if (Syscall.getpeername (so2, address2) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (address2.sa_family, UnixAddressFamily.AF_INET);
+                               Assert.AreEqual (remoteAddress.sin_port, address2.sin_port);
+                               Assert.AreEqual (remoteAddress.sin_addr, address2.sin_addr);
+
+                               // Send and receive a few bytes
+                               long ret;
+                               var buffer1 = new byte[] { 42, 43, 44 };
+                               ret = Syscall.send (so2, buffer1, (ulong) buffer1.Length, 0);
+                               if (ret < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               var buffer2 = new byte[1024];
+                               ret = Syscall.recv (so1, buffer2, (ulong) buffer2.Length, 0);
+                               if (ret < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               Assert.AreEqual (buffer1.Length, ret);
+                               for (int i = 0; i < buffer1.Length; i++)
+                                       Assert.AreEqual (buffer1[i], buffer2[i]);
+                       });
+               }
+
+               [Test]
+               public void IPv6 ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               Assert.Ignore ("OS does not support IPv6.");
+
+                       var address = new SockaddrIn6 {
+                               sin6_family = UnixAddressFamily.AF_INET6,
+                               sin6_port = Syscall.htons (0),
+                               sin6_addr = NativeConvert.ToIn6Addr (IPAddress.IPv6Loopback),
+                       };
+                       WithSockets (UnixAddressFamily.AF_INET6, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => {
+                               if (Syscall.bind (so1, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               var address1Stor = new SockaddrStorage ();
+                               if (Syscall.getsockname (so1, address1Stor) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               var address1 = new SockaddrIn6 ();
+                               address1Stor.CopyTo (address1);
+
+                               // Check getsockname(socket, null)
+                               if (Syscall.getsockname (so1, null) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               var address2 = new SockaddrIn6 ();
+                               if (Syscall.getsockname (so1, address2) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               Assert.AreEqual (address1, address2);
+                               Assert.IsTrue (Syscall.ntohs (address1.sin6_port) != 0);
+                               address1.sin6_port = 0;
+                               Assert.AreEqual (address, address1);
+
+                               var address3 = new Sockaddr ();
+                               if (Syscall.getsockname (so1, address3) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (address.sa_family, address3.sa_family);
+
+                               // Try to store a sockaddr_in6 into a Sockaddr. Should fail because sockaddr_in6 should be larger than sockaddr_in
+                               var address4 = new SockaddrIn ();
+                               if (Syscall.getsockname (so1, address4) == 0)
+                                       Assert.Fail ("getsockname() should have failed");
+                               Assert.AreEqual (Errno.ENOBUFS, Stdlib.GetLastError ());
+                       });
+               }
+
+               [Test]
+               public void UnixAccept ()
+               {
+                       var address = new SockaddrUn (TempFolder + "/socket1");
+                       var address2 = SockaddrUn.FromSockaddrStorage (address.ToSockaddrStorage ());
+                       Assert.AreEqual (address, address2);
+
+                       WithSockets (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => {
+                               if (Syscall.bind (so1, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               if (Syscall.listen (so1, 5) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               if (Syscall.connect (so2, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               var address3 = new SockaddrUn ();
+                               if (Syscall.getsockname (so1, address3) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (address, address3);
+
+                               var address4 = new SockaddrStorage ();
+                               if (Syscall.getsockname (so1, address4) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (UnixAddressFamily.AF_UNIX, address4.sa_family);
+                               Assert.AreEqual (address3, SockaddrUn.FromSockaddrStorage (address4));
+
+                               var address5 = new SockaddrUn ();
+                               if (Syscall.getsockname (so1, address5) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (UnixAddressFamily.AF_UNIX, address5.sa_family);
+
+                               // Check getsockname(socket, null)
+                               if (Syscall.getsockname (so1, null) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               int so3;
+                               var remote = new SockaddrUn ();
+                               if ((so3 = Syscall.accept (so1, remote)) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               try {
+                                       // Send and receive a few bytes
+                                       long ret;
+                                       var buffer1 = new byte[] { 42, 43, 44 };
+                                       ret = Syscall.send (so2, buffer1, (ulong) buffer1.Length, 0);
+                                       if (ret < 0)
+                                               UnixMarshal.ThrowExceptionForLastError ();
+
+                                       var buffer2 = new byte[1024];
+                                       ret = Syscall.recv (so3, buffer2, (ulong) buffer2.Length, 0);
+                                       if (ret < 0)
+                                               UnixMarshal.ThrowExceptionForLastError ();
+
+                                       Assert.AreEqual (buffer1.Length, ret);
+                                       for (int i = 0; i < buffer1.Length; i++)
+                                               Assert.AreEqual (buffer1[i], buffer2[i]);
+                               } finally {
+                                       if (Syscall.close (so3) < 0)
+                                               UnixMarshal.ThrowExceptionForLastError ();
+                               }
+                       });
+               }
+
+               [Test]
+               [Category ("NotOnMac")]
+               public void Accept4 ()
+               {
+                       WithSockets (UnixAddressFamily.AF_UNIX, UnixSocketType.SOCK_STREAM, 0, (so1, so2) => {
+                               var address = new SockaddrUn (TempFolder + "/socket2");
+                               if (Syscall.bind (so1, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               if (Syscall.listen (so1, 5) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               if (Syscall.connect (so2, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               int so3;
+                               var remote = new SockaddrUn ();
+                               if ((so3 = Syscall.accept4 (so1, remote, UnixSocketFlags.SOCK_CLOEXEC | UnixSocketFlags.SOCK_NONBLOCK)) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               try {
+                                       int _flags;
+                                       if ((_flags = Syscall.fcntl (so3, FcntlCommand.F_GETFL)) < 0)
+                                               UnixMarshal.ThrowExceptionForLastError ();
+                                       var flags = NativeConvert.ToOpenFlags (_flags);
+                                       Assert.IsTrue ((flags & OpenFlags.O_NONBLOCK) != 0);
+
+                                       int _flagsFD;
+                                       if ((_flagsFD = Syscall.fcntl (so3, FcntlCommand.F_GETFD)) < 0)
+                                               UnixMarshal.ThrowExceptionForLastError ();
+                                       // FD_CLOEXEC must be set
+                                       //var flagsFD = NativeConvert.ToFdFlags (_flagsFD);
+                                       //Assert.IsTrue ((flagsFD & FdFlags.FD_CLOEXEC) != 0);
+                                       Assert.IsTrue (_flagsFD != 0);
+                               } finally {
+                                       if (Syscall.close (so3) < 0)
+                                               UnixMarshal.ThrowExceptionForLastError ();
+                               }
+                       });
+               }
+
+               [Test]
+               public void SendToRecvFrom ()
+               {
+                       WithSockets (UnixAddressFamily.AF_INET, UnixSocketType.SOCK_DGRAM, UnixSocketProtocol.IPPROTO_UDP, (so1, so2) => {
+                               // Bind UDP socket so1 to 127.0.0.1 with dynamic port
+                               var address = new SockaddrIn { sin_family = UnixAddressFamily.AF_INET, sin_port = Syscall.htons (0), sin_addr = new InAddr (127, 0, 0, 1) };
+                               if (Syscall.bind (so1, address) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               // Get actual port number using getsockname()
+                               var actualAddress = new SockaddrIn ();
+                               if (Syscall.getsockname (so1, actualAddress) < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (actualAddress.sa_family, UnixAddressFamily.AF_INET);
+                               var port = Syscall.ntohs (actualAddress.sin_port);
+                               Assert.IsTrue (port != 0);
+
+
+                               var remoteAddress = new SockaddrIn {
+                                       sin_family = UnixAddressFamily.AF_INET,
+                                       sin_port = Syscall.htons (port),
+                                       sin_addr = new InAddr (127, 0, 0, 1),
+                               };
+
+                               // Send and receive a few bytes
+                               long ret;
+                               var buffer1 = new byte[] { 42, 43, 44 };
+                               ret = Syscall.sendto (so2, buffer1, (ulong) buffer1.Length, 0, remoteAddress);
+                               if (ret < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+
+                               var senderAddress = new SockaddrIn ();
+                               var buffer2 = new byte[1024];
+                               ret = Syscall.recvfrom (so1, buffer2, (ulong) buffer2.Length, 0, senderAddress);
+                               if (ret < 0)
+                                       UnixMarshal.ThrowExceptionForLastError ();
+                               Assert.AreEqual (senderAddress.sa_family, UnixAddressFamily.AF_INET);
+                               Assert.AreEqual (senderAddress.sin_addr, new InAddr (127, 0, 0, 1));
+
+                               Assert.AreEqual (buffer1.Length, ret);
+                               for (int i = 0; i < buffer1.Length; i++)
+                                       Assert.AreEqual (buffer1[i], buffer2[i]);
+                       });
+               }
        }
 }
 
index d621ad51d4533a336398b6c87bb69069dc59d790..9abc27094c9d0fe4c8fb8610e8b767386a4e0e8e 100644 (file)
@@ -424,6 +424,10 @@ namespace MonoTests.Mono.Unix {
                        foreach (Thread t in threads)
                                t.Join ();
                        AssertCountSet (usignals);
+                       // signal delivery might take some time, wait a bit before closing
+                       // the UnixSignal so we can ignore it and not terminate the process
+                       // when a SIGHUP/SIGTERM arrives afterwards
+                       Thread.Sleep (1000);
                        CloseSignals (usignals);
                }
 
index 74b2a8e71c7a19a2367ab46498d2b91144978f51..3be685a46d240ac731cc9403d0c72761bc0b75ee 100644 (file)
@@ -62,7 +62,7 @@ namespace Mono.Security.Providers.DotNet
                        get { return false; }
                }
 
-               public override bool SupportsTlsContext {
+               internal override bool SupportsTlsContext {
                        get { return false; }
                }
 
@@ -88,7 +88,7 @@ namespace Mono.Security.Providers.DotNet
                        return new DotNetSslStreamImpl (innerStream, leaveInnerStreamOpen, this, validation_callback, selection_callback);
                }
 
-               public override IMonoTlsContext CreateTlsContext (
+               internal override IMonoTlsContext CreateTlsContext (
                        string hostname, bool serverMode, TlsProtocols protocolFlags,
                        X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
                        bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
index 80d1238c4b625723dfc42f14af952fb82fbd8f80..c8974658e27d8f153be3ac0e74f7dd56369b5de7 100644 (file)
@@ -30,3 +30,4 @@
 ../System/Mono.Net.Security/IMonoTlsProvider.cs
 ../System/Mono.Net.Security/MonoTlsProviderFactory.cs
 ../System/Mono.Net.Security/MonoTlsProviderWrapper.cs
+
index b3178b82c3ad029aae19f7cf81d16f0bb2d804fb..23ba5bb253714f3a38ba9edf282d5147a5c9ba3a 100644 (file)
@@ -45,3 +45,4 @@ using System.Runtime.InteropServices;
 [assembly: NeutralResourcesLanguage ("en-US")]
 
 [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
+[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Makefile b/mcs/class/Mono.Security.Providers.NewTls/Makefile
new file mode 100644 (file)
index 0000000..a5f6412
--- /dev/null
@@ -0,0 +1,12 @@
+thisdir = class/Mono.Security.Providers.NewTls
+SUBDIRS = 
+include ../../build/rules.make
+
+LIBRARY = Mono.Security.Providers.NewTls.dll
+LIB_MCS_FLAGS = -unsafe -nowarn:1030 -keyfile:../mono.pub -delaysign -r:System.dll \
+       -r:NewSystemSource=Mono.Security.Providers.NewSystemSource.dll -r:Mono.Security.dll
+
+include ../../build/library.make
+
+$(the_lib): ../Mono.Security/Makefile
+
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls.dll.sources b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls.dll.sources
new file mode 100644 (file)
index 0000000..12d8a20
--- /dev/null
@@ -0,0 +1,13 @@
+./Properties/AssemblyInfo.cs
+../../build/common/SR.cs
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+
+./Mono.Security.Providers.NewTls/ITlsConfiguration.cs
+./Mono.Security.Providers.NewTls/ITlsContext.cs
+
+./Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
+./Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
+./Mono.Security.Providers.NewTls/NewTlsProvider.cs
+./Mono.Security.Providers.NewTls/TlsContextWrapper.cs
+./Mono.Security.Providers.NewTls/TlsProviderFactory.cs
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsConfiguration.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsConfiguration.cs
new file mode 100644 (file)
index 0000000..401afd7
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// ITlsContext.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015-2016 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Interface;
+using MX = Mono.Security.X509;
+
+namespace Mono.Security.Providers.NewTls
+{
+       interface ITlsConfiguration
+       {
+               bool HasCredentials {
+                       get;
+               }
+
+               void SetCertificate (MX.X509Certificate certificate, AsymmetricAlgorithm privateKey);
+
+               bool? AskForClientCertificate {
+                       get; set;
+               }
+       }
+}
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsContext.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/ITlsContext.cs
new file mode 100644 (file)
index 0000000..0d69805
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// ITlsContext.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015-2016 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+extern alias NewSystemSource;
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Interface;
+using MX = Mono.Security.X509;
+
+namespace Mono.Security.Providers.NewTls
+{
+       interface ITlsContext : IDisposable
+       {
+               bool IsValid {
+                       get;
+               }
+
+               TlsException LastError {
+                       get;
+               }
+
+               bool ReceivedCloseNotify {
+                       get;
+               }
+
+               MonoTlsConnectionInfo ConnectionInfo {
+                       get;
+               }
+
+               MX.X509Certificate GetRemoteCertificate (out MX.X509CertificateCollection remoteCertificateStore);
+
+               bool VerifyRemoteCertificate ();
+
+               int GenerateNextToken (TlsBuffer incoming, TlsMultiBuffer outgoing);
+
+               int DecryptMessage (ref TlsBuffer incoming);
+
+               int EncryptMessage (ref TlsBuffer incoming);
+
+               byte[] CreateAlert (Alert alert);
+
+               byte[] CreateHelloRequest ();
+       }
+}
+
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStream.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
new file mode 100644 (file)
index 0000000..6117f0f
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// MonoNewTlsStream.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+extern alias NewSystemSource;
+
+using EncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
+using LocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
+using RemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
+using SslStream = NewSystemSource::System.Net.Security.SslStream;
+
+using System;
+using System.IO;
+using System.Threading.Tasks;
+
+using MSI = Mono.Security.Interface;
+
+using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Providers.NewTls
+{
+       public class MonoNewTlsStream : SslStream, MSI.IMonoSslStream
+       {
+               MSI.MonoTlsProvider provider;
+
+               internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
+                       : this (innerStream, false, provider, settings)
+               {
+               }
+
+               internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
+                       : base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
+               {
+                       this.provider = provider;
+               }
+
+               public MSI.MonoTlsProvider Provider {
+                       get { return provider; }
+               }
+
+               new public bool IsClosed {
+                       get { return base.IsClosed; }
+               }
+
+               public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
+               {
+                       return GetMonoConnectionInfo ();
+               }
+
+               public Task Shutdown ()
+               {
+                       return Task.Factory.FromAsync ((state, result) => BeginShutdown (state, result), EndShutdown, null);
+               }
+
+               public Task RequestRenegotiation ()
+               {
+                       return Task.Factory.FromAsync ((state, result) => BeginRenegotiate (state, result), EndRenegotiate, null);
+               }
+
+                X509Certificate MSI.IMonoSslStream.InternalLocalCertificate {
+                       get { return InternalLocalCertificate; }
+               }
+
+               XAuthenticatedStream MSI.IMonoSslStream.AuthenticatedStream {
+                       get { return this; }
+               }
+       }
+}
+
+
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
new file mode 100644 (file)
index 0000000..d39f1bb
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// MonoNewTlsStreamFactory.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+extern alias NewSystemSource;
+
+using XEncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
+using XSslPolicyErrors = NewSystemSource::System.Net.Security.SslPolicyErrors;
+using XLocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
+using XRemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
+
+using System;
+using System.IO;
+using System.Net.Security;
+using System.Security.Authentication;
+
+using Mono.Security.Interface;
+
+using PSSCX = System.Security.Cryptography.X509Certificates;
+using SSCX = System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Providers.NewTls
+{
+       public static class MonoNewTlsStreamFactory
+       {
+               internal static IMonoSslStream CreateSslStream (
+                       Stream innerStream, bool leaveInnerStreamOpen,
+                       MonoTlsProvider provider, MonoTlsSettings settings = null)
+               {
+                       return new MonoNewTlsStream (innerStream, leaveInnerStreamOpen, provider, settings);
+               }
+
+               public static MonoNewTlsStream CreateServer (
+                       Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
+                       SSCX.X509Certificate serverCertificate, bool clientCertificateRequired,
+                       SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+               {
+                       var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
+
+                       try {
+                               stream.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
+                       } catch (Exception ex) {
+                               var tlsEx = stream.LastError;
+                               if (tlsEx != null)
+                                       throw new AggregateException (ex, tlsEx);
+                               throw;
+                       }
+
+                       return stream;
+               }
+
+               public static MonoNewTlsStream CreateClient (
+                       Stream innerStream, bool leaveOpen, MonoTlsProvider provider, MonoTlsSettings settings,
+                       string targetHost, PSSCX.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
+               {
+                       var stream = new MonoNewTlsStream (innerStream, leaveOpen, provider, settings);
+
+                       try {
+                               stream.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
+                       } catch (Exception ex) {
+                               var tlsEx = stream.LastError;
+                               if (tlsEx != null)
+                                       throw new AggregateException (ex, tlsEx);
+                               throw;
+                       }
+                       return stream;
+               }
+       }
+}
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/NewTlsProvider.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/NewTlsProvider.cs
new file mode 100644 (file)
index 0000000..e2b347f
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// NewTlsProvider.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+extern alias NewSystemSource;
+
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.Security.Authentication;
+
+using MSI = Mono.Security.Interface;
+using MX = Mono.Security.X509;
+
+using PSSCX = System.Security.Cryptography.X509Certificates;
+using SSCX = System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Providers.NewTls
+{
+       public class NewTlsProvider : MSI.MonoTlsProvider
+       {
+               static readonly Guid id = new Guid ("e5ff34f1-8b7a-4aa6-aff9-24719d709693");
+
+               public override Guid ID {
+                       get { return id; }
+               }
+
+               public override string Name {
+                       get { return "newtls"; }
+               }
+
+               public override bool SupportsSslStream {
+                       get { return true; }
+               }
+
+               public override bool SupportsConnectionInfo {
+                       get { return true; }
+               }
+
+               public override bool SupportsMonoExtensions {
+                       get { return true; }
+               }
+
+               internal override bool SupportsTlsContext {
+                       get { return true; }
+               }
+
+               public override SslProtocols SupportedProtocols {
+                       get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
+               }
+
+               public override MSI.IMonoSslStream CreateSslStream (
+                       Stream innerStream, bool leaveInnerStreamOpen,
+                       MSI.MonoTlsSettings settings = null)
+               {
+                       return MonoNewTlsStreamFactory.CreateSslStream (innerStream, leaveInnerStreamOpen, this, settings);
+               }
+
+               internal override MSI.IMonoTlsContext CreateTlsContext (
+                       string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
+                       SSCX.X509Certificate serverCertificate, PSSCX.X509CertificateCollection clientCertificates,
+                       bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
+                       MSI.MonoTlsSettings settings)
+               {
+                       var config = TlsProviderFactory.CreateTlsConfiguration (
+                               hostname, serverMode, protocolFlags, serverCertificate,
+                               remoteCertRequired, settings);
+                       return new TlsContextWrapper (config, serverMode);
+               }
+       }
+}
+
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsContextWrapper.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsContextWrapper.cs
new file mode 100644 (file)
index 0000000..389dd1a
--- /dev/null
@@ -0,0 +1,221 @@
+//
+// TlsContextWrapper.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+extern alias NewSystemSource;
+
+using System;
+using System.Security.Cryptography;
+
+using SSCX = System.Security.Cryptography.X509Certificates;
+using PSSCX = System.Security.Cryptography.X509Certificates;
+
+using MSI = Mono.Security.Interface;
+using MX = Mono.Security.X509;
+
+namespace Mono.Security.Providers.NewTls
+{
+       class TlsContextWrapper : IDisposable, MSI.IMonoTlsContext
+       {
+               ITlsConfiguration config;
+               ITlsContext context;
+               bool serverMode;
+
+               public TlsContextWrapper (ITlsConfiguration config, bool serverMode)
+               {
+                       this.config = config;
+                       this.serverMode = serverMode;
+               }
+
+               public bool IsServer {
+                       get { return serverMode; }
+               }
+
+               public bool IsValid {
+                       get { return context != null && context.IsValid; }
+               }
+
+               public void Initialize (MSI.IMonoTlsEventSink eventSink)
+               {
+                       if (context != null)
+                               throw new InvalidOperationException ();
+                       context = TlsProviderFactory.CreateTlsContext (config, serverMode, eventSink);
+               }
+
+               void Clear ()
+               {
+                       if (context != null) {
+                               context.Dispose ();
+                               context = null;
+                       }
+               }
+
+               public ITlsConfiguration Configuration {
+                       get {
+                               if (config == null)
+                                       throw new ObjectDisposedException ("TlsConfiguration");
+                               return config;
+                       }
+               }
+
+               public ITlsContext Context {
+                       get {
+                               if (!IsValid)
+                                       throw new ObjectDisposedException ("TlsContext");
+                               return context;
+                       }
+               }
+
+               public bool HasCredentials {
+                       get { return Configuration.HasCredentials; }
+               }
+
+               public void SetCertificate (SSCX.X509Certificate certificate, AsymmetricAlgorithm privateKey)
+               {
+                       var monoCert = new MX.X509Certificate (certificate.GetRawCertData ());
+                       Configuration.SetCertificate (monoCert, privateKey);
+               }
+
+               public int GenerateNextToken (MSI.IBufferOffsetSize incoming, out MSI.IBufferOffsetSize outgoing)
+               {
+                       var input = incoming != null ? new MSI.TlsBuffer (BOSWrapper.Wrap (incoming)) : null;
+                       var output = new MSI.TlsMultiBuffer ();
+                       var retval = Context.GenerateNextToken (input, output);
+                       if (output.IsEmpty)
+                               outgoing = null;
+                       outgoing = BOSWrapper.Wrap (output.StealBuffer ());
+                       return (int)retval;
+               }
+
+               public int EncryptMessage (ref MSI.IBufferOffsetSize incoming)
+               {
+                       var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
+                       var retval = Context.EncryptMessage (ref buffer);
+                       incoming = BOSWrapper.Wrap (buffer.GetRemaining ());
+                       return (int)retval;
+               }
+
+               public int DecryptMessage (ref MSI.IBufferOffsetSize incoming)
+               {
+                       var buffer = new MSI.TlsBuffer (BOSWrapper.Wrap (incoming));
+                       var retval = Context.DecryptMessage (ref buffer);
+                       incoming = buffer != null ? BOSWrapper.Wrap (buffer.GetRemaining ()) : null;
+                       return (int)retval;
+               }
+
+               class BOSWrapper : MSI.IBufferOffsetSize
+               {
+                       public byte[] Buffer {
+                               get;
+                               private set;
+                       }
+
+                       public int Offset {
+                               get;
+                               private set;
+                       }
+
+                       public int Size {
+                               get;
+                               private set;
+                       }
+
+                       BOSWrapper (byte[] buffer, int offset, int size)
+                       {
+                               Buffer = buffer;
+                               Offset = offset;
+                               Size = size;
+                       }
+
+                       public static BOSWrapper Wrap (MSI.IBufferOffsetSize bos)
+                       {
+                               return bos != null ? new BOSWrapper (bos.Buffer, bos.Offset, bos.Size) : null;
+                       }
+               }
+
+               public byte[] CreateCloseNotify ()
+               {
+                       return Context.CreateAlert (new MSI.Alert (MSI.AlertLevel.Warning, MSI.AlertDescription.CloseNotify));
+               }
+
+               public byte[] CreateHelloRequest ()
+               {
+                       return Context.CreateHelloRequest ();
+               }
+
+               public SSCX.X509Certificate GetRemoteCertificate (out PSSCX.X509CertificateCollection remoteCertificateStore)
+               {
+                       MX.X509CertificateCollection monoCollection;
+                       var remoteCert = Context.GetRemoteCertificate (out monoCollection);
+                       if (remoteCert == null) {
+                               remoteCertificateStore = null;
+                               return null;
+                       }
+
+                       remoteCertificateStore = new PSSCX.X509CertificateCollection ();
+                       foreach (var cert in monoCollection) {
+                               remoteCertificateStore.Add (new PSSCX.X509Certificate2 (cert.RawData));
+                       }
+                       return new PSSCX.X509Certificate2 (remoteCert.RawData);
+
+               }
+
+               public bool VerifyRemoteCertificate ()
+               {
+                       return Context.VerifyRemoteCertificate ();
+               }
+
+               public Exception LastError {
+                       get {
+                               if (context != null)
+                                       return context.LastError;
+                               return null;
+                       }
+               }
+
+               public bool ReceivedCloseNotify {
+                       get {
+                               return Context.ReceivedCloseNotify;
+                       }
+               }
+
+               public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
+               {
+                       return Context.ConnectionInfo;
+               }
+
+               public void Dispose ()
+               {
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
+               }
+
+               void Dispose (bool disposing)
+               {
+                       Clear ();
+               }
+       }
+}
+
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsProviderFactory.cs b/mcs/class/Mono.Security.Providers.NewTls/Mono.Security.Providers.NewTls/TlsProviderFactory.cs
new file mode 100644 (file)
index 0000000..92d8ab0
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// TlsProviderFactory.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015-2016 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+extern alias NewSystemSource;
+
+using System;
+using System.IO;
+
+using System.Net;
+using System.Net.Security;
+using System.Security.Authentication;
+
+using MSI = Mono.Security.Interface;
+using MX = Mono.Security.X509;
+
+using PSSCX = System.Security.Cryptography.X509Certificates;
+using SSCX = System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Providers.NewTls
+{
+       static class TlsProviderFactory
+       {
+               const string assemblyName = "Mono.Security.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2";
+               const string tlsConfigTypeName = "Mono.Security.NewTls.TlsConfiguration";
+               const string tlsContextTypeName = "Mono.Security.NewTls.TlsContext";
+
+               static object CreateInstance (string typeName, object[] args)
+               {
+                       var type = Type.GetType (typeName + ", " + assemblyName);
+                       return Activator.CreateInstance (type, args);
+               }
+
+               internal static ITlsConfiguration CreateTlsConfiguration (
+                       string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
+                       SSCX.X509Certificate serverCertificate, bool remoteCertRequired,
+                       MSI.MonoTlsSettings settings)
+               {
+                       object[] args;
+                       ITlsConfiguration config;
+                       if (serverMode) {
+                               var cert = (PSSCX.X509Certificate2)serverCertificate;
+                               var monoCert = new MX.X509Certificate (cert.RawData);
+                               args = new object[] {
+                                       (MSI.TlsProtocols)protocolFlags,
+                                       (MSI.MonoTlsSettings)settings,
+                                       monoCert,
+                                       cert.PrivateKey
+                               };
+                       } else {
+                               args = new object[] {
+                                       (MSI.TlsProtocols)protocolFlags,
+                                       (MSI.MonoTlsSettings)settings,
+                                       hostname
+                               };
+                       }
+
+                       config = (ITlsConfiguration)CreateInstance (tlsConfigTypeName, args);
+
+                       if (serverMode && remoteCertRequired)
+                               config.AskForClientCertificate = true;
+
+                       return config;
+               }
+
+               internal static ITlsContext CreateTlsContext (
+                       ITlsConfiguration config, bool serverMode,
+                       MSI.IMonoTlsEventSink eventSink)
+               {
+                       return (ITlsContext)CreateInstance (
+                               tlsContextTypeName,
+                               new object[] { config, serverMode, eventSink });
+               }
+       }
+}
diff --git a/mcs/class/Mono.Security.Providers.NewTls/Properties/AssemblyInfo.cs b/mcs/class/Mono.Security.Providers.NewTls/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..e369093
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2015 Xamarin, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the system assembly
+
+[assembly: AssemblyVersion (Consts.FxVersion)]
+
+[assembly: AssemblyCompany ("Xamarin")]
+[assembly: AssemblyCopyright ("(c) 2015 Xamarin")]
+[assembly: AssemblyDescription ("Mono.Security.Providers.NewTls.dll")]
+[assembly: AssemblyProduct ("MONO CLI")]
+[assembly: AssemblyTitle ("Mono.Security.Providers.NewTls.dll")]
+[assembly: CLSCompliant (false)]
+[assembly: ComVisible (false)]
+[assembly: NeutralResourcesLanguage ("en-US")]
+
+[assembly: InternalsVisibleTo ("Mono.Security.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400001100000003336d6aed41624ca156ab579881fe90a576f1dfec48378fc94e4e440f4556776224e2d70c18996d91f36227f539fdb44340e07651f1455a489b29a7e6219a8f85e52b0f8588b4f8a857746a8468d37b556223d1452f3fcbaf0f269cdf1900ceb68f69485dc5887750d19571030c732331e00387d9b813a9ad52891087301793")]
diff --git a/mcs/class/Mono.Security.Providers.NewTls/mobile_Mono.Security.Providers.NewTls.dll.sources b/mcs/class/Mono.Security.Providers.NewTls/mobile_Mono.Security.Providers.NewTls.dll.sources
new file mode 100644 (file)
index 0000000..7218dab
--- /dev/null
@@ -0,0 +1,7 @@
+Properties/AssemblyInfo.cs
+
+Mono.Security.Providers.NewTls/ITlsConfiguration.cs
+Mono.Security.Providers.NewTls/ITlsContext.cs
+
+Mono.Security.Providers.NewTls/MonoNewTlsStream.cs
+Mono.Security.Providers.NewTls/MonoNewTlsStreamFactory.cs
diff --git a/mcs/class/Mono.Security.Providers.NewTls/mobile_static_Mono.Security.Providers.NewTls.dll.sources b/mcs/class/Mono.Security.Providers.NewTls/mobile_static_Mono.Security.Providers.NewTls.dll.sources
new file mode 100644 (file)
index 0000000..baded51
--- /dev/null
@@ -0,0 +1 @@
+#include mobile_Mono.Security.Providers.NewTls.dll.sources
index 82bd9d5437bd23023a90c219665526fe28e396c5..4532a17e02fb2e8c9031c89fc407ef0bf51f54ee 100644 (file)
@@ -58,7 +58,7 @@ namespace Mono.Security.Providers.OldTls
                        get { return false; }
                }
 
-               public override bool SupportsTlsContext {
+               internal override bool SupportsTlsContext {
                        get { return false; }
                }
 
@@ -74,7 +74,7 @@ namespace Mono.Security.Providers.OldTls
                        return new MNS.Private.MonoSslStreamImpl (impl);
                }
 
-               public override IMonoTlsContext CreateTlsContext (
+               internal override IMonoTlsContext CreateTlsContext (
                        string hostname, bool serverMode, TlsProtocols protocolFlags,
                        X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
                        bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
index 85244bc1e4fb8b2255b9025e442ec8236a9ceae2..55e17aad73d7012b058a7295e29c9a4e050974f4 100644 (file)
@@ -60,6 +60,13 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyDelaySign (true)]
 [assembly: AssemblyKeyFile ("../mono.pub")]
 
-#if MOBILE
+#if NET_2_1
 [assembly: InternalsVisibleTo ("System, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
+#else
+[assembly: InternalsVisibleTo ("System, PublicKey=00000000000000000400000000000000")]
 #endif
+
+[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+[assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/BufferOffsetSize.cs b/mcs/class/Mono.Security/Mono.Security.Interface/BufferOffsetSize.cs
new file mode 100644 (file)
index 0000000..7138962
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// BufferOffsetSize.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace Mono.Security.Interface
+{
+       public class BufferOffsetSize : SecretParameters, IBufferOffsetSize
+       {
+               public byte[] Buffer {
+                       get;
+                       private set;
+               }
+
+               public int Offset {
+                       get;
+                       internal set;
+               }
+
+               public int Size {
+                       get { return EndOffset - Offset; }
+               }
+
+               public int EndOffset {
+                       get;
+                       internal set;
+               }
+
+               public BufferOffsetSize (byte[] buffer, int offset, int size)
+               {
+                       Buffer = buffer;
+                       Offset = offset;
+                       EndOffset = offset + size;
+               }
+
+               public BufferOffsetSize (byte[] buffer)
+                       : this (buffer, 0, buffer.Length)
+               {
+               }
+
+               public BufferOffsetSize (int size)
+                       : this (new byte [size])
+               {
+               }
+
+               public byte[] GetBuffer ()
+               {
+                       var copy = new byte [Size];
+                       Array.Copy (Buffer, Offset, copy, 0, Size);
+                       return copy;
+               }
+
+               public void TruncateTo (int newSize)
+               {
+                       if (newSize > Size)
+                               throw new ArgumentException ("newSize");
+                       EndOffset = Offset + newSize;
+               }
+
+               protected void SetBuffer (byte[] buffer, int offset, int size)
+               {
+                       Buffer = buffer;
+                       Offset = offset;
+                       EndOffset = offset + size;
+               }
+
+               protected override void Clear ()
+               {
+                       Buffer = null;
+                       Offset = EndOffset = 0;
+               }
+       }
+}
+
index 508bdc4fe61532fa6bee06ad7b1dcf2fa2de34a8..d1ac4e27d0eda996688dada49ede134f9e2245f3 100644 (file)
@@ -29,7 +29,7 @@ using System.Security.Cryptography.X509Certificates;
 
 namespace Mono.Security.Interface
 {
-       public interface IMonoTlsContext : IDisposable
+       interface IMonoTlsContext : IDisposable
        {
                bool IsServer {
                        get;
index 740d79536481597c38bebe58cea2470c5fd8fdbe..753cd97e5a23952166c2f74f6effd7524a407c6d 100644 (file)
@@ -72,6 +72,10 @@ namespace Mono.Security.Interface
 
        public abstract class MonoTlsProvider
        {
+               internal MonoTlsProvider ()
+               {
+               }
+
                public abstract Guid ID {
                        get;
                }
@@ -155,11 +159,11 @@ namespace Mono.Security.Interface
                 * The managed SSPI implementation from the new TLS code.
                 */
 
-               public abstract bool SupportsTlsContext {
+               internal abstract bool SupportsTlsContext {
                        get;
                }
 
-               public abstract IMonoTlsContext CreateTlsContext (
+               internal abstract IMonoTlsContext CreateTlsContext (
                        string hostname, bool serverMode, TlsProtocols protocolFlags,
                        X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
                        bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy,
index 9548da030fe1d3029c71ec35f0811337896d15e5..770680cbb8cab51b7ffb47504fa2ef4beeaafa6b 100644 (file)
@@ -72,14 +72,14 @@ namespace Mono.Security.Interface
                }
 
                /*
-                * Installs a custom TLS Provider.
+                * Selects the default TLS Provider.
                 *
                 * May only be called at application startup and will throw
                 * @InvalidOperationException if a provider has already been installed.
                 */
-               public static void InstallProvider (MonoTlsProvider provider)
+               public static void SetDefaultProvider (string name)
                {
-                       NoReflectionHelper.InstallProvider (provider);
+                       NoReflectionHelper.SetDefaultProvider (name);
                }
 
                /*
index 7e42720d17c7fee392c9f32139c61338738002e4..ee8f36188165790321b02539f9387de383e64634 100644 (file)
@@ -82,6 +82,10 @@ namespace Mono.Security.Interface
                        get; set;
                }
 
+               public CipherSuiteCode[] EnabledCiphers {
+                       get; set;
+               }
+
                bool cloned = false;
                bool checkCertName = true;
                bool checkCertRevocationStatus = false;
@@ -155,6 +159,7 @@ namespace Mono.Security.Interface
                        callbackNeedsChain = other.callbackNeedsChain;
                        UserSettings = other.UserSettings;
                        EnabledProtocols = other.EnabledProtocols;
+                       EnabledCiphers = other.EnabledCiphers;
                        TrustAnchors = other.TrustAnchors;
                        cloned = true;
                }
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/SecretParameters.cs b/mcs/class/Mono.Security/Mono.Security.Interface/SecretParameters.cs
new file mode 100644 (file)
index 0000000..a225ba6
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// SecretParameters.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace Mono.Security.Interface
+{
+       public abstract class SecretParameters : IDisposable
+       {
+               protected abstract void Clear ();
+
+               bool disposed;
+
+               protected void CheckDisposed ()
+               {
+                       if (disposed)
+                               throw new ObjectDisposedException (GetType ().Name);
+               }
+
+               protected static void Clear (byte[] array)
+               {
+                       Array.Clear (array, 0, array.Length);
+               }
+
+               public void Dispose ()
+               {
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
+               }
+
+               void Dispose (bool disposing)
+               {
+                       if (!disposed) {
+                               disposed = true;
+                               Clear ();
+                       }
+               }
+
+               ~SecretParameters ()
+               {
+                       Dispose (false);
+               }
+       }
+}
+
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/SecureBuffer.cs b/mcs/class/Mono.Security/Mono.Security.Interface/SecureBuffer.cs
new file mode 100644 (file)
index 0000000..fc05f7a
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// SecureBuffer.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace Mono.Security.Interface
+{
+       public class SecureBuffer : SecretParameters, IBufferOffsetSize
+       {
+               byte[] buffer;
+
+               public byte[] Buffer {
+                       get {
+                               CheckDisposed ();
+                               return buffer;
+                       }
+               }
+
+               public int Size {
+                       get {
+                               CheckDisposed ();
+                               return buffer != null ? buffer.Length : 0;
+                       }
+               }
+
+               int IBufferOffsetSize.Offset {
+                       get { return 0; }
+               }
+
+               public SecureBuffer (int size)
+               {
+                       buffer = new byte [size];
+               }
+
+               public SecureBuffer (byte[] buffer)
+               {
+                       this.buffer = buffer;
+               }
+
+               public byte[] StealBuffer ()
+               {
+                       CheckDisposed ();
+                       var retval = this.buffer;
+                       this.buffer = null;
+                       return retval;
+               }
+
+               public static SecureBuffer CreateCopy (byte[] buffer)
+               {
+                       var copy = new byte [buffer.Length];
+                       Array.Copy (buffer, copy, buffer.Length);
+                       return new SecureBuffer (copy);
+               }
+
+               protected override void Clear ()
+               {
+                       if (buffer != null) {
+                               Array.Clear (buffer, 0, buffer.Length);
+                               buffer = null;
+                       }
+               }
+       }
+}
+
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/TlsBuffer.cs b/mcs/class/Mono.Security/Mono.Security.Interface/TlsBuffer.cs
new file mode 100644 (file)
index 0000000..be3c007
--- /dev/null
@@ -0,0 +1,334 @@
+//
+// TlsBuffer.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace Mono.Security.Interface
+{
+       public class TlsBuffer : SecretParameters
+       {
+               public int Position {
+                       get; set;
+               }
+
+               public int Remaining {
+                       get { return Size - (Position - Offset); }
+               }
+
+               public byte[] Buffer {
+                       get { return innerBuffer.Buffer; }
+               }
+
+               public int Offset {
+                       get { return innerBuffer.Offset; }
+               }
+
+               public int Size {
+                       get { return innerBuffer.Size; }
+               }
+
+               public int EndOffset {
+                       get { return Offset + Size; }
+               }
+
+               IBufferOffsetSize innerBuffer;
+
+               protected TlsBuffer ()
+                       : this (null, 0, 0)
+               {
+               }
+
+               public TlsBuffer (IBufferOffsetSize bos)
+               {
+                       innerBuffer = bos;
+                       Position = bos.Offset;
+               }
+
+               public TlsBuffer (byte[] buffer, int offset, int size)
+                       : this (new BufferOffsetSize (buffer, offset, size))
+               {
+               }
+
+               public TlsBuffer (byte[] buffer)
+                       : this (buffer, 0, buffer.Length)
+               {
+               }
+
+               public TlsBuffer (int size)
+                       : this (new byte [size], 0, size)
+               {
+               }
+
+               public byte ReadByte ()
+               {
+                       if (Position >= EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+                       return Buffer [Position++];
+               }
+
+               public short ReadInt16 ()
+               {
+                       if (Position + 1 >= EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+                       var retval = (short)(Buffer [Position] << 8 | Buffer [Position + 1]);
+                       Position += 2;
+                       return retval;
+               }
+
+               public int ReadInt24 ()
+               {
+                       if (Position + 2 >= EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+                       var retval = ((Buffer [Position] << 16) | (Buffer [Position+1] << 8) | Buffer [Position+2]);
+                       Position += 3;
+                       return retval;
+               }
+
+               public int ReadInt32 ()
+               {
+                       if (Position + 3 >= EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+                       var retval = ((Buffer [Position] << 24) | (Buffer [Position+1] << 16) | (Buffer [Position+2] << 8) | Buffer [Position+3]);
+                       Position += 4;
+                       return retval;
+               }
+
+               public TlsBuffer ReadBuffer (int length)
+               {
+                       if (Position + length > EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+                       var retval = new TlsBuffer (Buffer, Position, length);
+                       Position += length;
+                       return retval;
+               }
+
+               public IBufferOffsetSize GetRemaining ()
+               {
+                       return new BufferOffsetSize (Buffer, Position, Remaining);
+               }
+
+               protected virtual void MakeRoomInternal (int size)
+               {
+                       if (Position + size > EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+               }
+
+               public void Write (byte value)
+               {
+                       MakeRoomInternal (1);
+                       Buffer [Position++] = value;
+               }
+
+               public void Write (short value)
+               {
+                       MakeRoomInternal (2);
+                       WriteInt16 (Buffer, Position, value);
+                       Position += 2;
+               }
+
+               public static void WriteInt16 (byte[] buffer, int offset, short value)
+               {
+                       buffer[offset] = ((byte)(value >> 8));
+                       buffer[offset+1] = ((byte)value);
+               }
+
+               public void Write (int value)
+               {
+                       MakeRoomInternal (4);
+                       WriteInt32 (Buffer, Position, value);
+                       Position += 4;
+               }
+
+               public void WriteInt24 (int value)
+               {
+                       MakeRoomInternal (3);
+                       WriteInt24 (Buffer, Position, value);
+                       Position += 3;
+               }
+
+               #pragma warning disable 3001
+               public void Write (ulong value)
+               #pragma warning restore 3001
+               {
+                       MakeRoomInternal (8);
+                       WriteInt64 (Buffer, Position, value);
+                       Position += 8;
+               }
+
+               public static void WriteInt24 (byte[] buffer, int offset, int value)
+               {
+                       buffer[offset] = ((byte)(value >> 16));
+                       buffer[offset+1] = ((byte)(value >> 8));
+                       buffer[offset+2] = ((byte)value);
+               }
+
+               public static void WriteInt32 (byte[] buffer, int offset, int value)
+               {
+                       buffer[offset] = ((byte)(value >> 24));
+                       buffer[offset+1] = ((byte)(value >> 16));
+                       buffer[offset+2] = ((byte)(value >> 8));
+                       buffer[offset+3] = ((byte)value);
+               }
+
+               #pragma warning disable 3001
+               public static void WriteInt64 (byte[] buffer, int offset, ulong value)
+               #pragma warning restore 3001
+               {
+                       buffer[offset] = (byte) (value >> 56);
+                       buffer[offset+1] = (byte) (value >> 48);
+                       buffer[offset+2] = (byte) (value >> 40);
+                       buffer[offset+3] = (byte) (value >> 32);
+                       buffer[offset+4] = (byte) (value >> 24);
+                       buffer[offset+5] = (byte) (value >> 16);
+                       buffer[offset+6] = (byte) (value >> 8);
+                       buffer[offset+7] = (byte) value;
+               }
+
+               public void Write (byte[] buffer)
+               {
+                       Write (buffer, 0, buffer.Length);
+               }
+
+               public void Write (byte[] buffer, int offset, int size)
+               {
+                       MakeRoomInternal (size);
+                       Array.Copy (buffer, offset, Buffer, Position, size);
+                       Position += size;
+               }
+
+               public void Write (IBufferOffsetSize buffer)
+               {
+                       Write (buffer.Buffer, buffer.Offset, buffer.Size);
+               }
+
+               public SecureBuffer ReadSecureBuffer (int count)
+               {
+                       return new SecureBuffer (ReadBytes (count));
+               }
+
+               public byte[] ReadBytes (int count)
+               {
+                       if (Position + count > EndOffset)
+                               throw new TlsException (AlertDescription.DecodeError, "Buffer overflow");
+                       var retval = new byte [count];
+                       Array.Copy (Buffer, Position, retval, 0, count);
+                       Position += count;
+                       return retval;
+               }
+
+               internal static bool Compare (SecureBuffer buffer1, SecureBuffer buffer2)
+               {
+                       if (buffer1 == null || buffer2 == null)
+                               return false;
+
+                       if (buffer1.Size != buffer2.Size)
+                               return false;
+
+                       for (int i = 0; i < buffer1.Size; i++) {
+                               if (buffer1.Buffer [i] != buffer2.Buffer [i])
+                                       return false;
+                       }
+                       return true;
+               }
+
+               public static bool Compare (IBufferOffsetSize buffer1, IBufferOffsetSize buffer2)
+               {
+                       if (buffer1 == null || buffer2 == null)
+                               return false;
+
+                       if (buffer1.Size != buffer2.Size)
+                               return false;
+
+                       for (int i = 0; i < buffer1.Size; i++) {
+                               if (buffer1.Buffer [buffer1.Offset + i] != buffer2.Buffer [buffer2.Offset + i])
+                                       return false;
+                       }
+                       return true;
+               }
+
+               public static bool Compare (byte[] buffer1, byte[] buffer2)
+               {
+                       if (buffer1 == null || buffer2 == null)
+                               return false;
+
+                       return Compare (buffer1, 0, buffer1.Length, buffer2, 0, buffer2.Length);
+               }
+
+               public static bool Compare (byte[] buffer1, int offset1, int size1, byte[] buffer2, int offset2, int size2)
+               {
+                       if (buffer1 == null || buffer2 == null)
+                               return false;
+
+                       if (size1 != size2)
+                               return false;
+
+                       for (int i = 0; i < size1; i++) {
+                               if (buffer1 [offset1 + i] != buffer2 [offset2 + i])
+                                       return false;
+                       }
+                       return true;
+
+               }
+
+               public static int ConstantTimeCompare (byte[] buffer1, int offset1, int size1, byte[] buffer2, int offset2, int size2)
+               {
+                       int status = 0;
+                       int effectiveSize;
+                       if (size1 < size2) {
+                               status--;
+                               effectiveSize = size1;
+                       } else if (size2 < size1) {
+                               status--;
+                               effectiveSize = size2;
+                       } else {
+                               effectiveSize = size1;
+                       }
+
+                       for (int i = 0; i < effectiveSize; i++) {
+                               if (buffer1 [offset1 + i] != buffer2 [offset2 + i])
+                                       status--;
+                       }
+
+                       return status;
+               }
+
+               protected void SetBuffer (byte[] buffer, int offset, int size)
+               {
+                       innerBuffer = new BufferOffsetSize (buffer, offset, size);
+               }
+
+               protected override void Clear ()
+               {
+                       var disposable = innerBuffer as IDisposable;
+                       if (disposable != null)
+                               disposable.Dispose ();
+                       innerBuffer = null;
+                       Position = 0;
+               }
+
+               public static readonly byte[] EmptyArray = new byte [0];
+       }
+}
+
diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/TlsMultiBuffer.cs b/mcs/class/Mono.Security/Mono.Security.Interface/TlsMultiBuffer.cs
new file mode 100644 (file)
index 0000000..de2975a
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// TlsMultiBuffer.cs
+//
+// Author:
+//       Martin Baulig <martin.baulig@xamarin.com>
+//
+// Copyright (c) 2014-2016 Xamarin Inc. (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace Mono.Security.Interface
+{
+       public class TlsMultiBuffer
+       {
+               MemoryChunk first, last;
+
+               private class MemoryChunk : BufferOffsetSize
+               {
+                       public MemoryChunk next;
+
+                       public MemoryChunk (byte[] buffer, int offset, int size)
+                               : base (buffer, offset, size)
+                       {
+                       }
+               }
+
+               public bool IsEmpty {
+                       get { return first == null; }
+               }
+
+               public bool IsSingle {
+                       get { return first != null && first.next == null; }
+               }
+
+               public void Add (TlsBuffer buffer)
+               {
+                       Add (buffer.Buffer, buffer.Offset, buffer.Size);
+               }
+
+               public void Add (byte[] buffer)
+               {
+                       Add (buffer, 0, buffer.Length);
+               }
+
+               public void Add (byte[] buffer, int offset, int size)
+               {
+                       var chunk = new MemoryChunk (buffer, offset, size);
+                       if (last == null)
+                               first = last = chunk;
+                       else {
+                               last.next = chunk;
+                               last = chunk;
+                       }
+               }
+
+               public BufferOffsetSize[] GetBufferArray ()
+               {
+                       int count = 0;
+                       for (var ptr = first; ptr != null; ptr = ptr.next)
+                               count++;
+                       var array = new BufferOffsetSize [count];
+                       count = 0;
+                       for (var ptr = first; ptr != null; ptr = ptr.next)
+                               array [count++] = ptr;
+                       return array;
+               }
+
+               public void Clear ()
+               {
+                       for (var ptr = first; ptr != null; ptr = ptr.next)
+                               ptr.Dispose ();
+                       first = last = null;
+               }
+
+               public BufferOffsetSize GetBuffer ()
+               {
+                       int totalSize = 0;
+                       for (var ptr = first; ptr != null; ptr = ptr.next)
+                               totalSize += ptr.Size;
+
+                       var outBuffer = new BufferOffsetSize (new byte [totalSize]);
+                       int offset = 0;
+                       for (var ptr = first; ptr != null; ptr = ptr.next) {
+                               Buffer.BlockCopy (ptr.Buffer, ptr.Offset, outBuffer.Buffer, offset, ptr.Size);
+                               offset += ptr.Size;
+                       }
+                       return outBuffer;
+               }
+
+               public BufferOffsetSize StealBuffer ()
+               {
+                       if (IsSingle) {
+                               var retval = first;
+                               first = last = null;
+                               return retval;
+                       }
+
+                       return GetBuffer ();
+               }
+       }
+}
+
index fc8ac2bb306ec90519e2c0e4da4afd84d6a90bd1..01e6ffd67a812f6178c8ac6b006abd8d333f14f7 100644 (file)
@@ -383,8 +383,13 @@ namespace Mono.Security.X509 {
 
                                byte[] authSafeData = authSafe.Content [0].Value;
                                byte[] calculatedMac = MAC (_password, macSalt.Value, _iterations, authSafeData);
-                               if (!Compare (macValue, calculatedMac))
-                                       throw new CryptographicException ("Invalid MAC - file may have been tampered!");
+                               if (!Compare (macValue, calculatedMac)) {
+                                       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!");
+                                       _password = nullPassword;
+                               }
                        }
 
                        // we now returns to our original presentation - PFX
index 7d6e4aaca19172150a6f2e8f4d3f3d4c8ed95aa7..7330f81b7be20dedc948fa3528216673d7a20af4 100644 (file)
 ./Mono.Security.Interface/TlsException.cs
 ./Mono.Security.Interface/TlsProtocolCode.cs
 ./Mono.Security.Interface/TlsProtocols.cs
+
+./Mono.Security.Interface/BufferOffsetSize.cs
+./Mono.Security.Interface/SecretParameters.cs
+./Mono.Security.Interface/SecureBuffer.cs
+./Mono.Security.Interface/TlsBuffer.cs
+./Mono.Security.Interface/TlsMultiBuffer.cs
\ No newline at end of file
index dba5c34020948fc64bac9fa1063dc72d127dbaa7..05cc4faad16b660c7fd75e70f302800576974fcb 100644 (file)
 ./Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs
 ./Mono.Xml/MiniParser.cs
 ./Mono.Xml/SecurityParser.cs
+
+./Mono.Security.Interface/BufferOffsetSize.cs
+./Mono.Security.Interface/SecretParameters.cs
+./Mono.Security.Interface/SecureBuffer.cs
+./Mono.Security.Interface/TlsBuffer.cs
+./Mono.Security.Interface/TlsMultiBuffer.cs
index 8c0149821b9a3be1b10a4fbc01577381dec0735f..6eefbf93b447f1e4ee4e1e1aa36df0bf1e8dccf3 100644 (file)
@@ -277,6 +277,10 @@ namespace MonoTests.System.Linq.Expressions
                [Test]
                public void NegateDecimal ()
                {
+                       // Make sure the negate method is not linked away
+                       decimal d1 = 1;
+                       decimal d2 = -d1;
+
                        var d = Expression.Parameter (typeof (decimal), "l");
 
                        var meth = typeof (decimal).GetMethod ("op_UnaryNegation", new [] { typeof (decimal) });
index 186f8e28e48e7bf98d7025f652882a53ecf8a6fd..4ead07ffd3361ca799fdc9f5b2562223b6c35b4d 100755 (executable)
@@ -2,6 +2,8 @@ Assembly/AssemblyInfo.cs
 ../../build/common/Consts.cs
 ../../build/common/Locale.cs
 System.Drawing/Bitmap.cs
+System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs
+System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
 System.Drawing/Brush.cs
 System.Drawing/Brushes.cs
 System.Drawing/BufferedGraphics.cs
diff --git a/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs b/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSameAssemblyAttribute.cs
new file mode 100644 (file)
index 0000000..759d126
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// System.Drawing.BitmapSuffixInSameAssemblyAttribute.cs
+//
+// Authors:
+//   Andrés G. Aragoneses (knocte@gmail.com)
+//
+// Copyright (C) 2016 Andrés G. Aragoneses
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+       [AttributeUsage (AttributeTargets.Assembly)]
+       public class BitmapSuffixInSameAssemblyAttribute : Attribute {
+
+               public BitmapSuffixInSameAssemblyAttribute ()
+                       : base ()
+               {
+               }
+
+               public virtual object TypeId {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs b/mcs/class/System.Drawing/System.Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
new file mode 100644 (file)
index 0000000..c66bd2c
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// System.Drawing.BitmapSuffixInSatelliteAssemblyAttribute.cs
+//
+// Authors:
+//   Andrés G. Aragoneses (knocte@gmail.com)
+//
+// Copyright (C) 2016 Andrés G. Aragoneses
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+
+namespace System.Drawing
+{
+       [AttributeUsage (AttributeTargets.Assembly)]
+       public class BitmapSuffixInSatelliteAssemblyAttribute : Attribute {
+
+               public BitmapSuffixInSatelliteAssemblyAttribute ()
+                       : base ()
+               {
+               }
+
+               public virtual object TypeId {
+                       get {
+                               throw new NotImplementedException ();
+                       }
+               }
+       }
+}
index a2a540c685a814c84d0061fc4e0c558100e94f98..1d055d9cdafa9deda9d411059535ccdbb94f7c27 100644 (file)
@@ -31,6 +31,6 @@ System.Web.Services.Description/WebReferenceOptionsTest.cs
 System.Web.Services.Description/WebServicesInteroperabilityTest.cs
 System.Web.Services.Protocols/LogicalMethodInfoTest.cs
 System.Web.Services.Protocols/SoapHttpClientProtocolTest.cs
-System.Web.Services.Protocols/SocketResponder.cs
 System.Web.Services.Protocols/WebClientProtocolTest.cs
 System.Web.Services.Protocols/SoapServerTypeTest.cs
+../../test-helpers/SocketResponder.cs
index 68673dbac40b9d0be29d680b9001bfaff54ffdbb..008730700360843fd4abcf313964439e7e2e2a2e 100755 (executable)
@@ -39,6 +39,8 @@ using System.Xml.Serialization;
 
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Web.Services.Protocols
 {
        [TestFixture]
diff --git a/mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SocketResponder.cs b/mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SocketResponder.cs
deleted file mode 100644 (file)
index 2ebe7cf..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// SocketResponder.cs - Utility class for tests that require a listener
-//
-// Author:
-//     Gert Driesen (drieseng@users.sourceforge.net)
-//
-// Copyright (C) 2007 Gert Driesen
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// 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.Globalization;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-using System.Threading;
-
-namespace MonoTests.System.Web.Services.Protocols
-{
-       public delegate byte [] SocketRequestHandler (Socket socket);
-
-       public class SocketResponder : IDisposable
-       {
-               private TcpListener tcpListener;
-               private readonly IPEndPoint _localEndPoint;
-               private Thread listenThread;
-               private SocketRequestHandler _requestHandler;
-               private bool _stopped = true;
-               private readonly object _syncRoot = new object ();
-
-               private const int SOCKET_CLOSED = 10004;
-
-               public SocketResponder (IPEndPoint localEP, SocketRequestHandler requestHandler)
-               {
-                       _localEndPoint = localEP;
-                       _requestHandler = requestHandler;
-               }
-
-               public IPEndPoint LocalEndPoint
-               {
-                       get { return _localEndPoint; }
-               }
-
-               public void Dispose ()
-               {
-                       Stop ();
-               }
-
-               public bool IsStopped
-               {
-                       get
-                       {
-                               lock (_syncRoot) {
-                                       return _stopped;
-                               }
-                       }
-               }
-
-               public void Start ()
-               {
-                       lock (_syncRoot) {
-                               if (!_stopped)
-                                       return;
-                               _stopped = false;
-                               listenThread = new Thread (new ThreadStart (Listen));
-                               listenThread.Start ();
-                               Thread.Sleep (20); // allow listener to start
-                       }
-               }
-
-               public void Stop ()
-               {
-                       lock (_syncRoot) {
-                               if (_stopped)
-                                       return;
-                               _stopped = true;
-                               if (tcpListener != null) {
-                                       tcpListener.Stop ();
-                                       tcpListener = null;
-#if MONO_FEATURE_THREAD_ABORT
-                                       listenThread.Abort ();
-#else
-                                       listenThread.Interrupt ();
-#endif
-                                       listenThread.Join ();
-                                       listenThread = null;
-                               }
-                       }
-               }
-
-               private void Listen ()
-               {
-                       tcpListener = new TcpListener (LocalEndPoint);
-                       tcpListener.Start ();
-                       try {
-                               Socket socket = tcpListener.AcceptSocket ();
-                               socket.Send (_requestHandler (socket));
-                               socket.Close ();
-                       } catch (SocketException ex) {
-                               // ignore interruption of blocking call
-                               if (ex.ErrorCode != SOCKET_CLOSED)
-                                       throw;
-                       }
-               }
-       }
-}
index 4f0d50bf06504991c01ec1ac1abb9c8a538406f6..a7651da891f7900adbb0b0cead4fa0ad03b94ce3 100644 (file)
@@ -80,4 +80,6 @@ using System.Runtime.InteropServices;
 
        [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
        [assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+       [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
+       [assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
        [assembly: InternalsVisibleTo ("Mono.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]
index 00036654b1cca414fea382dcc02d652b84d1a62d..e77553b47da4bd3ddba640b0d8c1f446524ef8dc 100644 (file)
@@ -148,7 +148,7 @@ namespace Mono.Http
                                return null;
 
                        lock (cache) {
-                               var ds = cache.GetOrCreateValue (request);
+                               var ds = cache.GetValue (request, x => new NtlmSession ());
                                return ds.Authenticate (header, webRequest, credentials);
                        }
                }
index c39b2144781bb83dd9f2c0f68a82b030e5ce3382..d6f6e5296f454a65ac7ca9f27b6d3e001087e539 100644 (file)
@@ -86,7 +86,7 @@ namespace Mono.Net.Security.Private
                        get { return false; }
                }
 
-               public override bool SupportsTlsContext {
+               internal override bool SupportsTlsContext {
                        get { return false; }
                }
 
index 85023644aee04643c8df76549a27d3ab92786b6e..f2cf321677deab8b6c4a5810deb8587c56934f29 100644 (file)
@@ -134,25 +134,35 @@ namespace Mono.Net.Security
 
 #if SECURITY_DEP && !MONO_FEATURE_NEW_SYSTEM_SOURCE
 
-#if !MOBILE
                static Dictionary<string,string> providerRegistration;
 
-               internal static void RegisterProvider (string name, string type)
+               static Type LookupProviderType (string name, bool throwOnError)
                {
                        lock (locker) {
                                InitializeProviderRegistration ();
-                               providerRegistration.Add (name, type);
+                               string typeName;
+                               if (!providerRegistration.TryGetValue (name, out typeName)) {
+                                       if (throwOnError)
+                                               throw new NotSupportedException (string.Format ("No such TLS Provider: `{0}'.", name));
+                                       return null;
+                               }
+                               var type = Type.GetType (typeName, false);
+                               if (type == null && throwOnError)
+                                       throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", typeName));
+                               return type;
                        }
                }
 
-               static string LookupProvider (string name)
+               static MSI.MonoTlsProvider LookupProvider (string name, bool throwOnError)
                {
-                       lock (locker) {
-                               InitializeProviderRegistration ();
-                               string type;
-                               if (!providerRegistration.TryGetValue (name, out type))
-                                       type = null;
-                               return type;
+                       var type = LookupProviderType (name, throwOnError);
+                       if (type == null)
+                               return null;
+
+                       try {
+                               return (MSI.MonoTlsProvider)Activator.CreateInstance (type);
+                       } catch (Exception ex) {
+                               throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", type), ex);
                        }
                }
 
@@ -162,11 +172,12 @@ namespace Mono.Net.Security
                                if (providerRegistration != null)
                                        return;
                                providerRegistration = new Dictionary<string,string> ();
-                               providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2");
-                               providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2");
+                               providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
+                               providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756");
                        }
                }
 
+#if !MOBILE
                static IMonoTlsProvider TryDynamicLoad ()
                {
                        var variable = Environment.GetEnvironmentVariable ("MONO_TLS_PROVIDER");
@@ -176,25 +187,7 @@ namespace Mono.Net.Security
                        if (string.Equals (variable, "default", StringComparison.OrdinalIgnoreCase))
                                return null;
 
-                       string typeName;
-                       if (variable.IndexOfAny (new char[] { ',', '.', '=' }) > 0) {
-                               typeName = variable;
-                       } else {
-                               typeName = LookupProvider (variable);
-                               if (typeName == null)
-                                       throw new NotSupportedException (string.Format ("No such TLS Provider: `{0}'.", typeName));
-                       }
-
-                       var type = Type.GetType (typeName, false);
-                       if (type == null)
-                               throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", typeName));
-
-                       MSI.MonoTlsProvider provider;
-                       try {
-                               provider = (MSI.MonoTlsProvider)Activator.CreateInstance (type);
-                       } catch (Exception ex) {
-                               throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", typeName), ex);
-                       }
+                       var provider = LookupProvider (variable, true);
 
                        return new Private.MonoTlsProviderWrapper (provider);
                }
@@ -245,9 +238,10 @@ namespace Mono.Net.Security
                        }
                }
 
-               internal static void InstallProvider (MSI.MonoTlsProvider provider)
+               internal static void SetDefaultProvider (string name)
                {
                        lock (locker) {
+                               var provider = LookupProvider (name, true);
                                currentProvider = new Private.MonoTlsProviderWrapper (provider);
                        }
                }
index 4216e5809f3ca9b44bb2684d485093463118554b..b0ae5d82c724627ca2360a856b159af606f23104 100644 (file)
@@ -100,7 +100,7 @@ namespace Mono.Net.Security.Private
                        bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
                        MSI.MonoTlsSettings settings);
 
-               public override MSI.IMonoTlsContext CreateTlsContext (
+               internal override MSI.IMonoTlsContext CreateTlsContext (
                        string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
                        X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
                        bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
index f4ccac81cb059fa3e847e0b449cdf1f55622ee96..a11fcec2c194ed559e80f3ead0f3fb7a4dc82931 100644 (file)
@@ -84,10 +84,10 @@ namespace Mono.Net.Security
                        }
                }
 
-               internal static void InstallProvider (object provider)
+               internal static void SetDefaultProvider (string name)
                {
                        #if SECURITY_DEP
-                       MonoTlsProviderFactory.InstallProvider ((MSI.MonoTlsProvider)provider);
+                       MonoTlsProviderFactory.SetDefaultProvider (name);
                        #else
                        throw new NotSupportedException ();
                        #endif
index 8c6fa0dcf4fb77a97882d0bba91e216deb500b15..59616e64d94d652f9091843da386f04e2ab191b6 100644 (file)
@@ -1281,11 +1281,11 @@ namespace System.Diagnostics {
                                return false;
 
 #if MONO_FEATURE_PROCESS_START
-                       if (async_output != null && !async_output.IsCompleted)
-                               async_output.AsyncWaitHandle.WaitOne ();
+                       if (async_output != null)
+                               async_output.WaitUtilEOF ();
 
-                       if (async_error != null && !async_error.IsCompleted)
-                               async_error.AsyncWaitHandle.WaitOne ();
+                       if (async_error != null)
+                               async_error.WaitUtilEOF ();
 #endif // MONO_FEATURE_PROCESS_START
 
                        if (EnableRaisingEvents)
@@ -1327,20 +1327,6 @@ namespace System.Diagnostics {
                [MonitoringDescription ("Raised when it receives error data")]
                public event DataReceivedEventHandler ErrorDataReceived;
 
-               void OnOutputDataReceived (string str)
-               {
-                       DataReceivedEventHandler cb = OutputDataReceived;
-                       if (cb != null)
-                               cb (this, new DataReceivedEventArgs (str));
-               }
-
-               void OnErrorDataReceived (string str)
-               {
-                       DataReceivedEventHandler cb = ErrorDataReceived;
-                       if (cb != null)
-                               cb (this, new DataReceivedEventArgs (str));
-               }
-
 #if MONO_FEATURE_PROCESS_START
                [Flags]
                enum AsyncModes {
@@ -1351,121 +1337,9 @@ namespace System.Diagnostics {
                        AsyncError = 1 << 3
                }
 
-               [StructLayout (LayoutKind.Sequential)]
-               sealed class ProcessAsyncReader : IOAsyncResult
-               {
-                       Process process;
-                       IntPtr handle;
-                       Stream stream;
-                       bool err_out;
-
-                       StringBuilder sb = new StringBuilder ();
-                       byte[] buffer = new byte [4096];
-
-                       const int ERROR_INVALID_HANDLE = 6;
-
-                       public ProcessAsyncReader (Process process, FileStream stream, bool err_out)
-                               : base (null, null)
-                       {
-                               this.process = process;
-                               this.handle = stream.SafeFileHandle.DangerousGetHandle ();
-                               this.stream = stream;
-                               this.err_out = err_out;
-                       }
-
-                       public void BeginReadLine ()
-                       {
-                               IOSelector.Add (this.handle, new IOSelectorJob (IOOperation.Read, _ => Read (), null));
-                       }
-
-                       void Read ()
-                       {
-                               int nread = 0;
-
-                               try {
-                                       nread = stream.Read (buffer, 0, buffer.Length);
-                               } catch (ObjectDisposedException) {
-                               } catch (IOException ex) {
-                                       if (ex.HResult != (unchecked((int) 0x80070000) | (int) ERROR_INVALID_HANDLE))
-                                               throw;
-                               } catch (NotSupportedException) {
-                                       if (stream.CanRead)
-                                               throw;
-                               }
-
-                               if (nread == 0) {
-                                       Flush (true);
-
-                                       if (err_out)
-                                               process.OnOutputDataReceived (null);
-                                       else
-                                               process.OnErrorDataReceived (null);
-
-                                       IsCompleted = true;
-
-                                       return;
-                               }
-
-                               try {
-                                       sb.Append (Encoding.Default.GetString (buffer, 0, nread));
-                               } catch {
-                                       // Just in case the encoding fails...
-                                       for (int i = 0; i < nread; i++) {
-                                               sb.Append ((char) buffer [i]);
-                                       }
-                               }
-
-                               Flush (false);
-
-                               IOSelector.Add (this.handle, new IOSelectorJob (IOOperation.Read, _ => Read (), null));
-                       }
-
-                       void Flush (bool last)
-                       {
-                               if (sb.Length == 0 || (err_out && process.output_canceled) || (!err_out && process.error_canceled))
-                                       return;
-
-                               string[] strs = sb.ToString ().Split ('\n');
-
-                               sb.Length = 0;
-
-                               if (strs.Length == 0)
-                                       return;
-
-                               for (int i = 0; i < strs.Length - 1; i++) {
-                                       if (err_out)
-                                               process.OnOutputDataReceived (strs [i]);
-                                       else
-                                               process.OnErrorDataReceived (strs [i]);
-                               }
-
-                               string end = strs [strs.Length - 1];
-                               if (last || (strs.Length == 1 && end == "")) {
-                                       if (err_out)
-                                               process.OnOutputDataReceived (end);
-                                       else
-                                               process.OnErrorDataReceived (end);
-                               } else {
-                                       sb.Append (end);
-                               }
-                       }
-
-                       public void Close ()
-                       {
-                               IOSelector.Remove (handle);
-                       }
-
-                       internal override void CompleteDisposed ()
-                       {
-                               throw new NotSupportedException ();
-                       }
-               }
-
                AsyncModes async_mode;
-               bool output_canceled;
-               bool error_canceled;
-               ProcessAsyncReader async_output;
-               ProcessAsyncReader async_error;
+               AsyncStreamReader async_output;
+               AsyncStreamReader async_error;
 
                [ComVisibleAttribute(false)] 
                public void BeginOutputReadLine ()
@@ -1477,10 +1351,22 @@ namespace System.Diagnostics {
                                throw new InvalidOperationException ("Cannot mix asynchronous and synchonous reads.");
 
                        async_mode |= AsyncModes.AsyncOutput;
-                       output_canceled = false;
-                       if (async_output == null) {
-                               async_output = new ProcessAsyncReader (this, (FileStream) output_stream.BaseStream, true);
-                               async_output.BeginReadLine ();
+
+                       if (async_output == null)
+                               async_output = new AsyncStreamReader (this, output_stream.BaseStream, new UserCallBack(this.OutputReadNotifyUser), output_stream.CurrentEncoding);
+
+                       async_output.BeginReadLine ();
+               }
+
+               void OutputReadNotifyUser (String data)
+               {
+                       // To avoid ---- between remove handler and raising the event
+                       DataReceivedEventHandler outputDataReceived = OutputDataReceived;
+                       if (outputDataReceived != null) {
+                               if (SynchronizingObject != null && SynchronizingObject.InvokeRequired)
+                                       SynchronizingObject.Invoke (outputDataReceived, new object[] { this, new DataReceivedEventArgs (data) });
+                               else
+                                       outputDataReceived (this, new DataReceivedEventArgs (data)); // Call back to user informing data is available.
                        }
                }
 
@@ -1496,7 +1382,9 @@ namespace System.Diagnostics {
                        if (async_output == null)
                                throw new InvalidOperationException ("No async operation in progress.");
 
-                       output_canceled = true;
+                       async_output.CancelOperation ();
+
+                       async_mode &= ~AsyncModes.AsyncOutput;
                }
 
                [ComVisibleAttribute(false)] 
@@ -1509,10 +1397,22 @@ namespace System.Diagnostics {
                                throw new InvalidOperationException ("Cannot mix asynchronous and synchonous reads.");
 
                        async_mode |= AsyncModes.AsyncError;
-                       error_canceled = false;
-                       if (async_error == null) {
-                               async_error = new ProcessAsyncReader (this, (FileStream) error_stream.BaseStream, false);
-                               async_error.BeginReadLine ();
+
+                       if (async_error == null)
+                               async_error = new AsyncStreamReader (this, error_stream.BaseStream, new UserCallBack(this.ErrorReadNotifyUser), error_stream.CurrentEncoding);
+
+                       async_error.BeginReadLine ();
+               }
+
+               void ErrorReadNotifyUser (String data)
+               {
+                       // To avoid ---- between remove handler and raising the event
+                       DataReceivedEventHandler errorDataReceived = ErrorDataReceived;
+                       if (errorDataReceived != null) {
+                               if (SynchronizingObject != null && SynchronizingObject.InvokeRequired)
+                                       SynchronizingObject.Invoke (errorDataReceived, new object[] { this, new DataReceivedEventArgs (data) });
+                               else
+                                       errorDataReceived (this, new DataReceivedEventArgs (data)); // Call back to user informing data is available.
                        }
                }
 
@@ -1528,7 +1428,9 @@ namespace System.Diagnostics {
                        if (async_error == null)
                                throw new InvalidOperationException ("No async operation in progress.");
 
-                       error_canceled = true;
+                       async_error.CancelOperation ();
+
+                       async_mode &= ~AsyncModes.AsyncError;
                }
 #else
                [Obsolete ("Process.BeginOutputReadLine is not supported on the current platform.", true)]
@@ -1588,11 +1490,8 @@ namespace System.Diagnostics {
                        // dispose all managed resources.
                        if (disposing) {
 #if MONO_FEATURE_PROCESS_START
-                               /* These have open FileStreams on the pipes we are about to close */
-                               if (async_output != null)
-                                       async_output.Close ();
-                               if (async_error != null)
-                                       async_error.Close ();
+                               async_output = null;
+                               async_error = null;
 
                                if (input_stream != null) {
                                        if (!input_stream_exposed)
@@ -1667,16 +1566,26 @@ namespace System.Diagnostics {
 
                void StartBackgroundWaitForExit ()
                {
+                       IntPtr handle = process_handle;
+
                        if (enable_raising_events == 0)
                                return;
                        if (exited_event == null)
                                return;
-                       if (process_handle == IntPtr.Zero)
+                       if (handle == IntPtr.Zero)
                                return;
                        if (background_wait_for_exit_thread != null)
                                return;
 
-                       Thread t = new Thread (_ => WaitForExit ()) { IsBackground = true };
+                       Thread t = new Thread (_ => {
+                               if (!WaitForExit_internal (handle, -1))
+                                       return;
+
+                               if (EnableRaisingEvents)
+                                       OnExited ();
+                       });
+
+                       t.IsBackground = true;
 
                        if (Interlocked.CompareExchange (ref background_wait_for_exit_thread, t, null) == null)
                                t.Start ();
index fc2a2ef16c16c9d5075f506fdf94f995914c07c4..0799816a9ea82ce2c0d22b625cf267d8eeaa1179 100644 (file)
@@ -298,7 +298,7 @@ namespace System.Net.Sockets
                        CheckDisposed ();
 
                        byte [] recBuffer = new byte [65536]; // Max. size
-                       EndPoint endPoint = new IPEndPoint (IPAddress.Any, 0);
+                       EndPoint endPoint = (EndPoint) remoteEP;
                        int dataRead = socket.ReceiveFrom (recBuffer, ref endPoint);
                        if (dataRead < recBuffer.Length)
                                recBuffer = CutArray (recBuffer, dataRead);
index 0b5d6a76e4bde04bd6251048da01be9e720c9fb5..8294f7b43d2574ac4142bfd1dc19476032484160 100644 (file)
 // 
 
 using System;
+using System.Net;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using System.Threading;
 
-namespace System.Net
+namespace Mono.Net
 {
        internal class CFObject : IDisposable
        {
index 97d15a285e04ce081f0fee2028ccea25d83c0823..8c1523ad82484bb59a94c69298e2e3337a0b2c98 100644 (file)
@@ -86,7 +86,7 @@ namespace System.Net
                static object classLock = new object ();
                MonoTlsStream tlsStream;
 
-#if MONOTOUCH
+#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
                [System.Runtime.InteropServices.DllImport ("__Internal")]
                static extern void xamarin_start_wwan (string uri);
 #endif
@@ -152,7 +152,7 @@ namespace System.Net
                                IPHostEntry hostEntry = sPoint.HostEntry;
 
                                if (hostEntry == null) {
-#if MONOTOUCH
+#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
                                        xamarin_start_wwan (sPoint.Address.ToString ());
                                        hostEntry = sPoint.HostEntry;
                                        if (hostEntry == null) {
@@ -160,7 +160,7 @@ namespace System.Net
                                                status = sPoint.UsesProxy ? WebExceptionStatus.ProxyNameResolutionFailure :
                                                                            WebExceptionStatus.NameResolutionFailure;
                                                return;
-#if MONOTOUCH
+#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
                                        }
 #endif
                                }
index ae1159958aa3ef0738f811e29f27e2cd640cc61b..889398ee6a42e98ae3341c4acb1df004b575da89 100644 (file)
@@ -41,6 +41,7 @@ using System.Net.Cache;
 using System.Security.Principal;
 using System.Threading.Tasks;
 using System.Text.RegularExpressions;
+using Mono.Net;
 
 #if NET_2_1
 using ConfigurationException = System.ArgumentException;
index 6b3ac78003c7c932cdf4a75e71cda945364cec6c..8cb89f394ddde6052fce597e4403e64f281a8bbc 100644 (file)
@@ -1176,3 +1176,5 @@ ReferenceSources/_SslStream.cs
 ../../../external/referencesource/System/compmod/system/codedom/compiler/ICodeParser.cs
 ../../../external/referencesource/System/compmod/system/codedom/compiler/IndentTextWriter.cs
 ../../../external/referencesource/System/compmod/system/codedom/compiler/LanguageOptions.cs
+
+../../../external/referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs
index 22e57b5086ca492771418a85e09944a6bf2bb7e2..7d07dd75041141098ea61d99b056e993dc454d55 100644 (file)
@@ -231,7 +231,6 @@ System.Net/ServicePointManagerTest.cs
 System.Net/ServicePointTest.cs
 System.Net/SocketPermissionAttributeTest.cs
 System.Net/SocketPermissionTest.cs
-System.Net/SocketResponder.cs
 System.Net/WebHeaderCollectionTest.cs
 System.Net/WebPermissionAttributeTest.cs
 System.Net/WebPermissionTest.cs
@@ -510,3 +509,4 @@ System.Collections.Concurrent/CollectionStressTestHelper.cs
 System.Collections.Concurrent/ParallelTestHelper.cs
 System.Net.WebSockets/ClientWebSocketTest.cs
 ../../test-helpers/NetworkHelpers.cs
+../../test-helpers/SocketResponder.cs
index 0d2dea47a73f5244dbac722c16b7ab8768e79e23..2f85b7b795ef33f0b58ccc3b51269444520bdab9 100755 (executable)
@@ -3495,6 +3495,14 @@ namespace MonoTests.System.Net.Sockets
                        s.Close ();
                }
 
+#if MONOTOUCH
+               // when the linker is enabled then reflection won't work and would throw an NRE
+               // this is also always true for iOS - so we do not need to poke internals
+               static bool SupportsPortReuse ()
+               {
+                       return true;
+               }
+#else
                static bool? supportsPortReuse;
                static bool SupportsPortReuse ()
                {
@@ -3506,6 +3514,7 @@ namespace MonoTests.System.Net.Sockets
                                        .Invoke (null, new object [] {});
                        return supportsPortReuse.Value;
                }
+#endif
 
                // Test case for bug #31557
                [Test]
index a02e150915b70a06f5f7964ca09f55a038370fdb..d4769eb811bc6eeb297046a2b44df0c597c9d36a 100644 (file)
@@ -13,6 +13,8 @@ using System.Net;
 using System.Net.Sockets;
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.Net.Sockets
 {
        /// <summary>
index 334f552b515a94da5491f6c3a74280c83a34771c..b7a537f662be204c61ffb1f6b1c9b6e0911d06cf 100644 (file)
@@ -1064,6 +1064,26 @@ namespace MonoTests.System.Net.Sockets {
 
                        client.Close ();
                }
+
+               [Test] // #6057
+               public void ReceiveIPv6 ()
+               {
+                       if (!Socket.OSSupportsIPv6)
+                               Assert.Ignore ("IPv6 not enabled.");
+
+                       int PORT = 9997;
+                       using(var udpClient = new UdpClient (PORT, AddressFamily.InterNetworkV6))
+                       using(var udpClient2 = new UdpClient (PORT+1, AddressFamily.InterNetworkV6))
+                       {
+                               var dataSent = new byte [] {1,2,3};
+                               udpClient2.SendAsync (dataSent, dataSent.Length, "::1", PORT);
+
+                               IPEndPoint endPoint = new IPEndPoint (IPAddress.IPv6Any, 0);
+                               var data = udpClient.Receive (ref endPoint);
+
+                               Assert.AreEqual (dataSent.Length, data.Length);
+                       }
+               }
                
                /* No test for Ttl default as it is platform dependent */
 
diff --git a/mcs/class/System/Test/System.Net/SocketResponder.cs b/mcs/class/System/Test/System.Net/SocketResponder.cs
deleted file mode 100644 (file)
index af05477..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-//
-// SocketResponder.cs - Utility class for tests that require a listener
-//
-// Author:
-//     Gert Driesen (drieseng@users.sourceforge.net)
-//
-// Copyright (C) 2007 Gert Driesen
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// 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.Globalization;
-using System.IO;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-using System.Threading;
-
-namespace MonoTests.System.Net
-{
-       public delegate byte [] SocketRequestHandler (Socket socket);
-
-       public class SocketResponder : IDisposable
-       {
-               private TcpListener tcpListener;
-               private readonly IPEndPoint _localEndPoint;
-               private Thread listenThread;
-               private Socket listenSocket;
-               private SocketRequestHandler _requestHandler;
-               private int _state = 0;
-               private readonly object _syncRoot = new object ();
-
-               private const int SOCKET_CLOSED = 10004;
-               private const int SOCKET_INVALID_ARGS = 10022;
-
-               private const int STATE_UNINITIALIZED = 0;
-               private const int STATE_RUNNING = 1;
-               private const int STATE_STOPPED = 2;
-
-               public SocketResponder (IPEndPoint localEP, SocketRequestHandler requestHandler)
-               {
-                       _localEndPoint = localEP;
-                       _requestHandler = requestHandler;
-               }
-
-               public IPEndPoint LocalEndPoint
-               {
-                       get { return _localEndPoint; }
-               }
-
-               public void Dispose ()
-               {
-                       Stop ();
-               }
-
-               public bool IsStopped
-               {
-                       get
-                       {
-                               lock (_syncRoot) {
-                                       return _state != STATE_RUNNING;
-                               }
-                       }
-               }
-
-               public void Start ()
-               {
-                       lock (_syncRoot) {
-                               if (_state != STATE_UNINITIALIZED)
-                                       throw new InvalidOperationException ("cannot restart SocketResponder");
-                               _state = STATE_RUNNING;
-                               tcpListener = new TcpListener (LocalEndPoint);
-                               tcpListener.Start ();
-                               listenThread = new Thread (new ThreadStart (Listen));
-                               listenThread.Start ();
-                       }
-               }
-
-               public void Stop ()
-               {
-                       lock (_syncRoot) {
-                               if (_state != STATE_RUNNING)
-                                       return;
-                               _state = STATE_STOPPED;
-                               if (tcpListener != null) {
-                                       tcpListener.Stop ();
-                                       tcpListener = null;
-                                       if (listenSocket != null)
-                                               listenSocket.Close ();
-#if MONO_FEATURE_THREAD_ABORT
-                                       listenThread.Abort ();
-#else
-                                       listenThread.Interrupt ();
-#endif
-                                       listenThread.Join ();
-                                       listenThread = null;
-                                       Thread.Sleep (50);
-                               }
-                       }
-               }
-
-               private void Listen ()
-               {
-                       while (_state == STATE_RUNNING) {
-                               listenSocket = null;
-                               try {
-                                       listenSocket = tcpListener.AcceptSocket ();
-                                       listenSocket.Send (_requestHandler (listenSocket));
-                                       try {
-                                               listenSocket.Shutdown (SocketShutdown.Receive);
-                                               listenSocket.Shutdown (SocketShutdown.Send);
-                                       } catch {
-                                       }
-                               } catch (SocketException ex) {
-                                       // ignore interruption of blocking call
-                                       if (ex.ErrorCode != SOCKET_CLOSED && ex.ErrorCode != SOCKET_INVALID_ARGS && _state != STATE_STOPPED)
-                                               throw;
-                               } catch (ObjectDisposedException ex) {
-                                       Console.WriteLine (ex);
-                                       if (_state != STATE_STOPPED)
-                                               throw;
-#if !MONO_FEATURE_THREAD_ABORT
-                               } catch (ThreadInterruptedException) {
-                                       break;
-#endif
-#if MOBILE
-                               } catch (InvalidOperationException ex) {
-                                       // This breaks some tests running on Android. The problem is that the stack trace
-                                       // doesn't point to where the exception is actually thrown from but the entire process
-                                       // is aborted because of unhandled exception.
-                                       Console.WriteLine ("SocketResponder.Listen failed:");
-                                       Console.WriteLine (ex);
-#endif
-                               } finally {
-#if MONO_FEATURE_THREAD_ABORT
-                                       Thread.Sleep (500);
-#else
-                                       try {
-                                               Thread.Sleep (500);
-                                       } catch (ThreadInterruptedException) {
-                                               // nothing to do
-                                       }
-#endif
-                                       if (listenSocket != null)
-                                               listenSocket.Close ();
-                               }
-                       }
-               }
-       }
-}
index 65a7971c6077d4d317b961b8df3b1cabf67db4ef..47c8946eb3b1e5f5abb460f5d84769535f603e6a 100644 (file)
@@ -788,6 +788,8 @@ ReferenceSources/Win32Exception.cs
 
 ../../../external/referencesource/System/compmod/system/diagnostics/TextWriterTraceListener.cs
 
+../../../external/referencesource/System/services/monitoring/system/diagnosticts/AsyncStreamReader.cs
+
 ../Mono.Security/Mono.Security.Authenticode/PrivateKey.cs
 ../Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs
 ../Mono.Security/Mono.Security.Cryptography/TlsHMAC.cs
index 818dc50039a6657de1396873df885376f49c4b67..b3284ea78796be7b38531510d7a79ffb72f7b7b2 100644 (file)
@@ -99,4 +99,3 @@ using System.Runtime.InteropServices;
 #endif
 
 [assembly: Guid ("BED7F4EA-1A96-11D2-8F08-00A0C9A6186D")]
-
diff --git a/mcs/class/corlib/Linux/ChangeLog b/mcs/class/corlib/Linux/ChangeLog
deleted file mode 100644 (file)
index 96eb5e7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-2002-03-18  Dan Lewis <dihlewis@yahoo.co.uk>
-
-       * Linux.cs: Removed math methods (now in System.Math).
-
-2002-01-23  Dick Porter  <dick@ximian.com>
-
-       * Linux.cs: GetFileTime and SetFileTime need to be static
-
-Tue Jan 22 22:50:29 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * Linux.cs: comment out call to Debug.Assert(): stuff from the System
-       assembly cannot be used in corlib.
-
-2001-12-11  Dick Porter  <dick@ximian.com>
-
-       * Linux.cs: IO implemented with file handles with internal calls,
-       rather than casting file descriptors for C library p/invokes.
-       Implemented Get/Set Creation/LastAccess/LastWrite TimeFile
-       functions.
-
-Wed Nov 14 16:30:27 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * Linux.cs: a '/' is a valid char in a file path.
-
-2001-11-10  Sean MacIsaac  <macisaac@ximian.com>
-
-       * Linux.cs (GetCurrentDirectory): implemented
diff --git a/mcs/class/corlib/Linux/Linux.cs b/mcs/class/corlib/Linux/Linux.cs
deleted file mode 100644 (file)
index 5a51ec9..0000000
+++ /dev/null
@@ -1,507 +0,0 @@
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-/*---------------------------------------------------------------------
-
-                XX                X                XXX
-                                 XX                 XX
-               XXX     XX XXX   XXXXX               XX
-                XX     XXX XX    XX                 XX
-                XX     XX  XX    XX      XXXXX      XX
-                XX     XX  XX    XX XX  XX    X     XX
-               XXXX    XX  XX     XXX   XXXXXXX    XXXX
-                                        XX
-                                         XXXXX
-
-Copyright (c) 2001 Intel Corporation.  All Rights Reserved.
-
-CREATED: August        22, 2001
-OWNER: Scott D Smith, Joel Marcey
-VERSION: 1.0
----------------------------------------------------------------------*/
-           
-using System;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.IO;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-namespace System.PAL
-{
-       /// <summary>
-       ///     Class that implements IOperatingSystem, providing the requested functionality through calls into APIs available in Linux 
-       /// </summary>
-       internal class OpSys
-       {
-               private Hashtable _environment = null;
-
-               //----------------------------------
-               //             Class Constants
-               //----------------------------------
-               private const int EOF = -1; // TODO: Linux: Is this true?
-       
-
-               // For StdInputStream and StdOutputStream
-               private IntPtr Stdin;
-               private IntPtr Stdout;
-               private IntPtr Stderr;
-
-               //----------------------------------
-               //              Class Fields
-               //----------------------------------
-
-               //----------------------------------
-               //              Class Constructor
-               //----------------------------------
-               public OpSys()
-               {
-                       Stdin=GetStdHandle(0);
-                       Stdout=GetStdHandle(1);
-                       Stderr=GetStdHandle(2);
-               }
-
-
-               //-------------------------------------------------
-               //              Environment Services 
-               //-------------------------------------------------
-
-               public string NewLineSequence
-               {
-                       get
-                       {
-                               return "\n";
-                       }
-               }
-
-               public char DirectorySeparator
-               {
-                       get
-                       {
-                               return '/';
-                       }
-               }
-
-               public char AltDirectorySeparator
-               {
-                       get
-                       {
-                               return '\\';
-                       }
-               }
-
-               public char VolumeSeparator
-               {
-                       get
-                       {
-                               return '/';
-                       }
-               }
-
-               public char PathSeparator
-               {
-                       get
-                       {
-                               return ':';
-                       }
-               }
-
-               public char[] InvalidPathChars
-               {
-                       get
-                       {
-                               return new char[] { '\0' };
-                       }
-               }
-
-               public char[] DirVolSeparatorChars
-               {
-                       get
-                       {
-                               return new char[] { this.DirectorySeparator, this.AltDirectorySeparator, this.VolumeSeparator};
-                       }
-               }
-               public char ExtensionCharacter
-               {
-                       get
-                       {
-                               return '.';
-                       }
-               }
-
-               public string GetEnvironmentVariable(string eVar)
-               {
-                       return EnvironmentVariables[eVar].ToString();
-               }
-
-               public IDictionary EnvironmentVariables
-               {
-                       get
-                       {
-                               if (_environment == null) {
-                                       IntPtr pp = _getEnviron(); // pointer to        an array of char*
-                                       _environment = new Hashtable();
-                       
-                                       if (pp != IntPtr.Zero) {
-                                               IntPtr p;
-                                               bool done = false;
-                                               char[] delimiter = { '=' };
-                               
-                                               while (!done) 
-                                               {
-                                                       p = Marshal.ReadIntPtr(pp);
-                                                       if (p != IntPtr.Zero) 
-                                                       {
-                                                               string str = Marshal.PtrToStringAuto(p);
-                                                               string[] ar = str.Split(delimiter, 2);
-                                                               switch(ar.Length) 
-                                                               {
-                                                                       case 1:
-                                                                               _environment.Add(ar[0], "");
-                                                                               break;
-                                                                       case 2:
-                                                                               _environment.Add(ar[0], ar[1]);
-                                                                               break;
-                                                                       default:
-                                                                               //System.Diagnostics/.Debug.Assert(false);      // this shouldn't happen
-                                                                               break;
-                                                               }
-                                                       } 
-                                                       else 
-                                                       {
-                                                               done = true;
-                                                       }
-                                               }
-                                       } 
-                               }                       
-                               return _environment;
-                       }
-               }
-
-               public string CommandLine
-               {
-                       get
-                       {
-                               string path = Path.Combine(Path.Combine("/proc", _getPid().ToString()), "cmdline");
-                               StreamReader stream = File.OpenText(path);
-                               string res = stream.ReadToEnd();
-                               stream.Close();
-                               return res;
-                       }
-               }
-
-               public string MachineName
-               {
-                       get
-                       {
-                               return GetEnvironmentVariable("HOSTNAME");
-                       }
-               }
-
-               public OperatingSystem OSVersion
-               {
-                       get
-                       {
-                               return null;
-                       }
-               }
-
-               // System.Path services
-
-               public string ChangeExtension(string path, string extension)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:ChangeExtension(System.String, System.String): Stub Method");
-                       return null;
-               }
-
-               public string GetExtension(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetExtension(System.String): Stub Method");
-                       return null;
-               }
-
-               public string GetFileName(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetFileName(System.String): Stub Method");
-                       return null;
-               }
-       
-               public string GetFileNameWithoutExtension(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetFileNameWithoutExtension(System.String): Stub Method");
-                       return null;
-               }
-
-               public string GetFullPath(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetFullPath(System.String): Stub Method");
-                       return null;
-               }
-
-               public string GetPathRoot(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetPathRoot(System.String): Stub Method");
-                       return null;
-
-               }
-       
-               public string GetTempFileName()
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetTempFileName(): Stub Method");
-                       return null;
-               }
-       
-               public string GetTempPath()
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetTempPath(): Stub Method");
-                       return null;
-               }
-
-               public bool HasExtension(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:HasExtension(System.String): Stub Method");
-                       return false;
-               }
-
-               public bool IsPathRooted(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:IsPathRooted(System.String): Stub Method");
-                       return false;
-               }
-
-
-
-               // System.Directory services
-
-               public void DeleteDirectory(string path, bool recursive)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:DeleteDirectory(System.String, System.Boolean): Stub Method");
-               }
-
-               public bool ExistsDirectory(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:ExistsDirectory(System.String): Stub Method");
-                       return false;
-               }
-
-               public DateTime GetCreationTimeDirectory(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetCreationTimeDirectory(System.String): Stub      Method");
-                       return new DateTime(0);
-               }
-
-               [System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
-               public extern string GetCurrentDirectory();
-
-               public string[] GetDirectories(string path, string searchPattern)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetDirectories(System.String,System.String): Stub Method");
-                       return null;
-               }
-
-               public string[] GetFiles(string path, string searchPattern)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetFiles(System.String, System.String): Stub Method");
-                       return null;
-               }
-
-               public string[] GetFileSystemEntries(string path, string searchPattern)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetFileSystemEntries(System.String, System.String): Stub Method");
-                       return null;
-               }
-
-               public DateTime GetLastAccessTimeDirectory(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetLastAccessTimeDirectory(System.String): Stub Method");
-                       return new DateTime(0);
-               }
-
-               public DateTime GetLastWriteTimeDirectory(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:GetLastWriteTimeDirectory(System.String): Stub Method");
-                       return new DateTime(0);
-               }
-
-               public void MoveDirectory(string sourceDirName, string destDirName)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:MoveDirectory(System.String, System.String): Stub Method");
-               }
-
-               public void SetCreationTimeDirectory(string path, DateTime creationTime)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:SetCreationTimeDirectory(System.String, System.DateTime): Stub Method");
-               }
-
-               public void SetCurrentDirectory(string path)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:SetCurrentDirectory(System.String): Stub Method");
-               }
-
-               public void SetLastAccessTimeDirectory(string path, DateTime lastAccessTime)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:SetLastAccessTimeDirectory(System.String, System.DateTime): Stub Method");
-               }
-
-               public void SetLastWriteTimeDirectory(string path, DateTime lastWriteTime)
-               {
-                       //System.Diagnostics/.Debug.WriteLine("Linux:SetLastWriteTimeDirectory(System.String, System.DateTime): Stub Method");
-               }
-
-               //-----------------------------------
-               //              I/O Services
-               //-----------------------------------
-
-               [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
-               private extern IntPtr GetStdHandle(int fd);
-
-               public IntPtr StdinHandle {
-                       get {
-                               return(Stdin);
-                       }
-               }
-
-               public IntPtr StdoutHandle {
-                       get {
-                               return(Stdout);
-                       }
-               }
-
-               public IntPtr StderrHandle {
-                       get {
-                               return(Stderr);
-                       }
-               }
-
-               [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
-               public extern void DeleteFile(string path);
-       
-               [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
-               public extern bool ExistsFile(string path);
-
-               /* The long time parameters in GetFileTime and
-                * SetFileTime correspond to Windows file times (ticks
-                * from DateTime(1/1/1601 00:00 GMT))
-                */
-               [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
-               private extern static bool GetFileTime(IntPtr handle, out long creat, out long lastaccess, out long lastwrite);
-
-               [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
-               private extern static bool SetFileTime(IntPtr handle, long creat, long lastaccess, long lastwrite);
-       
-               public DateTime GetCreationTimeFile(string path)
-               {
-                       long creat, lastaccess, lastwrite;
-                       bool ret;
-                       FileStream s = new FileStream(path, FileMode.Open, FileAccess.Read);
-                       
-                       ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
-                       s.Close();
-                       
-                       return DateTime.FromFileTime(creat);
-               }
-       
-               public DateTime GetLastAccessTimeFile(string path)
-               {
-                       long creat, lastaccess, lastwrite;
-                       bool ret;
-                       FileStream s = new FileStream(path, FileMode.Open, FileAccess.Read);
-                       
-                       ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
-                       s.Close();
-                       
-                       return DateTime.FromFileTime(lastaccess);
-               }
-       
-               public DateTime GetLastWriteTimeFile(string path)
-               {
-                       long creat, lastaccess, lastwrite;
-                       bool ret;
-                       FileStream s = new FileStream(path, FileMode.Open, FileAccess.Read);
-                       
-                       ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
-                       s.Close();
-                       
-                       return DateTime.FromFileTime(lastwrite);
-               }
-       
-               public void SetCreationTimeFile(string path, DateTime creationTime)
-               {
-                       long creat, lastaccess, lastwrite;
-                       bool ret;
-                       FileStream s = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
-                       
-                       // Get the existing times first
-                       ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
-
-                       creat=creationTime.ToFileTime();
-                       
-                       ret=SetFileTime(s.Handle, creat, lastaccess, lastwrite);
-                       s.Close();
-               }
-       
-               public void SetLastAccessTimeFile(string path, DateTime lastAccessTime)
-               {
-                       long creat, lastaccess, lastwrite;
-                       bool ret;
-                       FileStream s = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
-                       
-                       // Get the existing times first
-                       ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
-
-                       lastaccess=lastAccessTime.ToFileTime();
-                       
-                       ret=SetFileTime(s.Handle, creat, lastaccess, lastwrite);
-                       s.Close();
-               }
-       
-               public void SetLastWriteTimeFile(string path, DateTime lastWriteTime)
-               {
-                       long creat, lastaccess, lastwrite;
-                       bool ret;
-                       FileStream s = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
-                       
-                       // Get the existing times first
-                       ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
-
-                       lastwrite=lastWriteTime.ToFileTime();
-                       
-                       ret=SetFileTime(s.Handle, creat, lastaccess, lastwrite);
-                       s.Close();
-               }
-
-
-               public long FileLength(string path)
-               {
-                       return 0;
-               }
-
-               // Private implementation details
-               [DllImport("monowrapper", EntryPoint="mono_wrapper_environ", CharSet=CharSet.Ansi)]
-               private unsafe static extern IntPtr _getEnviron();
-
-               [DllImport("libc", EntryPoint="getpid")]
-               private unsafe static extern int _getPid();
-       }
-}
index 6037a8c923079018df185f19a5069ce1ac80be76..965cf02c2a6f365542309eaee49d232e98c61198 100644 (file)
@@ -33,10 +33,8 @@ namespace System {
                [System.Security.SecurityCritical]
                [ResourceExposure(ResourceScope.None)]
                [SuppressUnmanagedCodeSecurity]
-               internal static bool CheckThrowUnobservedTaskExceptions()
-               {
-                       return false;
-               }
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               extern internal static bool CheckThrowUnobservedTaskExceptions();
 
        }  // internal class CLRConfig
 
index 242bc800ac88169845c2dd3b980d754a40d28721..297a4d376c308a80d56b20fea5c0e83c47da3821 100644 (file)
@@ -629,7 +629,7 @@ namespace System.Globalization
                                numInfo = (NumberFormatInfo) numInfo.Clone ();
                        }
 
-                       textInfo = CreateTextInfo (read_only);
+                       textInfo = TextInfo.Invariant;
 
                        m_name=String.Empty;
                        englishname=
@@ -732,6 +732,9 @@ namespace System.Globalization
                
                public static CultureInfo GetCultureInfo (int culture)
                {
+                       if (culture < 1)
+                               throw new ArgumentOutOfRangeException ("culture", "Positive number required.");
+
                        CultureInfo c;
                        
                        lock (shared_table_lock){
diff --git a/mcs/class/corlib/System.PAL/.gitattributes b/mcs/class/corlib/System.PAL/.gitattributes
deleted file mode 100644 (file)
index 98196ac..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/IOperatingSystem.cs -crlf
diff --git a/mcs/class/corlib/System.PAL/IOperatingSystem.cs b/mcs/class/corlib/System.PAL/IOperatingSystem.cs
deleted file mode 100644 (file)
index e4721a6..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-\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
-/*---------------------------------------------------------------------\r
-\r
-                XX                X                XXX\r
-                                 XX                 XX\r
-               XXX     XX XXX   XXXXX               XX\r
-                XX     XXX XX    XX                 XX\r
-                XX     XX  XX    XX      XXXXX      XX\r
-                XX     XX  XX    XX XX  XX    X     XX\r
-               XXXX    XX  XX     XXX   XXXXXXX    XXXX\r
-                                        XX\r
-                                         XXXXX\r
-\r
-Copyright (c) 2001 Intel Corporation.  All Rights Reserved.\r
-\r
-CREATED: August        08, 2001\r
-OWNER: Scott D Smith, Joel Marcey\r
-VERSION: 1.0\r
----------------------------------------------------------------------*/\r
-           \r
-\r
-using System;\r
-using System.IO;\r
-using System.Collections;\r
-\r
-namespace System.PlatformAbstractionLayer\r
-{\r
-       /// <summary>\r
-       ///     Definition of functionality needed by the library that can only be provided by the underlying OS. \r
-       /// </summary>\r
-       internal interface IOperatingSystem\r
-       {\r
-       \r
-               // System.IO services\r
-       \r
-               int ReadStdInput(byte[] buffer, int offset, int count);\r
-\r
-               void FlushStdOutput(byte[] byteBuf);\r
-\r
-\r
-\r
-               //  System.File services\r
-\r
-               int ReadFile(IntPtr handle, byte[] buffer, int offset, int count);\r
-\r
-               int WriteFile(IntPtr handle, byte[] buffer, int offset, int count);\r
-       \r
-               void FlushFile(IntPtr handle, byte[] byteBuf);\r
-       \r
-               int SetLengthFile(IntPtr handle, long length);\r
-\r
-               IntPtr OpenFile(string path, FileMode mode, FileAccess access, FileShare share);\r
-       \r
-               void CloseFile(IntPtr handle);\r
-       \r
-               long SeekFile(IntPtr handle, long offset, SeekOrigin origin);\r
-       \r
-               IntPtr CreateFile(string path, FileMode mode, FileAccess access, FileShare share);\r
-       \r
-               void DeleteFile(string path);\r
-       \r
-               bool ExistsFile(string path);\r
-       \r
-               DateTime GetCreationTimeFile(string path);\r
-       \r
-               DateTime GetLastAccessTimeFile(string path);\r
-       \r
-               DateTime GetLastWriteTimeFile(string path);\r
-       \r
-               void SetCreationTimeFile(string path, DateTime creationTime);\r
-       \r
-               void SetLastAccessTimeFile(string path, DateTime lastAccessTime);\r
-       \r
-               void SetLastWriteTimeFile(string path, DateTime lastWriteTime);\r
-\r
-               long FileLength(string path);\r
-\r
-               long FileLength(IntPtr handle);\r
-       \r
-\r
-               //  System.Environment services\r
-               \r
-               string NewLineSequence {get;}\r
-       \r
-               char DirectorySeparator {get;}\r
-       \r
-               char AltDirectorySeparator {get;}\r
-       \r
-               char PathSeparator {get;}\r
-       \r
-               char VolumeSeparator {get;}\r
-       \r
-               char[] DirVolSeparatorChars {get;}\r
-       \r
-               char[] InvalidPathChars {get;}\r
-       \r
-               string GetEnvironmentVariable(string eVar);\r
-       \r
-               char ExtensionCharacter {get;}\r
-\r
-               string CommandLine {get;}\r
-\r
-               IDictionary EnvironmentVariables {get;}\r
-\r
-               string MachineName {get;}\r
-       \r
-               OperatingSystem OSVersion {get;}\r
-\r
-               //  System.Path services\r
-               // Note: Although some of these do not require direct acccess to the OS,\r
-               // some platforms don't support some of these methods\r
-       \r
-               string ChangeExtension(string path, string extension);\r
-       \r
-               string GetExtension(string path);\r
-       \r
-               string GetFileName(string path);\r
-       \r
-               string GetFileNameWithoutExtension(string path);\r
-       \r
-               string GetPathRoot(string path);\r
-       \r
-               string GetTempFileName();\r
-       \r
-               string GetTempPath();\r
-       \r
-               bool HasExtension(string path);\r
-       \r
-               bool IsPathRooted(string path);\r
-       \r
-               string GetFullPath(string path);\r
-       \r
-       \r
-               //  System.Directory services\r
-       \r
-               void DeleteDirectory(string path, bool recursive);\r
-       \r
-               bool ExistsDirectory(string path);\r
-       \r
-               DateTime GetCreationTimeDirectory(string path);\r
-       \r
-               string GetCurrentDirectory();\r
-       \r
-               string[] GetDirectories(string path, string searchPattern);\r
-       \r
-               string[] GetFiles(string path, string searchPattern);\r
-       \r
-               string[] GetFileSystemEntries(string path, string searchPattern);\r
-       \r
-               DateTime GetLastAccessTimeDirectory(string path);\r
-       \r
-               DateTime GetLastWriteTimeDirectory(string path);\r
-       \r
-               void MoveDirectory(string sourceDirName, string destDirName);\r
-       \r
-               void SetCreationTimeDirectory(string path, DateTime creationTime);\r
-       \r
-               void SetCurrentDirectory(string path);\r
-       \r
-               void SetLastAccessTimeDirectory(string path, DateTime lastAccessTime);\r
-       \r
-               void SetLastWriteTimeDirectory(string path, DateTime lastWriteTime);\r
-\r
-               double Acos(double d);\r
-\r
-               double Asin(double d);\r
-\r
-               double Atan(double d);\r
-\r
-               double Atan2(double y, double x);\r
-\r
-               double Cos(double d);\r
-\r
-               double Cosh(double value);\r
-\r
-               double Exp(dobule d);\r
-\r
-               double Log(double d);\r
-\r
-               double Log10(double d);\r
-\r
-               double Pow(double x, double y);\r
-\r
-               double Sin(double d);\r
-\r
-               double Sinh(double d);\r
-\r
-               double Sqrt(double d);\r
-\r
-               double Tan(double d);\r
-\r
-               double Tanh(double d);\r
-               \r
-       }\r
-}\r
diff --git a/mcs/class/corlib/System.PAL/Platform.cs b/mcs/class/corlib/System.PAL/Platform.cs
deleted file mode 100644 (file)
index 21ff295..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// Sean MacIsaac
-// Only want to have 1 OperatingSystemObject around.
-// We get the correct one from compile time.
-
-//
-// 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.PAL
-{
-       internal class Platform
-       {
-               private static OpSys _os;
-
-               public static OpSys OS
-               {
-
-                       get
-                       {
-                               if (_os == null) {
-                                       _os = new OpSys ();
-                               }
-                               return _os;
-                       }
-               }
-       }
-}
index 206c3429d8d5632e17fc9fca10d52920a5a03b68..aee50509f8f299f121260c1a47ac362951d5d504 100644 (file)
@@ -141,45 +141,29 @@ namespace System
                {
 #if !NET_2_1
                        if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
-                               StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
-                               w.AutoFlush = true;
-                               stdout = TextWriter.Synchronized (w);
-
-                               w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
-                               w.AutoFlush = true;
-                               stderr = TextWriter.Synchronized (w);
-                               
                                stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
-                       } else {
+                               stdout = TextWriter.Synchronized (new CStreamWriter (OpenStandardOutput (0), outputEncoding, true) { AutoFlush = true });
+                               stderr = TextWriter.Synchronized (new CStreamWriter (OpenStandardError (0), outputEncoding, true) { AutoFlush = true });
+                       } else
 #endif
-#if MONOTOUCH
-                               stdout = new NSLogWriter ();
-#else
-                               stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
-                               ((StreamWriter)stdout).AutoFlush = true;
-#endif
-                               stdout = TextWriter.Synchronized (stdout);
+                       {
+                               stdin = TextReader.Synchronized (new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding));
 
 #if MONOTOUCH
+                               stdout = new NSLogWriter ();
                                stderr = new NSLogWriter ();
 #else
-                               stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
-                               ((StreamWriter)stderr).AutoFlush = true;
-#endif
-                               stderr = TextWriter.Synchronized (stderr);
-
-                               stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
-                               stdin = TextReader.Synchronized (stdin);
-#if !NET_2_1
-                       }
-#endif
+                               stdout = TextWriter.Synchronized (new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding) { AutoFlush = true });
+                               stderr = TextWriter.Synchronized (new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding) { AutoFlush = true });
 
 #if MONODROID
-                       if (LogcatTextWriter.IsRunningOnAndroid ()) {
-                               stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
-                               stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
+                               if (LogcatTextWriter.IsRunningOnAndroid ()) {
+                                       stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
+                                       stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
+                               }
+#endif // MONODROID
+#endif // MONOTOUCH
                        }
-#endif  // MONODROID
 
                        GC.SuppressFinalize (stdout);
                        GC.SuppressFinalize (stderr);
index 99e35c2fe7c5c9744b7d73e0d795fe95392c933d..ba03204a083f1d5dfa90ed7cc399345cb4fb2748 100644 (file)
@@ -896,8 +896,11 @@ namespace System {
                        throw new NotImplementedException ();
                }
 
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]
+               extern static bool GetIs64BitOperatingSystem ();
+
                public static bool Is64BitOperatingSystem {
-                       get { return IntPtr.Size == 8; } // FIXME: is this good enough?
+                       get { return GetIs64BitOperatingSystem (); }
                }
 
                public static int SystemPageSize {
index 41f2b229460786a00653b71f458f1a682e4efdc2..364a8b3f955944c029f0cfa67784d550a1643701 100644 (file)
@@ -428,10 +428,10 @@ namespace MonoTests.System.Globalization
                }
 
                [Test]
-               public void GetCultureInfo_Identifier_Negative ()
+               public void GetCultureInfo_Identifier_Nonpositive ()
                {
                        try {
-                               CultureInfo.GetCultureInfo (-1);
+                               CultureInfo.GetCultureInfo (0);
                                Assert.Fail ("#1");
                        } catch (ArgumentOutOfRangeException ex) {
                                Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
index 7708e84a39d1be8755091be53ecea8fd79861b3d..efd4683fd9a54ae28bb895574ee01a97adf9b0d3 100644 (file)
@@ -65,9 +65,11 @@ namespace MonoTests.System.Threading
                {
                        int called = 0;
                        var cts = new CancellationTokenSource ();
-                       cts.Token.Register (() => called++);
+                       var mre = new ManualResetEvent(false);
+                       cts.Token.Register (() => { called++; mre.Set (); });
                        cts.CancelAfter (20);
-                       Thread.Sleep (50);
+
+                       Assert.IsTrue(mre.WaitOne (1000), "Should be cancelled in ~20ms");
                        Assert.AreEqual (1, called, "#1");
                }
 
diff --git a/mcs/class/test-helpers/SocketResponder.cs b/mcs/class/test-helpers/SocketResponder.cs
new file mode 100644 (file)
index 0000000..40c9a37
--- /dev/null
@@ -0,0 +1,149 @@
+//
+// SocketResponder.cs - Utility class for tests that require a listener
+//
+// Author:
+//     Gert Driesen (drieseng@users.sourceforge.net)
+//
+// Copyright (C) 2007 Gert Driesen
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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.Globalization;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+
+namespace MonoTests.Helpers
+{
+       public delegate byte [] SocketRequestHandler (Socket socket);
+
+       public class SocketResponder : IDisposable
+       {
+               private TcpListener tcpListener;
+               private readonly IPEndPoint _localEndPoint;
+               private Thread listenThread;
+               private Socket listenSocket;
+               private SocketRequestHandler _requestHandler;
+               private int _state = 0;
+               private readonly object _syncRoot = new object ();
+
+               private const int SOCKET_CLOSED = 10004;
+               private const int SOCKET_INVALID_ARGS = 10022;
+
+               private const int STATE_UNINITIALIZED = 0;
+               private const int STATE_RUNNING = 1;
+               private const int STATE_STOPPED = 2;
+
+               public SocketResponder (IPEndPoint localEP, SocketRequestHandler requestHandler)
+               {
+                       _localEndPoint = localEP;
+                       _requestHandler = requestHandler;
+               }
+
+               public IPEndPoint LocalEndPoint
+               {
+                       get { return _localEndPoint; }
+               }
+
+               public void Dispose ()
+               {
+                       Stop ();
+               }
+
+               public bool IsStopped
+               {
+                       get
+                       {
+                               lock (_syncRoot) {
+                                       return _state != STATE_RUNNING;
+                               }
+                       }
+               }
+
+               public void Start ()
+               {
+                       lock (_syncRoot) {
+                               if (_state != STATE_UNINITIALIZED)
+                                       throw new InvalidOperationException ("cannot restart SocketResponder");
+                               _state = STATE_RUNNING;
+                               tcpListener = new TcpListener (LocalEndPoint);
+                               tcpListener.Start ();
+                               listenThread = new Thread (new ThreadStart (Listen));
+                               listenThread.Start ();
+                       }
+               }
+
+               public void Stop ()
+               {
+                       lock (_syncRoot) {
+                               if (_state != STATE_RUNNING)
+                                       return;
+                               _state = STATE_STOPPED;
+                               if (tcpListener != null) {
+                                       tcpListener.Stop ();
+                                       tcpListener = null;
+                                       if (listenSocket != null)
+                                               listenSocket.Close ();
+                                       Thread.Sleep (50);
+                               }
+                       }
+               }
+
+               private void Listen ()
+               {
+                       while (_state == STATE_RUNNING) {
+                               listenSocket = null;
+                               try {
+                                       listenSocket = tcpListener.AcceptSocket ();
+                                       listenSocket.Send (_requestHandler (listenSocket));
+                                       try {
+                                               listenSocket.Shutdown (SocketShutdown.Receive);
+                                               listenSocket.Shutdown (SocketShutdown.Send);
+                                       } catch {
+                                       }
+                               } catch (SocketException ex) {
+                                       // ignore interruption of blocking call
+                                       if (ex.ErrorCode != SOCKET_CLOSED && ex.ErrorCode != SOCKET_INVALID_ARGS && _state != STATE_STOPPED)
+                                               throw;
+                               } catch (ObjectDisposedException ex) {
+                                       Console.WriteLine (ex);
+                                       if (_state != STATE_STOPPED)
+                                               throw;
+#if MOBILE
+                               } catch (InvalidOperationException ex) {
+                                       // This breaks some tests running on Android. The problem is that the stack trace
+                                       // doesn't point to where the exception is actually thrown from but the entire process
+                                       // is aborted because of unhandled exception.
+                                       Console.WriteLine ("SocketResponder.Listen failed:");
+                                       Console.WriteLine (ex);
+#endif
+                               } finally {
+                                       Thread.Sleep (500);
+                                       if (listenSocket != null)
+                                               listenSocket.Close ();
+                               }
+                       }
+               }
+       }
+}
index 749c4efcb8a4c99e70920f64be7d008a068e2d51..b1d2993256a517fc96483d5be1af20d2b09f332c 100644 (file)
@@ -115,7 +115,16 @@ namespace Mono.CSharp {
                        const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type;
 
                        if (sn != null) {
-                               expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);
+                               var errors_printer = new SessionReportPrinter ();
+                               var old = rc.Report.SetPrinter (errors_printer);
+                               try {
+                                       expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity);
+                               } finally {
+                                       rc.Report.SetPrinter (old);
+                               }
+
+                               if (errors_printer.ErrorsCount != 0)
+                                       return null;
 
                                //
                                // Resolve expression which does have type set as we need expression type
index 5192cc102a3fb290bae7cafc60269ae20e9f72c0..5a21804888e50cc48994ff4c6c1f17adad148678 100644 (file)
@@ -12503,11 +12503,6 @@ namespace Mono.CSharp
                                str = start.Value;
                                arguments = new Arguments (1);
                        } else {
-                               for (int i = 0; i < interpolations.Count; i += 2) {
-                                       var ipi = (InterpolatedStringInsert)interpolations [i];
-                                       ipi.Resolve (rc);
-                               }
-       
                                arguments = new Arguments (interpolations.Count);
 
                                var sb = new StringBuilder (start.Value);
@@ -12528,7 +12523,7 @@ namespace Mono.CSharp
                                                }
 
                                                sb.Append ('}');
-                                               arguments.Add (new Argument (interpolations [i]));
+                                               arguments.Add (new Argument (isi.Resolve (rc)));
                                        } else {
                                                sb.Append (((StringLiteral)interpolations [i]).Value);
                                        }
index 13abbd67c67425faf5f9b3701068ea4c9a2aefc2..7b092135a2b09601d4e7d20a7ed471aac6799ea7 100644 (file)
@@ -1210,6 +1210,14 @@ namespace Mono.CSharp {
                                settings.RuntimeMetadataVersion = value;
                                return ParseResult.Success;
 
+                       // csc options that we don't support
+                       case "/utf8output":
+                       case "/subsystemversion":
+                       case "/highentropyva":
+                       case "/highentropyva+":
+                       case "/highentropyva-":
+                               return ParseResult.Success;
+
                        default:
                                return ParseResult.UnknownOption;
                        }
diff --git a/mcs/tests/dtest-063.cs b/mcs/tests/dtest-063.cs
new file mode 100644 (file)
index 0000000..50ecbf0
--- /dev/null
@@ -0,0 +1,15 @@
+using System;
+
+class InvalidILWhenInterpolatingDynamicObjectTest
+{
+       static int Main ()
+       {
+               dynamic d = 1;
+               var str = $"{d + 3}";
+               if (str != "4")
+                       return 1;
+
+               Console.WriteLine (str);
+               return 0;
+       }
+}
\ No newline at end of file
index b2352089203209034d84842f849045f7e04bd169..7cda6f85b7de9df0e7d3f25eb7d450bfad39d942 100644 (file)
       </method>
     </type>
   </test>
+  <test name="dtest-063.cs">
+    <type name="InvalidILWhenInterpolatingDynamicObjectTest">
+      <method name="Int32 Main()" attrs="145">
+        <size>142</size>
+      </method>
+      <method name="Void .ctor()" attrs="6278">
+        <size>7</size>
+      </method>
+    </type>
+  </test>
   <test name="dtest-anontype-01.cs">
     <type name="C">
       <method name="Void Main()" attrs="150">
index 607b1e09a19f834ef0f36ff27698ce010f76f51d..357a6d867a75bb0a6c4ea17965ef7c466bd57cfa 100644 (file)
@@ -10,7 +10,7 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>\r
     <RootNamespace>csharp</RootNamespace>\r
     <AssemblyName>csharp</AssemblyName>\r
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
     <FileAlignment>512</FileAlignment>\r
     <FileUpgradeFlags>\r
     </FileUpgradeFlags>\r
@@ -44,6 +44,7 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
     <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
     <Externalconsole>true</Externalconsole>\r
+    <ExternalConsole>true</ExternalConsole>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
     <DebugType>pdbonly</DebugType>\r
     <ErrorReport>prompt</ErrorReport>\r
     <WarningLevel>4</WarningLevel>\r
     <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
   </PropertyGroup>\r
   <ItemGroup>\r
     <Reference Include="System" />\r
     <Reference Include="System.Core">\r
-      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
     </Reference>\r
   </ItemGroup>\r
   <ItemGroup>\r
     </BootstrapperPackage>\r
   </ItemGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
   -->\r
 </Project>
\ No newline at end of file
index 068fe5d3178fb09cd40d919051aee03e07d6411e..d0783dec3ecaecec317e8fda21bb63c473b7e55b 100644 (file)
@@ -462,7 +462,7 @@ namespace Mono.Terminal {
                                        
                                        Console.ForegroundColor = selected ? ConsoleColor.Black : ConsoleColor.Gray;
                                        Console.BackgroundColor = selected ? ConsoleColor.Cyan : ConsoleColor.Blue;
-                                       
+
                                        var item = Prefix + Completions [item_idx];
                                        if (item.Length > Width)
                                                item = item.Substring (0, Width);
@@ -490,7 +490,7 @@ namespace Mono.Terminal {
                        {
                                if (selected_item+1 < Completions.Length){
                                        selected_item++;
-                                       if (selected_item + top_item >= Height)
+                                       if (selected_item - top_item >= Height)
                                                top_item++;
                                        SaveExcursion (DrawSelection);
                                }
@@ -1418,7 +1418,15 @@ namespace Mono.Terminal {
        class Demo {
                static void Main ()
                {
-                       LineEditor le = new LineEditor ("foo");
+                       LineEditor le = new LineEditor ("foo") {
+                               HeuristicsMode = "csharp"
+                       };
+                       le.AutoCompleteEvent += delegate (string a, int pos){
+                               string prefix = "";
+                               var completions = new string [] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" };
+                               return new Mono.Terminal.LineEditor.Completion (prefix, completions);
+                       };
+                       
                        string s;
                        
                        while ((s = le.Edit ("shell> ", "")) != null){
index 74c219a82b61bd5811c3b708350b6a85a7c19a92..0e99e810203cb39600c34ab5c6d2fc6c67ae4b35 100644 (file)
@@ -141,8 +141,11 @@ namespace Mono.Linker.Steps {
 
                void ProcessVirtualMethods ()
                {
-                       foreach (MethodDefinition method in _virtual_methods)
+                       foreach (MethodDefinition method in _virtual_methods) {
+                               Annotations.Push (method);
                                ProcessVirtualMethod (method);
+                               Annotations.Pop ();
+                       }
                }
 
                void ProcessVirtualMethod (MethodDefinition method)
@@ -193,17 +196,21 @@ namespace Mono.Linker.Steps {
 
                protected virtual void MarkCustomAttribute (CustomAttribute ca)
                {
+                       Annotations.Push (ca);
                        MarkMethod (ca.Constructor);
 
                        MarkCustomAttributeArguments (ca);
 
                        TypeReference constructor_type = ca.Constructor.DeclaringType;
                        TypeDefinition type = constructor_type.Resolve ();
-                       if (type == null)
+                       if (type == null) {
+                               Annotations.Pop ();
                                throw new ResolutionException (constructor_type);
+                       }
 
                        MarkCustomAttributeProperties (ca, type);
                        MarkCustomAttributeFields (ca, type);
+                       Annotations.Pop ();
                }
 
                protected void MarkSecurityDeclarations (ISecurityDeclarationProvider provider)
@@ -268,10 +275,12 @@ namespace Mono.Linker.Steps {
                protected void MarkCustomAttributeProperty (CustomAttributeNamedArgument namedArgument, TypeDefinition attribute)
                {
                        PropertyDefinition property = GetProperty (attribute, namedArgument.Name);
+                       Annotations.Push (property);
                        if (property != null)
                                MarkMethod (property.SetMethod);
 
                        MarkIfType (namedArgument.Argument);
+                       Annotations.Pop ();
                }
 
                PropertyDefinition GetProperty (TypeDefinition type, string propertyname)
@@ -634,8 +643,10 @@ namespace Mono.Linker.Steps {
                                if (property.Name != property_name)
                                        continue;
 
+                               Annotations.Push (property);
                                MarkMethod (property.GetMethod);
                                MarkMethod (property.SetMethod);
+                               Annotations.Pop ();
                        }
                }
 
@@ -695,8 +706,11 @@ namespace Mono.Linker.Steps {
                void MarkMethodsIf (ICollection methods, MethodPredicate predicate)
                {
                        foreach (MethodDefinition method in methods)
-                               if (predicate (method))
+                               if (predicate (method)) {
+                                       Annotations.Push (predicate);
                                        MarkMethod (method);
+                                       Annotations.Pop ();
+                               }
                }
 
                static MethodPredicate IsDefaultConstructorPredicate = new MethodPredicate (IsDefaultConstructor);
@@ -906,6 +920,7 @@ namespace Mono.Linker.Steps {
                        EnqueueMethod (method);
 
                        Annotations.Pop ();
+                       Annotations.AddDependency (method);
 
                        return method;
                }
@@ -944,6 +959,7 @@ namespace Mono.Linker.Steps {
                        if (CheckProcessed (method))
                                return;
 
+                       Annotations.Push (method);
                        MarkType (method.DeclaringType);
                        MarkCustomAttributes (method);
                        MarkSecurityDeclarations (method);
@@ -987,6 +1003,7 @@ namespace Mono.Linker.Steps {
                        Annotations.Mark (method);
 
                        ApplyPreserveMethods (method);
+                       Annotations.Pop ();
                }
 
                // Allow subclassers to mark additional things when marking a method
index 9f7872f7a7d9ec0cd976fcecc79368e3c9839707..61101809fd47af8f7320e2c926186f64972f380e 100644 (file)
@@ -88,13 +88,16 @@ namespace Mono.Tuner {
                                return;
 
                        for (int i = 0; i < provider.CustomAttributes.Count; i++) {
-                               if (!IsRemovedAttribute (provider.CustomAttributes [i]))
+                               var attrib = provider.CustomAttributes [i];
+                               if (!IsRemovedAttribute (attrib))
                                        continue;
 
+                               WillRemoveAttribute (provider, attrib);
                                provider.CustomAttributes.RemoveAt (i--);
                        }
                }
 
                protected abstract bool IsRemovedAttribute (CustomAttribute attribute);
+               protected virtual void WillRemoveAttribute (ICustomAttributeProvider provider, CustomAttribute attribute) { }
        }
 }
index b963eb6a053a15d5d108e3b3af96fe011c93fa32..fd819424978689f7d5fea4e464f58615f461498c 100644 (file)
@@ -17,6 +17,7 @@ OTHER_H = \
        events.h        \
        handles.h       \
        io.h            \
+       io-trace.h      \
        io-layer.h      \
        io-portability.h        \
        macros.h        \
index 3ad606bcebc95ebdf277e88344cc714b93237138..723982cc3934b78400c736ceed5b7ac1aa086c80 100644 (file)
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/event-private.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
 
 static void event_signal(gpointer handle);
 static gboolean event_own (gpointer handle);
@@ -111,7 +107,7 @@ static gboolean event_own (gpointer handle)
                return (FALSE);
        }
        
-       DEBUG("%s: owning event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning event handle %p", __func__, handle);
 
        if(event_handle->manual==FALSE) {
                g_assert (event_handle->set_count > 0);
@@ -135,7 +131,7 @@ static gboolean namedevent_own (gpointer handle)
        struct _WapiHandle_namedevent *namedevent_handle;
        gboolean ok;
        
-       DEBUG ("%s: owning named event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning named event handle %p", __func__, handle);
 
        ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDEVENT,
                                  (gpointer *)&namedevent_handle);
@@ -168,7 +164,7 @@ static gpointer event_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
         */
        SetLastError (ERROR_SUCCESS);
 
-       DEBUG ("%s: Creating unnamed event", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating unnamed event", __func__);
        
        event_handle.manual = manual;
        event_handle.set_count = 0;
@@ -193,7 +189,7 @@ static gpointer event_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
                _wapi_handle_set_signal_state (handle, TRUE, FALSE);
        }
        
-       DEBUG("%s: created new event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: created new event handle %p", __func__, handle);
 
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
@@ -227,7 +223,7 @@ static gpointer namedevent_create (WapiSecurityAttributes *security G_GNUC_UNUSE
        
        utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
        
-       DEBUG ("%s: Creating named event [%s]", __func__, utf8_name);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named event [%s]", __func__, utf8_name);
        
        offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
                                                utf8_name);
@@ -298,7 +294,7 @@ static gpointer namedevent_create (WapiSecurityAttributes *security G_GNUC_UNUSE
                _wapi_handle_unlock_shared_handles ();
        }
        
-       DEBUG ("%s: returning event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning event handle %p", __func__, handle);
 
 cleanup:
        g_free (utf8_name);
@@ -360,7 +356,7 @@ static gboolean event_pulse (gpointer handle)
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
 
-       DEBUG ("%s: Pulsing event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Pulsing event handle %p", __func__, handle);
 
        if (event_handle->manual == TRUE) {
                _wapi_handle_set_signal_state (handle, TRUE, TRUE);
@@ -385,7 +381,7 @@ static gboolean event_pulse (gpointer handle)
                 * have proceeded.  Currently we rely on broadcasting
                 * a condition.
                 */
-               DEBUG ("%s: Obtained write lock on event handle %p",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on event handle %p",
                           __func__, handle);
 
                thr_ret = _wapi_handle_lock_handle (handle);
@@ -417,7 +413,7 @@ static gboolean namedevent_pulse (gpointer handle)
        thr_ret = _wapi_handle_lock_shared_handles ();
        g_assert (thr_ret == 0);
 
-       DEBUG ("%s: Pulsing named event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Pulsing named event handle %p", __func__, handle);
 
        if (namedevent_handle->manual == TRUE) {
                _wapi_shared_handle_set_signal_state (handle, TRUE);
@@ -441,7 +437,7 @@ static gboolean namedevent_pulse (gpointer handle)
                 * have proceeded.  Currently we rely on waiting for
                 * twice the shared handle poll interval.
                 */
-               DEBUG ("%s: Obtained write lock on event handle %p",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on event handle %p",
                           __func__, handle);
 
                thr_ret = _wapi_handle_lock_shared_handles ();
@@ -503,16 +499,16 @@ static gboolean event_reset (gpointer handle)
                return(FALSE);
        }
 
-       DEBUG ("%s: Resetting event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Resetting event handle %p", __func__, handle);
 
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
        if (_wapi_handle_issignalled (handle) == FALSE) {
-               DEBUG ("%s: No need to reset event handle %p", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No need to reset event handle %p", __func__,
                           handle);
        } else {
-               DEBUG ("%s: Obtained write lock on event handle %p",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on event handle %p",
                           __func__, handle);
 
                _wapi_handle_set_signal_state (handle, FALSE, FALSE);
@@ -540,16 +536,16 @@ static gboolean namedevent_reset (gpointer handle)
                return(FALSE);
        }
 
-       DEBUG ("%s: Resetting named event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Resetting named event handle %p", __func__, handle);
 
        thr_ret = _wapi_handle_lock_shared_handles ();
        g_assert (thr_ret == 0);
        
        if (_wapi_handle_issignalled (handle) == FALSE) {
-               DEBUG ("%s: No need to reset named event handle %p",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No need to reset named event handle %p",
                           __func__, handle);
        } else {
-               DEBUG ("%s: Obtained write lock on named event handle %p",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Obtained write lock on named event handle %p",
                           __func__, handle);
 
                _wapi_shared_handle_set_signal_state (handle, FALSE);
@@ -607,7 +603,7 @@ static gboolean event_set (gpointer handle)
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
 
-       DEBUG ("%s: Setting event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Setting event handle %p", __func__, handle);
 
        if (event_handle->manual == TRUE) {
                _wapi_handle_set_signal_state (handle, TRUE, TRUE);
@@ -639,7 +635,7 @@ static gboolean namedevent_set (gpointer handle)
        thr_ret = _wapi_handle_lock_shared_handles ();
        g_assert (thr_ret == 0);
 
-       DEBUG ("%s: Setting named event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Setting named event handle %p", __func__, handle);
 
        if (namedevent_handle->manual == TRUE) {
                _wapi_shared_handle_set_signal_state (handle, TRUE);
@@ -704,7 +700,7 @@ gpointer OpenEvent (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED
 
        utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
        
-       DEBUG ("%s: Opening named event [%s]", __func__, utf8_name);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named event [%s]", __func__, utf8_name);
        
        offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
                                                utf8_name);
@@ -733,7 +729,7 @@ gpointer OpenEvent (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED
        }
        ret = handle;
 
-       DEBUG ("%s: returning named event handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named event handle %p", __func__, handle);
 
 cleanup:
        g_free (utf8_name);
index f92b6566d8c4886f5e88bd1f40facfc4e44c8bf9..3cb0a73d5785d8941318152625124b807ee374c8 100644 (file)
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/shared.h>
 #include <mono/io-layer/process-private.h>
+#include <mono/io-layer/io-trace.h>
 
 #include <mono/utils/mono-os-mutex.h>
 #include <mono/utils/mono-proclib.h>
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
 #undef DEBUG_REFS
 
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
 static void (*_wapi_handle_ops_get_close_func (WapiHandleType type))(gpointer, gpointer);
 
 static WapiHandleCapability handle_caps[WAPI_HANDLE_COUNT] = { (WapiHandleCapability)0 };
@@ -193,8 +189,6 @@ static void handle_cleanup (void)
                        gpointer handle = GINT_TO_POINTER (i*_WAPI_HANDLE_INITIAL_COUNT+j);
 
                        for(k = handle_data->ref; k > 0; k--) {
-                               DEBUG ("%s: unreffing %s handle %p", __func__, _wapi_handle_typename[type], handle);
-                                       
                                _wapi_handle_unref_full (handle, TRUE);
                        }
                }
@@ -483,7 +477,7 @@ _wapi_handle_new (WapiHandleType type, gpointer handle_specific)
 
        g_assert (_wapi_has_shut_down == FALSE);
                
-       DEBUG ("%s: Creating new handle of type %s", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s", __func__,
                   _wapi_handle_typename[type]);
 
        g_assert(!_WAPI_FD_HANDLE(type));
@@ -519,7 +513,7 @@ _wapi_handle_new (WapiHandleType type, gpointer handle_specific)
        
        handle = GUINT_TO_POINTER (handle_idx);
 
-       DEBUG ("%s: Allocated new handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Allocated new handle %p", __func__, handle);
        
        if (_WAPI_SHARED_HANDLE(type)) {
                /* Add the shared section too */
@@ -536,7 +530,7 @@ _wapi_handle_new (WapiHandleType type, gpointer handle_specific)
                }
                
                _WAPI_PRIVATE_HANDLES(handle_idx).u.shared.offset = ref;
-               DEBUG ("%s: New shared handle at offset 0x%x", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New shared handle at offset 0x%x", __func__,
                           ref);
        }
                
@@ -554,7 +548,7 @@ gpointer _wapi_handle_new_from_offset (WapiHandleType type, guint32 offset,
        
        g_assert (_wapi_has_shut_down == FALSE);
        
-       DEBUG ("%s: Creating new handle of type %s to offset %d", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s to offset %d", __func__,
                   _wapi_handle_typename[type], offset);
 
        g_assert(!_WAPI_FD_HANDLE(type));
@@ -592,7 +586,7 @@ first_pass_done:
        if (handle != INVALID_HANDLE_VALUE) {
                _wapi_handle_ref (handle);
 
-               DEBUG ("%s: Returning old handle %p referencing 0x%x",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning old handle %p referencing 0x%x",
                           __func__, handle, offset);
                return (handle);
        }
@@ -603,12 +597,12 @@ first_pass_done:
        
        if (shared->type == WAPI_HANDLE_UNUSED) {
                /* Someone deleted this handle while we were working */
-               DEBUG ("%s: Handle at 0x%x unused", __func__, offset);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle at 0x%x unused", __func__, offset);
                goto done;
        }
 
        if (shared->type != type) {
-               DEBUG ("%s: Wrong type at %d 0x%x! Found %s wanted %s",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Wrong type at %d 0x%x! Found %s wanted %s",
                           __func__, offset, offset,
                           _wapi_handle_typename[shared->type],
                           _wapi_handle_typename[type]);
@@ -639,7 +633,7 @@ first_pass_done:
        _WAPI_PRIVATE_HANDLES(handle_idx).u.shared.offset = offset;
        InterlockedIncrement ((gint32 *)&shared->handle_refs);
        
-       DEBUG ("%s: Allocated new handle %p referencing 0x%x (shared refs %d)", __func__, handle, offset, shared->handle_refs);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Allocated new handle %p referencing 0x%x (shared refs %d)", __func__, handle, offset, shared->handle_refs);
        
 done:
        _wapi_handle_unlock_shared_handles ();
@@ -673,14 +667,14 @@ gpointer _wapi_handle_new_fd (WapiHandleType type, int fd,
        
        g_assert (_wapi_has_shut_down == FALSE);
        
-       DEBUG ("%s: Creating new handle of type %s", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating new handle of type %s", __func__,
                   _wapi_handle_typename[type]);
        
        g_assert(_WAPI_FD_HANDLE(type));
        g_assert(!_WAPI_SHARED_HANDLE(type));
        
        if (fd >= _wapi_fd_reserve) {
-               DEBUG ("%s: fd %d is too big", __func__, fd);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fd %d is too big", __func__, fd);
 
                return(GUINT_TO_POINTER (_WAPI_HANDLE_INVALID));
        }
@@ -692,13 +686,13 @@ gpointer _wapi_handle_new_fd (WapiHandleType type, int fd,
        handle = &_WAPI_PRIVATE_HANDLES(fd);
        
        if (handle->type != WAPI_HANDLE_UNUSED) {
-               DEBUG ("%s: fd %d is already in use!", __func__, fd);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fd %d is already in use!", __func__, fd);
                /* FIXME: clean up this handle?  We can't do anything
                 * with the fd, cos thats the new one
                 */
        }
 
-       DEBUG ("%s: Assigning new fd handle %d", __func__, fd);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Assigning new fd handle %d", __func__, fd);
 
        /* Prevent file share entries racing with us, when the file
         * handle is only half initialised
@@ -840,7 +834,7 @@ gpointer _wapi_search_handle (WapiHandleType type,
 
        if (!found && search_shared && _WAPI_SHARED_HANDLE (type)) {
                /* Not found yet, so search the shared memory too */
-               DEBUG ("%s: Looking at other shared handles...", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Looking at other shared handles...", __func__);
 
                for (i = 0; i < _WAPI_HANDLE_INITIAL_COUNT; i++) {
                        shared = &_wapi_shared_layout->handles[i];
@@ -861,7 +855,7 @@ gpointer _wapi_search_handle (WapiHandleType type,
                                        continue;
                                }
                                
-                               DEBUG ("%s: Opened tmp handle %p (type %s) from offset %d", __func__, ret, _wapi_handle_typename[type], i);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opened tmp handle %p (type %s) from offset %d", __func__, ret, _wapi_handle_typename[type], i);
 
                                /* It's possible that the shared part
                                 * of this handle has now been blown
@@ -938,7 +932,7 @@ gint32 _wapi_search_handle_namespace (WapiHandleType type,
        
        g_assert(_WAPI_SHARED_HANDLE(type));
        
-       DEBUG ("%s: Lookup for handle named [%s] type %s", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Lookup for handle named [%s] type %s", __func__,
                   utf8_name, _wapi_handle_typename[type]);
 
        thr_ret = _wapi_handle_lock_shared_handles ();
@@ -957,20 +951,20 @@ gint32 _wapi_search_handle_namespace (WapiHandleType type,
                        continue;
                }
 
-               DEBUG ("%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
 
                sharedns=(WapiSharedNamespace *)&shared_handle_data->u;
                        
-               DEBUG ("%s: name is [%s]", __func__, sharedns->name);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is [%s]", __func__, sharedns->name);
 
                if (strcmp (sharedns->name, utf8_name) == 0) {
                        if (shared_handle_data->type != type) {
                                /* Its the wrong type, so fail now */
-                               DEBUG ("%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
                                ret = -1;
                                goto done;
                        } else {
-                               DEBUG ("%s: handle 0x%x matches name and type", __func__, i);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x matches name and type", __func__, i);
                                ret = i;
                                goto done;
                        }
@@ -1076,7 +1070,7 @@ static void _wapi_handle_unref_full (gpointer handle, gboolean ignore_private_bu
                
                thr_ret = mono_os_mutex_lock (&scan_mutex);
 
-               DEBUG ("%s: Destroying handle %p", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Destroying handle %p", __func__, handle);
                
                memcpy (&handle_data, &_WAPI_PRIVATE_HANDLES(idx),
                        sizeof (struct _WapiHandleUnshared));
@@ -1169,7 +1163,7 @@ gboolean _wapi_handle_test_capabilities (gpointer handle,
        
        type = _WAPI_PRIVATE_HANDLES(idx).type;
 
-       DEBUG ("%s: testing 0x%x against 0x%x (%d)", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing 0x%x against 0x%x (%d)", __func__,
                   handle_caps[type], caps, handle_caps[type] & caps);
        
        return((handle_caps[type] & caps) != 0);
@@ -1370,7 +1364,7 @@ again:
                gpointer handle = handles[i];
                guint32 idx = GPOINTER_TO_UINT(handle);
 
-               DEBUG ("%s: attempting to lock %p", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempting to lock %p", __func__, handle);
 
                type = _WAPI_PRIVATE_HANDLES(idx).type;
 
@@ -1379,7 +1373,7 @@ again:
                if (thr_ret != 0) {
                        /* Bummer */
                        
-                       DEBUG ("%s: attempt failed for %p: %s", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt failed for %p: %s", __func__,
                                   handle, strerror (thr_ret));
 
                        thr_ret = _wapi_handle_unlock_shared_handles ();
@@ -1404,7 +1398,7 @@ again:
                                iter=1;
                        }
                        
-                       DEBUG ("%s: Backing off for %d ms", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Backing off for %d ms", __func__,
                                   iter*10);
                        _wapi_handle_spin (10 * iter);
                        
@@ -1412,7 +1406,7 @@ again:
                }
        }
        
-       DEBUG ("%s: Locked all handles", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locked all handles", __func__);
 
        count=0;
        *lowest=numhandles;
@@ -1423,7 +1417,7 @@ again:
                
                type = _WAPI_PRIVATE_HANDLES(idx).type;
 
-               DEBUG ("%s: Checking handle %p", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Checking handle %p", __func__, handle);
 
                if(((_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_OWN)==TRUE) &&
                    (_wapi_handle_ops_isowned (handle) == TRUE)) ||
@@ -1433,7 +1427,7 @@ again:
                    _WAPI_PRIVATE_HANDLES(idx).signalled == TRUE)) {
                        count++;
                        
-                       DEBUG ("%s: Handle %p signalled", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %p signalled", __func__,
                                   handle);
                        if(*lowest>i) {
                                *lowest=i;
@@ -1441,7 +1435,7 @@ again:
                }
        }
        
-       DEBUG ("%s: %d event handles signalled", __func__, count);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %d event handles signalled", __func__, count);
 
        if ((waitall == TRUE && count == numhandles) ||
            (waitall == FALSE && count > 0)) {
@@ -1450,7 +1444,7 @@ again:
                ret=FALSE;
        }
        
-       DEBUG ("%s: Returning %d", __func__, ret);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning %d", __func__, ret);
 
        *retcount=count;
        
@@ -1468,7 +1462,7 @@ void _wapi_handle_unlock_handles (guint32 numhandles, gpointer *handles)
        for(i=0; i<numhandles; i++) {
                gpointer handle = handles[i];
                
-               DEBUG ("%s: unlocking handle %p", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handle %p", __func__, handle);
 
                thr_ret = _wapi_handle_unlock_handle (handle);
                g_assert (thr_ret == 0);
@@ -1509,7 +1503,7 @@ signal_handle_and_unref (gpointer handle)
 int
 _wapi_handle_timedwait_signal_handle (gpointer handle, guint32 timeout, gboolean alertable, gboolean poll, gboolean *alerted)
 {
-       DEBUG ("%s: waiting for %p (type %s)", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: waiting for %p (type %s)", __func__, handle,
                   _wapi_handle_typename[_wapi_handle_type (handle)]);
 
        if (alertable)
@@ -1707,7 +1701,7 @@ static void _wapi_handle_check_share_by_pid (struct _WapiFileShare *share_info)
                 * owned by someone else) so mark this share info as
                 * dead
                 */
-               DEBUG ("%s: Didn't find it, destroying entry", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find it, destroying entry", __func__);
 
                _wapi_free_share_info (share_info);
        }
@@ -1756,7 +1750,7 @@ void _wapi_handle_check_share (struct _WapiFileShare *share_info, int fd)
                                struct _WapiHandle_file *file_handle = &handle->u.file;
 
                                if (file_handle->share_info == share_info) {
-                                       DEBUG ("%s: handle 0x%x has this file open!",
+                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle 0x%x has this file open!",
                                                           __func__, i);
 
                                        goto done;
@@ -1769,7 +1763,7 @@ void _wapi_handle_check_share (struct _WapiFileShare *share_info, int fd)
                _wapi_handle_check_share_by_pid (share_info);
        } else if (found == FALSE) {
                /* Blank out this entry, as it is stale */
-               DEBUG ("%s: Didn't find it, destroying entry", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find it, destroying entry", __func__);
 
                _wapi_free_share_info (share_info);
        }
diff --git a/mono/io-layer/io-trace.h b/mono/io-layer/io-trace.h
new file mode 100644 (file)
index 0000000..51f60f4
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * io-trace.h: tracing macros
+ *
+ * Authors:
+ *  Marek Habersack <grendel@twistedcode.net>
+ *
+ * Copyright 2016 Xamarin, Inc (http://xamarin.com/)
+ */
+
+#ifndef __IO_TRACE_H
+
+#ifdef DISABLE_IO_LAYER_TRACE
+#define MONO_TRACE(...)
+#else
+#define MONO_TRACE(...) mono_trace (__VA_ARGS__)
+#endif
+
+#endif
index e06a61aa9d514437d02dae2e7f62b8199b8dca63..c2e6a4e1906c1bfb59ea180dc16ba9a812f1d137 100644 (file)
 #include <mono/io-layer/timefuncs-private.h>
 #include <mono/io-layer/thread-private.h>
 #include <mono/io-layer/io-portability.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/strenc.h>
 #include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#define DEBUG_ENABLED 1
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
 
 static void file_close (gpointer handle, gpointer data);
 static WapiFileType file_getfiletype(void);
@@ -367,7 +362,7 @@ static void file_close (gpointer handle, gpointer data)
        struct _WapiHandle_file *file_handle = (struct _WapiHandle_file *)data;
        int fd = file_handle->fd;
        
-       DEBUG("%s: closing file handle %p [%s]", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing file handle %p [%s]", __func__, handle,
                  file_handle->filename);
 
        if (file_handle->attrs & FILE_FLAG_DELETE_ON_CLOSE)
@@ -410,7 +405,7 @@ static gboolean file_read(gpointer handle, gpointer buffer,
        
        if(!(file_handle->fileaccess & GENERIC_READ) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
                          __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
@@ -425,7 +420,7 @@ static gboolean file_read(gpointer handle, gpointer buffer,
        if(ret==-1) {
                gint err = errno;
 
-               DEBUG("%s: read of handle %p error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
                          handle, strerror(err));
                SetLastError (_wapi_get_win32_file_error (err));
                return(FALSE);
@@ -464,7 +459,7 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
        
        if(!(file_handle->fileaccess & GENERIC_WRITE) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
@@ -477,7 +472,7 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
                 */
                current_pos = lseek (fd, (off_t)0, SEEK_CUR);
                if (current_pos == -1) {
-                       DEBUG ("%s: handle %p lseek failed: %s", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
                                   handle, strerror (errno));
                        _wapi_set_last_error_from_errno ();
                        return(FALSE);
@@ -505,7 +500,7 @@ static gboolean file_write(gpointer handle, gconstpointer buffer,
                } else {
                        _wapi_set_last_error_from_errno ();
                                
-                       DEBUG("%s: write of handle %p error: %s",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
                                  __func__, handle, strerror(errno));
 
                        return(FALSE);
@@ -536,7 +531,7 @@ static gboolean file_flush(gpointer handle)
 
        if(!(file_handle->fileaccess & GENERIC_WRITE) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
@@ -544,7 +539,7 @@ static gboolean file_flush(gpointer handle)
 
        ret=fsync(fd);
        if (ret==-1) {
-               DEBUG("%s: fsync of handle %p error: %s", __func__, handle,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fsync of handle %p error: %s", __func__, handle,
                          strerror(errno));
 
                _wapi_set_last_error_from_errno ();
@@ -577,7 +572,7 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
        if(!(file_handle->fileaccess & GENERIC_READ) &&
           !(file_handle->fileaccess & GENERIC_WRITE) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(INVALID_SET_FILE_POINTER);
@@ -594,7 +589,7 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
                whence=SEEK_END;
                break;
        default:
-               DEBUG("%s: invalid seek type %d", __func__, method);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: invalid seek type %d", __func__, method);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return(INVALID_SET_FILE_POINTER);
@@ -603,18 +598,18 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
 #ifdef HAVE_LARGE_FILE_SUPPORT
        if(highmovedistance==NULL) {
                offset=movedistance;
-               DEBUG("%s: setting offset to %lld (low %d)", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld (low %d)", __func__,
                          offset, movedistance);
        } else {
                offset=((gint64) *highmovedistance << 32) | (guint32)movedistance;
                
-               DEBUG("%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
        }
 #else
        offset=movedistance;
 #endif
 
-       DEBUG ("%s: moving handle %p by %lld bytes from %d", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: moving handle %p by %lld bytes from %d", __func__,
                   handle, (long long)offset, whence);
 
 #ifdef PLATFORM_ANDROID
@@ -624,14 +619,14 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
        newpos=lseek(fd, offset, whence);
 #endif
        if(newpos==-1) {
-               DEBUG("%s: lseek on handle %p returned error %s",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek on handle %p returned error %s",
                          __func__, handle, strerror(errno));
 
                _wapi_set_last_error_from_errno ();
                return(INVALID_SET_FILE_POINTER);
        }
 
-       DEBUG ("%s: lseek returns %lld", __func__, newpos);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lseek returns %lld", __func__, newpos);
 
 #ifdef HAVE_LARGE_FILE_SUPPORT
        ret=newpos & 0xFFFFFFFF;
@@ -646,7 +641,7 @@ static guint32 file_seek(gpointer handle, gint32 movedistance,
        }
 #endif
 
-       DEBUG ("%s: move of handle %p returning %d/%d", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: move of handle %p returning %d/%d", __func__,
                   handle, ret, highmovedistance==NULL?0:*highmovedistance);
 
        return(ret);
@@ -672,7 +667,7 @@ static gboolean file_setendoffile(gpointer handle)
        
        if(!(file_handle->fileaccess & GENERIC_WRITE) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
@@ -686,7 +681,7 @@ static gboolean file_setendoffile(gpointer handle)
        
        ret=fstat(fd, &statbuf);
        if(ret==-1) {
-               DEBUG ("%s: handle %p fstat failed: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
                           handle, strerror(errno));
 
                _wapi_set_last_error_from_errno ();
@@ -695,7 +690,7 @@ static gboolean file_setendoffile(gpointer handle)
 
        pos=lseek(fd, (off_t)0, SEEK_CUR);
        if(pos==-1) {
-               DEBUG("%s: handle %p lseek failed: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p lseek failed: %s", __func__,
                          handle, strerror(errno));
 
                _wapi_set_last_error_from_errno ();
@@ -722,7 +717,7 @@ static gboolean file_setendoffile(gpointer handle)
                         !_wapi_thread_cur_apc_pending());
 
                if(ret==-1) {
-                       DEBUG("%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
 
                        _wapi_set_last_error_from_errno ();
                        return(FALSE);
@@ -731,7 +726,7 @@ static gboolean file_setendoffile(gpointer handle)
                /* And put the file position back after the write */
                ret = lseek (fd, pos, SEEK_SET);
                if (ret == -1) {
-                       DEBUG ("%s: handle %p second lseek failed: %s",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p second lseek failed: %s",
                                   __func__, handle, strerror(errno));
 
                        _wapi_set_last_error_from_errno ();
@@ -750,7 +745,7 @@ static gboolean file_setendoffile(gpointer handle)
        }
        while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending()); 
        if(ret==-1) {
-               DEBUG("%s: handle %p ftruncate failed: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ftruncate failed: %s", __func__,
                          handle, strerror(errno));
                
                _wapi_set_last_error_from_errno ();
@@ -783,7 +778,7 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
        if(!(file_handle->fileaccess & GENERIC_READ) &&
           !(file_handle->fileaccess & GENERIC_WRITE) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(INVALID_FILE_SIZE);
@@ -797,7 +792,7 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
        
        ret = fstat(fd, &statbuf);
        if (ret == -1) {
-               DEBUG ("%s: handle %p fstat failed: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__,
                           handle, strerror(errno));
 
                _wapi_set_last_error_from_errno ();
@@ -809,7 +804,7 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
        if (S_ISBLK(statbuf.st_mode)) {
                guint64 bigsize;
                if (ioctl(fd, BLKGETSIZE64, &bigsize) < 0) {
-                       DEBUG ("%s: handle %p ioctl BLKGETSIZE64 failed: %s",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p ioctl BLKGETSIZE64 failed: %s",
                                   __func__, handle, strerror(errno));
 
                        _wapi_set_last_error_from_errno ();
@@ -821,7 +816,7 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
                        *highsize = bigsize>>32;
                }
 
-               DEBUG ("%s: Returning block device size %d/%d",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning block device size %d/%d",
                           __func__, size, *highsize);
        
                return(size);
@@ -841,7 +836,7 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
        size = statbuf.st_size;
 #endif
 
-       DEBUG ("%s: Returning size %d/%d", __func__, size, *highsize);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning size %d/%d", __func__, size, *highsize);
        
        return(size);
 }
@@ -868,7 +863,7 @@ static gboolean file_getfiletime(gpointer handle, WapiFileTime *create_time,
 
        if(!(file_handle->fileaccess & GENERIC_READ) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
                          __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
@@ -877,14 +872,14 @@ static gboolean file_getfiletime(gpointer handle, WapiFileTime *create_time,
        
        ret=fstat(fd, &statbuf);
        if(ret==-1) {
-               DEBUG("%s: handle %p fstat failed: %s", __func__, handle,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
                          strerror(errno));
 
                _wapi_set_last_error_from_errno ();
                return(FALSE);
        }
 
-       DEBUG("%s: atime: %ld ctime: %ld mtime: %ld", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: atime: %ld ctime: %ld mtime: %ld", __func__,
                  statbuf.st_atime, statbuf.st_ctime,
                  statbuf.st_mtime);
 
@@ -905,7 +900,7 @@ static gboolean file_getfiletime(gpointer handle, WapiFileTime *create_time,
        access_ticks=((guint64)statbuf.st_atime*10000000)+116444736000000000ULL;
        write_ticks=((guint64)statbuf.st_mtime*10000000)+116444736000000000ULL;
        
-       DEBUG("%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
                  access_ticks, create_ticks, write_ticks);
 
        if(create_time!=NULL) {
@@ -950,14 +945,14 @@ static gboolean file_setfiletime(gpointer handle,
        
        if(!(file_handle->fileaccess & GENERIC_WRITE) &&
           !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
        }
 
        if(file_handle->filename == NULL) {
-               DEBUG("%s: handle %p unknown filename", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p unknown filename", __func__, handle);
 
                SetLastError (ERROR_INVALID_HANDLE);
                return(FALSE);
@@ -968,7 +963,7 @@ static gboolean file_setfiletime(gpointer handle,
         */
        ret=fstat (fd, &statbuf);
        if(ret==-1) {
-               DEBUG("%s: handle %p fstat failed: %s", __func__, handle,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p fstat failed: %s", __func__, handle,
                          strerror(errno));
 
                SetLastError (ERROR_INVALID_PARAMETER);
@@ -982,7 +977,7 @@ static gboolean file_setfiletime(gpointer handle,
                 * but this will do for now.
                 */
                if (access_ticks < 116444736000000000ULL) {
-                       DEBUG ("%s: attempt to set access time too early",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set access time too early",
                                   __func__);
                        SetLastError (ERROR_INVALID_PARAMETER);
                        return(FALSE);
@@ -1000,7 +995,7 @@ static gboolean file_setfiletime(gpointer handle,
                 * but this will do for now.
                 */
                if (write_ticks < 116444736000000000ULL) {
-                       DEBUG ("%s: attempt to set write time too early",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: attempt to set write time too early",
                                   __func__);
                        SetLastError (ERROR_INVALID_PARAMETER);
                        return(FALSE);
@@ -1011,12 +1006,12 @@ static gboolean file_setfiletime(gpointer handle,
                utbuf.modtime=statbuf.st_mtime;
        }
 
-       DEBUG ("%s: setting handle %p access %ld write %ld", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setting handle %p access %ld write %ld", __func__,
                   handle, utbuf.actime, utbuf.modtime);
 
        ret = _wapi_utime (file_handle->filename, &utbuf);
        if (ret == -1) {
-               DEBUG ("%s: handle %p [%s] utime failed: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p [%s] utime failed: %s", __func__,
                           handle, file_handle->filename, strerror(errno));
 
                SetLastError (ERROR_INVALID_PARAMETER);
@@ -1031,7 +1026,7 @@ static void console_close (gpointer handle, gpointer data)
        struct _WapiHandle_file *console_handle = (struct _WapiHandle_file *)data;
        int fd = console_handle->fd;
        
-       DEBUG("%s: closing console handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing console handle %p", __func__, handle);
 
        g_free (console_handle->filename);
 
@@ -1068,7 +1063,7 @@ static gboolean console_read(gpointer handle, gpointer buffer,
        
        if(!(console_handle->fileaccess & GENERIC_READ) &&
           !(console_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG ("%s: handle %p doesn't have GENERIC_READ access: %u",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
                           __func__, handle, console_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
@@ -1080,7 +1075,7 @@ static gboolean console_read(gpointer handle, gpointer buffer,
        } while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
 
        if(ret==-1) {
-               DEBUG("%s: read of handle %p error: %s", __func__, handle,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__, handle,
                          strerror(errno));
 
                _wapi_set_last_error_from_errno ();
@@ -1118,7 +1113,7 @@ static gboolean console_write(gpointer handle, gconstpointer buffer,
        
        if(!(console_handle->fileaccess & GENERIC_WRITE) &&
           !(console_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
@@ -1135,7 +1130,7 @@ static gboolean console_write(gpointer handle, gconstpointer buffer,
                } else {
                        _wapi_set_last_error_from_errno ();
                        
-                       DEBUG ("%s: write of handle %p error: %s",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s",
                                   __func__, handle, strerror(errno));
 
                        return(FALSE);
@@ -1153,7 +1148,7 @@ static void pipe_close (gpointer handle, gpointer data)
        struct _WapiHandle_file *pipe_handle = (struct _WapiHandle_file*)data;
        int fd = pipe_handle->fd;
 
-       DEBUG("%s: closing pipe handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing pipe handle %p", __func__, handle);
 
        /* No filename with pipe handles */
 
@@ -1189,14 +1184,14 @@ static gboolean pipe_read (gpointer handle, gpointer buffer,
        
        if(!(pipe_handle->fileaccess & GENERIC_READ) &&
           !(pipe_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ access: %u",
                          __func__, handle, pipe_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
        }
        
-       DEBUG ("%s: reading up to %d bytes from pipe %p", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: reading up to %d bytes from pipe %p", __func__,
                   numbytes, handle);
 
        do {
@@ -1209,14 +1204,14 @@ static gboolean pipe_read (gpointer handle, gpointer buffer,
                } else {
                        _wapi_set_last_error_from_errno ();
                        
-                       DEBUG("%s: read of handle %p error: %s", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read of handle %p error: %s", __func__,
                                  handle, strerror(errno));
 
                        return(FALSE);
                }
        }
        
-       DEBUG ("%s: read %d bytes from pipe", __func__, ret);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: read %d bytes from pipe", __func__, ret);
 
        if(bytesread!=NULL) {
                *bytesread=ret;
@@ -1249,13 +1244,13 @@ static gboolean pipe_write(gpointer handle, gconstpointer buffer,
        
        if(!(pipe_handle->fileaccess & GENERIC_WRITE) &&
           !(pipe_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
 
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
        }
        
-       DEBUG ("%s: writing up to %d bytes to pipe %p", __func__, numbytes,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: writing up to %d bytes to pipe %p", __func__, numbytes,
                   handle);
 
        do {
@@ -1269,7 +1264,7 @@ static gboolean pipe_write(gpointer handle, gconstpointer buffer,
                } else {
                        _wapi_set_last_error_from_errno ();
                        
-                       DEBUG("%s: write of handle %p error: %s", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write of handle %p error: %s", __func__,
                                  handle, strerror(errno));
 
                        return(FALSE);
@@ -1297,7 +1292,7 @@ static int convert_flags(guint32 fileaccess, guint32 createmode)
                flags=O_RDWR;
                break;
        default:
-               DEBUG("%s: Unknown access type 0x%x", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown access type 0x%x", __func__,
                          fileaccess);
                break;
        }
@@ -1318,7 +1313,7 @@ static int convert_flags(guint32 fileaccess, guint32 createmode)
                flags|=O_TRUNC;
                break;
        default:
-               DEBUG("%s: Unknown create mode 0x%x", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unknown create mode 0x%x", __func__,
                          createmode);
                break;
        }
@@ -1358,7 +1353,7 @@ static gboolean share_allows_open (struct stat *statbuf, guint32 sharemode,
                 */
                if (file_existing_share == 0) {
                        /* Quick and easy, no possibility to share */
-                       DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
 
                        _wapi_handle_share_release (*share_info);
                        
@@ -1370,7 +1365,7 @@ static gboolean share_allows_open (struct stat *statbuf, guint32 sharemode,
                    ((file_existing_share == FILE_SHARE_WRITE) &&
                     (fileaccess != GENERIC_WRITE))) {
                        /* New access mode doesn't match up */
-                       DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
 
                        _wapi_handle_share_release (*share_info);
                
@@ -1382,14 +1377,14 @@ static gboolean share_allows_open (struct stat *statbuf, guint32 sharemode,
                    ((file_existing_access & GENERIC_WRITE) &&
                     !(sharemode & FILE_SHARE_WRITE))) {
                        /* New share mode doesn't match up */
-                       DEBUG ("%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
 
                        _wapi_handle_share_release (*share_info);
                
                        return(FALSE);
                }
        } else {
-               DEBUG ("%s: New file!", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
        }
 
        return(TRUE);
@@ -1411,7 +1406,7 @@ share_allows_delete (struct stat *statbuf, struct _WapiFileShare **share_info)
                 */
                if (file_existing_share == 0) {
                        /* Quick and easy, no possibility to share */
-                       DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, (*share_info)->access);
 
                        _wapi_handle_share_release (*share_info);
 
@@ -1420,14 +1415,14 @@ share_allows_delete (struct stat *statbuf, struct _WapiFileShare **share_info)
 
                if (!(file_existing_share & FILE_SHARE_DELETE)) {
                        /* New access mode doesn't match up */
-                       DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, (*share_info)->access, file_existing_share);
 
                        _wapi_handle_share_release (*share_info);
 
                        return(FALSE);
                }
        } else {
-               DEBUG ("%s: New file!", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: New file!", __func__);
        }
 
        return(TRUE);
@@ -1514,7 +1509,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
        }
        
        if (name == NULL) {
-               DEBUG ("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(INVALID_HANDLE_VALUE);
@@ -1522,13 +1517,13 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
 
        filename = mono_unicode_to_external (name);
        if (filename == NULL) {
-               DEBUG("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(INVALID_HANDLE_VALUE);
        }
        
-       DEBUG ("%s: Opening %s with share 0x%x and access 0x%x", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening %s with share 0x%x and access 0x%x", __func__,
                   filename, sharemode, fileaccess);
        
        fd = _wapi_open (filename, flags, perms);
@@ -1548,7 +1543,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
        }
        
        if (fd == -1) {
-               DEBUG("%s: Error opening file %s: %s", __func__, filename,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename,
                          strerror(errno));
                _wapi_set_last_path_error_from_errno (NULL, filename);
                g_free (filename);
@@ -1557,7 +1552,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
        }
 
        if (fd >= _wapi_fd_reserve) {
-               DEBUG ("%s: File descriptor is too big", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
 
                SetLastError (ERROR_TOO_MANY_OPEN_FILES);
                
@@ -1569,7 +1564,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
 
        ret = fstat (fd, &statbuf);
        if (ret == -1) {
-               DEBUG ("%s: fstat error of file %s: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fstat error of file %s: %s", __func__,
                           filename, strerror (errno));
                _wapi_set_last_error_from_errno ();
                g_free (filename);
@@ -1595,7 +1590,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
        }
        if (file_handle.share_info == NULL) {
                /* No space, so no more files can be opened */
-               DEBUG ("%s: No space in the share table", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No space in the share table", __func__);
 
                SetLastError (ERROR_TOO_MANY_OPEN_FILES);
                close (fd);
@@ -1644,7 +1639,7 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
                return(INVALID_HANDLE_VALUE);
        }
        
-       DEBUG("%s: returning handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
        
        return(handle);
 }
@@ -1670,7 +1665,7 @@ gboolean DeleteFile(const gunichar2 *name)
 #endif
        
        if(name==NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -1678,7 +1673,7 @@ gboolean DeleteFile(const gunichar2 *name)
 
        filename=mono_unicode_to_external(name);
        if(filename==NULL) {
-               DEBUG("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -1686,7 +1681,7 @@ gboolean DeleteFile(const gunichar2 *name)
 
        attrs = GetFileAttributes (name);
        if (attrs == INVALID_FILE_ATTRIBUTES) {
-               DEBUG ("%s: file attributes error", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file attributes error", __func__);
                /* Error set by GetFileAttributes() */
                g_free (filename);
                return(FALSE);
@@ -1751,7 +1746,7 @@ gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name)
        struct _WapiFileShare *shareinfo;
        
        if(name==NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -1759,14 +1754,14 @@ gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name)
 
        utf8_name = mono_unicode_to_external (name);
        if (utf8_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
                
                SetLastError (ERROR_INVALID_NAME);
                return FALSE;
        }
        
        if(dest_name==NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                g_free (utf8_name);
                SetLastError (ERROR_INVALID_NAME);
@@ -1775,7 +1770,7 @@ gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name)
 
        utf8_dest_name = mono_unicode_to_external (dest_name);
        if (utf8_dest_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                g_free (utf8_name);
                SetLastError (ERROR_INVALID_NAME);
@@ -1896,7 +1891,7 @@ write_file (int src_fd, int dest_fd, struct stat *st_src, gboolean report_errors
 
                                if (report_errors)
                                        _wapi_set_last_error_from_errno ();
-                               DEBUG ("%s: write failed.", __func__);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: write failed.", __func__);
                                free (buf);
                                return FALSE;
                        }
@@ -1933,7 +1928,7 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
        int ret_utime;
        
        if(name==NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -1941,7 +1936,7 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
        
        utf8_src = mono_unicode_to_external (name);
        if (utf8_src == NULL) {
-               DEBUG ("%s: unicode conversion of source returned NULL",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of source returned NULL",
                           __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
@@ -1949,7 +1944,7 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
        }
        
        if(dest_name==NULL) {
-               DEBUG("%s: dest is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dest is NULL", __func__);
 
                g_free (utf8_src);
                SetLastError (ERROR_INVALID_NAME);
@@ -1958,7 +1953,7 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
        
        utf8_dest = mono_unicode_to_external (dest_name);
        if (utf8_dest == NULL) {
-               DEBUG ("%s: unicode conversion of dest returned NULL",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of dest returned NULL",
                           __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
@@ -2039,7 +2034,7 @@ gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
        dest_time.actime = st.st_atime;
        ret_utime = utime (utf8_dest, &dest_time);
        if (ret_utime == -1)
-               DEBUG ("%s: file [%s] utime failed: %s", __func__, utf8_dest, strerror(errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file [%s] utime failed: %s", __func__, utf8_dest, strerror(errno));
        
        g_free (utf8_src);
        g_free (utf8_dest);
@@ -2053,14 +2048,14 @@ convert_arg_to_utf8 (const gunichar2 *arg, const gchar *arg_name)
        gchar *utf8_ret;
 
        if (arg == NULL) {
-               DEBUG ("%s: %s is NULL", __func__, arg_name);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: %s is NULL", __func__, arg_name);
                SetLastError (ERROR_INVALID_NAME);
                return NULL;
        }
 
        utf8_ret = mono_unicode_to_external (arg);
        if (utf8_ret == NULL) {
-               DEBUG ("%s: unicode conversion of %s returned NULL",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion of %s returned NULL",
                           __func__, arg_name);
                SetLastError (ERROR_INVALID_PARAMETER);
                return NULL;
@@ -2163,7 +2158,7 @@ gpointer GetStdHandle(WapiStdHandle stdhandle)
                break;
 
        default:
-               DEBUG("%s: unknown standard handle type", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unknown standard handle type", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return(INVALID_HANDLE_VALUE);
@@ -2549,7 +2544,7 @@ gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
        const guint16 *ip;
        
        if(system_time==NULL) {
-               DEBUG("%s: system_time NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: system_time NULL", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return(FALSE);
@@ -2563,7 +2558,7 @@ gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
         * year and day calculation to work later
         */
        if(file_ticks<0) {
-               DEBUG("%s: file_time too big", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: file_time too big", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return(FALSE);
@@ -2571,29 +2566,29 @@ gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
 
        totaldays=(file_ticks / TICKS_PER_DAY);
        rem = file_ticks % TICKS_PER_DAY;
-       DEBUG("%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
 
        system_time->wHour=rem/TICKS_PER_HOUR;
        rem %= TICKS_PER_HOUR;
-       DEBUG("%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
        
        system_time->wMinute = rem / TICKS_PER_MINUTE;
        rem %= TICKS_PER_MINUTE;
-       DEBUG("%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
                  rem);
        
        system_time->wSecond = rem / TICKS_PER_SECOND;
        rem %= TICKS_PER_SECOND;
-       DEBUG("%s: Second: %d rem: %lld", __func__, system_time->wSecond,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Second: %d rem: %lld", __func__, system_time->wSecond,
                  rem);
        
        system_time->wMilliseconds = rem / TICKS_PER_MILLISECOND;
-       DEBUG("%s: Milliseconds: %d", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Milliseconds: %d", __func__,
                  system_time->wMilliseconds);
 
        /* January 1, 1601 was a Monday, according to Emacs calendar */
        system_time->wDayOfWeek = ((1 + totaldays) % 7) + 1;
-       DEBUG("%s: Day of week: %d", __func__, system_time->wDayOfWeek);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day of week: %d", __func__, system_time->wDayOfWeek);
        
        /* This algorithm to find year and month given days from epoch
         * from glibc
@@ -2606,7 +2601,7 @@ gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
        while(totaldays < 0 || totaldays >= (isleap(y)?366:365)) {
                /* Guess a corrected year, assuming 365 days per year */
                gint64 yg = y + totaldays / 365 - (totaldays % 365 < 0);
-               DEBUG("%s: totaldays: %lld yg: %lld y: %lld", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld yg: %lld y: %lld", __func__,
                          totaldays, yg,
                          y);
                g_message("%s: LEAPS(yg): %lld LEAPS(y): %lld", __func__,
@@ -2616,13 +2611,13 @@ gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
                totaldays -= ((yg - y) * 365
                              + LEAPS_THRU_END_OF (yg - 1)
                              - LEAPS_THRU_END_OF (y - 1));
-               DEBUG("%s: totaldays: %lld", __func__, totaldays);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
                y = yg;
-               DEBUG("%s: y: %lld", __func__, y);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: y: %lld", __func__, y);
        }
        
        system_time->wYear = y;
-       DEBUG("%s: Year: %d", __func__, system_time->wYear);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Year: %d", __func__, system_time->wYear);
 
        ip = mon_yday[isleap(y)];
        
@@ -2630,13 +2625,13 @@ gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
                continue;
        }
        totaldays-=ip[y];
-       DEBUG("%s: totaldays: %lld", __func__, totaldays);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: totaldays: %lld", __func__, totaldays);
        
        system_time->wMonth = y + 1;
-       DEBUG("%s: Month: %d", __func__, system_time->wMonth);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Month: %d", __func__, system_time->wMonth);
 
        system_time->wDay = totaldays + 1;
-       DEBUG("%s: Day: %d", __func__, system_time->wDay);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Day: %d", __func__, system_time->wDay);
        
        return(TRUE);
 }
@@ -2649,7 +2644,7 @@ gpointer FindFirstFile (const gunichar2 *pattern, WapiFindData *find_data)
        int result;
        
        if (pattern == NULL) {
-               DEBUG ("%s: pattern is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: pattern is NULL", __func__);
 
                SetLastError (ERROR_PATH_NOT_FOUND);
                return(INVALID_HANDLE_VALUE);
@@ -2657,13 +2652,13 @@ gpointer FindFirstFile (const gunichar2 *pattern, WapiFindData *find_data)
 
        utf8_pattern = mono_unicode_to_external (pattern);
        if (utf8_pattern == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
                
                SetLastError (ERROR_INVALID_NAME);
                return(INVALID_HANDLE_VALUE);
        }
 
-       DEBUG ("%s: looking for [%s]", __func__, utf8_pattern);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking for [%s]", __func__, utf8_pattern);
        
        /* Figure out which bit of the pattern is the directory */
        dir_part = _wapi_dirname (utf8_pattern);
@@ -2719,12 +2714,8 @@ gpointer FindFirstFile (const gunichar2 *pattern, WapiFindData *find_data)
        }
        
        if (result < 0) {
-#ifdef DEBUG_ENABLED
-               gint errnum = errno;
-#endif
                _wapi_set_last_path_error_from_errno (dir_part, NULL);
-               DEBUG ("%s: scandir error: %s", __func__,
-                          g_strerror (errnum));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: scandir error: %s", __func__, g_strerror (errno));
                g_free (utf8_pattern);
                g_free (entry_part);
                g_free (dir_part);
@@ -2734,7 +2725,7 @@ gpointer FindFirstFile (const gunichar2 *pattern, WapiFindData *find_data)
        g_free (utf8_pattern);
        g_free (entry_part);
        
-       DEBUG ("%s: Got %d matches", __func__, result);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Got %d matches", __func__, result);
 
        find_handle.dir_part = dir_part;
        find_handle.num = result;
@@ -2804,7 +2795,7 @@ retry:
        }
        
        if (result != 0) {
-               DEBUG ("%s: stat failed: %s", __func__, filename);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: stat failed: %s", __func__, filename);
 
                g_free (filename);
                goto retry;
@@ -2813,7 +2804,7 @@ retry:
 #ifndef __native_client__
        result = _wapi_lstat (filename, &linkbuf);
        if (result != 0) {
-               DEBUG ("%s: lstat failed: %s", __func__, filename);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: lstat failed: %s", __func__, filename);
 
                g_free (filename);
                goto retry;
@@ -2833,7 +2824,7 @@ retry:
        }
        g_free (filename);
        
-       DEBUG ("%s: Found [%s]", __func__, utf8_filename);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Found [%s]", __func__, utf8_filename);
        
        /* fill data block */
 
@@ -2956,7 +2947,7 @@ gboolean CreateDirectory (const gunichar2 *name,
        int result;
        
        if (name == NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -2964,7 +2955,7 @@ gboolean CreateDirectory (const gunichar2 *name,
        
        utf8_name = mono_unicode_to_external (name);
        if (utf8_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
        
                SetLastError (ERROR_INVALID_NAME);
                return FALSE;
@@ -2997,7 +2988,7 @@ gboolean RemoveDirectory (const gunichar2 *name)
        int result;
        
        if (name == NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -3005,7 +2996,7 @@ gboolean RemoveDirectory (const gunichar2 *name)
 
        utf8_name = mono_unicode_to_external (name);
        if (utf8_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
                
                SetLastError (ERROR_INVALID_NAME);
                return FALSE;
@@ -3039,7 +3030,7 @@ guint32 GetFileAttributes (const gunichar2 *name)
        guint32 ret;
        
        if (name == NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -3047,7 +3038,7 @@ guint32 GetFileAttributes (const gunichar2 *name)
        
        utf8_name = mono_unicode_to_external (name);
        if (utf8_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return (INVALID_FILE_ATTRIBUTES);
@@ -3105,7 +3096,7 @@ gboolean GetFileAttributesEx (const gunichar2 *name, WapiGetFileExInfoLevels lev
        int result;
        
        if (level != GetFileExInfoStandard) {
-               DEBUG ("%s: info level %d not supported.", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: info level %d not supported.", __func__,
                           level);
 
                SetLastError (ERROR_INVALID_PARAMETER);
@@ -3113,7 +3104,7 @@ gboolean GetFileAttributesEx (const gunichar2 *name, WapiGetFileExInfoLevels lev
        }
        
        if (name == NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -3121,7 +3112,7 @@ gboolean GetFileAttributesEx (const gunichar2 *name, WapiGetFileExInfoLevels lev
 
        utf8_name = mono_unicode_to_external (name);
        if (utf8_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return FALSE;
@@ -3199,7 +3190,7 @@ extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs)
         */
        
        if (name == NULL) {
-               DEBUG("%s: name is NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: name is NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(FALSE);
@@ -3207,7 +3198,7 @@ extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs)
 
        utf8_name = mono_unicode_to_external (name);
        if (utf8_name == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return FALSE;
@@ -3351,11 +3342,11 @@ gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
        
        mono_once (&io_ops_once, io_ops_init);
        
-       DEBUG ("%s: Creating pipe", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating pipe", __func__);
 
        ret=pipe (filedes);
        if(ret==-1) {
-               DEBUG ("%s: Error creating pipe: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error creating pipe: %s", __func__,
                           strerror (errno));
                
                _wapi_set_last_error_from_errno ();
@@ -3364,7 +3355,7 @@ gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
 
        if (filedes[0] >= _wapi_fd_reserve ||
            filedes[1] >= _wapi_fd_reserve) {
-               DEBUG ("%s: File descriptor is too big", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
 
                SetLastError (ERROR_TOO_MANY_OPEN_FILES);
                
@@ -3407,7 +3398,7 @@ gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
        *readpipe = read_handle;
        *writepipe = write_handle;
 
-       DEBUG ("%s: Returning pipe: read handle %p, write handle %p",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning pipe: read handle %p, write handle %p",
                   __func__, read_handle, write_handle);
 
        return(TRUE);
@@ -3879,7 +3870,7 @@ gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_
        else {
                utf8_path_name = mono_unicode_to_external (path_name);
                if (utf8_path_name == NULL) {
-                       DEBUG("%s: unicode conversion returned NULL", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                        SetLastError (ERROR_INVALID_NAME);
                        return(FALSE);
@@ -3906,7 +3897,7 @@ gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_
 
        if (ret == -1) {
                _wapi_set_last_error_from_errno ();
-               DEBUG ("%s: statvfs failed: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: statvfs failed: %s", __func__, strerror (errno));
                return(FALSE);
        }
 
@@ -4199,7 +4190,7 @@ guint32 GetDriveType(const gunichar2 *root_path_name)
        else {
                utf8_root_path_name = mono_unicode_to_external (root_path_name);
                if (utf8_root_path_name == NULL) {
-                       DEBUG("%s: unicode conversion returned NULL", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
                        return(DRIVE_NO_ROOT_DIR);
                }
                
index eec2549513dba01f0eb3a00093c7bf45afdad883..305c0ab48527cb7fd053c050a04041e7c1d7b10c 100644 (file)
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/io-private.h>
-
-#if 0
-// #define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
 
 gboolean
 _wapi_lock_file_region (int fd, off_t offset, off_t length)
@@ -48,7 +44,7 @@ _wapi_lock_file_region (int fd, off_t offset, off_t length)
                ret = fcntl (fd, F_SETLK, &lock_data);
        } while(ret == -1 && errno == EINTR);
        
-       DEBUG ("%s: fcntl returns %d", __func__, ret);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
 
        if (ret == -1) {
                /*
@@ -93,7 +89,7 @@ _wapi_unlock_file_region (int fd, off_t offset, off_t length)
                ret = fcntl (fd, F_SETLK, &lock_data);
        } while(ret == -1 && errno == EINTR);
        
-       DEBUG ("%s: fcntl returns %d", __func__, ret);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl returns %d", __func__, ret);
        
        if (ret == -1) {
                /*
@@ -140,7 +136,7 @@ LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
        if (!(file_handle->fileaccess & GENERIC_READ) &&
            !(file_handle->fileaccess & GENERIC_WRITE) &&
            !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
        }
@@ -149,7 +145,7 @@ LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
        offset = ((gint64)offset_high << 32) | offset_low;
        length = ((gint64)length_high << 32) | length_low;
 
-       DEBUG ("%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
 #else
        if (offset_high > 0 || length_high > 0) {
                SetLastError (ERROR_INVALID_PARAMETER);
@@ -158,7 +154,7 @@ LockFile (gpointer handle, guint32 offset_low, guint32 offset_high,
        offset = offset_low;
        length = length_low;
 
-       DEBUG ("%s: Locking handle %p, offset %ld, length %ld", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Locking handle %p, offset %ld, length %ld", __func__,
                   handle, offset, length);
 #endif
 
@@ -187,7 +183,7 @@ UnlockFile (gpointer handle, guint32 offset_low,
        if (!(file_handle->fileaccess & GENERIC_READ) &&
            !(file_handle->fileaccess & GENERIC_WRITE) &&
            !(file_handle->fileaccess & GENERIC_ALL)) {
-               DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
                SetLastError (ERROR_ACCESS_DENIED);
                return(FALSE);
        }
@@ -196,12 +192,12 @@ UnlockFile (gpointer handle, guint32 offset_low,
        offset = ((gint64)offset_high << 32) | offset_low;
        length = ((gint64)length_high << 32) | length_low;
 
-       DEBUG ("%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
 #else
        offset = offset_low;
        length = length_low;
 
-       DEBUG ("%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
 #endif
 
        return(_wapi_unlock_file_region (fd, offset, length));
index e1a4539a0b193ee513c6cc553bb9855df6a736ff..730363e6302b1fa16a42da9722eb0690ea970402 100644 (file)
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/mutex-private.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
 
 static void mutex_signal(gpointer handle);
 static gboolean mutex_own (gpointer handle);
@@ -116,7 +112,7 @@ static gboolean mutex_own (gpointer handle)
 
        _wapi_thread_own_mutex (handle);
        
-       DEBUG("%s: owning mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning mutex handle %p", __func__, handle);
 
        _wapi_handle_set_signal_state (handle, FALSE, FALSE);
        
@@ -124,7 +120,7 @@ static gboolean mutex_own (gpointer handle)
        mutex_handle->tid = pthread_self ();
        mutex_handle->recursion++;
 
-       DEBUG ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p locked %d times by %d:%ld", __func__,
                   handle, mutex_handle->recursion, mutex_handle->pid,
                   mutex_handle->tid);
 
@@ -144,17 +140,17 @@ static gboolean mutex_is_owned (gpointer handle)
                return(FALSE);
        }
        
-       DEBUG("%s: testing ownership mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing ownership mutex handle %p", __func__, handle);
 
        if (mutex_handle->recursion > 0 &&
            mutex_handle->pid == _wapi_getpid () &&
            pthread_equal (mutex_handle->tid, pthread_self ())) {
-               DEBUG ("%s: mutex handle %p owned by %d:%ld", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p owned by %d:%ld", __func__,
                           handle, _wapi_getpid (), pthread_self ());
 
                return(TRUE);
        } else {
-               DEBUG ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), mutex_handle->recursion, mutex_handle->pid, mutex_handle->tid);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), mutex_handle->recursion, mutex_handle->pid, mutex_handle->tid);
 
                return(FALSE);
        }
@@ -171,7 +167,7 @@ static gboolean namedmutex_own (gpointer handle)
        struct _WapiHandle_namedmutex *namedmutex_handle;
        gboolean ok;
        
-       DEBUG ("%s: owning named mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning named mutex handle %p", __func__, handle);
        
        ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDMUTEX,
                                  (gpointer *)&namedmutex_handle);
@@ -189,7 +185,7 @@ static gboolean namedmutex_own (gpointer handle)
 
        _wapi_shared_handle_set_signal_state (handle, FALSE);
 
-       DEBUG ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p locked %d times by %d:%ld", __func__,
                   handle, namedmutex_handle->recursion,
                   namedmutex_handle->pid, namedmutex_handle->tid);
        
@@ -209,17 +205,17 @@ static gboolean namedmutex_is_owned (gpointer handle)
                return(FALSE);
        }
        
-       DEBUG ("%s: testing ownership mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: testing ownership mutex handle %p", __func__, handle);
 
        if (namedmutex_handle->recursion > 0 &&
            namedmutex_handle->pid == _wapi_getpid () &&
            pthread_equal (namedmutex_handle->tid, pthread_self ())) {
-               DEBUG ("%s: mutex handle %p owned by %d:%ld", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p owned by %d:%ld", __func__,
                           handle, _wapi_getpid (), pthread_self ());
 
                return(TRUE);
        } else {
-               DEBUG ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), namedmutex_handle->recursion, namedmutex_handle->pid, namedmutex_handle->tid);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), namedmutex_handle->recursion, namedmutex_handle->pid, namedmutex_handle->tid);
 
                return(FALSE);
        }
@@ -245,26 +241,26 @@ static void namedmutex_prewait (gpointer handle)
                return;
        }
        
-       DEBUG ("%s: Checking ownership of named mutex handle %p", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Checking ownership of named mutex handle %p", __func__,
                   handle);
 
        if (namedmutex_handle->recursion == 0) {
-               DEBUG ("%s: Named mutex handle %p not owned", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Named mutex handle %p not owned", __func__,
                           handle);
        } else if (namedmutex_handle->pid == _wapi_getpid ()) {
-               DEBUG ("%s: Named mutex handle %p owned by this process",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Named mutex handle %p owned by this process",
                           __func__, handle);
        } else {
                int thr_ret;
                gpointer proc_handle;
                
-               DEBUG ("%s: Named mutex handle %p owned by another process", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Named mutex handle %p owned by another process", __func__, handle);
                proc_handle = OpenProcess (0, 0, namedmutex_handle->pid);
                if (proc_handle == NULL) {
                        /* Didn't find the process that this handle
                         * was owned by, overriding it
                         */
-                       DEBUG ("%s: overriding old owner of named mutex handle %p", __func__, handle);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: overriding old owner of named mutex handle %p", __func__, handle);
                        thr_ret = _wapi_handle_lock_shared_handles ();
                        g_assert (thr_ret == 0);
 
@@ -275,7 +271,7 @@ static void namedmutex_prewait (gpointer handle)
                        _wapi_shared_handle_set_signal_state (handle, TRUE);
                        _wapi_handle_unlock_shared_handles ();
                } else {
-                       DEBUG ("%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle);
                }
                if (proc_handle != NULL)
                        CloseProcess (proc_handle);
@@ -301,7 +297,7 @@ static void mutex_abandon (gpointer handle, pid_t pid, pthread_t tid)
        
        if (mutex_handle->pid == pid &&
            pthread_equal (mutex_handle->tid, tid)) {
-               DEBUG ("%s: Mutex handle %p abandoned!", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Mutex handle %p abandoned!", __func__, handle);
 
                mutex_handle->recursion = 0;
                mutex_handle->pid = 0;
@@ -333,7 +329,7 @@ static void namedmutex_abandon (gpointer handle, pid_t pid, pthread_t tid)
        
        if (mutex_handle->pid == pid &&
            pthread_equal (mutex_handle->tid, tid)) {
-               DEBUG ("%s: Mutex handle %p abandoned!", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Mutex handle %p abandoned!", __func__, handle);
 
                mutex_handle->recursion = 0;
                mutex_handle->pid = 0;
@@ -375,7 +371,7 @@ static gpointer mutex_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
         */
        SetLastError (ERROR_SUCCESS);
        
-       DEBUG ("%s: Creating unnamed mutex", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating unnamed mutex", __func__);
        
        handle = _wapi_handle_new (WAPI_HANDLE_MUTEX, &mutex_handle);
        if (handle == _WAPI_HANDLE_INVALID) {
@@ -393,7 +389,7 @@ static gpointer mutex_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
                _wapi_handle_set_signal_state (handle, TRUE, FALSE);
        }
        
-       DEBUG ("%s: returning mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning mutex handle %p", __func__, handle);
 
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
@@ -426,7 +422,7 @@ static gpointer namedmutex_create (WapiSecurityAttributes *security G_GNUC_UNUSE
        
        utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
        
-       DEBUG ("%s: Creating named mutex [%s]", __func__, utf8_name);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named mutex [%s]", __func__, utf8_name);
        
        offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDMUTEX,
                                                utf8_name);
@@ -490,7 +486,7 @@ static gpointer namedmutex_create (WapiSecurityAttributes *security G_GNUC_UNUSE
                _wapi_handle_unlock_shared_handles ();
        }
        
-       DEBUG ("%s: returning mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning mutex handle %p", __func__, handle);
 
 cleanup:
        g_free (utf8_name);
@@ -551,11 +547,11 @@ static gboolean mutex_release (gpointer handle)
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
        
-       DEBUG("%s: Releasing mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Releasing mutex handle %p", __func__, handle);
 
        if (!pthread_equal (mutex_handle->tid, tid) ||
            mutex_handle->pid != pid) {
-               DEBUG("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
 
                goto cleanup;
        }
@@ -567,7 +563,7 @@ static gboolean mutex_release (gpointer handle)
        if(mutex_handle->recursion==0) {
                _wapi_thread_disown_mutex (handle);
 
-               DEBUG("%s: Unlocking mutex handle %p", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking mutex handle %p", __func__, handle);
 
                mutex_handle->pid=0;
                mutex_handle->tid=0;
@@ -601,11 +597,11 @@ static gboolean namedmutex_release (gpointer handle)
        thr_ret = _wapi_handle_lock_shared_handles ();
        g_assert (thr_ret == 0);
        
-       DEBUG("%s: Releasing mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Releasing mutex handle %p", __func__, handle);
 
        if (!pthread_equal (mutex_handle->tid, tid) ||
            mutex_handle->pid != pid) {
-               DEBUG("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
 
                goto cleanup;
        }
@@ -617,7 +613,7 @@ static gboolean namedmutex_release (gpointer handle)
        if(mutex_handle->recursion==0) {
                _wapi_thread_disown_mutex (handle);
 
-               DEBUG("%s: Unlocking mutex handle %p", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Unlocking mutex handle %p", __func__, handle);
 
                mutex_handle->pid=0;
                mutex_handle->tid=0;
@@ -676,7 +672,7 @@ gpointer OpenMutex (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED
 
        utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
        
-       DEBUG ("%s: Opening named mutex [%s]", __func__, utf8_name);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named mutex [%s]", __func__, utf8_name);
        
        offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDMUTEX,
                                                utf8_name);
@@ -705,7 +701,7 @@ gpointer OpenMutex (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED
        }
        ret = handle;
 
-       DEBUG ("%s: returning named mutex handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named mutex handle %p", __func__, handle);
 
 cleanup:
        g_free (utf8_name);
index b51c1adf11e647046c035ae92671a008a40925ed..3cd41f67fe33d045e7d9ede7e033f40b35b407f9 100644 (file)
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/io-private.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
 
 static guint32
 convert_from_flags(int flags)
@@ -46,7 +42,7 @@ convert_from_flags(int flags)
        } else if ((flags & O_ACCMODE) == O_RDWR) {
                fileaccess=GENERIC_READ|GENERIC_WRITE;
        } else {
-               DEBUG("%s: Can't figure out flags 0x%x", __func__, flags);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't figure out flags 0x%x", __func__, flags);
        }
 
        /* Maybe sort out create mode too */
@@ -61,7 +57,7 @@ gpointer _wapi_stdhandle_create (int fd, const gchar *name)
        gpointer handle;
        int flags;
        
-       DEBUG("%s: creating standard handle type %s, fd %d", __func__,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: creating standard handle type %s, fd %d", __func__,
                  name, fd);
 
 #if !defined(__native_client__)        
@@ -74,7 +70,7 @@ gpointer _wapi_stdhandle_create (int fd, const gchar *name)
                /* Invalid fd.  Not really much point checking for EBADF
                 * specifically
                 */
-               DEBUG("%s: fcntl error on fd %d: %s", __func__, fd,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: fcntl error on fd %d: %s", __func__, fd,
                          strerror(errno));
 
                SetLastError (_wapi_get_win32_file_error (errno));
@@ -111,7 +107,7 @@ gpointer _wapi_stdhandle_create (int fd, const gchar *name)
                return(INVALID_HANDLE_VALUE);
        }
        
-       DEBUG("%s: returning handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p", __func__, handle);
 
        return(handle);
 }
index 851ffaffb6eb1b6f2712a38daca9cec9d7c59cea..7e21445761a83f1a3a1741ff878eb5a3bd79f830 100644 (file)
 #endif
 #endif
 
-#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(PLATFORM_MACOSX)
+#define USE_OSX_LOADER
+#endif
+
+#if ( defined(__OpenBSD__) || defined(__FreeBSD__) ) && defined(HAVE_LINK_H)
+#define USE_BSD_LOADER
+#endif
+
+#if defined(__HAIKU__)
+#define USE_HAIKU_LOADER
+#endif
+
+#if defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER)
 #include <sys/proc.h>
 #include <sys/sysctl.h>
 #  if !defined(__OpenBSD__)
@@ -85,6 +97,7 @@
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/process-private.h>
 #include <mono/io-layer/threads.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/strenc.h>
 #include <mono/utils/mono-path.h>
 #include <mono/io-layer/timefuncs-private.h>
 #include <mono/utils/mono-signal-handler.h>
 #include <mono/utils/mono-proclib.h>
 #include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
 
 /* The process' environment strings */
 #if defined(__APPLE__)
@@ -112,18 +126,11 @@ static char *mono_environ[1] = { NULL };
 extern char **environ;
 #endif
 
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#define DEBUG_ENABLED 1
-#else
-#define DEBUG(...)
-#endif
-
 static guint32 process_wait (gpointer handle, guint32 timeout, gboolean alertable);
 static void process_close (gpointer handle, gpointer data);
 static gboolean is_pid_valid (pid_t pid);
 
-#if !(defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__))
+#if !(defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER) || defined(USE_HAIKU_LOADER))
 static FILE *
 open_process_map (int pid, const char *mode);
 #endif
@@ -564,11 +571,11 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
        char *dir = NULL, **env_strings = NULL, **argv = NULL;
        guint32 i, env_count = 0;
        gboolean ret = FALSE;
-       gpointer handle;
+       gpointer handle = NULL;
        WapiHandle_process process_handle = {0}, *process_handle_data;
        GError *gerr = NULL;
        int in_fd, out_fd, err_fd;
-       pid_t pid;
+       pid_t pid = 0;
        int thr_ret;
        int startup_pipe [2] = {-1, -1};
        int dummy;
@@ -606,7 +613,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
        if (appname != NULL) {
                cmd = mono_unicode_to_external (appname);
                if (cmd == NULL) {
-                       DEBUG ("%s: unicode conversion returned NULL",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL",
                                   __func__);
 
                        SetLastError (ERROR_PATH_NOT_FOUND);
@@ -619,7 +626,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
        if (cmdline != NULL) {
                args = mono_unicode_to_external (cmdline);
                if (args == NULL) {
-                       DEBUG ("%s: unicode conversion returned NULL", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                        SetLastError (ERROR_PATH_NOT_FOUND);
                        goto free_strings;
@@ -629,7 +636,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
        if (cwd != NULL) {
                dir = mono_unicode_to_external (cwd);
                if (dir == NULL) {
-                       DEBUG ("%s: unicode conversion returned NULL", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                        SetLastError (ERROR_PATH_NOT_FOUND);
                        goto free_strings;
@@ -659,7 +666,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
 
                        /* Executable existing ? */
                        if (!is_readable_or_executable (prog)) {
-                               DEBUG ("%s: Couldn't find executable %s",
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
                                           __func__, prog);
                                g_free (unquoted);
                                SetLastError (ERROR_FILE_NOT_FOUND);
@@ -676,7 +683,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
 
                        /* And make sure it's readable */
                        if (!is_readable_or_executable (prog)) {
-                               DEBUG ("%s: Couldn't find executable %s",
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
                                           __func__, prog);
                                g_free (unquoted);
                                SetLastError (ERROR_FILE_NOT_FOUND);
@@ -741,7 +748,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                
                if (token == NULL) {
                        /* Give up */
-                       DEBUG ("%s: Couldn't find what to exec", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find what to exec", __func__);
 
                        SetLastError (ERROR_PATH_NOT_FOUND);
                        goto free_strings;
@@ -767,7 +774,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                        
                        /* Executable existing ? */
                        if (!is_readable_or_executable (prog)) {
-                               DEBUG ("%s: Couldn't find executable %s",
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s",
                                           __func__, token);
                                g_free (token);
                                SetLastError (ERROR_FILE_NOT_FOUND);
@@ -794,7 +801,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                                g_free (prog);
                                prog = g_find_program_in_path (token);
                                if (prog == NULL) {
-                                       DEBUG ("%s: Couldn't find executable %s", __func__, token);
+                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Couldn't find executable %s", __func__, token);
 
                                        g_free (token);
                                        SetLastError (ERROR_FILE_NOT_FOUND);
@@ -806,7 +813,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                g_free (token);
        }
 
-       DEBUG ("%s: Exec prog [%s] args [%s]", __func__, prog,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Exec prog [%s] args [%s]", __func__, prog,
                   args_after_prog);
        
        /* Check for CLR binaries; if found, we will try to invoke
@@ -849,7 +856,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                }
        } else {
                if (!is_executable (prog)) {
-                       DEBUG ("%s: Executable permisson not set on %s", __func__, prog);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Executable permisson not set on %s", __func__, prog);
                        SetLastError (ERROR_ACCESS_DENIED);
                        goto free_strings;
                }
@@ -960,7 +967,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                /* Could not create the pipe to synchroniz process startup. We'll just not synchronize.
                 * This is just for a very hard to hit race condition in the first place */
                startup_pipe [0] = startup_pipe [1] = -1;
-               DEBUG ("%s: new process startup not synchronized. We may not notice if the newly created process exits immediately.", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: new process startup not synchronized. We may not notice if the newly created process exits immediately.", __func__);
        }
 
        thr_ret = _wapi_handle_lock_shared_handles ();
@@ -979,7 +986,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                if (startup_pipe [0] != -1) {
                        /* Wait until the parent has updated it's internal data */
                        ssize_t _i G_GNUC_UNUSED = read (startup_pipe [0], &dummy, 1);
-                       DEBUG ("%s: child: parent has completed its setup", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: child: parent has completed its setup", __func__);
                        close (startup_pipe [0]);
                        close (startup_pipe [1]);
                }
@@ -1000,7 +1007,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline,
                        close (i);
 
 #ifdef DEBUG_ENABLED
-               DEBUG ("%s: exec()ing [%s] in dir [%s]", __func__, cmd,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: exec()ing [%s] in dir [%s]", __func__, cmd,
                           dir == NULL?".":dir);
                for (i = 0; argv[i] != NULL; i++)
                        g_message ("arg %d: [%s]", i, argv[i]);
@@ -1097,8 +1104,7 @@ free_strings:
        if (argv)
                g_strfreev (argv);
        
-       DEBUG ("%s: returning handle %p for pid %d", __func__, handle,
-                  pid);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning handle %p for pid %d", __func__, handle, pid);
 
        /* Check if something needs to be cleaned up. */
        mono_processes_cleanup ();
@@ -1118,7 +1124,7 @@ process_set_name (WapiHandle_process *process_handle)
        progname = g_get_prgname ();
        utf8_progname = mono_utf8_from_external (progname);
 
-       DEBUG ("%s: using [%s] as prog name", __func__, progname);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: using [%s] as prog name", __func__, progname);
 
        if (utf8_progname) {
                slash = strrchr (utf8_progname, '/');
@@ -1196,7 +1202,7 @@ process_open_compare (gpointer handle, gpointer user_data)
        process_handle = lookup_process_handle (handle);
        g_assert (process_handle);
        
-       DEBUG ("%s: looking at process %d", __func__, process_handle->id);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking at process %d", __func__, process_handle->id);
 
        checking_pid = process_handle->id;
 
@@ -1238,7 +1244,7 @@ OpenProcess (guint32 req_access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, g
        /* Find the process handle that corresponds to pid */
        gpointer handle = NULL;
        
-       DEBUG ("%s: looking for process %d", __func__, pid);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: looking for process %d", __func__, pid);
 
        handle = _wapi_search_handle (WAPI_HANDLE_PROCESS,
                                      process_open_compare,
@@ -1250,7 +1256,7 @@ OpenProcess (guint32 req_access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, g
                         */
                        return WAPI_PID_TO_HANDLE (pid);
                } else {
-                       DEBUG ("%s: Can't find pid %d", __func__, pid);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find pid %d", __func__, pid);
 
                        SetLastError (ERROR_PROC_NOT_FOUND);
        
@@ -1286,7 +1292,7 @@ GetExitCodeProcess (gpointer process, guint32 *code)
 
        process_handle = lookup_process_handle (process);
        if (!process_handle) {
-               DEBUG ("%s: Can't find process %p", __func__, process);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
                
                return FALSE;
        }
@@ -1340,7 +1346,7 @@ GetProcessTimes (gpointer process, WapiFileTime *create_time,
 
        process_handle = lookup_process_handle (process);
        if (!process_handle) {
-               DEBUG ("%s: Can't find process %p", __func__, process);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
                
                return FALSE;
        }
@@ -1409,7 +1415,7 @@ static gint find_procmodule (gconstpointer a, gconstpointer b)
        }
 }
 
-#ifdef PLATFORM_MACOSX
+#if defined(USE_OSX_LOADER)
 #include <mach-o/dyld.h>
 #include <mach-o/getsect.h>
 
@@ -1464,7 +1470,7 @@ static GSList *load_modules (void)
        
        return(ret);
 }
-#elif defined(__OpenBSD__) || defined(__FreeBSD__)
+#elif defined(USE_BSD_LOADER)
 #include <link.h>
 static int load_modules_callback (struct dl_phdr_info *info, size_t size, void *ptr)
 {
@@ -1505,7 +1511,7 @@ static GSList *load_modules (void)
                mod->inode = i;
                mod->filename = g_strdup (info->dlpi_name); 
 
-               DEBUG ("%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
                                   mod->inode, mod->filename, mod->address_start, mod->address_end);
 
                free(info);
@@ -1523,7 +1529,7 @@ static GSList *load_modules (void)
 
        return(ret);
 }
-#elif defined(__HAIKU__)
+#elif defined(USE_HAIKU_LOADER)
 
 static GSList *load_modules (void)
 {
@@ -1686,7 +1692,7 @@ static gboolean match_procname_to_modulename (char *procname, char *modulename)
        if (procname == NULL || modulename == NULL)
                return (FALSE);
 
-       DEBUG ("%s: procname=\"%s\", modulename=\"%s\"", __func__, procname, modulename);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: procname=\"%s\", modulename=\"%s\"", __func__, procname, modulename);
        pname = mono_path_resolve_symlinks (procname);
        mname = mono_path_resolve_symlinks (modulename);
 
@@ -1715,11 +1721,11 @@ static gboolean match_procname_to_modulename (char *procname, char *modulename)
        g_free (pname);
        g_free (mname);
 
-       DEBUG ("%s: result is %d", __func__, result);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: result is %d", __func__, result);
        return result;
 }
 
-#if !(defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__))
+#if !(defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER) || defined(USE_HAIKU_LOADER))
 static FILE *
 open_process_map (int pid, const char *mode)
 {
@@ -1748,7 +1754,7 @@ gboolean EnumProcessModules (gpointer process, gpointer *modules,
                             guint32 size, guint32 *needed)
 {
        WapiHandle_process *process_handle;
-#if !defined(__OpenBSD__) && !defined(PLATFORM_MACOSX) && !defined(__FreeBSD__)
+#if !defined(USE_OSX_LOADER) && !defined(USE_BSD_LOADER)
        FILE *fp;
 #endif
        GSList *mods = NULL;
@@ -1776,7 +1782,7 @@ gboolean EnumProcessModules (gpointer process, gpointer *modules,
        } else {
                process_handle = lookup_process_handle (process);
                if (!process_handle) {
-                       DEBUG ("%s: Can't find process %p", __func__, process);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
                
                        return FALSE;
                }
@@ -1784,7 +1790,7 @@ gboolean EnumProcessModules (gpointer process, gpointer *modules,
                proc_name = g_strdup (process_handle->proc_name);
        }
        
-#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__)
+#if defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER) || defined(USE_HAIKU_LOADER)
        mods = load_modules ();
        if (!proc_name) {
                modules[0] = NULL;
@@ -1841,11 +1847,11 @@ gboolean EnumProcessModules (gpointer process, gpointer *modules,
 static char *
 get_process_name_from_proc (pid_t pid)
 {
-#if defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(USE_BSD_LOADER)
        int mib [6];
        size_t size;
        struct kinfo_proc *pi;
-#elif defined(PLATFORM_MACOSX)
+#elif defined(USE_OSX_LOADER)
 #if !(!defined (__mono_ppc__) && defined (TARGET_OSX))
        size_t size;
        struct kinfo_proc *pi;
@@ -1872,7 +1878,7 @@ get_process_name_from_proc (pid_t pid)
                fclose (fp);
        }
        g_free (filename);
-#elif defined(PLATFORM_MACOSX)
+#elif defined(USE_OSX_LOADER)
 #if !defined (__mono_ppc__) && defined (TARGET_OSX)
        /* No proc name on OSX < 10.5 nor ppc nor iOS */
        memset (buf, '\0', sizeof(buf));
@@ -1913,7 +1919,7 @@ get_process_name_from_proc (pid_t pid)
        if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
                if (errno == ENOMEM) {
                        free(pi);
-                       DEBUG ("%s: Didn't allocate enough memory for kproc info", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't allocate enough memory for kproc info", __func__);
                }
                return(ret);
        }
@@ -1923,13 +1929,14 @@ get_process_name_from_proc (pid_t pid)
 
        free(pi);
 #endif
-#elif defined(__FreeBSD__)
+#elif defined(USE_BSD_LOADER)
+#if defined(__FreeBSD__)
        mib [0] = CTL_KERN;
        mib [1] = KERN_PROC;
        mib [2] = KERN_PROC_PID;
        mib [3] = pid;
        if (sysctl(mib, 4, NULL, &size, NULL, 0) < 0) {
-               DEBUG ("%s: sysctl() failed: %d", __func__, errno);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sysctl() failed: %d", __func__, errno);
                return(ret);
        }
 
@@ -1939,7 +1946,7 @@ get_process_name_from_proc (pid_t pid)
        if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
                if (errno == ENOMEM) {
                        free(pi);
-                       DEBUG ("%s: Didn't allocate enough memory for kproc info", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't allocate enough memory for kproc info", __func__);
                }
                return(ret);
        }
@@ -1957,7 +1964,7 @@ get_process_name_from_proc (pid_t pid)
 
 retry:
        if (sysctl(mib, 6, NULL, &size, NULL, 0) < 0) {
-               DEBUG ("%s: sysctl() failed: %d", __func__, errno);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sysctl() failed: %d", __func__, errno);
                return(ret);
        }
 
@@ -1975,16 +1982,12 @@ retry:
                return(ret);
        }
 
-#if defined(__OpenBSD__)
        if (strlen (pi->p_comm) > 0)
                ret = g_strdup (pi->p_comm);
-#elif defined(__FreeBSD__)
-       if (strlen (pi->ki_comm) > 0)
-               ret = g_strdup (pi->ki_comm);
-#endif
 
        free(pi);
-#elif defined(__HAIKU__)
+#endif
+#elif defined(USE_HAIKU_LOADER)
        image_info imageInfo;
        int32 cookie = 0;
 
@@ -2088,7 +2091,7 @@ get_module_name (gpointer process, gpointer module,
        char *procname_ext = NULL;
        glong len;
        gsize bytes;
-#if !defined(__OpenBSD__) && !defined(PLATFORM_MACOSX) && !defined(__FreeBSD__)
+#if !defined(USE_OSX_LOADER) && !defined(USE_BSD_LOADER)
        FILE *fp;
 #endif
        GSList *mods = NULL;
@@ -2097,7 +2100,7 @@ get_module_name (gpointer process, gpointer module,
        int i;
        char *proc_name = NULL;
        
-       DEBUG ("%s: Getting module base name, process handle %p module %p",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Getting module base name, process handle %p module %p",
                   __func__, process, module);
 
        size = size * sizeof (gunichar2); /* adjust for unicode characters */
@@ -2112,7 +2115,7 @@ get_module_name (gpointer process, gpointer module,
        } else {
                process_handle = lookup_process_handle (process);
                if (!process_handle) {
-                       DEBUG ("%s: Can't find process %p", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__,
                                   process);
                        
                        return 0;
@@ -2122,7 +2125,7 @@ get_module_name (gpointer process, gpointer module,
        }
 
        /* Look up the address in /proc/<pid>/maps */
-#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__HAIKU__)
+#if defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER) || defined(USE_HAIKU_LOADER)
        mods = load_modules ();
 #else
        fp = open_process_map (pid, "r");
@@ -2173,7 +2176,7 @@ get_module_name (gpointer process, gpointer module,
        g_free (proc_name);
 
        if (procname_ext) {
-               DEBUG ("%s: Process name is [%s]", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Process name is [%s]", __func__,
                           procname_ext);
 
                procname = mono_unicode_from_external (procname_ext, &bytes);
@@ -2189,11 +2192,11 @@ get_module_name (gpointer process, gpointer module,
                bytes += 2;
                
                if (size < bytes) {
-                       DEBUG ("%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
 
                        memcpy (basename, procname, size);
                } else {
-                       DEBUG ("%s: Size %d larger than needed (%ld)",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d larger than needed (%ld)",
                                   __func__, size, bytes);
 
                        memcpy (basename, procname, bytes);
@@ -2240,11 +2243,11 @@ get_module_filename (gpointer process, gpointer module,
        bytes += 2;
 
        if (size < bytes) {
-               DEBUG ("%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
 
                memcpy (basename, proc_path, size);
        } else {
-               DEBUG ("%s: Size %d larger than needed (%ld)",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Size %d larger than needed (%ld)",
                           __func__, size, bytes);
 
                memcpy (basename, proc_path, bytes);
@@ -2275,7 +2278,7 @@ GetModuleInformation (gpointer process, gpointer module,
 {
        WapiHandle_process *process_handle;
        pid_t pid;
-#if !defined(__OpenBSD__) && !defined(PLATFORM_MACOSX) && !defined(__FreeBSD__)
+#if !defined(USE_OSX_LOADER) && !defined(USE_BSD_LOADER)
        FILE *fp;
 #endif
        GSList *mods = NULL;
@@ -2285,7 +2288,7 @@ GetModuleInformation (gpointer process, gpointer module,
        gboolean ret = FALSE;
        char *proc_name = NULL;
        
-       DEBUG ("%s: Getting module info, process handle %p module %p",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Getting module info, process handle %p module %p",
                   __func__, process, module);
 
        if (modinfo == NULL || size < sizeof (WapiModuleInfo))
@@ -2297,7 +2300,7 @@ GetModuleInformation (gpointer process, gpointer module,
        } else {
                process_handle = lookup_process_handle (process);
                if (!process_handle) {
-                       DEBUG ("%s: Can't find process %p", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__,
                                   process);
                        
                        return FALSE;
@@ -2306,7 +2309,7 @@ GetModuleInformation (gpointer process, gpointer module,
                proc_name = g_strdup (process_handle->proc_name);
        }
 
-#if defined(PLATFORM_MACOSX) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
+#if defined(USE_OSX_LOADER) || defined(USE_BSD_LOADER) || defined(USE_HAIKU_LOADER)
        mods = load_modules ();
 #else
        /* Look up the address in /proc/<pid>/maps */
@@ -2361,7 +2364,7 @@ GetProcessWorkingSetSize (gpointer process, size_t *min, size_t *max)
        
        process_handle = lookup_process_handle (process);
        if (!process_handle) {
-               DEBUG ("%s: Can't find process %p", __func__, process);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
                
                return FALSE;
        }
@@ -2384,7 +2387,7 @@ SetProcessWorkingSetSize (gpointer process, size_t min, size_t max)
 
        process_handle = lookup_process_handle (process);
        if (!process_handle) {
-               DEBUG ("%s: Can't find process %p", __func__, process);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
                
                return FALSE;
        }
@@ -2411,7 +2414,7 @@ TerminateProcess (gpointer process, gint32 exitCode)
        } else {
                process_handle = lookup_process_handle (process);
                if (!process_handle) {
-                       DEBUG ("%s: Can't find process %p", __func__, process);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find process %p", __func__, process);
                        SetLastError (ERROR_INVALID_HANDLE);
                        return FALSE;
                }
@@ -2576,7 +2579,7 @@ mono_processes_cleanup (void)
        GSList *l;
        gpointer unref_handle;
 
-       DEBUG ("%s", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s", __func__);
 
        /* Ensure we're not in here in multiple threads at once, nor recursive. */
        if (InterlockedCompareExchange (&mono_processes_cleaning_up, 1, 0) != 0)
@@ -2640,7 +2643,7 @@ mono_processes_cleanup (void)
 
        mono_os_mutex_unlock (&mono_processes_mutex);
 
-       DEBUG ("%s done", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s done", __func__);
 
        InterlockedDecrement (&mono_processes_cleaning_up);
 }
@@ -2650,7 +2653,7 @@ process_close (gpointer handle, gpointer data)
 {
        WapiHandle_process *process_handle;
 
-       DEBUG ("%s", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s", __func__);
 
        process_handle = (WapiHandle_process *) data;
        g_free (process_handle->proc_name);
@@ -2667,7 +2670,7 @@ MONO_SIGNAL_HANDLER_FUNC (static, mono_sigchld_signal_handler, (int _dummy, sigi
        int pid;
        struct MonoProcess *p;
 
-       DEBUG ("SIG CHILD handler for pid: %i\n", info->si_pid);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "SIG CHILD handler for pid: %i\n", info->si_pid);
 
        do {
                do {
@@ -2677,7 +2680,7 @@ MONO_SIGNAL_HANDLER_FUNC (static, mono_sigchld_signal_handler, (int _dummy, sigi
                if (pid <= 0)
                        break;
 
-               DEBUG ("child ended: %i", pid);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "child ended: %i", pid);
 
                /*
                 * This can run concurrently with the code in the rest of this module.
@@ -2697,7 +2700,7 @@ MONO_SIGNAL_HANDLER_FUNC (static, mono_sigchld_signal_handler, (int _dummy, sigi
                }
        } while (1);
 
-       DEBUG ("SIG CHILD handler: done looping.");
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "SIG CHILD handler: done looping.");
 }
 
 #endif
@@ -2712,7 +2715,7 @@ process_add_sigchld_handler (void)
        sigemptyset (&sa.sa_mask);
        sa.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
        g_assert (sigaction (SIGCHLD, &sa, &previous_chld_sa) != -1);
-       DEBUG ("Added SIGCHLD handler");
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "Added SIGCHLD handler");
 #endif
 }
 
@@ -2730,7 +2733,7 @@ process_wait (gpointer handle, guint32 timeout, gboolean alertable)
         * but WaitFor*Object won't call us for pseudo handles. */
        g_assert ((GPOINTER_TO_UINT (handle) & _WAPI_PROCESS_UNHANDLED) != _WAPI_PROCESS_UNHANDLED);
 
-       DEBUG ("%s (%p, %u)", __func__, handle, timeout);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u)", __func__, handle, timeout);
 
        process_handle = lookup_process_handle (handle);
        if (!process_handle) {
@@ -2740,13 +2743,13 @@ process_wait (gpointer handle, guint32 timeout, gboolean alertable)
 
        if (process_handle->exited) {
                /* We've already done this one */
-               DEBUG ("%s (%p, %u): Process already exited", __func__, handle, timeout);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): Process already exited", __func__, handle, timeout);
                return WAIT_OBJECT_0;
        }
 
        pid = process_handle->id;
 
-       DEBUG ("%s (%p, %u): PID: %d", __func__, handle, timeout, pid);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): PID: %d", __func__, handle, timeout, pid);
 
        /* We don't need to lock mono_processes here, the entry
         * has a handle_count > 0 which means it will not be freed. */
@@ -2758,17 +2761,17 @@ process_wait (gpointer handle, guint32 timeout, gboolean alertable)
 
        while (1) {
                if (timeout != INFINITE) {
-                       DEBUG ("%s (%p, %u): waiting on semaphore for %li ms...", 
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): waiting on semaphore for %li ms...", 
                                   __func__, handle, timeout, (timeout - (now - start)));
                        ret = mono_os_sem_timedwait (&mp->exit_sem, (timeout - (now - start)), alertable ? MONO_SEM_FLAGS_ALERTABLE : MONO_SEM_FLAGS_NONE);
                } else {
-                       DEBUG ("%s (%p, %u): waiting on semaphore forever...", 
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): waiting on semaphore forever...", 
                                   __func__, handle, timeout);
                        ret = mono_os_sem_wait (&mp->exit_sem, alertable ? MONO_SEM_FLAGS_ALERTABLE : MONO_SEM_FLAGS_NONE);
                }
 
                if (ret == -1 && errno != EINTR && errno != ETIMEDOUT) {
-                       DEBUG ("%s (%p, %u): sem_timedwait failure: %s", 
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): sem_timedwait failure: %s", 
                                   __func__, handle, timeout, g_strerror (errno));
                        /* Should we return a failure here? */
                }
@@ -2780,24 +2783,24 @@ process_wait (gpointer handle, guint32 timeout, gboolean alertable)
                }
 
                if (timeout == 0) {
-                       DEBUG ("%s (%p, %u): WAIT_TIMEOUT (timeout = 0)", __func__, handle, timeout);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): WAIT_TIMEOUT (timeout = 0)", __func__, handle, timeout);
                        return WAIT_TIMEOUT;
                }
 
                now = mono_msec_ticks ();
                if (now - start >= timeout) {
-                       DEBUG ("%s (%p, %u): WAIT_TIMEOUT", __func__, handle, timeout);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): WAIT_TIMEOUT", __func__, handle, timeout);
                        return WAIT_TIMEOUT;
                }
                
                if (alertable && _wapi_thread_cur_apc_pending ()) {
-                       DEBUG ("%s (%p, %u): WAIT_IO_COMPLETION", __func__, handle, timeout);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): WAIT_IO_COMPLETION", __func__, handle, timeout);
                        return WAIT_IO_COMPLETION;
                }
        }
 
        /* Process must have exited */
-       DEBUG ("%s (%p, %u): Waited successfully", __func__, handle, timeout);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): Waited successfully", __func__, handle, timeout);
 
        ret = _wapi_handle_lock_shared_handles ();
        g_assert (ret == 0);
@@ -2811,7 +2814,7 @@ process_wait (gpointer handle, guint32 timeout, gboolean alertable)
 
        process_handle->exited = TRUE;
 
-       DEBUG ("%s (%p, %u): Setting pid %d signalled, exit status %d",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s (%p, %u): Setting pid %d signalled, exit status %d",
                   __func__, handle, timeout, process_handle->id, process_handle->exitstatus);
 
        _wapi_handle_set_signal_state (handle, TRUE, TRUE);
index 01179f4d18244f0e3469aeecc5d6a1a0a90de149..a8131fa97f6a7d36d862f8a66f64cc5b8cb3c63b 100644 (file)
 #include <mono/io-layer/wapi-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/semaphore-private.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/mono-once.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
 
 static void sema_signal(gpointer handle);
 static gboolean sema_own (gpointer handle);
@@ -110,11 +106,11 @@ static gboolean sema_own (gpointer handle)
                return(FALSE);
        }
        
-       DEBUG("%s: owning sem handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning sem handle %p", __func__, handle);
 
        sem_handle->val--;
        
-       DEBUG ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p val now %d", __func__, handle, sem_handle->val);
 
        if(sem_handle->val==0) {
                _wapi_handle_set_signal_state (handle, FALSE, FALSE);
@@ -134,7 +130,7 @@ static gboolean namedsema_own (gpointer handle)
        struct _WapiHandle_namedsem *namedsem_handle;
        gboolean ok;
        
-       DEBUG ("%s: owning named sem handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: owning named sem handle %p", __func__, handle);
 
        ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDSEM,
                                  (gpointer *)&namedsem_handle);
@@ -146,7 +142,7 @@ static gboolean namedsema_own (gpointer handle)
        
        namedsem_handle->val--;
        
-       DEBUG ("%s: named sem %p val now %d", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p val now %d", __func__, handle,
                   namedsem_handle->val);
 
        if (namedsem_handle->val == 0) {
@@ -185,7 +181,7 @@ static gpointer sem_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
                _wapi_handle_set_signal_state (handle, TRUE, FALSE);
        }
 
-       DEBUG ("%s: Created semaphore handle %p initial %d max %d",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Created semaphore handle %p initial %d max %d",
                   __func__, handle, initial, max);
 
        thr_ret = _wapi_handle_unlock_handle (handle);
@@ -218,7 +214,7 @@ static gpointer namedsem_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
 
        utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
        
-       DEBUG ("%s: Creating named sem [%s]", __func__, utf8_name);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Creating named sem [%s]", __func__, utf8_name);
 
        offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDSEM,
                                                utf8_name);
@@ -282,7 +278,7 @@ static gpointer namedsem_create (WapiSecurityAttributes *security G_GNUC_UNUSED,
                _wapi_handle_unlock_shared_handles ();
        }
        
-       DEBUG ("%s: returning named sem handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named sem handle %p", __func__, handle);
 
 cleanup:
        g_free (utf8_name);
@@ -316,14 +312,14 @@ gpointer CreateSemaphore(WapiSecurityAttributes *security G_GNUC_UNUSED, gint32
        mono_once (&sem_ops_once, sem_ops_init);
        
        if (max <= 0) {
-               DEBUG ("%s: max <= 0", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: max <= 0", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return(NULL);
        }
        
        if (initial > max || initial < 0) {
-               DEBUG ("%s: initial>max or < 0", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: initial>max or < 0", __func__);
 
                SetLastError (ERROR_INVALID_PARAMETER);
                return(NULL);
@@ -354,7 +350,7 @@ static gboolean sem_release (gpointer handle, gint32 count, gint32 *prevcount)
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
 
-       DEBUG ("%s: sem %p val %d count %d", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p val %d count %d", __func__, handle,
                   sem_handle->val, count);
        
        /* Do this before checking for count overflow, because overflowing max
@@ -366,7 +362,7 @@ static gboolean sem_release (gpointer handle, gint32 count, gint32 *prevcount)
        
        /* No idea why max is signed, but thats the spec :-( */
        if (sem_handle->val + count > (guint32)sem_handle->max) {
-               DEBUG ("%s: sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
 
                goto end;
        }
@@ -376,7 +372,7 @@ static gboolean sem_release (gpointer handle, gint32 count, gint32 *prevcount)
        
        ret = TRUE;
 
-       DEBUG ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sem %p val now %d", __func__, handle, sem_handle->val);
        
 end:
        thr_ret = _wapi_handle_unlock_handle (handle);
@@ -404,7 +400,7 @@ static gboolean namedsem_release (gpointer handle, gint32 count,
        thr_ret = _wapi_handle_lock_shared_handles ();
        g_assert (thr_ret == 0);
 
-       DEBUG("%s: named sem %p val %d count %d", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p val %d count %d", __func__, handle,
                  sem_handle->val, count);
        
        /* Do this before checking for count overflow, because overflowing max
@@ -416,7 +412,7 @@ static gboolean namedsem_release (gpointer handle, gint32 count,
        
        /* No idea why max is signed, but thats the spec :-( */
        if (sem_handle->val + count > (guint32)sem_handle->max) {
-               DEBUG ("%s: named sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
 
                goto end;
        }
@@ -426,7 +422,7 @@ static gboolean namedsem_release (gpointer handle, gint32 count,
        
        ret = TRUE;
 
-       DEBUG("%s: named sem %p val now %d", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: named sem %p val now %d", __func__, handle,
                  sem_handle->val);
        
 end:
@@ -485,7 +481,7 @@ gpointer OpenSemaphore (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UN
        
        utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
        
-       DEBUG ("%s: Opening named sem [%s]", __func__, utf8_name);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Opening named sem [%s]", __func__, utf8_name);
 
        offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDSEM,
                                                utf8_name);
@@ -514,7 +510,7 @@ gpointer OpenSemaphore (guint32 access G_GNUC_UNUSED, gboolean inherit G_GNUC_UN
        }
        ret = handle;
        
-       DEBUG ("%s: returning named sem handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning named sem handle %p", __func__, handle);
 
 cleanup:
        g_free (utf8_name);
index 54c8798637c27a71cae21ba763b3dea7cd9a06a9..aaa53ffe16d157b16554960ba51f2ab35c430ab8 100644 (file)
 #include <mono/io-layer/socket-private.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/socket-wrappers.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/mono-poll.h>
 #include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
 
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <netdb.h>
 #endif
 
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
 static guint32 in_cleanup = 0;
 
 static void socket_close (gpointer handle, gpointer data);
@@ -85,7 +81,7 @@ static void socket_close (gpointer handle, gpointer data)
        int ret;
        struct _WapiHandle_socket *socket_handle = (struct _WapiHandle_socket *)data;
 
-       DEBUG ("%s: closing socket handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: closing socket handle %p", __func__, handle);
 
        /* Shutdown the socket for reading, to interrupt any potential
         * receives that may be blocking for data.  See bug 75705.
@@ -99,7 +95,7 @@ static void socket_close (gpointer handle, gpointer data)
        
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: close error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: close error: %s", __func__, strerror (errno));
                errnum = errno_to_WSA (errnum, __func__);
                if (!in_cleanup)
                        WSASetLastError (errnum);
@@ -118,7 +114,7 @@ cleanup_close (gpointer handle, gpointer data)
 
 void _wapi_cleanup_networking(void)
 {
-       DEBUG ("%s: cleaning up", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: cleaning up", __func__);
 
        in_cleanup = 1;
        _wapi_handle_foreach (WAPI_HANDLE_SOCKET, cleanup_close, NULL);
@@ -183,7 +179,7 @@ guint32 _wapi_accept(guint32 fd, struct sockaddr *addr, socklen_t *addrlen)
 
        if (new_fd == -1) {
                gint errnum = errno;
-               DEBUG ("%s: accept error: %s", __func__, strerror(errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: accept error: %s", __func__, strerror(errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -192,7 +188,7 @@ guint32 _wapi_accept(guint32 fd, struct sockaddr *addr, socklen_t *addrlen)
        }
 
        if (new_fd >= _wapi_fd_reserve) {
-               DEBUG ("%s: File descriptor is too big", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big", __func__);
 
                WSASetLastError (WSASYSCALLFAILURE);
                
@@ -214,7 +210,7 @@ guint32 _wapi_accept(guint32 fd, struct sockaddr *addr, socklen_t *addrlen)
                return(INVALID_SOCKET);
        }
 
-       DEBUG ("%s: returning newly accepted socket handle %p with",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning newly accepted socket handle %p with",
                   __func__, new_handle);
        
        return(new_fd);
@@ -233,7 +229,7 @@ int _wapi_bind(guint32 fd, struct sockaddr *my_addr, socklen_t addrlen)
        ret = bind (fd, my_addr, addrlen);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: bind error: %s", __func__, strerror(errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: bind error: %s", __func__, strerror(errno));
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
                
@@ -263,7 +259,7 @@ int _wapi_connect(guint32 fd, const struct sockaddr *serv_addr,
                errnum = errno;
                
                if (errno != EINTR) {
-                       DEBUG ("%s: connect error: %s", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect error: %s", __func__,
                                   strerror (errnum));
 
                        errnum = errno_to_WSA (errnum, __func__);
@@ -301,7 +297,7 @@ int _wapi_connect(guint32 fd, const struct sockaddr *serv_addr,
                        if (errno != EINTR) {
                                errnum = errno_to_WSA (errno, __func__);
 
-                               DEBUG ("%s: connect poll error: %s",
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect poll error: %s",
                                           __func__, strerror (errno));
 
                                WSASetLastError (errnum);
@@ -314,7 +310,7 @@ int _wapi_connect(guint32 fd, const struct sockaddr *serv_addr,
                                &len) == -1) {
                        errnum = errno_to_WSA (errno, __func__);
 
-                       DEBUG ("%s: connect getsockopt error: %s",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt error: %s",
                                   __func__, strerror (errno));
 
                        WSASetLastError (errnum);
@@ -333,7 +329,7 @@ int _wapi_connect(guint32 fd, const struct sockaddr *serv_addr,
                                socket_handle->saved_error = errnum;
                        }
                        
-                       DEBUG ("%s: connect getsockopt returned error: %s",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: connect getsockopt returned error: %s",
                                   __func__, strerror (so_error));
 
                        WSASetLastError (errnum);
@@ -357,7 +353,7 @@ int _wapi_getpeername(guint32 fd, struct sockaddr *name, socklen_t *namelen)
        ret = getpeername (fd, name, namelen);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: getpeername error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getpeername error: %s", __func__,
                           strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
@@ -382,7 +378,7 @@ int _wapi_getsockname(guint32 fd, struct sockaddr *name, socklen_t *namelen)
        ret = getsockname (fd, name, namelen);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: getsockname error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockname error: %s", __func__,
                           strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
@@ -419,7 +415,7 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval,
        ret = getsockopt (fd, level, optname, tmp_val, optlen);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: getsockopt error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: getsockopt error: %s", __func__,
                           strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
@@ -471,7 +467,7 @@ int _wapi_listen(guint32 fd, int backlog)
        ret = listen (fd, backlog);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: listen error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: listen error: %s", __func__, strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -534,7 +530,7 @@ int _wapi_recvfrom(guint32 fd, void *buf, size_t len, int recv_flags,
        
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: recv error: %s", __func__, strerror(errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recv error: %s", __func__, strerror(errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -574,7 +570,7 @@ _wapi_recvmsg(guint32 fd, struct msghdr *msg, int recv_flags)
        
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: recvmsg error: %s", __func__, strerror(errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: recvmsg error: %s", __func__, strerror(errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -601,7 +597,7 @@ int _wapi_send(guint32 fd, const void *msg, size_t len, int send_flags)
 
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: send error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, strerror (errno));
 
 #ifdef O_NONBLOCK
                /* At least linux returns EAGAIN/EWOULDBLOCK when the timeout has been set on
@@ -638,7 +634,7 @@ int _wapi_sendto(guint32 fd, const void *msg, size_t len, int send_flags,
 
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: send error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: send error: %s", __func__, strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -666,7 +662,7 @@ _wapi_sendmsg(guint32 fd,  const struct msghdr *msg, int send_flags)
 
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: sendmsg error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: sendmsg error: %s", __func__, strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -719,7 +715,7 @@ int _wapi_setsockopt(guint32 fd, int level, int optname,
        ret = setsockopt (fd, level, optname, tmp_val, optlen);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: setsockopt error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: setsockopt error: %s", __func__,
                           strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
@@ -773,7 +769,7 @@ int _wapi_shutdown(guint32 fd, int how)
        ret = shutdown (fd, how);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: shutdown error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: shutdown error: %s", __func__,
                           strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
@@ -808,7 +804,7 @@ guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
        
        if (fd == -1) {
                gint errnum = errno;
-               DEBUG ("%s: socket error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, strerror (errno));
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
 
@@ -816,7 +812,7 @@ guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
        }
 
        if (fd >= _wapi_fd_reserve) {
-               DEBUG ("%s: File descriptor is too big (%d >= %d)",
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File descriptor is too big (%d >= %d)",
                           __func__, fd, _wapi_fd_reserve);
 
                WSASetLastError (WSASYSCALLFAILURE);
@@ -848,7 +844,7 @@ guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
                if (ret == -1) {
                        int errnum = errno;
 
-                       DEBUG ("%s: Error setting SO_REUSEADDR", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error setting SO_REUSEADDR", __func__);
                        
                        errnum = errno_to_WSA (errnum, __func__);
                        WSASetLastError (errnum);
@@ -870,7 +866,7 @@ guint32 _wapi_socket(int domain, int type, int protocol, void *unused,
                return(INVALID_SOCKET);
        }
 
-       DEBUG ("%s: returning socket handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: returning socket handle %p", __func__, handle);
 
        return(fd);
 }
@@ -896,7 +892,7 @@ static gboolean socket_disconnect (guint32 fd)
        if (newsock == -1) {
                gint errnum = errno;
 
-               DEBUG ("%s: socket error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: socket error: %s", __func__, strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -916,7 +912,7 @@ static gboolean socket_disconnect (guint32 fd)
        if (ret == -1) {
                gint errnum = errno;
                
-               DEBUG ("%s: dup2 error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: dup2 error: %s", __func__, strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -932,7 +928,7 @@ static gboolean socket_disconnect (guint32 fd)
 static gboolean wapi_disconnectex (guint32 fd, WapiOverlapped *overlapped,
                                   guint32 flags, guint32 reserved)
 {
-       DEBUG ("%s: called on socket %d!", __func__, fd);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: called on socket %d!", __func__, fd);
        
        if (reserved != 0) {
                WSASetLastError (WSAEINVAL);
@@ -1171,7 +1167,7 @@ WSAIoctl (guint32 fd, gint32 command,
        ret = ioctl (fd, command, buffer);
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG("%s: WSAIoctl error: %s", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: WSAIoctl error: %s", __func__,
                          strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
@@ -1264,7 +1260,7 @@ int ioctlsocket(guint32 fd, unsigned long command, gpointer arg)
 
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: ioctl error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: ioctl error: %s", __func__, strerror (errno));
 
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
@@ -1301,7 +1297,7 @@ int _wapi_select(int nfds G_GNUC_UNUSED, fd_set *readfds, fd_set *writefds,
 
        if (ret == -1) {
                gint errnum = errno;
-               DEBUG ("%s: select error: %s", __func__, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: select error: %s", __func__, strerror (errno));
                errnum = errno_to_WSA (errnum, __func__);
                WSASetLastError (errnum);
                
index 8a147e1f2e46c0a9fd9124814a548df3ccd2c1ec..6b811b0a3bfec31f8add6846cf568d311c1e185b 100644 (file)
 #include <mono/io-layer/versioninfo.h>
 #include <mono/io-layer/io-portability.h>
 #include <mono/io-layer/error.h>
+#include <mono/io-layer/io-trace.h>
 #include <mono/utils/strenc.h>
 #include <mono/utils/mono-mmap.h>
-
-#if 0
-// #define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/utils/mono-logger-internals.h>
 
 #define ALIGN32(ptr) ptr = (gpointer)((char *)ptr + 3); ptr = (gpointer)((char *)ptr - ((gsize)ptr & 3));
 
@@ -163,14 +159,14 @@ find_pe_file_resources32 (gpointer file_map, guint32 map_size,
 
        dos_header = (WapiImageDosHeader *)file_map;
        if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
-               DEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
        }
        
        if (map_size < sizeof(WapiImageNTHeaders32) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
-               DEBUG ("%s: File is too small: %d", __func__, map_size);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File is too small: %d", __func__, map_size);
 
                SetLastError (ERROR_BAD_LENGTH);
                return(NULL);
@@ -178,7 +174,7 @@ find_pe_file_resources32 (gpointer file_map, guint32 map_size,
        
        nt_headers = (WapiImageNTHeaders32 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
        if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
-               DEBUG ("%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
@@ -192,7 +188,7 @@ find_pe_file_resources32 (gpointer file_map, guint32 map_size,
        }
 
        if (resource_rva == 0) {
-               DEBUG ("%s: No resources in file!", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No resources in file!", __func__);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
@@ -200,7 +196,7 @@ find_pe_file_resources32 (gpointer file_map, guint32 map_size,
        
        resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
        if (resource_dir == NULL) {
-               DEBUG ("%s: Can't find resource directory", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find resource directory", __func__);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
@@ -237,14 +233,14 @@ find_pe_file_resources64 (gpointer file_map, guint32 map_size,
 
        dos_header = (WapiImageDosHeader *)file_map;
        if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
-               DEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
        }
        
        if (map_size < sizeof(WapiImageNTHeaders64) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
-               DEBUG ("%s: File is too small: %d", __func__, map_size);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File is too small: %d", __func__, map_size);
 
                SetLastError (ERROR_BAD_LENGTH);
                return(NULL);
@@ -252,7 +248,7 @@ find_pe_file_resources64 (gpointer file_map, guint32 map_size,
        
        nt_headers = (WapiImageNTHeaders64 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
        if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
-               DEBUG ("%s: Bad NT signature 0x%x", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Bad NT signature 0x%x", __func__,
                           nt_headers->Signature);
 
                SetLastError (ERROR_INVALID_DATA);
@@ -267,7 +263,7 @@ find_pe_file_resources64 (gpointer file_map, guint32 map_size,
        }
 
        if (resource_rva == 0) {
-               DEBUG ("%s: No resources in file!", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: No resources in file!", __func__);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
@@ -275,7 +271,7 @@ find_pe_file_resources64 (gpointer file_map, guint32 map_size,
        
        resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
        if (resource_dir == NULL) {
-               DEBUG ("%s: Can't find resource directory", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Can't find resource directory", __func__);
 
                SetLastError (ERROR_INVALID_DATA);
                return(NULL);
@@ -328,7 +324,7 @@ map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
 
        filename_ext = mono_unicode_to_external (filename);
        if (filename_ext == NULL) {
-               DEBUG ("%s: unicode conversion returned NULL", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unicode conversion returned NULL", __func__);
 
                SetLastError (ERROR_INVALID_NAME);
                return(NULL);
@@ -336,7 +332,7 @@ map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
        
        fd = _wapi_open (filename_ext, O_RDONLY, 0);
        if (fd == -1) {
-               DEBUG ("%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
 
                SetLastError (_wapi_get_win32_file_error (errno));
                g_free (filename_ext);
@@ -345,7 +341,7 @@ map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
        }
 
        if (fstat (fd, &statbuf) == -1) {
-               DEBUG ("%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
 
                SetLastError (_wapi_get_win32_file_error (errno));
                g_free (filename_ext);
@@ -356,7 +352,7 @@ map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
        
        /* Check basic file size */
        if (statbuf.st_size < sizeof(WapiImageDosHeader)) {
-               DEBUG ("%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
 
                SetLastError (ERROR_BAD_LENGTH);
                g_free (filename_ext);
@@ -366,7 +362,7 @@ map_pe_file (gunichar2 *filename, gint32 *map_size, void **handle)
        
        file_map = mono_file_map (statbuf.st_size, MONO_MMAP_READ | MONO_MMAP_PRIVATE, fd, 0, handle);
        if (file_map == NULL) {
-               DEBUG ("%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
 
                SetLastError (_wapi_get_win32_file_error (errno));
                g_free (filename_ext);
@@ -473,12 +469,12 @@ get_fixedfileinfo_block (gconstpointer data, version_data *block)
        data_ptr = get_versioninfo_block (data, block);
                
        if (block->value_len != sizeof(WapiFixedFileInfo)) {
-               DEBUG ("%s: FIXEDFILEINFO size mismatch", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: FIXEDFILEINFO size mismatch", __func__);
                return(NULL);
        }
 
        if (!unicode_string_equals (block->key, "VS_VERSION_INFO")) {
-               DEBUG ("%s: VS_VERSION_INFO mismatch", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: VS_VERSION_INFO mismatch", __func__);
 
                return(NULL);
        }
@@ -486,7 +482,7 @@ get_fixedfileinfo_block (gconstpointer data, version_data *block)
        ffi = ((WapiFixedFileInfo *)data_ptr);
        if ((ffi->dwSignature != VS_FFI_SIGNATURE) ||
            (ffi->dwStrucVersion != VS_FFI_STRUCVERSION)) {
-               DEBUG ("%s: FIXEDFILEINFO bad signature", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: FIXEDFILEINFO bad signature", __func__);
 
                return(NULL);
        }
@@ -528,7 +524,7 @@ get_string_block (gconstpointer data_ptr,
                        /* We must have hit padding, so give up
                         * processing now
                         */
-                       DEBUG ("%s: Hit 0-length block, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
 
                        return(NULL);
                }
@@ -584,7 +580,7 @@ get_stringtable_block (gconstpointer data_ptr,
                        /* We must have hit padding, so give up
                         * processing now
                         */
-                       DEBUG ("%s: Hit 0-length block, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
                        return(NULL);
                }
                
@@ -592,7 +588,7 @@ get_stringtable_block (gconstpointer data_ptr,
 
                found_lang = g_utf16_to_utf8 (block->key, 8, NULL, NULL, NULL);
                if (found_lang == NULL) {
-                       DEBUG ("%s: Didn't find a valid language key, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid language key, giving up", __func__);
                        return(NULL);
                }
                
@@ -615,7 +611,7 @@ get_stringtable_block (gconstpointer data_ptr,
                
                if (data_ptr == NULL) {
                        /* Child block hit padding */
-                       DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
                        return(NULL);
                }
        }
@@ -645,7 +641,7 @@ big_up_string_block (gconstpointer data_ptr, version_data *block)
                        /* We must have hit padding, so give up
                         * processing now
                         */
-                       DEBUG ("%s: Hit 0-length block, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
                        return(NULL);
                }
                
@@ -656,7 +652,7 @@ big_up_string_block (gconstpointer data_ptr, version_data *block)
                                       "UTF-16BE", "UTF-16LE", NULL, NULL,
                                       NULL);
                if (big_value == NULL) {
-                       DEBUG ("%s: Didn't find a valid string, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid string, giving up", __func__);
                        return(NULL);
                }
                
@@ -673,7 +669,7 @@ big_up_string_block (gconstpointer data_ptr, version_data *block)
                                       "UTF-16BE", "UTF-16LE", NULL, NULL,
                                       NULL);
                if (big_value == NULL) {
-                       DEBUG ("%s: Didn't find a valid data string, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid data string, giving up", __func__);
                        return(NULL);
                }
                memcpy ((gpointer)data_ptr, big_value,
@@ -712,7 +708,7 @@ big_up_stringtable_block (gconstpointer data_ptr, version_data *block)
                        /* We must have hit padding, so give up
                         * processing now
                         */
-                       DEBUG ("%s: Hit 0-length block, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
                        return(NULL);
                }
                
@@ -721,7 +717,7 @@ big_up_stringtable_block (gconstpointer data_ptr, version_data *block)
                big_value = g_convert ((gchar *)block->key, 16, "UTF-16BE",
                                       "UTF-16LE", NULL, NULL, NULL);
                if (big_value == NULL) {
-                       DEBUG ("%s: Didn't find a valid string, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Didn't find a valid string, giving up", __func__);
                        return(NULL);
                }
                
@@ -732,7 +728,7 @@ big_up_stringtable_block (gconstpointer data_ptr, version_data *block)
                
                if (data_ptr == NULL) {
                        /* Child block hit padding */
-                       DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
                        return(NULL);
                }
        }
@@ -784,7 +780,7 @@ big_up (gconstpointer datablock, guint32 size)
                                /* We must have hit padding, so give
                                 * up processing now
                                 */
-                               DEBUG ("%s: Hit 0-length block, giving up", __func__);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
                                return;
                        }
                        
@@ -800,13 +796,13 @@ big_up (gconstpointer datablock, guint32 size)
                                                                     &block);
                        } else {
                                /* Bogus data */
-                               DEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Not a valid VERSIONINFO child block", __func__);
                                return;
                        }
                        
                        if (data_ptr == NULL) {
                                /* Child block hit padding */
-                               DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
                                return;
                        }
                }
@@ -878,7 +874,7 @@ VerQueryValue (gconstpointer datablock, const gunichar2 *subblock, gpointer *buf
                                        /* We must have hit padding,
                                         * so give up processing now
                                         */
-                                       DEBUG ("%s: Hit 0-length block, giving up", __func__);
+                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Hit 0-length block, giving up", __func__);
                                        goto done;
                                }
                                
@@ -907,13 +903,13 @@ VerQueryValue (gconstpointer datablock, const gunichar2 *subblock, gpointer *buf
                                        }
                                } else {
                                        /* Bogus data */
-                                       DEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
+                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Not a valid VERSIONINFO child block", __func__);
                                        goto done;
                                }
                                
                                if (data_ptr == NULL) {
                                        /* Child block hit padding */
-                                       DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+                                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Child block hit 0-length block, giving up", __func__);
                                        goto done;
                                }
                        }
index 2d94e91d4fdf7955bfe7d7cd9e164ba5552a02fa..82a441ee3b8c71a792c3186fb6111db4be7f8a7a 100644 (file)
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/wapi-private.h>
-
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
+#include <mono/io-layer/io-trace.h>
+#include <mono/utils/mono-logger-internals.h>
 
 static gboolean own_if_signalled(gpointer handle)
 {
@@ -113,7 +109,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
        
        if (_wapi_handle_test_capabilities (handle,
                                            WAPI_HANDLE_CAP_WAIT) == FALSE) {
-               DEBUG ("%s: handle %p can't be waited for", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p can't be waited for", __func__,
                           handle);
 
                return(WAIT_FAILED);
@@ -122,7 +118,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
        _wapi_handle_ops_prewait (handle);
        
        if (_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_SPECIAL_WAIT) == TRUE) {
-               DEBUG ("%s: handle %p has special wait", __func__, handle);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p has special wait", __func__, handle);
 
                ret = _wapi_handle_ops_special_wait (handle, timeout, alertable);
        
@@ -133,7 +129,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
        }
        
        
-       DEBUG ("%s: locking handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handle %p", __func__, handle);
 
        thr_ret = _wapi_handle_lock_handle (handle);
        g_assert (thr_ret == 0);
@@ -141,7 +137,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
        if (_wapi_handle_test_capabilities (handle,
                                            WAPI_HANDLE_CAP_OWN) == TRUE) {
                if (own_if_owned (handle) == TRUE) {
-                       DEBUG ("%s: handle %p already owned", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already owned", __func__,
                                   handle);
                        ret = WAIT_OBJECT_0;
                        goto done;
@@ -149,7 +145,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
        }
 
        if (own_if_signalled (handle) == TRUE) {
-               DEBUG ("%s: handle %p already signalled", __func__,
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already signalled", __func__,
                           handle);
 
                ret=WAIT_OBJECT_0;
@@ -167,7 +163,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
                _wapi_handle_ops_prewait (handle);
 
                if (own_if_signalled (handle)) {
-                       DEBUG ("%s: handle %p signalled", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__,
                                   handle);
 
                        ret = WAIT_OBJECT_0;
@@ -182,7 +178,7 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
                         * if someone else got in before us.)
                         */
                        if (own_if_signalled (handle)) {
-                               DEBUG ("%s: handle %p signalled", __func__,
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__,
                                           handle);
 
                                ret=WAIT_OBJECT_0;
@@ -194,14 +190,14 @@ guint32 WaitForSingleObjectEx(gpointer handle, guint32 timeout,
        } while(waited == 0 && !apc_pending);
 
        /* Timeout or other error */
-       DEBUG ("%s: wait on handle %p error: %s", __func__, handle,
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: wait on handle %p error: %s", __func__, handle,
                   strerror (waited));
 
        ret = apc_pending ? WAIT_IO_COMPLETION : WAIT_TIMEOUT;
 
 done:
 
-       DEBUG ("%s: unlocking handle %p", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handle %p", __func__, handle);
        
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
@@ -253,7 +249,7 @@ guint32 WaitForSingleObject(gpointer handle, guint32 timeout)
 guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
                            guint32 timeout, gboolean alertable)
 {
-       guint32 ret, waited;
+       guint32 ret = 0, waited;
        int thr_ret;
        gboolean apc_pending = FALSE;
        gpointer current_thread = wapi_get_current_thread_handle ();
@@ -308,7 +304,7 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
                return (WAIT_FAILED);
        }
 
-       DEBUG ("%s: locking handle %p", __func__, wait);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handle %p", __func__, wait);
 
        thr_ret = _wapi_handle_lock_handle (wait);
        g_assert (thr_ret == 0);
@@ -317,7 +313,7 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
 
        if (_wapi_handle_test_capabilities (wait, WAPI_HANDLE_CAP_OWN)==TRUE) {
                if (own_if_owned (wait)) {
-                       DEBUG ("%s: handle %p already owned", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already owned", __func__,
                                   wait);
                        ret = WAIT_OBJECT_0;
                        goto done;
@@ -325,7 +321,7 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
        }
 
        if (own_if_signalled (wait)) {
-               DEBUG ("%s: handle %p already signalled", __func__, wait);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p already signalled", __func__, wait);
 
                ret = WAIT_OBJECT_0;
                goto done;
@@ -337,7 +333,7 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
                _wapi_handle_ops_prewait (wait);
        
                if (own_if_signalled (wait)) {
-                       DEBUG ("%s: handle %p signalled", __func__, wait);
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__, wait);
 
                        ret = WAIT_OBJECT_0;
                        goto done;
@@ -351,7 +347,7 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
                         * if someone else got in before us.)
                         */
                        if (own_if_signalled (wait)) {
-                               DEBUG ("%s: handle %p signalled", __func__,
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: handle %p signalled", __func__,
                                           wait);
 
                                ret = WAIT_OBJECT_0;
@@ -363,14 +359,13 @@ guint32 SignalObjectAndWait(gpointer signal_handle, gpointer wait,
        } while(waited == 0 && !apc_pending);
 
        /* Timeout or other error */
-       DEBUG ("%s: wait on handle %p error: %s", __func__, wait,
-                  strerror (ret));
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: wait on handle %p error: %s", __func__, wait, strerror (ret));
 
        ret = apc_pending ? WAIT_IO_COMPLETION : WAIT_TIMEOUT;
 
 done:
 
-       DEBUG ("%s: unlocking handle %p", __func__, wait);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handle %p", __func__, wait);
 
        thr_ret = _wapi_handle_unlock_handle (wait);
        g_assert (thr_ret == 0);
@@ -385,7 +380,7 @@ static gboolean test_and_own (guint32 numobjects, gpointer *handles,
        gboolean done;
        int i;
        
-       DEBUG ("%s: locking handles", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking handles", __func__);
        
        done = _wapi_handle_count_signalled_handles (numobjects, handles,
                                                     waitall, count, lowest);
@@ -399,7 +394,7 @@ static gboolean test_and_own (guint32 numobjects, gpointer *handles,
                }
        }
        
-       DEBUG ("%s: unlocking handles", __func__);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking handles", __func__);
 
        _wapi_handle_unlock_handles (numobjects, handles);
 
@@ -457,7 +452,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
        }
        
        if (numobjects > MAXIMUM_WAIT_OBJECTS) {
-               DEBUG ("%s: Too many handles: %d", __func__, numobjects);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Too many handles: %d", __func__, numobjects);
 
                return(WAIT_FAILED);
        }
@@ -472,7 +467,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
                        handles[i] = wapi_get_current_thread_handle ();
                        
                        if (handles[i] == NULL) {
-                               DEBUG ("%s: Handle %d bogus", __func__, i);
+                               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %d bogus", __func__, i);
 
                                bogustype = TRUE;
                                break;
@@ -480,7 +475,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
                }
 
                if ((GPOINTER_TO_UINT (handles[i]) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED) {
-                       DEBUG ("%s: Handle %d pseudo process", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %d pseudo process", __func__,
                                   i);
 
                        bogustype = TRUE;
@@ -488,7 +483,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
                }
 
                if (_wapi_handle_test_capabilities (handles[i], WAPI_HANDLE_CAP_WAIT) == FALSE) {
-                       DEBUG ("%s: Handle %p can't be waited for",
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Handle %p can't be waited for",
                                   __func__, handles[i]);
 
                        bogustype = TRUE;
@@ -508,13 +503,13 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
        }
 
        if (duplicate == TRUE) {
-               DEBUG ("%s: Returning due to duplicates", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning due to duplicates", __func__);
 
                return(WAIT_FAILED);
        }
 
        if (bogustype == TRUE) {
-               DEBUG ("%s: Returning due to bogus type", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Returning due to bogus type", __func__);
 
                return(WAIT_FAILED);
        }
@@ -556,7 +551,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
                        }
                }
                
-               DEBUG ("%s: locking signal mutex", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: locking signal mutex", __func__);
 
                thr_ret = _wapi_handle_lock_signal_mutex ();
                g_assert (thr_ret == 0);
@@ -582,7 +577,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
                        ret = 0;
                }
 
-               DEBUG ("%s: unlocking signal mutex", __func__);
+               MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: unlocking signal mutex", __func__);
 
                thr_ret = _wapi_handle_unlock_signal_mutex (NULL);
                g_assert (thr_ret == 0);
@@ -605,7 +600,7 @@ guint32 WaitForMultipleObjectsEx(guint32 numobjects, gpointer *handles,
                        /* Didn't get all handles, and there was a
                         * timeout or other error
                         */
-                       DEBUG ("%s: wait returned error: %s", __func__,
+                       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: wait returned error: %s", __func__,
                                   strerror (ret));
 
                        if(ret==ETIMEDOUT) {
index c9c8a907240d84b4aa2d9e00d76dd563954fbef3..bb65b5f799cd44f8279b4419777e5a16210f6aa9 100644 (file)
 #include <mono/io-layer/handles-private.h>
 #include <mono/io-layer/thread-private.h>
 #include <mono/io-layer/mutex-private.h>
+#include <mono/io-layer/io-trace.h>
 
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/atomic.h>
 #include <mono/utils/mono-time.h>
 #include <mono/utils/mono-once.h>
+#include <mono/utils/mono-logger-internals.h>
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
 #include <valgrind/memcheck.h>
 #endif
 
-#if 0
-#define DEBUG(...) g_message(__VA_ARGS__)
-#else
-#define DEBUG(...)
-#endif
-
-#if 0
-#define WAIT_DEBUG(code) do { code } while (0)
-#else
-#define WAIT_DEBUG(code) do { } while (0)
-#endif
-
 struct _WapiHandleOps _wapi_thread_ops = {
        NULL,                           /* close */
        NULL,                           /* signal */
@@ -126,11 +116,11 @@ wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus)
                return;
        }
 
-       DEBUG ("%s: Thread %p terminating", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Thread %p terminating", __func__, handle);
 
        thread_handle = lookup_thread (handle);
 
-       DEBUG ("%s: Thread %p abandoning held mutexes", __func__, handle);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Thread %p abandoning held mutexes", __func__, handle);
 
        for (i = 0; i < thread_handle->owned_mutexes->len; i++) {
                gpointer mutex = g_ptr_array_index (thread_handle->owned_mutexes, i);
@@ -148,7 +138,7 @@ wapi_thread_handle_set_exited (gpointer handle, guint32 exitstatus)
        thr_ret = _wapi_handle_unlock_handle (handle);
        g_assert (thr_ret == 0);
        
-       DEBUG("%s: Recording thread handle %p id %ld status as %d",
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: Recording thread handle %p id %ld status as %d",
                  __func__, handle, thread_handle->id, exitstatus);
        
        /* The thread is no longer active, so unref it */
@@ -188,7 +178,7 @@ wapi_create_thread_handle (void)
         */
        _wapi_handle_ref (handle);
 
-       DEBUG ("%s: started thread id %ld", __func__, thread->id);
+       MONO_TRACE (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_LAYER, "%s: started thread id %ld", __func__, thread->id);
        
        return handle;
 }
index a0d7c20748e1601b1e384f22cb8a78f544beb16d..ff8b646fbd6bdba9095bb14d71ecbc9f92f78e73 100644 (file)
@@ -216,8 +216,7 @@ common_sources = \
        seq-points-data.h       \
        seq-points-data.c       \
        handle.c        \
-       handle.h        \
-       handle-private.h
+       handle.h
 
 
 # These source files have compile time dependencies on GC code
index 184fb62150895e0498f046c6f032517dd8c2d825..7f85924e80c05dd9436661d3cbfb4204ff048d79 100644 (file)
@@ -110,7 +110,7 @@ static void
 add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *hash);
 
 static MonoAppDomain *
-mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *setup);
+mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *setup, MonoError *error);
 
 static char *
 get_shadow_assembly_location_base (MonoDomain *domain, MonoError *error);
@@ -278,7 +278,7 @@ mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
 
        /* mscorlib is loaded before we install the load hook */
        mono_domain_fire_assembly_load (mono_defaults.corlib->assembly, NULL);
-       
+
        return;
 }
 
@@ -392,6 +392,7 @@ mono_runtime_quit ()
 MonoDomain *
 mono_domain_create_appdomain (char *friendly_name, char *configuration_file)
 {
+       MonoError error;
        MonoAppDomain *ad;
        MonoAppDomainSetup *setup;
        MonoClass *klass;
@@ -400,7 +401,8 @@ mono_domain_create_appdomain (char *friendly_name, char *configuration_file)
        setup = (MonoAppDomainSetup *) mono_object_new (mono_domain_get (), klass);
        setup->configuration_file = configuration_file != NULL ? mono_string_new (mono_domain_get (), configuration_file) : NULL;
 
-       ad = mono_domain_create_appdomain_internal (friendly_name, setup);
+       ad = mono_domain_create_appdomain_internal (friendly_name, setup, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
 
        return mono_domain_from_appdomain (ad);
 }
@@ -460,14 +462,13 @@ copy_app_domain_setup (MonoDomain *domain, MonoAppDomainSetup *setup)
 }
 
 static MonoAppDomain *
-mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *setup)
+mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *setup, MonoError *error)
 {
-       MonoError error;
        MonoClass *adclass;
        MonoAppDomain *ad;
        MonoDomain *data;
        char *shadow_location;
-       
+
        adclass = mono_class_from_name (mono_defaults.corlib, "System", "AppDomain");
 
        /* FIXME: pin all those objects */
@@ -490,14 +491,15 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetup *
        mono_context_init (data);
 
        data->setup = copy_app_domain_setup (data, setup);
-       mono_set_private_bin_path_from_config (data);
+       mono_domain_set_options_from_config (data);
        add_assemblies_to_domain (data, mono_defaults.corlib->assembly, NULL);
 
 #ifndef DISABLE_SHADOW_COPY
        /*FIXME, guard this for when the debugger is not running */
-       shadow_location = get_shadow_assembly_location_base (data, &error);
-       if (!mono_error_ok (&error))
-               mono_error_raise_exception (&error);
+       shadow_location = get_shadow_assembly_location_base (data, error);
+       if (!mono_error_ok (error))
+               return NULL;
+
        g_free (shadow_location);
 #endif
 
@@ -710,6 +712,14 @@ ves_icall_System_AppDomain_getRootDomain ()
        return root->domain;
 }
 
+MonoBoolean
+ves_icall_System_CLRConfig_CheckThrowUnobservedTaskExceptions ()
+{
+       MonoDomain *domain = mono_domain_get ();
+
+       return domain->throw_unobserved_task_exceptions;
+}
+
 static char*
 get_attribute_value (const gchar **attribute_names, 
                     const gchar **attribute_values, 
@@ -742,8 +752,18 @@ start_element (GMarkupParseContext *context,
                runtime_config->assemblybinding_count++;
                return;
        }
-       
-       if (runtime_config->runtime_count != 1 || runtime_config->assemblybinding_count != 1)
+
+       if (runtime_config->runtime_count != 1)
+               return;
+
+       if (strcmp (element_name, "ThrowUnobservedTaskExceptions") == 0) {
+               const char *value = get_attribute_value (attribute_names, attribute_values, "enabled");
+
+               if (value && g_ascii_strcasecmp (value, "true") == 0)
+                       runtime_config->domain->throw_unobserved_task_exceptions = TRUE;
+       }
+
+       if (runtime_config->assemblybinding_count != 1)
                return;
 
        if (strcmp (element_name, "probing") != 0)
@@ -793,7 +813,7 @@ mono_parser = {
 };
 
 void
-mono_set_private_bin_path_from_config (MonoDomain *domain)
+mono_domain_set_options_from_config (MonoDomain *domain)
 {
        MonoError error;
        gchar *config_file_name = NULL, *text = NULL, *config_file_path = NULL;
@@ -846,11 +866,17 @@ ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomai
        mono_set_pending_exception (mono_get_exception_not_supported ("AppDomain creation is not supported on this runtime."));
        return NULL;
 #else
-       char *fname = mono_string_to_utf8 (friendly_name);
-       MonoAppDomain *ad = mono_domain_create_appdomain_internal (fname, setup);
-       
+       MonoError error;
+       char *fname;
+       MonoAppDomain *ad;
+
+       fname = mono_string_to_utf8 (friendly_name);
+       ad = mono_domain_create_appdomain_internal (fname, setup, &error);
+
        g_free (fname);
 
+       mono_error_raise_exception (&error);
+
        return ad;
 #endif
 }
@@ -1231,8 +1257,9 @@ mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name)
 }
 
 char *
-mono_make_shadow_copy (const char *filename)
+mono_make_shadow_copy (const char *filename, MonoError *error)
 {
+       mono_error_init (error);
        return (char *) filename;
 }
 #else
@@ -1610,7 +1637,7 @@ or NULL if source file not found.
 FIXME bubble up the error instead of raising it here
 */
 char *
-mono_make_shadow_copy (const char *filename)
+mono_make_shadow_copy (const char *filename, MonoError *oerror)
 {
        MonoError error;
        gchar *sibling_source, *sibling_target;
@@ -1619,13 +1646,14 @@ mono_make_shadow_copy (const char *filename)
        guint32 attrs;
        char *shadow;
        gboolean copy_result;
-       MonoException *exc;
        struct stat src_sbuf;
        struct utimbuf utbuf;
        char *dir_name = g_path_get_dirname (filename);
        MonoDomain *domain = mono_domain_get ();
        char *shadow_dir;
 
+       mono_error_init (oerror);
+
        set_domain_search_path (domain);
 
        if (!mono_is_shadow_copy_enabled (domain, dir_name)) {
@@ -1638,8 +1666,8 @@ mono_make_shadow_copy (const char *filename)
        if (!mono_error_ok (&error)) {
                mono_error_cleanup (&error);
                g_free (dir_name);
-               exc = mono_get_exception_execution_engine ("Failed to create shadow copy (invalid characters in shadow directory name).");
-               mono_raise_exception (exc);
+               mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Failed to create shadow copy (invalid characters in shadow directory name).");
+               return NULL;
        }
 
        if (strstr (dir_name, shadow_dir)) {
@@ -1653,14 +1681,14 @@ mono_make_shadow_copy (const char *filename)
        shadow = get_shadow_assembly_location (filename, &error);
        if (!mono_error_ok (&error)) {
                mono_error_cleanup (&error);
-               exc = mono_get_exception_execution_engine ("Failed to create shadow copy (invalid characters in file name).");
-               mono_raise_exception (exc);
+               mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Failed to create shadow copy (invalid characters in file name).");
+               return NULL;
        }
 
        if (ensure_directory_exists (shadow) == FALSE) {
                g_free (shadow);
-               exc = mono_get_exception_execution_engine ("Failed to create shadow copy (ensure directory exists).");
-               mono_raise_exception (exc);
+               mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Failed to create shadow copy (ensure directory exists).");
+               return NULL;
        }       
 
        if (!private_file_needs_copying (filename, &src_sbuf, shadow))
@@ -1696,8 +1724,8 @@ mono_make_shadow_copy (const char *filename)
                if (GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND)
                        return NULL; /* file not found, shadow copy failed */
 
-               exc = mono_get_exception_execution_engine ("Failed to create shadow copy (CopyFile).");
-               mono_raise_exception (exc);
+               mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Failed to create shadow copy (CopyFile).");
+               return NULL;
        }
 
        /* attempt to copy .mdb, .config if they exist */
@@ -1715,15 +1743,15 @@ mono_make_shadow_copy (const char *filename)
        
        if (copy_result == FALSE)  {
                g_free (shadow);
-               exc = mono_get_exception_execution_engine ("Failed to create shadow copy of sibling data (CopyFile).");
-               mono_raise_exception (exc);
+               mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Failed to create shadow copy of sibling data (CopyFile).");
+               return NULL;
        }
 
        /* Create a .ini file containing the original assembly location */
        if (!shadow_copy_create_ini (shadow, filename)) {
                g_free (shadow);
-               exc = mono_get_exception_execution_engine ("Failed to create shadow copy .ini file.");
-               mono_raise_exception (exc);
+               mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Failed to create shadow copy .ini file.");
+               return NULL;
        }
 
        utbuf.actime = src_sbuf.st_atime;
index a3916463b691522ce18b0f11b87e17c1d5195102..f381d464b98988397e28d31466b705fd7f6d4e01 100644 (file)
@@ -1577,8 +1577,11 @@ mono_assembly_open_full (const char *filename, MonoImageOpenStatus *status, gboo
                        "Assembly Loader probing location: '%s'.", fname);
 
        new_fname = NULL;
-       if (!mono_assembly_is_in_gac (fname))
-               new_fname = mono_make_shadow_copy (fname);
+       if (!mono_assembly_is_in_gac (fname)) {
+               MonoError error;
+               new_fname = mono_make_shadow_copy (fname, &error);
+               mono_error_raise_exception (&error); /* FIXME don't raise here */
+       }
        if (new_fname && new_fname != fname) {
                g_free (fname);
                fname = new_fname;
index 0bd92412414f81254439cbe17c0edc83af451273..d26a8c2e9aab5952c3f480906ecbfdea7f5a412b 100644 (file)
@@ -190,7 +190,6 @@ mono_gc_base_init (void)
 
        GC_init ();
 
-       GC_oom_fn = mono_gc_out_of_memory;
        GC_set_warn_proc (mono_gc_warning);
        GC_finalize_on_demand = 1;
        GC_finalizer_notifier = mono_gc_finalize_notify;
@@ -630,6 +629,8 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
 
        if (!vtable->klass->has_references) {
                obj = (MonoObject *)GC_MALLOC_ATOMIC (size);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
 
                obj->vtable = vtable;
                obj->synchronisation = NULL;
@@ -637,8 +638,12 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
                memset ((char *) obj + sizeof (MonoObject), 0, size - sizeof (MonoObject));
        } else if (vtable->gc_descr != GC_NO_DESCRIPTOR) {
                obj = (MonoObject *)GC_GCJ_MALLOC (size, vtable);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
        } else {
                obj = (MonoObject *)GC_MALLOC (size);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
 
                obj->vtable = vtable;
        }
@@ -656,6 +661,8 @@ mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length)
 
        if (!vtable->klass->has_references) {
                obj = (MonoArray *)GC_MALLOC_ATOMIC (size);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
 
                obj->obj.vtable = vtable;
                obj->obj.synchronisation = NULL;
@@ -663,8 +670,12 @@ mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length)
                memset ((char *) obj + sizeof (MonoObject), 0, size - sizeof (MonoObject));
        } else if (vtable->gc_descr != GC_NO_DESCRIPTOR) {
                obj = (MonoArray *)GC_GCJ_MALLOC (size, vtable);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
        } else {
                obj = (MonoArray *)GC_MALLOC (size);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
 
                obj->obj.vtable = vtable;
        }
@@ -684,6 +695,8 @@ mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uint
 
        if (!vtable->klass->has_references) {
                obj = (MonoArray *)GC_MALLOC_ATOMIC (size);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
 
                obj->obj.vtable = vtable;
                obj->obj.synchronisation = NULL;
@@ -691,8 +704,12 @@ mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uint
                memset ((char *) obj + sizeof (MonoObject), 0, size - sizeof (MonoObject));
        } else if (vtable->gc_descr != GC_NO_DESCRIPTOR) {
                obj = (MonoArray *)GC_GCJ_MALLOC (size, vtable);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
        } else {
                obj = (MonoArray *)GC_MALLOC (size);
+               if (G_UNLIKELY (!obj))
+                       return NULL;
 
                obj->obj.vtable = vtable;
        }
@@ -712,6 +729,8 @@ void *
 mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len)
 {
        MonoString *obj = (MonoString *)GC_MALLOC_ATOMIC (size);
+       if (G_UNLIKELY (!obj))
+               return NULL;
 
        obj->object.vtable = vtable;
        obj->object.synchronisation = NULL;
@@ -724,6 +743,18 @@ mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len)
        return obj;
 }
 
+void*
+mono_gc_alloc_mature (MonoVTable *vtable, size_t size)
+{
+       return mono_gc_alloc_obj (vtable, size);
+}
+
+void*
+mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size)
+{
+       return mono_gc_alloc_obj (vtable, size);
+}
+
 int
 mono_gc_invoke_finalizers (void)
 {
@@ -1040,7 +1071,7 @@ create_allocator (int atype, int tls_key, gboolean slowpath)
                mono_mb_emit_icall (mb, mono_string_alloc);
        } else {
                mono_mb_emit_ldarg (mb, 0);
-               mono_mb_emit_icall (mb, mono_object_new_specific);
+               mono_mb_emit_icall (mb, ves_icall_object_new_specific);
        }
 
        mono_mb_emit_byte (mb, MONO_CEE_RET);
index bf2b5c6a8e93c109408a607a10113e4eefbcfee7..28a25a1f8f7c68f9a4011e80f355cf4926940a27 100644 (file)
@@ -1326,7 +1326,10 @@ char*
 mono_type_get_full_name (MonoClass *klass);
 
 char *
-mono_method_get_name_full (MonoMethod *method, gboolean signature, MonoTypeNameFormat format);
+mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, MonoTypeNameFormat format);
+
+char *
+mono_method_get_full_name (MonoMethod *method);
 
 MonoArrayType *mono_dup_array_type (MonoImage *image, MonoArrayType *a);
 MonoMethodSignature *mono_metadata_signature_deep_dup (MonoImage *image, MonoMethodSignature *sig);
index 9c4c8e60d371401b4c8b96845db4122bd7ca7d3c..7f5372e48085093436c950efbcf6b2e74d473179 100644 (file)
@@ -1600,6 +1600,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal
 MonoObject *
 ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type)
 {
+       MonoError error;
        MonoClass *klass;
        MonoDomain *domain;
        MonoObject *obj;
@@ -1607,13 +1608,15 @@ ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type)
        domain = mono_object_domain (type);
        klass = mono_class_from_mono_type (type->type);
 
-       /* call mono_object_new_alloc_specific instead of mono_object_new
+       /* call mono_object_new_alloc_specific_checked instead of mono_object_new
         * because we want to actually create object. mono_object_new checks
         * to see if type is import and creates transparent proxy. this method
         * is called by the corresponding real proxy to create the real RCW.
         * Constructor does not need to be called. Will be called later.
        */
-       obj = mono_object_new_alloc_specific (mono_class_vtable_full (domain, klass, TRUE));
+       obj = mono_object_new_alloc_specific_checked (mono_class_vtable_full (domain, klass, TRUE), &error);
+       mono_error_raise_exception (&error);
+
        return obj;
 }
 
index 0ac3b3981f1a6dc5d0bc3f83c317c4c031321635..5a4d518c230720b5e985d3ea1d34edbb2dc5f7ab 100644 (file)
@@ -345,19 +345,19 @@ console_set_signal_handlers ()
        
        // Continuing
        sigcont.sa_handler = (void (*)(int)) sigcont_handler;
-       sigcont.sa_flags = 0;
+       sigcont.sa_flags = SA_RESTART;
        sigemptyset (&sigcont.sa_mask);
        sigaction (SIGCONT, &sigcont, &save_sigcont);
        
        // Interrupt handler
        sigint.sa_handler = (void (*)(int)) sigint_handler;
-       sigint.sa_flags = 0;
+       sigint.sa_flags = SA_RESTART;
        sigemptyset (&sigint.sa_mask);
        sigaction (SIGINT, &sigint, &save_sigint);
 
        // Window size changed
        sigwinch.sa_handler = (void (*)(int)) sigwinch_handler;
-       sigwinch.sa_flags = 0;
+       sigwinch.sa_flags = SA_RESTART;
        sigemptyset (&sigwinch.sa_mask);
        sigaction (SIGWINCH, &sigwinch, &save_sigwinch);
 #endif
index 300cce8fd978697e9bef3b2c17cafb1126a4083e..99925e156d6afdf65de185660864236c099e7c4a 100644 (file)
@@ -307,93 +307,93 @@ static const NumberFormatEntry number_format_entries [] = {
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 37097, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37122, 36960, 36962, 36966, 37126, 36937, 37139, 37144, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37149, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37122, 36960, 36962, 36966, 36927, 36937, 2438, 37126, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37131, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37152, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37162, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37166, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37170, 37180, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37134, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37144, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37148, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37152, 37162, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37189, 36960, 36962, 36966, 37193, 37212, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37231, 36960, 36962, 36966, 37078, 37152, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36951, 691, 37234, 37238, 36960, 36962, 36966, 37242, 37251, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37171, 36960, 36962, 36966, 37175, 37194, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37213, 36960, 36962, 36966, 37078, 37134, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36951, 691, 37216, 37220, 36960, 36962, 36966, 37224, 37233, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37260, 36960, 37268, 36966, 37285, 37313, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37340, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 2, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37242, 36960, 37250, 36966, 37267, 37295, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37322, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 2, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37000, 37012, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 36951, 37343, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 36951, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37356, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37360, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37364, 36960, 37367, 36966, 37390, 36937, 37406, 37414, 3, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37422, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37425, 36960, 37429, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37446, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37450, 37464, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 36951, 37325, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 36951, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37338, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37342, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37346, 36960, 37349, 36966, 37372, 36937, 37388, 37396, 3, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37404, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37407, 36960, 37411, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37428, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37432, 37446, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 36972, 36960, 37477, 36966, 37491, 37503, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 37514, 36891, 36951, 37516, 36960, 36962, 36966, 37519, 37530, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 36972, 36960, 37459, 36966, 37473, 37485, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 37496, 36891, 36951, 37498, 36960, 36962, 36966, 37501, 37512, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36891, 0, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
-       {185, 36891, 185, 36893, 37540, 36906, 37549, 36924, 37560, 36937, 37575, 37414, 3, 0, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37582, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 37586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {185, 36891, 185, 36893, 37522, 36906, 37531, 36924, 37542, 36937, 37557, 37396, 3, 0, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37564, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37568, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 691, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37592, 37602, 2438, 36970, 8, 3, 10, 3, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37611, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37574, 37584, 2438, 36970, 8, 3, 10, 3, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37593, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36951, 10586, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36951, 10586, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 10586, 36960, 37618, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 37514, 36891, 36951, 10586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 0, 36960, 37624, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 10586, 36960, 37600, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 37496, 36891, 36951, 10586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 0, 36960, 37606, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
        {691, 36891, 691, 36891, 36972, 36960, 0, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 36972, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 36972, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36972, 36960, 0, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37669, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37651, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {2438, 36951, 36891, 36951, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 0, 36960, 37672, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37689, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 0, 36960, 37654, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37671, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36893, 0, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37693, 36960, 37700, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37675, 36960, 37682, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 0, 1, 2, 2, {3, 2}, {3, 2}},
        {691, 36891, 691, 36891, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, 2}, {3, 2}},
-       {37727, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, 2}, {3, 2}},
+       {37709, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
        {36891, 36951, 36891, 36891, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36993, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
-       {691, 36891, 691, 36891, 37729, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 37732, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 2, 2, 2, {3, -1}, {3, 0}},
-       {691, 36891, 691, 691, 37736, 36960, 37740, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, 0}, {3, 0}},
+       {691, 36891, 691, 36891, 37711, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37714, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 2, 2, 2, {3, -1}, {3, 0}},
+       {691, 36891, 691, 691, 37718, 36960, 37722, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, 0}, {3, 0}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37665, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37777, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, 2}},
-       {691, 36891, 691, 36891, 37785, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 1, {3, 0}, {3, 0}},
-       {36891, 37514, 36891, 36951, 0, 36960, 0, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37792, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 2}},
-       {691, 36891, 691, 36893, 37805, 36906, 0, 36966, 36927, 36937, 2438, 36970, 3, 0, 4, 2, 3, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37808, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37647, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37759, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, 2}},
+       {691, 36891, 691, 36891, 37767, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 1, {3, 0}, {3, 0}},
+       {36891, 37496, 36891, 36951, 0, 36960, 0, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37774, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 2}},
+       {691, 36891, 691, 36893, 37787, 36906, 0, 36966, 36927, 36937, 2438, 36970, 3, 0, 4, 2, 3, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37790, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 0, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37812, 36960, 0, 36966, 36927, 36937, 2438, 36970, 9, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37794, 36960, 0, 36966, 36927, 36937, 2438, 36970, 9, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36951, 10586, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 0}, {3, 0}},
-       {691, 36891, 691, 36891, 37812, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 0}, {3, 0}},
+       {691, 36891, 691, 36891, 37794, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36993, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 0}},
        {36891, 36951, 36891, 36951, 36972, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 37234, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36891, 37260, 36960, 0, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 691, 37816, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37729, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 37216, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36891, 37242, 36960, 0, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 691, 37798, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37711, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36893, 36896, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36954, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 36976, 36985, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37819, 36960, 37823, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37801, 36960, 37805, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36996, 36960, 36962, 36966, 37000, 37012, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
@@ -401,992 +401,992 @@ static const NumberFormatEntry number_format_entries [] = {
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 37097, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37122, 36960, 36962, 36966, 37126, 36937, 37139, 37144, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37149, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37122, 36960, 36962, 36966, 36927, 36937, 2438, 37126, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37131, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37152, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37162, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37166, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37170, 37180, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37134, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37144, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37148, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37152, 37162, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37189, 36960, 36962, 36966, 37193, 37212, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37231, 36960, 36962, 36966, 37078, 37152, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36951, 691, 37234, 37238, 36960, 36962, 36966, 37242, 37251, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37171, 36960, 36962, 36966, 37175, 37194, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37213, 36960, 36962, 36966, 37078, 37134, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36951, 691, 37216, 37220, 36960, 36962, 36966, 37224, 37233, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37260, 36960, 37268, 36966, 37285, 37313, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37340, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 2, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37242, 36960, 37250, 36966, 37267, 37295, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37322, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 2, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37000, 37012, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 36951, 37343, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 36951, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37356, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37360, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37364, 36960, 37367, 36966, 37390, 36937, 37406, 37414, 3, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37422, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37425, 36960, 37429, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37446, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37450, 37464, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 36951, 37325, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 36951, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37338, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37342, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37346, 36960, 37349, 36966, 37372, 36937, 37388, 37396, 3, 0, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37404, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37407, 36960, 37411, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 37428, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37432, 37446, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 36972, 36960, 37477, 36966, 37491, 37503, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 37514, 36891, 36951, 37516, 36960, 36962, 36966, 37519, 37530, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36891, 37833, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
-       {185, 36891, 185, 36893, 37540, 36906, 37549, 36924, 37560, 36937, 37575, 37414, 3, 0, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37582, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 37586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 691, 37840, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37592, 37602, 2438, 36970, 8, 3, 10, 3, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37611, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 36972, 36960, 37459, 36966, 37473, 37485, 2438, 36970, 9, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 37496, 36891, 36951, 37498, 36960, 36962, 36966, 37501, 37512, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36891, 37815, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
+       {185, 36891, 185, 36893, 37522, 36906, 37531, 36924, 37542, 36937, 37557, 37396, 3, 0, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37564, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37568, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 691, 37822, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37574, 37584, 2438, 36970, 8, 3, 10, 3, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37593, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36951, 10586, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36951, 10586, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 10586, 36960, 37618, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 37514, 36891, 36951, 10586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 0, 36960, 37624, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 10586, 36960, 37600, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 37496, 36891, 36951, 10586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 0, 36960, 37606, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
        {691, 36891, 691, 36891, 36972, 36960, 0, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37689, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36893, 37845, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37665, 36960, 37700, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37665, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, 2}, {3, 2}},
-       {37727, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {36891, 36951, 36891, 36951, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37671, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36893, 37827, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37647, 36960, 37682, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 2, 2, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37647, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, 2}, {3, 2}},
+       {37709, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
        {691, 36891, 691, 36891, 36993, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
-       {691, 36891, 691, 36891, 37729, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 37732, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 2, 2, 2, {3, -1}, {3, 0}},
-       {691, 36891, 691, 691, 37736, 36960, 37740, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, 0}, {3, 0}},
+       {691, 36891, 691, 36891, 37711, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37714, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 2, 2, 2, {3, -1}, {3, 0}},
+       {691, 36891, 691, 691, 37718, 36960, 37722, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, 0}, {3, 0}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37665, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36891, 37777, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, 2}},
-       {691, 36891, 691, 36891, 37785, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 1, {3, 0}, {3, 0}},
-       {691, 36891, 691, 36891, 37792, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 2}},
-       {691, 36891, 691, 36893, 37805, 36906, 0, 36966, 36927, 36937, 2438, 36970, 3, 0, 4, 2, 3, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37808, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37812, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37812, 36960, 0, 36966, 36927, 36937, 2438, 36970, 9, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37647, 36960, 0, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36891, 37759, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, 2}},
+       {691, 36891, 691, 36891, 37767, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 1, {3, 0}, {3, 0}},
+       {691, 36891, 691, 36891, 37774, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 2}},
+       {691, 36891, 691, 36893, 37787, 36906, 0, 36966, 36927, 36937, 2438, 36970, 3, 0, 4, 2, 3, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37790, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37794, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37794, 36960, 0, 36966, 36927, 36937, 2438, 36970, 9, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36951, 10586, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 2, 2, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37024, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 0}, {3, 0}},
-       {691, 36891, 691, 36891, 37812, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37024, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, 0}, {3, 0}},
+       {691, 36891, 691, 36891, 37794, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36993, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 0}},
        {36891, 36951, 36891, 36951, 36972, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36891, 37260, 36960, 0, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 691, 37816, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37729, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 37851, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37162, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36951, 36891, 37861, 37238, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37729, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36891, 37242, 36960, 0, 36966, 36927, 36937, 2438, 36970, 5, 1, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 691, 37798, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37711, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37833, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37144, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36951, 36891, 37843, 37220, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37711, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36951, 36891, 37861, 37238, 36960, 36962, 36966, 37078, 37152, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37170, 37180, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36951, 36891, 37843, 37220, 36960, 36962, 36966, 37078, 37134, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37152, 37162, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37078, 37152, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 36972, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 691, 37863, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37078, 37134, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 36972, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 691, 37845, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36972, 36960, 0, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36893, 37871, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37878, 36960, 37700, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 0, 1, 2, 2, {3, 2}, {3, 2}},
-       {691, 36891, 691, 36893, 37882, 36906, 36962, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37076, 36960, 37823, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36893, 37853, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37860, 36960, 37682, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 0, 1, 2, 2, {3, 2}, {3, 2}},
+       {691, 36891, 691, 36893, 37864, 36906, 36962, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37076, 36960, 37805, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 37076, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 15, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36951, 36972, 36960, 37349, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 37892, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 0, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36951, 36972, 36960, 37331, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37874, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 0, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 7920, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36951, 36891, 37861, 37238, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37902, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 2, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 37905, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37915, 36960, 37823, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 37861, 0, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36951, 36891, 37843, 37220, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37884, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 2, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37887, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37897, 36960, 37805, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 37843, 0, 36960, 36962, 36966, 37027, 37038, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37920, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 0, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37902, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 0, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 691, 36972, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37902, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 37924, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37884, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37906, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36972, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37934, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37916, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 36972, 36960, 36962, 36966, 37106, 37114, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37902, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 37938, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37884, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37920, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 10586, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37948, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 37953, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37930, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37935, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 1, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37963, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37948, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 37967, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37945, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37930, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37949, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 1, 0, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37977, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 37982, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37959, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37964, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37992, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37996, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 38004, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37974, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37978, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 37986, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 691, 38014, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 691, 37996, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 0, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 36972, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 38024, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37808, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 38006, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37790, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 9, 2, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 38034, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 38016, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
        {36891, 691, 36891, 691, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 9, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 38044, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 38054, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36893, 38058, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37665, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, 2}, {3, 2}},
-       {36891, 691, 36891, 691, 38068, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 38026, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 3, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 38036, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 0, 0, 1, 0, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36893, 38040, 36906, 36909, 36924, 36927, 36937, 2438, 36946, 3, 2, 0, 0, 3, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37647, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, 2}, {3, 2}},
+       {36891, 691, 36891, 691, 38050, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 14, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 0, 0, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 2308, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 12, 2, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 38071, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 38053, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 1, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 37076, 36960, 36962, 36966, 37078, 37088, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, 0}},
-       {36891, 691, 36891, 691, 37948, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37902, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 38074, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 38082, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 691, 37863, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37930, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37884, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 38056, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 38064, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 691, 37845, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {691, 36891, 691, 36891, 36993, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 2, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 37902, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 691, 37840, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36893, 37871, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 691, 36891, 691, 37884, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 691, 37822, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36893, 37853, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36891, 0, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 38087, 36960, 37823, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 38087, 36960, 37823, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 38069, 36960, 37805, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 38069, 36960, 37805, 36966, 36927, 36937, 2438, 36970, 0, 0, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
        {36891, 36951, 36891, 36951, 37024, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 12, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 691, 36891, 691, 38082, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
-       {36891, 36951, 36891, 36891, 37833, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
-       {36891, 36951, 36891, 36893, 37845, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
-       {36891, 37514, 36891, 36951, 0, 36960, 0, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
-       {691, 36891, 691, 36891, 37812, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}}
+       {36891, 691, 36891, 691, 38064, 36960, 36962, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, -1}, {3, -1}},
+       {36891, 36951, 36891, 36891, 37815, 36960, 0, 36966, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 2, 2, {3, 0}, {3, 0}},
+       {36891, 36951, 36891, 36893, 37827, 36906, 36962, 36924, 36927, 36937, 2438, 36970, 8, 3, 1, 1, 1, 0, 2, {3, -1}, {3, -1}},
+       {36891, 37496, 36891, 36951, 0, 36960, 0, 36966, 37106, 37114, 2438, 36970, 8, 3, 0, 0, 1, 2, 2, {3, -1}, {3, -1}},
+       {691, 36891, 691, 36891, 37794, 36960, 0, 36966, 36927, 36937, 2438, 36970, 2, 2, 0, 0, 1, 2, 2, {3, -1}, {3, -1}}
 };
 
 
 static const CultureInfoEntry culture_entries [] = {
-       {0x0001, 0x007F, 768, -1, 38091, 38094, 38101, 38116, 38120, 38091, 0, {0, 0, 38124, 0}, 0, 0, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x0002, 0x007F, 257, -1, 38152, 38155, 38165, 38184, 38188, 38152, 0, {38192, 0, 0, 0}, 1, 1, { 1251, 21025, 10007, 866, 0, ';' }},
-       {0x0003, 0x007F, 257, -1, 38234, 38237, 38245, 38253, 38257, 38234, 0, {38261, 0, 0, 0}, 2, 2, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0004, 0x0004, 257, -1, 38281, 38288, 38316, 38323, 38327, 38331, 0, {38334, 0, 0, 0}, 3, 3, { 936, 500, 10008, 936, 0, ',' }},
-       {0x0004, 0x7804, 257, -1, 38341, 38349, 38316, 38323, 38327, 38331, 0, {38334, 0, 0, 0}, 4, 4, { 936, 500, 10008, 936, 0, ',' }},
-       {0x0005, 0x007F, 257, -1, 38370, 38373, 38379, 38389, 38393, 38370, 0, {38397, 0, 0, 0}, 5, 5, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x0006, 0x007F, 257, -1, 38423, 38426, 38433, 38439, 38443, 38423, 0, {38447, 0, 0, 0}, 6, 6, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0007, 0x007F, 257, -1, 38468, 38471, 38478, 38486, 38490, 38468, 0, {38494, 0, 0, 0}, 7, 7, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x0008, 0x007F, 257, -1, 38519, 38522, 38528, 38545, 38549, 38519, 0, {38553, 0, 0, 0}, 8, 8, { 1253, 20273, 10006, 737, 0, ';' }},
-       {0x0009, 0x007F, 257, -1, 38595, 38598, 38598, 38606, 38610, 38595, 0, {38614, 0, 0, 0}, 9, 9, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x000A, 0x007F, 257, -1, 38633, 38636, 38644, 38653, 38657, 38633, 0, {38661, 0, 0, 0}, 10, 10, { 1252, 20284, 10000, 850, 0, ';' }},
-       {0x000B, 0x007F, 257, -1, 38683, 38686, 38694, 38700, 38704, 38683, 0, {38708, 0, 0, 0}, 11, 11, { 1252, 20278, 10000, 850, 0, ';' }},
-       {0x000C, 0x007F, 257, -1, 38733, 38736, 38743, 38753, 38757, 38733, 0, {38761, 0, 0, 0}, 12, 12, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x000D, 0x007F, 257, -1, 38783, 38786, 38793, 38804, 38808, 38783, 0, {38812, 0, 0, 0}, 13, 13, { 1255, 500, 10005, 862, 1, ',' }},
-       {0x000E, 0x007F, 257, -1, 38845, 38848, 38858, 38865, 38869, 38845, 0, {38873, 0, 0, 0}, 14, 14, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x000F, 0x007F, 257, -1, 38889, 38892, 38902, 38912, 38916, 38889, 0, {38920, 0, 0, 0}, 15, 15, { 1252, 20871, 10079, 850, 0, ';' }},
-       {0x0010, 0x007F, 257, -1, 38940, 38943, 38951, 38960, 38964, 38940, 0, {38968, 0, 0, 0}, 16, 16, { 1252, 20280, 10000, 850, 0, ';' }},
-       {0x0011, 0x007F, 257, -1, 38990, 38993, 39002, 39012, 39016, 38990, 0, {39020, 0, 0, 0}, 17, 17, { 932, 20290, 10001, 932, 0, ',' }},
-       {0x0012, 0x007F, 257, -1, 39047, 39050, 39057, 39067, 39071, 39047, 0, {39075, 0, 0, 0}, 18, 18, { 949, 20833, 10003, 949, 0, ',' }},
-       {0x0013, 0x007F, 257, -1, 39085, 39088, 39094, 39105, 39109, 39085, 0, {39113, 0, 0, 0}, 19, 19, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0014, 0x007F, 257, -1, 39135, 39138, 39148, 39154, 39158, 39162, 0, {38447, 0, 0, 0}, 20, 20, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0015, 0x007F, 257, -1, 39165, 39168, 39175, 39182, 39186, 39165, 0, {39190, 0, 0, 0}, 21, 21, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x0016, 0x007F, 257, -1, 39214, 39217, 39228, 39239, 39243, 39214, 0, {39247, 0, 0, 0}, 22, 22, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0017, 0x007F, 257, -1, 39270, 39273, 39281, 39291, 39295, 39270, 0, {39299, 0, 0, 0}, 23, 23, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x0018, 0x007F, 257, -1, 39319, 39322, 39331, 39340, 39344, 39319, 0, {39348, 0, 0, 0}, 24, 24, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x0019, 0x007F, 257, -1, 39367, 39370, 39378, 39393, 39397, 39367, 0, {39401, 0, 0, 0}, 25, 25, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x001A, 0x007F, 257, -1, 39447, 39450, 39459, 39468, 39472, 39447, 0, {39476, 0, 0, 0}, 26, 26, { 1250, 500, 10082, 852, 0, ';' }},
-       {0x001B, 0x007F, 257, -1, 12674, 39499, 39506, 39518, 39522, 12674, 0, {39526, 0, 0, 0}, 27, 27, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x001C, 0x007F, 257, -1, 39550, 39553, 39562, 39568, 39572, 39550, 0, {39576, 0, 0, 0}, 28, 28, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x001D, 0x007F, 257, -1, 39596, 39599, 39607, 39615, 39619, 39596, 0, {38447, 0, 0, 0}, 29, 29, { 1252, 20278, 10000, 850, 0, ';' }},
-       {0x001E, 0x007F, 512, -1, 39623, 39626, 39631, 39641, 39645, 39623, 0, {0, 39649, 0, 0}, 30, 30, { 874, 20838, 10021, 874, 0, ',' }},
-       {0x001F, 0x007F, 257, -1, 12683, 39680, 39688, 39697, 39701, 12683, 0, {39705, 0, 0, 0}, 31, 31, { 1254, 20905, 10081, 857, 0, ';' }},
-       {0x0020, 0x007F, 257, -1, 39719, 39722, 39727, 39736, 39740, 39719, 0, {39744, 0, 0, 0}, 32, 32, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x0021, 0x007F, 257, -1, 39774, 39777, 39788, 39805, 39809, 39774, 0, {39813, 0, 0, 0}, 33, 33, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0022, 0x007F, 257, -1, 39832, 39835, 39845, 39866, 39870, 39832, 0, {39874, 0, 0, 0}, 34, 34, { 1251, 500, 10017, 866, 0, ';' }},
-       {0x0023, 0x007F, 257, -1, 39920, 39923, 39934, 39955, 39959, 39920, 0, {39963, 0, 0, 0}, 35, 35, { 1251, 500, 10007, 866, 0, ';' }},
-       {0x0024, 0x007F, 257, -1, 40005, 40008, 40018, 40032, 40036, 40005, 0, {40040, 0, 0, 0}, 36, 36, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x0025, 0x007F, 257, -1, 40062, 40065, 40074, 40080, 40084, 40062, 0, {40088, 0, 0, 0}, 37, 37, { 1257, 500, 10029, 775, 0, ';' }},
-       {0x0026, 0x007F, 257, -1, 40108, 40111, 40119, 40129, 40133, 40108, 0, {40137, 0, 0, 0}, 38, 38, { 1257, 500, 10029, 775, 0, ';' }},
-       {0x0027, 0x007F, 257, -1, 40156, 40159, 40170, 40180, 40184, 40156, 0, {40188, 0, 0, 0}, 39, 39, { 1257, 500, 10029, 775, 0, ';' }},
-       {0x0028, 0x007F, 257, -1, 40211, 40214, 40220, 40233, 40237, 40211, 0, {0, 0, 0, 0}, 40, 40, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0029, 0x007F, 257, -1, 40241, 40244, 40252, 40263, 40267, 40241, 0, {40271, 0, 0, 0}, 41, 41, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x002A, 0x007F, 257, -1, 40295, 40298, 40309, 40324, 35137, 40295, 0, {40328, 0, 0, 0}, 42, 42, { 1258, 500, 10000, 1258, 0, ',' }},
-       {0x002B, 0x007F, 257, -1, 40343, 40346, 40355, 40370, 40374, 40343, 0, {40378, 0, 0, 0}, 43, 43, { 0, 500, 2, 1, 0, ',' }},
-       {0x002C, 0x007F, 257, -1, 40408, 40411, 40423, 40435, 40439, 40408, 0, {40443, 0, 0, 0}, 44, 44, { 1254, 20905, 10081, 857, 0, ';' }},
-       {0x002D, 0x007F, 257, -1, 40462, 40465, 40472, 40480, 40484, 40462, 0, {40488, 0, 0, 0}, 45, 45, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x002F, 0x007F, 257, -1, 40508, 40511, 40522, 40543, 40547, 40508, 0, {40551, 0, 0, 0}, 46, 46, { 1251, 500, 10007, 866, 0, ';' }},
-       {0x0032, 0x007F, 257, -1, 40595, 40598, 40605, 40614, 40618, 40595, 0, {0, 0, 0, 0}, 47, 47, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0034, 0x007F, 257, -1, 40622, 40625, 40631, 40640, 40644, 40622, 0, {0, 0, 0, 0}, 48, 48, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0035, 0x007F, 257, -1, 40648, 40651, 40656, 40664, 40668, 40648, 0, {40672, 0, 0, 0}, 49, 49, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0036, 0x007F, 257, -1, 40693, 40696, 40696, 40706, 40710, 40693, 0, {40714, 0, 0, 0}, 50, 50, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0037, 0x007F, 257, -1, 40734, 40737, 40746, 40768, 40772, 40734, 0, {40776, 0, 0, 0}, 51, 51, { 0, 500, 2, 1, 0, ';' }},
-       {0x0038, 0x007F, 257, -1, 40841, 40844, 40852, 40862, 40866, 40841, 0, {0, 0, 0, 0}, 52, 52, { 1252, 20277, 10079, 850, 0, ';' }},
-       {0x0039, 0x007F, 257, -1, 40870, 40873, 40879, 40895, 40899, 40870, 0, {40903, 0, 0, 0}, 53, 53, { 0, 500, 2, 1, 0, ',' }},
-       {0x003A, 0x007F, 257, -1, 40956, 40959, 40967, 40973, 40977, 40956, 0, {40981, 0, 0, 0}, 54, 54, { 0, 500, 2, 1, 0, ',' }},
-       {0x003B, 0x007F, 257, -1, 41002, 41005, 41019, 41036, 41040, 41002, 0, {41044, 0, 0, 0}, 55, 55, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x003C, 0x007F, 257, -1, 41063, 41066, 41072, 41080, 41084, 41063, 0, {41088, 0, 0, 0}, 56, 56, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x003E, 0x007F, 257, -1, 41109, 41112, 41118, 41132, 41136, 41109, 0, {41140, 0, 0, 0}, 57, 57, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x003F, 0x007F, 257, -1, 41157, 41160, 41167, 41187, 41191, 41157, 0, {41195, 0, 0, 0}, 58, 58, { 0, 500, 2, 1, 0, ';' }},
-       {0x0040, 0x007F, 257, -1, 41237, 41240, 41247, 41264, 41268, 41237, 0, {41272, 0, 0, 0}, 59, 59, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0041, 0x007F, 257, -1, 41310, 41313, 41321, 41331, 41335, 41310, 0, {41339, 0, 0, 0}, 60, 60, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x0043, 0x007F, 257, -1, 41360, 41363, 41369, 41380, 41384, 41360, 0, {41388, 0, 0, 0}, 61, 61, { 1254, 500, 10029, 857, 0, ';' }},
-       {0x0045, 0x007F, 257, -1, 41408, 41411, 41419, 41435, 41439, 41408, 0, {41443, 0, 0, 0}, 62, 62, { 0, 500, 2, 1, 0, ',' }},
-       {0x0046, 0x007F, 257, -1, 41508, 41511, 41519, 41538, 41542, 41508, 0, {41546, 0, 0, 0}, 63, 63, { 0, 500, 2, 1, 0, ',' }},
-       {0x0047, 0x007F, 257, -1, 41593, 41596, 41605, 41627, 41631, 41593, 0, {41635, 0, 0, 0}, 64, 64, { 0, 500, 2, 1, 0, ',' }},
-       {0x0048, 0x007F, 257, -1, 41691, 41694, 41700, 41716, 41720, 41691, 0, {0, 0, 0, 0}, 65, 65, { 0, 500, 2, 1, 0, ',' }},
-       {0x0049, 0x007F, 257, -1, 41724, 41727, 41733, 41749, 41753, 41724, 0, {41757, 0, 0, 0}, 66, 66, { 0, 500, 2, 1, 0, ',' }},
-       {0x004A, 0x007F, 257, -1, 41822, 41825, 41832, 41851, 41855, 41822, 0, {41859, 0, 0, 0}, 67, 67, { 0, 500, 2, 1, 0, ',' }},
-       {0x004B, 0x007F, 257, -1, 37340, 41924, 41932, 41948, 41952, 37340, 0, {41956, 0, 0, 0}, 68, 68, { 0, 500, 2, 1, 0, ',' }},
-       {0x004C, 0x007F, 257, -1, 42021, 42024, 42034, 42053, 42057, 42021, 0, {42061, 0, 0, 0}, 69, 69, { 0, 500, 2, 1, 0, ',' }},
-       {0x004D, 0x007F, 257, -1, 42105, 42108, 42117, 42139, 42143, 42105, 0, {42147, 0, 0, 0}, 70, 70, { 0, 500, 2, 1, 0, ',' }},
-       {0x004E, 0x007F, 257, -1, 42200, 42203, 42211, 42227, 2402, 42200, 0, {42231, 0, 0, 0}, 71, 71, { 0, 500, 2, 1, 0, ',' }},
-       {0x0050, 0x007F, 257, -1, 42293, 42296, 42306, 42319, 42323, 42293, 0, {42327, 0, 0, 0}, 72, 72, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0051, 0x007F, 257, -1, 42359, 42362, 42370, 42395, 42399, 42359, 0, {0, 0, 0, 0}, 73, 73, { 0, 500, 2, 1, 0, ',' }},
-       {0x0052, 0x007F, 257, -1, 42403, 42406, 42412, 42420, 42424, 42403, 0, {42428, 0, 0, 0}, 74, 74, { 1252, 20285, 10000, 850, 0, ',' }},
-       {0x0053, 0x007F, 257, -1, 42444, 42447, 42453, 42469, 42473, 42444, 0, {42477, 0, 0, 0}, 75, 75, { 0, 500, 2, 1, 0, ',' }},
-       {0x0054, 0x007F, 257, -1, 42532, 42535, 42539, 42549, 42553, 42532, 0, {42557, 0, 0, 0}, 76, 76, { 0, 500, 2, 1, 0, ',' }},
-       {0x0056, 0x007F, 257, -1, 42603, 42606, 42615, 42622, 42626, 42603, 0, {38968, 0, 0, 0}, 77, 77, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0057, 0x007F, 257, -1, 42630, 42634, 42642, 42661, 42630, 42630, 0, {0, 0, 0, 0}, 78, 78, { 0, 500, 2, 1, 0, ',' }},
-       {0x005B, 0x007F, 257, -1, 42665, 42668, 42676, 42692, 42696, 42665, 0, {42700, 0, 0, 0}, 79, 79, { 0, 500, 2, 1, 0, ',' }},
-       {0x005E, 0x007F, 257, -1, 8022, 42759, 42767, 42780, 42784, 8022, 0, {42788, 0, 0, 0}, 80, 80, { 0, 500, 2, 1, 0, ';' }},
-       {0x005F, 0x007F, 257, -1, 42833, 42837, 42861, 42871, 42833, 42833, 0, {0, 0, 0, 0}, 81, 81, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x0061, 0x007F, 257, -1, 1883, 42875, 42882, 42901, 42905, 1883, 0, {42909, 0, 0, 0}, 82, 82, { 0, 500, 2, 1, 0, ',' }},
-       {0x0063, 0x007F, 1024, -1, 42959, 42962, 42969, 42978, 42982, 42959, 0, {0, 0, 0, 0}, 83, 83, { 0, 500, 2, 1, 1, ';' }},
-       {0x0064, 0x007F, 257, -1, 42986, 42990, 42990, 42999, 42986, 42986, 0, {43003, 0, 0, 0}, 84, 84, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x0068, 0x007F, 257, -1, 43026, 43029, 43029, 43035, 43039, 43026, 0, {0, 0, 0, 0}, 85, 85, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x006A, 0x007F, 257, -1, 43043, 43046, 43053, 43068, 43072, 43043, 0, {0, 0, 0, 0}, 86, 86, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x006C, 0x007F, 257, -1, 43076, 43080, 43095, 43112, 43076, 43076, 0, {0, 0, 0, 0}, 87, 87, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x006F, 0x007F, 257, -1, 43116, 43119, 43131, 43143, 43147, 43116, 0, {43151, 0, 0, 0}, 88, 88, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0070, 0x007F, 257, -1, 43178, 43181, 43181, 43186, 43190, 43178, 0, {0, 0, 0, 0}, 89, 89, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x0078, 0x007F, 257, -1, 43194, 43197, 43208, 43218, 43222, 43194, 0, {43226, 0, 0, 0}, 90, 90, { 0, 500, 2, 1, 0, ',' }},
-       {0x007E, 0x007F, 257, -1, 43239, 43242, 43249, 43259, 43263, 43239, 0, {43267, 0, 0, 0}, 91, 91, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x0084, 0x007F, 257, -1, 43287, 43291, 43304, 43323, 43287, 43287, 0, {43327, 0, 0, 0}, 92, 92, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x0085, 0x007F, 257, -1, 43352, 43356, 43362, 43380, 43352, 43352, 0, {0, 0, 0, 0}, 93, 93, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0087, 0x007F, 257, -1, 43384, 43387, 43387, 43399, 43403, 43384, 0, {0, 0, 0, 0}, 94, 94, { 1252, 37, 10000, 437, 0, ';' }},
-       {0x0091, 0x007F, 257, -1, 43407, 43410, 43426, 43436, 43440, 43407, 0, {43444, 0, 0, 0}, 95, 95, { 1252, 20285, 10000, 850, 0, ',' }},
-       {0x0401, 0x0001, 768, 95, 43469, 43475, 43497, 38116, 38120, 38091, 13629, {0, 0, 38124, 0}, 96, 96, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x0402, 0x0002, 257, 11, 43561, 43567, 43588, 38184, 38188, 38152, 43626, {38192, 0, 0, 0}, 97, 97, { 1251, 21025, 10007, 866, 0, ';' }},
-       {0x0403, 0x0003, 257, 31, 43629, 43635, 43651, 38253, 38257, 38234, 43669, {38261, 0, 0, 0}, 98, 98, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0404, 0x7C04, 257, 107, 43672, 43678, 43700, 43716, 38327, 38331, 43720, {43723, 0, 0, 0}, 99, 99, { 950, 500, 10002, 950, 0, ',' }},
-       {0x0405, 0x0005, 257, 23, 43730, 43736, 43759, 38389, 38393, 38370, 43789, {38397, 0, 0, 0}, 100, 100, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x0406, 0x0006, 257, 25, 43792, 43798, 43815, 38439, 38443, 38423, 43831, {38447, 0, 0, 0}, 101, 101, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0407, 0x0007, 257, 24, 43834, 43840, 43857, 38486, 38490, 38468, 43879, {38494, 0, 0, 0}, 102, 102, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x0408, 0x0008, 257, 39, 43882, 43888, 43903, 38545, 38549, 38519, 43935, {38553, 0, 0, 0}, 103, 103, { 1253, 20273, 10006, 737, 0, ';' }},
-       {0x0409, 0x0009, 257, 109, 43938, 43944, 43944, 38606, 38610, 38595, 43968, {38614, 0, 0, 0}, 104, 104, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x040B, 0x000B, 257, 33, 43971, 43977, 43995, 38700, 38704, 38683, 44009, {38708, 0, 0, 0}, 105, 105, { 1252, 20278, 10000, 850, 0, ';' }},
-       {0x040C, 0x000C, 257, 35, 44012, 44018, 44034, 38753, 38757, 38733, 44053, {38761, 0, 0, 0}, 106, 106, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x040D, 0x000D, 257, 47, 44056, 44062, 44078, 38804, 38808, 38783, 44102, {38812, 0, 0, 0}, 107, 107, { 1255, 500, 10005, 862, 1, ',' }},
-       {0x040E, 0x000E, 257, 44, 44105, 44111, 44131, 38865, 38869, 38845, 44154, {38873, 0, 0, 0}, 108, 108, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x040F, 0x000F, 257, 51, 44157, 44163, 44183, 38912, 38916, 38889, 44203, {38920, 0, 0, 0}, 109, 109, { 1252, 20871, 10079, 850, 0, ';' }},
-       {0x0410, 0x0010, 257, 52, 44206, 44212, 44228, 38960, 38964, 38940, 44246, {38968, 0, 0, 0}, 110, 110, { 1252, 20280, 10000, 850, 0, ';' }},
-       {0x0411, 0x0011, 257, 55, 44249, 44255, 44272, 39012, 39016, 38990, 44291, {39020, 0, 0, 0}, 111, 111, { 932, 20290, 10001, 932, 0, ',' }},
-       {0x0412, 0x0012, 257, 58, 44294, 44300, 44321, 39067, 39071, 39047, 44346, {39075, 0, 0, 0}, 112, 112, { 949, 20833, 10003, 949, 0, ',' }},
-       {0x0413, 0x0013, 257, 77, 44349, 44355, 44375, 39105, 39109, 39085, 44398, {39113, 0, 0, 0}, 113, 113, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0414, 0x7C14, 257, 78, 44401, 44407, 44434, 39154, 39158, 39162, 44456, {38447, 0, 0, 0}, 114, 114, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0415, 0x0015, 257, 86, 44459, 44465, 44481, 39182, 39186, 39165, 44497, {39190, 0, 0, 0}, 115, 115, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x0416, 0x0016, 257, 14, 44500, 44506, 44526, 39239, 39243, 39214, 44546, {39247, 0, 0, 0}, 116, 116, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0417, 0x0017, 257, 18, 44549, 44555, 44577, 39291, 39295, 39270, 13632, {39299, 0, 0, 0}, 117, 117, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x0418, 0x0018, 257, 91, 44596, 44602, 44621, 39340, 39344, 39319, 44641, {39348, 0, 0, 0}, 118, 118, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x0419, 0x0019, 257, 93, 44644, 44650, 44667, 39393, 39397, 39367, 44697, {39401, 0, 0, 0}, 119, 119, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x041A, 0x001A, 257, 43, 44700, 44706, 44725, 39468, 39472, 39447, 44745, {39476, 0, 0, 0}, 120, 120, { 1250, 500, 10082, 852, 0, ';' }},
-       {0x041B, 0x001B, 257, 99, 44748, 44754, 44772, 39518, 39522, 12674, 44796, {39526, 0, 0, 0}, 121, 121, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x041C, 0x001C, 257, 2, 44799, 44805, 44824, 39568, 39572, 39550, 44842, {39576, 0, 0, 0}, 122, 122, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x041D, 0x001D, 257, 96, 44845, 44851, 44868, 39615, 39619, 39596, 44886, {38447, 0, 0, 0}, 123, 123, { 1252, 20278, 10000, 850, 0, ';' }},
-       {0x041E, 0x001E, 512, 102, 44889, 44895, 44911, 39641, 39645, 39623, 44933, {0, 39649, 0, 0}, 124, 124, { 874, 20838, 10021, 874, 0, ',' }},
-       {0x041F, 0x001F, 257, 105, 44936, 44942, 44959, 39697, 39701, 12683, 44979, {39705, 0, 0, 0}, 125, 125, { 1254, 20905, 10081, 857, 0, ';' }},
-       {0x0420, 0x0020, 257, 85, 44982, 44988, 45004, 39736, 39740, 39719, 45030, {39744, 0, 0, 0}, 126, 126, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x0421, 0x0021, 257, 45, 45033, 45039, 45062, 39805, 39809, 39774, 45091, {39813, 0, 0, 0}, 127, 127, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0422, 0x0022, 257, 108, 45094, 45100, 45120, 39866, 39870, 39832, 45158, {39874, 0, 0, 0}, 128, 128, { 1251, 500, 10017, 866, 0, ';' }},
-       {0x0423, 0x0023, 257, 15, 45161, 45167, 45188, 39955, 39959, 39920, 45228, {39963, 0, 0, 0}, 129, 129, { 1251, 500, 10007, 866, 0, ';' }},
-       {0x0424, 0x0024, 257, 98, 45231, 45237, 45258, 40032, 40036, 40005, 45284, {40040, 0, 0, 0}, 130, 130, { 1250, 20880, 10029, 852, 0, ';' }},
-       {0x0425, 0x0025, 257, 29, 45287, 45293, 45312, 40080, 40084, 40062, 45326, {40088, 0, 0, 0}, 131, 131, { 1257, 500, 10029, 775, 0, ';' }},
-       {0x0426, 0x0026, 257, 66, 45329, 45335, 45352, 40129, 40133, 40108, 45372, {40137, 0, 0, 0}, 132, 132, { 1257, 500, 10029, 775, 0, ';' }},
-       {0x0427, 0x0027, 257, 64, 45375, 45381, 45404, 40180, 40184, 40156, 45424, {40188, 0, 0, 0}, 133, 133, { 1257, 500, 10029, 775, 0, ';' }},
-       {0x0428, 0x7C28, 257, 103, 45427, 45438, 45467, 40233, 40237, 40211, 45503, {0, 0, 0, 0}, 134, 134, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0429, 0x0029, 257, 50, 45506, 45512, 45527, 40263, 40267, 40241, 45551, {40271, 0, 0, 0}, 135, 135, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x042A, 0x002A, 257, 113, 45554, 45560, 45581, 40324, 35137, 40295, 45609, {40328, 0, 0, 0}, 136, 136, { 1258, 500, 10000, 1258, 0, ',' }},
-       {0x042B, 0x002B, 257, 3, 45612, 45618, 45637, 40370, 40374, 40343, 1820, {40378, 0, 0, 0}, 137, 137, { 0, 500, 2, 1, 0, ',' }},
-       {0x042C, 0x782C, 257, 7, 45671, 45682, 45714, 40435, 40439, 40408, 45740, {40443, 0, 0, 0}, 138, 138, { 1254, 20905, 10081, 857, 0, ';' }},
-       {0x042D, 0x002D, 257, 31, 45743, 45749, 45764, 40480, 40484, 40462, 43669, {40488, 0, 0, 0}, 139, 139, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x042F, 0x002F, 257, 71, 45783, 45789, 45812, 40543, 40547, 40508, 45856, {40551, 0, 0, 0}, 140, 140, { 1251, 500, 10007, 866, 0, ';' }},
-       {0x0432, 0x0032, 257, 115, 45859, 45865, 40605, 40614, 40618, 40595, 45887, {0, 0, 0, 0}, 141, 141, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0434, 0x0034, 257, 115, 45890, 45896, 40631, 40640, 40644, 40622, 45887, {0, 0, 0, 0}, 142, 142, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0435, 0x0035, 257, 115, 45917, 45923, 45943, 40664, 40668, 40648, 45887, {40672, 0, 0, 0}, 143, 143, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0436, 0x0036, 257, 115, 45968, 45974, 45999, 40706, 40710, 40693, 45887, {40714, 0, 0, 0}, 144, 144, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0437, 0x0037, 257, 37, 46023, 46029, 46048, 40768, 40772, 40734, 46103, {40776, 0, 0, 0}, 145, 145, { 0, 500, 2, 1, 0, ';' }},
-       {0x0438, 0x0038, 257, 34, 46106, 46112, 46136, 40862, 40866, 40841, 46157, {0, 0, 0, 0}, 146, 146, { 1252, 20277, 10079, 850, 0, ';' }},
-       {0x0439, 0x0039, 257, 48, 46160, 46166, 46180, 40895, 40899, 40870, 46211, {40903, 0, 0, 0}, 147, 147, { 0, 500, 2, 1, 0, ',' }},
-       {0x043A, 0x003A, 257, 73, 46214, 46220, 46236, 40973, 40977, 40956, 46250, {40981, 0, 0, 0}, 148, 148, { 0, 500, 2, 1, 0, ',' }},
-       {0x043B, 0x003B, 257, 78, 46253, 46259, 46282, 41036, 41040, 41002, 44456, {41044, 0, 0, 0}, 149, 149, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0441, 0x0041, 257, 56, 46307, 46313, 46329, 41331, 41335, 41310, 46347, {41339, 0, 0, 0}, 150, 150, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x0443, 0x7C43, 257, 111, 46350, 46361, 46387, 41380, 41384, 41360, 46413, {41388, 0, 0, 0}, 151, 151, { 1254, 500, 10029, 857, 0, ';' }},
-       {0x0445, 0x0045, 257, 48, 46416, 46422, 46438, 41435, 41439, 41408, 46211, {41443, 0, 0, 0}, 152, 152, { 0, 500, 2, 1, 0, ',' }},
-       {0x0447, 0x0047, 257, 48, 46469, 46475, 46492, 41627, 41631, 41593, 46211, {41635, 0, 0, 0}, 153, 153, { 0, 500, 2, 1, 0, ',' }},
-       {0x0448, 0x0048, 257, 48, 46529, 46535, 46549, 41716, 41720, 41691, 46211, {0, 0, 0, 0}, 154, 154, { 0, 500, 2, 1, 0, ',' }},
-       {0x0449, 0x0049, 257, 48, 46580, 46586, 46600, 41749, 41753, 41724, 46211, {41757, 0, 0, 0}, 155, 155, { 0, 500, 2, 1, 0, ',' }},
-       {0x044A, 0x004A, 257, 48, 46640, 46646, 46661, 41851, 41855, 41822, 46211, {41859, 0, 0, 0}, 156, 156, { 0, 500, 2, 1, 0, ',' }},
-       {0x044B, 0x004B, 257, 48, 46708, 46714, 46730, 41948, 41952, 37340, 46211, {41956, 0, 0, 0}, 157, 157, { 0, 500, 2, 1, 0, ',' }},
-       {0x044C, 0x004C, 257, 48, 46761, 46767, 46785, 42053, 42057, 42021, 46211, {42061, 0, 0, 0}, 158, 158, { 0, 500, 2, 1, 0, ',' }},
-       {0x044D, 0x004D, 257, 48, 46825, 46831, 46848, 42139, 42143, 42105, 46211, {42147, 0, 0, 0}, 159, 159, { 0, 500, 2, 1, 0, ',' }},
-       {0x044E, 0x004E, 257, 48, 46885, 46891, 46907, 42227, 2402, 42200, 46211, {42231, 0, 0, 0}, 160, 160, { 0, 500, 2, 1, 0, ',' }},
-       {0x0451, 0x0051, 257, 20, 46938, 46944, 46960, 42395, 42399, 42359, 13711, {0, 0, 0, 0}, 161, 161, { 0, 500, 2, 1, 0, ',' }},
-       {0x0452, 0x0052, 257, 36, 47006, 47012, 47035, 42420, 42424, 42403, 47062, {42428, 0, 0, 0}, 162, 162, { 1252, 20285, 10000, 850, 0, ',' }},
-       {0x0453, 0x0053, 257, 57, 47065, 47071, 47088, 42469, 42473, 42444, 47128, {42477, 0, 0, 0}, 163, 163, { 0, 500, 2, 1, 0, ',' }},
-       {0x0454, 0x0054, 257, 60, 47131, 47137, 47148, 42549, 42553, 42532, 47170, {42557, 0, 0, 0}, 164, 164, { 0, 500, 2, 1, 0, ',' }},
-       {0x0456, 0x0056, 257, 31, 47173, 47179, 47196, 42622, 42626, 42603, 43669, {38968, 0, 0, 0}, 165, 165, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0457, 0x0057, 257, 48, 47213, 47220, 47236, 42661, 42630, 42630, 46211, {0, 0, 0, 0}, 166, 166, { 0, 500, 2, 1, 0, ',' }},
-       {0x045B, 0x005B, 257, 63, 47270, 47276, 47296, 42692, 42696, 42665, 47346, {42700, 0, 0, 0}, 167, 167, { 0, 500, 2, 1, 0, ',' }},
-       {0x045E, 0x005E, 257, 32, 47349, 47355, 47374, 42780, 42784, 8022, 47405, {42788, 0, 0, 0}, 168, 168, { 0, 500, 2, 1, 0, ';' }},
-       {0x0461, 0x0061, 257, 79, 47408, 47414, 47429, 42901, 42905, 1883, 47466, {42909, 0, 0, 0}, 169, 169, { 0, 500, 2, 1, 0, ',' }},
-       {0x0463, 0x0063, 1024, 1, 47469, 47475, 47496, 42978, 42982, 42959, 47526, {0, 0, 0, 0}, 170, 170, { 0, 500, 2, 1, 1, ';' }},
-       {0x0464, 0x0064, 257, 84, 47529, 47536, 47559, 42999, 42986, 42986, 47580, {43003, 0, 0, 0}, 171, 171, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x0468, 0x7C68, 257, 75, 47583, 47594, 47617, 43035, 43039, 43026, 47634, {0, 0, 0, 0}, 172, 172, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x046A, 0x006A, 257, 75, 47637, 47643, 47660, 43068, 43072, 43043, 47634, {0, 0, 0, 0}, 173, 173, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x046C, 0x006C, 257, 115, 47706, 47713, 43095, 43112, 43076, 43076, 45887, {0, 0, 0, 0}, 174, 174, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x046F, 0x006F, 257, 38, 47743, 47749, 47773, 43143, 43147, 43116, 47804, {43151, 0, 0, 0}, 175, 175, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0470, 0x0070, 257, 75, 47807, 47813, 47813, 43186, 43190, 43178, 47634, {0, 0, 0, 0}, 176, 176, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x0478, 0x0078, 257, 20, 47828, 47834, 47853, 43218, 43222, 43194, 13711, {43226, 0, 0, 0}, 177, 177, { 0, 500, 2, 1, 0, ',' }},
-       {0x047E, 0x007E, 257, 35, 47872, 47878, 47894, 43259, 43263, 43239, 44053, {43267, 0, 0, 0}, 178, 178, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x0485, 0x0085, 257, 93, 47913, 47920, 43362, 43380, 43352, 43352, 44697, {0, 0, 0, 0}, 179, 179, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0487, 0x0087, 257, 94, 47935, 47941, 47941, 43399, 43403, 43384, 47962, {0, 0, 0, 0}, 180, 180, { 1252, 37, 10000, 437, 0, ';' }},
-       {0x0491, 0x0091, 257, 36, 47965, 47971, 48004, 43436, 43440, 43407, 47062, {43444, 0, 0, 0}, 181, 181, { 1252, 20285, 10000, 850, 0, ',' }},
-       {0x0801, 0x0001, 257, 49, 48040, 48046, 48060, 48090, 38120, 38091, 48094, {48097, 0, 0, 0}, 182, 182, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x0804, 0x0004, 257, 20, 48129, 38349, 48135, 38323, 38327, 38331, 13711, {38334, 0, 0, 0}, 183, 183, { 936, 500, 10008, 936, 0, ',' }},
-       {0x0807, 0x0007, 257, 18, 48151, 48157, 48178, 48196, 38490, 38468, 13632, {38494, 0, 0, 0}, 184, 184, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x0809, 0x0009, 257, 36, 48200, 48206, 48206, 48231, 38610, 38595, 47062, {38614, 0, 0, 0}, 185, 185, { 1252, 20285, 10000, 850, 0, ',' }},
-       {0x080A, 0x000A, 257, 74, 48235, 48241, 48258, 48277, 38657, 38633, 48281, {38968, 0, 0, 0}, 186, 186, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x080C, 0x000C, 257, 10, 48284, 48290, 48307, 48328, 38757, 38733, 48332, {38761, 0, 0, 0}, 187, 187, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x0810, 0x0010, 257, 18, 48335, 48341, 48363, 48383, 38964, 38940, 13632, {38968, 0, 0, 0}, 188, 188, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0813, 0x0013, 257, 10, 48387, 48393, 48409, 48430, 39109, 39085, 48332, {39113, 0, 0, 0}, 189, 189, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x0814, 0x7814, 257, 78, 48434, 48440, 48467, 48483, 48487, 48491, 44456, {38447, 0, 0, 0}, 190, 190, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x0816, 0x0016, 257, 88, 48494, 48500, 48522, 48544, 39243, 39214, 48548, {39247, 0, 0, 0}, 191, 191, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x081D, 0x001D, 257, 33, 48551, 48557, 48575, 48593, 39619, 39596, 44009, {38447, 0, 0, 0}, 192, 192, { 1252, 20278, 10000, 850, 0, ';' }},
-       {0x082C, 0x742C, 257, 7, 48597, 48608, 45714, 48643, 40439, 40408, 45740, {40443, 0, 0, 0}, 193, 193, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x083C, 0x003C, 257, 46, 48647, 48653, 48669, 41080, 41084, 41063, 48685, {41088, 0, 0, 0}, 194, 194, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0843, 0x7843, 257, 111, 48688, 48699, 46387, 41380, 41384, 41360, 46413, {48728, 0, 0, 0}, 195, 195, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x0845, 0x0045, 257, 9, 48766, 48772, 48793, 48836, 41439, 41408, 48840, {41443, 0, 0, 0}, 196, 196, { 0, 500, 2, 1, 0, ',' }},
-       {0x0C01, 0x0001, 257, 30, 48843, 48849, 48864, 48888, 38120, 38091, 48892, {48097, 0, 0, 0}, 197, 197, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x0C04, 0x7C04, 257, 41, 48895, 48901, 48944, 48981, 38327, 38331, 48985, {43723, 0, 0, 0}, 198, 198, { 950, 500, 10002, 950, 0, ',' }},
-       {0x0C07, 0x0007, 257, 5, 48988, 48994, 49011, 49033, 38490, 38468, 49037, {38494, 0, 0, 0}, 199, 199, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x0C09, 0x0009, 257, 6, 49040, 49046, 49046, 49066, 38610, 38595, 49070, {38614, 0, 0, 0}, 200, 200, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x0C0A, 0x000A, 257, 31, 49073, 49079, 49095, 49114, 38657, 38633, 43669, {38661, 0, 0, 0}, 201, 201, { 1252, 20284, 10000, 850, 0, ';' }},
-       {0x0C0C, 0x000C, 257, 17, 49118, 49124, 49140, 49159, 38757, 38733, 49163, {49166, 0, 0, 0}, 202, 202, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x0C3B, 0x003B, 257, 33, 49188, 49194, 49218, 49244, 49248, 41002, 44009, {41044, 0, 0, 0}, 203, 203, { 1252, 20278, 10000, 850, 0, ';' }},
-       {0x1001, 0x0001, 257, 67, 49252, 49258, 49273, 49301, 38120, 38091, 49305, {48097, 0, 0, 0}, 204, 204, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x1004, 0x0004, 257, 97, 49308, 49314, 49346, 49365, 38327, 38331, 49369, {38334, 0, 0, 0}, 205, 205, { 936, 500, 10008, 936, 0, ',' }},
-       {0x1007, 0x0007, 257, 65, 49372, 49378, 49398, 49418, 38490, 38468, 49422, {38494, 0, 0, 0}, 206, 206, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x1009, 0x0009, 257, 17, 49425, 49431, 49431, 49448, 38610, 38595, 49163, {38614, 0, 0, 0}, 207, 207, { 1252, 37, 10000, 850, 0, ',' }},
-       {0x100A, 0x000A, 257, 40, 49452, 49458, 49478, 49499, 38657, 38633, 49503, {38661, 0, 0, 0}, 208, 208, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x100C, 0x000C, 257, 18, 49506, 49512, 49533, 49552, 38757, 38733, 13632, {38761, 0, 0, 0}, 209, 209, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x101A, 0x001A, 257, 8, 49556, 49562, 49596, 49627, 49631, 39447, 49635, {39476, 0, 0, 0}, 210, 210, { 1250, 870, 10082, 852, 0, ';' }},
-       {0x1401, 0x0001, 257, 27, 49638, 49644, 49661, 49693, 38120, 38091, 49697, {48097, 0, 0, 0}, 211, 211, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x1404, 0x7C04, 257, 72, 49700, 49706, 49745, 49782, 38327, 38331, 49786, {43723, 0, 0, 0}, 212, 212, { 950, 500, 10002, 950, 0, ',' }},
-       {0x1407, 0x0007, 257, 62, 49789, 49795, 49818, 49842, 38490, 38468, 49846, {38494, 0, 0, 0}, 213, 213, { 1252, 20273, 10000, 850, 0, ';' }},
-       {0x1409, 0x0009, 257, 80, 49849, 49855, 49855, 49877, 38610, 38595, 49881, {38614, 0, 0, 0}, 214, 214, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x140A, 0x000A, 257, 22, 49884, 49890, 49911, 49933, 38657, 38633, 49937, {38661, 0, 0, 0}, 215, 215, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x140C, 0x000C, 257, 65, 49940, 49946, 49966, 49989, 38757, 38733, 49422, {38761, 0, 0, 0}, 216, 216, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x141A, 0x681A, 257, 8, 49993, 50004, 50044, 50075, 50079, 50083, 49635, {50086, 0, 0, 0}, 217, 217, { 1250, 870, 10082, 852, 0, ';' }},
-       {0x1801, 0x0001, 257, 68, 50109, 50115, 50132, 50162, 38120, 38091, 50166, {48097, 0, 0, 0}, 218, 218, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x1809, 0x0009, 257, 46, 50169, 50175, 50175, 50193, 38610, 38595, 48685, {38614, 0, 0, 0}, 219, 219, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x180A, 0x000A, 257, 82, 50197, 50203, 50220, 50239, 38657, 38633, 50243, {38661, 0, 0, 0}, 220, 220, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x180C, 0x000C, 257, 69, 50246, 50252, 50268, 50287, 38757, 38733, 50291, {38761, 0, 0, 0}, 221, 221, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x181A, 0x701A, 257, 8, 50294, 50305, 50345, 50397, 50401, 50405, 49635, {50086, 0, 0, 0}, 222, 222, { 1250, 870, 10082, 852, 0, ';' }},
-       {0x1C01, 0x0001, 257, 104, 50408, 50414, 50431, 50457, 38120, 38091, 50461, {48097, 0, 0, 0}, 223, 223, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x1C09, 0x0009, 257, 115, 50464, 50470, 50470, 50493, 38610, 38595, 45887, {38614, 0, 0, 0}, 224, 224, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x1C0A, 0x000A, 257, 26, 50497, 50503, 50532, 50565, 38657, 38633, 50569, {38661, 0, 0, 0}, 225, 225, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x1C1A, 0x6C1A, 257, 8, 50572, 50583, 50345, 50626, 50630, 50405, 49635, {40551, 0, 0, 0}, 226, 226, { 1251, 21025, 10007, 855, 0, ';' }},
-       {0x2001, 0x0001, 257, 81, 50634, 50640, 50654, 50682, 38120, 38091, 50686, {48097, 0, 0, 0}, 227, 227, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x2009, 0x0009, 257, 53, 50689, 50695, 50695, 50713, 38610, 38595, 50717, {38614, 0, 0, 0}, 228, 228, { 1252, 500, 10000, 850, 0, ',' }},
-       {0x200A, 0x000A, 257, 112, 50720, 50726, 50746, 50767, 38657, 38633, 50771, {38661, 0, 0, 0}, 229, 229, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x201A, 0x641A, 257, 8, 50774, 50785, 50044, 50828, 50832, 50083, 49635, {40551, 0, 0, 0}, 230, 230, { 1251, 870, 10082, 855, 0, ';' }},
-       {0x2401, 0x0001, 257, 114, 50836, 50842, 50857, 50885, 38120, 38091, 50889, {48097, 0, 0, 0}, 231, 231, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x240A, 0x000A, 257, 21, 50892, 50898, 50917, 50937, 38657, 38633, 50941, {38661, 0, 0, 0}, 232, 232, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x241A, 0x701A, 257, 92, 50944, 50955, 50979, 51007, 2130, 50405, 51011, {50086, 0, 0, 0}, 233, 233, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x2801, 0x0001, 257, 101, 51014, 51020, 51035, 51063, 38120, 38091, 51067, {48097, 0, 0, 0}, 234, 234, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x2809, 0x0009, 257, 16, 51070, 51076, 51076, 51093, 38610, 38595, 51097, {38614, 0, 0, 0}, 235, 235, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x280A, 0x000A, 257, 83, 51100, 51106, 51121, 51138, 38657, 38633, 51142, {38661, 0, 0, 0}, 236, 236, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x281A, 0x6C1A, 257, 92, 51145, 51156, 50979, 51183, 2130, 50405, 51011, {40551, 0, 0, 0}, 237, 237, { 1251, 21025, 10007, 855, 0, ';' }},
-       {0x2C01, 0x0001, 257, 54, 51187, 51193, 51209, 51239, 38120, 38091, 51243, {48097, 0, 0, 0}, 238, 238, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x2C09, 0x0009, 257, 106, 51246, 51252, 51252, 51282, 38610, 38595, 51286, {38614, 0, 0, 0}, 239, 239, { 1252, 500, 10000, 850, 0, ';' }},
-       {0x2C0A, 0x000A, 257, 4, 51289, 51295, 51315, 51336, 38657, 38633, 51340, {38661, 0, 0, 0}, 240, 240, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x2C1A, 0x701A, 257, 70, 51343, 51354, 51382, 51415, 2130, 50405, 51419, {50086, 0, 0, 0}, 241, 241, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x3001, 0x0001, 257, 61, 51422, 51428, 51445, 51473, 38120, 38091, 51477, {48097, 0, 0, 0}, 242, 242, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x3009, 0x0009, 257, 116, 51480, 51486, 51486, 51505, 38610, 38595, 51509, {38614, 0, 0, 0}, 243, 243, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x300A, 0x000A, 257, 28, 51512, 51518, 51536, 51555, 38657, 38633, 51559, {38661, 0, 0, 0}, 244, 244, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x301A, 0x6C1A, 257, 70, 51562, 51573, 51382, 51604, 2130, 50405, 51419, {40551, 0, 0, 0}, 245, 245, { 1251, 21025, 10007, 855, 0, ';' }},
-       {0x3401, 0x0001, 257, 59, 51608, 51614, 51630, 51660, 38120, 38091, 51664, {48097, 0, 0, 0}, 246, 246, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x3409, 0x0009, 257, 84, 51667, 51673, 51673, 51695, 38610, 38595, 47580, {38614, 0, 0, 0}, 247, 247, { 1252, 500, 10000, 437, 0, ',' }},
-       {0x340A, 0x000A, 257, 19, 51699, 51705, 51721, 51738, 38657, 38633, 51742, {38661, 0, 0, 0}, 248, 248, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x3801, 0x0001, 257, 0, 51745, 51751, 51781, 51845, 38120, 38091, 51849, {48097, 0, 0, 0}, 249, 249, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x380A, 0x000A, 257, 110, 51852, 51858, 51876, 51895, 38657, 38633, 51899, {38661, 0, 0, 0}, 250, 250, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x3C01, 0x0001, 257, 12, 51902, 51908, 51925, 51957, 38120, 38091, 51961, {48097, 0, 0, 0}, 251, 251, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x3C0A, 0x000A, 257, 89, 51964, 51970, 51989, 52009, 38657, 38633, 52013, {38661, 0, 0, 0}, 252, 252, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x4001, 0x0001, 257, 90, 52016, 52022, 52037, 52061, 38120, 38091, 52065, {48097, 0, 0, 0}, 253, 253, { 1256, 20420, 10004, 720, 1, ';' }},
-       {0x4009, 0x0009, 257, 48, 52068, 52074, 52074, 52090, 38610, 38595, 46211, {38614, 0, 0, 0}, 254, 254, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x400A, 0x000A, 257, 13, 52094, 52100, 52118, 52137, 38657, 38633, 52141, {38661, 0, 0, 0}, 255, 255, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x440A, 0x000A, 257, 100, 52144, 52150, 52172, 52195, 38657, 38633, 52199, {38661, 0, 0, 0}, 256, 256, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x4809, 0x0009, 257, 97, 52202, 52208, 52208, 52228, 38610, 38595, 49369, {38614, 0, 0, 0}, 257, 257, { 1252, 37, 10000, 437, 0, ',' }},
-       {0x480A, 0x000A, 257, 42, 52232, 52238, 52257, 52277, 38657, 38633, 52281, {38661, 0, 0, 0}, 258, 258, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x4C0A, 0x000A, 257, 76, 52284, 52290, 52310, 52331, 38657, 38633, 52335, {38661, 0, 0, 0}, 259, 259, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x500A, 0x000A, 257, 87, 52338, 52344, 52366, 52389, 38657, 38633, 52393, {38661, 0, 0, 0}, 260, 260, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x540A, 0x000A, 257, 109, 52396, 52402, 52426, 52452, 38657, 38633, 43968, {38661, 0, 0, 0}, 261, 261, { 1252, 20284, 10000, 850, 0, ',' }},
-       {0x641A, 0x781A, 257, -1, 52456, 52464, 52483, 50828, 50832, 50083, 0, {40551, 0, 0, 0}, 262, 262, { 1251, 870, 10082, 855, 0, ';' }},
-       {0x681A, 0x781A, 257, -1, 52492, 52500, 52483, 50075, 50079, 50083, 0, {50086, 0, 0, 0}, 263, 263, { 1250, 870, 10082, 852, 0, ';' }},
-       {0x6C1A, 0x7C1A, 257, -1, 52516, 52524, 52543, 51183, 2130, 50405, 0, {40551, 0, 0, 0}, 264, 264, { 1251, 21025, 10007, 855, 0, ';' }},
-       {0x701A, 0x7C1A, 257, -1, 52556, 52564, 52543, 51007, 2130, 50405, 0, {50086, 0, 0, 0}, 265, 265, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x742C, 0x002C, 257, -1, 52580, 52588, 40423, 48643, 40439, 40408, 0, {40443, 0, 0, 0}, 266, 266, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x7804, 0x007F, 257, -1, 38331, 38349, 38316, 38323, 38327, 38331, 0, {38334, 0, 0, 0}, 267, 267, { 936, 500, 10008, 936, 0, ',' }},
-       {0x7814, 0x0014, 257, -1, 48491, 52611, 52629, 48483, 48487, 48491, 0, {38447, 0, 0, 0}, 268, 268, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x781A, 0x007F, 257, -1, 50083, 52637, 52483, 50075, 50079, 50083, 0, {50086, 0, 0, 0}, 269, 269, { 1250, 870, 10082, 852, 0, ';' }},
-       {0x782C, 0x002C, 257, -1, 52645, 52653, 40423, 40435, 40439, 40408, 0, {40443, 0, 0, 0}, 270, 270, { 1254, 20905, 10081, 857, 0, ';' }},
-       {0x7843, 0x0043, 257, -1, 52673, 52681, 41369, 41380, 41384, 41360, 0, {48728, 0, 0, 0}, 271, 271, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x7850, 0x0050, 257, -1, 52698, 52706, 42306, 52727, 42323, 42293, 0, {42327, 0, 0, 0}, 272, 272, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x7C04, 0x7804, 257, -1, 52731, 43678, 38316, 43716, 38327, 38331, 0, {43723, 0, 0, 0}, 273, 273, { 950, 500, 10002, 950, 0, ',' }},
-       {0x7C04, 0x7C04, 257, -1, 52739, 52746, 38316, 43716, 38327, 38331, 0, {43723, 0, 0, 0}, 274, 274, { 950, 500, 10002, 950, 0, ',' }},
-       {0x7C14, 0x0014, 257, -1, 39162, 52775, 52793, 39154, 39158, 39162, 0, {38447, 0, 0, 0}, 275, 275, { 1252, 20277, 10000, 850, 0, ';' }},
-       {0x7C1A, 0x007F, 257, -1, 50405, 52807, 52543, 52815, 2130, 50405, 0, {40551, 0, 0, 0}, 276, 276, { 1250, 500, 10029, 852, 0, ';' }},
-       {0x7C28, 0x0028, 257, -1, 52819, 52827, 40220, 40233, 40237, 40211, 0, {0, 0, 0, 0}, 277, 277, { 1251, 20880, 10007, 866, 0, ';' }},
-       {0x7C43, 0x0043, 257, -1, 52844, 52852, 41369, 41380, 41384, 41360, 0, {41388, 0, 0, 0}, 278, 278, { 1254, 500, 10029, 857, 0, ';' }},
-       {0x7C5F, 0x005F, 257, -1, 52866, 52875, 42861, 42871, 42833, 42833, 0, {0, 0, 0, 0}, 279, 279, { 1252, 20297, 10000, 850, 0, ';' }},
-       {0x7C68, 0x0068, 257, -1, 52907, 52915, 43029, 43035, 43039, 43026, 0, {0, 0, 0, 0}, 280, 280, { 1252, 37, 10000, 437, 0, ',' }}
+       {0x0001, 0x007F, 768, -1, 38073, 38076, 38083, 38098, 38102, 38073, 0, {0, 0, 38106, 0}, 0, 0, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x0002, 0x007F, 257, -1, 38134, 38137, 38147, 38166, 38170, 38134, 0, {38174, 0, 0, 0}, 1, 1, { 1251, 21025, 10007, 866, 0, ';' }},
+       {0x0003, 0x007F, 257, -1, 38216, 38219, 38227, 38235, 38239, 38216, 0, {38243, 0, 0, 0}, 2, 2, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0004, 0x0004, 257, -1, 38263, 38270, 38298, 38305, 38309, 38313, 0, {38316, 0, 0, 0}, 3, 3, { 936, 500, 10008, 936, 0, ',' }},
+       {0x0004, 0x7804, 257, -1, 38323, 38331, 38298, 38305, 38309, 38313, 0, {38316, 0, 0, 0}, 4, 4, { 936, 500, 10008, 936, 0, ',' }},
+       {0x0005, 0x007F, 257, -1, 38352, 38355, 38361, 38371, 38375, 38352, 0, {38379, 0, 0, 0}, 5, 5, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x0006, 0x007F, 257, -1, 38405, 38408, 38415, 38421, 38425, 38405, 0, {38429, 0, 0, 0}, 6, 6, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0007, 0x007F, 257, -1, 38450, 38453, 38460, 38468, 38472, 38450, 0, {38476, 0, 0, 0}, 7, 7, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x0008, 0x007F, 257, -1, 38501, 38504, 38510, 38527, 38531, 38501, 0, {38535, 0, 0, 0}, 8, 8, { 1253, 20273, 10006, 737, 0, ';' }},
+       {0x0009, 0x007F, 257, -1, 38577, 38580, 38580, 38588, 38592, 38577, 0, {38596, 0, 0, 0}, 9, 9, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x000A, 0x007F, 257, -1, 38615, 38618, 38626, 38635, 38639, 38615, 0, {38643, 0, 0, 0}, 10, 10, { 1252, 20284, 10000, 850, 0, ';' }},
+       {0x000B, 0x007F, 257, -1, 38665, 38668, 38676, 38682, 38686, 38665, 0, {38690, 0, 0, 0}, 11, 11, { 1252, 20278, 10000, 850, 0, ';' }},
+       {0x000C, 0x007F, 257, -1, 38715, 38718, 38725, 38735, 38739, 38715, 0, {38743, 0, 0, 0}, 12, 12, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x000D, 0x007F, 257, -1, 38765, 38768, 38775, 38786, 38790, 38765, 0, {38794, 0, 0, 0}, 13, 13, { 1255, 500, 10005, 862, 1, ',' }},
+       {0x000E, 0x007F, 257, -1, 38827, 38830, 38840, 38847, 38851, 38827, 0, {38855, 0, 0, 0}, 14, 14, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x000F, 0x007F, 257, -1, 38871, 38874, 38884, 38894, 38898, 38871, 0, {38902, 0, 0, 0}, 15, 15, { 1252, 20871, 10079, 850, 0, ';' }},
+       {0x0010, 0x007F, 257, -1, 38922, 38925, 38933, 38942, 38946, 38922, 0, {38950, 0, 0, 0}, 16, 16, { 1252, 20280, 10000, 850, 0, ';' }},
+       {0x0011, 0x007F, 257, -1, 38972, 38975, 38984, 38994, 38998, 38972, 0, {39002, 0, 0, 0}, 17, 17, { 932, 20290, 10001, 932, 0, ',' }},
+       {0x0012, 0x007F, 257, -1, 39029, 39032, 39039, 39049, 39053, 39029, 0, {39057, 0, 0, 0}, 18, 18, { 949, 20833, 10003, 949, 0, ',' }},
+       {0x0013, 0x007F, 257, -1, 39067, 39070, 39076, 39087, 39091, 39067, 0, {39095, 0, 0, 0}, 19, 19, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0014, 0x007F, 257, -1, 39117, 39120, 39130, 39136, 39140, 39144, 0, {38429, 0, 0, 0}, 20, 20, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0015, 0x007F, 257, -1, 39147, 39150, 39157, 39164, 39168, 39147, 0, {39172, 0, 0, 0}, 21, 21, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x0016, 0x007F, 257, -1, 39196, 39199, 39210, 39221, 39225, 39196, 0, {39229, 0, 0, 0}, 22, 22, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0017, 0x007F, 257, -1, 39252, 39255, 39263, 39273, 39277, 39252, 0, {39281, 0, 0, 0}, 23, 23, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x0018, 0x007F, 257, -1, 39301, 39304, 39313, 39322, 39326, 39301, 0, {39330, 0, 0, 0}, 24, 24, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x0019, 0x007F, 257, -1, 39349, 39352, 39360, 39375, 39379, 39349, 0, {39383, 0, 0, 0}, 25, 25, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x001A, 0x007F, 257, -1, 39429, 39432, 39441, 39450, 39454, 39429, 0, {39458, 0, 0, 0}, 26, 26, { 1250, 500, 10082, 852, 0, ';' }},
+       {0x001B, 0x007F, 257, -1, 12674, 39481, 39488, 39500, 39504, 12674, 0, {39508, 0, 0, 0}, 27, 27, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x001C, 0x007F, 257, -1, 39532, 39535, 39544, 39550, 39554, 39532, 0, {39558, 0, 0, 0}, 28, 28, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x001D, 0x007F, 257, -1, 39578, 39581, 39589, 39597, 39601, 39578, 0, {38429, 0, 0, 0}, 29, 29, { 1252, 20278, 10000, 850, 0, ';' }},
+       {0x001E, 0x007F, 512, -1, 39605, 39608, 39613, 39623, 39627, 39605, 0, {0, 39631, 0, 0}, 30, 30, { 874, 20838, 10021, 874, 0, ',' }},
+       {0x001F, 0x007F, 257, -1, 12683, 39662, 39670, 39679, 39683, 12683, 0, {39687, 0, 0, 0}, 31, 31, { 1254, 20905, 10081, 857, 0, ';' }},
+       {0x0020, 0x007F, 257, -1, 39701, 39704, 39709, 39718, 39722, 39701, 0, {39726, 0, 0, 0}, 32, 32, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x0021, 0x007F, 257, -1, 39756, 39759, 39770, 39787, 39791, 39756, 0, {39795, 0, 0, 0}, 33, 33, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0022, 0x007F, 257, -1, 39814, 39817, 39827, 39848, 39852, 39814, 0, {39856, 0, 0, 0}, 34, 34, { 1251, 500, 10017, 866, 0, ';' }},
+       {0x0023, 0x007F, 257, -1, 39902, 39905, 39916, 39937, 39941, 39902, 0, {39945, 0, 0, 0}, 35, 35, { 1251, 500, 10007, 866, 0, ';' }},
+       {0x0024, 0x007F, 257, -1, 39987, 39990, 40000, 40014, 40018, 39987, 0, {40022, 0, 0, 0}, 36, 36, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x0025, 0x007F, 257, -1, 40044, 40047, 40056, 40062, 40066, 40044, 0, {40070, 0, 0, 0}, 37, 37, { 1257, 500, 10029, 775, 0, ';' }},
+       {0x0026, 0x007F, 257, -1, 40090, 40093, 40101, 40111, 40115, 40090, 0, {40119, 0, 0, 0}, 38, 38, { 1257, 500, 10029, 775, 0, ';' }},
+       {0x0027, 0x007F, 257, -1, 40138, 40141, 40152, 40162, 40166, 40138, 0, {40170, 0, 0, 0}, 39, 39, { 1257, 500, 10029, 775, 0, ';' }},
+       {0x0028, 0x007F, 257, -1, 40193, 40196, 40202, 40215, 40219, 40193, 0, {0, 0, 0, 0}, 40, 40, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0029, 0x007F, 257, -1, 40223, 40226, 40234, 40245, 40249, 40223, 0, {40253, 0, 0, 0}, 41, 41, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x002A, 0x007F, 257, -1, 40277, 40280, 40291, 40306, 35137, 40277, 0, {40310, 0, 0, 0}, 42, 42, { 1258, 500, 10000, 1258, 0, ',' }},
+       {0x002B, 0x007F, 257, -1, 40325, 40328, 40337, 40352, 40356, 40325, 0, {40360, 0, 0, 0}, 43, 43, { 0, 500, 2, 1, 0, ',' }},
+       {0x002C, 0x007F, 257, -1, 40390, 40393, 40405, 40417, 40421, 40390, 0, {40425, 0, 0, 0}, 44, 44, { 1254, 20905, 10081, 857, 0, ';' }},
+       {0x002D, 0x007F, 257, -1, 40444, 40447, 40454, 40462, 40466, 40444, 0, {40470, 0, 0, 0}, 45, 45, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x002F, 0x007F, 257, -1, 40490, 40493, 40504, 40525, 40529, 40490, 0, {40533, 0, 0, 0}, 46, 46, { 1251, 500, 10007, 866, 0, ';' }},
+       {0x0032, 0x007F, 257, -1, 40577, 40580, 40587, 40596, 40600, 40577, 0, {0, 0, 0, 0}, 47, 47, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0034, 0x007F, 257, -1, 40604, 40607, 40613, 40622, 40626, 40604, 0, {0, 0, 0, 0}, 48, 48, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0035, 0x007F, 257, -1, 40630, 40633, 40638, 40646, 40650, 40630, 0, {40654, 0, 0, 0}, 49, 49, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0036, 0x007F, 257, -1, 40675, 40678, 40678, 40688, 40692, 40675, 0, {40696, 0, 0, 0}, 50, 50, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0037, 0x007F, 257, -1, 40716, 40719, 40728, 40750, 40754, 40716, 0, {40758, 0, 0, 0}, 51, 51, { 0, 500, 2, 1, 0, ';' }},
+       {0x0038, 0x007F, 257, -1, 40823, 40826, 40834, 40844, 40848, 40823, 0, {0, 0, 0, 0}, 52, 52, { 1252, 20277, 10079, 850, 0, ';' }},
+       {0x0039, 0x007F, 257, -1, 40852, 40855, 40861, 40877, 40881, 40852, 0, {40885, 0, 0, 0}, 53, 53, { 0, 500, 2, 1, 0, ',' }},
+       {0x003A, 0x007F, 257, -1, 40938, 40941, 40949, 40955, 40959, 40938, 0, {40963, 0, 0, 0}, 54, 54, { 0, 500, 2, 1, 0, ',' }},
+       {0x003B, 0x007F, 257, -1, 40984, 40987, 41001, 41018, 41022, 40984, 0, {41026, 0, 0, 0}, 55, 55, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x003C, 0x007F, 257, -1, 41045, 41048, 41054, 41062, 41066, 41045, 0, {41070, 0, 0, 0}, 56, 56, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x003E, 0x007F, 257, -1, 41091, 41094, 41100, 41114, 41118, 41091, 0, {41122, 0, 0, 0}, 57, 57, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x003F, 0x007F, 257, -1, 41139, 41142, 41149, 41169, 41173, 41139, 0, {41177, 0, 0, 0}, 58, 58, { 0, 500, 2, 1, 0, ';' }},
+       {0x0040, 0x007F, 257, -1, 41219, 41222, 41229, 41246, 41250, 41219, 0, {41254, 0, 0, 0}, 59, 59, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0041, 0x007F, 257, -1, 41292, 41295, 41303, 41313, 41317, 41292, 0, {41321, 0, 0, 0}, 60, 60, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x0043, 0x007F, 257, -1, 41342, 41345, 41351, 41362, 41366, 41342, 0, {41370, 0, 0, 0}, 61, 61, { 1254, 500, 10029, 857, 0, ';' }},
+       {0x0045, 0x007F, 257, -1, 41390, 41393, 41401, 41417, 41421, 41390, 0, {41425, 0, 0, 0}, 62, 62, { 0, 500, 2, 1, 0, ',' }},
+       {0x0046, 0x007F, 257, -1, 41490, 41493, 41501, 41520, 41524, 41490, 0, {41528, 0, 0, 0}, 63, 63, { 0, 500, 2, 1, 0, ',' }},
+       {0x0047, 0x007F, 257, -1, 41575, 41578, 41587, 41609, 41613, 41575, 0, {41617, 0, 0, 0}, 64, 64, { 0, 500, 2, 1, 0, ',' }},
+       {0x0048, 0x007F, 257, -1, 41673, 41676, 41682, 41698, 41702, 41673, 0, {0, 0, 0, 0}, 65, 65, { 0, 500, 2, 1, 0, ',' }},
+       {0x0049, 0x007F, 257, -1, 41706, 41709, 41715, 41731, 41735, 41706, 0, {41739, 0, 0, 0}, 66, 66, { 0, 500, 2, 1, 0, ',' }},
+       {0x004A, 0x007F, 257, -1, 41804, 41807, 41814, 41833, 41837, 41804, 0, {41841, 0, 0, 0}, 67, 67, { 0, 500, 2, 1, 0, ',' }},
+       {0x004B, 0x007F, 257, -1, 37322, 41906, 41914, 41930, 41934, 37322, 0, {41938, 0, 0, 0}, 68, 68, { 0, 500, 2, 1, 0, ',' }},
+       {0x004C, 0x007F, 257, -1, 42003, 42006, 42016, 42035, 42039, 42003, 0, {42043, 0, 0, 0}, 69, 69, { 0, 500, 2, 1, 0, ',' }},
+       {0x004D, 0x007F, 257, -1, 42087, 42090, 42099, 42121, 42125, 42087, 0, {42129, 0, 0, 0}, 70, 70, { 0, 500, 2, 1, 0, ',' }},
+       {0x004E, 0x007F, 257, -1, 42182, 42185, 42193, 42209, 2402, 42182, 0, {42213, 0, 0, 0}, 71, 71, { 0, 500, 2, 1, 0, ',' }},
+       {0x0050, 0x007F, 257, -1, 42275, 42278, 42288, 42301, 42305, 42275, 0, {42309, 0, 0, 0}, 72, 72, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0051, 0x007F, 257, -1, 42341, 42344, 42352, 42377, 42381, 42341, 0, {0, 0, 0, 0}, 73, 73, { 0, 500, 2, 1, 0, ',' }},
+       {0x0052, 0x007F, 257, -1, 42385, 42388, 42394, 42402, 42406, 42385, 0, {42410, 0, 0, 0}, 74, 74, { 1252, 20285, 10000, 850, 0, ',' }},
+       {0x0053, 0x007F, 257, -1, 42426, 42429, 42435, 42451, 42455, 42426, 0, {42459, 0, 0, 0}, 75, 75, { 0, 500, 2, 1, 0, ',' }},
+       {0x0054, 0x007F, 257, -1, 42514, 42517, 42521, 42531, 42535, 42514, 0, {42539, 0, 0, 0}, 76, 76, { 0, 500, 2, 1, 0, ',' }},
+       {0x0056, 0x007F, 257, -1, 42585, 42588, 42597, 42604, 42608, 42585, 0, {38950, 0, 0, 0}, 77, 77, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0057, 0x007F, 257, -1, 42612, 42616, 42624, 42643, 42612, 42612, 0, {0, 0, 0, 0}, 78, 78, { 0, 500, 2, 1, 0, ',' }},
+       {0x005B, 0x007F, 257, -1, 42647, 42650, 42658, 42674, 42678, 42647, 0, {42682, 0, 0, 0}, 79, 79, { 0, 500, 2, 1, 0, ',' }},
+       {0x005E, 0x007F, 257, -1, 8022, 42741, 42749, 42762, 42766, 8022, 0, {42770, 0, 0, 0}, 80, 80, { 0, 500, 2, 1, 0, ';' }},
+       {0x005F, 0x007F, 257, -1, 42815, 42819, 42843, 42853, 42815, 42815, 0, {0, 0, 0, 0}, 81, 81, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x0061, 0x007F, 257, -1, 1883, 42857, 42864, 42883, 42887, 1883, 0, {42891, 0, 0, 0}, 82, 82, { 0, 500, 2, 1, 0, ',' }},
+       {0x0063, 0x007F, 1024, -1, 42941, 42944, 42951, 42960, 42964, 42941, 0, {0, 0, 0, 0}, 83, 83, { 0, 500, 2, 1, 1, ';' }},
+       {0x0064, 0x007F, 257, -1, 42968, 42972, 42972, 42981, 42968, 42968, 0, {42985, 0, 0, 0}, 84, 84, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x0068, 0x007F, 257, -1, 43008, 43011, 43011, 43017, 43021, 43008, 0, {0, 0, 0, 0}, 85, 85, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x006A, 0x007F, 257, -1, 43025, 43028, 43035, 43050, 43054, 43025, 0, {0, 0, 0, 0}, 86, 86, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x006C, 0x007F, 257, -1, 43058, 43062, 43077, 43094, 43058, 43058, 0, {0, 0, 0, 0}, 87, 87, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x006F, 0x007F, 257, -1, 43098, 43101, 43113, 43125, 43129, 43098, 0, {43133, 0, 0, 0}, 88, 88, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0070, 0x007F, 257, -1, 43160, 43163, 43163, 43168, 43172, 43160, 0, {0, 0, 0, 0}, 89, 89, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x0078, 0x007F, 257, -1, 43176, 43179, 43190, 43200, 43204, 43176, 0, {43208, 0, 0, 0}, 90, 90, { 0, 500, 2, 1, 0, ',' }},
+       {0x007E, 0x007F, 257, -1, 43221, 43224, 43231, 43241, 43245, 43221, 0, {43249, 0, 0, 0}, 91, 91, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x0084, 0x007F, 257, -1, 43269, 43273, 43286, 43305, 43269, 43269, 0, {43309, 0, 0, 0}, 92, 92, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x0085, 0x007F, 257, -1, 43334, 43338, 43344, 43362, 43334, 43334, 0, {0, 0, 0, 0}, 93, 93, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0087, 0x007F, 257, -1, 43366, 43369, 43369, 43381, 43385, 43366, 0, {0, 0, 0, 0}, 94, 94, { 1252, 37, 10000, 437, 0, ';' }},
+       {0x0091, 0x007F, 257, -1, 43389, 43392, 43408, 43418, 43422, 43389, 0, {43426, 0, 0, 0}, 95, 95, { 1252, 20285, 10000, 850, 0, ',' }},
+       {0x0401, 0x0001, 768, 95, 43451, 43457, 43479, 38098, 38102, 38073, 13629, {0, 0, 38106, 0}, 96, 96, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x0402, 0x0002, 257, 11, 43543, 43549, 43570, 38166, 38170, 38134, 43608, {38174, 0, 0, 0}, 97, 97, { 1251, 21025, 10007, 866, 0, ';' }},
+       {0x0403, 0x0003, 257, 31, 43611, 43617, 43633, 38235, 38239, 38216, 43651, {38243, 0, 0, 0}, 98, 98, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0404, 0x7C04, 257, 107, 43654, 43660, 43682, 43698, 38309, 38313, 43702, {43705, 0, 0, 0}, 99, 99, { 950, 500, 10002, 950, 0, ',' }},
+       {0x0405, 0x0005, 257, 23, 43712, 43718, 43741, 38371, 38375, 38352, 43771, {38379, 0, 0, 0}, 100, 100, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x0406, 0x0006, 257, 25, 43774, 43780, 43797, 38421, 38425, 38405, 43813, {38429, 0, 0, 0}, 101, 101, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0407, 0x0007, 257, 24, 43816, 43822, 43839, 38468, 38472, 38450, 43861, {38476, 0, 0, 0}, 102, 102, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x0408, 0x0008, 257, 39, 43864, 43870, 43885, 38527, 38531, 38501, 43917, {38535, 0, 0, 0}, 103, 103, { 1253, 20273, 10006, 737, 0, ';' }},
+       {0x0409, 0x0009, 257, 109, 43920, 43926, 43926, 38588, 38592, 38577, 43950, {38596, 0, 0, 0}, 104, 104, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x040B, 0x000B, 257, 33, 43953, 43959, 43977, 38682, 38686, 38665, 43991, {38690, 0, 0, 0}, 105, 105, { 1252, 20278, 10000, 850, 0, ';' }},
+       {0x040C, 0x000C, 257, 35, 43994, 44000, 44016, 38735, 38739, 38715, 44035, {38743, 0, 0, 0}, 106, 106, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x040D, 0x000D, 257, 47, 44038, 44044, 44060, 38786, 38790, 38765, 44084, {38794, 0, 0, 0}, 107, 107, { 1255, 500, 10005, 862, 1, ',' }},
+       {0x040E, 0x000E, 257, 44, 44087, 44093, 44113, 38847, 38851, 38827, 44136, {38855, 0, 0, 0}, 108, 108, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x040F, 0x000F, 257, 51, 44139, 44145, 44165, 38894, 38898, 38871, 44185, {38902, 0, 0, 0}, 109, 109, { 1252, 20871, 10079, 850, 0, ';' }},
+       {0x0410, 0x0010, 257, 52, 44188, 44194, 44210, 38942, 38946, 38922, 44228, {38950, 0, 0, 0}, 110, 110, { 1252, 20280, 10000, 850, 0, ';' }},
+       {0x0411, 0x0011, 257, 55, 44231, 44237, 44254, 38994, 38998, 38972, 44273, {39002, 0, 0, 0}, 111, 111, { 932, 20290, 10001, 932, 0, ',' }},
+       {0x0412, 0x0012, 257, 58, 44276, 44282, 44303, 39049, 39053, 39029, 44328, {39057, 0, 0, 0}, 112, 112, { 949, 20833, 10003, 949, 0, ',' }},
+       {0x0413, 0x0013, 257, 77, 44331, 44337, 44357, 39087, 39091, 39067, 44380, {39095, 0, 0, 0}, 113, 113, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0414, 0x7C14, 257, 78, 44383, 44389, 44416, 39136, 39140, 39144, 44438, {38429, 0, 0, 0}, 114, 114, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0415, 0x0015, 257, 86, 44441, 44447, 44463, 39164, 39168, 39147, 44479, {39172, 0, 0, 0}, 115, 115, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x0416, 0x0016, 257, 14, 44482, 44488, 44508, 39221, 39225, 39196, 44528, {39229, 0, 0, 0}, 116, 116, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0417, 0x0017, 257, 18, 44531, 44537, 44559, 39273, 39277, 39252, 13632, {39281, 0, 0, 0}, 117, 117, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x0418, 0x0018, 257, 91, 44578, 44584, 44603, 39322, 39326, 39301, 44623, {39330, 0, 0, 0}, 118, 118, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x0419, 0x0019, 257, 93, 44626, 44632, 44649, 39375, 39379, 39349, 44679, {39383, 0, 0, 0}, 119, 119, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x041A, 0x001A, 257, 43, 44682, 44688, 44707, 39450, 39454, 39429, 44727, {39458, 0, 0, 0}, 120, 120, { 1250, 500, 10082, 852, 0, ';' }},
+       {0x041B, 0x001B, 257, 99, 44730, 44736, 44754, 39500, 39504, 12674, 44778, {39508, 0, 0, 0}, 121, 121, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x041C, 0x001C, 257, 2, 44781, 44787, 44806, 39550, 39554, 39532, 44824, {39558, 0, 0, 0}, 122, 122, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x041D, 0x001D, 257, 96, 44827, 44833, 44850, 39597, 39601, 39578, 44868, {38429, 0, 0, 0}, 123, 123, { 1252, 20278, 10000, 850, 0, ';' }},
+       {0x041E, 0x001E, 512, 102, 44871, 44877, 44893, 39623, 39627, 39605, 44915, {0, 39631, 0, 0}, 124, 124, { 874, 20838, 10021, 874, 0, ',' }},
+       {0x041F, 0x001F, 257, 105, 44918, 44924, 44941, 39679, 39683, 12683, 44961, {39687, 0, 0, 0}, 125, 125, { 1254, 20905, 10081, 857, 0, ';' }},
+       {0x0420, 0x0020, 257, 85, 44964, 44970, 44986, 39718, 39722, 39701, 45012, {39726, 0, 0, 0}, 126, 126, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x0421, 0x0021, 257, 45, 45015, 45021, 45044, 39787, 39791, 39756, 45073, {39795, 0, 0, 0}, 127, 127, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0422, 0x0022, 257, 108, 45076, 45082, 45102, 39848, 39852, 39814, 45140, {39856, 0, 0, 0}, 128, 128, { 1251, 500, 10017, 866, 0, ';' }},
+       {0x0423, 0x0023, 257, 15, 45143, 45149, 45170, 39937, 39941, 39902, 45210, {39945, 0, 0, 0}, 129, 129, { 1251, 500, 10007, 866, 0, ';' }},
+       {0x0424, 0x0024, 257, 98, 45213, 45219, 45240, 40014, 40018, 39987, 45266, {40022, 0, 0, 0}, 130, 130, { 1250, 20880, 10029, 852, 0, ';' }},
+       {0x0425, 0x0025, 257, 29, 45269, 45275, 45294, 40062, 40066, 40044, 45308, {40070, 0, 0, 0}, 131, 131, { 1257, 500, 10029, 775, 0, ';' }},
+       {0x0426, 0x0026, 257, 66, 45311, 45317, 45334, 40111, 40115, 40090, 45354, {40119, 0, 0, 0}, 132, 132, { 1257, 500, 10029, 775, 0, ';' }},
+       {0x0427, 0x0027, 257, 64, 45357, 45363, 45386, 40162, 40166, 40138, 45406, {40170, 0, 0, 0}, 133, 133, { 1257, 500, 10029, 775, 0, ';' }},
+       {0x0428, 0x7C28, 257, 103, 45409, 45420, 45449, 40215, 40219, 40193, 45485, {0, 0, 0, 0}, 134, 134, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0429, 0x0029, 257, 50, 45488, 45494, 45509, 40245, 40249, 40223, 45533, {40253, 0, 0, 0}, 135, 135, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x042A, 0x002A, 257, 113, 45536, 45542, 45563, 40306, 35137, 40277, 45591, {40310, 0, 0, 0}, 136, 136, { 1258, 500, 10000, 1258, 0, ',' }},
+       {0x042B, 0x002B, 257, 3, 45594, 45600, 45619, 40352, 40356, 40325, 1820, {40360, 0, 0, 0}, 137, 137, { 0, 500, 2, 1, 0, ',' }},
+       {0x042C, 0x782C, 257, 7, 45653, 45664, 45696, 40417, 40421, 40390, 45722, {40425, 0, 0, 0}, 138, 138, { 1254, 20905, 10081, 857, 0, ';' }},
+       {0x042D, 0x002D, 257, 31, 45725, 45731, 45746, 40462, 40466, 40444, 43651, {40470, 0, 0, 0}, 139, 139, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x042F, 0x002F, 257, 71, 45765, 45771, 45794, 40525, 40529, 40490, 45838, {40533, 0, 0, 0}, 140, 140, { 1251, 500, 10007, 866, 0, ';' }},
+       {0x0432, 0x0032, 257, 115, 45841, 45847, 40587, 40596, 40600, 40577, 45869, {0, 0, 0, 0}, 141, 141, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0434, 0x0034, 257, 115, 45872, 45878, 40613, 40622, 40626, 40604, 45869, {0, 0, 0, 0}, 142, 142, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0435, 0x0035, 257, 115, 45899, 45905, 45925, 40646, 40650, 40630, 45869, {40654, 0, 0, 0}, 143, 143, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0436, 0x0036, 257, 115, 45950, 45956, 45981, 40688, 40692, 40675, 45869, {40696, 0, 0, 0}, 144, 144, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0437, 0x0037, 257, 37, 46005, 46011, 46030, 40750, 40754, 40716, 46085, {40758, 0, 0, 0}, 145, 145, { 0, 500, 2, 1, 0, ';' }},
+       {0x0438, 0x0038, 257, 34, 46088, 46094, 46118, 40844, 40848, 40823, 46139, {0, 0, 0, 0}, 146, 146, { 1252, 20277, 10079, 850, 0, ';' }},
+       {0x0439, 0x0039, 257, 48, 46142, 46148, 46162, 40877, 40881, 40852, 46193, {40885, 0, 0, 0}, 147, 147, { 0, 500, 2, 1, 0, ',' }},
+       {0x043A, 0x003A, 257, 73, 46196, 46202, 46218, 40955, 40959, 40938, 46232, {40963, 0, 0, 0}, 148, 148, { 0, 500, 2, 1, 0, ',' }},
+       {0x043B, 0x003B, 257, 78, 46235, 46241, 46264, 41018, 41022, 40984, 44438, {41026, 0, 0, 0}, 149, 149, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0441, 0x0041, 257, 56, 46289, 46295, 46311, 41313, 41317, 41292, 46329, {41321, 0, 0, 0}, 150, 150, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x0443, 0x7C43, 257, 111, 46332, 46343, 46369, 41362, 41366, 41342, 46395, {41370, 0, 0, 0}, 151, 151, { 1254, 500, 10029, 857, 0, ';' }},
+       {0x0445, 0x0045, 257, 48, 46398, 46404, 46420, 41417, 41421, 41390, 46193, {41425, 0, 0, 0}, 152, 152, { 0, 500, 2, 1, 0, ',' }},
+       {0x0447, 0x0047, 257, 48, 46451, 46457, 46474, 41609, 41613, 41575, 46193, {41617, 0, 0, 0}, 153, 153, { 0, 500, 2, 1, 0, ',' }},
+       {0x0448, 0x0048, 257, 48, 46511, 46517, 46531, 41698, 41702, 41673, 46193, {0, 0, 0, 0}, 154, 154, { 0, 500, 2, 1, 0, ',' }},
+       {0x0449, 0x0049, 257, 48, 46562, 46568, 46582, 41731, 41735, 41706, 46193, {41739, 0, 0, 0}, 155, 155, { 0, 500, 2, 1, 0, ',' }},
+       {0x044A, 0x004A, 257, 48, 46622, 46628, 46643, 41833, 41837, 41804, 46193, {41841, 0, 0, 0}, 156, 156, { 0, 500, 2, 1, 0, ',' }},
+       {0x044B, 0x004B, 257, 48, 46690, 46696, 46712, 41930, 41934, 37322, 46193, {41938, 0, 0, 0}, 157, 157, { 0, 500, 2, 1, 0, ',' }},
+       {0x044C, 0x004C, 257, 48, 46743, 46749, 46767, 42035, 42039, 42003, 46193, {42043, 0, 0, 0}, 158, 158, { 0, 500, 2, 1, 0, ',' }},
+       {0x044D, 0x004D, 257, 48, 46807, 46813, 46830, 42121, 42125, 42087, 46193, {42129, 0, 0, 0}, 159, 159, { 0, 500, 2, 1, 0, ',' }},
+       {0x044E, 0x004E, 257, 48, 46867, 46873, 46889, 42209, 2402, 42182, 46193, {42213, 0, 0, 0}, 160, 160, { 0, 500, 2, 1, 0, ',' }},
+       {0x0451, 0x0051, 257, 20, 46920, 46926, 46942, 42377, 42381, 42341, 13711, {0, 0, 0, 0}, 161, 161, { 0, 500, 2, 1, 0, ',' }},
+       {0x0452, 0x0052, 257, 36, 46988, 46994, 47017, 42402, 42406, 42385, 47044, {42410, 0, 0, 0}, 162, 162, { 1252, 20285, 10000, 850, 0, ',' }},
+       {0x0453, 0x0053, 257, 57, 47047, 47053, 47070, 42451, 42455, 42426, 47110, {42459, 0, 0, 0}, 163, 163, { 0, 500, 2, 1, 0, ',' }},
+       {0x0454, 0x0054, 257, 60, 47113, 47119, 47130, 42531, 42535, 42514, 47152, {42539, 0, 0, 0}, 164, 164, { 0, 500, 2, 1, 0, ',' }},
+       {0x0456, 0x0056, 257, 31, 47155, 47161, 47178, 42604, 42608, 42585, 43651, {38950, 0, 0, 0}, 165, 165, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0457, 0x0057, 257, 48, 47195, 47202, 47218, 42643, 42612, 42612, 46193, {0, 0, 0, 0}, 166, 166, { 0, 500, 2, 1, 0, ',' }},
+       {0x045B, 0x005B, 257, 63, 47252, 47258, 47278, 42674, 42678, 42647, 47328, {42682, 0, 0, 0}, 167, 167, { 0, 500, 2, 1, 0, ',' }},
+       {0x045E, 0x005E, 257, 32, 47331, 47337, 47356, 42762, 42766, 8022, 47387, {42770, 0, 0, 0}, 168, 168, { 0, 500, 2, 1, 0, ';' }},
+       {0x0461, 0x0061, 257, 79, 47390, 47396, 47411, 42883, 42887, 1883, 47448, {42891, 0, 0, 0}, 169, 169, { 0, 500, 2, 1, 0, ',' }},
+       {0x0463, 0x0063, 1024, 1, 47451, 47457, 47478, 42960, 42964, 42941, 47508, {0, 0, 0, 0}, 170, 170, { 0, 500, 2, 1, 1, ';' }},
+       {0x0464, 0x0064, 257, 84, 47511, 47518, 47541, 42981, 42968, 42968, 47562, {42985, 0, 0, 0}, 171, 171, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x0468, 0x7C68, 257, 75, 47565, 47576, 47599, 43017, 43021, 43008, 47616, {0, 0, 0, 0}, 172, 172, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x046A, 0x006A, 257, 75, 47619, 47625, 47642, 43050, 43054, 43025, 47616, {0, 0, 0, 0}, 173, 173, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x046C, 0x006C, 257, 115, 47688, 47695, 43077, 43094, 43058, 43058, 45869, {0, 0, 0, 0}, 174, 174, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x046F, 0x006F, 257, 38, 47725, 47731, 47755, 43125, 43129, 43098, 47786, {43133, 0, 0, 0}, 175, 175, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0470, 0x0070, 257, 75, 47789, 47795, 47795, 43168, 43172, 43160, 47616, {0, 0, 0, 0}, 176, 176, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x0478, 0x0078, 257, 20, 47810, 47816, 47835, 43200, 43204, 43176, 13711, {43208, 0, 0, 0}, 177, 177, { 0, 500, 2, 1, 0, ',' }},
+       {0x047E, 0x007E, 257, 35, 47854, 47860, 47876, 43241, 43245, 43221, 44035, {43249, 0, 0, 0}, 178, 178, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x0485, 0x0085, 257, 93, 47895, 47902, 43344, 43362, 43334, 43334, 44679, {0, 0, 0, 0}, 179, 179, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0487, 0x0087, 257, 94, 47917, 47923, 47923, 43381, 43385, 43366, 47944, {0, 0, 0, 0}, 180, 180, { 1252, 37, 10000, 437, 0, ';' }},
+       {0x0491, 0x0091, 257, 36, 47947, 47953, 47986, 43418, 43422, 43389, 47044, {43426, 0, 0, 0}, 181, 181, { 1252, 20285, 10000, 850, 0, ',' }},
+       {0x0801, 0x0001, 257, 49, 48022, 48028, 48042, 48072, 38102, 38073, 48076, {48079, 0, 0, 0}, 182, 182, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x0804, 0x0004, 257, 20, 48111, 38331, 48117, 38305, 38309, 38313, 13711, {38316, 0, 0, 0}, 183, 183, { 936, 500, 10008, 936, 0, ',' }},
+       {0x0807, 0x0007, 257, 18, 48133, 48139, 48160, 48178, 38472, 38450, 13632, {38476, 0, 0, 0}, 184, 184, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x0809, 0x0009, 257, 36, 48182, 48188, 48188, 48213, 38592, 38577, 47044, {38596, 0, 0, 0}, 185, 185, { 1252, 20285, 10000, 850, 0, ',' }},
+       {0x080A, 0x000A, 257, 74, 48217, 48223, 48240, 48259, 38639, 38615, 48263, {38950, 0, 0, 0}, 186, 186, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x080C, 0x000C, 257, 10, 48266, 48272, 48289, 48310, 38739, 38715, 48314, {38743, 0, 0, 0}, 187, 187, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x0810, 0x0010, 257, 18, 48317, 48323, 48345, 48365, 38946, 38922, 13632, {38950, 0, 0, 0}, 188, 188, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0813, 0x0013, 257, 10, 48369, 48375, 48391, 48412, 39091, 39067, 48314, {39095, 0, 0, 0}, 189, 189, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x0814, 0x7814, 257, 78, 48416, 48422, 48449, 48465, 48469, 48473, 44438, {38429, 0, 0, 0}, 190, 190, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x0816, 0x0016, 257, 88, 48476, 48482, 48504, 48526, 39225, 39196, 48530, {39229, 0, 0, 0}, 191, 191, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x081D, 0x001D, 257, 33, 48533, 48539, 48557, 48575, 39601, 39578, 43991, {38429, 0, 0, 0}, 192, 192, { 1252, 20278, 10000, 850, 0, ';' }},
+       {0x082C, 0x742C, 257, 7, 48579, 48590, 45696, 48625, 40421, 40390, 45722, {40425, 0, 0, 0}, 193, 193, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x083C, 0x003C, 257, 46, 48629, 48635, 48651, 41062, 41066, 41045, 48667, {41070, 0, 0, 0}, 194, 194, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0843, 0x7843, 257, 111, 48670, 48681, 46369, 41362, 41366, 41342, 46395, {48710, 0, 0, 0}, 195, 195, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x0845, 0x0045, 257, 9, 48748, 48754, 48775, 48818, 41421, 41390, 48822, {41425, 0, 0, 0}, 196, 196, { 0, 500, 2, 1, 0, ',' }},
+       {0x0C01, 0x0001, 257, 30, 48825, 48831, 48846, 48870, 38102, 38073, 48874, {48079, 0, 0, 0}, 197, 197, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x0C04, 0x7C04, 257, 41, 48877, 48883, 48926, 48963, 38309, 38313, 48967, {43705, 0, 0, 0}, 198, 198, { 950, 500, 10002, 950, 0, ',' }},
+       {0x0C07, 0x0007, 257, 5, 48970, 48976, 48993, 49015, 38472, 38450, 49019, {38476, 0, 0, 0}, 199, 199, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x0C09, 0x0009, 257, 6, 49022, 49028, 49028, 49048, 38592, 38577, 49052, {38596, 0, 0, 0}, 200, 200, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x0C0A, 0x000A, 257, 31, 49055, 49061, 49077, 49096, 38639, 38615, 43651, {38643, 0, 0, 0}, 201, 201, { 1252, 20284, 10000, 850, 0, ';' }},
+       {0x0C0C, 0x000C, 257, 17, 49100, 49106, 49122, 49141, 38739, 38715, 49145, {49148, 0, 0, 0}, 202, 202, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x0C3B, 0x003B, 257, 33, 49170, 49176, 49200, 49226, 49230, 40984, 43991, {41026, 0, 0, 0}, 203, 203, { 1252, 20278, 10000, 850, 0, ';' }},
+       {0x1001, 0x0001, 257, 67, 49234, 49240, 49255, 49283, 38102, 38073, 49287, {48079, 0, 0, 0}, 204, 204, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x1004, 0x0004, 257, 97, 49290, 49296, 49328, 49347, 38309, 38313, 49351, {38316, 0, 0, 0}, 205, 205, { 936, 500, 10008, 936, 0, ',' }},
+       {0x1007, 0x0007, 257, 65, 49354, 49360, 49380, 49400, 38472, 38450, 49404, {38476, 0, 0, 0}, 206, 206, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x1009, 0x0009, 257, 17, 49407, 49413, 49413, 49430, 38592, 38577, 49145, {38596, 0, 0, 0}, 207, 207, { 1252, 37, 10000, 850, 0, ',' }},
+       {0x100A, 0x000A, 257, 40, 49434, 49440, 49460, 49481, 38639, 38615, 49485, {38643, 0, 0, 0}, 208, 208, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x100C, 0x000C, 257, 18, 49488, 49494, 49515, 49534, 38739, 38715, 13632, {38743, 0, 0, 0}, 209, 209, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x101A, 0x001A, 257, 8, 49538, 49544, 49578, 49609, 49613, 39429, 49617, {39458, 0, 0, 0}, 210, 210, { 1250, 870, 10082, 852, 0, ';' }},
+       {0x1401, 0x0001, 257, 27, 49620, 49626, 49643, 49675, 38102, 38073, 49679, {48079, 0, 0, 0}, 211, 211, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x1404, 0x7C04, 257, 72, 49682, 49688, 49727, 49764, 38309, 38313, 49768, {43705, 0, 0, 0}, 212, 212, { 950, 500, 10002, 950, 0, ',' }},
+       {0x1407, 0x0007, 257, 62, 49771, 49777, 49800, 49824, 38472, 38450, 49828, {38476, 0, 0, 0}, 213, 213, { 1252, 20273, 10000, 850, 0, ';' }},
+       {0x1409, 0x0009, 257, 80, 49831, 49837, 49837, 49859, 38592, 38577, 49863, {38596, 0, 0, 0}, 214, 214, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x140A, 0x000A, 257, 22, 49866, 49872, 49893, 49915, 38639, 38615, 49919, {38643, 0, 0, 0}, 215, 215, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x140C, 0x000C, 257, 65, 49922, 49928, 49948, 49971, 38739, 38715, 49404, {38743, 0, 0, 0}, 216, 216, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x141A, 0x681A, 257, 8, 49975, 49986, 50026, 50057, 50061, 50065, 49617, {50068, 0, 0, 0}, 217, 217, { 1250, 870, 10082, 852, 0, ';' }},
+       {0x1801, 0x0001, 257, 68, 50091, 50097, 50114, 50144, 38102, 38073, 50148, {48079, 0, 0, 0}, 218, 218, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x1809, 0x0009, 257, 46, 50151, 50157, 50157, 50175, 38592, 38577, 48667, {38596, 0, 0, 0}, 219, 219, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x180A, 0x000A, 257, 82, 50179, 50185, 50202, 50221, 38639, 38615, 50225, {38643, 0, 0, 0}, 220, 220, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x180C, 0x000C, 257, 69, 50228, 50234, 50250, 50269, 38739, 38715, 50273, {38743, 0, 0, 0}, 221, 221, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x181A, 0x701A, 257, 8, 50276, 50287, 50327, 50379, 50383, 50387, 49617, {50068, 0, 0, 0}, 222, 222, { 1250, 870, 10082, 852, 0, ';' }},
+       {0x1C01, 0x0001, 257, 104, 50390, 50396, 50413, 50439, 38102, 38073, 50443, {48079, 0, 0, 0}, 223, 223, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x1C09, 0x0009, 257, 115, 50446, 50452, 50452, 50475, 38592, 38577, 45869, {38596, 0, 0, 0}, 224, 224, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x1C0A, 0x000A, 257, 26, 50479, 50485, 50514, 50547, 38639, 38615, 50551, {38643, 0, 0, 0}, 225, 225, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x1C1A, 0x6C1A, 257, 8, 50554, 50565, 50327, 50608, 50612, 50387, 49617, {40533, 0, 0, 0}, 226, 226, { 1251, 21025, 10007, 855, 0, ';' }},
+       {0x2001, 0x0001, 257, 81, 50616, 50622, 50636, 50664, 38102, 38073, 50668, {48079, 0, 0, 0}, 227, 227, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x2009, 0x0009, 257, 53, 50671, 50677, 50677, 50695, 38592, 38577, 50699, {38596, 0, 0, 0}, 228, 228, { 1252, 500, 10000, 850, 0, ',' }},
+       {0x200A, 0x000A, 257, 112, 50702, 50708, 50728, 50749, 38639, 38615, 50753, {38643, 0, 0, 0}, 229, 229, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x201A, 0x641A, 257, 8, 50756, 50767, 50026, 50810, 50814, 50065, 49617, {40533, 0, 0, 0}, 230, 230, { 1251, 870, 10082, 855, 0, ';' }},
+       {0x2401, 0x0001, 257, 114, 50818, 50824, 50839, 50867, 38102, 38073, 50871, {48079, 0, 0, 0}, 231, 231, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x240A, 0x000A, 257, 21, 50874, 50880, 50899, 50919, 38639, 38615, 50923, {38643, 0, 0, 0}, 232, 232, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x241A, 0x701A, 257, 92, 50926, 50937, 50961, 50989, 2130, 50387, 50993, {50068, 0, 0, 0}, 233, 233, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x2801, 0x0001, 257, 101, 50996, 51002, 51017, 51045, 38102, 38073, 51049, {48079, 0, 0, 0}, 234, 234, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x2809, 0x0009, 257, 16, 51052, 51058, 51058, 51075, 38592, 38577, 51079, {38596, 0, 0, 0}, 235, 235, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x280A, 0x000A, 257, 83, 51082, 51088, 51103, 51120, 38639, 38615, 51124, {38643, 0, 0, 0}, 236, 236, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x281A, 0x6C1A, 257, 92, 51127, 51138, 50961, 51165, 2130, 50387, 50993, {40533, 0, 0, 0}, 237, 237, { 1251, 21025, 10007, 855, 0, ';' }},
+       {0x2C01, 0x0001, 257, 54, 51169, 51175, 51191, 51221, 38102, 38073, 51225, {48079, 0, 0, 0}, 238, 238, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x2C09, 0x0009, 257, 106, 51228, 51234, 51234, 51264, 38592, 38577, 51268, {38596, 0, 0, 0}, 239, 239, { 1252, 500, 10000, 850, 0, ';' }},
+       {0x2C0A, 0x000A, 257, 4, 51271, 51277, 51297, 51318, 38639, 38615, 51322, {38643, 0, 0, 0}, 240, 240, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x2C1A, 0x701A, 257, 70, 51325, 51336, 51364, 51397, 2130, 50387, 51401, {50068, 0, 0, 0}, 241, 241, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x3001, 0x0001, 257, 61, 51404, 51410, 51427, 51455, 38102, 38073, 51459, {48079, 0, 0, 0}, 242, 242, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x3009, 0x0009, 257, 116, 51462, 51468, 51468, 51487, 38592, 38577, 51491, {38596, 0, 0, 0}, 243, 243, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x300A, 0x000A, 257, 28, 51494, 51500, 51518, 51537, 38639, 38615, 51541, {38643, 0, 0, 0}, 244, 244, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x301A, 0x6C1A, 257, 70, 51544, 51555, 51364, 51586, 2130, 50387, 51401, {40533, 0, 0, 0}, 245, 245, { 1251, 21025, 10007, 855, 0, ';' }},
+       {0x3401, 0x0001, 257, 59, 51590, 51596, 51612, 51642, 38102, 38073, 51646, {48079, 0, 0, 0}, 246, 246, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x3409, 0x0009, 257, 84, 51649, 51655, 51655, 51677, 38592, 38577, 47562, {38596, 0, 0, 0}, 247, 247, { 1252, 500, 10000, 437, 0, ',' }},
+       {0x340A, 0x000A, 257, 19, 51681, 51687, 51703, 51720, 38639, 38615, 51724, {38643, 0, 0, 0}, 248, 248, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x3801, 0x0001, 257, 0, 51727, 51733, 51763, 51827, 38102, 38073, 51831, {48079, 0, 0, 0}, 249, 249, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x380A, 0x000A, 257, 110, 51834, 51840, 51858, 51877, 38639, 38615, 51881, {38643, 0, 0, 0}, 250, 250, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x3C01, 0x0001, 257, 12, 51884, 51890, 51907, 51939, 38102, 38073, 51943, {48079, 0, 0, 0}, 251, 251, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x3C0A, 0x000A, 257, 89, 51946, 51952, 51971, 51991, 38639, 38615, 51995, {38643, 0, 0, 0}, 252, 252, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x4001, 0x0001, 257, 90, 51998, 52004, 52019, 52043, 38102, 38073, 52047, {48079, 0, 0, 0}, 253, 253, { 1256, 20420, 10004, 720, 1, ';' }},
+       {0x4009, 0x0009, 257, 48, 52050, 52056, 52056, 52072, 38592, 38577, 46193, {38596, 0, 0, 0}, 254, 254, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x400A, 0x000A, 257, 13, 52076, 52082, 52100, 52119, 38639, 38615, 52123, {38643, 0, 0, 0}, 255, 255, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x440A, 0x000A, 257, 100, 52126, 52132, 52154, 52177, 38639, 38615, 52181, {38643, 0, 0, 0}, 256, 256, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x4809, 0x0009, 257, 97, 52184, 52190, 52190, 52210, 38592, 38577, 49351, {38596, 0, 0, 0}, 257, 257, { 1252, 37, 10000, 437, 0, ',' }},
+       {0x480A, 0x000A, 257, 42, 52214, 52220, 52239, 52259, 38639, 38615, 52263, {38643, 0, 0, 0}, 258, 258, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x4C0A, 0x000A, 257, 76, 52266, 52272, 52292, 52313, 38639, 38615, 52317, {38643, 0, 0, 0}, 259, 259, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x500A, 0x000A, 257, 87, 52320, 52326, 52348, 52371, 38639, 38615, 52375, {38643, 0, 0, 0}, 260, 260, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x540A, 0x000A, 257, 109, 52378, 52384, 52408, 52434, 38639, 38615, 43950, {38643, 0, 0, 0}, 261, 261, { 1252, 20284, 10000, 850, 0, ',' }},
+       {0x641A, 0x781A, 257, -1, 52438, 52446, 52465, 50810, 50814, 50065, 0, {40533, 0, 0, 0}, 262, 262, { 1251, 870, 10082, 855, 0, ';' }},
+       {0x681A, 0x781A, 257, -1, 52474, 52482, 52465, 50057, 50061, 50065, 0, {50068, 0, 0, 0}, 263, 263, { 1250, 870, 10082, 852, 0, ';' }},
+       {0x6C1A, 0x7C1A, 257, -1, 52498, 52506, 52525, 51165, 2130, 50387, 0, {40533, 0, 0, 0}, 264, 264, { 1251, 21025, 10007, 855, 0, ';' }},
+       {0x701A, 0x7C1A, 257, -1, 52538, 52546, 52525, 50989, 2130, 50387, 0, {50068, 0, 0, 0}, 265, 265, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x742C, 0x002C, 257, -1, 52562, 52570, 40405, 48625, 40421, 40390, 0, {40425, 0, 0, 0}, 266, 266, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x7804, 0x007F, 257, -1, 38313, 38331, 38298, 38305, 38309, 38313, 0, {38316, 0, 0, 0}, 267, 267, { 936, 500, 10008, 936, 0, ',' }},
+       {0x7814, 0x0014, 257, -1, 48473, 52593, 52611, 48465, 48469, 48473, 0, {38429, 0, 0, 0}, 268, 268, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x781A, 0x007F, 257, -1, 50065, 52619, 52465, 50057, 50061, 50065, 0, {50068, 0, 0, 0}, 269, 269, { 1250, 870, 10082, 852, 0, ';' }},
+       {0x782C, 0x002C, 257, -1, 52627, 52635, 40405, 40417, 40421, 40390, 0, {40425, 0, 0, 0}, 270, 270, { 1254, 20905, 10081, 857, 0, ';' }},
+       {0x7843, 0x0043, 257, -1, 52655, 52663, 41351, 41362, 41366, 41342, 0, {48710, 0, 0, 0}, 271, 271, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x7850, 0x0050, 257, -1, 52680, 52688, 42288, 52709, 42305, 42275, 0, {42309, 0, 0, 0}, 272, 272, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x7C04, 0x7804, 257, -1, 52713, 43660, 38298, 43698, 38309, 38313, 0, {43705, 0, 0, 0}, 273, 273, { 950, 500, 10002, 950, 0, ',' }},
+       {0x7C04, 0x7C04, 257, -1, 52721, 52728, 38298, 43698, 38309, 38313, 0, {43705, 0, 0, 0}, 274, 274, { 950, 500, 10002, 950, 0, ',' }},
+       {0x7C14, 0x0014, 257, -1, 39144, 52757, 52775, 39136, 39140, 39144, 0, {38429, 0, 0, 0}, 275, 275, { 1252, 20277, 10000, 850, 0, ';' }},
+       {0x7C1A, 0x007F, 257, -1, 50387, 52789, 52525, 52797, 2130, 50387, 0, {40533, 0, 0, 0}, 276, 276, { 1250, 500, 10029, 852, 0, ';' }},
+       {0x7C28, 0x0028, 257, -1, 52801, 52809, 40202, 40215, 40219, 40193, 0, {0, 0, 0, 0}, 277, 277, { 1251, 20880, 10007, 866, 0, ';' }},
+       {0x7C43, 0x0043, 257, -1, 52826, 52834, 41351, 41362, 41366, 41342, 0, {41370, 0, 0, 0}, 278, 278, { 1254, 500, 10029, 857, 0, ';' }},
+       {0x7C5F, 0x005F, 257, -1, 52848, 52857, 42843, 42853, 42815, 42815, 0, {0, 0, 0, 0}, 279, 279, { 1252, 20297, 10000, 850, 0, ';' }},
+       {0x7C68, 0x0068, 257, -1, 52889, 52897, 43011, 43017, 43021, 43008, 0, {0, 0, 0, 0}, 280, 280, { 1252, 37, 10000, 437, 0, ',' }}
 };
 
 
 static const CultureInfoNameEntry culture_name_entries [] = {
-       {40693, 50},     /* af */
-       {52929, 144},    /* af-za */
+       {40675, 50},     /* af */
+       {52911, 144},    /* af-za */
        {8022, 80},      /* am */
-       {52935, 168},    /* am-et */
-       {38091, 0},      /* ar */
-       {52941, 249},    /* ar-ae */
-       {52947, 251},    /* ar-bh */
-       {52953, 211},    /* ar-dz */
-       {52959, 197},    /* ar-eg */
-       {52965, 182},    /* ar-iq */
-       {52971, 238},    /* ar-jo */
-       {52977, 246},    /* ar-kw */
-       {52983, 242},    /* ar-lb */
-       {52989, 204},    /* ar-ly */
-       {52995, 218},    /* ar-ma */
-       {53001, 227},    /* ar-om */
-       {53007, 253},    /* ar-qa */
-       {53013, 96},     /* ar-sa */
-       {53019, 234},    /* ar-sy */
-       {53025, 223},    /* ar-tn */
-       {53031, 231},    /* ar-ye */
-       {42105, 70},     /* as */
-       {53037, 159},    /* as-in */
-       {40408, 44},     /* az */
-       {53043, 266},    /* az-cyrl */
-       {53051, 193},    /* az-cyrl-az */
-       {53062, 270},    /* az-latn */
-       {53070, 138},    /* az-latn-az */
-       {39920, 35},     /* be */
-       {53081, 129},    /* be-by */
-       {38152, 1},      /* bg */
-       {53087, 97},     /* bg-bg */
-       {41408, 62},     /* bn */
-       {53093, 196},    /* bn-bd */
-       {53099, 152},    /* bn-in */
-       {42359, 73},     /* bo */
-       {53105, 161},    /* bo-cn */
-       {43239, 91},     /* br */
-       {53111, 178},    /* br-fr */
-       {50083, 269},    /* bs */
-       {53117, 262},    /* bs-cyrl */
-       {53125, 230},    /* bs-cyrl-ba */
-       {53136, 263},    /* bs-latn */
-       {53144, 217},    /* bs-latn-ba */
-       {38234, 2},      /* ca */
-       {53155, 98},     /* ca-es */
-       {38370, 5},      /* cs */
-       {53161, 100},    /* cs-cz */
-       {42403, 74},     /* cy */
-       {53167, 162},    /* cy-gb */
-       {38423, 6},      /* da */
-       {53173, 101},    /* da-dk */
-       {38468, 7},      /* de */
-       {53179, 199},    /* de-at */
-       {53185, 184},    /* de-ch */
-       {53191, 102},    /* de-de */
-       {53197, 213},    /* de-li */
-       {53203, 206},    /* de-lu */
-       {38519, 8},      /* el */
-       {53209, 103},    /* el-gr */
-       {38595, 9},      /* en */
-       {53215, 200},    /* en-au */
-       {53221, 235},    /* en-bz */
-       {53227, 207},    /* en-ca */
-       {53233, 185},    /* en-gb */
-       {53239, 219},    /* en-ie */
-       {53245, 254},    /* en-in */
-       {53251, 228},    /* en-jm */
-       {53257, 214},    /* en-nz */
-       {53263, 247},    /* en-ph */
-       {53269, 257},    /* en-sg */
-       {53275, 239},    /* en-tt */
-       {53281, 104},    /* en-us */
-       {53287, 224},    /* en-za */
-       {53293, 243},    /* en-zw */
-       {38633, 10},     /* es */
-       {53299, 240},    /* es-ar */
-       {53305, 255},    /* es-bo */
-       {53311, 248},    /* es-cl */
-       {53317, 232},    /* es-co */
-       {53323, 215},    /* es-cr */
-       {53329, 225},    /* es-do */
-       {53335, 244},    /* es-ec */
-       {53341, 201},    /* es-es */
-       {53347, 208},    /* es-gt */
-       {53353, 258},    /* es-hn */
-       {53359, 186},    /* es-mx */
-       {53365, 259},    /* es-ni */
-       {53371, 220},    /* es-pa */
-       {53377, 236},    /* es-pe */
-       {53383, 260},    /* es-pr */
-       {53389, 252},    /* es-py */
-       {53395, 256},    /* es-sv */
-       {53401, 261},    /* es-us */
-       {53407, 250},    /* es-uy */
-       {53413, 229},    /* es-ve */
-       {40062, 37},     /* et */
-       {53419, 131},    /* et-ee */
-       {40462, 45},     /* eu */
-       {53425, 139},    /* eu-es */
-       {40241, 41},     /* fa */
-       {53431, 135},    /* fa-ir */
-       {38683, 11},     /* fi */
-       {53437, 105},    /* fi-fi */
-       {42986, 84},     /* fil */
-       {53443, 171},    /* fil-ph */
-       {40841, 52},     /* fo */
-       {53450, 146},    /* fo-fo */
-       {38733, 12},     /* fr */
-       {53456, 187},    /* fr-be */
-       {53462, 202},    /* fr-ca */
-       {53468, 209},    /* fr-ch */
-       {53474, 106},    /* fr-fr */
-       {53480, 216},    /* fr-lu */
-       {53486, 221},    /* fr-mc */
-       {41063, 56},     /* ga */
-       {53492, 194},    /* ga-ie */
-       {43407, 95},     /* gd */
-       {53498, 181},    /* gd-gb */
-       {42603, 77},     /* gl */
-       {53504, 165},    /* gl-es */
-       {43287, 92},     /* gsw */
-       {41593, 64},     /* gu */
-       {53510, 153},    /* gu-in */
-       {43026, 85},     /* ha */
-       {53516, 280},    /* ha-latn */
-       {53524, 172},    /* ha-latn-ng */
-       {38783, 13},     /* he */
-       {53535, 107},    /* he-il */
-       {40870, 53},     /* hi */
-       {53541, 147},    /* hi-in */
-       {39447, 26},     /* hr */
-       {53547, 210},    /* hr-ba */
-       {53553, 120},    /* hr-hr */
-       {38845, 14},     /* hu */
-       {53559, 108},    /* hu-hu */
-       {40343, 43},     /* hy */
-       {53565, 137},    /* hy-am */
-       {39774, 33},     /* id */
-       {53571, 127},    /* id-id */
-       {43178, 89},     /* ig */
-       {53577, 176},    /* ig-ng */
-       {43194, 90},     /* ii */
-       {53583, 177},    /* ii-cn */
-       {38889, 15},     /* is */
-       {53589, 109},    /* is-is */
-       {38940, 16},     /* it */
-       {53595, 188},    /* it-ch */
-       {53601, 110},    /* it-it */
-       {38990, 17},     /* ja */
-       {53607, 111},    /* ja-jp */
-       {40734, 51},     /* ka */
-       {53613, 145},    /* ka-ge */
-       {41157, 58},     /* kk */
-       {43116, 88},     /* kl */
-       {53619, 175},    /* kl-gl */
-       {42444, 75},     /* km */
-       {53625, 163},    /* km-kh */
-       {37340, 68},     /* kn */
-       {53631, 157},    /* kn-in */
-       {39047, 18},     /* ko */
-       {53637, 112},    /* ko-kr */
-       {42630, 78},     /* kok */
-       {53643, 166},    /* kok-in */
-       {41237, 59},     /* ky */
-       {42532, 76},     /* lo */
-       {53650, 164},    /* lo-la */
-       {40156, 39},     /* lt */
-       {53656, 133},    /* lt-lt */
-       {40108, 38},     /* lv */
-       {53662, 132},    /* lv-lv */
-       {40508, 46},     /* mk */
-       {53668, 140},    /* mk-mk */
-       {42021, 69},     /* ml */
-       {53674, 158},    /* ml-in */
-       {42293, 72},     /* mn */
-       {53680, 272},    /* mn-cyrl */
-       {42200, 71},     /* mr */
-       {53688, 160},    /* mr-in */
-       {41109, 57},     /* ms */
-       {40956, 54},     /* mt */
-       {53694, 148},    /* mt-mt */
-       {39162, 275},    /* nb */
-       {53700, 114},    /* nb-no */
+       {52917, 168},    /* am-et */
+       {38073, 0},      /* ar */
+       {52923, 249},    /* ar-ae */
+       {52929, 251},    /* ar-bh */
+       {52935, 211},    /* ar-dz */
+       {52941, 197},    /* ar-eg */
+       {52947, 182},    /* ar-iq */
+       {52953, 238},    /* ar-jo */
+       {52959, 246},    /* ar-kw */
+       {52965, 242},    /* ar-lb */
+       {52971, 204},    /* ar-ly */
+       {52977, 218},    /* ar-ma */
+       {52983, 227},    /* ar-om */
+       {52989, 253},    /* ar-qa */
+       {52995, 96},     /* ar-sa */
+       {53001, 234},    /* ar-sy */
+       {53007, 223},    /* ar-tn */
+       {53013, 231},    /* ar-ye */
+       {42087, 70},     /* as */
+       {53019, 159},    /* as-in */
+       {40390, 44},     /* az */
+       {53025, 266},    /* az-cyrl */
+       {53033, 193},    /* az-cyrl-az */
+       {53044, 270},    /* az-latn */
+       {53052, 138},    /* az-latn-az */
+       {39902, 35},     /* be */
+       {53063, 129},    /* be-by */
+       {38134, 1},      /* bg */
+       {53069, 97},     /* bg-bg */
+       {41390, 62},     /* bn */
+       {53075, 196},    /* bn-bd */
+       {53081, 152},    /* bn-in */
+       {42341, 73},     /* bo */
+       {53087, 161},    /* bo-cn */
+       {43221, 91},     /* br */
+       {53093, 178},    /* br-fr */
+       {50065, 269},    /* bs */
+       {53099, 262},    /* bs-cyrl */
+       {53107, 230},    /* bs-cyrl-ba */
+       {53118, 263},    /* bs-latn */
+       {53126, 217},    /* bs-latn-ba */
+       {38216, 2},      /* ca */
+       {53137, 98},     /* ca-es */
+       {38352, 5},      /* cs */
+       {53143, 100},    /* cs-cz */
+       {42385, 74},     /* cy */
+       {53149, 162},    /* cy-gb */
+       {38405, 6},      /* da */
+       {53155, 101},    /* da-dk */
+       {38450, 7},      /* de */
+       {53161, 199},    /* de-at */
+       {53167, 184},    /* de-ch */
+       {53173, 102},    /* de-de */
+       {53179, 213},    /* de-li */
+       {53185, 206},    /* de-lu */
+       {38501, 8},      /* el */
+       {53191, 103},    /* el-gr */
+       {38577, 9},      /* en */
+       {53197, 200},    /* en-au */
+       {53203, 235},    /* en-bz */
+       {53209, 207},    /* en-ca */
+       {53215, 185},    /* en-gb */
+       {53221, 219},    /* en-ie */
+       {53227, 254},    /* en-in */
+       {53233, 228},    /* en-jm */
+       {53239, 214},    /* en-nz */
+       {53245, 247},    /* en-ph */
+       {53251, 257},    /* en-sg */
+       {53257, 239},    /* en-tt */
+       {53263, 104},    /* en-us */
+       {53269, 224},    /* en-za */
+       {53275, 243},    /* en-zw */
+       {38615, 10},     /* es */
+       {53281, 240},    /* es-ar */
+       {53287, 255},    /* es-bo */
+       {53293, 248},    /* es-cl */
+       {53299, 232},    /* es-co */
+       {53305, 215},    /* es-cr */
+       {53311, 225},    /* es-do */
+       {53317, 244},    /* es-ec */
+       {53323, 201},    /* es-es */
+       {53329, 208},    /* es-gt */
+       {53335, 258},    /* es-hn */
+       {53341, 186},    /* es-mx */
+       {53347, 259},    /* es-ni */
+       {53353, 220},    /* es-pa */
+       {53359, 236},    /* es-pe */
+       {53365, 260},    /* es-pr */
+       {53371, 252},    /* es-py */
+       {53377, 256},    /* es-sv */
+       {53383, 261},    /* es-us */
+       {53389, 250},    /* es-uy */
+       {53395, 229},    /* es-ve */
+       {40044, 37},     /* et */
+       {53401, 131},    /* et-ee */
+       {40444, 45},     /* eu */
+       {53407, 139},    /* eu-es */
+       {40223, 41},     /* fa */
+       {53413, 135},    /* fa-ir */
+       {38665, 11},     /* fi */
+       {53419, 105},    /* fi-fi */
+       {42968, 84},     /* fil */
+       {53425, 171},    /* fil-ph */
+       {40823, 52},     /* fo */
+       {53432, 146},    /* fo-fo */
+       {38715, 12},     /* fr */
+       {53438, 187},    /* fr-be */
+       {53444, 202},    /* fr-ca */
+       {53450, 209},    /* fr-ch */
+       {53456, 106},    /* fr-fr */
+       {53462, 216},    /* fr-lu */
+       {53468, 221},    /* fr-mc */
+       {41045, 56},     /* ga */
+       {53474, 194},    /* ga-ie */
+       {43389, 95},     /* gd */
+       {53480, 181},    /* gd-gb */
+       {42585, 77},     /* gl */
+       {53486, 165},    /* gl-es */
+       {43269, 92},     /* gsw */
+       {41575, 64},     /* gu */
+       {53492, 153},    /* gu-in */
+       {43008, 85},     /* ha */
+       {53498, 280},    /* ha-latn */
+       {53506, 172},    /* ha-latn-ng */
+       {38765, 13},     /* he */
+       {53517, 107},    /* he-il */
+       {40852, 53},     /* hi */
+       {53523, 147},    /* hi-in */
+       {39429, 26},     /* hr */
+       {53529, 210},    /* hr-ba */
+       {53535, 120},    /* hr-hr */
+       {38827, 14},     /* hu */
+       {53541, 108},    /* hu-hu */
+       {40325, 43},     /* hy */
+       {53547, 137},    /* hy-am */
+       {39756, 33},     /* id */
+       {53553, 127},    /* id-id */
+       {43160, 89},     /* ig */
+       {53559, 176},    /* ig-ng */
+       {43176, 90},     /* ii */
+       {53565, 177},    /* ii-cn */
+       {38871, 15},     /* is */
+       {53571, 109},    /* is-is */
+       {38922, 16},     /* it */
+       {53577, 188},    /* it-ch */
+       {53583, 110},    /* it-it */
+       {38972, 17},     /* ja */
+       {53589, 111},    /* ja-jp */
+       {40716, 51},     /* ka */
+       {53595, 145},    /* ka-ge */
+       {41139, 58},     /* kk */
+       {43098, 88},     /* kl */
+       {53601, 175},    /* kl-gl */
+       {42426, 75},     /* km */
+       {53607, 163},    /* km-kh */
+       {37322, 68},     /* kn */
+       {53613, 157},    /* kn-in */
+       {39029, 18},     /* ko */
+       {53619, 112},    /* ko-kr */
+       {42612, 78},     /* kok */
+       {53625, 166},    /* kok-in */
+       {41219, 59},     /* ky */
+       {42514, 76},     /* lo */
+       {53632, 164},    /* lo-la */
+       {40138, 39},     /* lt */
+       {53638, 133},    /* lt-lt */
+       {40090, 38},     /* lv */
+       {53644, 132},    /* lv-lv */
+       {40490, 46},     /* mk */
+       {53650, 140},    /* mk-mk */
+       {42003, 69},     /* ml */
+       {53656, 158},    /* ml-in */
+       {42275, 72},     /* mn */
+       {53662, 272},    /* mn-cyrl */
+       {42182, 71},     /* mr */
+       {53670, 160},    /* mr-in */
+       {41091, 57},     /* ms */
+       {40938, 54},     /* mt */
+       {53676, 148},    /* mt-mt */
+       {39144, 275},    /* nb */
+       {53682, 114},    /* nb-no */
        {1883, 82},      /* ne */
-       {53706, 169},    /* ne-np */
-       {39085, 19},     /* nl */
-       {53712, 189},    /* nl-be */
-       {53718, 113},    /* nl-nl */
-       {48491, 268},    /* nn */
-       {53724, 190},    /* nn-no */
-       {39135, 20},     /* no */
-       {43076, 87},     /* nso */
-       {53730, 174},    /* nso-za */
-       {41691, 65},     /* or */
-       {53737, 154},    /* or-in */
-       {41508, 63},     /* pa */
-       {39165, 21},     /* pl */
-       {53743, 115},    /* pl-pl */
-       {42959, 83},     /* ps */
-       {53749, 170},    /* ps-af */
-       {39214, 22},     /* pt */
-       {53755, 116},    /* pt-br */
-       {53761, 191},    /* pt-pt */
-       {39270, 23},     /* rm */
-       {53767, 117},    /* rm-ch */
-       {39319, 24},     /* ro */
-       {53773, 118},    /* ro-ro */
-       {39367, 25},     /* ru */
-       {53779, 119},    /* ru-ru */
-       {43384, 94},     /* rw */
-       {53785, 180},    /* rw-rw */
-       {43352, 93},     /* sah */
-       {53791, 179},    /* sah-ru */
-       {41002, 55},     /* se */
-       {53798, 203},    /* se-fi */
-       {53804, 149},    /* se-no */
-       {42665, 79},     /* si */
-       {53810, 167},    /* si-lk */
+       {53688, 169},    /* ne-np */
+       {39067, 19},     /* nl */
+       {53694, 189},    /* nl-be */
+       {53700, 113},    /* nl-nl */
+       {48473, 268},    /* nn */
+       {53706, 190},    /* nn-no */
+       {39117, 20},     /* no */
+       {43058, 87},     /* nso */
+       {53712, 174},    /* nso-za */
+       {41673, 65},     /* or */
+       {53719, 154},    /* or-in */
+       {41490, 63},     /* pa */
+       {39147, 21},     /* pl */
+       {53725, 115},    /* pl-pl */
+       {42941, 83},     /* ps */
+       {53731, 170},    /* ps-af */
+       {39196, 22},     /* pt */
+       {53737, 116},    /* pt-br */
+       {53743, 191},    /* pt-pt */
+       {39252, 23},     /* rm */
+       {53749, 117},    /* rm-ch */
+       {39301, 24},     /* ro */
+       {53755, 118},    /* ro-ro */
+       {39349, 25},     /* ru */
+       {53761, 119},    /* ru-ru */
+       {43366, 94},     /* rw */
+       {53767, 180},    /* rw-rw */
+       {43334, 93},     /* sah */
+       {53773, 179},    /* sah-ru */
+       {40984, 55},     /* se */
+       {53780, 203},    /* se-fi */
+       {53786, 149},    /* se-no */
+       {42647, 79},     /* si */
+       {53792, 167},    /* si-lk */
        {12674, 27},     /* sk */
-       {53816, 121},    /* sk-sk */
-       {40005, 36},     /* sl */
-       {53822, 130},    /* sl-si */
-       {39550, 28},     /* sq */
-       {53828, 122},    /* sq-al */
-       {50405, 276},    /* sr */
-       {53834, 264},    /* sr-cyrl */
-       {53842, 226},    /* sr-cyrl-ba */
-       {53853, 245},    /* sr-cyrl-me */
-       {53864, 237},    /* sr-cyrl-rs */
-       {53875, 265},    /* sr-latn */
-       {53883, 222},    /* sr-latn-ba */
-       {53894, 241},    /* sr-latn-me */
-       {53905, 233},    /* sr-latn-rs */
-       {39596, 29},     /* sv */
-       {53916, 192},    /* sv-fi */
-       {53922, 123},    /* sv-se */
-       {41310, 60},     /* sw */
-       {53928, 150},    /* sw-ke */
-       {41724, 66},     /* ta */
-       {53934, 155},    /* ta-in */
-       {41822, 67},     /* te */
-       {53940, 156},    /* te-in */
-       {40211, 40},     /* tg */
-       {53946, 277},    /* tg-cyrl */
-       {53954, 134},    /* tg-cyrl-tj */
-       {39623, 30},     /* th */
-       {53965, 124},    /* th-th */
-       {40595, 47},     /* tn */
-       {53971, 141},    /* tn-za */
+       {53798, 121},    /* sk-sk */
+       {39987, 36},     /* sl */
+       {53804, 130},    /* sl-si */
+       {39532, 28},     /* sq */
+       {53810, 122},    /* sq-al */
+       {50387, 276},    /* sr */
+       {53816, 264},    /* sr-cyrl */
+       {53824, 226},    /* sr-cyrl-ba */
+       {53835, 245},    /* sr-cyrl-me */
+       {53846, 237},    /* sr-cyrl-rs */
+       {53857, 265},    /* sr-latn */
+       {53865, 222},    /* sr-latn-ba */
+       {53876, 241},    /* sr-latn-me */
+       {53887, 233},    /* sr-latn-rs */
+       {39578, 29},     /* sv */
+       {53898, 192},    /* sv-fi */
+       {53904, 123},    /* sv-se */
+       {41292, 60},     /* sw */
+       {53910, 150},    /* sw-ke */
+       {41706, 66},     /* ta */
+       {53916, 155},    /* ta-in */
+       {41804, 67},     /* te */
+       {53922, 156},    /* te-in */
+       {40193, 40},     /* tg */
+       {53928, 277},    /* tg-cyrl */
+       {53936, 134},    /* tg-cyrl-tj */
+       {39605, 30},     /* th */
+       {53947, 124},    /* th-th */
+       {40577, 47},     /* tn */
+       {53953, 141},    /* tn-za */
        {12683, 31},     /* tr */
-       {53977, 125},    /* tr-tr */
-       {42833, 81},     /* tzm */
-       {53983, 279},    /* tzm-latn */
-       {39832, 34},     /* uk */
-       {53992, 128},    /* uk-ua */
-       {39719, 32},     /* ur */
-       {53998, 126},    /* ur-pk */
-       {41360, 61},     /* uz */
-       {54004, 271},    /* uz-cyrl */
-       {54012, 195},    /* uz-cyrl-uz */
-       {54023, 278},    /* uz-latn */
-       {54031, 151},    /* uz-latn-uz */
-       {40295, 42},     /* vi */
-       {54042, 136},    /* vi-vn */
-       {40622, 48},     /* xh */
-       {54048, 142},    /* xh-za */
-       {43043, 86},     /* yo */
-       {54054, 173},    /* yo-ng */
-       {38331, 267},    /* zh */
-       {54060, 3},      /* zh-chs */
-       {54067, 274},    /* zh-cht */
-       {54074, 183},    /* zh-cn */
-       {54080, 4},      /* zh-hans */
-       {54088, 273},    /* zh-hant */
-       {54096, 198},    /* zh-hk */
-       {54102, 212},    /* zh-mo */
-       {54108, 205},    /* zh-sg */
-       {54114, 99},     /* zh-tw */
-       {40648, 49},     /* zu */
-       {54120, 143}     /* zu-za */
+       {53959, 125},    /* tr-tr */
+       {42815, 81},     /* tzm */
+       {53965, 279},    /* tzm-latn */
+       {39814, 34},     /* uk */
+       {53974, 128},    /* uk-ua */
+       {39701, 32},     /* ur */
+       {53980, 126},    /* ur-pk */
+       {41342, 61},     /* uz */
+       {53986, 271},    /* uz-cyrl */
+       {53994, 195},    /* uz-cyrl-uz */
+       {54005, 278},    /* uz-latn */
+       {54013, 151},    /* uz-latn-uz */
+       {40277, 42},     /* vi */
+       {54024, 136},    /* vi-vn */
+       {40604, 48},     /* xh */
+       {54030, 142},    /* xh-za */
+       {43025, 86},     /* yo */
+       {54036, 173},    /* yo-ng */
+       {38313, 267},    /* zh */
+       {54042, 3},      /* zh-chs */
+       {54049, 274},    /* zh-cht */
+       {54056, 183},    /* zh-cn */
+       {54062, 4},      /* zh-hans */
+       {54070, 273},    /* zh-hant */
+       {54078, 198},    /* zh-hk */
+       {54084, 212},    /* zh-mo */
+       {54090, 205},    /* zh-sg */
+       {54096, 99},     /* zh-tw */
+       {40630, 49},     /* zu */
+       {54102, 143}     /* zu-za */
 };
 
 
 static const RegionInfoEntry region_entries [] = {
-       { 224,51849,48888,48888,54126,54147,38034,54194,54198,54226},
-       { 3,47526,54250,54250,54254,54266,37805,54285,54289,54304},
-       { 6,44842,54317,54317,54321,54329,37343,54339,54343,54356},
-       { 7,1820,50162,50162,54370,54378,37586,54395,54399,54413},
-       { 11,51340,49693,49693,54439,54439,37076,51063,54449,54464},
-       { 14,49037,54479,54479,54483,54491,36972,54503,54507,54507},
-       { 12,49070,54512,54512,54516,54516,37076,54526,54530,54530},
-       { 5,45740,40435,40435,54548,54559,37840,54571,54575,54593},
-       { 25,49635,54613,54613,54617,54640,37902,54660,54664,54700},
-       { 23,48840,54720,54720,54724,54735,37878,54760,54764,54781},
-       { 21,48332,39955,39955,54822,54830,36972,54503,54507,54839},
-       { 35,43626,38184,38184,54844,54853,36954,54870,54874,54888},
-       { 17,51961,54914,54914,54918,54926,38044,54941,54945,54960},
-       { 26,52141,54984,54984,54988,54988,38068,42395,54996,55015},
-       { 32,44546,55025,55025,55029,55036,37231,55043,55047,55062},
-       { 29,45228,55078,55078,55082,55090,37446,55107,55111,55128},
-       { 24,51097,55160,55160,55164,55164,37076,55171,55175,55175},
-       { 39,49163,55189,55189,55193,55193,37076,55200,55204,55220},
-       { 223,13632,55236,55236,55240,55252,37238,37238,55259,55271},
-       { 46,51742,55285,55285,55289,55289,37076,55295,55299,55312},
-       { 45,13711,55325,55325,55329,55335,36993,55354,55358,55371},
-       { 51,50941,55390,55390,55394,55394,37076,55403,55407,55422},
-       { 54,49937,55438,55438,55442,55442,37920,55453,55457,55476},
-       { 75,43789,55497,55497,55501,55516,36996,55534,55538,55560},
-       { 94,43879,38486,38486,55575,55583,36972,54503,54507,54507},
-       { 61,43831,55595,55595,55599,55607,37024,55615,55619,55632},
-       { 65,50569,55644,55644,55648,55667,37076,55689,55693,55708},
-       { 4,49697,55724,55724,55728,55736,37905,55751,55755,55770},
-       { 66,51559,55794,55794,55798,55798,37076,55806,55810,55820},
-       { 70,45326,52452,52452,55842,55850,36972,54503,54507,54839},
-       { 67,48892,55856,55856,55860,55866,37882,55873,55877,55892},
-       { 217,43669,38653,38653,55910,55916,36972,54503,54507,54839},
-       { 73,47405,55924,55924,55928,55937,37785,55953,55957,55972},
-       { 77,44009,38700,38700,55998,56006,36972,54503,54507,54839},
-       { 81,46157,56012,56012,56016,56030,37024,55615,55619,56039},
-       { 84,44053,38753,38753,56052,56052,36972,54503,54507,54839},
-       { 242,47062,56059,56059,56063,56078,37729,56095,56099,56122},
-       { 88,46103,56144,56144,56148,56156,0,56187,56191,56205},
-       { 93,47804,56240,56240,56244,56254,37024,55615,55619,56271},
-       { 98,43935,56291,56291,56295,56302,36972,54503,54507,56315},
-       { 99,49503,56324,56324,56328,56328,7920,56338,56342,56361},
-       { 104,48985,56382,56382,56386,56406,37076,56434,56438,56455},
-       { 106,52281,56462,56462,56466,56466,2308,56475,56479,56496},
-       { 108,44745,39468,39468,56515,56523,37340,56532,56536,56550},
-       { 109,44154,38865,38865,56564,56572,37149,56586,56590,56607},
-       { 111,45091,56621,56621,56625,56625,37422,56635,56639,56657},
-       { 68,48685,56674,56674,56678,56686,36972,54503,54507,54507},
-       { 117,44102,56692,56692,56696,56703,37122,56714,56718,56737},
-       { 113,46211,39805,39805,56744,56750,37665,56763,56767,56780},
-       { 121,48094,56815,56815,56819,56824,37851,56837,56841,56853},
-       { 116,45551,56875,56875,56879,56884,37540,56895,56899,56912},
-       { 110,44203,38912,38912,56932,56940,37024,56948,56952,56969},
-       { 118,44246,38960,38960,56985,56991,36972,54503,54507,54507},
-       { 124,50717,56998,56998,57002,57002,37076,57010,57014,57014},
-       { 126,51243,57030,57030,57034,57041,38004,57054,57058,57074},
-       { 122,44291,39012,39012,57096,57102,37162,57109,57113,57126},
-       { 129,46347,57136,57136,57140,57140,37689,57146,57150,57166},
-       { 40,47128,42469,42469,57184,57193,37732,57215,57219,57234},
-       { 134,44346,39067,39067,57266,57278,37166,57291,57295,57312},
-       { 136,51664,57329,57329,57333,57340,38024,57353,57357,57371},
-       { 138,47170,42549,42549,57393,42539,37736,57398,57402,57414},
-       { 139,51477,57434,57434,57438,57446,38014,57457,57461,57476},
-       { 145,49846,57498,57498,57502,57502,0,37238,55259,57516},
-       { 42,47346,57534,57534,57538,57548,37777,57580,57584,57601},
-       { 141,45424,57649,57649,57653,57663,37516,57671,57675,57692},
-       { 147,49422,57707,57707,57711,57722,36972,54503,54507,54507},
-       { 140,45372,57732,57732,57736,57743,36972,54503,54507,57751},
-       { 148,49305,57756,57756,57760,57766,37892,57777,57781,57794},
-       { 159,50166,42227,42227,57814,57822,37924,57835,57839,57855},
-       { 158,50291,57875,57875,57879,57879,36972,54503,54507,54839},
-       { 270,51419,57886,57886,57890,57901,36972,54503,54507,57919},
-       { 19618,45856,57924,57924,57928,57938,37611,57924,57959,57976},
-       { 151,49786,58008,58008,58012,58028,37915,58056,58060,58076},
-       { 163,46250,40973,40973,58086,58086,36972,54503,54507,58092},
-       { 166,48281,58097,58097,58101,58108,37076,58116,58120,58133},
-       { 175,47634,58147,58147,58151,58159,37812,58168,58172,58187},
-       { 182,52335,58193,58193,58197,58197,38071,58207,58211,58231},
-       { 176,44398,39105,39105,58254,58266,36972,54503,54507,54507},
-       { 177,44456,39154,39154,58276,58283,37024,58289,58293,58309},
-       { 178,47466,58323,58323,58327,58333,37792,58349,58353,58368},
-       { 183,49881,58409,58409,58413,58413,37076,58425,58429,58429},
-       { 164,50686,58448,58448,58452,58457,37953,58468,58472,58483},
-       { 192,50243,41538,41538,58503,58510,37934,58518,58522,58540},
-       { 187,51142,58557,58557,58561,58566,37992,58572,58576,58595},
-       { 201,47580,58613,58613,58617,58629,37808,58639,58643,58643},
-       { 190,45030,58659,58659,58663,58672,37364,58687,58691,58707},
-       { 191,44497,58735,58735,58739,58746,37189,58753,58757,58770},
-       { 202,52393,58784,58784,58788,58788,37076,55806,55810,55820},
-       { 193,48548,58800,58800,58804,58804,36972,54503,54507,54507},
-       { 185,52013,58813,58813,58817,58817,38054,58826,58830,58849},
-       { 197,52065,58868,58868,58872,58878,38058,58885,58889,58901},
-       { 200,44641,58919,58919,58923,58931,0,58940,58944,58957},
-       { 271,51011,52815,52815,58971,58978,37977,58991,58995,59009},
-       { 203,44697,39393,39393,59022,59029,37260,59042,59046,59060},
-       { 204,47962,59092,59092,59096,59096,37816,59103,59107,0},
-       { 205,13629,59121,59121,59125,59138,36896,59185,59189,59201},
-       { 221,44886,59221,59221,59225,59232,37024,59240,59244,59258},
-       { 215,49369,59271,59271,59275,59285,37076,59295,59299,59316},
-       { 212,45284,59329,59329,59333,59342,36972,54503,54507,59352},
-       { 143,44796,59357,59357,59361,59370,36972,54503,54507,54507},
-       { 72,52199,40032,40032,59380,59380,37076,55806,55810,55820},
-       { 222,51067,59392,59392,59396,59402,37982,59413,59417,59430},
-       { 227,44933,39641,39641,59450,39631,37356,59459,59463,59473},
-       { 228,45503,59492,59492,59496,59507,37833,59528,59532,59551},
-       { 234,50461,59564,59564,59568,59576,37938,59585,59589,59604},
-       { 235,44979,59625,59625,59629,59636,37360,59645,59649,59662},
-       { 225,51286,59676,59676,59680,59680,37076,59700,59704,59704},
-       { 237,43720,59731,59731,59735,59742,37819,59749,59753,59771},
-       { 241,45158,39866,39866,59781,59789,37425,59804,59808,59826},
-       { 244,43968,59860,59860,59864,59864,37076,55806,55810,55810},
-       { 246,51899,59878,59878,59882,59882,37076,59890,59894,59909},
-       { 247,46413,41380,41380,59923,59934,37845,59947,59951,59966},
-       { 249,50771,59985,59985,59989,59989,37963,59999,60003,60023},
-       { 251,45609,60043,60043,60047,60055,37582,60066,60070,60086},
-       { 261,50889,60105,60105,60109,60115,37967,60126,60130,60142},
-       { 209,45887,60160,60160,60164,0,10586,60177,60181,0},
-       { 264,51509,60200,60200,60204,60204,37076,55806,55810,55810}
+       { 224,51831,48870,48870,54108,54129,38016,54176,54180,54208},
+       { 3,47508,54232,54232,54236,54248,37787,54267,54271,54286},
+       { 6,44824,54299,54299,54303,54311,37325,54321,54325,54338},
+       { 7,1820,50144,50144,54352,54360,37568,54377,54381,54395},
+       { 11,51322,49675,49675,54421,54421,37076,51045,54431,54446},
+       { 14,49019,54461,54461,54465,54473,36972,54485,54489,54489},
+       { 12,49052,54494,54494,54498,54498,37076,54508,54512,54512},
+       { 5,45722,40417,40417,54530,54541,37822,54553,54557,54575},
+       { 25,49617,54595,54595,54599,54622,37884,54642,54646,54682},
+       { 23,48822,54702,54702,54706,54717,37860,54742,54746,54763},
+       { 21,48314,39937,39937,54804,54812,36972,54485,54489,54821},
+       { 35,43608,38166,38166,54826,54835,36954,54852,54856,54870},
+       { 17,51943,54896,54896,54900,54908,38026,54923,54927,54942},
+       { 26,52123,54966,54966,54970,54970,38050,42377,54978,54997},
+       { 32,44528,55007,55007,55011,55018,37213,55025,55029,55044},
+       { 29,45210,55060,55060,55064,55072,37428,55089,55093,55110},
+       { 24,51079,55142,55142,55146,55146,37076,55153,55157,55157},
+       { 39,49145,55171,55171,55175,55175,37076,55182,55186,55202},
+       { 223,13632,55218,55218,55222,55234,37220,37220,55241,55253},
+       { 46,51724,55267,55267,55271,55271,37076,55277,55281,55294},
+       { 45,13711,55307,55307,55311,55317,36993,55336,55340,55353},
+       { 51,50923,55372,55372,55376,55376,37076,55385,55389,55404},
+       { 54,49919,55420,55420,55424,55424,37902,55435,55439,55458},
+       { 75,43771,55479,55479,55483,55498,36996,55516,55520,55542},
+       { 94,43861,38468,38468,55557,55565,36972,54485,54489,54489},
+       { 61,43813,55577,55577,55581,55589,37024,55597,55601,55614},
+       { 65,50551,55626,55626,55630,55649,37076,55671,55675,55690},
+       { 4,49679,55706,55706,55710,55718,37887,55733,55737,55752},
+       { 66,51541,55776,55776,55780,55780,37076,55788,55792,55802},
+       { 70,45308,52434,52434,55824,55832,36972,54485,54489,54821},
+       { 67,48874,55838,55838,55842,55848,37864,55855,55859,55874},
+       { 217,43651,38635,38635,55892,55898,36972,54485,54489,54821},
+       { 73,47387,55906,55906,55910,55919,37767,55935,55939,55954},
+       { 77,43991,38682,38682,55980,55988,36972,54485,54489,54821},
+       { 81,46139,55994,55994,55998,56012,37024,55597,55601,56021},
+       { 84,44035,38735,38735,56034,56034,36972,54485,54489,54821},
+       { 242,47044,56041,56041,56045,56060,37711,56077,56081,56104},
+       { 88,46085,56126,56126,56130,56138,0,56169,56173,56187},
+       { 93,47786,56222,56222,56226,56236,37024,55597,55601,56253},
+       { 98,43917,56273,56273,56277,56284,36972,54485,54489,56297},
+       { 99,49485,56306,56306,56310,56310,7920,56320,56324,56343},
+       { 104,48967,56364,56364,56368,56388,37076,56416,56420,56437},
+       { 106,52263,56444,56444,56448,56448,2308,56457,56461,56478},
+       { 108,44727,39450,39450,56497,56505,37322,56514,56518,56532},
+       { 109,44136,38847,38847,56546,56554,37131,56568,56572,56589},
+       { 111,45073,56603,56603,56607,56607,37404,56617,56621,56639},
+       { 68,48667,56656,56656,56660,56668,36972,54485,54489,54489},
+       { 117,44084,56674,56674,56678,56685,37122,56696,56700,56719},
+       { 113,46193,39787,39787,56726,56732,37647,56745,56749,56762},
+       { 121,48076,56797,56797,56801,56806,37833,56819,56823,56835},
+       { 116,45533,56857,56857,56861,56866,37522,56877,56881,56894},
+       { 110,44185,38894,38894,56914,56922,37024,56930,56934,56951},
+       { 118,44228,38942,38942,56967,56973,36972,54485,54489,54489},
+       { 124,50699,56980,56980,56984,56984,37076,56992,56996,56996},
+       { 126,51225,57012,57012,57016,57023,37986,57036,57040,57056},
+       { 122,44273,38994,38994,57078,57084,37144,57091,57095,57108},
+       { 129,46329,57118,57118,57122,57122,37671,57128,57132,57148},
+       { 40,47110,42451,42451,57166,57175,37714,57197,57201,57216},
+       { 134,44328,39049,39049,57248,57260,37148,57273,57277,57294},
+       { 136,51646,57311,57311,57315,57322,38006,57335,57339,57353},
+       { 138,47152,42531,42531,57375,42521,37718,57380,57384,57396},
+       { 139,51459,57416,57416,57420,57428,37996,57439,57443,57458},
+       { 145,49828,57480,57480,57484,57484,0,37220,55241,57498},
+       { 42,47328,57516,57516,57520,57530,37759,57562,57566,57583},
+       { 141,45406,57631,57631,57635,57645,37498,57653,57657,57674},
+       { 147,49404,57689,57689,57693,57704,36972,54485,54489,54489},
+       { 140,45354,57714,57714,57718,57725,36972,54485,54489,57733},
+       { 148,49287,57738,57738,57742,57748,37874,57759,57763,57776},
+       { 159,50148,42209,42209,57796,57804,37906,57817,57821,57837},
+       { 158,50273,57857,57857,57861,57861,36972,54485,54489,54821},
+       { 270,51401,57868,57868,57872,57883,36972,54485,54489,57901},
+       { 19618,45838,57906,57906,57910,57920,37593,57906,57941,57958},
+       { 151,49768,57990,57990,57994,58010,37897,58038,58042,58058},
+       { 163,46232,40955,40955,58068,58068,36972,54485,54489,58074},
+       { 166,48263,58079,58079,58083,58090,37076,58098,58102,58115},
+       { 175,47616,58129,58129,58133,58141,37794,58150,58154,58169},
+       { 182,52317,58175,58175,58179,58179,38053,58189,58193,58213},
+       { 176,44380,39087,39087,58236,58248,36972,54485,54489,54489},
+       { 177,44438,39136,39136,58258,58265,37024,58271,58275,58291},
+       { 178,47448,58305,58305,58309,58315,37774,58331,58335,58350},
+       { 183,49863,58391,58391,58395,58395,37076,58407,58411,58411},
+       { 164,50668,58430,58430,58434,58439,37935,58450,58454,58465},
+       { 192,50225,41520,41520,58485,58492,37916,58500,58504,58522},
+       { 187,51124,58539,58539,58543,58548,37974,58554,58558,58577},
+       { 201,47562,58595,58595,58599,58611,37790,58621,58625,58625},
+       { 190,45012,58641,58641,58645,58654,37346,58669,58673,58689},
+       { 191,44479,58717,58717,58721,58728,37171,58735,58739,58752},
+       { 202,52375,58766,58766,58770,58770,37076,55788,55792,55802},
+       { 193,48530,58782,58782,58786,58786,36972,54485,54489,54489},
+       { 185,51995,58795,58795,58799,58799,38036,58808,58812,58831},
+       { 197,52047,58850,58850,58854,58860,38040,58867,58871,58883},
+       { 200,44623,58901,58901,58905,58913,0,58922,58926,58939},
+       { 271,50993,52797,52797,58953,58960,37959,58973,58977,58991},
+       { 203,44679,39375,39375,59004,59011,37242,59024,59028,59042},
+       { 204,47944,59074,59074,59078,59078,37798,59085,59089,0},
+       { 205,13629,59103,59103,59107,59120,36896,59167,59171,59183},
+       { 221,44868,59203,59203,59207,59214,37024,59222,59226,59240},
+       { 215,49351,59253,59253,59257,59267,37076,59277,59281,59298},
+       { 212,45266,59311,59311,59315,59324,36972,54485,54489,59334},
+       { 143,44778,59339,59339,59343,59352,36972,54485,54489,54489},
+       { 72,52181,40014,40014,59362,59362,37076,55788,55792,55802},
+       { 222,51049,59374,59374,59378,59384,37964,59395,59399,59412},
+       { 227,44915,39623,39623,59432,39613,37338,59441,59445,59455},
+       { 228,45485,59474,59474,59478,59489,37815,59510,59514,59533},
+       { 234,50443,59546,59546,59550,59558,37920,59567,59571,59586},
+       { 235,44961,59607,59607,59611,59618,37342,59627,59631,59644},
+       { 225,51268,59658,59658,59662,59662,37076,59682,59686,59686},
+       { 237,43702,59713,59713,59717,59724,37801,59731,59735,59753},
+       { 241,45140,39848,39848,59763,59771,37407,59786,59790,59808},
+       { 244,43950,59842,59842,59846,59846,37076,55788,55792,55792},
+       { 246,51881,59860,59860,59864,59864,37076,59872,59876,59891},
+       { 247,46395,41362,41362,59905,59916,37827,59929,59933,59948},
+       { 249,50753,59967,59967,59971,59971,37945,59981,59985,60005},
+       { 251,45591,60025,60025,60029,60037,37564,60048,60052,60068},
+       { 261,50871,60087,60087,60091,60097,37949,60108,60112,60124},
+       { 209,45869,60142,60142,60146,0,10586,60159,60163,0},
+       { 264,51491,60182,60182,60186,60186,37076,55788,55792,55792}
 };
 
 
 static const RegionInfoNameEntry region_name_entries [] = {
-       {51849, 0},      /* AE */
-       {47526, 1},      /* AF */
-       {44842, 2},      /* AL */
+       {51831, 0},      /* AE */
+       {47508, 1},      /* AF */
+       {44824, 2},      /* AL */
        {1820, 3},       /* AM */
-       {51340, 4},      /* AR */
-       {49037, 5},      /* AT */
-       {49070, 6},      /* AU */
-       {45740, 7},      /* AZ */
-       {49635, 8},      /* BA */
-       {48840, 9},      /* BD */
-       {48332, 10},     /* BE */
-       {43626, 11},     /* BG */
-       {51961, 12},     /* BH */
-       {52141, 13},     /* BO */
-       {44546, 14},     /* BR */
-       {45228, 15},     /* BY */
-       {51097, 16},     /* BZ */
-       {49163, 17},     /* CA */
+       {51322, 4},      /* AR */
+       {49019, 5},      /* AT */
+       {49052, 6},      /* AU */
+       {45722, 7},      /* AZ */
+       {49617, 8},      /* BA */
+       {48822, 9},      /* BD */
+       {48314, 10},     /* BE */
+       {43608, 11},     /* BG */
+       {51943, 12},     /* BH */
+       {52123, 13},     /* BO */
+       {44528, 14},     /* BR */
+       {45210, 15},     /* BY */
+       {51079, 16},     /* BZ */
+       {49145, 17},     /* CA */
        {13632, 18},     /* CH */
-       {51742, 19},     /* CL */
+       {51724, 19},     /* CL */
        {13711, 20},     /* CN */
-       {50941, 21},     /* CO */
-       {49937, 22},     /* CR */
-       {43789, 23},     /* CZ */
-       {43879, 24},     /* DE */
-       {43831, 25},     /* DK */
-       {50569, 26},     /* DO */
-       {49697, 27},     /* DZ */
-       {51559, 28},     /* EC */
-       {45326, 29},     /* EE */
-       {48892, 30},     /* EG */
-       {43669, 31},     /* ES */
-       {47405, 32},     /* ET */
-       {44009, 33},     /* FI */
-       {46157, 34},     /* FO */
-       {44053, 35},     /* FR */
-       {47062, 36},     /* GB */
-       {46103, 37},     /* GE */
-       {47804, 38},     /* GL */
-       {43935, 39},     /* GR */
-       {49503, 40},     /* GT */
-       {48985, 41},     /* HK */
-       {52281, 42},     /* HN */
-       {44745, 43},     /* HR */
-       {44154, 44},     /* HU */
-       {45091, 45},     /* ID */
-       {48685, 46},     /* IE */
-       {44102, 47},     /* IL */
-       {46211, 48},     /* IN */
-       {48094, 49},     /* IQ */
-       {45551, 50},     /* IR */
-       {44203, 51},     /* IS */
-       {44246, 52},     /* IT */
-       {50717, 53},     /* JM */
-       {51243, 54},     /* JO */
-       {44291, 55},     /* JP */
-       {46347, 56},     /* KE */
-       {47128, 57},     /* KH */
-       {44346, 58},     /* KR */
-       {51664, 59},     /* KW */
-       {47170, 60},     /* LA */
-       {51477, 61},     /* LB */
-       {49846, 62},     /* LI */
-       {47346, 63},     /* LK */
-       {45424, 64},     /* LT */
-       {49422, 65},     /* LU */
-       {45372, 66},     /* LV */
-       {49305, 67},     /* LY */
-       {50166, 68},     /* MA */
-       {50291, 69},     /* MC */
-       {51419, 70},     /* ME */
-       {45856, 71},     /* MK */
-       {49786, 72},     /* MO */
-       {46250, 73},     /* MT */
-       {48281, 74},     /* MX */
-       {47634, 75},     /* NG */
-       {52335, 76},     /* NI */
-       {44398, 77},     /* NL */
-       {44456, 78},     /* NO */
-       {47466, 79},     /* NP */
-       {49881, 80},     /* NZ */
-       {50686, 81},     /* OM */
-       {50243, 82},     /* PA */
-       {51142, 83},     /* PE */
-       {47580, 84},     /* PH */
-       {45030, 85},     /* PK */
-       {44497, 86},     /* PL */
-       {52393, 87},     /* PR */
-       {48548, 88},     /* PT */
-       {52013, 89},     /* PY */
-       {52065, 90},     /* QA */
-       {44641, 91},     /* RO */
-       {51011, 92},     /* RS */
-       {44697, 93},     /* RU */
-       {47962, 94},     /* RW */
+       {50923, 21},     /* CO */
+       {49919, 22},     /* CR */
+       {43771, 23},     /* CZ */
+       {43861, 24},     /* DE */
+       {43813, 25},     /* DK */
+       {50551, 26},     /* DO */
+       {49679, 27},     /* DZ */
+       {51541, 28},     /* EC */
+       {45308, 29},     /* EE */
+       {48874, 30},     /* EG */
+       {43651, 31},     /* ES */
+       {47387, 32},     /* ET */
+       {43991, 33},     /* FI */
+       {46139, 34},     /* FO */
+       {44035, 35},     /* FR */
+       {47044, 36},     /* GB */
+       {46085, 37},     /* GE */
+       {47786, 38},     /* GL */
+       {43917, 39},     /* GR */
+       {49485, 40},     /* GT */
+       {48967, 41},     /* HK */
+       {52263, 42},     /* HN */
+       {44727, 43},     /* HR */
+       {44136, 44},     /* HU */
+       {45073, 45},     /* ID */
+       {48667, 46},     /* IE */
+       {44084, 47},     /* IL */
+       {46193, 48},     /* IN */
+       {48076, 49},     /* IQ */
+       {45533, 50},     /* IR */
+       {44185, 51},     /* IS */
+       {44228, 52},     /* IT */
+       {50699, 53},     /* JM */
+       {51225, 54},     /* JO */
+       {44273, 55},     /* JP */
+       {46329, 56},     /* KE */
+       {47110, 57},     /* KH */
+       {44328, 58},     /* KR */
+       {51646, 59},     /* KW */
+       {47152, 60},     /* LA */
+       {51459, 61},     /* LB */
+       {49828, 62},     /* LI */
+       {47328, 63},     /* LK */
+       {45406, 64},     /* LT */
+       {49404, 65},     /* LU */
+       {45354, 66},     /* LV */
+       {49287, 67},     /* LY */
+       {50148, 68},     /* MA */
+       {50273, 69},     /* MC */
+       {51401, 70},     /* ME */
+       {45838, 71},     /* MK */
+       {49768, 72},     /* MO */
+       {46232, 73},     /* MT */
+       {48263, 74},     /* MX */
+       {47616, 75},     /* NG */
+       {52317, 76},     /* NI */
+       {44380, 77},     /* NL */
+       {44438, 78},     /* NO */
+       {47448, 79},     /* NP */
+       {49863, 80},     /* NZ */
+       {50668, 81},     /* OM */
+       {50225, 82},     /* PA */
+       {51124, 83},     /* PE */
+       {47562, 84},     /* PH */
+       {45012, 85},     /* PK */
+       {44479, 86},     /* PL */
+       {52375, 87},     /* PR */
+       {48530, 88},     /* PT */
+       {51995, 89},     /* PY */
+       {52047, 90},     /* QA */
+       {44623, 91},     /* RO */
+       {50993, 92},     /* RS */
+       {44679, 93},     /* RU */
+       {47944, 94},     /* RW */
        {13629, 95},     /* SA */
-       {44886, 96},     /* SE */
-       {49369, 97},     /* SG */
-       {45284, 98},     /* SI */
-       {44796, 99},     /* SK */
-       {52199, 100},    /* SV */
-       {51067, 101},    /* SY */
-       {44933, 102},    /* TH */
-       {45503, 103},    /* TJ */
-       {50461, 104},    /* TN */
-       {44979, 105},    /* TR */
-       {51286, 106},    /* TT */
-       {43720, 107},    /* TW */
-       {45158, 108},    /* UA */
-       {43968, 109},    /* US */
-       {51899, 110},    /* UY */
-       {46413, 111},    /* UZ */
-       {50771, 112},    /* VE */
-       {45609, 113},    /* VN */
-       {50889, 114},    /* YE */
-       {45887, 115},    /* ZA */
-       {51509, 116}     /* ZW */
+       {44868, 96},     /* SE */
+       {49351, 97},     /* SG */
+       {45266, 98},     /* SI */
+       {44778, 99},     /* SK */
+       {52181, 100},    /* SV */
+       {51049, 101},    /* SY */
+       {44915, 102},    /* TH */
+       {45485, 103},    /* TJ */
+       {50443, 104},    /* TN */
+       {44961, 105},    /* TR */
+       {51268, 106},    /* TT */
+       {43702, 107},    /* TW */
+       {45140, 108},    /* UA */
+       {43950, 109},    /* US */
+       {51881, 110},    /* UY */
+       {46395, 111},    /* UZ */
+       {50753, 112},    /* VE */
+       {45591, 113},    /* VN */
+       {50871, 114},    /* YE */
+       {45869, 115},    /* ZA */
+       {51491, 116}     /* ZW */
 };
 
 
@@ -5047,8 +5047,6 @@ static const char locale_strings [] = {
        "-Infini\0"
        "+Infini\0"
        "\xe2\x82\xaa\0"
-       "\xe2\x80\x8e-Infinity\0"
-       "\xe2\x80\x8e-\0"
        "\xe2\x80\x8e+\0"
        "Ft\0"
        "+Infinito\0"
index 35b81fc96ced36802632607b52b7730ae58a9b54..db4b765fbde68816b4ee47b3a02c32c2457121f8 100644 (file)
@@ -775,7 +775,7 @@ mono_field_full_name (MonoClassField *field)
 }
 
 char *
-mono_method_get_name_full (MonoMethod *method, gboolean signature, MonoTypeNameFormat format)
+mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, MonoTypeNameFormat format)
 {
        char *res;
        char wrapper [64];
@@ -831,8 +831,15 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, MonoTypeNameF
                        sprintf (wrapper, "(wrapper %s) ", wrapper_type_to_str (method->wrapper_type));
                else
                        strcpy (wrapper, "");
-               res = g_strdup_printf ("%s%s:%s%s (%s)", wrapper, klass_desc, 
-                                                          method->name, inst_desc ? inst_desc : "", tmpsig);
+               if (ret) {
+                       char *ret_str = mono_type_full_name (mono_method_signature (method)->ret);
+                       res = g_strdup_printf ("%s%s %s:%s%s (%s)", wrapper, ret_str, klass_desc,
+                                                                  method->name, inst_desc ? inst_desc : "", tmpsig);
+                       g_free (ret_str);
+               } else {
+                       res = g_strdup_printf ("%s%s:%s%s (%s)", wrapper, klass_desc,
+                                                                  method->name, inst_desc ? inst_desc : "", tmpsig);
+               }
                g_free (tmpsig);
        } else {
                res = g_strdup_printf ("%s%s:%s%s", wrapper, klass_desc,
@@ -848,7 +855,13 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, MonoTypeNameF
 char *
 mono_method_full_name (MonoMethod *method, gboolean signature)
 {
-       return mono_method_get_name_full (method, signature, MONO_TYPE_NAME_FORMAT_IL);
+       return mono_method_get_name_full (method, signature, FALSE, MONO_TYPE_NAME_FORMAT_IL);
+}
+
+char *
+mono_method_get_full_name (MonoMethod *method)
+{
+       return mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL);
 }
 
 static const char*
index 4cb4af6c02d1aca82dfca8f81fd08e5c0a867688..04eec95154a6152d5d40b182f835430e147edcc3 100644 (file)
@@ -60,6 +60,7 @@ struct _MonoJitInfoTableChunk
        int                    refcount;
        volatile int           num_elements;
        volatile gint8        *last_code_end;
+       MonoJitInfo *next_tombstone;
        MonoJitInfo * volatile data [MONO_JIT_INFO_TABLE_CHUNK_SIZE];
 };
 
@@ -201,7 +202,10 @@ struct _MonoJitInfo {
                gpointer aot_info;
                gpointer tramp_info;
        } d;
-       struct _MonoJitInfo *next_jit_code_hash;
+       union {
+               struct _MonoJitInfo *next_jit_code_hash;
+               struct _MonoJitInfo *next_tombstone;
+       } n;
        gpointer    code_start;
        guint32     unwind_info;
        int         code_size;
@@ -412,6 +416,9 @@ struct _MonoDomain {
        /* Maps MonoMethod* to weak links to DynamicMethod objects */
        GHashTable *method_to_dyn_method;
 
+       /* <ThrowUnobservedTaskExceptions /> support */
+       gboolean throw_unobserved_task_exceptions;
+
        guint32 execution_context_field_offset;
 };
 
@@ -490,7 +497,7 @@ void
 mono_jit_info_set_generic_sharing_context (MonoJitInfo *ji, MonoGenericSharingContext *gsctx);
 
 char *
-mono_make_shadow_copy (const char *filename);
+mono_make_shadow_copy (const char *filename, MonoError *error);
 
 gboolean
 mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name);
@@ -637,6 +644,9 @@ ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad);
 MonoString *
 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid);
 
+MonoBoolean
+ves_icall_System_CLRConfig_CheckThrowUnobservedTaskExceptions (void);
+
 MonoAssembly *
 mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status);
 
@@ -670,7 +680,7 @@ MonoAssembly* mono_assembly_load_full_nosearch (MonoAssemblyName *aname,
                                                MonoImageOpenStatus *status,
                                                gboolean refonly);
 
-void mono_set_private_bin_path_from_config (MonoDomain *domain);
+void mono_domain_set_options_from_config (MonoDomain *domain);
 
 int mono_framework_version (void);
 
index bc9edcbe3ad1a1fb289d37dd8adc04e5fd2cb0e3..25cb5014e69bb29ee1ccc1f09c3ffb10dc9dae1c 100644 (file)
@@ -153,6 +153,7 @@ void* mono_gc_alloc_obj (MonoVTable *vtable, size_t size);
 void* mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length);
 void* mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uintptr_t bounds_size);
 void* mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len);
+void* mono_gc_alloc_mature (MonoVTable *vtable, size_t size);
 MonoGCDescriptor mono_gc_make_descr_for_string (gsize *bitmap, int numbits);
 
 void  mono_gc_register_for_finalization (MonoObject *obj, void *user_data);
@@ -162,7 +163,7 @@ void  mono_gc_deregister_root (char* addr);
 int   mono_gc_finalizers_for_domain (MonoDomain *domain, MonoObject **out_array, int out_size);
 void  mono_gc_run_finalize (void *obj, void *data);
 void  mono_gc_clear_domain (MonoDomain * domain);
-void* mono_gc_alloc_mature (MonoVTable *vtable);
+
 
 /* 
  * Register a root which can only be written using a write barrier.
index 901a985a587039274d535a496d934e75c58df240..7f85c3a0e04b33dee00a398c595a7e1510d138fe 100644 (file)
@@ -914,15 +914,6 @@ mono_gc_get_mach_exception_thread (void)
 }
 #endif
 
-#ifndef HAVE_SGEN_GC
-void*
-mono_gc_alloc_mature (MonoVTable *vtable)
-{
-       return mono_object_new_specific (vtable);
-}
-#endif
-
-
 static MonoReferenceQueue *ref_queues;
 
 static void
diff --git a/mono/metadata/handle-private.h b/mono/metadata/handle-private.h
deleted file mode 100644 (file)
index de52a33..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef __MONO_HANDLE_PRIVATE_H__
-#define __MONO_HANDLE_PRIVATE_H__
-
-#include <mono/metadata/handle.h>
-
-MonoHandle
-mono_handle_arena_new (MonoHandleArena *arena, MonoObject *obj);
-
-MonoHandle
-mono_handle_arena_elevate (MonoHandleArena *arena, MonoHandle handle);
-
-void
-mono_handle_arena_stack_push (MonoHandleArena **arena_stack, MonoHandleArena *arena, gsize nb_handles);
-
-void
-mono_handle_arena_stack_pop (MonoHandleArena **arena_stack, MonoHandleArena *arena, gsize nb_handles);
-
-void
-mono_handle_arena_initialize (MonoHandleArena **arena_stack);
-
-void
-mono_handle_arena_deinitialize (MonoHandleArena **arena_stack);
-
-#endif/*__MONO_HANDLE_PRIVATE_H__*/
index 10c573a1a7096ed3e3e02e2cc3ada15537e77b32..2fe167a9fe793a3d98cb503b5c93e9e180776196 100644 (file)
 #include <glib.h>
 
 #include <mono/metadata/handle.h>
-#include <mono/metadata/handle-private.h>
 #include <mono/metadata/object-internals.h>
 #include <mono/metadata/gc-internals.h>
 #include <mono/utils/atomic.h>
 #include <mono/utils/mono-lazy-init.h>
+#include <mono/utils/mono-threads.h>
 
-#define HANDLES_PER_CHUNK (16 - 3)
+#define HANDLES_PER_CHUNK (16 - 2)
 
 typedef struct _MonoHandleArenaChunk MonoHandleArenaChunk;
 struct _MonoHandleArenaChunk {
        MonoHandleArenaChunk *next;
-       gsize handles_capacity;
        gsize handles_size;
-       MonoHandleStorage handles [MONO_ZERO_LEN_ARRAY];
+       MonoHandleStorage handles [HANDLES_PER_CHUNK];
 };
 
 struct _MonoHandleArena {
@@ -35,9 +34,7 @@ struct _MonoHandleArena {
 
 static mono_lazy_init_t arena_status = MONO_LAZY_INIT_STATUS_NOT_INITIALIZED;
 
-#ifdef HAVE_SGEN_GC
 static MonoGCDescriptor arena_desc = MONO_GC_DESCRIPTOR_NULL;
-#endif
 
 static MonoHandleArenaChunk *chunk_free_list = NULL;
 
@@ -51,8 +48,8 @@ chunk_alloc (void)
                if (!old) {
                        MonoHandleArenaChunk *chunk;
 
-                       chunk = g_malloc0 (sizeof (MonoHandleArenaChunk) + sizeof (MonoHandleStorage) * (HANDLES_PER_CHUNK - MONO_ZERO_LEN_ARRAY));
-                       chunk->handles_capacity = HANDLES_PER_CHUNK;
+                       chunk = g_malloc0 (sizeof (MonoHandleArenaChunk));
+                       g_assert (chunk);
 
                        return chunk;
                }
@@ -82,8 +79,8 @@ handle_new (MonoHandleArena *arena, MonoObject *obj)
 
        chunk = arena->chunk_last;
 
-       if (chunk->handles_size < chunk->handles_capacity) {
-               chunk->handles [chunk->handles_size].obj = obj;
+       if (chunk->handles_size < HANDLES_PER_CHUNK) {
+               chunk->handles [chunk->handles_size].__private_obj = obj;
                chunk->handles_size += 1;
 
                return &chunk->handles [chunk->handles_size - 1];
@@ -91,7 +88,7 @@ handle_new (MonoHandleArena *arena, MonoObject *obj)
 
        chunk = chunk->next = chunk_alloc ();
 
-       chunk->handles [0].obj = obj;
+       chunk->handles [0].__private_obj = obj;
        chunk->handles_size = 1;
 
        arena->chunk_last = chunk;
@@ -106,16 +103,6 @@ mono_handle_arena_new (MonoHandleArena *arena, MonoObject *obj)
        return handle_new (arena, obj);
 }
 
-MonoHandle
-mono_handle_new (MonoObject *obj)
-{
-       /* TODO: finish implementation by placing an arena somewhere
-        * in the current thread */
-       g_assert_not_reached ();
-       MonoHandleArena *arena = NULL;
-       return mono_handle_arena_new (arena, obj);
-}
-
 /*
  * Elevate the handle to the parent arena
  */
@@ -126,28 +113,17 @@ mono_handle_arena_elevate (MonoHandleArena *arena, MonoHandle handle)
        g_assert (arena);
        g_assert (arena->prev);
 
-       return handle_new (arena->prev, handle->obj);
-}
-
-MonoHandle
-mono_handle_elevate (MonoHandle handle)
-{
-       /* TODO: finish implementation by placing an arena somewhere
-        * in the current thread */
-       g_assert_not_reached ();
-       MonoHandleArena *arena = NULL;
-       return mono_handle_arena_elevate (arena, handle);
+       return handle_new (arena->prev, handle->__private_obj);
 }
 
 gsize
-mono_handle_arena_size (gsize nb_handles)
+mono_handle_arena_size (void)
 {
-       g_assert (nb_handles > 0);
-       return sizeof (MonoHandleArena) + sizeof (MonoHandleArenaChunk) + sizeof (MonoHandle) * (MAX (nb_handles, HANDLES_PER_CHUNK) - MONO_ZERO_LEN_ARRAY);
+       return sizeof (MonoHandleArena) + sizeof (MonoHandleArenaChunk);
 }
 
 void
-mono_handle_arena_stack_push(MonoHandleArena **arena_stack, MonoHandleArena *arena, gsize nb_handles)
+mono_handle_arena_stack_push(MonoHandleArena **arena_stack, MonoHandleArena *arena)
 {
        g_assert (arena_stack);
        g_assert (arena);
@@ -156,15 +132,14 @@ mono_handle_arena_stack_push(MonoHandleArena **arena_stack, MonoHandleArena *are
        arena->chunk = arena->chunk_last = (MonoHandleArenaChunk*) (((char*) arena) + sizeof (MonoHandleArena));
 
        arena->chunk->next = NULL;
-       arena->chunk->handles_capacity = MAX (nb_handles, HANDLES_PER_CHUNK);
        arena->chunk->handles_size = 0;
-       memset (&arena->chunk->handles [0], 0, sizeof (MonoHandle) * arena->chunk->handles_capacity);
+       memset (&arena->chunk->handles [0], 0, sizeof (MonoHandleStorage) * HANDLES_PER_CHUNK);
 
        *arena_stack = arena;
 }
 
 void
-mono_handle_arena_stack_pop(MonoHandleArena **arena_stack, MonoHandleArena *arena, gsize nb_handles)
+mono_handle_arena_stack_pop(MonoHandleArena **arena_stack, MonoHandleArena *arena)
 {
        MonoHandleArenaChunk *chunk, *next;
 
@@ -177,7 +152,7 @@ mono_handle_arena_stack_pop(MonoHandleArena **arena_stack, MonoHandleArena *aren
 
        for (chunk = arena->chunk; chunk; chunk = next) {
                next = chunk->next;
-               memset (&chunk->handles [0], 0, sizeof (MonoHandle) * chunk->handles_capacity);
+               memset (&chunk->handles [0], 0, sizeof (MonoHandleStorage) * HANDLES_PER_CHUNK);
                if (chunk != arena->chunk)
                        chunk_free (chunk);
        }
@@ -193,8 +168,8 @@ arena_scan (gpointer addr, MonoGCMarkFunc mark_func, gpointer gc_data)
        for (arena = *(MonoHandleArena**) addr; arena; arena = arena->prev) {
                for (chunk = arena->chunk; chunk; chunk = chunk->next) {
                        for (i = 0; i < chunk->handles_size; ++i) {
-                               if (chunk->handles [i].obj != NULL)
-                                       mark_func (&chunk->handles [i].obj, gc_data);
+                               if (chunk->handles [i].__private_obj != NULL)
+                                       mark_func (&chunk->handles [i].__private_obj, gc_data);
                        }
                }
        }
@@ -203,25 +178,30 @@ arena_scan (gpointer addr, MonoGCMarkFunc mark_func, gpointer gc_data)
 static void
 initialize (void)
 {
-#ifdef HAVE_SGEN_GC
        arena_desc = mono_gc_make_root_descr_user (arena_scan);
-#endif
 }
 
 void
-mono_handle_arena_initialize (MonoHandleArena **arena_stack)
+mono_handle_arena_init (MonoHandleArena **arena_stack)
 {
-#ifdef HAVE_SGEN_GC
        mono_lazy_initialize (&arena_status, initialize);
        mono_gc_register_root ((char*) arena_stack, sizeof (MonoHandleArena*), arena_desc, MONO_ROOT_SOURCE_HANDLE, "runtime threads handle arena");
-#endif
 }
 
 void
-mono_handle_arena_deinitialize (MonoHandleArena **arena_stack)
+mono_handle_arena_cleanup (MonoHandleArena **arena_stack)
 {
-#ifdef HAVE_SGEN_GC
        mono_gc_deregister_root ((char*) arena_stack);
-#endif
 }
 
+MonoHandleArena*
+mono_handle_arena_current (void)
+{
+       return (MonoHandleArena*) mono_thread_info_current ()->handle_arena;
+}
+
+MonoHandleArena**
+mono_handle_arena_current_addr (void)
+{
+       return (MonoHandleArena**) &mono_thread_info_current ()->handle_arena;
+}
index bf94296791fc6a9b06c82fa25870344919569b70..b933039b0b0ed222b08aaa2df015b7f947e13b04 100644 (file)
 #include <config.h>
 #include <glib.h>
 
-#include "object.h"
-#include "class.h"
-#include "class-internals.h"
-#include "threads-types.h"
-
-#include "mono/utils/mono-threads-coop.h"
+#include <mono/metadata/object.h>
+#include <mono/metadata/class.h>
+#include <mono/utils/mono-error.h>
+#include <mono/utils/checked-build.h>
 
 G_BEGIN_DECLS
 
-typedef struct _MonoHandleStorage MonoHandleStorage;
-typedef MonoHandleStorage* MonoHandle;
-
 /*
  * DO NOT ACCESS DIRECTLY
  * USE mono_handle_obj BELOW TO ACCESS OBJ
@@ -32,47 +27,112 @@ typedef MonoHandleStorage* MonoHandle;
  * The field obj is not private as there is no way to do that
  * in C, but using a C++ template would simplify that a lot
  */
-struct _MonoHandleStorage {
-       MonoObject *obj;
-};
+typedef struct {
+       MonoObject *__private_obj;
+} MonoHandleStorage;
+
+typedef MonoHandleStorage* MonoHandle;
+
+typedef struct _MonoHandleArena MonoHandleArena;
+
+gsize
+mono_handle_arena_size (void);
+
+MonoHandle
+mono_handle_arena_new (MonoHandleArena *arena, MonoObject *obj);
+
+MonoHandle
+mono_handle_arena_elevate (MonoHandleArena *arena, MonoHandle handle);
+
+void
+mono_handle_arena_stack_push (MonoHandleArena **arena_stack, MonoHandleArena *arena);
+
+void
+mono_handle_arena_stack_pop (MonoHandleArena **arena_stack, MonoHandleArena *arena);
+
+void
+mono_handle_arena_init (MonoHandleArena **arena_stack);
+
+void
+mono_handle_arena_cleanup (MonoHandleArena **arena_stack);
+
+MonoHandleArena*
+mono_handle_arena_current (void);
+
+MonoHandleArena**
+mono_handle_arena_current_addr (void);
+
+#define MONO_HANDLE_ARENA_PUSH()       \
+       do {    \
+               MonoHandleArena **__arena_stack = mono_handle_arena_current_addr ();    \
+               MonoHandleArena *__arena = (MonoHandleArena*) g_alloca (mono_handle_arena_size ());     \
+               mono_handle_arena_stack_push (__arena_stack, __arena)
+
+#define MONO_HANDLE_ARENA_POP()        \
+               mono_handle_arena_stack_pop (__arena_stack, __arena);   \
+       } while (0)
+
+#define MONO_HANDLE_ARENA_POP_RETURN_UNSAFE(handle,ret)        \
+               (ret) = (handle)->__private_obj;        \
+               mono_handle_arena_stack_pop (__arena_stack, __arena);   \
+       } while (0)
+
+#define MONO_HANDLE_ARENA_POP_RETURN(handle,ret_handle)        \
+               *((MonoHandle**)(&(ret_handle))) = mono_handle_elevate ((MonoHandle*)(handle)); \
+               mono_handle_arena_stack_pop(__arena_stack, __arena);    \
+       } while (0)
+
+static inline MonoHandle
+mono_handle_new (MonoObject *obj)
+{
+       return mono_handle_arena_new (mono_handle_arena_current (), obj);
+}
+
+static inline MonoHandle
+mono_handle_elevate (MonoHandle handle)
+{
+       return mono_handle_arena_elevate (mono_handle_arena_current (), handle);
+}
 
 #ifndef CHECKED_BUILD
 
-#define mono_handle_obj(handle) ((handle)->obj)
+#define mono_handle_obj(handle) ((handle)->__private_obj)
 
-#define mono_handle_assign(handle,rawptr) do { (handle)->obj = (rawptr); } while(0)
+#define mono_handle_assign(handle,rawptr) do { (handle)->__private_obj = (rawptr); } while(0)
 
 #else
 
 static inline void
 mono_handle_check_in_critical_section ()
 {
-       MONO_REQ_GC_UNSAFE_MODE;
+       MONO_REQ_GC_CRITICAL;
 }
 
-#define mono_handle_obj(handle) (mono_handle_check_in_critical_section (), (handle)->obj)
+#define mono_handle_obj(handle) (mono_handle_check_in_critical_section (), (handle)->__private_obj)
 
-#define mono_handle_assign(handle,rawptr) do { mono_handle_check_in_critical_section (); (handle)->obj = (rawptr); } while (0)
+#define mono_handle_assign(handle,rawptr) do { mono_handle_check_in_critical_section (); (handle)->__private_obj = (rawptr); } while (0)
 
 #endif
 
 static inline MonoClass*
 mono_handle_class (MonoHandle handle)
 {
-       return handle->obj->vtable->klass;
+       return mono_object_get_class (handle->__private_obj);
 }
 
 static inline MonoDomain*
 mono_handle_domain (MonoHandle handle)
 {
-       return handle->obj->vtable->domain;
+       return mono_object_get_domain (handle->__private_obj);
 }
 
-#define MONO_HANDLE_TYPE_DECL(type)      typedef struct { type *obj; } type ## HandleStorage ; \
+#define mono_handle_obj_is_null(handle) ((handle)->__private_obj == NULL)
+
+#define MONO_HANDLE_TYPE_DECL(type)      typedef struct { type *__private_obj; } type ## HandleStorage ; \
        typedef type ## HandleStorage * type ## Handle
 #define MONO_HANDLE_TYPE(type)           type ## Handle
 #define MONO_HANDLE_NEW(type,obj)        ((type ## Handle) mono_handle_new ((MonoObject*) (obj)))
-#define MONO_HANDLE_ELEVATE(type,handle) ((type ## Handle) mono_handle_elevate ((MonoObject*) (handle)->obj))
+#define MONO_HANDLE_ELEVATE(type,handle) ((type ## Handle) mono_handle_elevate ((MonoObject*) (handle)->__private_obj))
 
 #define MONO_HANDLE_ASSIGN(handle,rawptr)      \
        do {    \
@@ -87,6 +147,14 @@ mono_handle_domain (MonoHandle handle)
                MONO_FINISH_GC_CRITICAL_REGION;                                 \
        } while (0)
 
+#define MONO_HANDLE_SETREF_NULL(handle,fieldname)                      \
+       do {                                                            \
+               MONO_PREPARE_GC_CRITICAL_REGION;                        \
+               MONO_OBJECT_SETREF (mono_handle_obj ((handle)), fieldname, NULL); \
+               MONO_FINISH_GC_CRITICAL_REGION;                         \
+       } while (0)
+
+
 #define MONO_HANDLE_SET(handle,fieldname,value)        \
        do {    \
                MONO_PREPARE_GC_CRITICAL_REGION;        \
@@ -102,25 +170,23 @@ mono_handle_domain (MonoHandle handle)
                MONO_FINISH_GC_CRITICAL_REGION;                                 \
        } while (0)
 
+#define MONO_HANDLE_ARRAY_SETREF_NULL(handle,index)                    \
+       do {                                                            \
+               MONO_PREPARE_GC_CRITICAL_REGION;                        \
+               mono_array_setref (mono_handle_obj ((handle)), (index), NULL); \
+               MONO_FINISH_GC_CRITICAL_REGION;                         \
+       } while (0)
+       
+
 #define MONO_HANDLE_ARRAY_SET(handle,type,index,value) \
        do {    \
                MONO_PREPARE_GC_CRITICAL_REGION;        \
-               mono_array_set (mono_handle_obj ((handle)), (type), (index), (value));  \
+               mono_array_set (mono_handle_obj ((handle)), type, (index), (value));    \
                MONO_FINISH_GC_CRITICAL_REGION; \
        } while (0)
 
-/* handle arena specific functions */
 
-typedef struct _MonoHandleArena MonoHandleArena;
 
-gsize
-mono_handle_arena_size (gsize nb_handles);
-
-MonoHandle
-mono_handle_new (MonoObject *rawptr);
-
-MonoHandle
-mono_handle_elevate (MonoHandle handle);
 
 /* Some common handle types */
 
index a98091bc5a9ffc0fc5a9789a8bda0408d1e454ff..538371bf50cf4938bd72ceefb026f1e6a48348f2 100644 (file)
@@ -110,6 +110,9 @@ ICALL(BUFFER_2, "_ByteLength", ves_icall_System_Buffer_ByteLengthInternal)
 ICALL(BUFFER_3, "_GetByte", ves_icall_System_Buffer_GetByteInternal)
 ICALL(BUFFER_4, "_SetByte", ves_icall_System_Buffer_SetByteInternal)
 
+ICALL_TYPE(CLRCONFIG, "System.CLRConfig", CLRCONFIG_1)
+ICALL(CLRCONFIG_1, "CheckThrowUnobservedTaskExceptions", ves_icall_System_CLRConfig_CheckThrowUnobservedTaskExceptions)
+
 ICALL_TYPE (COMPO_W, "System.ComponentModel.Win32Exception", COMPO_W_1)
 ICALL (COMPO_W_1, "W32ErrorMessage", ves_icall_System_ComponentModel_Win32Exception_W32ErrorMessage)
 
@@ -228,6 +231,7 @@ ICALL_TYPE(ENV, "System.Environment", ENV_1)
 ICALL(ENV_1, "Exit", ves_icall_System_Environment_Exit)
 ICALL(ENV_2, "GetCommandLineArgs", mono_runtime_get_main_args)
 ICALL(ENV_3, "GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames)
+ICALL(ENV_31, "GetIs64BitOperatingSystem", ves_icall_System_Environment_GetIs64BitOperatingSystem)
 ICALL(ENV_4, "GetLogicalDrivesInternal", ves_icall_System_Environment_GetLogicalDrives )
 ICALL(ENV_5, "GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path)
 ICALL(ENV_51, "GetNewLine", ves_icall_System_Environment_get_NewLine)
index 06b2c57a759b7010a4bd92f16ecc04cef9814301..c6094ef9cd0fa8aaaf815f4a970f0be01098a5f2 100644 (file)
 #include "decimal-ms.h"
 #include "number-ms.h"
 
+#if !defined(HOST_WIN32) && defined(HAVE_SYS_UTSNAME_H)
+#include <sys/utsname.h>
+#endif
+
 extern MonoString* ves_icall_System_Environment_GetOSVersionString (void);
 
 ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void);
@@ -816,14 +820,15 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoAr
        }
 
 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
-#define SWAP(n) {\
-       guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
-       guint ## n *src = (guint ## n *) field_data; \
-       guint ## n *end = (guint ## n *)((char*)src + size); \
-\
-       for (; src < end; data++, src++) { \
-               *data = read ## n (src); \
-       } \
+#define SWAP(n) {                                                              \
+       guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0);     \
+       guint ## n *src = (guint ## n *) field_data;                            \
+       int i,                                                                  \
+           nEnt = (size / sizeof(guint ## n));                                 \
+                                                                               \
+       for (i = 0; i < nEnt; i++) {                                            \
+               data[i] = read ## n (&src[i]);                                  \
+       }                                                                       \
 }
 
        /* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
@@ -864,8 +869,13 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObj
 {
        if ((obj == NULL) || (! (obj->vtable->klass->valuetype)))
                return obj;
-       else
-               return mono_object_clone (obj);
+       else {
+               MonoError error;
+               MonoObject *ret = mono_object_clone_checked (obj, &error);
+               mono_error_raise_exception (&error);
+
+               return ret;
+       }
 }
 
 ICALL_EXPORT void
@@ -933,7 +943,11 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStac
 ICALL_EXPORT MonoObject *
 ves_icall_System_Object_MemberwiseClone (MonoObject *this_obj)
 {
-       return mono_object_clone (this_obj);
+       MonoError error;
+       MonoObject *ret = mono_object_clone_checked (this_obj, &error);
+       mono_error_raise_exception (&error);
+
+       return ret;
 }
 
 ICALL_EXPORT gint32
@@ -4557,6 +4571,9 @@ ves_icall_GetCurrentMethod (void)
 {
        MonoMethod *m = mono_method_get_last_managed ();
 
+       if (!m)
+               mono_raise_exception (mono_get_exception_not_supported ("Stack walks are not supported on this platform."));
+
        while (m->is_inflated)
                m = ((MonoMethodInflated*)m)->declaring;
 
@@ -4659,6 +4676,8 @@ ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
        mono_stack_walk_no_il (get_caller_no_reflection, &dest);
        if (!dest)
                dest = m;
+       if (!m)
+               mono_raise_exception (mono_get_exception_not_supported ("Stack walks are not supported on this platform."));
        return mono_assembly_get_object (mono_domain_get (), dest->klass->image->assembly);
 }
 
@@ -5880,6 +5899,28 @@ ves_icall_System_Environment_get_NewLine (void)
 #endif
 }
 
+ICALL_EXPORT MonoBoolean
+ves_icall_System_Environment_GetIs64BitOperatingSystem (void)
+{
+#if SIZEOF_VOID_P == 8
+       return TRUE;
+#else
+#ifdef HOST_WIN32
+       gboolean isWow64Process = FALSE;
+       if (IsWow64Process (GetCurrentProcess (), &isWow64Process)) {
+               return (MonoBoolean)isWow64Process;
+       }
+#elif defined(HAVE_SYS_UTSNAME_H)
+       struct utsname name;
+
+       if (uname (&name) >= 0) {
+               return strcmp (name.machine, "x86_64") == 0 || strncmp (name.machine, "aarch64", 7) == 0 || strncmp (name.machine, "ppc64", 5) == 0;
+       }
+#endif
+       return FALSE;
+#endif
+}
+
 ICALL_EXPORT MonoString *
 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
 {
@@ -6378,8 +6419,10 @@ ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (Mo
 ICALL_EXPORT MonoObject *
 ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType *type)
 {
+       MonoError error;
        MonoClass *klass;
        MonoDomain *domain;
+       MonoObject *ret;
        
        domain = mono_object_domain (type);
        klass = mono_class_from_mono_type (type->type);
@@ -6395,7 +6438,10 @@ ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClas
                return (MonoObject *) mono_array_new (domain, klass->element_class, 0);
        } else {
                /* Bypass remoting object creation check */
-               return mono_object_new_alloc_specific (mono_class_vtable_full (domain, klass, TRUE));
+               ret = mono_object_new_alloc_specific_checked (mono_class_vtable_full (domain, klass, TRUE), &error);
+               mono_error_raise_exception (&error);
+
+               return ret;
        }
 }
 
index 33dd5471c5fc713016ed172149a0b0642720d9bb..17b7107e63d873a495ed3fa70569a79bde57499b 100644 (file)
@@ -125,18 +125,15 @@ mono_jit_info_table_free (MonoJitInfoTable *table)
 
        for (i = 0; i < num_chunks; ++i) {
                MonoJitInfoTableChunk *chunk = table->chunks [i];
-               int num_elements;
-               int j;
+               MonoJitInfo *tombstone;
 
                if (--chunk->refcount > 0)
                        continue;
 
-               num_elements = chunk->num_elements;
-               for (j = 0; j < num_elements; ++j) {
-                       MonoJitInfo *ji = chunk->data [j];
-
-                       if (IS_JIT_INFO_TOMBSTONE (ji))
-                               g_free (ji);
+               for (tombstone = chunk->next_tombstone; tombstone; ) {
+                       MonoJitInfo *next = tombstone->n.next_tombstone;
+                       g_free (tombstone);
+                       tombstone = next;
                }
 
                g_free (chunk);
@@ -657,13 +654,15 @@ mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji)
 }
 
 static MonoJitInfo*
-mono_jit_info_make_tombstone (MonoJitInfo *ji)
+mono_jit_info_make_tombstone (MonoJitInfoTableChunk *chunk, MonoJitInfo *ji)
 {
        MonoJitInfo *tombstone = g_new0 (MonoJitInfo, 1);
 
        tombstone->code_start = ji->code_start;
        tombstone->code_size = ji->code_size;
        tombstone->d.method = JIT_INFO_TOMBSTONE_MARKER;
+       tombstone->n.next_tombstone = chunk->next_tombstone;
+       chunk->next_tombstone = tombstone;
 
        return tombstone;
 }
@@ -716,7 +715,7 @@ jit_info_table_remove (MonoJitInfoTable *table, MonoJitInfo *ji)
  found:
        g_assert (chunk->data [pos] == ji);
 
-       chunk->data [pos] = mono_jit_info_make_tombstone (ji);
+       chunk->data [pos] = mono_jit_info_make_tombstone (chunk, ji);
 
        /* Debugging code, should be removed. */
        //jit_info_table_check (table);
@@ -840,7 +839,7 @@ jit_info_next_value (gpointer value)
 {
        MonoJitInfo *info = (MonoJitInfo*)value;
 
-       return (gpointer*)&info->next_jit_code_hash;
+       return (gpointer*)&info->n.next_jit_code_hash;
 }
 
 void
index 70e471dba2d0bbb5754503439c40be7ea5104453..c2eeb47187ec21b5e6c5be0c8912e61abc747c74 100644 (file)
@@ -44,6 +44,7 @@
 #include "mono/utils/mono-memory-model.h"
 #include "mono/utils/atomic.h"
 #include <mono/utils/mono-threads.h>
+#include <mono/utils/mono-error-internals.h>
 
 #include <string.h>
 #include <errno.h>
@@ -139,6 +140,9 @@ mono_marshal_isinst_with_cache (MonoObject *obj, MonoClass *klass, uintptr_t *ca
 
 static void init_safe_handle (void);
 
+static void*
+ves_icall_marshal_alloc (gulong size);
+
 /* MonoMethod pointers to SafeHandle::DangerousAddRef and ::DangerousRelease */
 static MonoMethod *sh_dangerous_add_ref;
 static MonoMethod *sh_dangerous_release;
@@ -215,7 +219,7 @@ mono_marshal_init (void)
                register_icall (mono_ftnptr_to_delegate, "mono_ftnptr_to_delegate", "object ptr ptr", FALSE);
                register_icall (mono_marshal_asany, "mono_marshal_asany", "ptr object int32 int32", FALSE);
                register_icall (mono_marshal_free_asany, "mono_marshal_free_asany", "void object ptr int32 int32", FALSE);
-               register_icall (mono_marshal_alloc, "mono_marshal_alloc", "ptr int32", FALSE);
+               register_icall (ves_icall_marshal_alloc, "ves_icall_marshal_alloc", "ptr int32", FALSE);
                register_icall (mono_marshal_free, "mono_marshal_free", "void ptr", FALSE);
                register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", FALSE);
                register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", FALSE);
@@ -290,6 +294,8 @@ mono_delegate_to_ftnptr (MonoDelegate *delegate)
        g_assert (klass->delegate);
 
        method = delegate->method;
+       if (delegate->method_is_virtual)
+               method = mono_object_get_virtual_method (delegate->target, method);
 
        if (mono_method_signature (method)->pinvoke) {
                const char *exc_class, *exc_arg;
@@ -828,7 +834,8 @@ mono_string_utf16_to_builder (MonoStringBuilder *sb, gunichar2 *text)
 gchar*
 mono_string_builder_to_utf8 (MonoStringBuilder *sb)
 {
-       GError *error = NULL;
+       MonoError error;
+       GError *gerror = NULL;
 
        if (!sb)
                return NULL;
@@ -838,16 +845,17 @@ mono_string_builder_to_utf8 (MonoStringBuilder *sb)
 
        guint str_len = mono_string_builder_string_length (sb);
 
-       gchar *tmp = g_utf16_to_utf8 (str_utf16, str_len, NULL, NULL, &error);
+       gchar *tmp = g_utf16_to_utf8 (str_utf16, str_len, NULL, NULL, &gerror);
 
-       if (error) {
-               g_error_free (error);
+       if (gerror) {
+               g_error_free (gerror);
                g_free (str_utf16);
                mono_raise_exception (mono_get_exception_execution_engine ("Failed to convert StringBuilder from utf16 to utf8"));
                return NULL;
        } else {
                guint len = mono_string_builder_capacity (sb) + 1;
-               gchar *res = (gchar *)mono_marshal_alloc (len * sizeof (gchar));
+               gchar *res = (gchar *)mono_marshal_alloc (len * sizeof (gchar), &error);
+               mono_error_raise_exception (&error); /* FIXME don't raise here */
                g_assert (str_len < len);
                memcpy (res, tmp, str_len * sizeof (gchar));
                res[str_len] = '\0';
@@ -872,6 +880,8 @@ mono_string_builder_to_utf8 (MonoStringBuilder *sb)
 gunichar2*
 mono_string_builder_to_utf16 (MonoStringBuilder *sb)
 {
+       MonoError error;
+
        if (!sb)
                return NULL;
 
@@ -882,7 +892,9 @@ mono_string_builder_to_utf16 (MonoStringBuilder *sb)
        if (len == 0)
                len = 1;
 
-       gunichar2 *str = (gunichar2 *)mono_marshal_alloc ((len + 1) * sizeof (gunichar2));
+       gunichar2 *str = (gunichar2 *)mono_marshal_alloc ((len + 1) * sizeof (gunichar2), &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
+
        str[len] = '\0';
 
        if (len == 0)
@@ -3469,7 +3481,6 @@ handle_enum:
        case MONO_TYPE_CHAR:
                return &mono_defaults.uint16_class->byval_arg;
        case MONO_TYPE_U:
-       case MONO_TYPE_PTR:
                return &mono_defaults.int_class->byval_arg;
        case MONO_TYPE_VALUETYPE:
                if (t->data.klass->enumtype) {
@@ -4914,7 +4925,7 @@ emit_marshal_vtype (EmitMarshalContext *m, int argnum, MonoType *t,
                g_assert (m->retobj_var);
                mono_mb_emit_icon (mb, mono_class_native_size (klass, NULL));
                mono_mb_emit_byte (mb, CEE_CONV_I);
-               mono_mb_emit_icall (mb, mono_marshal_alloc);
+               mono_mb_emit_icall (mb, ves_icall_marshal_alloc);
                mono_mb_emit_stloc (mb, 1);
                mono_mb_emit_ldloc (mb, 1);
                mono_mb_emit_stloc (mb, m->retobj_var);
@@ -5757,7 +5768,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                        /* Allocate and set dest */
                        mono_mb_emit_icon (mb, mono_class_native_size (klass, NULL));
                        mono_mb_emit_byte (mb, CEE_CONV_I);
-                       mono_mb_emit_icall (mb, mono_marshal_alloc);
+                       mono_mb_emit_icall (mb, ves_icall_marshal_alloc);
                        mono_mb_emit_stloc (mb, 1);
                        
                        /* Update argument pointer */
@@ -5821,7 +5832,7 @@ emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
                /* Allocate and set dest */
                mono_mb_emit_icon (mb, mono_class_native_size (klass, NULL));
                mono_mb_emit_byte (mb, CEE_CONV_I);
-               mono_mb_emit_icall (mb, mono_marshal_alloc);
+               mono_mb_emit_icall (mb, ves_icall_marshal_alloc);
                mono_mb_emit_byte (mb, CEE_DUP);
                mono_mb_emit_stloc (mb, 1);
                mono_mb_emit_stloc (mb, 3);
@@ -6643,7 +6654,7 @@ emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
                        mono_mb_emit_byte (mb, CEE_ADD);
                }
                mono_mb_emit_byte (mb, CEE_MUL);
-               mono_mb_emit_icall (mb, mono_marshal_alloc);
+               mono_mb_emit_icall (mb, ves_icall_marshal_alloc);
                mono_mb_emit_stloc (mb, dest);
                mono_mb_emit_ldloc (mb, dest);
                mono_mb_emit_stloc (mb, 3);
@@ -8686,7 +8697,12 @@ mono_marshal_get_struct_to_ptr (MonoClass *klass)
        res = mono_mb_create (mb, mono_signature_no_pinvoke (stoptr), 0, info);
        mono_mb_free (mb);
 
-       klass->marshal_info->str_to_ptr = res;
+       mono_marshal_lock ();
+       if (!klass->marshal_info->str_to_ptr)
+               klass->marshal_info->str_to_ptr = res;
+       else
+               res = klass->marshal_info->str_to_ptr;
+       mono_marshal_unlock ();
        return res;
 }
 
@@ -8760,7 +8776,12 @@ mono_marshal_get_ptr_to_struct (MonoClass *klass)
        res = mono_mb_create (mb, ptostr, 0, info);
        mono_mb_free (mb);
 
-       klass->marshal_info->ptr_to_str = res;
+       mono_marshal_lock ();
+       if (!klass->marshal_info->ptr_to_str)
+               klass->marshal_info->ptr_to_str = res;
+       else
+               res = klass->marshal_info->ptr_to_str;
+       mono_marshal_unlock ();
        return res;
 }
 
@@ -10037,20 +10058,32 @@ mono_marshal_get_array_accessor_wrapper (MonoMethod *method)
 }
 
 void*
-mono_marshal_alloc (gulong size)
+mono_marshal_alloc (gulong size, MonoError *error)
 {
        gpointer res;
 
+       mono_error_init (error);
+
 #ifdef HOST_WIN32
        res = CoTaskMemAlloc (size);
 #else
        res = g_try_malloc ((gulong)size);
        if (!res)
-               mono_gc_out_of_memory ((gulong)size);
+               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", size);
 #endif
        return res;
 }
 
+static void*
+ves_icall_marshal_alloc (gulong size)
+{
+       MonoError error;
+       void *ret = mono_marshal_alloc (size, &error);
+       mono_error_raise_exception (&error);
+
+       return ret;
+}
+
 void
 mono_marshal_free (gpointer ptr)
 {
@@ -10086,7 +10119,9 @@ mono_marshal_string_to_utf16_copy (MonoString *s)
        if (s == NULL) {
                return NULL;
        } else {
-               gunichar2 *res = (gunichar2 *)mono_marshal_alloc ((mono_string_length (s) * 2) + 2);
+               MonoError error;
+               gunichar2 *res = (gunichar2 *)mono_marshal_alloc ((mono_string_length (s) * 2) + 2, &error);
+               mono_error_raise_exception (&error); /* FIXME don't raise here */
                memcpy (res, mono_string_chars (s), mono_string_length (s) * 2);
                res [mono_string_length (s)] = 0;
                return res;
@@ -10535,7 +10570,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_AllocHGlobal (gpointer size)
        res = g_try_malloc (s);
 #endif
        if (!res)
-               mono_gc_out_of_memory (s);
+               mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
 
        return res;
 }
@@ -10547,7 +10582,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_ReAllocHGlobal (gpointer ptr, g
        size_t s = (size_t)size;
 
        if (ptr == NULL) {
-               mono_gc_out_of_memory (s);
+               mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
                return NULL;
        }
 
@@ -10557,7 +10592,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_ReAllocHGlobal (gpointer ptr, g
        res = g_try_realloc (ptr, s);
 #endif
        if (!res)
-               mono_gc_out_of_memory (s);
+               mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
 
        return res;
 }
@@ -10587,7 +10622,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMem (int size)
        res = g_try_malloc ((gulong)size);
 #endif
        if (!res)
-               mono_gc_out_of_memory ((gulong)size);
+               mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
        return res;
 }
 
@@ -10612,7 +10647,7 @@ ves_icall_System_Runtime_InteropServices_Marshal_ReAllocCoTaskMem (gpointer ptr,
        res = g_try_realloc (ptr, (gulong)size);
 #endif
        if (!res)
-               mono_gc_out_of_memory ((gulong)size);
+               mono_raise_exception (mono_domain_get ()->out_of_memory_ex);
        return res;
 }
 
@@ -11013,6 +11048,7 @@ mono_marshal_type_size (MonoType *type, MonoMarshalSpec *mspec, guint32 *align,
 gpointer
 mono_marshal_asany (MonoObject *o, MonoMarshalNative string_encoding, int param_attrs)
 {
+       MonoError error;
        MonoType *t;
        MonoClass *klass;
 
@@ -11065,7 +11101,8 @@ mono_marshal_asany (MonoObject *o, MonoMarshalNative string_encoding, int param_
                        klass->blittable || klass->enumtype))
                        return mono_object_unbox (o);
 
-               res = mono_marshal_alloc (mono_class_native_size (klass, NULL));
+               res = mono_marshal_alloc (mono_class_native_size (klass, NULL), &error);
+               mono_error_raise_exception (&error); /* FIXME don't raise here */
 
                if (!((param_attrs & PARAM_ATTRIBUTE_OUT) && !(param_attrs & PARAM_ATTRIBUTE_IN))) {
                        method = mono_marshal_get_struct_to_ptr (o->vtable->klass);
index 494ff3d435ef5dbdbc99385fa2f90eea8ee6f162..6ef4f19390c42ea57651626f4f62bb758a24f361 100644 (file)
@@ -19,6 +19,7 @@
 #include <mono/metadata/reflection.h>
 #include <mono/metadata/method-builder.h>
 #include <mono/metadata/remoting.h>
+#include <mono/utils/mono-error.h>
 
 #define mono_marshal_find_bitfield_offset(type, elem, byte_offset, bitmask) \
        do { \
@@ -442,7 +443,7 @@ mono_marshal_unlock_internal (void);
 /* marshaling internal calls */
 
 void * 
-mono_marshal_alloc (gulong size);
+mono_marshal_alloc (gulong size, MonoError *error);
 
 void 
 mono_marshal_free (gpointer ptr);
index a7543b50f851ec194734d38cd5c576bf9ad65d40..d82ca0c831f7a167d88d04d5ecd71990f1b1699f 100644 (file)
@@ -10,6 +10,7 @@
 #include "mono/metadata/mono-mlist.h"
 #include "mono/metadata/appdomain.h"
 #include "mono/metadata/class-internals.h"
+#include "mono/metadata/object-internals.h"
 
 /* matches the System.MonoListItem object*/
 struct _MonoMList {
@@ -37,13 +38,15 @@ static MonoVTable *monolist_item_vtable = NULL;
 MonoMList*
 mono_mlist_alloc (MonoObject *data)
 {
+       MonoError error;
        MonoMList* res;
        if (!monolist_item_vtable) {
                MonoClass *klass = mono_class_from_name (mono_defaults.corlib, "System", "MonoListItem");
                monolist_item_vtable = mono_class_vtable (mono_get_root_domain (), klass);
                g_assert (monolist_item_vtable);
        }
-       res = (MonoMList*)mono_object_new_fast (monolist_item_vtable);
+       res = (MonoMList*)mono_object_new_fast_checked (monolist_item_vtable, &error);
+       mono_error_raise_exception (&error);
        MONO_OBJECT_SETREF (res, data, data);
        return res;
 }
index e5c16e1e9a46b2eab51c6249b54115f6ed82bad6..f933e11276f1d54d4e2e3662dcc2d5eafe3e0f6e 100644 (file)
@@ -234,6 +234,18 @@ mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len)
        return obj;
 }
 
+void*
+mono_gc_alloc_mature (MonoVTable *vtable, size_t size)
+{
+       return mono_gc_alloc_obj (vtable, size);
+}
+
+void*
+mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size)
+{
+       return mono_gc_alloc_obj (vtable, size);
+}
+
 void
 mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value)
 {
index 60cfaac692c5b764310a4f21bdad53f1f3a3080e..d2a1ba1c916f5385097b5d5045809838804ebece 100644 (file)
@@ -611,6 +611,7 @@ typedef struct {
        void     (*debug_log) (int level, MonoString *category, MonoString *message);
        gboolean (*debug_log_is_enabled) (void);
        gboolean (*tls_key_supported) (MonoTlsKey key);
+       void     (*init_delegate) (MonoDelegate *del);
 } MonoRuntimeCallbacks;
 
 typedef gboolean (*MonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data);
@@ -1611,6 +1612,15 @@ mono_class_free_ref_info (MonoClass *klass);
 MonoObject *
 mono_object_new_pinned (MonoDomain *domain, MonoClass *klass);
 
+MonoObject *
+mono_object_new_specific_checked (MonoVTable *vtable, MonoError *error);
+
+MonoObject *
+ves_icall_object_new_specific (MonoVTable *vtable);
+
+MonoObject *
+mono_object_new_alloc_specific_checked (MonoVTable *vtable, MonoError *error);
+
 void
 mono_field_static_get_value_for_thread (MonoInternalThread *thread, MonoVTable *vt, MonoClassField *field, void *value);
 
@@ -1651,6 +1661,18 @@ mono_error_set_pending_exception (MonoError *error);
 MonoArray *
 mono_glist_to_array (GList *list, MonoClass *eclass);
 
+MonoObject*
+mono_object_new_mature (MonoVTable *vtable, MonoError *error);
+
+MonoObject*
+mono_object_new_fast_checked (MonoVTable *vtable, MonoError *error);
+
+MonoObject *
+ves_icall_object_new_fast (MonoVTable *vtable);
+
+MonoObject *
+mono_object_clone_checked (MonoObject *obj, MonoError *error);
+
 #endif /* __MONO_OBJECT_INTERNALS_H__ */
 
 
index 8ba5568aa9d40e02e914880e843f12cbf7c00ef6..b86da42eec66c463f928d799ff649cf8269be504 100644 (file)
@@ -979,7 +979,7 @@ mono_class_compute_gc_descriptor (MonoClass *klass)
        if (!gcj_inited) {
                mono_loader_lock ();
 
-               mono_register_jit_icall (mono_object_new_fast, "mono_object_new_fast", mono_create_icall_signature ("object ptr"), FALSE);
+               mono_register_jit_icall (ves_icall_object_new_fast, "ves_icall_object_new_fast", mono_create_icall_signature ("object ptr"), FALSE);
                mono_register_jit_icall (mono_string_alloc, "mono_string_alloc", mono_create_icall_signature ("object int"), FALSE);
 
                gcj_inited = TRUE;
@@ -4191,7 +4191,7 @@ mono_runtime_exec_main (MonoMethod *method, MonoArray *args, MonoObject **exc)
                        str = g_strconcat (assembly->image->name, ".config", NULL);
                        MONO_OBJECT_SETREF (domain->setup, configuration_file, mono_string_new (domain, str));
                        g_free (str);
-                       mono_set_private_bin_path_from_config (domain);
+                       mono_domain_set_options_from_config (domain);
                }
        }
 
@@ -4500,7 +4500,12 @@ mono_object_new (MonoDomain *domain, MonoClass *klass)
        vtable = mono_class_vtable (domain, klass);
        if (!vtable)
                return NULL;
-       return mono_object_new_specific (vtable);
+
+       MonoError error;
+       MonoObject *o = mono_object_new_specific_checked (vtable, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
+
+       return o;
 }
 
 /**
@@ -4520,11 +4525,14 @@ mono_object_new_pinned (MonoDomain *domain, MonoClass *klass)
        if (!vtable)
                return NULL;
 
-#ifdef HAVE_SGEN_GC
-       return (MonoObject *)mono_gc_alloc_pinned_obj (vtable, mono_class_instance_size (klass));
-#else
-       return mono_object_new_specific (vtable);
-#endif
+       MonoObject *o = (MonoObject *)mono_gc_alloc_pinned_obj (vtable, mono_class_instance_size (klass));
+
+       if (G_UNLIKELY (!o))
+               mono_gc_out_of_memory (mono_class_instance_size (klass));
+       else if (G_UNLIKELY (vtable->klass->has_finalize))
+               mono_object_register_finalizer (o);
+
+       return o;
 }
 
 /**
@@ -4536,11 +4544,23 @@ mono_object_new_pinned (MonoDomain *domain, MonoClass *klass)
  */
 MonoObject *
 mono_object_new_specific (MonoVTable *vtable)
+{
+       MonoError error;
+       MonoObject *o = mono_object_new_specific_checked (vtable, &error);
+       mono_error_raise_exception (&error);
+
+       return o;
+}
+
+MonoObject *
+mono_object_new_specific_checked (MonoVTable *vtable, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
        MonoObject *o;
 
+       mono_error_init (error);
+
        /* check for is_com_object for COM Interop */
        if (mono_vtable_is_remote (vtable) || mono_class_is_com_object (vtable->klass))
        {
@@ -4554,8 +4574,10 @@ mono_object_new_specific (MonoVTable *vtable)
                                mono_class_init (klass);
 
                        im = mono_class_get_method_from_name (klass, "CreateProxyForType", 1);
-                       if (!im)
-                               mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
+                       if (!im) {
+                               mono_error_set_generic_error (error, "System", "NotSupportedException", "Linked away.");
+                               return NULL;
+                       }
                        vtable->domain->create_proxy_for_type_method = im;
                }
        
@@ -4565,17 +4587,43 @@ mono_object_new_specific (MonoVTable *vtable)
                if (o != NULL) return o;
        }
 
-       return mono_object_new_alloc_specific (vtable);
+       return mono_object_new_alloc_specific_checked (vtable, error);
+}
+
+MonoObject *
+ves_icall_object_new_specific (MonoVTable *vtable)
+{
+       MonoError error;
+       MonoObject *o = mono_object_new_specific_checked (vtable, &error);
+       mono_error_raise_exception (&error);
+
+       return o;
 }
 
 MonoObject *
 mono_object_new_alloc_specific (MonoVTable *vtable)
+{
+       MonoError error;
+       MonoObject *o = mono_object_new_alloc_specific_checked (vtable, &error);
+       mono_error_raise_exception (&error);
+
+       return o;
+}
+
+MonoObject *
+mono_object_new_alloc_specific_checked (MonoVTable *vtable, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
-       MonoObject *o = (MonoObject *)mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
+       MonoObject *o;
+
+       mono_error_init (error);
+
+       o = (MonoObject *)mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
 
-       if (G_UNLIKELY (vtable->klass->has_finalize))
+       if (G_UNLIKELY (!o))
+               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", vtable->klass->instance_size);
+       else if (G_UNLIKELY (vtable->klass->has_finalize))
                mono_object_register_finalizer (o);
 
        return o;
@@ -4583,10 +4631,58 @@ mono_object_new_alloc_specific (MonoVTable *vtable)
 
 MonoObject*
 mono_object_new_fast (MonoVTable *vtable)
+{
+       MonoError error;
+       MonoObject *o = mono_object_new_fast_checked (vtable, &error);
+       mono_error_raise_exception (&error);
+
+       return o;
+}
+
+MonoObject*
+mono_object_new_fast_checked (MonoVTable *vtable, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
-       return (MonoObject *)mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
+       MonoObject *o;
+
+       mono_error_init (error);
+
+       o = mono_gc_alloc_obj (vtable, vtable->klass->instance_size);
+
+       if (G_UNLIKELY (!o))
+               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", vtable->klass->instance_size);
+
+       return o;
+}
+
+MonoObject *
+ves_icall_object_new_fast (MonoVTable *vtable)
+{
+       MonoError error;
+       MonoObject *o = mono_object_new_fast_checked (vtable, &error);
+       mono_error_raise_exception (&error);
+
+       return o;
+}
+
+MonoObject*
+mono_object_new_mature (MonoVTable *vtable, MonoError *error)
+{
+       MONO_REQ_GC_UNSAFE_MODE;
+
+       MonoObject *o;
+
+       mono_error_init (error);
+
+       o = mono_gc_alloc_mature (vtable, vtable->klass->instance_size);
+
+       if (G_UNLIKELY (!o))
+               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", vtable->klass->instance_size);
+       else if (G_UNLIKELY (vtable->klass->has_finalize))
+               mono_object_register_finalizer (o);
+
+       return o;
 }
 
 /**
@@ -4606,14 +4702,14 @@ mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *p
        *pass_size_in_words = FALSE;
 
        if (mono_class_has_finalizer (vtable->klass) || mono_class_is_marshalbyref (vtable->klass) || (mono_profiler_get_events () & MONO_PROFILE_ALLOCATIONS))
-               return mono_object_new_specific;
+               return ves_icall_object_new_specific;
 
        if (vtable->gc_descr != MONO_GC_DESCRIPTOR_NULL) {
 
-               return mono_object_new_fast;
+               return ves_icall_object_new_fast;
 
                /* 
-                * FIXME: This is actually slower than mono_object_new_fast, because
+                * FIXME: This is actually slower than ves_icall_object_new_fast, because
                 * of the overhead of parameter passing.
                 */
                /*
@@ -4626,7 +4722,7 @@ mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *p
                */
        }
 
-       return mono_object_new_specific;
+       return ves_icall_object_new_specific;
 }
 
 /**
@@ -4660,17 +4756,36 @@ mono_object_new_from_token  (MonoDomain *domain, MonoImage *image, guint32 token
  */
 MonoObject *
 mono_object_clone (MonoObject *obj)
+{
+       MonoError error;
+       MonoObject *o = mono_object_clone_checked (obj, &error);
+       mono_error_raise_exception (&error);
+
+       return o;
+}
+
+MonoObject *
+mono_object_clone_checked (MonoObject *obj, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
        MonoObject *o;
-       int size = obj->vtable->klass->instance_size;
+       int size;
+
+       mono_error_init (error);
+
+       size = obj->vtable->klass->instance_size;
 
        if (obj->vtable->klass->rank)
                return (MonoObject*)mono_array_clone ((MonoArray*)obj);
 
        o = (MonoObject *)mono_gc_alloc_obj (obj->vtable, size);
 
+       if (G_UNLIKELY (!o)) {
+               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", size);
+               return NULL;
+       }
+
        /* If the object doesn't contain references this will do a simple memmove. */
        mono_gc_wbarrier_object_copy (o, obj);
 
@@ -4894,6 +5009,10 @@ mono_array_new_full (MonoDomain *domain, MonoClass *array_class, uintptr_t *leng
                o = (MonoObject *)mono_gc_alloc_array (vtable, byte_len, len, bounds_size);
        else
                o = (MonoObject *)mono_gc_alloc_vector (vtable, byte_len, len);
+
+       if (G_UNLIKELY (!o))
+               mono_gc_out_of_memory (byte_len);
+
        array = (MonoArray*)o;
 
        bounds = array->bounds;
@@ -4944,7 +5063,6 @@ mono_array_new_specific (MonoVTable *vtable, uintptr_t n)
        MONO_REQ_GC_UNSAFE_MODE;
 
        MonoObject *o;
-       MonoArray *ao;
        uintptr_t byte_len;
 
        if (G_UNLIKELY (n > MONO_ARRAY_MAX_INDEX)) {
@@ -4957,9 +5075,11 @@ mono_array_new_specific (MonoVTable *vtable, uintptr_t n)
                return NULL;
        }
        o = (MonoObject *)mono_gc_alloc_vector (vtable, byte_len, n);
-       ao = (MonoArray*)o;
 
-       return ao;
+       if (G_UNLIKELY (!o))
+               mono_gc_out_of_memory (byte_len);
+
+       return (MonoArray*)o;
 }
 
 /**
@@ -5047,6 +5167,9 @@ mono_string_new_size (MonoDomain *domain, gint32 len)
 
        s = (MonoString *)mono_gc_alloc_string (vtable, size, len);
 
+       if (G_UNLIKELY (!s))
+               mono_gc_out_of_memory (size);
+
        return s;
 }
 
@@ -5159,6 +5282,7 @@ mono_value_box (MonoDomain *domain, MonoClass *klass, gpointer value)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
+       MonoError error;
        MonoObject *res;
        int size;
        MonoVTable *vtable;
@@ -5171,7 +5295,8 @@ mono_value_box (MonoDomain *domain, MonoClass *klass, gpointer value)
        if (!vtable)
                return NULL;
        size = mono_class_instance_size (klass);
-       res = mono_object_new_alloc_specific (vtable);
+       res = mono_object_new_alloc_specific_checked (vtable, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
 
        size = size - sizeof (MonoObject);
 
@@ -5440,13 +5565,16 @@ str_lookup (MonoDomain *domain, gpointer user_data)
        info->res = (MonoString *)mono_g_hash_table_lookup (domain->ldstr_table, info->ins);
 }
 
-#ifdef HAVE_SGEN_GC
-
 static MonoString*
-mono_string_get_pinned (MonoString *str)
+mono_string_get_pinned (MonoString *str, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
+       mono_error_init (error);
+
+       /* We only need to make a pinned version of a string if this is a moving GC */
+       if (!mono_gc_is_moving ())
+               return str;
        int size;
        MonoString *news;
        size = sizeof (MonoString) + 2 * (mono_string_length (str) + 1);
@@ -5454,19 +5582,18 @@ mono_string_get_pinned (MonoString *str)
        if (news) {
                memcpy (mono_string_chars (news), mono_string_chars (str), mono_string_length (str) * 2);
                news->length = mono_string_length (str);
+       } else {
+               mono_error_set_out_of_memory (error, "Could not allocate %i bytes", size);
        }
        return news;
 }
 
-#else
-#define mono_string_get_pinned(str) (str)
-#endif
-
 static MonoString*
 mono_string_is_interned_lookup (MonoString *str, int insert)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
+       MonoError error;
        MonoGHashTable *ldstr_table;
        MonoString *s, *res;
        MonoDomain *domain;
@@ -5482,7 +5609,8 @@ mono_string_is_interned_lookup (MonoString *str, int insert)
        if (insert) {
                /* Allocate outside the lock */
                ldstr_unlock ();
-               s = mono_string_get_pinned (str);
+               s = mono_string_get_pinned (str, &error);
+               mono_error_raise_exception (&error); /* FIXME don't raise here */
                if (s) {
                        ldstr_lock ();
                        res = (MonoString *)mono_g_hash_table_lookup (ldstr_table, str);
@@ -5580,6 +5708,7 @@ mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
+       MonoError error;
        const char *str = sig;
        MonoString *o, *interned;
        size_t len2;
@@ -5604,7 +5733,8 @@ mono_ldstr_metadata_sig (MonoDomain *domain, const char* sig)
        if (interned)
                return interned; /* o will get garbage collected */
 
-       o = mono_string_get_pinned (o);
+       o = mono_string_get_pinned (o, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
        if (o) {
                ldstr_lock ();
                interned = (MonoString *)mono_g_hash_table_lookup (domain->ldstr_table, o);
@@ -6430,6 +6560,8 @@ mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpoint
        }
 
        delegate->invoke_impl = arch_create_delegate_trampoline (delegate->object.vtable->domain, delegate->object.vtable->klass);
+       if (callbacks.init_delegate)
+               callbacks.init_delegate (delegate);
 }
 
 /**
index c547c696eea1a0ebe7ee4e819ba002297a74f61f..568752d9c9acf3d8e54e1d6a23ee133b83ccfb8b 100644 (file)
@@ -7073,7 +7073,8 @@ mono_param_get_objects_internal (MonoDomain *domain, MonoMethod *method, MonoCla
        res = mono_array_new_specific (mono_class_vtable (domain, System_Reflection_ParameterInfo_array), sig->param_count);
        pinfo_vtable = mono_class_vtable (domain, System_Reflection_ParameterInfo);
        for (i = 0; i < sig->param_count; ++i) {
-               param = (MonoReflectionParameter *)mono_object_new_specific (pinfo_vtable);
+               param = (MonoReflectionParameter *) mono_object_new_specific_checked (pinfo_vtable, &error);
+               mono_error_raise_exception (&error); /* FIXME don't raise here */
                MONO_OBJECT_SETREF (param, ClassImpl, mono_type_get_object (domain, sig->params [i]));
                MONO_OBJECT_SETREF (param, MemberImpl, (MonoObject*)member);
                MONO_OBJECT_SETREF (param, NameImpl, mono_string_new (domain, names [i]));
index 71906968539f8ebb845ab1f53f5de001d4b8b222..2c0445c4a11dbb6eecd050a7e699b0d99af4233e 100644 (file)
@@ -675,8 +675,6 @@ extern MonoNativeTlsKey thread_info_key;
 #define IN_CRITICAL_REGION (__thread_info__->client_info.in_critical_region)
 #endif
 
-#ifndef DISABLE_CRITICAL_REGION
-
 #ifdef HAVE_KW_THREAD
 #define IN_CRITICAL_REGION sgen_thread_info->client_info.in_critical_region
 #else
@@ -691,8 +689,6 @@ extern MonoNativeTlsKey thread_info_key;
  */
 #define EXIT_CRITICAL_REGION  do { mono_atomic_store_release (&IN_CRITICAL_REGION, 0); } while (0)
 
-#endif
-
 #define SGEN_TV_DECLARE(name) gint64 name
 #define SGEN_TV_GETTIME(tv) tv = mono_100ns_ticks ()
 #define SGEN_TV_ELAPSED(start,end) ((long)(end-start))
index 8d3b7c137eb4fa444980841bcfbb68b1e6cb4773..78fa394559af8e54e796f105d7125c320085abdd 100644 (file)
@@ -34,6 +34,7 @@
 #include "metadata/runtime.h"
 #include "metadata/sgen-bridge-internals.h"
 #include "metadata/gc-internals.h"
+#include "metadata/handle.h"
 #include "utils/mono-memory-model.h"
 #include "utils/mono-logger-internals.h"
 
@@ -935,8 +936,10 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
 {
        MonoObject *obj = sgen_alloc_obj (vtable, size);
 
-       if (G_UNLIKELY (alloc_events))
-               mono_profiler_allocation (obj);
+       if (G_UNLIKELY (alloc_events)) {
+               if (obj)
+                       mono_profiler_allocation (obj);
+       }
 
        return obj;
 }
@@ -946,22 +949,23 @@ mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size)
 {
        MonoObject *obj = sgen_alloc_obj_pinned (vtable, size);
 
-       if (G_UNLIKELY (alloc_events))
-               mono_profiler_allocation (obj);
+       if (G_UNLIKELY (alloc_events)) {
+               if (obj)
+                       mono_profiler_allocation (obj);
+       }
 
        return obj;
 }
 
 void*
-mono_gc_alloc_mature (MonoVTable *vtable)
+mono_gc_alloc_mature (MonoVTable *vtable, size_t size)
 {
-       MonoObject *obj = sgen_alloc_obj_mature (vtable, vtable->klass->instance_size);
+       MonoObject *obj = sgen_alloc_obj_mature (vtable, size);
 
-       if (obj && G_UNLIKELY (obj->vtable->klass->has_finalize))
-               mono_object_register_finalizer (obj);
-
-       if (G_UNLIKELY (alloc_events))
-               mono_profiler_allocation (obj);
+       if (G_UNLIKELY (alloc_events)) {
+               if (obj)
+                       mono_profiler_allocation (obj);
+       }
 
        return obj;
 }
@@ -1104,7 +1108,7 @@ create_allocator (int atype, gboolean slowpath)
                case ATYPE_NORMAL:
                case ATYPE_SMALL:
                        mono_mb_emit_ldarg (mb, 0);
-                       mono_mb_emit_icall (mb, mono_object_new_specific);
+                       mono_mb_emit_icall (mb, ves_icall_object_new_specific);
                        break;
                case ATYPE_VECTOR:
                        mono_mb_emit_ldarg (mb, 0);
@@ -1400,10 +1404,7 @@ create_allocator (int atype, gboolean slowpath)
 int
 mono_gc_get_aligned_size_for_allocator (int size)
 {
-       int aligned_size = size;
-       aligned_size += SGEN_ALLOC_ALIGN - 1;
-       aligned_size &= ~(SGEN_ALLOC_ALIGN - 1);
-       return aligned_size;
+       return SGEN_ALIGN_UP (size);
 }
 
 /*
@@ -1735,7 +1736,7 @@ mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length)
        arr = (MonoArray*)sgen_alloc_obj_nolock (vtable, size);
        if (G_UNLIKELY (!arr)) {
                UNLOCK_GC;
-               return mono_gc_out_of_memory (size);
+               return NULL;
        }
 
        arr->max_length = (mono_array_size_t)max_length;
@@ -1780,7 +1781,7 @@ mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uint
        arr = (MonoArray*)sgen_alloc_obj_nolock (vtable, size);
        if (G_UNLIKELY (!arr)) {
                UNLOCK_GC;
-               return mono_gc_out_of_memory (size);
+               return NULL;
        }
 
        arr->max_length = (mono_array_size_t)max_length;
@@ -1824,7 +1825,7 @@ mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len)
        str = (MonoString*)sgen_alloc_obj_nolock (vtable, size);
        if (G_UNLIKELY (!str)) {
                UNLOCK_GC;
-               return mono_gc_out_of_memory (size);
+               return NULL;
        }
 
        str->length = len;
@@ -2276,6 +2277,8 @@ thread_in_critical_region (SgenThreadInfo *info)
 static void
 sgen_thread_attach (SgenThreadInfo *info)
 {
+       mono_handle_arena_init ((MonoHandleArena**) &info->client_info.info.handle_arena);
+
        if (mono_gc_get_gc_callbacks ()->thread_attach_func && !info->client_info.runtime_data)
                info->client_info.runtime_data = mono_gc_get_gc_callbacks ()->thread_attach_func ();
 }
@@ -2291,6 +2294,8 @@ sgen_thread_detach (SgenThreadInfo *p)
         */
        if (mono_domain_get ())
                mono_thread_detach_internal (mono_thread_internal_current ());
+
+       mono_handle_arena_cleanup ((MonoHandleArena**) &p->client_info.info.handle_arena);
 }
 
 gboolean
@@ -2704,12 +2709,6 @@ mono_gc_register_altstack (gpointer stack, gint32 stack_size, gpointer altstack,
        // FIXME:
 }
 
-void
-sgen_client_out_of_memory (size_t size)
-{
-       mono_gc_out_of_memory (size);
-}
-
 guint8*
 mono_gc_get_card_table (int *shift_bits, gpointer *mask)
 {
index 2a8b7ad10f4420ca8d2a0cec1f3e1de393044337..29ce34f917c0bd0b805a7247bddd6d8ad441fec0 100644 (file)
@@ -107,7 +107,7 @@ suspend_thread (SgenThreadInfo *info, void *context)
        if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
                mono_gc_get_gc_callbacks ()->thread_suspend_func (info->client_info.runtime_data, context, NULL);
 
-       SGEN_LOG (4, "Posting suspend_ack_semaphore for suspend from %p %p", info, (gpointer)mono_native_thread_id_get ());
+       SGEN_LOG (4, "Posting suspend_ack_semaphore for suspend from %p %p", info, (gpointer) (gsize) mono_native_thread_id_get ());
 
        /*
        Block the restart signal. 
@@ -129,7 +129,7 @@ suspend_thread (SgenThreadInfo *info, void *context)
        /* Unblock the restart signal. */
        pthread_sigmask (SIG_UNBLOCK, &suspend_ack_signal_mask, NULL);
 
-       SGEN_LOG (4, "Posting suspend_ack_semaphore for resume from %p %p\n", info, (gpointer)mono_native_thread_id_get ());
+       SGEN_LOG (4, "Posting suspend_ack_semaphore for resume from %p %p\n", info, (gpointer) (gsize) mono_native_thread_id_get ());
        /* notify the waiting thread */
        SGEN_SEMAPHORE_POST (suspend_ack_semaphore_ptr);
 }
@@ -163,7 +163,7 @@ MONO_SIG_HANDLER_FUNC (static, restart_handler)
 
        info = mono_thread_info_current ();
        info->client_info.signal = restart_signal_num;
-       SGEN_LOG (4, "Restart handler in %p %p", info, (gpointer)mono_native_thread_id_get ());
+       SGEN_LOG (4, "Restart handler in %p %p", info, (gpointer) (gsize) mono_native_thread_id_get ());
        errno = old_errno;
 }
 
index 8a2ae113da920483d3624c5995234a5fcfe8acca..f9f699b7601c5b0e93c2979985305b346441359e 100644 (file)
@@ -1,6 +1,6 @@
 #include "config.h"
 
-#if defined(HAVE_SGEN_GC) && defined(HOST_WIN32)
+#if defined(HAVE_SGEN_GC) && !defined(USE_COOP_GC) && defined(HOST_WIN32)
 
 #include "io-layer/io-layer.h"
 
index 651dbb59de190cef0863ee60ba3ca6f95bad872b..b2cb17c3b91dd3bb50bbd4c6812409f6734de873 100644 (file)
@@ -224,7 +224,7 @@ sgen_client_stop_world (int generation)
        update_current_thread_stack (&generation);
 
        sgen_global_stop_count++;
-       SGEN_LOG (3, "stopping world n %d from %p %p", sgen_global_stop_count, mono_thread_info_current (), (gpointer)mono_native_thread_id_get ());
+       SGEN_LOG (3, "stopping world n %d from %p %p", sgen_global_stop_count, mono_thread_info_current (), (gpointer) (gsize) mono_native_thread_id_get ());
        TV_GETTIME (stop_world_time);
 
        if (mono_thread_info_unified_management_enabled ()) {
index c39b70375a29b552d22ec03f86d232889802c73b..9ea5120c3f975dc57a5f8e712394d369fdbf89ad 100644 (file)
@@ -570,8 +570,11 @@ set_current_thread_for_domain (MonoDomain *domain, MonoInternalThread *thread, M
 static MonoThread*
 create_thread_object (MonoDomain *domain)
 {
+       MonoError error;
        MonoVTable *vt = mono_class_vtable (domain, mono_defaults.thread_class);
-       return (MonoThread*)mono_gc_alloc_mature (vt);
+       MonoThread *t = (MonoThread*)mono_object_new_mature (vt, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       return t;
 }
 
 static MonoThread*
@@ -585,11 +588,13 @@ new_thread_with_internal (MonoDomain *domain, MonoInternalThread *internal)
 static MonoInternalThread*
 create_internal_thread (void)
 {
+       MonoError error;
        MonoInternalThread *thread;
        MonoVTable *vt;
 
        vt = mono_class_vtable (mono_get_root_domain (), mono_defaults.internal_thread_class);
-       thread = (MonoInternalThread*)mono_gc_alloc_mature (vt);
+       thread = (MonoInternalThread*)mono_object_new_mature (vt, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
 
        thread->synch_cs = g_new0 (MonoCoopMutex, 1);
        mono_coop_mutex_init_recursive (thread->synch_cs);
@@ -2346,64 +2351,64 @@ void mono_thread_stop (MonoThread *thread)
 gint8
 ves_icall_System_Threading_Thread_VolatileRead1 (void *ptr)
 {
-       gint8 tmp;
-       mono_atomic_load_acquire (tmp, gint8, (volatile gint8 *) ptr);
+       gint8 tmp = *(volatile gint8 *)ptr;
+       mono_memory_barrier ();
        return tmp;
 }
 
 gint16
 ves_icall_System_Threading_Thread_VolatileRead2 (void *ptr)
 {
-       gint16 tmp;
-       mono_atomic_load_acquire (tmp, gint16, (volatile gint16 *) ptr);
+       gint16 tmp = *(volatile gint16 *)ptr;
+       mono_memory_barrier ();
        return tmp;
 }
 
 gint32
 ves_icall_System_Threading_Thread_VolatileRead4 (void *ptr)
 {
-       gint32 tmp;
-       mono_atomic_load_acquire (tmp, gint32, (volatile gint32 *) ptr);
+       gint32 tmp = *(volatile gint32 *)ptr;
+       mono_memory_barrier ();
        return tmp;
 }
 
 gint64
 ves_icall_System_Threading_Thread_VolatileRead8 (void *ptr)
 {
-       gint64 tmp;
-       mono_atomic_load_acquire (tmp, gint64, (volatile gint64 *) ptr);
+       gint64 tmp = *(volatile gint64 *)ptr;
+       mono_memory_barrier ();
        return tmp;
 }
 
 void *
 ves_icall_System_Threading_Thread_VolatileReadIntPtr (void *ptr)
 {
-       volatile void *tmp;
-       mono_atomic_load_acquire (tmp, volatile void *, (volatile void **) ptr);
+       volatile void *tmp = *(volatile void **)ptr;
+       mono_memory_barrier ();
        return (void *) tmp;
 }
 
 void *
 ves_icall_System_Threading_Thread_VolatileReadObject (void *ptr)
 {
-       volatile MonoObject *tmp;
-       mono_atomic_load_acquire (tmp, volatile MonoObject *, (volatile MonoObject **) ptr);
+       volatile MonoObject *tmp = *(volatile MonoObject **)ptr;
+       mono_memory_barrier ();
        return (MonoObject *) tmp;
 }
 
 double
 ves_icall_System_Threading_Thread_VolatileReadDouble (void *ptr)
 {
-       double tmp;
-       mono_atomic_load_acquire (tmp, double, (volatile double *) ptr);
+       double tmp = *(volatile double *)ptr;
+       mono_memory_barrier ();
        return tmp;
 }
 
 float
 ves_icall_System_Threading_Thread_VolatileReadFloat (void *ptr)
 {
-       float tmp;
-       mono_atomic_load_acquire (tmp, float, (volatile float *) ptr);
+       float tmp = *(volatile float *)ptr;
+       mono_memory_barrier ();
        return tmp;
 }
 
@@ -2485,49 +2490,57 @@ ves_icall_System_Threading_Volatile_Read_T (void *ptr)
 void
 ves_icall_System_Threading_Thread_VolatileWrite1 (void *ptr, gint8 value)
 {
-       mono_atomic_store_release ((volatile gint8 *) ptr, value);
+       mono_memory_barrier ();
+       *(volatile gint8 *)ptr = value;
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWrite2 (void *ptr, gint16 value)
 {
-       mono_atomic_store_release ((volatile gint16 *) ptr, value);
+       mono_memory_barrier ();
+       *(volatile gint16 *)ptr = value;
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWrite4 (void *ptr, gint32 value)
 {
-       mono_atomic_store_release ((volatile gint32 *) ptr, value);
+       mono_memory_barrier ();
+       *(volatile gint32 *)ptr = value;
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWrite8 (void *ptr, gint64 value)
 {
-       mono_atomic_store_release ((volatile gint64 *) ptr, value);
+       mono_memory_barrier ();
+       *(volatile gint64 *)ptr = value;
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWriteIntPtr (void *ptr, void *value)
 {
-       mono_atomic_store_release ((volatile void **) ptr, value);
+       mono_memory_barrier ();
+       *(volatile void **)ptr = value;
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWriteObject (void *ptr, MonoObject *value)
 {
-       mono_gc_wbarrier_generic_store_atomic (ptr, value);
+       mono_memory_barrier ();
+       mono_gc_wbarrier_generic_store (ptr, value);
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWriteDouble (void *ptr, double value)
 {
-       mono_atomic_store_release ((volatile double *) ptr, value);
+       mono_memory_barrier ();
+       *(volatile double *)ptr = value;
 }
 
 void
 ves_icall_System_Threading_Thread_VolatileWriteFloat (void *ptr, float value)
 {
-       mono_atomic_store_release ((volatile float *) ptr, value);
+       mono_memory_barrier ();
+       *(volatile float *)ptr = value;
 }
 
 void
index 8d320c4e4c878c822f764f8adbfa010bdc03d060..17de03c02481664d3729f175cc97f36eb4376511 100755 (executable)
@@ -480,7 +480,6 @@ if AMD64
 arch_sources = $(amd64_sources)
 arch_built=cpu-amd64.h
 arch_define=__x86_64__
-ARCH_FULLAOT_EXCLUDE=--exclude DYNCALL --exclude GSHAREDVT
 endif
 
 if POWERPC
index 1608dd78d697c927d132f85fb346f4842cd650ed..1aa383569e9439a03411b7cc2108a0eb2f1319fc 100644 (file)
@@ -2141,6 +2141,22 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size)
 #endif
 }
 
+
+#if defined (TARGET_AMD64)
+
+static void
+amd64_emit_load_got_slot (MonoAotCompile *acfg, int dreg, int got_slot)
+{
+
+       g_assert (acfg->fp);
+       emit_unset_mode (acfg);
+
+       fprintf (acfg->fp, "mov %s+%d(%%rip), %s\n", acfg->got_symbol, (unsigned int) ((got_slot * sizeof (gpointer))), mono_arch_regname (dreg));
+}
+
+#endif
+
+
 /*
  * arch_emit_gsharedvt_arg_trampoline:
  *
@@ -2206,6 +2222,14 @@ arch_emit_gsharedvt_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp
        emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (gpointer)) + 4);
 #elif defined(TARGET_ARM64)
        arm64_emit_gsharedvt_arg_trampoline (acfg, offset, tramp_size);
+#elif defined (TARGET_AMD64)
+
+       amd64_emit_load_got_slot (acfg, AMD64_RAX, offset);
+       amd64_emit_load_got_slot (acfg, MONO_ARCH_IMT_SCRATCH_REG, offset + 1);
+       g_assert (AMD64_R11 == MONO_ARCH_IMT_SCRATCH_REG);
+       fprintf (acfg->fp, "jmp *%%r11\n");
+
+       *tramp_size = 0x11;
 #else
        g_assert_not_reached ();
 #endif
@@ -3295,7 +3319,7 @@ add_extra_method_with_depth (MonoAotCompile *acfg, MonoMethod *method, int depth
                method = mini_get_shared_method_full (method, TRUE, TRUE);
 
        if (acfg->aot_opts.log_generics)
-               aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_full_name (method, TRUE));
+               aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method));
 
        add_method_full (acfg, method, TRUE, depth);
 }
@@ -4192,7 +4216,7 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth,
                method = mono_marshal_get_delegate_invoke (method, NULL);
 
                if (acfg->aot_opts.log_generics)
-                       aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_full_name (method, TRUE));
+                       aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method));
 
                add_method (acfg, method);
        }
@@ -5247,7 +5271,7 @@ emit_method_code (MonoAotCompile *acfg, MonoCompile *cfg)
        }
 
        if (cfg->verbose_level > 0)
-               g_print ("Method %s emitted as %s\n", mono_method_full_name (method, TRUE), cfg->asm_symbol);
+               g_print ("Method %s emitted as %s\n", mono_method_get_full_name (method), cfg->asm_symbol);
 
        acfg->stats.code_size += cfg->code_len;
 
@@ -5422,6 +5446,7 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint
        case MONO_PATCH_INFO_AOT_MODULE:
                break;
        case MONO_PATCH_INFO_SIGNATURE:
+       case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
                encode_signature (acfg, (MonoMethodSignature*)patch_info->data.target, p, &p);
                break;
        case MONO_PATCH_INFO_TLS_OFFSET:
@@ -7103,20 +7128,20 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
 
        if (cfg->exception_type == MONO_EXCEPTION_GENERIC_SHARING_FAILED) {
                if (acfg->aot_opts.print_skipped_methods)
-                       printf ("Skip (gshared failure): %s (%s)\n", mono_method_full_name (method, TRUE), cfg->exception_message);
+                       printf ("Skip (gshared failure): %s (%s)\n", mono_method_get_full_name (method), cfg->exception_message);
                InterlockedIncrement (&acfg->stats.genericcount);
                return;
        }
        if (cfg->exception_type != MONO_EXCEPTION_NONE) {
                if (acfg->aot_opts.print_skipped_methods)
-                       printf ("Skip (JIT failure): %s\n", mono_method_full_name (method, TRUE));
+                       printf ("Skip (JIT failure): %s\n", mono_method_get_full_name (method));
                /* Let the exception happen at runtime */
                return;
        }
 
        if (cfg->disable_aot) {
                if (acfg->aot_opts.print_skipped_methods)
-                       printf ("Skip (disabled): %s\n", mono_method_full_name (method, TRUE));
+                       printf ("Skip (disabled): %s\n", mono_method_get_full_name (method));
                InterlockedIncrement (&acfg->stats.ocount);
                mono_destroy_compile (cfg);
                return;
@@ -7159,7 +7184,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
 
        if (skip) {
                if (acfg->aot_opts.print_skipped_methods)
-                       printf ("Skip (abs call): %s\n", mono_method_full_name (method, TRUE));
+                       printf ("Skip (abs call): %s\n", mono_method_get_full_name (method));
                InterlockedIncrement (&acfg->stats.abscount);
                mono_destroy_compile (cfg);
                return;
@@ -7188,7 +7213,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
 
        if (skip) {
                if (acfg->aot_opts.print_skipped_methods)
-                       printf ("Skip (patches): %s\n", mono_method_full_name (method, TRUE));
+                       printf ("Skip (patches): %s\n", mono_method_get_full_name (method));
                acfg->stats.ocount++;
                mono_destroy_compile (cfg);
                mono_acfg_unlock (acfg);
@@ -7200,9 +7225,9 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
 
        if (method->is_inflated && acfg->aot_opts.log_instances) {
                if (acfg->instances_logfile)
-                       fprintf (acfg->instances_logfile, "%s ### %d\n", mono_method_full_name (method, TRUE), cfg->code_size);
+                       fprintf (acfg->instances_logfile, "%s ### %d\n", mono_method_get_full_name (method), cfg->code_size);
                else
-                       printf ("%s ### %d\n", mono_method_full_name (method, TRUE), cfg->code_size);
+                       printf ("%s ### %d\n", mono_method_get_full_name (method), cfg->code_size);
        }
 
        /* Adds generic instances referenced by this method */
@@ -7297,7 +7322,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
        if (!cfg->has_got_slots)
                InterlockedIncrement (&acfg->stats.methods_without_got_slots);
 
-       if (!cfg->method->wrapper_type)
+       if (!cfg->method->wrapper_type || cfg->method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE)
                /* These only need out wrappers */
                add_gsharedvt_wrappers (acfg, mono_method_signature (cfg->method), FALSE, TRUE);
 
@@ -8439,7 +8464,7 @@ emit_extra_methods (MonoAotCompile *acfg)
                value = get_method_index (acfg, method);
 
                hash = mono_aot_method_hash (method) % table_size;
-               //printf ("X: %s %x\n", mono_method_full_name (method, 1), mono_aot_method_hash (method));
+               //printf ("X: %s %x\n", mono_method_get_full_name (method), mono_aot_method_hash (method));
 
                chain_lengths [hash] ++;
                max_chain_length = MAX (max_chain_length, chain_lengths [hash]);
@@ -9305,7 +9330,7 @@ collect_methods (MonoAotCompile *acfg)
                                  (method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
                                  (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))) {
                                if (!mono_debug_lookup_method (method)) {
-                                       fprintf (stderr, "Method %s has no debug info, probably the .mdb file for the assembly is missing.\n", mono_method_full_name (method, TRUE));
+                                       fprintf (stderr, "Method %s has no debug info, probably the .mdb file for the assembly is missing.\n", mono_method_get_full_name (method));
                                        exit (1);
                                }
                        }
@@ -9750,8 +9775,7 @@ static void aot_dump (MonoAotCompile *acfg)
 
                mono_json_writer_indent (&writer);
                mono_json_writer_object_key(&writer, "signature");
-               mono_json_writer_printf (&writer, "\"%s\",\n", mono_method_full_name (method,
-                       /*signature=*/TRUE));
+               mono_json_writer_printf (&writer, "\"%s\",\n", mono_method_get_full_name (method));
 
                mono_json_writer_indent (&writer);
                mono_json_writer_object_key(&writer, "code_size");
@@ -9854,7 +9878,8 @@ static void aot_dump (MonoAotCompile *acfg)
 static const char *preinited_jit_icalls[] = {
        "mono_aot_init_llvm_method",
        "mono_aot_init_gshared_method_this",
-       "mono_aot_init_gshared_method_rgctx",
+       "mono_aot_init_gshared_method_mrgctx",
+       "mono_aot_init_gshared_method_vtable",
        "mono_llvm_throw_corlib_exception",
        "mono_init_vtable_slot",
        "mono_helper_ldstr_mscorlib"
@@ -9980,12 +10005,14 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 #ifndef ENABLE_GSHAREDVT
                aot_printerrf (acfg, "--aot=llvmonly requires a runtime compiled with --enable-gsharedvt.\n");
                return 1;
-#else
-               acfg->opts |= MONO_OPT_GSHAREDVT;
-               opts |= MONO_OPT_GSHAREDVT;
 #endif
        }
 
+#if defined(ENABLE_GSHAREDVT) && defined(MONO_ARCH_GSHAREDVT_SUPPORTED)
+       acfg->opts |= MONO_OPT_GSHAREDVT;
+       opts |= MONO_OPT_GSHAREDVT;
+#endif
+
        if (opts & MONO_OPT_GSHAREDVT)
                mono_set_generic_sharing_vt_supported (TRUE);
 
index 2289ed25607b5b6256c70f6fc94d9d8a1b30b4fd..28f72b83fb0a3451324f5d184a24eebaef330b61 100644 (file)
@@ -3012,7 +3012,11 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
                p += mono_seq_point_info_read (&seq_points, p, FALSE);
 
                mono_domain_lock (domain);
-               g_hash_table_insert (domain_jit_info (domain)->seq_points, method, seq_points);
+               /* This could be set already since this function can be called more than once for the same method */
+               if (!g_hash_table_lookup (domain_jit_info (domain)->seq_points, method))
+                       g_hash_table_insert (domain_jit_info (domain)->seq_points, method, seq_points);
+               else
+                       mono_seq_point_info_free (seq_points);
                mono_domain_unlock (domain);
        }
 
@@ -3540,6 +3544,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
        case MONO_PATCH_INFO_MSCORLIB_GOT_ADDR:
                break;
        case MONO_PATCH_INFO_SIGNATURE:
+       case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
                ji->data.target = decode_signature (aot_module, p, &p);
                break;
        case MONO_PATCH_INFO_TLS_OFFSET:
@@ -4167,7 +4172,7 @@ mono_aot_init_gshared_method_this (gpointer aot_module, guint32 method_index, Mo
 }
 
 void
-mono_aot_init_gshared_method_rgctx  (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx)
+mono_aot_init_gshared_method_mrgctx (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx)
 {
        MonoAotModule *amodule = (MonoAotModule *)aot_module;
        gboolean res;
@@ -4184,6 +4189,29 @@ mono_aot_init_gshared_method_rgctx  (gpointer aot_module, guint32 method_index,
        g_assert (res);
 }
 
+void
+mono_aot_init_gshared_method_vtable (gpointer aot_module, guint32 method_index, MonoVTable *vtable)
+{
+       MonoAotModule *amodule = (MonoAotModule *)aot_module;
+       gboolean res;
+       MonoClass *klass;
+       MonoGenericContext *context;
+       MonoMethod *method;
+
+       klass = vtable->klass;
+
+       amodule_lock (amodule);
+       method = (MonoMethod *)g_hash_table_lookup (amodule->extra_methods, GUINT_TO_POINTER (method_index));
+       amodule_unlock (amodule);
+
+       g_assert (method);
+       context = mono_method_get_context (method);
+       g_assert (context);
+
+       res = init_llvm_method (amodule, method_index, NULL, klass, context);
+       g_assert (res);
+}
+
 /*
  * mono_aot_get_method:
  *
@@ -4381,9 +4409,11 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
                }
 
                if (method_index == 0xffffff && method->is_inflated && mono_method_is_generic_sharable_full (method, FALSE, FALSE, TRUE)) {
+                       MonoMethod *shared;
                        /* gsharedvt */
                        /* Use the all-vt shared method since this is what was AOTed */
-                       method_index = find_aot_method (mini_get_shared_method_full (method, TRUE, TRUE), &amodule);
+                       shared = mini_get_shared_method_full (method, TRUE, TRUE);
+                       method_index = find_aot_method (shared, &amodule);
                        if (method_index != 0xffffff)
                                method = mini_get_shared_method_full (method, TRUE, FALSE);
                }
@@ -5606,7 +5636,12 @@ mono_aot_init_gshared_method_this (gpointer aot_module, guint32 method_index, Mo
 }
 
 void
-mono_aot_init_gshared_method_rgctx  (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx)
+mono_aot_init_gshared_method_mrgctx (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx)
+{
+}
+
+void
+mono_aot_init_gshared_method_vtable (gpointer aot_module, guint32 method_index, MonoVTable *vtable)
 {
 }
 
index a79e708282b296df8284d14cb19bbd5672601c3b..bd823f2b9062cce310ff2791ed9c39a5876c1d44 100644 (file)
@@ -443,4 +443,36 @@ class Tests
                var s1 = new FpStruct () { a = 1, b = 1, c = 10 };
                return pass_hfa_on_stack (s1, s1, s1);
        }
+
+       public static int test_0_get_current_method () {
+               var m = MethodBase.GetCurrentMethod ();
+#if __MOBILE__
+               var m2 = typeof (AotTests).GetMethod ("test_0_get_current_method");
+#else
+               var m2 = typeof (Tests).GetMethod ("test_0_get_current_method");
+#endif
+               return m == m2 ? 0 : 1;
+       }
+
+       class GetCurrentMethodClass<T> {
+               [MethodImplAttribute (MethodImplOptions.NoInlining)]
+               public MethodBase get_current () {
+                       return MethodBase.GetCurrentMethod ();
+               }
+       }
+
+       public static int test_0_get_current_method_generic () {
+               var c = new GetCurrentMethodClass<string> ();
+               var m = c.get_current ();
+               var m2 = typeof (GetCurrentMethodClass<>).GetMethod ("get_current");
+               return m == m2 ? 0 : 1;
+       }
+
+       public static int test_0_array_wrappers_runtime_invoke () {
+               string[][] arr = new string [10][];
+               IEnumerable<string[]> iface = arr;
+               var m = typeof(IEnumerable<string[]>).GetMethod ("GetEnumerator");
+               m.Invoke (arr, null);
+               return 0;
+       }
 }
index a8e6b3920eb370ed43e229f6f4ce9d1317dffe39..b527d51d54499f2f99c7cd9c42bc6876b98dc12a 100644 (file)
@@ -2387,7 +2387,7 @@ buffer_add_typeid (Buffer *buf, MonoDomain *domain, MonoClass *klass)
                if (is_debugger_thread ())
                        DEBUG_PRINTF (2, "[dbg]   send class [%s]\n", s);
                else
-                       DEBUG_PRINTF (2, "[%p]   send class [%s]\n", (gpointer)mono_native_thread_id_get (), s);
+                       DEBUG_PRINTF (2, "[%p]   send class [%s]\n", (gpointer) (gsize) mono_native_thread_id_get (), s);
                g_free (s);
        }
 }
@@ -2665,7 +2665,7 @@ notify_thread (gpointer key, gpointer value, gpointer user_data)
        if (mono_native_thread_id_equals (mono_native_thread_id_get (), tid) || tls->terminated)
                return;
 
-       DEBUG_PRINTF (1, "[%p] Interrupting %p...\n", (gpointer)mono_native_thread_id_get (), (gpointer)tid);
+       DEBUG_PRINTF (1, "[%p] Interrupting %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid);
 
        /* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
        InterruptData interrupt_data = { 0 };
@@ -2673,7 +2673,7 @@ notify_thread (gpointer key, gpointer value, gpointer user_data)
 
        mono_thread_info_safe_suspend_and_run ((MonoNativeThreadId)(gpointer)(gsize)thread->tid, FALSE, debugger_interrupt_critical, &interrupt_data);
        if (!interrupt_data.valid_info) {
-               DEBUG_PRINTF (1, "[%p] mono_thread_info_suspend_sync () failed for %p...\n", (gpointer)mono_native_thread_id_get (), (gpointer)tid);
+               DEBUG_PRINTF (1, "[%p] mono_thread_info_suspend_sync () failed for %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid);
                /* 
                 * Attached thread which died without detaching.
                 */
@@ -2704,7 +2704,7 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx)
        if (suspend_count - tls->resume_count > 0)
                tls->suspending = TRUE;
 
-       DEBUG_PRINTF (1, "[%p] Received single step event for suspending.\n", (gpointer)mono_native_thread_id_get ());
+       DEBUG_PRINTF (1, "[%p] Received single step event for suspending.\n", (gpointer) (gsize) mono_native_thread_id_get ());
 
        if (suspend_count - tls->resume_count == 0) {
                /* 
@@ -2712,7 +2712,7 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx)
                 * suspending is still active.
                 * FIXME: This slows down single threaded invokes.
                 */
-               DEBUG_PRINTF (1, "[%p] Ignored during single threaded invoke.\n", (gpointer)mono_native_thread_id_get ());
+               DEBUG_PRINTF (1, "[%p] Ignored during single threaded invoke.\n", (gpointer) (gsize) mono_native_thread_id_get ());
                return;
        }
 
@@ -2743,7 +2743,7 @@ suspend_vm (void)
 
        suspend_count ++;
 
-       DEBUG_PRINTF (1, "[%p] Suspending vm...\n", (gpointer)mono_native_thread_id_get ());
+       DEBUG_PRINTF (1, "[%p] Suspending vm...\n", (gpointer) (gsize) mono_native_thread_id_get ());
 
        if (suspend_count == 1) {
                // FIXME: Is it safe to call this inside the lock ?
@@ -2782,7 +2782,7 @@ resume_vm (void)
        g_assert (suspend_count > 0);
        suspend_count --;
 
-       DEBUG_PRINTF (1, "[%p] Resuming vm, suspend count=%d...\n", (gpointer)mono_native_thread_id_get (), suspend_count);
+       DEBUG_PRINTF (1, "[%p] Resuming vm, suspend count=%d...\n", (gpointer) (gsize) mono_native_thread_id_get (), suspend_count);
 
        if (suspend_count == 0) {
                // FIXME: Is it safe to call this inside the lock ?
@@ -2906,7 +2906,7 @@ suspend_current (void)
                mono_coop_sem_post (&suspend_sem);
        }
 
-       DEBUG_PRINTF (1, "[%p] Suspended.\n", (gpointer)mono_native_thread_id_get ());
+       DEBUG_PRINTF (1, "[%p] Suspended.\n", (gpointer) (gsize) mono_native_thread_id_get ());
 
        while (suspend_count - tls->resume_count > 0) {
                err = mono_coop_cond_wait (&suspend_cond, &suspend_mutex);
@@ -2920,7 +2920,7 @@ suspend_current (void)
 
        mono_coop_mutex_unlock (&suspend_mutex);
 
-       DEBUG_PRINTF (1, "[%p] Resumed.\n", (gpointer)mono_native_thread_id_get ());
+       DEBUG_PRINTF (1, "[%p] Resumed.\n", (gpointer) (gsize) mono_native_thread_id_get ());
 
        if (tls->pending_invoke) {
                /* Save the original context */
@@ -3736,7 +3736,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx
                vm_start_event_sent = TRUE;
        }
 
-       DEBUG_PRINTF (1, "[%p] Sent %d events %s(%d), suspend=%d.\n", (gpointer)mono_native_thread_id_get (), nevents, event_to_string (event), ecount, suspend_policy);
+       DEBUG_PRINTF (1, "[%p] Sent %d events %s(%d), suspend=%d.\n", (gpointer) (gsize) mono_native_thread_id_get (), nevents, event_to_string (event), ecount, suspend_policy);
 
        switch (suspend_policy) {
        case SUSPEND_POLICY_NONE:
@@ -4512,7 +4512,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t
                /*
                 * These seq points are inserted by the JIT after calls, step over needs to skip them.
                 */
-               DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping over, continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), sp->il_offset);
+               DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping over, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
                return FALSE;
        }
 
@@ -4522,7 +4522,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t
                compute_frame_info (tls->thread, tls);
                if (req->nframes && tls->frame_count && tls->frame_count > req->nframes) {
                        /* Hit the breakpoint in a recursive call */
-                       DEBUG_PRINTF (1, "[%p] Breakpoint at lower frame while stepping over, continuing single stepping.\n", (gpointer)mono_native_thread_id_get ());
+                       DEBUG_PRINTF (1, "[%p] Breakpoint at lower frame while stepping over, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get ());
                        return FALSE;
                }
        }
@@ -4533,7 +4533,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t
                        mono_thread_state_init_from_monoctx (&tls->context, ctx);
                compute_frame_info (tls->thread, tls);
                if (ss_req->start_method == method && req->nframes && tls->frame_count == req->nframes) {//Check also frame count(could be recursion)
-                       DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), sp->il_offset);
+                       DEBUG_PRINTF (1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
                        return FALSE;
                }
        }
@@ -4549,11 +4549,11 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t
                loc = mono_debug_method_lookup_location (minfo, sp->il_offset);
 
        if (!loc) {
-               DEBUG_PRINTF (1, "[%p] No line number info for il offset %x, continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), sp->il_offset);
+               DEBUG_PRINTF (1, "[%p] No line number info for il offset %x, continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), sp->il_offset);
                ss_req->last_method = method;
                hit = FALSE;
        } else if (loc && method == ss_req->last_method && loc->row == ss_req->last_line) {
-               DEBUG_PRINTF (1, "[%p] Same source line (%d), continuing single stepping.\n", (gpointer)mono_native_thread_id_get (), loc->row);
+               DEBUG_PRINTF (1, "[%p] Same source line (%d), continuing single stepping.\n", (gpointer) (gsize) mono_native_thread_id_get (), loc->row);
                hit = FALSE;
        }
                                
@@ -4626,7 +4626,7 @@ process_breakpoint_inner (DebuggerTlsData *tls, gboolean from_signal)
 
        g_assert (found_sp);
 
-       DEBUG_PRINTF (1, "[%p] Breakpoint hit, method=%s, ip=%p, [il=0x%x,native=0x%x].\n", (gpointer)mono_native_thread_id_get (), method->name, ip, sp.il_offset, native_offset);
+       DEBUG_PRINTF (1, "[%p] Breakpoint hit, method=%s, ip=%p, [il=0x%x,native=0x%x].\n", (gpointer) (gsize) mono_native_thread_id_get (), method->name, ip, sp.il_offset, native_offset);
 
        bp = NULL;
        for (i = 0; i < breakpoints->len; ++i) {
@@ -4733,7 +4733,7 @@ resume_from_signal_handler (void *sigctx, void *func)
        // FIXME: This might not work on an altstack ?
        tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
        if (!tls)
-               fprintf (stderr, "Thread %p is not attached to the JIT.\n", (gpointer)mono_native_thread_id_get ());
+               fprintf (stderr, "Thread %p is not attached to the JIT.\n", (gpointer) (gsize) mono_native_thread_id_get ());
        g_assert (tls);
 
        // FIXME: MonoContext usually doesn't include the fp registers, so these are 
@@ -4857,7 +4857,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal)
        if (log_level > 0) {
                ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, &domain);
 
-               DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer)mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp);
+               DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer) (gsize) mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp);
        }
 
        ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, &domain);
@@ -5877,7 +5877,7 @@ decode_vtype (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8
        if (t && klass != mono_class_from_mono_type (t)) {
                char *name = mono_type_full_name (t);
                char *name2 = mono_type_full_name (&klass->byval_arg);
-               DEBUG_PRINTF (1, "[%p] Expected value of type %s, got %s.\n", (gpointer)mono_native_thread_id_get (), name, name2);
+               DEBUG_PRINTF (1, "[%p] Expected value of type %s, got %s.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, name2);
                g_free (name);
                g_free (name2);
                return ERR_INVALID_ARGUMENT;
@@ -5913,7 +5913,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
                !(t->type == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) &&
                !(t->type == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) {
                char *name = mono_type_full_name (t);
-               DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer)mono_native_thread_id_get (), name, type);
+               DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, type);
                g_free (name);
                return ERR_INVALID_ARGUMENT;
        }
@@ -6057,7 +6057,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
                                g_free (vtype_buf);
                        } else {
                                char *name = mono_type_full_name (t);
-                               DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer)mono_native_thread_id_get (), name, type);
+                               DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, type);
                                g_free (name);
                                return ERR_INVALID_ARGUMENT;
                        }
@@ -6471,7 +6471,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
                 * Invoke this method directly, currently only Environment.Exit () is supported.
                 */
                this_arg = NULL;
-               DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer)mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
+               DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
                mono_runtime_invoke (invoke->method, NULL, invoke->args, &exc);
                g_assert_not_reached ();
        }
@@ -6489,7 +6489,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
                /* Should be null */
                int type = decode_byte (p, &p, end);
                if (type != VALUE_TYPE_ID_NULL) {
-                       DEBUG_PRINTF (1, "[%p] Error: Static vtype method invoked with this argument.\n", (gpointer)mono_native_thread_id_get ());
+                       DEBUG_PRINTF (1, "[%p] Error: Static vtype method invoked with this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
                        return ERR_INVALID_ARGUMENT;
                }
                memset (this_buf, 0, mono_class_instance_size (m->klass));
@@ -6519,7 +6519,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
 
        if (MONO_CLASS_IS_INTERFACE (m->klass)) {
                if (!this_arg) {
-                       DEBUG_PRINTF (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer)mono_native_thread_id_get ());
+                       DEBUG_PRINTF (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
                        return ERR_INVALID_ARGUMENT;
                }
                m = mono_object_get_virtual_method (this_arg, m);
@@ -6530,7 +6530,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
                }
        } else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !m->klass->valuetype && invoke->flags & INVOKE_FLAG_VIRTUAL) {
                if (!this_arg) {
-                       DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer)mono_native_thread_id_get ());
+                       DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ());
                        return ERR_INVALID_ARGUMENT;
                }
                m = mono_object_get_virtual_method (this_arg, m);
@@ -6540,7 +6540,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
                }
        }
 
-       DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer)mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
+       DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : "<null>");
 
        if (this_arg && this_arg->vtable->domain != domain)
                NOT_IMPLEMENTED;
@@ -6622,7 +6622,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
        else
                res = mono_runtime_invoke (m, this_arg, args, &exc);
        mono_stopwatch_stop (&watch);
-       DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer)mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch));
+       DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch));
        if (exc) {
                buffer_add_byte (buf, 0);
                buffer_add_value (buf, &mono_defaults.object_class->byval_arg, &exc, domain);
@@ -6770,7 +6770,7 @@ invoke_method (void)
                tls->resume_count -= invoke->suspend_count;
        }
 
-       DEBUG_PRINTF (1, "[%p] Invoke finished (%d), resume_count = %d.\n", (gpointer)mono_native_thread_id_get (), err, tls->resume_count);
+       DEBUG_PRINTF (1, "[%p] Invoke finished (%d), resume_count = %d.\n", (gpointer) (gsize) mono_native_thread_id_get (), err, tls->resume_count);
 
        /*
         * Take the loader lock to avoid race conditions with CMD_VM_ABORT_INVOKE:
@@ -9198,10 +9198,13 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                return err;
 
        MonoClass *obj_type;
+       gboolean remote_obj = FALSE;
 
        obj_type = obj->vtable->klass;
-       if (mono_class_is_transparent_proxy (obj_type))
+       if (mono_class_is_transparent_proxy (obj_type)) {
                obj_type = ((MonoTransparentProxy *)obj)->remote_class->proxy_class;
+               remote_obj = TRUE;
+       }
 
        g_assert (obj_type);
 
@@ -9243,7 +9246,19 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
                                buffer_add_value (buf, f->type, val, obj->vtable->domain);
                                g_free (val);
                        } else {
-                               buffer_add_value (buf, f->type, (guint8*)obj + f->offset, obj->vtable->domain);
+                               guint8 *field_value = NULL;
+                               void *field_storage = NULL;
+
+                               if (remote_obj) {
+#ifndef DISABLE_REMOTING
+                                       field_value = mono_load_remote_field(obj, obj_type, f, &field_storage);
+#else
+                                       g_assert_not_reached ();
+#endif
+                               } else
+                                       field_value = (guint8*)obj + f->offset;
+
+                               buffer_add_value (buf, f->type, field_value, obj->vtable->domain);
                        }
                }
                break;
@@ -9590,7 +9605,7 @@ debugger_thread (void *arg)
        gboolean no_reply;
        gboolean attach_failed = FALSE;
 
-       DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer)mono_native_thread_id_get ());
+       DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer) (gsize) mono_native_thread_id_get ());
 
        debugger_thread_id = mono_native_thread_id_get ();
 
index 2899a1e91838ffda2f0a30771e3a01e09f2b7e61..1bb364a588d0174fbc365cdecae98541730b7e2a 100644 (file)
@@ -519,8 +519,6 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins)
        }
 
        if (emulate) {
-               MonoJitICallInfo *info = NULL;
-
 #if SIZEOF_REGISTER == 8
                if (decompose_long_opcode (cfg, ins, &repl))
                        emulate = FALSE;
@@ -529,33 +527,8 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins)
                        emulate = FALSE;
 #endif
 
-               if (emulate)
-                       info = mono_find_jit_opcode_emulation (ins->opcode);
-               if (info) {
-                       MonoInst **args;
-                       MonoInst *call;
-
-                       /* Create dummy MonoInst's for the arguments */
-                       g_assert (!info->sig->hasthis);
-                       g_assert (info->sig->param_count <= MONO_MAX_SRC_REGS);
-
-                       args = (MonoInst **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst*) * info->sig->param_count);
-                       if (info->sig->param_count > 0) {
-                               int sregs [MONO_MAX_SRC_REGS];
-                               int num_sregs, i;
-                               num_sregs = mono_inst_get_src_registers (ins, sregs);
-                               g_assert (num_sregs == info->sig->param_count);
-                               for (i = 0; i < num_sregs; ++i) {
-                                       MONO_INST_NEW (cfg, args [i], OP_ARG);
-                                       args [i]->dreg = sregs [i];
-                               }
-                       }
-
-                       call = mono_emit_jit_icall_by_info (cfg, info, args);
-                       call->dreg = ins->dreg;
-
-                       NULLIFY_INS (ins);
-               }
+               if (emulate && mono_find_jit_opcode_emulation (ins->opcode))
+                       cfg->has_emulated_ops = TRUE;
        }
 
        if (ins->opcode == OP_NOP) {
@@ -614,8 +587,6 @@ mono_decompose_long_opts (MonoCompile *cfg)
         * needs to be able to handle long vregs.
         */
 
-       /* reg + 1 contains the ls word, reg + 2 contains the ms word */
-
        /**
         * Create a dummy bblock and emit code into it so we can use the normal 
         * code generation macros.
@@ -638,28 +609,28 @@ mono_decompose_long_opts (MonoCompile *cfg)
 
                        switch (tree->opcode) {
                        case OP_I8CONST:
-                               MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 1, tree->inst_ls_word);
-                               MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 2, tree->inst_ms_word);
+                               MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (tree->dreg), tree->inst_ls_word);
+                               MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), tree->inst_ms_word);
                                break;
                        case OP_DUMMY_I8CONST:
-                               MONO_EMIT_NEW_DUMMY_INIT (cfg, tree->dreg + 1, OP_DUMMY_ICONST);
-                               MONO_EMIT_NEW_DUMMY_INIT (cfg, tree->dreg + 2, OP_DUMMY_ICONST);
+                               MONO_EMIT_NEW_DUMMY_INIT (cfg, MONO_LVREG_LS (tree->dreg), OP_DUMMY_ICONST);
+                               MONO_EMIT_NEW_DUMMY_INIT (cfg, MONO_LVREG_MS (tree->dreg), OP_DUMMY_ICONST);
                                break;
                        case OP_LMOVE:
                        case OP_LCONV_TO_U8:
                        case OP_LCONV_TO_I8:
                        case OP_LCONV_TO_OVF_U8_UN:
                        case OP_LCONV_TO_OVF_I8:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1 + 1);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 2, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
                                break;
                        case OP_STOREI8_MEMBASE_REG:
-                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, tree->inst_destbasereg, tree->inst_offset + MINI_MS_WORD_OFFSET, tree->sreg1 + 2);
-                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, tree->inst_destbasereg, tree->inst_offset + MINI_LS_WORD_OFFSET, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, tree->inst_destbasereg, tree->inst_offset + MINI_MS_WORD_OFFSET, MONO_LVREG_MS (tree->sreg1));
+                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, tree->inst_destbasereg, tree->inst_offset + MINI_LS_WORD_OFFSET, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LOADI8_MEMBASE:
-                               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, tree->dreg + 2, tree->inst_basereg, tree->inst_offset + MINI_MS_WORD_OFFSET);
-                               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, tree->dreg + 1, tree->inst_basereg, tree->inst_offset + MINI_LS_WORD_OFFSET);
+                               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, MONO_LVREG_MS (tree->dreg), tree->inst_basereg, tree->inst_offset + MINI_MS_WORD_OFFSET);
+                               MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, MONO_LVREG_LS (tree->dreg), tree->inst_basereg, tree->inst_offset + MINI_LS_WORD_OFFSET);
                                break;
 
                        case OP_ICONV_TO_I8: {
@@ -670,108 +641,114 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                 * tmp = low > -1 ? 1: 0;
                                 * high = tmp - 1; if low is zero or pos high becomes 0, else -1
                                 */
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, tree->dreg + 1, -1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), tree->sreg1);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, MONO_LVREG_LS (tree->dreg), -1);
                                MONO_EMIT_NEW_BIALU (cfg, OP_ICGT, tmpreg, -1, -1);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISUB_IMM, tree->dreg + 2, tmpreg, 1);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ISUB_IMM, MONO_LVREG_MS (tree->dreg), tmpreg, 1);
                                break;
                        }
                        case OP_ICONV_TO_U8:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1);
-                               MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 2, 0);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), tree->sreg1);
+                               MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
                                break;
                        case OP_ICONV_TO_OVF_I8:
                                /* a signed 32 bit num always fits in a signed 64 bit one */
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_IMM, tree->dreg + 2, tree->sreg1, 31);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_IMM, MONO_LVREG_MS (tree->dreg), tree->sreg1, 31);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), tree->sreg1);
                                break;
                        case OP_ICONV_TO_OVF_U8:
                                MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1, 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
-                               MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 2, 0);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1);
+                               MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), tree->sreg1);
                                break;
                        case OP_ICONV_TO_OVF_I8_UN:
                        case OP_ICONV_TO_OVF_U8_UN:
                                /* an unsigned 32 bit num always fits in an (un)signed 64 bit one */
-                               MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 2, 0);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1);
+                               MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), tree->sreg1);
                                break;
                        case OP_LCONV_TO_I1:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_U1:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_U1, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_U1, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_I2:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_U2:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_U2, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_U2, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_I4:
                        case OP_LCONV_TO_U4:
                        case OP_LCONV_TO_I:
                        case OP_LCONV_TO_U:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
+#ifndef MONO_ARCH_EMULATE_LCONV_TO_R8
                        case OP_LCONV_TO_R8:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_R8_2, tree->dreg, tree->sreg1 + 1, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_R8_2, tree->dreg, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_MS (tree->sreg1));
                                break;
+#endif
+#ifndef MONO_ARCH_EMULATE_LCONV_TO_R4
                        case OP_LCONV_TO_R4:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_R4_2, tree->dreg, tree->sreg1 + 1, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_R4_2, tree->dreg, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_MS (tree->sreg1));
                                break;
+#endif
+#ifndef MONO_ARCH_EMULATE_LCONV_TO_R8_UN
                        case OP_LCONV_TO_R_UN:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_R_UN_2, tree->dreg, tree->sreg1 + 1, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_R_UN_2, tree->dreg, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_MS (tree->sreg1));
                                break;
+#endif
                        case OP_LCONV_TO_OVF_I1: {
                                MonoBasicBlock *is_negative, *end_label;
 
                                NEW_BBLOCK (cfg, is_negative);
                                NEW_BBLOCK (cfg, end_label);
 
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException");
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, -1);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), -1);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
 
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBLT, is_negative);
 
                                /* Positive */
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, 127);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), 127);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException");
                                MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_label);
 
                                /* Negative */
                                MONO_START_BB (cfg, is_negative);
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, -128);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), -128);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT_UN, "OverflowException");
 
                                MONO_START_BB (cfg, end_label);
 
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        }
                        case OP_LCONV_TO_OVF_I1_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "OverflowException");
 
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, 127);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), 127);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException");
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, -128);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), -128);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I1, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_OVF_U1:
                        case OP_LCONV_TO_OVF_U1_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "OverflowException");
 
                                /* probe value to be within 0 to 255 */
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, 255);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), 255);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException");
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, tree->dreg, tree->sreg1 + 1, 0xff);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, tree->dreg, MONO_LVREG_LS (tree->sreg1), 0xff);
                                break;
                        case OP_LCONV_TO_OVF_I2: {
                                MonoBasicBlock *is_negative, *end_label;
@@ -779,132 +756,132 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                NEW_BBLOCK (cfg, is_negative);
                                NEW_BBLOCK (cfg, end_label);
 
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException");
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, -1);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), -1);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
 
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBLT, is_negative);
 
                                /* Positive */
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, 32767);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), 32767);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException");
                                MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_label);
 
                                /* Negative */
                                MONO_START_BB (cfg, is_negative);
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, -32768);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), -32768);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT_UN, "OverflowException");
                                MONO_START_BB (cfg, end_label);
 
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        }
                        case OP_LCONV_TO_OVF_I2_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "OverflowException");
 
                                /* Probe value to be within -32768 and 32767 */
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, 32767);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), 32767);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT, "OverflowException");
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, -32768);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), -32768);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
-                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_ICONV_TO_I2, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_OVF_U2:
                        case OP_LCONV_TO_OVF_U2_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "OverflowException");
 
                                /* Probe value to be within 0 and 65535 */
-                               MONO_EMIT_NEW_COMPARE_IMM (cfg, tree->sreg1 + 1, 0xffff);
+                               MONO_EMIT_NEW_COMPARE_IMM (cfg, MONO_LVREG_LS (tree->sreg1), 0xffff);
                                MONO_EMIT_NEW_COND_EXC (cfg, GT_UN, "OverflowException");
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, tree->dreg, tree->sreg1 + 1, 0xffff);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, tree->dreg, MONO_LVREG_LS (tree->sreg1), 0xffff);
                                break;
                        case OP_LCONV_TO_OVF_I4:
                        case OP_LCONV_TO_OVF_I:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_OVF_I4_2, tree->dreg, tree->sreg1 + 1, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_LCONV_TO_OVF_I4_2, tree->dreg, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_MS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_OVF_U4:
                        case OP_LCONV_TO_OVF_U:
                        case OP_LCONV_TO_OVF_U4_UN:
                        case OP_LCONV_TO_OVF_U_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "OverflowException");
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_OVF_I_UN:
                        case OP_LCONV_TO_OVF_I4_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, NE_UN, "OverflowException");
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 1, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_LS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg, tree->sreg1 + 1);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg, MONO_LVREG_LS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_OVF_U8:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
 
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1 + 1);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 2, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
                                break;
                        case OP_LCONV_TO_OVF_I8_UN:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, tree->sreg1 + 2, 0);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, MONO_LVREG_MS (tree->sreg1), 0);
                                MONO_EMIT_NEW_COND_EXC (cfg, LT, "OverflowException");
 
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1 + 1);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 2, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
                                break;
 
                        case OP_LADD:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IADDCC, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IADC, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IADDCC, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IADC, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                break;
                        case OP_LSUB:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_ISUBCC, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_ISBB, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_ISUBCC, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_ISBB, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                break;
 
                        case OP_LADD_OVF:
                                /* ADC sets the condition code */
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IADDCC, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IADC, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IADDCC, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IADC, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                MONO_EMIT_NEW_COND_EXC (cfg, OV, "OverflowException");
                                break;
                        case OP_LADD_OVF_UN:
                                /* ADC sets the condition code */
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IADDCC, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IADC, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IADDCC, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IADC, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                MONO_EMIT_NEW_COND_EXC (cfg, C, "OverflowException");
                                break;
                        case OP_LSUB_OVF:
                                /* SBB sets the condition code */
-                               MONO_EMIT_NEW_BIALU (cfg, OP_ISUBCC, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_ISBB, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_ISUBCC, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_ISBB, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                MONO_EMIT_NEW_COND_EXC (cfg, OV, "OverflowException");
                                break;
                        case OP_LSUB_OVF_UN:
                                /* SBB sets the condition code */
-                               MONO_EMIT_NEW_BIALU (cfg, OP_ISUBCC, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_ISBB, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_ISUBCC, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_ISBB, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                MONO_EMIT_NEW_COND_EXC (cfg, C, "OverflowException");
                                break;
                        case OP_LAND:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IAND, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IAND, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IAND, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IAND, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                break;
                        case OP_LOR:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IOR, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IOR, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IOR, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                break;
                        case OP_LXOR:
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, tree->dreg + 1, tree->sreg1 + 1, tree->sreg2 + 1);
-                               MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, tree->dreg + 2, tree->sreg1 + 2, tree->sreg2 + 2);
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                               MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                break;
                        case OP_LNOT:
-                               MONO_EMIT_NEW_UNALU (cfg, OP_INOT, tree->dreg + 1, tree->sreg1 + 1);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_INOT, tree->dreg + 2, tree->sreg1 + 2);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_INOT, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
+                               MONO_EMIT_NEW_UNALU (cfg, OP_INOT, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
                                break;
                        case OP_LNEG:
                                /* Handled in mono_arch_decompose_long_opts () */
@@ -916,24 +893,24 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                break;
 
                        case OP_LADD_IMM:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADDCC_IMM, tree->dreg + 1, tree->sreg1 + 1, tree->inst_ls_word);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADC_IMM, tree->dreg + 2, tree->sreg1 + 2, tree->inst_ms_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADDCC_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADC_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
                        case OP_LSUB_IMM:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUBCC_IMM, tree->dreg + 1, tree->sreg1 + 1, tree->inst_ls_word);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SBB_IMM, tree->dreg + 2, tree->sreg1 + 2, tree->inst_ms_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SUBCC_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SBB_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
                        case OP_LAND_IMM:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, tree->dreg + 1, tree->sreg1 + 1, tree->inst_ls_word);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, tree->dreg + 2, tree->sreg1 + 2, tree->inst_ms_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_AND_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
                        case OP_LOR_IMM:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_OR_IMM, tree->dreg + 1, tree->sreg1 + 1, tree->inst_ls_word);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_OR_IMM, tree->dreg + 2, tree->sreg1 + 2, tree->inst_ms_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_OR_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_OR_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
                        case OP_LXOR_IMM:
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, tree->dreg + 1, tree->sreg1 + 1, tree->inst_ls_word);
-                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, tree->dreg + 2, tree->sreg1 + 2, tree->inst_ms_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_LS (tree->dreg), MONO_LVREG_LS (tree->sreg1), tree->inst_ls_word);
+                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, MONO_LVREG_MS (tree->dreg), MONO_LVREG_MS (tree->sreg1), tree->inst_ms_word);
                                break;
                        case OP_LSHR_UN_IMM:
                                if (tree->inst_c1 == 32) {
@@ -945,15 +922,15 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                         */
                                        /* FIXME: Move this to the strength reduction pass */
                                        /* just move the upper half to the lower and zero the high word */
-                                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 1, tree->sreg1 + 2);
-                                       MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 2, 0);
+                                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (tree->dreg), MONO_LVREG_MS (tree->sreg1));
+                                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_MS (tree->dreg), 0);
                                }
                                break;
                        case OP_LSHL_IMM:
                                if (tree->inst_c1 == 32) {
                                        /* just move the lower half to the upper and zero the lower word */
-                                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, tree->dreg + 2, tree->sreg1 + 1);
-                                       MONO_EMIT_NEW_ICONST (cfg, tree->dreg + 1, 0);
+                                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (tree->dreg), MONO_LVREG_LS (tree->sreg1));
+                                       MONO_EMIT_NEW_ICONST (cfg, MONO_LVREG_LS (tree->dreg), 0);
                                }
                                break;
 
@@ -970,8 +947,8 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                        /* Branchless version based on gcc code */
                                        d1 = alloc_ireg (cfg);
                                        d2 = alloc_ireg (cfg);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d1, tree->sreg1 + 1, tree->sreg2 + 1);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d2, tree->sreg1 + 2, tree->sreg2 + 2);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d1, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d2, MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                        MONO_EMIT_NEW_BIALU (cfg, OP_IOR, d1, d1, d2);
                                        MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, d1, 0);
                                        MONO_EMIT_NEW_BRANCH_BLOCK2 (cfg, next->opcode == OP_LBEQ ? OP_IBEQ : OP_IBNE_UN, next->inst_true_bb, next->inst_false_bb);
@@ -987,11 +964,11 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                case OP_LBLE_UN:
                                case OP_LBLT_UN:
                                        /* Convert into three comparisons + branches */
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, tree->sreg1 + 2, tree->sreg2 + 2);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, lbr_decomp [next->opcode - OP_LBEQ][0], next->inst_true_bb);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, tree->sreg1 + 2, tree->sreg2 + 2);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBNE_UN, next->inst_false_bb);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, tree->sreg1 + 1, tree->sreg2 + 1);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
                                        MONO_EMIT_NEW_BRANCH_BLOCK2 (cfg, lbr_decomp [next->opcode - OP_LBEQ][1], next->inst_true_bb, next->inst_false_bb);
                                        NULLIFY_INS (next);
                                        break;
@@ -1001,8 +978,8 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                        /* Branchless version based on gcc code */
                                        d1 = alloc_ireg (cfg);
                                        d2 = alloc_ireg (cfg);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d1, tree->sreg1 + 1, tree->sreg2 + 1);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d2, tree->sreg1 + 2, tree->sreg2 + 2);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d1, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_IXOR, d2, MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                        MONO_EMIT_NEW_BIALU (cfg, OP_IOR, d1, d1, d2);
 
                                        MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, d1, 0);
@@ -1020,11 +997,11 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                        NEW_BBLOCK (cfg, set_to_1);
 
                                        MONO_EMIT_NEW_ICONST (cfg, next->dreg, 0);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, tree->sreg1 + 2, tree->sreg2 + 2);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, lcset_decomp [next->opcode - OP_LCEQ][0], set_to_0);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, tree->sreg1 + 2, tree->sreg2 + 2);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, MONO_LVREG_MS (tree->sreg1), MONO_LVREG_MS (tree->sreg2));
                                        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBNE_UN, set_to_1);
-                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, tree->sreg1 + 1, tree->sreg2 + 1);
+                                       MONO_EMIT_NEW_BIALU (cfg, OP_COMPARE, -1, MONO_LVREG_LS (tree->sreg1), MONO_LVREG_LS (tree->sreg2));
                                        MONO_EMIT_NEW_BRANCH_BLOCK (cfg, lcset_decomp [next->opcode - OP_LCEQ][1], set_to_0);
                                        MONO_START_BB (cfg, set_to_1);
                                        MONO_EMIT_NEW_ICONST (cfg, next->dreg, 1);
@@ -1043,8 +1020,8 @@ mono_decompose_long_opts (MonoCompile *cfg)
                                MonoInst *next = mono_inst_next (tree, FILTER_IL_SEQ_POINT);
                                guint32 low_imm = tree->inst_ls_word;
                                guint32 high_imm = tree->inst_ms_word;
-                               int low_reg = tree->sreg1 + 1;
-                               int high_reg = tree->sreg1 + 2;
+                               int low_reg = MONO_LVREG_LS (tree->sreg1);
+                               int high_reg = MONO_LVREG_MS (tree->sreg1);
 
                                g_assert (next);
 
@@ -1409,8 +1386,8 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
                                                                break;
                                                        }
                                                        call2->inst.dreg = alloc_lreg (cfg);
-                                                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, dest->dreg, MINI_MS_WORD_OFFSET, call2->inst.dreg + 2);
-                                                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, dest->dreg, MINI_LS_WORD_OFFSET, call2->inst.dreg + 1);
+                                                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, dest->dreg, MINI_MS_WORD_OFFSET, MONO_LVREG_MS (call2->inst.dreg));
+                                                       MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, dest->dreg, MINI_LS_WORD_OFFSET, MONO_LVREG_LS (call2->inst.dreg));
 #else
                                                        MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI8_MEMBASE_REG, dest->dreg, 0, call2->inst.dreg);
 #endif
@@ -1644,19 +1621,19 @@ mono_decompose_soft_float (MonoCompile *cfg)
                                        break;
                                case OP_FGETLOW32:
                                        ins->opcode = OP_MOVE;
-                                       ins->sreg1 = ins->sreg1 + 1;
+                                       ins->sreg1 = MONO_LVREG_LS (ins->sreg1);
                                        break;
                                case OP_FGETHIGH32:
                                        ins->opcode = OP_MOVE;
-                                       ins->sreg1 = ins->sreg1 + 2;
+                                       ins->sreg1 = MONO_LVREG_MS (ins->sreg1);
                                        break;
                                case OP_SETFRET: {
                                        int reg = ins->sreg1;
 
                                        ins->opcode = OP_SETLRET;
                                        ins->dreg = -1;
-                                       ins->sreg1 = reg + 1;
-                                       ins->sreg2 = reg + 2;
+                                       ins->sreg1 = MONO_LVREG_LS (reg);
+                                       ins->sreg2 = MONO_LVREG_MS (reg);
                                        break;
                                }
                                case OP_LOADR8_MEMBASE:
@@ -1881,4 +1858,89 @@ mono_decompose_soft_float (MonoCompile *cfg)
 
 #endif
 
+void
+mono_local_emulate_ops (MonoCompile *cfg)
+{
+       MonoBasicBlock *bb;
+       gboolean inlined_wrapper = FALSE;
+
+       for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
+               MonoInst *ins;
+
+               MONO_BB_FOR_EACH_INS (bb, ins) {
+                       int op_noimm = mono_op_imm_to_op (ins->opcode);
+                       MonoJitICallInfo *info;
+
+                       /*
+                        * Emulation can't handle _IMM ops. If this is an imm opcode we need
+                        * to check whether its non-imm counterpart is emulated and, if so,
+                        * decompose it back to its non-imm counterpart.
+                        */
+                       if (op_noimm != -1)
+                               info = mono_find_jit_opcode_emulation (op_noimm);
+                       else
+                               info = mono_find_jit_opcode_emulation (ins->opcode);
+
+                       if (info) {
+                               MonoInst **args;
+                               MonoInst *call;
+                               MonoBasicBlock *first_bb;
+
+                               /* Create dummy MonoInst's for the arguments */
+                               g_assert (!info->sig->hasthis);
+                               g_assert (info->sig->param_count <= MONO_MAX_SRC_REGS);
+
+                               if (op_noimm != -1)
+                                       mono_decompose_op_imm (cfg, bb, ins);
+
+                               args = (MonoInst **)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst*) * info->sig->param_count);
+                               if (info->sig->param_count > 0) {
+                                       int sregs [MONO_MAX_SRC_REGS];
+                                       int num_sregs, i;
+                                       num_sregs = mono_inst_get_src_registers (ins, sregs);
+                                       g_assert (num_sregs == info->sig->param_count);
+                                       for (i = 0; i < num_sregs; ++i) {
+                                               MONO_INST_NEW (cfg, args [i], OP_ARG);
+                                               args [i]->dreg = sregs [i];
+                                       }
+                               }
+
+                               /* We emit the call on a separate dummy basic block */
+                               cfg->cbb = mono_mempool_alloc0 ((cfg)->mempool, sizeof (MonoBasicBlock));
+                               first_bb = cfg->cbb;
+
+                               call = mono_emit_jit_icall_by_info (cfg, info, args);
+                               call->dreg = ins->dreg;
+
+                               /* Replace ins with the emitted code and do the necessary bb linking */
+                               if (cfg->cbb->code || (cfg->cbb != first_bb)) {
+                                       MonoInst *saved_prev = ins->prev;
+
+                                       mono_replace_ins (cfg, bb, ins, &ins->prev, first_bb, cfg->cbb);
+                                       first_bb->code = first_bb->last_ins = NULL;
+                                       first_bb->in_count = first_bb->out_count = 0;
+                                       cfg->cbb = first_bb;
+
+                                       /* ins is hanging, continue scanning the emitted code */
+                                       ins = saved_prev;
+                               } else {
+                                       g_error ("Failed to emit emulation code");
+                               }
+                               inlined_wrapper = TRUE;
+                       }
+               }
+       }
+
+       /*
+        * Avoid rerunning these passes by emitting directly the exception checkpoint
+        * at IR level, instead of inlining the icall wrapper. FIXME
+        */
+       if (inlined_wrapper) {
+               if (!COMPILE_LLVM (cfg))
+                       mono_decompose_long_opts (cfg);
+               if (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP))
+                       mono_local_cprop (cfg);
+       }
+}
+
 #endif /* DISABLE_JIT */
index ab0fab80d49bfbb5d9276f9e7c8559a7b94ca46d..c801bd9ed21d3244b451647ca88523541a1cc15d 100644 (file)
@@ -50,6 +50,7 @@
 #include <mono/metadata/attach.h>
 #include "mono/utils/mono-counters.h"
 #include "mono/utils/mono-hwcap.h"
+#include "mono/utils/mono-logger-internals.h"
 
 #include "mini.h"
 #include "jit.h"
@@ -1574,7 +1575,7 @@ mono_main (int argc, char* argv[])
 #if TARGET_OSX
        darwin_change_default_file_handles ();
 #endif
-       
+
        if (g_getenv ("MONO_NO_SMP"))
                mono_set_use_smp (FALSE);
        
@@ -2240,8 +2241,9 @@ mono_jit_init (const char *file)
  * (since Mono does not support having more than one mscorlib runtime
  * loaded at once).
  *
- * The @runtime_version can be one of these strings: "v1.1.4322" for
- * the 1.1 runtime or "v2.0.50727"  for the 2.0 runtime. 
+ * The @runtime_version can be one of these strings: "v4.0.30319" for
+ * desktop, "mobile" for mobile or "moonlight" for Silverlight compat.
+ * If an unrecognized string is input, the vm will default to desktop.
  *
  * Returns: the MonoDomain representing the domain where the assembly
  * was loaded.
index e84abc68b019d0994e72115d53373ee2097a8f99..98c6046e61a5cdea5dab273ee1b289d63c26a7b5 100644 (file)
@@ -2318,6 +2318,7 @@ class Tests
                Console.WriteLine ();
        }
 
+       [Category ("!BITCODE")]
        public static int test_0_rethrow_stacktrace () {
                // Check that rethrowing an exception preserves the original stack trace
                try {
index bf1353f8eed6f5cc3a0928e1c59594f0391884d3..1284cb292ae733f3f58dc8b78c5a07d72d31e488 100644 (file)
@@ -999,7 +999,6 @@ class Tests
        public static int test_0_fullaot_variant_iface () {
                var arr = new BClass [10];
                var enumerable = (IEnumerable<AClass>)arr;
-               Console.WriteLine (enumerable);
                enumerable.GetEnumerator ();
                return 0;
        }
@@ -1245,6 +1244,34 @@ class Tests
                test("a", "b", "c", "d", "e", "f", "g", "h");
                return delegate_8_args_res == "h" ? 0 : 1;
        }
+
+       static void throw_catch_t<T> () where T: Exception {
+               try {
+                       throw new NotSupportedException ();
+               } catch (T) {
+               }
+       }
+
+       public static int test_0_gshared_catch_open_type () {
+               throw_catch_t<NotSupportedException> ();
+               return 0;
+       }
+
+       class ThrowClass<T> where T: Exception {
+               public void throw_catch_t () {
+                       try {
+                               throw new NotSupportedException ();
+                       } catch (T) {
+                       }
+               }
+       }
+
+       public static int test_0_gshared_catch_open_type_instance () {
+               var c = new ThrowClass<NotSupportedException> ();
+               c.throw_catch_t ();
+               return 0;
+       }
+
 }
 
 #if !__MOBILE__
index 48a3e4416315c97845cd8008ec433f47f67f3979..7f54d4b709de41ca9f2aff2ddfbcf7371375014d 100644 (file)
@@ -464,6 +464,21 @@ public class Tests
                return 0;
        }
 
+       class DelClass {
+               [MethodImplAttribute (MethodImplOptions.NoInlining)]
+               public static T return_t<T> (T t) {
+                       return t;
+               }
+       }
+
+       public static int test_0_gsharedvt_in_delegates_reflection () {
+               var m = typeof(DelClass).GetMethod ("return_t").MakeGenericMethod (new Type [] { typeof (int) });
+               Func<int, int> f = (Func<int, int>)Delegate.CreateDelegate (typeof (Func<int,int>), null, m, false);
+               if (f (42) != 42)
+                       return 1;
+               return 0;
+       }
+
        [MethodImplAttribute (MethodImplOptions.NoInlining)]
        static T return2_t<T> (T t) {
                return return_t (t);
index b9ed1784a5643c47f95c11fb39edaf9e0699cfe6..8f7b81b30a217b43f87cf259b4fd02b59454e039 100644 (file)
@@ -340,7 +340,7 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg)
         (dest)->dreg = alloc_dreg ((cfg), STACK_MP); \
                (cfg)->has_indirection = TRUE;  \
                          if (G_UNLIKELY (cfg->gsharedvt) && mini_is_gsharedvt_variable_type ((var)->inst_vtype)) { handle_gsharedvt_ldaddr ((cfg)); } \
-               if (SIZEOF_REGISTER == 4 && DECOMPOSE_INTO_REGPAIR ((var)->type)) { MonoInst *var1 = get_vreg_to_inst (cfg, (var)->dreg + 1); MonoInst *var2 = get_vreg_to_inst (cfg, (var)->dreg + 2); g_assert (var1); g_assert (var2); var1->flags |= MONO_INST_INDIRECT; var2->flags |= MONO_INST_INDIRECT; } \
+               if (SIZEOF_REGISTER == 4 && DECOMPOSE_INTO_REGPAIR ((var)->type)) { MonoInst *var1 = get_vreg_to_inst (cfg, MONO_LVREG_LS ((var)->dreg)); MonoInst *var2 = get_vreg_to_inst (cfg, MONO_LVREG_MS ((var)->dreg)); g_assert (var1); g_assert (var2); var1->flags |= MONO_INST_INDIRECT; var2->flags |= MONO_INST_INDIRECT; } \
        } while (0)
 
 #define NEW_VARSTORE(cfg,dest,var,vartype,inst) do {   \
index ef3e7a4e45a0d0f2973cdcbd960bc3768e0840e1..49e516545a3c131f27d86795b436f315b1686fdc 100644 (file)
@@ -1611,66 +1611,43 @@ mono_init_vtable_slot (MonoVTable *vtable, int slot)
        return ftnptr;
 }
 
-static gboolean
-is_callee_gsharedvt_variable (gpointer addr)
-{
-       MonoJitInfo *ji;
-       gboolean callee_gsharedvt;
-
-       ji = mini_jit_info_table_find (mono_domain_get (), (char *)mono_get_addr_from_ftnptr (addr), NULL);
-       g_assert (ji);
-       callee_gsharedvt = mini_jit_info_is_gsharedvt (ji);
-       if (callee_gsharedvt)
-               callee_gsharedvt = mini_is_gsharedvt_variable_signature (mono_method_signature (jinfo_get_method (ji)));
-       return callee_gsharedvt;
-}
-
 /*
- * mono_init_delegate:
+ * mono_llvmonly_init_delegate:
  *
  *   Initialize a MonoDelegate object.
  * Similar to mono_delegate_ctor ().
  */
 void
-mono_init_delegate (MonoDelegate *del, MonoObject *target, MonoMethod *method)
+mono_llvmonly_init_delegate (MonoDelegate *del)
 {
-       MONO_OBJECT_SETREF (del, target, target);
-       del->method = method;
-       del->method_ptr = mono_compile_method (method);
-
-       if (mono_method_needs_static_rgctx_invoke (method, FALSE))
-               del->rgctx = mini_method_get_rgctx (method);
-
        /*
-        * Avoid adding gsharedvt in wrappers since they might not exist if
-        * this delegate is called through a gsharedvt delegate invoke wrapper.
-        * Instead, encode that the method is gsharedvt in del->rgctx,
-        * the CEE_MONO_CALLI_EXTRA_ARG implementation in the JIT depends on this.
+        * We store a MonoFtnDesc in del->method_code.
         */
-       if (is_callee_gsharedvt_variable (del->method_ptr)) {
-               g_assert ((((mgreg_t)del->rgctx) & 1) == 0);
-               del->rgctx = (gpointer)(((mgreg_t)del->rgctx) | 1);
+       MonoFtnDesc *ftndesc = *(MonoFtnDesc**)del->method_code;
+
+       if (G_UNLIKELY (!ftndesc)) {
+               gpointer addr = mono_compile_method (del->method);
+               gpointer arg = mini_get_delegate_arg (del->method, addr);
+
+               ftndesc = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, arg);
+               mono_memory_barrier ();
+               *del->method_code = (gpointer)ftndesc;
        }
+       del->method_ptr = ftndesc->addr;
+       del->rgctx = ftndesc->arg;
 }
 
 void
-mono_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method)
+mono_llvmonly_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method)
 {
        g_assert (target);
 
        method = mono_object_get_virtual_method (target, method);
 
-       MONO_OBJECT_SETREF (del, target, target);
        del->method = method;
        del->method_ptr = mono_compile_method (method);
 
-       if (mono_method_needs_static_rgctx_invoke (method, FALSE))
-               del->rgctx = mini_method_get_rgctx (method);
-
-       if (is_callee_gsharedvt_variable (del->method_ptr)) {
-               g_assert ((((mgreg_t)del->rgctx) & 1) == 0);
-               del->rgctx = (gpointer)(((mgreg_t)del->rgctx) | 1);
-       }
+       mini_init_delegate (del);
 }
 
 MonoObject*
@@ -1679,6 +1656,12 @@ mono_get_assembly_object (MonoImage *image)
        return (MonoObject*)mono_assembly_get_object (mono_domain_get (), image->assembly);
 }
 
+MonoObject*
+mono_get_method_object (MonoMethod *method)
+{
+       return (MonoObject*)mono_method_get_object (mono_domain_get (), method, method->klass);
+}
+
 double
 mono_ckfinite (double d)
 {
@@ -1686,3 +1669,25 @@ mono_ckfinite (double d)
                mono_set_pending_exception (mono_get_exception_arithmetic ());
        return d;
 }
+
+void
+mono_llvmonly_set_calling_assembly (MonoImage *image)
+{
+       MonoJitTlsData *jit_tls = NULL;
+
+       jit_tls = (MonoJitTlsData *)mono_native_tls_get_value (mono_jit_tls_id);
+       g_assert (jit_tls);
+       jit_tls->calling_image = image;
+}
+
+MonoObject*
+mono_llvmonly_get_calling_assembly (void)
+{
+       MonoJitTlsData *jit_tls = NULL;
+
+       jit_tls = (MonoJitTlsData *)mono_native_tls_get_value (mono_jit_tls_id);
+       g_assert (jit_tls);
+       if (!jit_tls->calling_image)
+               mono_raise_exception (mono_get_exception_not_supported ("Stack walks are not supported on this platform."));
+       return (MonoObject*)mono_assembly_get_object (mono_domain_get (), jit_tls->calling_image->assembly);
+}
index 2edf5759cd482d803cd2e6f2f881994dd100af93..e0f4172d03a887809408d1a5d85e74c49966d1b0 100644 (file)
@@ -205,12 +205,18 @@ MonoFtnDesc* mono_resolve_generic_virtual_iface_call (MonoVTable *vt, int imt_sl
 
 gpointer mono_init_vtable_slot (MonoVTable *vtable, int slot);
 
-void mono_init_delegate (MonoDelegate *del, MonoObject *target, MonoMethod *method);
+void mono_llvmonly_init_delegate (MonoDelegate *del);
 
-void mono_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method);
+void mono_llvmonly_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method);
 
 MonoObject* mono_get_assembly_object (MonoImage *image);
 
+MonoObject* mono_get_method_object (MonoMethod *method);
+
 double mono_ckfinite (double d);
 
+void mono_llvmonly_set_calling_assembly (MonoImage *image);
+
+MonoObject* mono_llvmonly_get_calling_assembly (void);
+
 #endif /* __MONO_JIT_ICALLS_H__ */
index ee87dfa082ad509892177d58242c5dc7bf962971..f26d6597bb52b970dcdef31455f800478e39cd59 100644 (file)
@@ -103,8 +103,8 @@ visit_bb (MonoCompile *cfg, MonoBasicBlock *bb, GSList **visited)
                        cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
                        if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
                                /* Make the component vregs volatile as well (#612206) */
-                               get_vreg_to_inst (cfg, var->dreg + 1)->flags |= MONO_INST_VOLATILE;
-                               get_vreg_to_inst (cfg, var->dreg + 2)->flags |= MONO_INST_VOLATILE;
+                               get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
+                               get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
                        }
                }
                        
@@ -122,8 +122,8 @@ visit_bb (MonoCompile *cfg, MonoBasicBlock *bb, GSList **visited)
                                cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
                                if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
                                        /* Make the component vregs volatile as well (#612206) */
-                                       get_vreg_to_inst (cfg, var->dreg + 1)->flags |= MONO_INST_VOLATILE;
-                                       get_vreg_to_inst (cfg, var->dreg + 2)->flags |= MONO_INST_VOLATILE;
+                                       get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
+                                       get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
                                }
                        }
                }
index 96787ddd9999187c300dc4440e3bc3b4bc0edf87..7d64d16da87a34352068e2b7c88f9aca1184ac39 100644 (file)
@@ -4196,7 +4196,7 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                        alloc_ftn = mono_object_new;
                } else {
                        iargs [0] = data;
-                       alloc_ftn = mono_object_new_specific;
+                       alloc_ftn = ves_icall_object_new_specific;
                }
 
                if (managed_alloc && !(cfg->opt & MONO_OPT_SHARED)) {
@@ -4445,6 +4445,22 @@ icall_is_direct_callable (MonoCompile *cfg, MonoMethod *cmethod)
        return FALSE;
 }
 
+/* Return whenever METHOD calls Assembly.GetCallingAssembly () */
+// FIXME: It would be better to generalize this using some kind of method attribute
+// or automatic detection
+static gboolean
+method_needs_calling_assembly (MonoMethod *method)
+{
+       MonoClass *klass = method->klass;
+
+       if (klass->image != mono_defaults.corlib)
+               return FALSE;
+       if (!strcmp (klass->name_space, "System") && !strcmp (klass->name, "Activator") &&
+               !strcmp (method->name, "CreateInstance"))
+               return TRUE;
+       return FALSE;
+}
+
 #define is_complex_isinst(klass) ((klass->flags & TYPE_ATTRIBUTE_INTERFACE) || klass->rank || mono_class_is_nullable (klass) || mono_class_is_marshalbyref (klass) || (klass->flags & TYPE_ATTRIBUTE_SEALED) || klass->byval_arg.type == MONO_TYPE_VAR || klass->byval_arg.type == MONO_TYPE_MVAR)
 
 static MonoInst*
@@ -5016,22 +5032,6 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
        if (!obj)
                return NULL;
 
-       if (cfg->llvm_only) {
-               MonoInst *args [16];
-
-               /*
-                * If the method to be called needs an rgctx, we can't fall back to mono_delegate_ctor (), since it might receive
-                * the address of a gshared method. So use a JIT icall.
-                * FIXME: Optimize this.
-                */
-               args [0] = obj;
-               args [1] = target;
-               args [2] = emit_get_rgctx_method (cfg, context_used, method, MONO_RGCTX_INFO_METHOD);
-               mono_emit_jit_icall (cfg, virtual_ ? mono_init_delegate_virtual : mono_init_delegate, args);
-
-               return obj;
-       }
-
        /* Inline the contents of mono_delegate_ctor */
 
        /* Set target field */
@@ -5076,6 +5076,22 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, obj->dreg, MONO_STRUCT_OFFSET (MonoDelegate, method_code), code_slot_ins->dreg);                
        }
 
+       if (cfg->llvm_only) {
+               MonoInst *args [16];
+
+               if (virtual_) {
+                       args [0] = obj;
+                       args [1] = target;
+                       args [2] = emit_get_rgctx_method (cfg, context_used, method, MONO_RGCTX_INFO_METHOD);
+                       mono_emit_jit_icall (cfg, mono_llvmonly_init_delegate_virtual, args);
+               } else {
+                       args [0] = obj;
+                       mono_emit_jit_icall (cfg, mono_llvmonly_init_delegate, args);
+               }
+
+               return obj;
+       }
+
        if (cfg->compile_aot) {
                MonoDelegateClassMethodPair *del_tramp;
 
@@ -6160,7 +6176,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                                if (opcode == OP_LOADI8_MEMBASE)
                                        ins = mono_decompose_opcode (cfg, ins);
 
-                               emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_ACQ);
+                               emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_SEQ);
 
                                return ins;
                        }
@@ -6184,7 +6200,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                                opcode = OP_STORE_MEMBASE_REG;
 
                        if (opcode) {
-                               emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_REL);
+                               emit_memory_barrier (cfg, MONO_MEMORY_BARRIER_SEQ);
 
                                MONO_INST_NEW (cfg, ins, opcode);
                                ins->sreg1 = args [1]->dreg;
@@ -6551,34 +6567,38 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
 
                if (!cfg->llvm_only && !strcmp (cmethod->name, "Read") && fsig->param_count == 1) {
                        guint32 opcode = 0;
-                       gboolean is_ref = mini_type_is_reference (fsig->params [0]);
-                       gboolean is_float = fsig->params [0]->type == MONO_TYPE_R4 || fsig->params [0]->type == MONO_TYPE_R8;
-
-                       if (fsig->params [0]->type == MONO_TYPE_I1)
+                       MonoType *t = fsig->params [0];
+                       gboolean is_ref;
+                       gboolean is_float = t->type == MONO_TYPE_R4 || t->type == MONO_TYPE_R8;
+
+                       g_assert (t->byref);
+                       /* t is a byref type, so the reference check is more complicated */
+                       is_ref = mini_type_is_reference (&mono_class_from_mono_type (t)->byval_arg);
+                       if (t->type == MONO_TYPE_I1)
                                opcode = OP_ATOMIC_LOAD_I1;
-                       else if (fsig->params [0]->type == MONO_TYPE_U1 || fsig->params [0]->type == MONO_TYPE_BOOLEAN)
+                       else if (t->type == MONO_TYPE_U1 || t->type == MONO_TYPE_BOOLEAN)
                                opcode = OP_ATOMIC_LOAD_U1;
-                       else if (fsig->params [0]->type == MONO_TYPE_I2)
+                       else if (t->type == MONO_TYPE_I2)
                                opcode = OP_ATOMIC_LOAD_I2;
-                       else if (fsig->params [0]->type == MONO_TYPE_U2)
+                       else if (t->type == MONO_TYPE_U2)
                                opcode = OP_ATOMIC_LOAD_U2;
-                       else if (fsig->params [0]->type == MONO_TYPE_I4)
+                       else if (t->type == MONO_TYPE_I4)
                                opcode = OP_ATOMIC_LOAD_I4;
-                       else if (fsig->params [0]->type == MONO_TYPE_U4)
+                       else if (t->type == MONO_TYPE_U4)
                                opcode = OP_ATOMIC_LOAD_U4;
-                       else if (fsig->params [0]->type == MONO_TYPE_R4)
+                       else if (t->type == MONO_TYPE_R4)
                                opcode = OP_ATOMIC_LOAD_R4;
-                       else if (fsig->params [0]->type == MONO_TYPE_R8)
+                       else if (t->type == MONO_TYPE_R8)
                                opcode = OP_ATOMIC_LOAD_R8;
 #if SIZEOF_REGISTER == 8
-                       else if (fsig->params [0]->type == MONO_TYPE_I8 || fsig->params [0]->type == MONO_TYPE_I)
+                       else if (t->type == MONO_TYPE_I8 || t->type == MONO_TYPE_I)
                                opcode = OP_ATOMIC_LOAD_I8;
-                       else if (is_ref || fsig->params [0]->type == MONO_TYPE_U8 || fsig->params [0]->type == MONO_TYPE_U)
+                       else if (is_ref || t->type == MONO_TYPE_U8 || t->type == MONO_TYPE_U)
                                opcode = OP_ATOMIC_LOAD_U8;
 #else
-                       else if (fsig->params [0]->type == MONO_TYPE_I)
+                       else if (t->type == MONO_TYPE_I)
                                opcode = OP_ATOMIC_LOAD_I4;
-                       else if (is_ref || fsig->params [0]->type == MONO_TYPE_U)
+                       else if (is_ref || t->type == MONO_TYPE_U)
                                opcode = OP_ATOMIC_LOAD_U4;
 #endif
 
@@ -6592,7 +6612,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                                ins->backend.memory_barrier_kind = MONO_MEMORY_BARRIER_ACQ;
                                MONO_ADD_INS (cfg->cbb, ins);
 
-                               switch (fsig->params [0]->type) {
+                               switch (t->type) {
                                case MONO_TYPE_BOOLEAN:
                                case MONO_TYPE_I1:
                                case MONO_TYPE_U1:
@@ -6621,7 +6641,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                                        ins->type = STACK_R8;
                                        break;
                                default:
-                                       g_assert (mini_type_is_reference (fsig->params [0]));
+                                       g_assert (is_ref);
                                        ins->type = STACK_OBJ;
                                        break;
                                }
@@ -6630,33 +6650,36 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
 
                if (!cfg->llvm_only && !strcmp (cmethod->name, "Write") && fsig->param_count == 2) {
                        guint32 opcode = 0;
-                       gboolean is_ref = mini_type_is_reference (fsig->params [0]);
+                       MonoType *t = fsig->params [0];
+                       gboolean is_ref;
 
-                       if (fsig->params [0]->type == MONO_TYPE_I1)
+                       g_assert (t->byref);
+                       is_ref = mini_type_is_reference (&mono_class_from_mono_type (t)->byval_arg);
+                       if (t->type == MONO_TYPE_I1)
                                opcode = OP_ATOMIC_STORE_I1;
-                       else if (fsig->params [0]->type == MONO_TYPE_U1 || fsig->params [0]->type == MONO_TYPE_BOOLEAN)
+                       else if (t->type == MONO_TYPE_U1 || t->type == MONO_TYPE_BOOLEAN)
                                opcode = OP_ATOMIC_STORE_U1;
-                       else if (fsig->params [0]->type == MONO_TYPE_I2)
+                       else if (t->type == MONO_TYPE_I2)
                                opcode = OP_ATOMIC_STORE_I2;
-                       else if (fsig->params [0]->type == MONO_TYPE_U2)
+                       else if (t->type == MONO_TYPE_U2)
                                opcode = OP_ATOMIC_STORE_U2;
-                       else if (fsig->params [0]->type == MONO_TYPE_I4)
+                       else if (t->type == MONO_TYPE_I4)
                                opcode = OP_ATOMIC_STORE_I4;
-                       else if (fsig->params [0]->type == MONO_TYPE_U4)
+                       else if (t->type == MONO_TYPE_U4)
                                opcode = OP_ATOMIC_STORE_U4;
-                       else if (fsig->params [0]->type == MONO_TYPE_R4)
+                       else if (t->type == MONO_TYPE_R4)
                                opcode = OP_ATOMIC_STORE_R4;
-                       else if (fsig->params [0]->type == MONO_TYPE_R8)
+                       else if (t->type == MONO_TYPE_R8)
                                opcode = OP_ATOMIC_STORE_R8;
 #if SIZEOF_REGISTER == 8
-                       else if (fsig->params [0]->type == MONO_TYPE_I8 || fsig->params [0]->type == MONO_TYPE_I)
+                       else if (t->type == MONO_TYPE_I8 || t->type == MONO_TYPE_I)
                                opcode = OP_ATOMIC_STORE_I8;
-                       else if (is_ref || fsig->params [0]->type == MONO_TYPE_U8 || fsig->params [0]->type == MONO_TYPE_U)
+                       else if (is_ref || t->type == MONO_TYPE_U8 || t->type == MONO_TYPE_U)
                                opcode = OP_ATOMIC_STORE_U8;
 #else
-                       else if (fsig->params [0]->type == MONO_TYPE_I)
+                       else if (t->type == MONO_TYPE_I)
                                opcode = OP_ATOMIC_STORE_I4;
-                       else if (is_ref || fsig->params [0]->type == MONO_TYPE_U)
+                       else if (is_ref || t->type == MONO_TYPE_U)
                                opcode = OP_ATOMIC_STORE_U4;
 #endif
 
@@ -6710,6 +6733,29 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        ins = mono_emit_jit_icall (cfg, mono_get_assembly_object, &assembly_ins);
                        return ins;
                }
+               if (cfg->llvm_only && !strcmp (cmethod->name, "GetCallingAssembly")) {
+                       /* No stack walks are currently available, so implement this as an intrinsic */
+                       ins = mono_emit_jit_icall (cfg, mono_llvmonly_get_calling_assembly, NULL);
+                       return ins;
+               }
+       } else if (cmethod->klass->image == mono_defaults.corlib &&
+                          (strcmp (cmethod->klass->name_space, "System.Reflection") == 0) &&
+                          (strcmp (cmethod->klass->name, "MethodBase") == 0)) {
+               if (cfg->llvm_only && !strcmp (cmethod->name, "GetCurrentMethod")) {
+                       /* No stack walks are currently available, so implement this as an intrinsic */
+                       MonoInst *method_ins;
+                       MonoMethod *declaring = cfg->method;
+
+                       /* This returns the declaring generic method */
+                       if (declaring->is_inflated)
+                               declaring = ((MonoMethodInflated*)cfg->method)->declaring;
+                       EMIT_NEW_AOTCONST (cfg, method_ins, MONO_PATCH_INFO_METHODCONST, declaring);
+                       ins = mono_emit_jit_icall (cfg, mono_get_method_object, &method_ins);
+                       cfg->no_inline = TRUE;
+                       if (cfg->method != cfg->current_method)
+                               inline_failure (cfg, "MethodBase:GetCurrentMethod ()");
+                       return ins;
+               }
        } else if (cmethod->klass == mono_defaults.math_class) {
                /* 
                 * There is general branchless code for Min/Max, but it does not work for 
@@ -9127,6 +9173,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        gboolean delegate_invoke = FALSE;
                        gboolean direct_icall = FALSE;
                        gboolean constrained_partial_call = FALSE;
+                       gboolean needs_calling_assembly = FALSE;
                        MonoMethod *cil_method;
 
                        CHECK_OPSIZE (5);
@@ -9245,6 +9292,21 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                }
                        }
 
+                       /*
+                        * Stack walks are not supported in llvmonly mode, so
+                        * when calling methods which call GetCallingAssembly (), save the
+                        * current assembly in the caller. The call to GetCallingAssembly ()
+                        * will be turned into an icall which will retrieve the value.
+                        */
+                       if (cfg->llvm_only && cmethod && method_needs_calling_assembly (cmethod)) {
+                               needs_calling_assembly = TRUE;
+
+                               MonoInst *assembly_ins;
+
+                               EMIT_NEW_AOTCONST (cfg, assembly_ins, MONO_PATCH_INFO_IMAGE, cfg->method->klass->image);
+                               ins = mono_emit_jit_icall (cfg, mono_llvmonly_set_calling_assembly, &assembly_ins);
+                       }
+
                        mono_save_token_info (cfg, image, token, cil_method);
 
                        if (!(seq_point_locs && mono_bitset_test_fast (seq_point_locs, ip + 5 - header->code)))
@@ -9943,6 +10005,18 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                EMIT_NEW_DUMMY_USE (cfg, dummy_use, keep_this_alive);
                        }
 
+                       if (needs_calling_assembly) {
+                               /*
+                                * Clear the calling assembly.
+                                * This is not EH safe, but this is not a problem in practice, since
+                                * the null value is only used for error checking.
+                                */
+                               MonoInst *assembly_ins;
+
+                               EMIT_NEW_PCONST (cfg, assembly_ins, NULL);
+                               ins = mono_emit_jit_icall (cfg, mono_llvmonly_set_calling_assembly, &assembly_ins);
+                       }
+
                        CHECK_CFG_EXCEPTION;
 
                        ip += 5;
@@ -10404,15 +10478,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                        /* Use the immediate opcodes if possible */
                        if (((sp [1]->opcode == OP_ICONST) || (sp [1]->opcode == OP_I8CONST)) && mono_arch_is_inst_imm (sp [1]->opcode == OP_ICONST ? sp [1]->inst_c0 : sp [1]->inst_l)) {
-                               int imm_opcode;
-
-                               imm_opcode = mono_op_to_op_imm_noemul (ins->opcode);
-#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_DIV)
-                               /* Keep emulated opcodes which are optimized away later */
-                               if ((ins->opcode == OP_IREM_UN || ins->opcode == OP_IDIV_UN_IMM) && (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP)) && sp [1]->opcode == OP_ICONST && mono_is_power_of_two (sp [1]->inst_c0) >= 0) {
-                                       imm_opcode = mono_op_to_op_imm (ins->opcode);
-                               }
-#endif
+                               int imm_opcode = mono_op_to_op_imm_noemul (ins->opcode);
                                if (imm_opcode != -1) {
                                        ins->opcode = imm_opcode;
                                        if (sp [1]->opcode == OP_I8CONST) {
@@ -12765,6 +12831,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                addr = *sp;
                                fsig = mini_get_signature (method, token, generic_context);
 
+                               if (cfg->llvm_only)
+                                       cfg->signatures = g_slist_prepend_mempool (cfg->mempool, cfg->signatures, fsig);
+
                                n = fsig->param_count + fsig->hasthis + 1;
 
                                CHECK_STACK (n);
@@ -12816,7 +12885,45 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                                                MONO_START_BB (cfg, end_bb);
                                        } else {
-                                               ins = emit_extra_arg_calli (cfg, fsig, sp, arg->dreg, addr);
+                                               /* Caller uses a normal calling conv */
+
+                                               MonoInst *callee = addr;
+                                               MonoInst *call, *localloc_ins;
+                                               MonoBasicBlock *is_gsharedvt_bb, *end_bb;
+                                               int low_bit_reg = alloc_preg (cfg);
+
+                                               NEW_BBLOCK (cfg, is_gsharedvt_bb);
+                                               NEW_BBLOCK (cfg, end_bb);
+
+                                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PAND_IMM, low_bit_reg, arg->dreg, 1);
+                                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, low_bit_reg, 0);
+                                               MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, is_gsharedvt_bb);
+
+                                               /* Normal case: callee uses a normal cconv, no conversion is needed */
+                                               call = emit_extra_arg_calli (cfg, fsig, sp, arg->dreg, callee);
+                                               MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb);
+                                               /* Gsharedvt case: callee uses a gsharedvt cconv, have to add an in wrapper */
+                                               MONO_START_BB (cfg, is_gsharedvt_bb);
+                                               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PXOR_IMM, arg->dreg, arg->dreg, 1);
+                                               NEW_AOTCONST (cfg, addr, MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER, fsig);
+                                               MONO_ADD_INS (cfg->cbb, addr);
+                                               /*
+                                                * ADDR points to a gsharedvt-in wrapper, have to pass <callee, arg> as an extra arg.
+                                                */
+                                               MONO_INST_NEW (cfg, ins, OP_LOCALLOC_IMM);
+                                               ins->dreg = alloc_preg (cfg);
+                                               ins->inst_imm = 2 * SIZEOF_VOID_P;
+                                               MONO_ADD_INS (cfg->cbb, ins);
+                                               localloc_ins = ins;
+                                               cfg->flags |= MONO_CFG_HAS_ALLOCA;
+                                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, localloc_ins->dreg, 0, callee->dreg);
+                                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, localloc_ins->dreg, SIZEOF_VOID_P, arg->dreg);
+
+                                               ins = emit_extra_arg_calli (cfg, fsig, sp, localloc_ins->dreg, addr);
+                                               ins->dreg = call->dreg;
+                                               MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_BR, end_bb);
+
+                                               MONO_START_BB (cfg, end_bb);
                                        }
                                } else {
                                        /* Same as CEE_CALLI */
@@ -14097,8 +14204,8 @@ mono_handle_global_vregs (MonoCompile *cfg)
                                         * Make the component vregs volatile since the optimizations can
                                         * get confused otherwise.
                                         */
-                                       get_vreg_to_inst (cfg, vreg + 1)->flags |= MONO_INST_VOLATILE;
-                                       get_vreg_to_inst (cfg, vreg + 2)->flags |= MONO_INST_VOLATILE;
+                                       get_vreg_to_inst (cfg, MONO_LVREG_LS (vreg))->flags |= MONO_INST_VOLATILE;
+                                       get_vreg_to_inst (cfg, MONO_LVREG_MS (vreg))->flags |= MONO_INST_VOLATILE;
                                }
 #endif
 
@@ -14243,9 +14350,9 @@ mono_handle_global_vregs (MonoCompile *cfg)
                                        /* Modify the two component vars too */
                                        MonoInst *var1;
 
-                                       var1 = get_vreg_to_inst (cfg, cfg->varinfo [pos]->dreg + 1);
+                                       var1 = get_vreg_to_inst (cfg, MONO_LVREG_LS (cfg->varinfo [pos]->dreg));
                                        var1->inst_c0 = pos;
-                                       var1 = get_vreg_to_inst (cfg, cfg->varinfo [pos]->dreg + 2);
+                                       var1 = get_vreg_to_inst (cfg, MONO_LVREG_MS (cfg->varinfo [pos]->dreg));
                                        var1->inst_c0 = pos;
                                }
 #endif
@@ -14340,13 +14447,13 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
 
                                g_assert (ins->opcode == OP_REGOFFSET);
 
-                               tree = get_vreg_to_inst (cfg, ins->dreg + 1);
+                               tree = get_vreg_to_inst (cfg, MONO_LVREG_LS (ins->dreg));
                                g_assert (tree);
                                tree->opcode = OP_REGOFFSET;
                                tree->inst_basereg = ins->inst_basereg;
                                tree->inst_offset = ins->inst_offset + MINI_LS_WORD_OFFSET;
 
-                               tree = get_vreg_to_inst (cfg, ins->dreg + 2);
+                               tree = get_vreg_to_inst (cfg, MONO_LVREG_MS (ins->dreg));
                                g_assert (tree);
                                tree->opcode = OP_REGOFFSET;
                                tree->inst_basereg = ins->inst_basereg;
@@ -14603,9 +14710,9 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
 
 #if SIZEOF_REGISTER != 8
                                        if (regtype == 'l') {
-                                               NEW_STORE_MEMBASE (cfg, store_ins, OP_STOREI4_MEMBASE_REG, var->inst_basereg, var->inst_offset + MINI_LS_WORD_OFFSET, ins->dreg + 1);
+                                               NEW_STORE_MEMBASE (cfg, store_ins, OP_STOREI4_MEMBASE_REG, var->inst_basereg, var->inst_offset + MINI_LS_WORD_OFFSET, MONO_LVREG_LS (ins->dreg));
                                                mono_bblock_insert_after_ins (bb, ins, store_ins);
-                                               NEW_STORE_MEMBASE (cfg, store_ins, OP_STOREI4_MEMBASE_REG, var->inst_basereg, var->inst_offset + MINI_MS_WORD_OFFSET, ins->dreg + 2);
+                                               NEW_STORE_MEMBASE (cfg, store_ins, OP_STOREI4_MEMBASE_REG, var->inst_basereg, var->inst_offset + MINI_MS_WORD_OFFSET, MONO_LVREG_MS (ins->dreg));
                                                mono_bblock_insert_after_ins (bb, ins, store_ins);
                                                def_ins = store_ins;
                                        }
@@ -14772,9 +14879,9 @@ mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts)
 
 #if SIZEOF_REGISTER != 8
                                                if (regtype == 'l') {
-                                                       NEW_LOAD_MEMBASE (cfg, load_ins, OP_LOADI4_MEMBASE, sreg + 2, var->inst_basereg, var->inst_offset + MINI_MS_WORD_OFFSET);
+                                                       NEW_LOAD_MEMBASE (cfg, load_ins, OP_LOADI4_MEMBASE, MONO_LVREG_MS (sreg), var->inst_basereg, var->inst_offset + MINI_MS_WORD_OFFSET);
                                                        mono_bblock_insert_before_ins (bb, ins, load_ins);
-                                                       NEW_LOAD_MEMBASE (cfg, load_ins, OP_LOADI4_MEMBASE, sreg + 1, var->inst_basereg, var->inst_offset + MINI_LS_WORD_OFFSET);
+                                                       NEW_LOAD_MEMBASE (cfg, load_ins, OP_LOADI4_MEMBASE, MONO_LVREG_LS (sreg), var->inst_basereg, var->inst_offset + MINI_LS_WORD_OFFSET);
                                                        mono_bblock_insert_before_ins (bb, ins, load_ins);
                                                        use_ins = load_ins;
                                                }
index a1e877743ae410b190a1083f1abbe3a355900435..a97493988ce3e39f80e1a40b7c5b2144df161e38 100644 (file)
@@ -495,7 +495,8 @@ typedef enum {
 typedef struct {
        gint16 offset;
        gint8  reg;
-       ArgStorage storage;
+       ArgStorage storage : 8;
+       gboolean is_gsharedvt_return_value : 1;
 
        /* Only if storage == ArgValuetypeInReg */
        ArgStorage pair_storage [2];
@@ -503,6 +504,8 @@ typedef struct {
        /* The size of each pair */
        int pair_size [2];
        int nregs;
+       /* Only if storage == ArgOnStack */
+       int arg_size;
 } ArgInfo;
 
 typedef struct {
@@ -537,6 +540,7 @@ add_general (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo)
 
     if (*gr >= PARAM_REGS) {
                ainfo->storage = ArgOnStack;
+               ainfo->arg_size = sizeof (mgreg_t);
                /* Since the same stack slot size is used for all arg */
                /*  types, it needs to be big enough to hold them all */
                (*stack_size) += sizeof(mgreg_t);
@@ -561,6 +565,7 @@ add_float (guint32 *gr, guint32 *stack_size, ArgInfo *ainfo, gboolean is_double)
 
     if (*gr >= FLOAT_PARAM_REGS) {
                ainfo->storage = ArgOnStack;
+               ainfo->arg_size = sizeof (mgreg_t);
                /* Since the same stack slot size is used for both float */
                /*  types, it needs to be big enough to hold them both */
                (*stack_size) += sizeof(mgreg_t);
@@ -771,6 +776,8 @@ add_valuetype_win64 (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
                ainfo->offset = *stack_size;
                *stack_size += ALIGN_TO (size, 8);
                ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack;
+               if (!is_return)
+                       ainfo->arg_size = ALIGN_TO (size, 8);
 
                g_free (fields);
                return;
@@ -815,6 +822,7 @@ add_valuetype_win64 (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
                                else {
                                        ainfo->pair_storage [0] = ArgOnStack;
                                        ainfo->offset = *stack_size;
+                                       ainfo->arg_size = sizeof (mgreg_t);
                                        *stack_size += 8;
                                }
                        }
@@ -899,6 +907,8 @@ add_valuetype_win64 (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
                        ainfo->offset = *stack_size;
                        *stack_size += sizeof (mgreg_t);
                        ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack;
+                       if (!is_return)
+                               ainfo->arg_size = sizeof (mgreg_t);
                }
        }
 }
@@ -969,6 +979,8 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
                ainfo->offset = *stack_size;
                *stack_size += ALIGN_TO (size, 8);
                ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack;
+               if (!is_return)
+                       ainfo->arg_size = ALIGN_TO (size, 8);
 
                g_free (fields);
                return;
@@ -1011,6 +1023,8 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
                        ainfo->offset = *stack_size;
                        *stack_size += ALIGN_TO (info->native_size, 8);
                        ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack;
+                       if (!is_return)
+                               ainfo->arg_size = ALIGN_TO (info->native_size, 8);
 
                        g_free (fields);
                        return;
@@ -1066,7 +1080,7 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
 
                while (quadsize [0] != 1 && quadsize [0] != 2 && quadsize [0] != 4 && quadsize [0] != 8)
                        quadsize [0] ++;
-               while (quadsize [1] != 1 && quadsize [1] != 2 && quadsize [1] != 4 && quadsize [1] != 8)
+               while (quadsize [1] != 0 && quadsize [1] != 1 && quadsize [1] != 2 && quadsize [1] != 4 && quadsize [1] != 8)
                        quadsize [1] ++;
 
                ainfo->storage = ArgValuetypeInReg;
@@ -1109,16 +1123,20 @@ add_valuetype (MonoMethodSignature *sig, ArgInfo *ainfo, MonoType *type,
                }
 
                if ((args [0] == ARG_CLASS_MEMORY) || (args [1] == ARG_CLASS_MEMORY)) {
+                       int arg_size;
                        /* Revert possible register assignments */
                        *gr = orig_gr;
                        *fr = orig_fr;
 
                        ainfo->offset = *stack_size;
                        if (sig->pinvoke)
-                               *stack_size += ALIGN_TO (info->native_size, 8);
+                               arg_size = ALIGN_TO (info->native_size, 8);
                        else
-                               *stack_size += nquads * sizeof(mgreg_t);
+                               arg_size = nquads * sizeof(mgreg_t);
+                       *stack_size += arg_size;
                        ainfo->storage = is_return ? ArgValuetypeAddrInIReg : ArgOnStack;
+                       if (!is_return)
+                               ainfo->arg_size = arg_size;
                }
        }
 #endif /* !TARGET_WIN32 */
@@ -1198,6 +1216,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig)
                }
                if (mini_is_gsharedvt_type (ret_type)) {
                        cinfo->ret.storage = ArgValuetypeAddrInIReg;
+                       cinfo->ret.is_gsharedvt_return_value = 1;
                        break;
                }
                /* fall through */
@@ -1213,6 +1232,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig)
        case MONO_TYPE_MVAR:
                g_assert (mini_is_gsharedvt_type (ret_type));
                cinfo->ret.storage = ArgValuetypeAddrInIReg;
+               cinfo->ret.is_gsharedvt_return_value = 1;
                break;
        case MONO_TYPE_VOID:
                break;
@@ -1461,6 +1481,9 @@ mono_arch_init (void)
        mono_aot_register_jit_icall ("mono_amd64_throw_corlib_exception", mono_amd64_throw_corlib_exception);
        mono_aot_register_jit_icall ("mono_amd64_resume_unwind", mono_amd64_resume_unwind);
        mono_aot_register_jit_icall ("mono_amd64_get_original_ip", mono_amd64_get_original_ip);
+#if defined(ENABLE_GSHAREDVT)
+       mono_aot_register_jit_icall ("mono_amd64_start_gsharedvt_call", mono_amd64_start_gsharedvt_call);
+#endif
 
        if (!mono_aot_only)
                bp_trampoline = mini_get_breakpoint_trampoline ();
@@ -1896,6 +1919,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                case ArgInDoubleSSEReg:
                        cfg->ret->opcode = OP_REGVAR;
                        cfg->ret->inst_c0 = cinfo->ret.reg;
+                       cfg->ret->dreg = cinfo->ret.reg;
                        break;
                case ArgValuetypeAddrInIReg:
                        /* The register is volatile */
@@ -1928,7 +1952,6 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                default:
                        g_assert_not_reached ();
                }
-               cfg->ret->dreg = cfg->ret->inst_c0;
        }
 
        /* Allocate locals */
@@ -2038,7 +2061,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                                NOT_IMPLEMENTED;
                        }
 
-                       if (!inreg && (ainfo->storage != ArgOnStack) && (ainfo->storage != ArgValuetypeAddrInIReg)) {
+                       if (!inreg && (ainfo->storage != ArgOnStack) && (ainfo->storage != ArgValuetypeAddrInIReg) && (ainfo->storage != ArgGSharedVtOnStack)) {
                                ins->opcode = OP_REGOFFSET;
                                ins->inst_basereg = cfg->frame_reg;
                                /* These arguments are saved to the stack in the prolog */
@@ -2365,6 +2388,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                        t = sig->params [i - sig->hasthis];
 
                t = mini_get_underlying_type (t);
+               //XXX what about ArgGSharedVtOnStack here?
                if (ainfo->storage == ArgOnStack && !MONO_TYPE_ISSTRUCT (t) && !call->tail_call) {
                        if (!t->byref) {
                                if (t->type == MONO_TYPE_R4)
@@ -2426,6 +2450,7 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                        if (ainfo->storage == ArgOnStack && !MONO_TYPE_ISSTRUCT (t) && !call->tail_call)
                                /* Already emitted above */
                                break;
+                       //FIXME what about ArgGSharedVtOnStack ?
                        if (ainfo->storage == ArgOnStack && call->tail_call) {
                                MonoInst *call_inst = (MonoInst*)call;
                                cfg->args [i]->flags |= MONO_INST_VOLATILE;
@@ -2604,7 +2629,7 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src)
                mono_call_inst_add_outarg_reg (cfg, call, src->dreg, ainfo->reg, FALSE);
                break;
        case ArgGSharedVtOnStack:
-               g_assert_not_reached ();
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, AMD64_RSP, ainfo->offset, src->dreg);
                break;
        default:
                if (size == 8) {
@@ -7239,6 +7264,9 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                                if (ainfo->pair_storage [0] == ArgInIReg)
                                        amd64_mov_membase_reg (code, ins->inst_left->inst_basereg, ins->inst_left->inst_offset, ainfo->pair_regs [0],  sizeof (gpointer));
                                break;
+                       case ArgGSharedVtInReg:
+                               amd64_mov_membase_reg (code, ins->inst_basereg, ins->inst_offset, ainfo->reg, 8);
+                               break;
                        default:
                                break;
                        }
@@ -8816,4 +8844,4 @@ mono_arch_opcode_supported (int opcode)
 
 #include "../../../mono-extensions/mono/mini/mini-amd64-gsharedvt.c"
 
-#endif /* !MONOTOUCH */
+#endif /* !ENABLE_GSHAREDVT */
index 526e5b00c195d3652e55a35ef1766472b3ed90b5..2d0d2dd77a3351dbbeb88882de6c58e4c2636eee 100644 (file)
@@ -220,7 +220,23 @@ typedef struct MonoCompileArch {
 #endif
 
 typedef struct {
-       int dummy;
+       /* Method address to call */
+       gpointer addr;
+       /* The trampoline reads this, so keep the size explicit */
+       int ret_marshal;
+       /* If ret_marshal != NONE, this is the reg of the vret arg, else -1 */
+       int vret_arg_reg;
+       /* The stack slot where the return value will be stored */
+       int vret_slot;
+       int stack_usage, map_count;
+       /* If not -1, then make a virtual call using this vtable offset */
+       int vcall_offset;
+       /* If 1, make an indirect call to the address in the rgctx reg */
+       int calli;
+       /* Whenever this is a in or an out call */
+       int gsharedvt_in;
+       /* Maps stack slots/registers in the caller to the stack slots/registers in the callee */
+       int map [MONO_ZERO_LEN_ARRAY];
 } GSharedVtCallInfo;
 
 /* Structure used by the sequence points in AOTed code */
@@ -350,6 +366,7 @@ typedef struct {
 #define MONO_ARCH_HAVE_CONTEXT_SET_INT_REG 1
 #define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
 #define MONO_ARCH_HAVE_CREATE_LLVM_NATIVE_THUNK 1
+#define MONO_ARCH_GSHAREDVT_SUPPORTED 1
 #define MONO_ARCH_HAVE_OP_TAIL_CALL 1
 #define MONO_ARCH_HAVE_TRANSLATE_TLS_OFFSET 1
 #define MONO_ARCH_HAVE_DUMMY_INIT 1
@@ -401,6 +418,9 @@ mono_amd64_resume_unwind (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint6
                                                  guint64 dummy5, guint64 dummy6,
                                                  MonoContext *mctx, guint32 dummy7, gint64 dummy8);
 
+gpointer
+mono_amd64_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg);
+
 guint64
 mono_amd64_get_original_ip (void);
 
index 1f7204a884b0d09aae0f4319b5fc8721ab2d1b98..63096e7439f6f435a68f47d3a0d7f3cc2c9c6fe5 100644 (file)
@@ -57,24 +57,22 @@ DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key_end
 
        .align 4
 DECLARE_GLOBAL_SYMBOL mono_fallback_get_tls_key
-#if defined(__linux__)
-       mov     r1, r0
-       mvn     r0, #0xf000
-       sub     r0, r0, #31
+#if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
        push    {lr}
-       blx     r0
-#if defined(HAVE_KW_THREAD)
+       mov     r1, r0
+       bl      __aeabi_read_tp
        ldr     r0, [r0, r1]
-#elif defined(TARGET_ANDROID)
-       ldr     r0, [r0, r1, lsl #2]
-#endif
        pop     {pc}
 #elif defined(TARGET_IOS)
-       push    {lr}
+       push    {r7, lr}
+       mov     r7, sp
        bl      _pthread_getspecific
+       pop     {r7, pc}
+#elif defined(TARGET_ANDROID)
+       push    {lr}
+       bl      pthread_getspecific
        pop     {pc}
 #endif
-
        /*
         * The following thunks set the value corresponding to the key/offset
         * passed in R0. These thunks don't do jumps to external code so execution
@@ -107,23 +105,54 @@ DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key_end
 
        .align 4
 DECLARE_GLOBAL_SYMBOL mono_fallback_set_tls_key
-#if defined(__linux__)
-       mov     r2, r0
-       mvn     r0, #0xf000
-       sub     r0, r0, #31
+#if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
        push    {lr}
-       blx     r0
-#if defined(HAVE_KW_THREAD)
+       mov     r2, r0
+       bl      __aeabi_read_tp
        str     r1, [r0, r2]
-#elif defined(TARGET_ANDROID)
-       str     r1, [r0, r2, lsl #2]
-#endif
        pop     {pc}
 #elif defined(TARGET_IOS)
-       push    {lr}
+       push    {r7, lr}
+       mov     r7, sp
        bl      _pthread_setspecific
+       pop     {r7, pc}
+#elif defined(TARGET_ANDROID)
+       push    {lr}
+       bl      pthread_setspecific
        pop     {pc}
 #endif
 
+
+       /* Additional tls getters/setters */
+
+#if defined(TARGET_ANDROID)
+       .align 4
+DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2
+       bic     r0, r0, #0x80000000
+       mrc     15, 0, r1, cr13, cr0, #3
+       lsls    r0, r0, #3
+       ldr     r1, [r1, #4]
+       add     r0, r1
+       ldr     r0, [r0, #0x68]
+       bx      lr
+DECLARE_GLOBAL_SYMBOL mono_fast_get_tls_key2_end
+
+       /*
+        * In order to use this fast setter we need to make sure that the key was
+        * already set at least once using the pthread api, otherwise it will not
+        * interwork with the api.
+        */
+       .align 4
+DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2
+       bic     r0, r0, #0x80000000
+       mrc     15, 0, r2, cr13, cr0, #3
+       lsls    r0, r0, #3
+       ldr     r2, [r2, #4]
+       add     r0, r2
+       str     r1, [r0, #0x68]
+       bx      lr
+DECLARE_GLOBAL_SYMBOL mono_fast_set_tls_key2_end
+#endif
+
 #endif
 
index 30b2494dfc70c21ad396339e5e8cec5f8c86af6f..3fa4bef20620202cd3a6348f87101802f6d5a886 100644 (file)
@@ -5,6 +5,8 @@
 
 int mono_fast_get_tls_key (int);
 void mono_fast_set_tls_key (int, int);
+int mono_fast_get_tls_key2 (int);
+void mono_fast_set_tls_key2 (int, int);
 
 /* Fallback tls getters/setters */
 
@@ -15,5 +17,103 @@ void mono_fallback_set_tls_key (int, int);
 
 void mono_fast_get_tls_key_end (void);
 void mono_fast_set_tls_key_end (void);
+void mono_fast_get_tls_key2_end (void);
+void mono_fast_set_tls_key2_end (void);
 
+#if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
+void* __aeabi_read_tp (void);
+#endif
+
+/* Structure that maps a possible  tls implementation to the corresponding thunks */
+typedef struct {
+       guint32 *expected_code;
+       int expected_code_length;
+       gboolean check_kernel_helper;
+       gpointer get_tls_thunk;
+       gpointer get_tls_thunk_end;
+       gpointer set_tls_thunk;
+       gpointer set_tls_thunk_end;
+} MonoTlsImplementation;
+
+
+static MonoTlsImplementation known_tls_implementations [] = {
+#if defined(HAVE_KW_THREAD) && defined(__linux__) && defined(__ARM_EABI__)
+       { (guint32[]) {0x0f70ee1d, 0xbf004770}, 8, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end },
+       { (guint32[]) {0xe3e00a0f, 0xe240f01f}, 8, TRUE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end }
+#elif defined(TARGET_IOS)
+       { (guint32[]) {0x1f70ee1d, 0x0103f021, 0x0020f851, 0xbf004770}, 16, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end }
+#elif defined(TARGET_ANDROID)
+       { (guint32[]) {0xe2403003, 0xe353003c, 0xe92d4010, 0xe1a04000, 0x9a000001, 0xe3a00000, 0xe8bd8010, 0xe3e00a0f, 0xe240101f, 0xe12fff31, 0xe7900104, 0xe8bd8010}, 48, TRUE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 1.5 */
+       { (guint32[]) {0xe2402003, 0xe1a03000, 0xe352003c, 0x8a000002, 0xee1d0f70, 0xe7900103, 0xe12fff1e}, 28, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 4.2 */
+       { (guint32[]) {0xe2403007, 0xe3530084, 0x8a000002, 0xee1d1f70, 0xe7910100, 0xe12fff1e, 0xe3a00000, 0xe12fff1e}, 32, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 4.4 */
+       { (guint32[]) {0x2b8c1fc3, 0xee1dd804, 0xf8511f70, 0x47700020, 0x47702000}, 20, FALSE, mono_fast_get_tls_key, mono_fast_get_tls_key_end, mono_fast_set_tls_key, mono_fast_set_tls_key_end}, /* 5.0 */
+       { (guint32[]) {0xb5104b0f, 0xda114298, 0xf020490e, 0xee1d4000, 0x00c24f70, 0xf8514479, 0x68631030, 0xd50707cc, 0x6e54441a, 0xd103428c, 0xbd106e90}, 44, FALSE, mono_fast_get_tls_key2, mono_fast_get_tls_key2_end, mono_fast_set_tls_key2, mono_fast_set_tls_key2_end} /* 6.0 */
+#endif
+};
+
+static gboolean
+known_kernel_helper (void)
+{
+#ifdef __linux__
+       const guint32* kuser_get_tls = (void*)0xffff0fe0; /* linux kernel user helper on arm */
+       guint32 expected [] = {0xee1d0f70, 0xe12fff1e};
+
+       /* Expecting mrc + bx lr in the kuser_get_tls kernel helper */
+       return memcmp (kuser_get_tls, expected, 8) == 0;
+#else
+       g_error ("Trying to check linux kernel helper on non linux platform"); 
+       return FALSE;
+#endif
+}
+
+static void
+dump_code (guint32 *ptr)
+{
+       char current_impl [256];
+       char hex [16];
+       int i;
+       guint32 page_mask = ~((guint32)mono_pagesize () - 1);
+
+       current_impl [0] = 0;
+       for (i = 0; i < 16; i++) {
+               /* Don't risk page fault since we don't know where the code ends */
+               if (((guint32)&ptr [i] & page_mask) != ((guint32)ptr & page_mask))
+                       break;
+               sprintf (hex, "0x%x ", ptr [i]);
+               strcat (current_impl, hex);
+       }
+
+       g_warning (current_impl);
+}
+
+static MonoTlsImplementation
+mono_arm_get_tls_implementation (void)
+{
+#ifdef MONO_CROSS_COMPILE
+       g_assert_not_reached ();
+#else
+       /* Discard thumb bit */
+#if defined(__linux__) && defined(HAVE_KW_THREAD) && defined(__ARM_EABI__)
+       guint32* check_addr = (guint32*) ((guint32)__aeabi_read_tp & 0xfffffffe);
+#else
+       guint32* check_addr = (guint32*) ((guint32)pthread_getspecific & 0xfffffffe);
+#endif
+       int i;
+
+       if (!mini_get_debug_options ()->arm_use_fallback_tls) {
+               for (i = 0; i < sizeof (known_tls_implementations) / sizeof (MonoTlsImplementation); i++) {
+                       if (memcmp (check_addr, known_tls_implementations [i].expected_code, known_tls_implementations [i].expected_code_length) == 0) {
+                               if ((known_tls_implementations [i].check_kernel_helper && known_kernel_helper ()) ||
+                                               !known_tls_implementations [i].check_kernel_helper)
+                                       return known_tls_implementations [i];
+                       }
+               }
+       }
+
+       g_warning ("No fast tls on device. Using fallbacks. Current implementation : ");
+       dump_code (check_addr);
+
+       return (MonoTlsImplementation) { NULL, 0, FALSE, mono_fallback_get_tls_key, NULL, mono_fallback_set_tls_key, NULL };
+#endif
+}
 #endif
index a2c8541e260be1434415cf45dee0e82cf2998eab..a491184277a8cb5e82498d15674b5dcc06e691d4 100644 (file)
@@ -29,7 +29,7 @@
 #include "mini-gc.h"
 #include "mono/arch/arm/arm-vfp-codegen.h"
 
-#if defined(HAVE_KW_THREAD) && defined(__linux__) \
+#if (defined(HAVE_KW_THREAD) && defined(__linux__) && defined(__ARM_EABI__)) \
        || defined(TARGET_ANDROID) \
        || (defined(TARGET_IOS) && !defined(TARGET_WATCHOS))
 #define HAVE_FAST_TLS
@@ -645,30 +645,6 @@ emit_restore_lmf (MonoCompile *cfg, guint8 *code, gint32 lmf_offset)
 
 #endif /* #ifndef DISABLE_JIT */
 
-#ifndef MONO_CROSS_COMPILE
-static gboolean
-mono_arm_have_fast_tls (void)
-{
-       if (mini_get_debug_options ()->arm_use_fallback_tls)
-               return FALSE;
-#if (defined(HAVE_KW_THREAD) && defined(__linux__)) \
-       || defined(TARGET_ANDROID)
-       guint32* kuser_get_tls = (void*)0xffff0fe0;
-       guint32 expected [] = {0xee1d0f70, 0xe12fff1e};
-
-       /* Expecting mrc + bx lr in the kuser_get_tls kernel helper */
-       return memcmp (kuser_get_tls, expected, 8) == 0;
-#elif defined(TARGET_IOS)
-       guint32 expected [] = {0x1f70ee1d, 0x0103f021, 0x0020f851, 0xbf004770};
-       /* Discard thumb bit */
-       guint32* pthread_getspecific_addr = (guint32*) ((guint32)pthread_getspecific & 0xfffffffe);
-       return memcmp ((void*)pthread_getspecific_addr, expected, 16) == 0;
-#else
-       return FALSE;
-#endif
-}
-#endif
-
 /*
  * mono_arm_have_tls_get:
  *
@@ -678,7 +654,6 @@ mono_arm_have_fast_tls (void)
 gboolean
 mono_arm_have_tls_get (void)
 {
-       return FALSE;
 #ifdef HAVE_FAST_TLS
        return TRUE;
 #else
@@ -2378,13 +2353,13 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                        if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = in->dreg + 1;
+                               ins->sreg1 = MONO_LVREG_LS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg, FALSE);
 
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = in->dreg + 2;
+                               ins->sreg1 = MONO_LVREG_MS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg + 1, FALSE);
                        } else if (!t->byref && ((t->type == MONO_TYPE_R8) || (t->type == MONO_TYPE_R4))) {
@@ -2481,10 +2456,10 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                        break;
                case RegTypeBaseGen:
                        if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
-                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, ARMREG_SP, ainfo->offset, (G_BYTE_ORDER == G_BIG_ENDIAN) ? in->dreg + 1 : in->dreg + 2);
+                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, ARMREG_SP, ainfo->offset, (G_BYTE_ORDER == G_BIG_ENDIAN) ? MONO_LVREG_LS (in->dreg) : MONO_LVREG_MS (in->dreg));
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = G_BYTE_ORDER == G_BIG_ENDIAN ? in->dreg + 2 : in->dreg + 1;
+                               ins->sreg1 = G_BYTE_ORDER == G_BIG_ENDIAN ? MONO_LVREG_MS (in->dreg) : MONO_LVREG_LS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ARMREG_R3, FALSE);
                        } else if (!t->byref && (t->type == MONO_TYPE_R8)) {
@@ -2682,8 +2657,8 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
                                MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg, val->dreg);
                        } else {
                                MONO_INST_NEW (cfg, ins, OP_SETLRET);
-                               ins->sreg1 = val->dreg + 1;
-                               ins->sreg2 = val->dreg + 2;
+                               ins->sreg1 = MONO_LVREG_LS (val->dreg);
+                               ins->sreg2 = MONO_LVREG_MS (val->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                        }
                        return;
@@ -3488,11 +3463,14 @@ loop_start:
                case OP_IOR_IMM:
                case OP_IXOR_IMM:
                        if ((imm8 = mono_arm_is_rotated_imm8 (ins->inst_imm, &rot_amount)) < 0) {
+                               int opcode2 = mono_op_imm_to_op (ins->opcode);
                                ADD_NEW_INS (cfg, temp, OP_ICONST);
                                temp->inst_c0 = ins->inst_imm;
                                temp->dreg = mono_alloc_ireg (cfg);
                                ins->sreg2 = temp->dreg;
-                               ins->opcode = mono_op_imm_to_op (ins->opcode);
+                               if (opcode2 == -1)
+                                       g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode));
+                               ins->opcode = opcode2;
                        }
                        if (ins->opcode == OP_SBB || ins->opcode == OP_ISBB || ins->opcode == OP_SUBCC)
                                goto loop_start;
@@ -3532,13 +3510,17 @@ loop_start:
                case OP_IDIV_IMM:
                case OP_IDIV_UN_IMM:
                case OP_IREM_IMM:
-               case OP_IREM_UN_IMM:
+               case OP_IREM_UN_IMM: {
+                       int opcode2 = mono_op_imm_to_op (ins->opcode);
                        ADD_NEW_INS (cfg, temp, OP_ICONST);
                        temp->inst_c0 = ins->inst_imm;
                        temp->dreg = mono_alloc_ireg (cfg);
                        ins->sreg2 = temp->dreg;
-                       ins->opcode = mono_op_imm_to_op (ins->opcode);
+                       if (opcode2 == -1)
+                               g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode));
+                       ins->opcode = opcode2;
                        break;
+               }
                case OP_LOCALLOC_IMM:
                        ADD_NEW_INS (cfg, temp, OP_ICONST);
                        temp->inst_c0 = ins->inst_imm;
@@ -3715,8 +3697,8 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
 
        if (long_ins->opcode == OP_LNEG) {
                ins = long_ins;
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ARM_RSBS_IMM, ins->dreg + 1, ins->sreg1 + 1, 0);
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ARM_RSC_IMM, ins->dreg + 2, ins->sreg1 + 2, 0);
+               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ARM_RSBS_IMM, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), 0);
+               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ARM_RSC_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 0);
                NULLIFY_INS (ins);
        }
 }
@@ -5992,15 +5974,17 @@ mono_arch_register_lowlevel_calls (void)
 
 #ifndef MONO_CROSS_COMPILE
        if (mono_arm_have_tls_get ()) {
-               if (mono_arm_have_fast_tls ()) {
-                       mono_register_jit_icall (mono_fast_get_tls_key, "mono_get_tls_key", mono_create_icall_signature ("ptr ptr"), TRUE);
-                       mono_register_jit_icall (mono_fast_set_tls_key, "mono_set_tls_key", mono_create_icall_signature ("void ptr ptr"), TRUE);
+               MonoTlsImplementation tls_imp = mono_arm_get_tls_implementation ();
+
+               mono_register_jit_icall (tls_imp.get_tls_thunk, "mono_get_tls_key", mono_create_icall_signature ("ptr ptr"), TRUE);
+               mono_register_jit_icall (tls_imp.set_tls_thunk, "mono_set_tls_key", mono_create_icall_signature ("void ptr ptr"), TRUE);
 
+               if (tls_imp.get_tls_thunk_end) {
                        mono_tramp_info_register (
                                mono_tramp_info_create (
                                        "mono_get_tls_key",
-                                       (guint8*)mono_fast_get_tls_key,
-                                       (guint8*)mono_fast_get_tls_key_end - (guint8*)mono_fast_get_tls_key,
+                                       (guint8*)tls_imp.get_tls_thunk,
+                                       (guint8*)tls_imp.get_tls_thunk_end - (guint8*)tls_imp.get_tls_thunk,
                                        NULL,
                                        mono_arch_get_cie_program ()
                                        ),
@@ -6009,17 +5993,13 @@ mono_arch_register_lowlevel_calls (void)
                        mono_tramp_info_register (
                                mono_tramp_info_create (
                                        "mono_set_tls_key",
-                                       (guint8*)mono_fast_set_tls_key,
-                                       (guint8*)mono_fast_set_tls_key_end - (guint8*)mono_fast_set_tls_key,
+                                       (guint8*)tls_imp.set_tls_thunk,
+                                       (guint8*)tls_imp.set_tls_thunk_end - (guint8*)tls_imp.set_tls_thunk,
                                        NULL,
                                        mono_arch_get_cie_program ()
                                        ),
                                NULL
                                );
-               } else {
-                       g_warning ("No fast tls on device. Using fallbacks.");
-                       mono_register_jit_icall (mono_fallback_get_tls_key, "mono_get_tls_key", mono_create_icall_signature ("ptr ptr"), TRUE);
-                       mono_register_jit_icall (mono_fallback_set_tls_key, "mono_set_tls_key", mono_create_icall_signature ("void ptr ptr"), TRUE);
                }
        }
 #endif
index 1994ba0a6abf5d77addee2dc77a8730b3f0df1ff..b09db53452a1993fc7f13f51d056a678d1ef3a03 100644 (file)
@@ -306,7 +306,7 @@ typedef struct MonoCompileArch {
 #endif
 
 #define MONO_ARCH_HAVE_TLS_GET (mono_arm_have_tls_get ())
-// #define MONO_ARCH_HAVE_TLS_GET_REG 1
+#define MONO_ARCH_HAVE_TLS_GET_REG 1
 
 /* ARM doesn't have too many registers, so we have to use a callee saved one */
 #define MONO_ARCH_RGCTX_REG ARMREG_V5
index 8db012832c683dda702d7e504e79a97f7a2e8f83..781aa4b4b080d0738b2c0d7867389454064f62fd 100644 (file)
@@ -519,17 +519,22 @@ get_generic_info_from_stack_frame (MonoJitInfo *ji, MonoContext *ctx)
 
        method = jinfo_get_method (ji);
        if (mono_method_get_context (method)->method_inst) {
+               /* A MonoMethodRuntimeGenericContext* */
                return info;
        } else if ((method->flags & METHOD_ATTRIBUTE_STATIC) || method->klass->valuetype) {
+               /* A MonoVTable* */
                return info;
        } else {
                /* Avoid returning a managed object */
                MonoObject *this_obj = (MonoObject *)info;
 
-               return this_obj->vtable->klass;
+               return this_obj->vtable;
        }
 }
 
+/*
+ * generic_info is either a MonoMethodRuntimeGenericContext or a MonoVTable.
+ */
 static MonoGenericContext
 get_generic_context_from_stack_frame (MonoJitInfo *ji, gpointer generic_info)
 {
@@ -547,12 +552,10 @@ get_generic_context_from_stack_frame (MonoJitInfo *ji, gpointer generic_info)
                klass = mrgctx->class_vtable->klass;
                context.method_inst = mrgctx->method_inst;
                g_assert (context.method_inst);
-       } else if ((method->flags & METHOD_ATTRIBUTE_STATIC) || method->klass->valuetype) {
+       } else {
                MonoVTable *vtable = (MonoVTable *)generic_info;
 
                klass = vtable->klass;
-       } else {
-               klass = (MonoClass *)generic_info;
        }
 
        //g_assert (!method->klass->generic_container);
@@ -677,7 +680,7 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
                        char *s;
 
                        sf->method = NULL;
-                       s = mono_method_get_name_full (method, TRUE, MONO_TYPE_NAME_FORMAT_REFLECTION);
+                       s = mono_method_get_name_full (method, TRUE, FALSE, MONO_TYPE_NAME_FORMAT_REFLECTION);
                        MONO_OBJECT_SETREF (sf, internal_method_name, mono_string_new (domain, s));
                        g_free (s);
                }
@@ -2831,29 +2834,33 @@ mono_llvm_load_exception (void)
        MonoJitTlsData *jit_tls = mono_get_jit_tls ();
 
        MonoException *mono_ex = (MonoException*)mono_gchandle_get_target (jit_tls->thrown_exc);
-       g_assert (mono_ex->trace_ips);
 
-       GList *trace_ips = NULL;
-       gpointer ip = __builtin_return_address (0);
+       if (mono_ex->trace_ips) {
+               GList *trace_ips = NULL;
+               gpointer ip = __builtin_return_address (0);
 
-       size_t upper = mono_array_length (mono_ex->trace_ips);
+               size_t upper = mono_array_length (mono_ex->trace_ips);
 
-       for (int i = 0; i < upper; i++) {
-               gpointer curr_ip = mono_array_get (mono_ex->trace_ips, gpointer, i);
-               trace_ips = g_list_prepend (trace_ips, curr_ip);
+               for (int i = 0; i < upper; i++) {
+                       gpointer curr_ip = mono_array_get (mono_ex->trace_ips, gpointer, i);
+                       trace_ips = g_list_prepend (trace_ips, curr_ip);
 
-               if (ip == curr_ip)
-                       break;
-       }
+                       if (ip == curr_ip)
+                               break;
+               }
 
-       // FIXME: Does this work correctly for rethrows?
-       // We may be discarding useful information
-       // when this gets GC'ed
-       MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_glist_to_array (trace_ips, mono_defaults.int_class));
-       g_list_free (trace_ips);
+               // FIXME: Does this work correctly for rethrows?
+               // We may be discarding useful information
+               // when this gets GC'ed
+               MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_glist_to_array (trace_ips, mono_defaults.int_class));
+               g_list_free (trace_ips);
 
-       // FIXME:
-       //MONO_OBJECT_SETREF (mono_ex, stack_trace, ves_icall_System_Exception_get_trace (mono_ex));
+               // FIXME:
+               //MONO_OBJECT_SETREF (mono_ex, stack_trace, ves_icall_System_Exception_get_trace (mono_ex));
+       } else {
+               MONO_OBJECT_SETREF (mono_ex, trace_ips, mono_array_new (mono_domain_get (), mono_defaults.int_class, 0));
+               MONO_OBJECT_SETREF (mono_ex, stack_trace, mono_array_new (mono_domain_get (), mono_defaults.stack_frame_class, 0));
+       }
 
        return &mono_ex->object;
 }
@@ -2880,7 +2887,7 @@ mono_llvm_clear_exception (void)
  * the current exception.
  */
 gint32
-mono_llvm_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end)
+mono_llvm_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end, gpointer rgctx, MonoObject *this_obj)
 {
        MonoJitTlsData *jit_tls = mono_get_jit_tls ();
        MonoObject *exc;
@@ -2890,12 +2897,25 @@ mono_llvm_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 reg
        exc = mono_gchandle_get_target (jit_tls->thrown_exc);
        for (int i = 0; i < jinfo->num_clauses; i++) {
                MonoJitExceptionInfo *ei = &jinfo->clauses [i];
+               MonoClass *catch_class;
 
                if (! (ei->try_offset == region_start && ei->try_offset + ei->try_len == region_end) )
                        continue;
 
+               catch_class = ei->data.catch_class;
+               if (catch_class->byval_arg.type == MONO_TYPE_VAR || catch_class->byval_arg.type == MONO_TYPE_MVAR || catch_class->byval_arg.type == MONO_TYPE_GENERICINST) {
+                       MonoGenericContext context;
+                       MonoType *inflated_type;
+
+                       g_assert (rgctx || this_obj);
+                       context = get_generic_context_from_stack_frame (jinfo, rgctx ? rgctx : this_obj->vtable);
+                       inflated_type = mono_class_inflate_generic_type (&catch_class->byval_arg, &context);
+                       catch_class = mono_class_from_mono_type (inflated_type);
+                       mono_metadata_free_type (inflated_type);
+               }
+
                // FIXME: Handle edge cases handled in get_exception_catch_class
-               if (ei->flags == MONO_EXCEPTION_CLAUSE_NONE && mono_object_isinst (exc, ei->data.catch_class)) {
+               if (ei->flags == MONO_EXCEPTION_CLAUSE_NONE && mono_object_isinst (exc, catch_class)) {
                        index = ei->clause_index;
                        break;
                } else if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
index 2e88f8352324d0e0ed00042e78179581869f34b9..a4963295fcbb2f1bce5c014faf3aeb1841d29cf9 100644 (file)
@@ -643,6 +643,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
 
                return &inflated_class->fields [i];
        }
+       case MONO_RGCTX_INFO_SIG_GSHAREDVT_IN_TRAMPOLINE_CALLI:
        case MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI: {
                MonoMethodSignature *sig = (MonoMethodSignature *)data;
                MonoMethodSignature *isig;
@@ -1043,6 +1044,19 @@ get_wrapper_shared_type (MonoType *t)
        t = mini_get_underlying_type (t);
 
        switch (t->type) {
+       case MONO_TYPE_I1:
+               /* This removes any attributes etc. */
+               return &mono_defaults.sbyte_class->byval_arg;
+       case MONO_TYPE_U1:
+               return &mono_defaults.byte_class->byval_arg;
+       case MONO_TYPE_I2:
+               return &mono_defaults.int16_class->byval_arg;
+       case MONO_TYPE_U2:
+               return &mono_defaults.uint16_class->byval_arg;
+       case MONO_TYPE_I4:
+               return &mono_defaults.int32_class->byval_arg;
+       case MONO_TYPE_U4:
+               return &mono_defaults.uint32_class->byval_arg;
        case MONO_TYPE_OBJECT:
        case MONO_TYPE_CLASS:
        case MONO_TYPE_SZARRAY:
@@ -1543,7 +1557,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
                        /* No need for a wrapper */
                        return mini_create_llvmonly_ftndesc (domain, addr, mini_method_get_rgctx (m));
                } else {
-                       addr = mini_add_method_wrappers_llvmonly (m, addr, FALSE, FALSE, &arg);
+                       addr = mini_add_method_wrappers_llvmonly (m, addr, TRUE, FALSE, &arg);
 
                        /* Returns an ftndesc */
                        return mini_create_llvmonly_ftndesc (domain, addr, arg);
@@ -1641,6 +1655,17 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
 
                return method->context.method_inst;
        }
+       case MONO_RGCTX_INFO_SIG_GSHAREDVT_IN_TRAMPOLINE_CALLI: {
+               MonoMethodSignature *gsig = (MonoMethodSignature *)oti->data;
+               MonoMethodSignature *sig = (MonoMethodSignature *)data;
+               gpointer addr;
+
+               /*
+                * This is an indirect call to the address passed by the caller in the rgctx reg.
+                */
+               addr = mini_get_gsharedvt_wrapper (TRUE, NULL, sig, gsig, -1, TRUE);
+               return addr;
+       }
        case MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI: {
                MonoMethodSignature *gsig = (MonoMethodSignature *)oti->data;
                MonoMethodSignature *sig = (MonoMethodSignature *)data;
@@ -1776,10 +1801,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
 
                                        gpointer in_wrapper_arg = mini_create_llvmonly_ftndesc (domain, callee_ji->code_start, mini_method_get_rgctx (method));
 
-                                       gpointer out_wrapper = mini_get_gsharedvt_wrapper (FALSE, NULL, sig, gsig, -1, FALSE);
-                                       MonoFtnDesc *out_wrapper_arg = mini_create_llvmonly_ftndesc (domain, in_wrapper, in_wrapper_arg);
-
-                                       addr = mini_create_llvmonly_ftndesc (domain, out_wrapper, out_wrapper_arg);
+                                       addr = mini_create_llvmonly_ftndesc (domain, in_wrapper, in_wrapper_arg);
                                } else {
                                        addr = mini_create_llvmonly_ftndesc (domain, addr, mini_method_get_rgctx (method));
                                }
@@ -1905,6 +1927,7 @@ mono_rgctx_info_type_to_str (MonoRgctxInfoType type)
        case MONO_RGCTX_INFO_FIELD_OFFSET: return "FIELD_OFFSET";
        case MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE: return "METHOD_GSHAREDVT_OUT_TRAMPOLINE";
        case MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE_VIRT: return "METHOD_GSHAREDVT_OUT_TRAMPOLINE_VIRT";
+       case MONO_RGCTX_INFO_SIG_GSHAREDVT_IN_TRAMPOLINE_CALLI: return "SIG_GSHAREDVT_IN_TRAMPOLINE_CALLI";
        case MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI: return "SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI";
        case MONO_RGCTX_INFO_MEMCPY: return "MEMCPY";
        case MONO_RGCTX_INFO_BZERO: return "BZERO";
@@ -2006,6 +2029,7 @@ info_equal (gpointer data1, gpointer data2, MonoRgctxInfoType info_type)
        case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE:
        case MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE:
        case MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE_VIRT:
+       case MONO_RGCTX_INFO_SIG_GSHAREDVT_IN_TRAMPOLINE_CALLI:
        case MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI:
                return data1 == data2;
        case MONO_RGCTX_INFO_VIRT_METHOD_CODE:
index 0e8838ae1223cea4ff0b043ee10d77de394a83e8..09bee82ed5f27b5b5eaf24d124bdb1f204ee7839 100644 (file)
@@ -1586,6 +1586,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
                                break;
                        }
 
+                       if (mono_op_imm_to_op (ins->opcode) == -1)
+                               g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode));
                        ins->opcode = mono_op_imm_to_op (ins->opcode);
 
                        if (ins->inst_imm == 0)
index 3cb056774a012f593ee39bde4bb32048a55f778b..4301c057b9b693b8fc55f68918848be4bbae1bd2 100644 (file)
@@ -78,7 +78,7 @@ typedef struct {
        const char *jit_got_symbol;
        const char *eh_frame_symbol;
        LLVMValueRef get_method, get_unbox_tramp;
-       LLVMValueRef init_method, init_method_gshared_rgctx, init_method_gshared_this;
+       LLVMValueRef init_method, init_method_gshared_mrgctx, init_method_gshared_this, init_method_gshared_vtable;
        LLVMValueRef code_start, code_end;
        LLVMValueRef inited_var;
        int max_inited_idx, max_method_idx;
@@ -634,6 +634,8 @@ op_to_llvm_type (int opcode)
        case OP_RCONV_TO_I2:
        case OP_RCONV_TO_U2:
                return LLVMInt16Type ();
+       case OP_RCONV_TO_U4:
+               return LLVMInt32Type ();
        case OP_FCONV_TO_I:
        case OP_FCONV_TO_U:
                return sizeof (gpointer) == 8 ? LLVMInt64Type () : LLVMInt32Type ();
@@ -1497,6 +1499,26 @@ LLVMFunctionType3 (LLVMTypeRef ReturnType,
        return LLVMFunctionType (ReturnType, param_types, 3, IsVarArg);
 }
 
+static G_GNUC_UNUSED LLVMTypeRef
+LLVMFunctionType5 (LLVMTypeRef ReturnType,
+                                  LLVMTypeRef ParamType1,
+                                  LLVMTypeRef ParamType2,
+                                  LLVMTypeRef ParamType3,
+                                  LLVMTypeRef ParamType4,
+                                  LLVMTypeRef ParamType5,
+                                  int IsVarArg)
+{
+       LLVMTypeRef param_types [5];
+
+       param_types [0] = ParamType1;
+       param_types [1] = ParamType2;
+       param_types [2] = ParamType3;
+       param_types [3] = ParamType4;
+       param_types [4] = ParamType5;
+
+       return LLVMFunctionType (ReturnType, param_types, 5, IsVarArg);
+}
+
 /*
  * create_builder:
  *
@@ -2484,6 +2506,8 @@ emit_init_icall_wrapper (MonoLLVMModule *module, const char *name, const char *i
                sig = LLVMFunctionType2 (LLVMVoidType (), IntPtrType (), LLVMInt32Type (), FALSE);
                break;
        case 1:
+       case 3:
+               /* mrgctx/vtable */
                func = LLVMAddFunction (lmodule, name, LLVMFunctionType2 (LLVMVoidType (), LLVMInt32Type (), IntPtrType (), FALSE));
                sig = LLVMFunctionType3 (LLVMVoidType (), IntPtrType (), LLVMInt32Type (), IntPtrType (), FALSE);
                break;
@@ -2548,8 +2572,9 @@ static void
 emit_init_icall_wrappers (MonoLLVMModule *module)
 {
        module->init_method = emit_init_icall_wrapper (module, "init_method", "mono_aot_init_llvm_method", 0);
-       module->init_method_gshared_rgctx = emit_init_icall_wrapper (module, "init_method_gshared_rgctx", "mono_aot_init_gshared_method_rgctx", 1);
+       module->init_method_gshared_mrgctx = emit_init_icall_wrapper (module, "init_method_gshared_mrgctx", "mono_aot_init_gshared_method_mrgctx", 1);
        module->init_method_gshared_this = emit_init_icall_wrapper (module, "init_method_gshared_this", "mono_aot_init_gshared_method_this", 2);
+       module->init_method_gshared_vtable = emit_init_icall_wrapper (module, "init_method_gshared_vtable", "mono_aot_init_gshared_method_vtable", 3);
 }
 
 static void
@@ -2664,10 +2689,16 @@ emit_init_method (EmitContext *ctx)
        LLVMPositionBuilderAtEnd (ctx->builder, notinited_bb);
 
        // FIXME: Cache
-       if (ctx->rgctx_arg) {
+       if (ctx->rgctx_arg && cfg->method->is_inflated && mono_method_get_context (cfg->method)->method_inst) {
+               args [0] = LLVMConstInt (LLVMInt32Type (), cfg->method_index, 0);
+               args [1] = convert (ctx, ctx->rgctx_arg, IntPtrType ());
+               callee = ctx->module->init_method_gshared_mrgctx;
+               call = LLVMBuildCall (builder, callee, args, 2, "");
+       } else if (ctx->rgctx_arg) {
+               /* A vtable is passed as the rgctx argument */
                args [0] = LLVMConstInt (LLVMInt32Type (), cfg->method_index, 0);
                args [1] = convert (ctx, ctx->rgctx_arg, IntPtrType ());
-               callee = ctx->module->init_method_gshared_rgctx;
+               callee = ctx->module->init_method_gshared_vtable;
                call = LLVMBuildCall (builder, callee, args, 2, "");
        } else if (cfg->gshared) {
                args [0] = LLVMConstInt (LLVMInt32Type (), cfg->method_index, 0);
@@ -2702,15 +2733,24 @@ emit_unbox_tramp (EmitContext *ctx, const char *method_name, LLVMTypeRef method_
        LLVMValueRef tramp, call, *args;
        LLVMBuilderRef builder;
        LLVMBasicBlockRef lbb;
+       LLVMCallInfo *linfo;
        char *tramp_name;
        int i, nargs;
 
        tramp_name = g_strdup_printf ("ut_%s", method_name);
        tramp = LLVMAddFunction (ctx->module->lmodule, tramp_name, method_type);
        LLVMSetLinkage (tramp, LLVMInternalLinkage);
-       LLVMAddFunctionAttr (tramp, LLVMNoUnwindAttribute);
+       linfo = ctx->linfo;
+       // FIXME: Reduce code duplication with mono_llvm_compile_method () etc.
        if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
                LLVMAddAttribute (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVMInRegAttribute);
+       if (ctx->cfg->vret_addr) {
+               LLVMSetValueName (LLVMGetParam (tramp, linfo->vret_arg_pindex), "vret");
+               if (linfo->ret.storage == LLVMArgVtypeByRef) {
+                       LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMStructRetAttribute);
+                       LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+               }
+       }
 
        lbb = LLVMAppendBasicBlock (tramp, "");
        builder = LLVMCreateBuilder ();
@@ -2731,7 +2771,10 @@ emit_unbox_tramp (EmitContext *ctx, const char *method_name, LLVMTypeRef method_
        call = LLVMBuildCall (builder, method, args, nargs, "");
        if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
                LLVMAddInstrAttribute (call, 1 + ctx->rgctx_arg_pindex, LLVMInRegAttribute);
-       mono_llvm_set_must_tail (call);
+       if (linfo->ret.storage == LLVMArgVtypeByRef)
+               LLVMAddInstrAttribute (call, 1 + linfo->vret_arg_pindex, LLVMStructRetAttribute);
+
+       //mono_llvm_set_must_tail (call);
        if (LLVMGetReturnType (method_type) == LLVMVoidType ())
                LLVMBuildRetVoid (builder);
        else
@@ -2773,8 +2816,10 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
                        vtype = type_to_llvm_type (ctx, var->inst_vtype);
                        CHECK_FAILURE (ctx);
                        /* Could be already created by an OP_VPHI */
-                       if (!ctx->addresses [var->dreg])
+                       if (!ctx->addresses [var->dreg]) {
                                ctx->addresses [var->dreg] = build_alloca (ctx, var->inst_vtype);
+                               //LLVMSetValueName (ctx->addresses [var->dreg], g_strdup_printf ("vreg_loc_%d", var->dreg));
+                       }
                        ctx->vreg_cli_types [var->dreg] = var->inst_vtype;
                }
        }
@@ -3211,6 +3256,14 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
                break;
        }
 
+       /*
+        * Sometimes the same method is called with two different signatures (i.e. with and without 'this'), so
+        * use the real callee for argument type conversion.
+        */
+       LLVMTypeRef callee_type = LLVMGetElementType (LLVMTypeOf (callee));
+       LLVMTypeRef *param_types = (LLVMTypeRef*)g_alloca (sizeof (LLVMTypeRef) * LLVMCountParamTypes (callee_type));
+       LLVMGetParamTypes (callee_type, param_types);
+
        for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
                guint32 regpair;
                int reg, pindex;
@@ -3259,7 +3312,7 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
                case LLVMArgGsharedvtFixed:
                case LLVMArgGsharedvtFixedVtype:
                        g_assert (addresses [reg]);
-                       args [pindex] = addresses [reg];
+                       args [pindex] = convert (ctx, addresses [reg], LLVMPointerType (type_to_llvm_arg_type (ctx, ainfo->type), 0));
                        break;
                case LLVMArgGsharedvtVariable:
                        g_assert (addresses [reg]);
@@ -3268,7 +3321,7 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
                default:
                        g_assert (args [pindex]);
                        if (i == 0 && sig->hasthis)
-                               args [pindex] = convert (ctx, args [pindex], ThisType ());
+                               args [pindex] = convert (ctx, args [pindex], param_types [pindex]);
                        else
                                args [pindex] = convert (ctx, args [pindex], type_to_llvm_arg_type (ctx, ainfo->type));
                        break;
@@ -3530,13 +3583,24 @@ mono_llvm_emit_match_exception_call (EmitContext *ctx, LLVMBuilderRef builder, g
 
        ctx->builder = builder;
 
-       const int num_args = 3;
+       const int num_args = 5;
        LLVMValueRef args [num_args];
        args [0] = convert (ctx, get_aotconst (ctx, MONO_PATCH_INFO_AOT_JIT_INFO, GINT_TO_POINTER (ctx->cfg->method_index)), IntPtrType ());
        args [1] = LLVMConstInt (LLVMInt32Type (), region_start, 0);
        args [2] = LLVMConstInt (LLVMInt32Type (), region_end, 0);
+       if (ctx->cfg->rgctx_var) {
+               LLVMValueRef rgctx_alloc = ctx->addresses [ctx->cfg->rgctx_var->dreg];
+               g_assert (rgctx_alloc);
+               args [3] = LLVMBuildLoad (builder, convert (ctx, rgctx_alloc, LLVMPointerType (IntPtrType (), 0)), "");
+       } else {
+               args [3] = LLVMConstInt (IntPtrType (), 0, 0);
+       }
+       if (ctx->this_arg)
+               args [4] = convert (ctx, ctx->this_arg, IntPtrType ());
+       else
+               args [4] = LLVMConstInt (IntPtrType (), 0, 0);
 
-       LLVMTypeRef match_sig = LLVMFunctionType3 (LLVMInt32Type (), IntPtrType (), LLVMInt32Type (), LLVMInt32Type (), FALSE);
+       LLVMTypeRef match_sig = LLVMFunctionType5 (LLVMInt32Type (), IntPtrType (), LLVMInt32Type (), LLVMInt32Type (), IntPtrType (), IntPtrType (), FALSE);
        LLVMValueRef callee = ctx->module->match_exc;
 
        if (!callee) {
@@ -3914,9 +3978,20 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                emit_dbg_loc (ctx, builder, ins->cil_code);
 
                nins ++;
-               if (nins > 3000 && builder == starting_builder) {
-                       /* some steps in llc are non-linear in the size of basic blocks, see #5714 */
-                       LLVM_FAILURE (ctx, "basic block too long");
+               if (nins > 1000) {
+                       /*
+                        * Some steps in llc are non-linear in the size of basic blocks, see #5714.
+                        * Start a new bblock. If the llvm optimization passes merge these, we
+                        * can work around that by doing a volatile load + cond branch from
+                        * localloc-ed memory.
+                        */
+                       //LLVM_FAILURE (ctx, "basic block too long");
+                       cbb = gen_bb (ctx, "CONT_LONG_BB");
+                       LLVMBuildBr (ctx->builder, cbb);
+                       ctx->builder = builder = create_builder (ctx);
+                       LLVMPositionBuilderAtEnd (builder, cbb);
+                       ctx->bblocks [bb->block_num].end_bblock = cbb;
+                       nins = 0;
                }
 
                if (has_terminator)
@@ -4274,10 +4349,12 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                        break;
                }
                case OP_FCEQ:
+               case OP_FCNEQ:
                case OP_FCLT:
                case OP_FCLT_UN:
                case OP_FCGT:
-               case OP_FCGT_UN: {
+               case OP_FCGT_UN:
+               case OP_FCGE: {
                        CompRelation rel;
                        LLVMValueRef cmp;
 
@@ -4731,6 +4808,9 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                case OP_RCONV_TO_U2:
                        values [ins->dreg] = LLVMBuildZExt (builder, LLVMBuildFPToUI (builder, lhs, LLVMInt16Type (), dname), LLVMInt32Type (), "");
                        break;
+               case OP_RCONV_TO_U4:
+                       values [ins->dreg] = LLVMBuildFPToUI (builder, lhs, LLVMInt32Type (), dname);
+                       break;
                case OP_FCONV_TO_I8:
                case OP_RCONV_TO_I8:
                        values [ins->dreg] = LLVMBuildFPToSI (builder, lhs, LLVMInt64Type (), dname);
@@ -5460,6 +5540,13 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                                                g_assert (addresses [ins->sreg1]);
                                                addresses [ins->dreg] = addresses [ins->sreg1];
                                        }
+                       } else if (ainfo->storage == LLVMArgGsharedvtFixed) {
+                               if (!addresses [ins->sreg1]) {
+                                       addresses [ins->sreg1] = build_alloca (ctx, t);
+                                       g_assert (values [ins->sreg1]);
+                               }
+                               LLVMBuildStore (builder, convert (ctx, values [ins->sreg1], LLVMGetElementType (LLVMTypeOf (addresses [ins->sreg1]))), addresses [ins->sreg1]);
+                               addresses [ins->dreg] = addresses [ins->sreg1];
                        } else {
                                if (!addresses [ins->sreg1]) {
                                        addresses [ins->sreg1] = build_alloca (ctx, t);
@@ -6401,7 +6488,7 @@ mono_llvm_emit_method (MonoCompile *cfg)
                if (clause->flags != MONO_EXCEPTION_CLAUSE_FINALLY && clause->flags != MONO_EXCEPTION_CLAUSE_NONE)
                        LLVM_FAILURE (ctx, "non-finally/catch clause.");
        }
-       if (header->num_clauses || (cfg->method->iflags & METHOD_IMPL_ATTRIBUTE_NOINLINING))
+       if (header->num_clauses || (cfg->method->iflags & METHOD_IMPL_ATTRIBUTE_NOINLINING) || cfg->no_inline)
                /* We can't handle inlined methods with clauses */
                LLVMAddFunctionAttr (method, LLVMNoInlineAttribute);
 
@@ -6860,7 +6947,7 @@ mono_llvm_create_vars (MonoCompile *cfg)
        sig = mono_method_signature (cfg->method);
        if (cfg->gsharedvt && cfg->llvm_only) {
                if (mini_is_gsharedvt_variable_signature (sig) && sig->ret->type != MONO_TYPE_VOID) {
-                       cfg->vret_addr = mono_compile_create_var (cfg, &mono_get_int32_class ()->byval_arg, OP_ARG);
+                       cfg->vret_addr = mono_compile_create_var (cfg, &mono_get_intptr_class ()->byval_arg, OP_ARG);
                        if (G_UNLIKELY (cfg->verbose_level > 1)) {
                                printf ("vret_addr = ");
                                mono_print_ins (cfg->vret_addr);
index b7ec0167d226bbfb142375f3d578fbe32ead03a4..027a16fa3c75ec9a48dcede0540f1996e42c2c48 100644 (file)
@@ -17,15 +17,6 @@ void     mono_llvm_check_method_supported   (MonoCompile *cfg) MONO_LLVM_INTERNA
 void     mono_llvm_free_domain_info         (MonoDomain *domain) MONO_LLVM_INTERNAL;
 MONO_API void mono_personality              (void);
 int      mono_llvm_load                     (const char* bpath);
-void     mono_llvm_rethrow_exception (MonoObject *ex);
-void     mono_llvm_throw_exception (MonoObject *ex);
-void     mono_llvm_throw_corlib_exception (guint32 ex_token_index);
-void     mono_llvm_resume_exception (void);
-gint32   mono_llvm_match_exception (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end);
-void     mono_llvm_clear_exception (void);
-MonoObject *mono_llvm_load_exception (void);
-void     mono_llvm_reset_exception (void);
-void     mono_llvm_raise_exception (MonoException *e);
 void     mono_llvm_create_vars (MonoCompile *cfg) MONO_LLVM_INTERNAL;
 
 gboolean mini_llvm_init                     (void);
index f9157a8690bc9d1ab6cdce0552381b25531de724..fd0e074ecbbe6839ce2b1d72f3af2a8ef6ffa8d6 100644 (file)
@@ -1742,13 +1742,13 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                        if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = in->dreg + 1;
+                               ins->sreg1 = MONO_LVREG_LS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg + ls_word_idx, FALSE);
 
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = in->dreg + 2;
+                               ins->sreg1 = MONO_LVREG_MS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg + ms_word_idx, FALSE);
                        } else
@@ -1967,8 +1967,8 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
                        MonoInst *ins;
 
                        MONO_INST_NEW (cfg, ins, OP_SETLRET);
-                       ins->sreg1 = val->dreg + 1;
-                       ins->sreg2 = val->dreg + 2;
+                       ins->sreg1 = MONO_LVREG_LS (val->dreg);
+                       ins->sreg2 = MONO_LVREG_MS (val->dreg);
                        MONO_ADD_INS (cfg->cbb, ins);
                        return;
                }
@@ -2616,6 +2616,8 @@ map_to_reg_reg_op (int op)
        case OP_STOREI8_MEMBASE_IMM:
                return OP_STOREI8_MEMBASE_REG;
        }
+       if (mono_op_imm_to_op (op) == -1)
+               g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (op));
        return mono_op_imm_to_op (op);
 }
 
index 962557058b4bedb68a655480a721c24b23230f71..1acee9adb16664099e5a8e2519022186b1365206 100644 (file)
@@ -387,7 +387,7 @@ MONO_SIG_HANDLER_FUNC (static, sigusr2_signal_handler)
 }
 
 static void
-add_signal_handler (int signo, gpointer handler)
+add_signal_handler (int signo, gpointer handler, int flags)
 {
        struct sigaction sa;
        struct sigaction previous_sa;
@@ -395,7 +395,7 @@ add_signal_handler (int signo, gpointer handler)
 #ifdef MONO_ARCH_USE_SIGACTION
        sa.sa_sigaction = (void (*)(int, siginfo_t *, void *))handler;
        sigemptyset (&sa.sa_mask);
-       sa.sa_flags = SA_SIGINFO;
+       sa.sa_flags = SA_SIGINFO | flags;
 #ifdef MONO_ARCH_SIGSEGV_ON_ALTSTACK
 
 /*Apple likes to deliver SIGBUS for *0 */
@@ -426,7 +426,7 @@ add_signal_handler (int signo, gpointer handler)
 #else
        sa.sa_handler = handler;
        sigemptyset (&sa.sa_mask);
-       sa.sa_flags = 0;
+       sa.sa_flags = flags;
 #endif
        g_assert (sigaction (signo, &sa, &previous_sa) != -1);
 
@@ -464,14 +464,14 @@ mono_runtime_posix_install_handlers (void)
        sigset_t signal_set;
 
        if (mini_get_debug_options ()->handle_sigint)
-               add_signal_handler (SIGINT, mono_sigint_signal_handler);
+               add_signal_handler (SIGINT, mono_sigint_signal_handler, SA_RESTART);
 
-       add_signal_handler (SIGFPE, mono_sigfpe_signal_handler);
-       add_signal_handler (SIGQUIT, sigquit_signal_handler);
-       add_signal_handler (SIGILL, mono_sigill_signal_handler);
-       add_signal_handler (SIGBUS, mono_sigsegv_signal_handler);
+       add_signal_handler (SIGFPE, mono_sigfpe_signal_handler, 0);
+       add_signal_handler (SIGQUIT, sigquit_signal_handler, SA_RESTART);
+       add_signal_handler (SIGILL, mono_sigill_signal_handler, 0);
+       add_signal_handler (SIGBUS, mono_sigsegv_signal_handler, 0);
        if (mono_jit_trace_calls != NULL)
-               add_signal_handler (SIGUSR2, sigusr2_signal_handler);
+               add_signal_handler (SIGUSR2, sigusr2_signal_handler, SA_RESTART);
 
        /* it seems to have become a common bug for some programs that run as parents
         * of many processes to block signal delivery for real time signals.
@@ -487,10 +487,10 @@ mono_runtime_posix_install_handlers (void)
 
        signal (SIGPIPE, SIG_IGN);
 
-       add_signal_handler (SIGABRT, sigabrt_signal_handler);
+       add_signal_handler (SIGABRT, sigabrt_signal_handler, 0);
 
        /* catch SIGSEGV */
-       add_signal_handler (SIGSEGV, mono_sigsegv_signal_handler);
+       add_signal_handler (SIGSEGV, mono_sigsegv_signal_handler, 0);
 }
 
 #ifndef PLATFORM_MACOSX
@@ -602,7 +602,7 @@ mono_runtime_setup_stat_profiler (void)
                        return;
                }
                profiling_signal_in_use = SIGPROF;
-               add_signal_handler (profiling_signal_in_use, sigprof_signal_handler);
+               add_signal_handler (profiling_signal_in_use, sigprof_signal_handler, SA_RESTART);
                if (ioctl (rtc_fd, RTC_IRQP_SET, freq) == -1) {
                        perror ("set rtc freq");
                        return;
@@ -633,7 +633,7 @@ mono_runtime_setup_stat_profiler (void)
                return;
        inited = 1;
        profiling_signal_in_use = get_itimer_signal ();
-       add_signal_handler (profiling_signal_in_use, sigprof_signal_handler);
+       add_signal_handler (profiling_signal_in_use, sigprof_signal_handler, SA_RESTART);
        setitimer (get_itimer_mode (), &itval, NULL);
 #endif
 }
index ee00251eeab0fc87a98ff1743637aff20d633f5e..6060e0a0782244354d369301801ad110fd8883d8 100644 (file)
@@ -1681,13 +1681,13 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                        if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = in->dreg + 1;
+                               ins->sreg1 = MONO_LVREG_LS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg + 1, FALSE);
 
                                MONO_INST_NEW (cfg, ins, OP_MOVE);
                                ins->dreg = mono_alloc_ireg (cfg);
-                               ins->sreg1 = in->dreg + 2;
+                               ins->sreg1 = MONO_LVREG_MS (in->dreg);
                                MONO_ADD_INS (cfg->cbb, ins);
                                mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg, FALSE);
                        } else
@@ -1910,8 +1910,8 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
                        MonoInst *ins;
 
                        MONO_INST_NEW (cfg, ins, OP_SETLRET);
-                       ins->sreg1 = val->dreg + 1;
-                       ins->sreg2 = val->dreg + 2;
+                       ins->sreg1 = MONO_LVREG_LS (val->dreg);
+                       ins->sreg2 = MONO_LVREG_MS (val->dreg);
                        MONO_ADD_INS (cfg->cbb, ins);
                        return;
                }
@@ -2411,32 +2411,32 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
        switch (ins->opcode) {
        case OP_LADD_OVF:
                /* ADC sets the condition code */
-               MONO_EMIT_NEW_BIALU (cfg, OP_ADDCC, ins->dreg + 1, ins->sreg1 + 1, ins->sreg2 + 1);
-               MONO_EMIT_NEW_BIALU (cfg, OP_ADD_OVF_CARRY, ins->dreg + 2, ins->sreg1 + 2, ins->sreg2 + 2);
+               MONO_EMIT_NEW_BIALU (cfg, OP_ADDCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
+               MONO_EMIT_NEW_BIALU (cfg, OP_ADD_OVF_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
                NULLIFY_INS (ins);
                break;
        case OP_LADD_OVF_UN:
                /* ADC sets the condition code */
-               MONO_EMIT_NEW_BIALU (cfg, OP_ADDCC, ins->dreg + 1, ins->sreg1 + 1, ins->sreg2 + 1);
-               MONO_EMIT_NEW_BIALU (cfg, OP_ADD_OVF_UN_CARRY, ins->dreg + 2, ins->sreg1 + 2, ins->sreg2 + 2);
+               MONO_EMIT_NEW_BIALU (cfg, OP_ADDCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
+               MONO_EMIT_NEW_BIALU (cfg, OP_ADD_OVF_UN_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
                NULLIFY_INS (ins);
                break;
        case OP_LSUB_OVF:
                /* SBB sets the condition code */
-               MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, ins->dreg + 1, ins->sreg1 + 1, ins->sreg2 + 1);
-               MONO_EMIT_NEW_BIALU (cfg, OP_SUB_OVF_CARRY, ins->dreg + 2, ins->sreg1 + 2, ins->sreg2 + 2);
+               MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
+               MONO_EMIT_NEW_BIALU (cfg, OP_SUB_OVF_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
                NULLIFY_INS (ins);
                break;
        case OP_LSUB_OVF_UN:
                /* SBB sets the condition code */
-               MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, ins->dreg + 1, ins->sreg1 + 1, ins->sreg2 + 1);
-               MONO_EMIT_NEW_BIALU (cfg, OP_SUB_OVF_UN_CARRY, ins->dreg + 2, ins->sreg1 + 2, ins->sreg2 + 2);
+               MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
+               MONO_EMIT_NEW_BIALU (cfg, OP_SUB_OVF_UN_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
                NULLIFY_INS (ins);
                break;
        case OP_LNEG:
                /* From gcc generated code */
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PPC_SUBFIC, ins->dreg + 1, ins->sreg1 + 1, 0);
-               MONO_EMIT_NEW_UNALU (cfg, OP_PPC_SUBFZE, ins->dreg + 2, ins->sreg1 + 2);
+               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PPC_SUBFIC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), 0);
+               MONO_EMIT_NEW_UNALU (cfg, OP_PPC_SUBFZE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
                NULLIFY_INS (ins);
                break;
        default:
@@ -2568,6 +2568,8 @@ map_to_reg_reg_op (int op)
        case OP_STOREI8_MEMBASE_IMM:
                return OP_STOREI8_MEMBASE_REG;
        }
+       if (mono_op_imm_to_op (op) == -1)
+               g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (op));
        return mono_op_imm_to_op (op);
 }
 
index a11f89d5c3a0ee37a174d1ff6ba2261c66e1d3aa..94fbf4f5d714e014a5ff37bbffb90361b8c775dd 100644 (file)
@@ -1262,6 +1262,8 @@ mono_patch_info_hash (gconstpointer data)
        }
        case MONO_PATCH_INFO_JIT_ICALL_ADDR:
                return (ji->type << 8) | g_str_hash (ji->data.target);
+       case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
+               return (ji->type << 8) | mono_signature_hash (ji->data.sig);
        default:
                printf ("info type: %d\n", ji->type);
                mono_print_ji (ji); printf ("\n");
@@ -1326,6 +1328,8 @@ mono_patch_info_equal (gconstpointer ka, gconstpointer kb)
                if (ji1->data.target == ji2->data.target)
                        return 1;
                return strcmp (ji1->data.target, ji2->data.target) == 0 ? 1 : 0;
+       case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
+               return mono_metadata_signature_equal (ji1->data.sig, ji2->data.sig) ? 1 : 0;
        default:
                if (ji1->data.target != ji2->data.target)
                        return 0;
@@ -1698,6 +1702,9 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
 
                break;
        }
+       case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
+               target = mini_get_gsharedvt_wrapper (TRUE, NULL, patch_info->data.sig, NULL, -1, FALSE);
+               break;
        default:
                g_assert_not_reached ();
        }
@@ -2280,15 +2287,14 @@ create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer com
 #ifndef ENABLE_GSHAREDVT
                        g_assert_not_reached ();
 #endif
+                       info->gsharedvt_invoke = TRUE;
                        if (!callee_gsharedvt) {
                                /* Invoke a gsharedvt out wrapper instead */
                                MonoMethod *wrapper = mini_get_gsharedvt_out_sig_wrapper (sig);
                                MonoMethodSignature *wrapper_sig = mini_get_gsharedvt_out_sig_wrapper_signature (sig->hasthis, sig->ret->type != MONO_TYPE_VOID, sig->param_count);
 
-                               info->gsharedvt_invoke = TRUE;
                                info->wrapper_arg = g_malloc0 (2 * sizeof (gpointer));
-                               info->wrapper_arg [0] = info->compiled_method;
-                               info->wrapper_arg [1] = mono_method_needs_static_rgctx_invoke (method, TRUE) ? mini_method_get_rgctx (method) : NULL;
+                               info->wrapper_arg [0] = mini_add_method_wrappers_llvmonly (method, info->compiled_method, FALSE, FALSE, &(info->wrapper_arg [1]));
 
                                /* Pass has_rgctx == TRUE since the wrapper has an extra arg */
                                invoke = mono_marshal_get_runtime_invoke_for_sig (wrapper_sig);
@@ -2300,7 +2306,6 @@ create_runtime_invoke_info (MonoDomain *domain, MonoMethod *method, gpointer com
                                /* The out wrapper has the same signature as the compiled gsharedvt method */
                                MonoMethodSignature *wrapper_sig = mini_get_gsharedvt_out_sig_wrapper_signature (sig->hasthis, sig->ret->type != MONO_TYPE_VOID, sig->param_count);
 
-                               info->gsharedvt_invoke = TRUE;
                                info->wrapper_arg = mono_method_needs_static_rgctx_invoke (method, TRUE) ? mini_method_get_rgctx (method) : NULL;
 
                                invoke = mono_marshal_get_runtime_invoke_for_sig (wrapper_sig);
@@ -2365,7 +2370,7 @@ mono_llvmonly_runtime_invoke (MonoMethod *method, RuntimeInvokeInfo *info, void
                        params [i] = nullable_buf;
                }
 
-               if (MONO_TYPE_IS_REFERENCE (t)) {
+               if (!t->byref && (MONO_TYPE_IS_REFERENCE (t) || t->type == MONO_TYPE_PTR)) {
                        param_refs [i] = params [i];
                        params [i] = &(param_refs [i]);
                }
@@ -2468,6 +2473,8 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
                        if (mono_llvm_only) {
                                ji = mini_jit_info_table_find (mono_domain_get (), (char *)mono_get_addr_from_ftnptr (compiled_method), NULL);
                                callee_gsharedvt = mini_jit_info_is_gsharedvt (ji);
+                               if (callee_gsharedvt)
+                                       callee_gsharedvt = mini_is_gsharedvt_variable_signature (mono_method_signature (jinfo_get_method (ji)));
                        }
 
                        if (!callee_gsharedvt)
@@ -2680,9 +2687,6 @@ mono_llvmonly_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTChec
                        virtual_generic = TRUE;
        }
 
-       if (virtual_generic)
-               g_assert (fail_tramp);
-
        /*
         * Initialize all vtable entries reachable from this imt slot, so the compiled
         * code doesn't have to check it.
@@ -2736,7 +2740,7 @@ mono_llvmonly_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTChec
                res [0] = mono_llvmonly_imt_thunk;
                break;
        }
-       if (fail_tramp)
+       if (virtual_generic || fail_tramp)
                res [0] = mono_llvmonly_fallback_imt_thunk;
        res [1] = buf;
 
@@ -3011,6 +3015,49 @@ mini_imt_entry_inited (MonoVTable *vt, int imt_slot_index)
        return (imt [imt_slot_index] != mini_get_imt_trampoline (vt, imt_slot_index));
 }
 
+static gboolean
+is_callee_gsharedvt_variable (gpointer addr)
+{
+       MonoJitInfo *ji;
+       gboolean callee_gsharedvt;
+
+       ji = mini_jit_info_table_find (mono_domain_get (), (char *)mono_get_addr_from_ftnptr (addr), NULL);
+       g_assert (ji);
+       callee_gsharedvt = mini_jit_info_is_gsharedvt (ji);
+       if (callee_gsharedvt)
+               callee_gsharedvt = mini_is_gsharedvt_variable_signature (mono_method_signature (jinfo_get_method (ji)));
+       return callee_gsharedvt;
+}
+
+gpointer
+mini_get_delegate_arg (MonoMethod *method, gpointer method_ptr)
+{
+       gpointer arg = NULL;
+
+       if (mono_method_needs_static_rgctx_invoke (method, FALSE))
+               arg = mini_method_get_rgctx (method);
+
+       /*
+        * Avoid adding gsharedvt in wrappers since they might not exist if
+        * this delegate is called through a gsharedvt delegate invoke wrapper.
+        * Instead, encode that the method is gsharedvt in del->rgctx,
+        * the CEE_MONO_CALLI_EXTRA_ARG implementation in the JIT depends on this.
+        */
+       if (method->is_inflated && is_callee_gsharedvt_variable (method_ptr)) {
+               g_assert ((((mgreg_t)arg) & 1) == 0);
+               arg = (gpointer)(((mgreg_t)arg) | 1);
+       }
+       return arg;
+}
+
+void
+mini_init_delegate (MonoDelegate *del)
+{
+       if (mono_llvm_only) {
+               del->rgctx = mini_get_delegate_arg (del->method, del->method_ptr);
+       }
+}
+
 gpointer
 mono_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *method)
 {
@@ -3439,10 +3486,10 @@ mini_init (const char *filename, const char *runtime_version)
        callbacks.debug_log = mono_debugger_agent_debug_log;
        callbacks.debug_log_is_enabled = mono_debugger_agent_debug_log_is_enabled;
        callbacks.tls_key_supported = mini_tls_key_supported;
-
        callbacks.get_vtable_trampoline = mini_get_vtable_trampoline;
        callbacks.get_imt_trampoline = mini_get_imt_trampoline;
        callbacks.imt_entry_inited = mini_imt_entry_inited;
+       callbacks.init_delegate = mini_init_delegate;
 
        mono_install_callbacks (&callbacks);
 
@@ -3819,7 +3866,7 @@ register_icalls (void)
        register_icall (mono_ldstr, "mono_ldstr", "object ptr ptr int32", FALSE);
        register_icall (mono_helper_stelem_ref_check, "mono_helper_stelem_ref_check", "void object object", FALSE);
        register_icall (mono_object_new, "mono_object_new", "object ptr ptr", FALSE);
-       register_icall (mono_object_new_specific, "mono_object_new_specific", "object ptr", FALSE);
+       register_icall (ves_icall_object_new_specific, "ves_icall_object_new_specific", "object ptr", FALSE);
        register_icall (mono_array_new, "mono_array_new", "object ptr ptr int32", FALSE);
        register_icall (mono_array_new_specific, "mono_array_new_specific", "object ptr int32", FALSE);
        register_icall (mono_runtime_class_init, "mono_runtime_class_init", "void ptr", FALSE);
@@ -3857,17 +3904,21 @@ register_icalls (void)
 
        register_icall (mono_aot_init_llvm_method, "mono_aot_init_llvm_method", "void ptr int", TRUE);
        register_icall (mono_aot_init_gshared_method_this, "mono_aot_init_gshared_method_this", "void ptr int object", TRUE);
-       register_icall (mono_aot_init_gshared_method_rgctx, "mono_aot_init_gshared_method_rgctx", "void ptr int ptr", TRUE);
+       register_icall (mono_aot_init_gshared_method_mrgctx, "mono_aot_init_gshared_method_mrgctx", "void ptr int ptr", TRUE);
+       register_icall (mono_aot_init_gshared_method_vtable, "mono_aot_init_gshared_method_vtable", "void ptr int ptr", TRUE);
 
        register_icall_no_wrapper (mono_resolve_iface_call_gsharedvt, "mono_resolve_iface_call_gsharedvt", "ptr object int ptr ptr");
        register_icall_no_wrapper (mono_resolve_vcall_gsharedvt, "mono_resolve_vcall_gsharedvt", "ptr object int ptr ptr");
        register_icall_no_wrapper (mono_resolve_generic_virtual_call, "mono_resolve_generic_virtual_call", "ptr ptr int ptr");
        register_icall_no_wrapper (mono_resolve_generic_virtual_iface_call, "mono_resolve_generic_virtual_iface_call", "ptr ptr int ptr");
+       register_icall_no_wrapper (mono_llvmonly_set_calling_assembly, "mono_llvmonly_set_calling_assembly", "void ptr");
+       register_icall_no_wrapper (mono_llvmonly_get_calling_assembly, "mono_llvmonly_get_calling_assembly", "object");
        /* This needs a wrapper so it can have a preserveall cconv */
        register_icall (mono_init_vtable_slot, "mono_init_vtable_slot", "ptr ptr int", FALSE);
-       register_icall (mono_init_delegate, "mono_init_delegate", "void object object ptr", TRUE);
-       register_icall (mono_init_delegate_virtual, "mono_init_delegate_virtual", "void object object ptr", TRUE);
+       register_icall (mono_llvmonly_init_delegate, "mono_llvmonly_init_delegate", "void object", TRUE);
+       register_icall (mono_llvmonly_init_delegate_virtual, "mono_llvmonly_init_delegate_virtual", "void object object ptr", TRUE);
        register_icall (mono_get_assembly_object, "mono_get_assembly_object", "object ptr", TRUE);
+       register_icall (mono_get_method_object, "mono_get_method_object", "object ptr", TRUE);
 
 #ifdef TARGET_IOS
        register_icall (pthread_getspecific, "pthread_getspecific", "ptr ptr", TRUE);
index af0805adf29335282fcb7eae617ff1304bd07317..d64be482f1280c6bb10814d58dae25f97fdc5be8 100644 (file)
@@ -801,8 +801,8 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                case ArgInIRegPair: {
                        MonoType *t = mini_get_underlying_type (sig->ret);
                        if (((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
-                               MonoInst *low = get_vreg_to_inst (cfg, cfg->ret->dreg + 1);
-                               MonoInst *high = get_vreg_to_inst (cfg, cfg->ret->dreg + 2);
+                               MonoInst *low = get_vreg_to_inst (cfg, MONO_LVREG_LS (cfg->ret->dreg));
+                               MonoInst *high = get_vreg_to_inst (cfg, MONO_LVREG_MS (cfg->ret->dreg));
 
                                low->opcode = OP_REGVAR;
                                low->dreg = cinfo->ret.reg + 1;
@@ -943,8 +943,8 @@ mono_arch_allocate_vars (MonoCompile *cfg)
                                break;
                        case ArgInIRegPair:
                                if (inst->type == STACK_I8) {
-                                       MonoInst *low = get_vreg_to_inst (cfg, inst->dreg + 1);
-                                       MonoInst *high = get_vreg_to_inst (cfg, inst->dreg + 2);
+                                       MonoInst *low = get_vreg_to_inst (cfg, MONO_LVREG_LS (inst->dreg));
+                                       MonoInst *high = get_vreg_to_inst (cfg, MONO_LVREG_MS (inst->dreg));
 
                                        low->opcode = OP_REGVAR;
                                        low->dreg = sparc_i0 + ainfo->reg + 1;
@@ -1032,8 +1032,8 @@ mono_arch_create_vars (MonoCompile *cfg)
        }
 
        if (!sig->ret->byref && (sig->ret->type == MONO_TYPE_I8 || sig->ret->type == MONO_TYPE_U8)) {
-               MonoInst *low = get_vreg_to_inst (cfg, cfg->ret->dreg + 1);
-               MonoInst *high = get_vreg_to_inst (cfg, cfg->ret->dreg + 2);
+               MonoInst *low = get_vreg_to_inst (cfg, MONO_LVREG_LS (cfg->ret->dreg));
+               MonoInst *high = get_vreg_to_inst (cfg, MONO_LVREG_MS (cfg->ret->dreg));
 
                low->flags |= MONO_INST_VOLATILE;
                high->flags |= MONO_INST_VOLATILE;
@@ -1090,16 +1090,16 @@ emit_pass_long (MonoCompile *cfg, MonoCallInst *call, ArgInfo *ainfo, MonoInst *
 
        switch (ainfo->storage) {
        case ArgInIRegPair:
-               add_outarg_reg (cfg, call, ArgInIReg, sparc_o0 + ainfo->reg + 1, in->dreg + 1);
-               add_outarg_reg (cfg, call, ArgInIReg, sparc_o0 + ainfo->reg, in->dreg + 2);
+               add_outarg_reg (cfg, call, ArgInIReg, sparc_o0 + ainfo->reg + 1, MONO_LVREG_LS (in->dreg));
+               add_outarg_reg (cfg, call, ArgInIReg, sparc_o0 + ainfo->reg, MONO_LVREG_MS (in->dreg));
                break;
        case ArgOnStackPair:
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, sparc_sp, offset, in->dreg + 2);
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, sparc_sp, offset + 4, in->dreg + 1);
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, sparc_sp, offset, MONO_LVREG_MS (in->dreg));
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, sparc_sp, offset + 4, MONO_LVREG_LS (in->dreg));
                break;
        case ArgInSplitRegStack:
-               add_outarg_reg (cfg, call, ArgInIReg, sparc_o0 + ainfo->reg, in->dreg + 2);
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, sparc_sp, offset + 4, in->dreg + 1);
+               add_outarg_reg (cfg, call, ArgInIReg, sparc_o0 + ainfo->reg, MONO_LVREG_MS (in->dreg));
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, sparc_sp, offset + 4, MONO_LVREG_LS (in->dreg));
                break;
        default:
                g_assert_not_reached ();
@@ -1347,8 +1347,8 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
                if (ret->type == MONO_TYPE_I8 || ret->type == MONO_TYPE_U8) {
                        MONO_EMIT_NEW_UNALU (cfg, OP_LMOVE, cfg->ret->dreg, val->dreg);
                } else {
-                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg + 2, val->dreg + 2);
-                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg + 1, val->dreg + 1);
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_MS (cfg->ret->dreg), MONO_LVREG_MS (val->dreg));
+                       MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, MONO_LVREG_LS (cfg->ret->dreg), MONO_LVREG_LS (val->dreg));
                }
                break;
        case ArgInFReg:
@@ -1822,8 +1822,8 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
 {
        switch (ins->opcode) {
        case OP_LNEG:
-               MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, ins->dreg + 1, 0, ins->sreg1 + 1);
-               MONO_EMIT_NEW_BIALU (cfg, OP_SBB, ins->dreg + 2, 0, ins->sreg1 + 2);
+               MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, MONO_LVREG_LS (ins->dreg), 0, MONO_LVREG_LS (ins->sreg1));
+               MONO_EMIT_NEW_BIALU (cfg, OP_SBB, MONO_LVREG_MS (ins->dreg), 0, MONO_LVREG_MS (ins->sreg1));
                NULLIFY_INS (ins);
                break;
        default:
index 116d97782807134fd85cfcd7add1473b1753657d..d40ace4cd3e242bd3dc7af301f0c31b4f10a0a15 100644 (file)
@@ -406,7 +406,7 @@ mini_create_llvmonly_ftndesc (MonoDomain *domain, gpointer addr, gpointer arg)
 gpointer
 mini_add_method_wrappers_llvmonly (MonoMethod *m, gpointer compiled_method, gboolean caller_gsharedvt, gboolean add_unbox_tramp, gpointer *out_arg)
 {
-       gpointer addr = compiled_method;
+       gpointer addr;
        gboolean callee_gsharedvt, callee_array_helper;
        MonoMethod *jmethod = NULL;
        MonoJitInfo *ji;
@@ -465,6 +465,7 @@ mini_add_method_wrappers_llvmonly (MonoMethod *m, gpointer compiled_method, gboo
 
        if (!caller_gsharedvt && callee_gsharedvt) {
                MonoMethodSignature *sig, *gsig;
+               gpointer wrapper_addr;
 
                /* Here m is a generic instance, while ji->method is the gsharedvt method implementing it */
 
@@ -472,12 +473,13 @@ mini_add_method_wrappers_llvmonly (MonoMethod *m, gpointer compiled_method, gboo
                sig = mono_method_signature (m);
                gsig = mono_method_signature (jmethod);
 
-               addr = mini_get_gsharedvt_wrapper (TRUE, addr, sig, gsig, -1, FALSE);
+               wrapper_addr = mini_get_gsharedvt_wrapper (TRUE, addr, sig, gsig, -1, FALSE);
 
                /*
                 * This is a gsharedvt in wrapper, it gets passed a ftndesc for the gsharedvt method as an argument.
                 */
-               *out_arg = mini_create_llvmonly_ftndesc (mono_domain_get (), compiled_method, mini_method_get_rgctx (m));
+               *out_arg = mini_create_llvmonly_ftndesc (mono_domain_get (), addr, mini_method_get_rgctx (m));
+               addr = wrapper_addr;
                //printf ("IN: %s\n", mono_method_full_name (m, TRUE));
        }
 
index a74765570f76a2139af0e55533dacdfb50ab8a66..dfea009165db3619193940062ed2c720a88ebf9b 100644 (file)
@@ -1537,8 +1537,8 @@ mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
                                                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER8_MEMBASE_REG, X86_ESP, ainfo->offset, in->dreg);
                                                argsize = 8;
                                        } else if (t->type == MONO_TYPE_I8 || t->type == MONO_TYPE_U8) {
-                                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, X86_ESP, ainfo->offset + 4, in->dreg + 2);
-                                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, X86_ESP, ainfo->offset, in->dreg + 1);
+                                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, X86_ESP, ainfo->offset + 4, MONO_LVREG_MS (in->dreg));
+                                               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, X86_ESP, ainfo->offset, MONO_LVREG_LS (in->dreg));
                                                argsize = 4;
                                        } else {
                                                MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, X86_ESP, ainfo->offset, in->dreg);
@@ -1674,8 +1674,8 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
                        if (COMPILE_LLVM (cfg))
                                MONO_EMIT_NEW_UNALU (cfg, OP_LMOVE, cfg->ret->dreg, val->dreg);
                        else {
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, X86_EAX, val->dreg + 1);
-                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, X86_EDX, val->dreg + 2);
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, X86_EAX, MONO_LVREG_LS (val->dreg));
+                               MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, X86_EDX, MONO_LVREG_MS (val->dreg));
                        }
                        return;
                }
@@ -6486,9 +6486,9 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
 
        if (long_ins->opcode == OP_LNEG) {
                ins = long_ins;
-               MONO_EMIT_NEW_UNALU (cfg, OP_INEG, ins->dreg + 1, ins->sreg1 + 1);
-               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADC_IMM, ins->dreg + 2, ins->sreg1 + 2, 0);
-               MONO_EMIT_NEW_UNALU (cfg, OP_INEG, ins->dreg + 2, ins->dreg + 2);
+               MONO_EMIT_NEW_UNALU (cfg, OP_INEG, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1));
+               MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ADC_IMM, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), 0);
+               MONO_EMIT_NEW_UNALU (cfg, OP_INEG, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->dreg));
                NULLIFY_INS (ins);
                return;
        }
@@ -6517,7 +6517,7 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
                ins->klass = mono_defaults.int32_class;
                ins->sreg1 = vreg;
                ins->type = STACK_I4;
-               ins->dreg = long_ins->dreg + 1;
+               ins->dreg = MONO_LVREG_LS (long_ins->dreg);
                MONO_ADD_INS (cfg->cbb, ins);
        
                MONO_INST_NEW (cfg, ins, OP_PSHUFLED);
@@ -6532,7 +6532,7 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
                ins->klass = mono_defaults.int32_class;
                ins->sreg1 = vreg;
                ins->type = STACK_I4;
-               ins->dreg = long_ins->dreg + 2;
+               ins->dreg = MONO_LVREG_MS (long_ins->dreg);
                MONO_ADD_INS (cfg->cbb, ins);
        
                long_ins->opcode = OP_NOP;
@@ -6541,14 +6541,14 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
                MONO_INST_NEW (cfg, ins, OP_INSERTX_I4_SLOW);
                ins->dreg = long_ins->dreg;
                ins->sreg1 = long_ins->dreg;
-               ins->sreg2 = long_ins->sreg2 + 1;
+               ins->sreg2 = MONO_LVREG_LS (long_ins->sreg2);
                ins->inst_c0 = long_ins->inst_c0 * 2;
                MONO_ADD_INS (cfg->cbb, ins);
 
                MONO_INST_NEW (cfg, ins, OP_INSERTX_I4_SLOW);
                ins->dreg = long_ins->dreg;
                ins->sreg1 = long_ins->dreg;
-               ins->sreg2 = long_ins->sreg2 + 2;
+               ins->sreg2 = MONO_LVREG_MS (long_ins->sreg2);
                ins->inst_c0 = long_ins->inst_c0 * 2 + 1;
                MONO_ADD_INS (cfg->cbb, ins);
 
@@ -6557,7 +6557,7 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
        case OP_EXPAND_I8:
                MONO_INST_NEW (cfg, ins, OP_ICONV_TO_X);
                ins->dreg = long_ins->dreg;
-               ins->sreg1 = long_ins->sreg1 + 1;
+               ins->sreg1 = MONO_LVREG_LS (long_ins->sreg1);
                ins->klass = long_ins->klass;
                ins->type = STACK_VTYPE;
                MONO_ADD_INS (cfg->cbb, ins);
@@ -6565,7 +6565,7 @@ mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *long_ins)
                MONO_INST_NEW (cfg, ins, OP_INSERTX_I4_SLOW);
                ins->dreg = long_ins->dreg;
                ins->sreg1 = long_ins->dreg;
-               ins->sreg2 = long_ins->sreg1 + 2;
+               ins->sreg2 = MONO_LVREG_MS (long_ins->sreg1);
                ins->inst_c0 = 1;
                ins->klass = long_ins->klass;
                ins->type = STACK_VTYPE;
index 82a94497d411de4482b3ef8d38d43d4014d5057b..7a490f01304c16d85d0ded4c14478ddc8cbc4bd6 100644 (file)
@@ -666,6 +666,8 @@ mono_op_imm_to_op (int opcode)
                return OP_LSUB;
        case OP_IMUL_IMM:
                return OP_IMUL;
+       case OP_LMUL_IMM:
+               return OP_LMUL;
        case OP_AND_IMM:
 #if SIZEOF_REGISTER == 4
                return OP_IAND;
@@ -710,10 +712,16 @@ mono_op_imm_to_op (int opcode)
                return OP_LSHR_UN;
        case OP_IDIV_IMM:
                return OP_IDIV;
+       case OP_LDIV_IMM:
+               return OP_LDIV;
        case OP_IDIV_UN_IMM:
                return OP_IDIV_UN;
+       case OP_LDIV_UN_IMM:
+               return OP_LDIV_UN;
        case OP_IREM_UN_IMM:
                return OP_IREM_UN;
+       case OP_LREM_UN_IMM:
+               return OP_LREM_UN;
        case OP_IREM_IMM:
                return OP_IREM;
        case OP_LREM_IMM:
@@ -748,11 +756,9 @@ mono_op_imm_to_op (int opcode)
                return OP_ICOMPARE;
        case OP_LOCALLOC_IMM:
                return OP_LOCALLOC;
-       default:
-               printf ("%s\n", mono_inst_name (opcode));
-               g_assert_not_reached ();
-               return -1;
        }
+
+       return -1;
 }
 
 /*
@@ -763,17 +769,41 @@ mono_op_imm_to_op (int opcode)
 void
 mono_decompose_op_imm (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins)
 {
+       int opcode2 = mono_op_imm_to_op (ins->opcode);
        MonoInst *temp;
+       guint32 dreg;
+       const char *spec = INS_INFO (ins->opcode);
+
+       if (spec [MONO_INST_SRC2] == 'l') {
+               dreg = mono_alloc_lreg (cfg);
+
+               /* Load the 64bit constant using decomposed ops */
+               MONO_INST_NEW (cfg, temp, OP_ICONST);
+               temp->inst_c0 = ins->inst_ls_word;
+               temp->dreg = MONO_LVREG_LS (dreg);
+               mono_bblock_insert_before_ins (bb, ins, temp);
+
+               MONO_INST_NEW (cfg, temp, OP_ICONST);
+               temp->inst_c0 = ins->inst_ms_word;
+               temp->dreg = MONO_LVREG_MS (dreg);
+       } else {
+               dreg = mono_alloc_ireg (cfg);
+
+               MONO_INST_NEW (cfg, temp, OP_ICONST);
+               temp->inst_c0 = ins->inst_imm;
+               temp->dreg = dreg;
+       }
 
-       MONO_INST_NEW (cfg, temp, OP_ICONST);
-       temp->inst_c0 = ins->inst_imm;
-       temp->dreg = mono_alloc_ireg (cfg);
        mono_bblock_insert_before_ins (bb, ins, temp);
-       ins->opcode = mono_op_imm_to_op (ins->opcode);
+
+       if (opcode2 == -1)
+                g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (ins->opcode));
+       ins->opcode = opcode2;
+
        if (ins->opcode == OP_LOCALLOC)
-               ins->sreg1 = temp->dreg;
+               ins->sreg1 = dreg;
        else
-               ins->sreg2 = temp->dreg;
+               ins->sreg2 = dreg;
 
        bb->max_vreg = MAX (bb->max_vreg, cfg->next_vreg);
 }
@@ -870,7 +900,7 @@ mono_compile_create_var_for_vreg (MonoCompile *cfg, MonoType *type, int opcode,
                 */
 
                if (cfg->verbose_level >= 4) {
-                       printf ("  Create LVAR R%d (R%d, R%d)\n", inst->dreg, inst->dreg + 1, inst->dreg + 2);
+                       printf ("  Create LVAR R%d (R%d, R%d)\n", inst->dreg, MONO_LVREG_LS (inst->dreg), MONO_LVREG_MS (inst->dreg));
                }
 
                if (mono_arch_is_soft_float () && cfg->opt & MONO_OPT_SSA) {
@@ -880,7 +910,7 @@ mono_compile_create_var_for_vreg (MonoCompile *cfg, MonoType *type, int opcode,
 
                /* Allocate a dummy MonoInst for the first vreg */
                MONO_INST_NEW (cfg, tree, OP_LOCAL);
-               tree->dreg = inst->dreg + 1;
+               tree->dreg = MONO_LVREG_LS (inst->dreg);
                if (cfg->opt & MONO_OPT_SSA)
                        tree->flags = MONO_INST_VOLATILE;
                tree->inst_c0 = num;
@@ -888,11 +918,11 @@ mono_compile_create_var_for_vreg (MonoCompile *cfg, MonoType *type, int opcode,
                tree->inst_vtype = &mono_defaults.int32_class->byval_arg;
                tree->klass = mono_class_from_mono_type (tree->inst_vtype);
 
-               set_vreg_to_inst (cfg, inst->dreg + 1, tree);
+               set_vreg_to_inst (cfg, MONO_LVREG_LS (inst->dreg), tree);
 
                /* Allocate a dummy MonoInst for the second vreg */
                MONO_INST_NEW (cfg, tree, OP_LOCAL);
-               tree->dreg = inst->dreg + 2;
+               tree->dreg = MONO_LVREG_MS (inst->dreg);
                if (cfg->opt & MONO_OPT_SSA)
                        tree->flags = MONO_INST_VOLATILE;
                tree->inst_c0 = num;
@@ -900,7 +930,7 @@ mono_compile_create_var_for_vreg (MonoCompile *cfg, MonoType *type, int opcode,
                tree->inst_vtype = &mono_defaults.int32_class->byval_arg;
                tree->klass = mono_class_from_mono_type (tree->inst_vtype);
 
-               set_vreg_to_inst (cfg, inst->dreg + 2, tree);
+               set_vreg_to_inst (cfg, MONO_LVREG_MS (inst->dreg), tree);
        }
 
        cfg->num_varinfo++;
@@ -3678,7 +3708,12 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        /* Should be done before branch opts */
        if (cfg->opt & (MONO_OPT_CONSPROP | MONO_OPT_COPYPROP))
                mono_local_cprop (cfg);
-
+       /*
+        * Should be done after cprop which can do strength reduction on
+        * some of these ops, after propagating immediates.
+        */
+       if (cfg->has_emulated_ops)
+               mono_local_emulate_ops (cfg);
        if (cfg->opt & MONO_OPT_BRANCH)
                mono_optimize_branches (cfg);
 
index 3c75f2c8b897544ba09ac8d569ad8620773311f3..37d5f08ebccdc9d49c9eb2ad7773753baf428142 100644 (file)
 #define inst_ls_word data.op[MINI_LS_WORD_IDX].const_val
 #define inst_ms_word data.op[MINI_MS_WORD_IDX].const_val
 
+#define MONO_LVREG_LS(lvreg)   ((lvreg) + 1)
+#define MONO_LVREG_MS(lvreg)   ((lvreg) + 2)
+
 #ifndef DISABLE_AOT
 #define MONO_USE_AOT_COMPILER
 #endif
 
 /* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 130
+#define MONO_AOT_FILE_VERSION 131
 
 //TODO: This is x86/amd64 specific.
 #define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
@@ -1158,6 +1161,11 @@ typedef struct {
         * The current exception in flight
         */
        guint32 thrown_exc;
+
+       /*
+        * The calling assembly in llvmonly mode.
+        */
+       MonoImage *calling_image;
 } MonoJitTlsData;
 
 /*
@@ -1215,6 +1223,7 @@ typedef enum {
        MONO_RGCTX_INFO_METHOD_GSHAREDVT_OUT_TRAMPOLINE_VIRT,
        /* Same for calli, associated with a signature */
        MONO_RGCTX_INFO_SIG_GSHAREDVT_OUT_TRAMPOLINE_CALLI,
+       MONO_RGCTX_INFO_SIG_GSHAREDVT_IN_TRAMPOLINE_CALLI,
        /* One of MONO_GSHAREDVT_BOX_TYPE */
        MONO_RGCTX_INFO_CLASS_BOX_TYPE,
        /* Resolves to a MonoGSharedVtMethodRuntimeInfo */
@@ -1677,6 +1686,7 @@ typedef struct {
        guint            compute_gc_maps : 1;
        guint            soft_breakpoints : 1;
        guint            arch_eh_jit_info : 1;
+       guint            has_emulated_ops : 1;
        guint            has_indirection : 1;
        guint            has_atomic_add_i4 : 1;
        guint            has_atomic_exchange_i4 : 1;
@@ -1684,6 +1694,8 @@ typedef struct {
        guint            check_pinvoke_callconv : 1;
        guint            has_unwind_info_for_epilog : 1;
        guint            disable_inline : 1;
+       /* Disable inlining into caller */
+       guint            no_inline : 1;
        guint            gshared : 1;
        guint            gsharedvt : 1;
        guint            r4fp : 1;
@@ -2446,7 +2458,8 @@ void     mono_aot_register_jit_icall        (const char *name, gpointer addr);
 guint32  mono_aot_find_method_index         (MonoMethod *method);
 void     mono_aot_init_llvm_method          (gpointer aot_module, guint32 method_index);
 void     mono_aot_init_gshared_method_this  (gpointer aot_module, guint32 method_index, MonoObject *this_ins);
-void     mono_aot_init_gshared_method_rgctx  (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx);
+void     mono_aot_init_gshared_method_mrgctx  (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx);
+void     mono_aot_init_gshared_method_vtable  (gpointer aot_module, guint32 method_index, MonoVTable *vtable);
 
 /* This is an exported function */
 MONO_API void     mono_aot_register_module           (gpointer *aot_info);
@@ -2574,12 +2587,15 @@ void              mono_decompose_long_opts (MonoCompile *cfg);
 void              mono_decompose_vtype_opts (MonoCompile *cfg);
 void              mono_decompose_array_access_opts (MonoCompile *cfg);
 void              mono_decompose_soft_float (MonoCompile *cfg);
+void              mono_local_emulate_ops (MonoCompile *cfg);
 void              mono_handle_global_vregs (MonoCompile *cfg);
 void              mono_spill_global_vars (MonoCompile *cfg, gboolean *need_local_opts);
 void              mono_allocate_gsharedvt_vars (MonoCompile *cfg);
 void              mono_if_conversion (MonoCompile *cfg);
 
-/* virtual function delegate */
+/* Delegates */
+gpointer          mini_get_delegate_arg (MonoMethod *method, gpointer method_ptr);
+void              mini_init_delegate (MonoDelegate *del);
 gpointer          mono_get_delegate_virtual_invoke_impl  (MonoMethodSignature *sig, MonoMethod *method);
 
 /* methods that must be provided by the arch-specific port */
@@ -2788,6 +2804,15 @@ MONO_API gboolean mono_exception_walk_trace     (MonoException *ex, MonoExceptio
 void mono_restore_context                       (MonoContext *ctx);
 guint8* mono_jinfo_get_unwind_info              (MonoJitInfo *ji, guint32 *unwind_info_len);
 int  mono_jinfo_get_epilog_size                 (MonoJitInfo *ji);
+void     mono_llvm_rethrow_exception            (MonoObject *ex);
+void     mono_llvm_throw_exception              (MonoObject *ex);
+void     mono_llvm_throw_corlib_exception       (guint32 ex_token_index);
+void     mono_llvm_resume_exception             (void);
+void     mono_llvm_clear_exception              (void);
+MonoObject *mono_llvm_load_exception            (void);
+void     mono_llvm_reset_exception              (void);
+void     mono_llvm_raise_exception              (MonoException *e);
+gint32 mono_llvm_match_exception                (MonoJitInfo *jinfo, guint32 region_start, guint32 region_end, gpointer rgctx, MonoObject *this_obj);
 
 gboolean
 mono_find_jit_info_ext (MonoDomain *domain, MonoJitTlsData *jit_tls, 
index c9b9885e18ba3906b59224c477e92b7c81289047..a29cdafe8002eba9a9b33d34b86a6039d1c253cb 100644 (file)
@@ -58,3 +58,4 @@ PATCH_INFO(NONE, "none")
 PATCH_INFO(AOT_MODULE, "aot_module")
 PATCH_INFO(AOT_JIT_INFO, "aot_jit_info")
 PATCH_INFO(GC_NURSERY_BITS, "gc_nursery_bits")
+PATCH_INFO(GSHAREDVT_IN_WRAPPER, "gsharedvt_in_wrapper")
index ac22ca41f070d0201b7c4b55371cc597b1e97a51..9afb2ed79933baef0950c674d5328ea3d874fcf0 100644 (file)
 #include "seq-points.h"
 
 static void
-collect_pred_seq_points (MonoBasicBlock *bb, MonoInst *ins, GSList **next, int depth)
+insert_pred_seq_point (MonoBasicBlock *in_bb, MonoInst *ins, GSList **next)
 {
-       int i;
-       MonoBasicBlock *in_bb;
        GSList *l;
+       int src_index = in_bb->last_seq_point->backend.size;
+       int dst_index = ins->backend.size;
+
+       /* bb->in_bb might contain duplicates */
+       for (l = next [src_index]; l; l = l->next)
+               if (GPOINTER_TO_UINT (l->data) == dst_index)
+                       break;
+       if (!l)
+               next [src_index] = g_slist_append (next [src_index], GUINT_TO_POINTER (dst_index));
+}
 
-       for (i = 0; i < bb->in_count; ++i) {
-               in_bb = bb->in_bb [i];
+static void
+collect_pred_seq_points (MonoBasicBlock *bb, MonoInst *ins, GSList **next, GHashTable *memoize)
+{
+       const gpointer MONO_SEQ_SEEN_LOOP = GINT_TO_POINTER(-1);
 
-               if (in_bb->last_seq_point) {
-                       int src_index = in_bb->last_seq_point->backend.size;
-                       int dst_index = ins->backend.size;
+       for (int i = 0; i < bb->in_count; ++i) {
+               MonoBasicBlock *in_bb = bb->in_bb [i];
+               gpointer result = g_hash_table_lookup (memoize, in_bb);
 
-                       /* bb->in_bb might contain duplicates */
-                       for (l = next [src_index]; l; l = l->next)
-                               if (GPOINTER_TO_UINT (l->data) == dst_index)
-                                       break;
-                       if (!l)
-                               next [src_index] = g_slist_append (next [src_index], GUINT_TO_POINTER (dst_index));
+               if (result == MONO_SEQ_SEEN_LOOP) {
+                       // We've looped or handled this before, exit early.
+                       // No last sequence points to find.
+                       continue;
+               } else if (in_bb->last_seq_point) {
+                       // if last seq point, insert into next
+                       insert_pred_seq_point (in_bb, ins, next);
                } else {
-                       /* Have to look at its predecessors */
-                       if (depth < 5)
-                               collect_pred_seq_points (in_bb, ins, next, depth + 1);
+                       // Compute predecessors of in_bb
+
+                       // Insert/remove sentinel into the memoize table to detect loops containing in_bb
+                       // This works to ensure that we only have a basic block on the stack once
+                       // at any given time
+                       g_hash_table_insert (memoize, in_bb, MONO_SEQ_SEEN_LOOP);
+                       collect_pred_seq_points (in_bb, ins, next, memoize);
+                       g_hash_table_remove (memoize, in_bb);
                }
        }
 }
@@ -75,6 +91,7 @@ mono_save_seq_point_info (MonoCompile *cfg)
                 * following it, this is needed to implement 'step over' in the debugger agent.
                 */
                next = g_new0 (GSList*, cfg->seq_points->len);
+               GHashTable *memoize = g_hash_table_new (NULL, NULL);
                for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
                        bb_seq_points = g_slist_reverse (bb->seq_points);
                        last = NULL;
@@ -92,7 +109,7 @@ mono_save_seq_point_info (MonoCompile *cfg)
                                        next [last->backend.size] = g_slist_append (next [last->backend.size], GUINT_TO_POINTER (ins->backend.size));
                                } else {
                                        /* Link with the last bb in the previous bblocks */
-                                       collect_pred_seq_points (bb, ins, next, 0);
+                                       collect_pred_seq_points (bb, ins, next, memoize);
                                }
 
                                last = ins;
@@ -123,6 +140,7 @@ mono_save_seq_point_info (MonoCompile *cfg)
                                }
                        }
                }
+               g_hash_table_destroy (memoize);
 
                if (cfg->verbose_level > 2) {
                        printf ("\nSEQ POINT MAP: \n");
index 06508eb512f0bdd1d3ebb596e052300dcc3fe420..eb42a0279c1faf464a2b0840c7a8b611d95a4a2b 100755 (executable)
@@ -16,7 +16,7 @@ tmp_file () {
 }
 
 clean_aot () {
-       rm -rf *.exe..so *.exe.dylib *.exe.dylib.dSYM
+       rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
 }
 
 # The test compares the generated native code size between a compilation with and without seq points.
@@ -89,7 +89,7 @@ while read line; do
        fi
 done < $TMP_FILE
 
-TESTRESULT_FILE=TestResult-op_il_seq_point.xml
+TESTRESULT_FILE=TestResult-op_il_seq_point.tmp
 
 echo -n "              <test-case name=\"MonoTests.op_il_seq_point.${TEST_FILE}${USE_AOT}\" executed=\"True\" time=\"0\" asserts=\"0\" success=\"" >> $TESTRESULT_FILE
 
index 583945708ca2dad329e281145f30747ded3fab0b..1dbbdf8c017bb310a10f8b14c732be597f1646ba 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-TESTRESULT_FILE=TestResult-op_il_seq_point.xml
+TESTRESULT_FILE=TestResult-op_il_seq_point.tmp
 TOTAL=$(grep -c "<test-case" $TESTRESULT_FILE)
 FAILURES=$(grep -c "<failure>" $TESTRESULT_FILE)
 if [ "$FAILURES" -eq "0" ]
@@ -36,6 +36,5 @@ echo "        <results>" >> $TESTRESULT_FILE.header
 echo "          <test-suite name=\"op_il_seq_point\" success=\"${PASS}\" time=\"0\" asserts=\"0\">" >> $TESTRESULT_FILE.header
 echo "            <results>" >> $TESTRESULT_FILE.header
 
-cat $TESTRESULT_FILE.header $TESTRESULT_FILE > $TESTRESULT_FILE.new
-mv $TESTRESULT_FILE.new $TESTRESULT_FILE
-rm -f $TESTRESULT_FILE.header
+cat $TESTRESULT_FILE.header $TESTRESULT_FILE > $(basename $TESTRESULT_FILE .tmp).xml
+rm -f $TESTRESULT_FILE.header $TESTRESULT_FILE
index 8e054b99dadf150db4a8e4631565b94862e145f9..66b8bfa4c4e36f9d6d92a6e73fcba93414ebc666 100644 (file)
@@ -406,6 +406,8 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
                        amd64_mov_reg_membase (code, i, AMD64_RSP, r11_save_offset + orig_rsp_to_rbp_offset, sizeof(mgreg_t));
                        amd64_mov_membase_reg (code, AMD64_RBP, saved_regs_offset + (i * sizeof(mgreg_t)), i, sizeof(mgreg_t));
                }
+               /* cfa = rbp + cfa_offset */
+               mono_add_unwind_op_offset (unwind_ops, code, buf, i, - cfa_offset + saved_regs_offset + (i * sizeof (mgreg_t)));
        }
        for (i = 0; i < 8; ++i)
                amd64_movsd_membase_reg (code, AMD64_RBP, saved_fpregs_offset + (i * sizeof(mgreg_t)), i);
@@ -966,6 +968,7 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
        amd64_ret (code);
 
        mono_arch_flush_icache (code, code - buf);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
        g_assert (code - buf <= tramp_size);
 
        const char *tramp_name = single_step ? "sdb_single_step_trampoline" : "sdb_breakpoint_trampoline";
@@ -978,4 +981,27 @@ mono_arch_create_sdb_trampoline (gboolean single_step, MonoTrampInfo **info, gbo
 
 #include "../../../mono-extensions/mono/mini/tramp-amd64-gsharedvt.c"
 
+#else
+
+gpointer
+mono_amd64_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_arch_get_gsharedvt_arg_trampoline (MonoDomain *domain, gpointer arg, gpointer addr)
+{
+       g_assert_not_reached ();
+       return NULL;
+}
+
+gpointer
+mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+       *info = NULL;
+       return NULL;
+}
+
 #endif /* !ENABLE_GSHAREDVT */
index 22030a29885168b536b6eb372ba3cb184374a03c..311a30c0f935b7f6e10efc6654dd32940bd78013 100644 (file)
@@ -183,11 +183,10 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
 #ifdef USE_JUMP_TABLES
        gpointer *load_get_lmf_addr = NULL, *load_trampoline = NULL;
 #else
-        guint8 *load_get_lmf_addr  = NULL, *load_trampoline  = NULL;
+       guint8 *load_get_lmf_addr  = NULL, *load_trampoline  = NULL;
        gpointer *constants;
 #endif
-
-       int cfa_offset, regsave_size, lr_offset;
+       int i, cfa_offset, regsave_size, lr_offset;
        GSList *unwind_ops = NULL;
        MonoJumpInfo *ji = NULL;
        int buf_len;
@@ -223,6 +222,9 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
        mono_add_unwind_op_def_cfa (unwind_ops, code, buf, ARMREG_SP, cfa_offset);
        // PC saved at sp+LR_OFFSET
        mono_add_unwind_op_offset (unwind_ops, code, buf, ARMREG_LR, -4);
+       /* Callee saved regs */
+       for (i = 0; i < 8; ++i)
+               mono_add_unwind_op_offset (unwind_ops, code, buf, ARMREG_R4 + i, -regsave_size + ((4 + i) * 4));
 
        if (aot) {
                /* 
index ca9d645e6aa78922de22b7aa2fa896e3eb7fbfa3..349eff5401457757c9757591a398a275d7990aab 100644 (file)
@@ -426,8 +426,6 @@ sgen_alloc_obj (GCVTable vtable, size_t size)
        if (!SGEN_CAN_ALIGN_UP (size))
                return NULL;
 
-#ifndef DISABLE_CRITICAL_REGION
-
        if (G_UNLIKELY (has_per_allocation_action)) {
                static int alloc_count;
                int current_alloc = InterlockedIncrement (&alloc_count);
@@ -452,12 +450,10 @@ sgen_alloc_obj (GCVTable vtable, size_t size)
                return res;
        }
        EXIT_CRITICAL_REGION;
-#endif
+
        LOCK_GC;
        res = sgen_alloc_obj_nolock (vtable, size);
        UNLOCK_GC;
-       if (G_UNLIKELY (!res))
-               sgen_client_out_of_memory (size);
        return res;
 }
 
index b6e9479f1479e6a7f65a4acbd2433b470ed9dee1..f88b933a68e49f9d3e9fc3f81cda93d1f9e2d51a 100644 (file)
@@ -119,19 +119,13 @@ sgen_card_table_wbarrier_value_copy (gpointer dest, gpointer src, int count, siz
 {
        size_t size = count * element_size;
 
-#ifdef DISABLE_CRITICAL_REGION
-       LOCK_GC;
-#else
        TLAB_ACCESS_INIT;
        ENTER_CRITICAL_REGION;
-#endif
+
        mono_gc_memmove_atomic (dest, src, size);
        sgen_card_table_mark_range ((mword)dest, size);
-#ifdef DISABLE_CRITICAL_REGION
-       UNLOCK_GC;
-#else
+
        EXIT_CRITICAL_REGION;
-#endif
 }
 
 static void
@@ -139,20 +133,14 @@ sgen_card_table_wbarrier_object_copy (GCObject* obj, GCObject *src)
 {
        size_t size = sgen_client_par_object_get_size (SGEN_LOAD_VTABLE_UNCHECKED (obj), obj);
 
-#ifdef DISABLE_CRITICAL_REGION
-       LOCK_GC;
-#else
        TLAB_ACCESS_INIT;
        ENTER_CRITICAL_REGION;
-#endif
+
        mono_gc_memmove_aligned ((char*)obj + SGEN_CLIENT_OBJECT_HEADER_SIZE, (char*)src + SGEN_CLIENT_OBJECT_HEADER_SIZE,
                        size - SGEN_CLIENT_OBJECT_HEADER_SIZE);
        sgen_card_table_mark_range ((mword)obj, size);
-#ifdef DISABLE_CRITICAL_REGION
-       UNLOCK_GC;
-#else
+
        EXIT_CRITICAL_REGION;
-#endif 
 }
 
 static void
index 5c803b50ae59a397cd1314702b19f3895091ea79..edf9dde8439e1f1cd4bef151e6dde539d853caf3 100644 (file)
@@ -140,14 +140,6 @@ void sgen_client_degraded_allocation (size_t size);
  */
 void sgen_client_total_allocated_heap_changed (size_t allocated_heap_size);
 
-/*
- * Called when an object allocation fails.  The suggested action is to abort the program.
- *
- * FIXME: Don't we want to return a BOOL here that indicates whether to retry the
- * allocation?
- */
-void sgen_client_out_of_memory (size_t size);
-
 /*
  * If the client has registered any internal memory types, this must return a string
  * describing the given type.  Only used for debugging.
index 177ba02c8745981eb62ba9ea08f94399681d09d6..1d5b36637eede053a25c3593da22d285e8a0c866 100644 (file)
@@ -123,10 +123,7 @@ mono_gc_make_descr_for_object (gsize *bitmap, int numbits, size_t obj_size)
 {
        int first_set = -1, num_set = 0, last_set = -1, i;
        SgenDescriptor desc = 0;
-       size_t stored_size = obj_size;
-
-       stored_size += SGEN_ALLOC_ALIGN - 1;
-       stored_size &= ~(SGEN_ALLOC_ALIGN - 1);
+       size_t stored_size = SGEN_ALIGN_UP (obj_size);
 
        for (i = 0; i < numbits; ++i) {
                if (bitmap [i / GC_BITS_PER_WORD] & ((gsize)1 << (i % GC_BITS_PER_WORD))) {
index b73c1d88ff1d2d1330fccfa95dd7c106ee86724c..0af554a01ff502af0ae73946f84407bbb3094803 100644 (file)
@@ -3193,7 +3193,7 @@ sgen_stop_world (int generation)
 
        SGEN_ASSERT (0, !world_is_stopped, "Why are we stopping a stopped world?");
 
-       binary_protocol_world_stopping (generation, sgen_timestamp (), (gpointer)mono_native_thread_id_get ());
+       binary_protocol_world_stopping (generation, sgen_timestamp (), (gpointer) (gsize) mono_native_thread_id_get ());
 
        sgen_client_stop_world (generation);
 
index 9e022e12ba902d4bac866957dc71ccbfe3c4c1e3..afd5ba5dce858c2721c9a7e53d6113d2205b9c83 100644 (file)
@@ -146,12 +146,16 @@ extern int current_collection_generation;
 
 extern unsigned int sgen_global_stop_count;
 
+#define SGEN_ALIGN_UP_TO(val,align)    (((val) + (align - 1)) & ~(align - 1))
+#define SGEN_ALIGN_DOWN_TO(val,align)  ((val) & ~(align - 1))
+
 #define SGEN_ALLOC_ALIGN               8
 #define SGEN_ALLOC_ALIGN_BITS  3
 
 /* s must be non-negative */
 #define SGEN_CAN_ALIGN_UP(s)           ((s) <= SIZE_MAX - (SGEN_ALLOC_ALIGN - 1))
-#define SGEN_ALIGN_UP(s)               (((s)+(SGEN_ALLOC_ALIGN-1)) & ~(SGEN_ALLOC_ALIGN-1))
+#define SGEN_ALIGN_UP(s)               SGEN_ALIGN_UP_TO(s, SGEN_ALLOC_ALIGN)
+#define SGEN_ALIGN_DOWN(s)             SGEN_ALIGN_DOWN_TO(s, SGEN_ALLOC_ALIGN)
 
 #if SIZEOF_VOID_P == 4
 #define ONE_P 1
index 2421150fcfb93ba9bf7087d8e5fe9c587ecf16b5..c0ea17bb329982efe49392adda5ff15df6bdfe1d 100644 (file)
@@ -203,15 +203,34 @@ get_from_size_list (LOSFreeChunks **list, size_t size)
        return free_chunks;
 }
 
+static LOSObject*
+randomize_los_object_start (gpointer addr, size_t obj_size, size_t alloced_size, size_t addr_alignment)
+{
+       size_t offset = 0;
+       if (alloced_size != obj_size) {
+               /*
+                * We want to get a random offset between 0 and (alloced_size - obj_size)
+                * We do a prime multiplication to avoid usage of functions which might not
+                * be thread/signal safe (like rand ()). We subtract 1 to avoid common
+                * power by 2 factors.
+                */
+               offset = SGEN_ALIGN_DOWN ((((size_t)addr - 1) * 2654435761u) % (alloced_size - obj_size));
+       }
+       SGEN_ASSERT (0, (alloced_size - obj_size) < addr_alignment, "Why are we wasting one entire chunk for a los object ?");
+       /* Randomize the location within the reserved chunks to improve cache performance */
+       return (LOSObject*)((guint8*)addr + offset);
+
+}
+
 static LOSObject*
 get_los_section_memory (size_t size)
 {
        LOSSection *section;
        LOSFreeChunks *free_chunks;
        size_t num_chunks;
+       size_t obj_size = size;
 
-       size += LOS_CHUNK_SIZE - 1;
-       size &= ~(LOS_CHUNK_SIZE - 1);
+       size = SGEN_ALIGN_UP_TO (size, LOS_CHUNK_SIZE);
 
        num_chunks = size >> LOS_CHUNK_BITS;
 
@@ -232,8 +251,9 @@ get_los_section_memory (size_t size)
                        free_chunks = get_from_size_list (&los_fast_free_lists [0], size);
        }
 
-       if (free_chunks)
-               return (LOSObject*)free_chunks;
+       if (free_chunks) {
+               return randomize_los_object_start (free_chunks, obj_size, size, LOS_CHUNK_SIZE);
+       }
 
        if (!sgen_memgov_try_alloc_space (LOS_SECTION_SIZE, SPACE_LOS))
                return NULL;
@@ -269,8 +289,7 @@ free_los_section_memory (LOSObject *obj, size_t size)
        LOSSection *section = LOS_SECTION_FOR_OBJ (obj);
        size_t num_chunks, i, start_index;
 
-       size += LOS_CHUNK_SIZE - 1;
-       size &= ~(LOS_CHUNK_SIZE - 1);
+       size = SGEN_ALIGN_UP_TO (size, LOS_CHUNK_SIZE);
 
        num_chunks = size >> LOS_CHUNK_BITS;
 
@@ -292,11 +311,9 @@ free_los_section_memory (LOSObject *obj, size_t size)
                section->free_chunk_map [i] = 1;
        }
 
-       add_free_chunk ((LOSFreeChunks*)obj, size);
+       add_free_chunk ((LOSFreeChunks*)SGEN_ALIGN_DOWN_TO ((mword)obj, LOS_CHUNK_SIZE), size);
 }
 
-static int pagesize;
-
 void
 sgen_los_free_object (LOSObject *obj)
 {
@@ -314,12 +331,10 @@ sgen_los_free_object (LOSObject *obj)
        free (obj);
 #else
        if (size > LOS_SECTION_OBJECT_LIMIT) {
-               if (!pagesize)
-                       pagesize = mono_pagesize ();
+               int pagesize = mono_pagesize ();
                size += sizeof (LOSObject);
-               size += pagesize - 1;
-               size &= ~(pagesize - 1);
-               sgen_free_os_memory (obj, size, SGEN_ALLOC_HEAP);
+               size = SGEN_ALIGN_UP_TO (size, pagesize);
+               sgen_free_os_memory ((gpointer)SGEN_ALIGN_DOWN_TO ((mword)obj, pagesize), size, SGEN_ALLOC_HEAP);
                sgen_memgov_release_space (size, SPACE_LOS);
        } else {
                free_los_section_memory (obj, size + sizeof (LOSObject));
@@ -372,14 +387,13 @@ sgen_los_alloc_large_inner (GCVTable vtable, size_t size)
        memset (obj, 0, size + sizeof (LOSObject));
 #else
        if (size > LOS_SECTION_OBJECT_LIMIT) {
-               size_t alloc_size = size;
-               if (!pagesize)
-                       pagesize = mono_pagesize ();
-               alloc_size += sizeof (LOSObject);
-               alloc_size += pagesize - 1;
-               alloc_size &= ~(pagesize - 1);
+               size_t obj_size = size + sizeof (LOSObject);
+               int pagesize = mono_pagesize ();
+               size_t alloc_size = SGEN_ALIGN_UP_TO (obj_size, pagesize);
                if (sgen_memgov_try_alloc_space (alloc_size, SPACE_LOS)) {
                        obj = (LOSObject *)sgen_alloc_os_memory (alloc_size, (SgenAllocFlags)(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE), NULL);
+                       if (obj)
+                               obj = randomize_los_object_start (obj, obj_size, alloc_size, pagesize);
                }
        } else {
                obj = get_los_section_memory (size + sizeof (LOSObject));
@@ -704,9 +718,9 @@ sgen_los_mark_mod_union_card (GCObject *mono_obj, void **ptr)
 {
        LOSObject *obj = sgen_los_header_for_object (mono_obj);
        guint8 *mod_union = get_cardtable_mod_union_for_object (obj);
-       size_t offset = sgen_card_table_get_card_offset ((char*)ptr, (char*)sgen_card_table_align_pointer ((char*)obj));
+       /* The LOSObject structure is not represented within the card space */
+       size_t offset = sgen_card_table_get_card_offset ((char*)ptr, (char*)sgen_card_table_align_pointer((char*)mono_obj));
        SGEN_ASSERT (0, mod_union, "FIXME: optionally allocate the mod union if it's not here and CAS it in.");
-       SGEN_ASSERT (0, (char*)obj == (char*)sgen_card_table_align_pointer ((char*)obj), "Why are LOS objects not card aligned?");
        mod_union [offset] = 1;
 }
 
index 56efcf2694d669d25ba25535ffa9867d15237ec1..fc2161e7d3ec9583b1a72c5ae37515da335e4bcf 100644 (file)
@@ -52,12 +52,12 @@ COPY_OR_MARK_FUNCTION_NAME (GCObject **ptr, GCObject *obj, SgenGrayQueue *queue)
 #endif
 
        SGEN_ASSERT (9, obj, "null object from pointer %p", ptr);
-#ifndef COPY_OR_MARK_CONCURRENT
+#if !defined(COPY_OR_MARK_CONCURRENT) && !defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION)
        SGEN_ASSERT (9, current_collection_generation == GENERATION_OLD, "old gen parallel allocator called from a %d collection", current_collection_generation);
 #endif
 
        if (sgen_ptr_in_nursery (obj)) {
-#ifndef COPY_OR_MARK_CONCURRENT
+#if !defined(COPY_OR_MARK_CONCURRENT) && !defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION)
                int word, bit;
                GCObject *forwarded, *old_obj;
                mword vtable_word = *(mword*)obj;
@@ -166,7 +166,7 @@ COPY_OR_MARK_FUNCTION_NAME (GCObject **ptr, GCObject *obj, SgenGrayQueue *queue)
 
                        block = MS_BLOCK_FOR_OBJ (obj);
 
-#ifdef COPY_OR_MARK_CONCURRENT
+#ifdef COPY_OR_MARK_CONCURRENT_WITH_EVACUATION
                        if (G_UNLIKELY (major_block_is_evacuating (block))) {
                                /*
                                 * We don't copy within the concurrent phase. These objects will
@@ -220,15 +220,14 @@ SCAN_OBJECT_FUNCTION_NAME (GCObject *full_object, SgenDescriptor desc, SgenGrayQ
        /* Now scan the object. */
 
 #undef HANDLE_PTR
-#ifdef COPY_OR_MARK_CONCURRENT
+#if defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION)
 #define HANDLE_PTR(ptr,obj)    do {                                    \
                GCObject *__old = *(ptr);                               \
                binary_protocol_scan_process_reference ((full_object), (ptr), __old); \
                if (__old && !sgen_ptr_in_nursery (__old)) {            \
-                       MSBlockInfo *block = MS_BLOCK_FOR_OBJ (__old);  \
                        if (G_UNLIKELY (!sgen_ptr_in_nursery (ptr) &&   \
                                        sgen_safe_object_is_small (__old, sgen_obj_get_descriptor (__old) & DESC_TYPE_MASK) && \
-                                       major_block_is_evacuating (block))) { \
+                                       major_block_is_evacuating (MS_BLOCK_FOR_OBJ (__old)))) { \
                                mark_mod_union_card ((full_object), (void**)(ptr), __old); \
                        } else {                                        \
                                PREFETCH_READ (__old);                  \
@@ -239,6 +238,18 @@ SCAN_OBJECT_FUNCTION_NAME (GCObject *full_object, SgenDescriptor desc, SgenGrayQ
                                mark_mod_union_card ((full_object), (void**)(ptr), __old); \
                        }                                               \
                } while (0)
+#elif defined(COPY_OR_MARK_CONCURRENT)
+#define HANDLE_PTR(ptr,obj)    do {                                    \
+               GCObject *__old = *(ptr);                               \
+               binary_protocol_scan_process_reference ((full_object), (ptr), __old); \
+               if (__old && !sgen_ptr_in_nursery (__old)) {            \
+                       PREFETCH_READ (__old);                  \
+                       COPY_OR_MARK_FUNCTION_NAME ((ptr), __old, queue); \
+               } else {                                                \
+                       if (G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)))) \
+                               mark_mod_union_card ((full_object), (void**)(ptr), __old); \
+                       }                                               \
+               } while (0)
 #else
 #define HANDLE_PTR(ptr,obj)    do {                                    \
                GCObject *__old = *(ptr);                                       \
@@ -260,7 +271,7 @@ SCAN_OBJECT_FUNCTION_NAME (GCObject *full_object, SgenDescriptor desc, SgenGrayQ
 static gboolean
 DRAIN_GRAY_STACK_FUNCTION_NAME (SgenGrayQueue *queue)
 {
-#ifdef COPY_OR_MARK_CONCURRENT
+#if defined(COPY_OR_MARK_CONCURRENT) || defined(COPY_OR_MARK_CONCURRENT_WITH_EVACUATION)
        int i;
        for (i = 0; i < 32; i++) {
 #else
index 62260b42e1a68d64589aff310ad36bcf0fc24f84..0e9691db42f89e168a93f638fff63ddc32ee45e5 100644 (file)
@@ -1190,29 +1190,49 @@ static guint64 stat_drain_loops;
 
 #undef COPY_OR_MARK_WITH_EVACUATION
 #define COPY_OR_MARK_CONCURRENT
-#define COPY_OR_MARK_FUNCTION_NAME     major_copy_or_mark_object_concurrent
-#define SCAN_OBJECT_FUNCTION_NAME      major_scan_object_concurrent
-#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent
+#define COPY_OR_MARK_FUNCTION_NAME     major_copy_or_mark_object_concurrent_no_evacuation
+#define SCAN_OBJECT_FUNCTION_NAME      major_scan_object_concurrent_no_evacuation
+#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent_no_evacuation
 #include "sgen-marksweep-drain-gray-stack.h"
 
-static gboolean
-drain_gray_stack (SgenGrayQueue *queue)
+#undef COPY_OR_MARK_CONCURRENT
+#define COPY_OR_MARK_CONCURRENT_WITH_EVACUATION
+#define COPY_OR_MARK_FUNCTION_NAME     major_copy_or_mark_object_concurrent_with_evacuation
+#define SCAN_OBJECT_FUNCTION_NAME      major_scan_object_concurrent_with_evacuation
+#define DRAIN_GRAY_STACK_FUNCTION_NAME drain_gray_stack_concurrent_with_evacuation
+#include "sgen-marksweep-drain-gray-stack.h"
+
+static inline gboolean
+major_is_evacuating (void)
 {
-       gboolean evacuation = FALSE;
        int i;
        for (i = 0; i < num_block_obj_sizes; ++i) {
                if (evacuate_block_obj_sizes [i]) {
-                       evacuation = TRUE;
-                       break;
+                       return TRUE;
                }
        }
 
-       if (evacuation)
+       return FALSE;
+}
+
+static gboolean
+drain_gray_stack (SgenGrayQueue *queue)
+{
+       if (major_is_evacuating ())
                return drain_gray_stack_with_evacuation (queue);
        else
                return drain_gray_stack_no_evacuation (queue);
 }
 
+static gboolean
+drain_gray_stack_concurrent (SgenGrayQueue *queue)
+{
+       if (major_is_evacuating ())
+               return drain_gray_stack_concurrent_with_evacuation (queue);
+       else
+               return drain_gray_stack_concurrent_no_evacuation (queue);
+}
+
 #include "sgen-marksweep-scan-object-concurrent.h"
 
 static void
@@ -1224,7 +1244,7 @@ major_copy_or_mark_object_canonical (GCObject **ptr, SgenGrayQueue *queue)
 static void
 major_copy_or_mark_object_concurrent_canonical (GCObject **ptr, SgenGrayQueue *queue)
 {
-       major_copy_or_mark_object_concurrent (ptr, *ptr, queue);
+       major_copy_or_mark_object_concurrent_with_evacuation (ptr, *ptr, queue);
 }
 
 static void
@@ -2471,7 +2491,7 @@ sgen_marksweep_init_internal (SgenMajorCollector *collector, gboolean is_concurr
        collector->major_ops_serial.drain_gray_stack = drain_gray_stack;
        if (is_concurrent) {
                collector->major_ops_concurrent_start.copy_or_mark_object = major_copy_or_mark_object_concurrent_canonical;
-               collector->major_ops_concurrent_start.scan_object = major_scan_object_concurrent;
+               collector->major_ops_concurrent_start.scan_object = major_scan_object_concurrent_with_evacuation;
                collector->major_ops_concurrent_start.drain_gray_stack = drain_gray_stack_concurrent;
 
                collector->major_ops_concurrent_finish.copy_or_mark_object = major_copy_or_mark_object_concurrent_finish_canonical;
index 2047065c58366da809b70b4c7866853cee0f0a8d..d95f31f4a655bb38fef728cc96d1708f11a72d47 100644 (file)
@@ -1,6 +1,6 @@
 SUBDIRS = assemblyresolve gc-descriptors
 
-check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-cattr-type-load test-reflection-load-with-context test_platform test-process-exit test-messages test-env-options test-unhandled-exception-2 test-appdomain-unload rm-empty-logs
+check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-cattr-type-load test-reflection-load-with-context test_platform test-process-exit test-console-output test-messages test-env-options test-unhandled-exception-2 test-appdomain-unload rm-empty-logs
 check-full: test-sgen check-local
 check-parallel: compile-tests check-full
 
@@ -869,11 +869,11 @@ runtest: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQS
 
 runtest-managed: test-runner.exe $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
        @if [ "x$$CI" = "x1" ]; then disabled_tests="$(DISABLED_TESTS_WRENCH)"; else disabled_tests="$(DISABLED_TESTS)"; fi; \
-       $(RUNTIME) ./test-runner.exe -j a --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
+       $(RUNTIME) --debug ./test-runner.exe -j a --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
 
 runtest-managed-serial: test-runner.exe $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
        @if [ "x$$CI" = "x1" ]; then disabled_tests="$(DISABLED_TESTS_WRENCH)"; else disabled_tests="$(DISABLED_TESTS)"; fi; \
-       $(RUNTIME) ./test-runner.exe -j 1 --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
+       $(RUNTIME) --debug ./test-runner.exe -j 1 --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
 
 testjit:
        @if test x$(M) != x0; then $(MAKE) runtest-managed; else $(MAKE) runtest; fi
@@ -1407,6 +1407,13 @@ test-appdomain-unload: appdomain-loader.exe appdomain-tester.exe
        MONO_DEBUG_ASSEMBLY_UNLOAD=1 $(RUNTIME) -O=gshared appdomain-loader.exe > appdomain-loader.exe.3.stdout || exit 1;
        MONO_DEBUG_ASSEMBLY_UNLOAD=1 $(RUNTIME) appdomain-loader.exe > appdomain-loader.exe.4.stdout || exit 1;
 
+EXTRA_DIST += console-output.cs console-output.exe.stderr.expected console-output.exe.stdout.expected
+test-console-output: console-output.exe
+       @$(RUNTIME) console-output.exe 1>console-output.exe.stdout
+       @$(RUNTIME) console-output.exe 2>console-output.exe.stderr
+       @diff -w console-output.exe.stdout $(srcdir)/console-output.exe.stdout.expected \
+               && diff -w console-output.exe.stderr $(srcdir)/console-output.exe.stderr.expected
+
 coreclr-gcstress:
        $(MAKE) -C $(mono_build_root)/acceptance-tests coreclr-gcstress
 
diff --git a/mono/tests/console-output.cs b/mono/tests/console-output.cs
new file mode 100644 (file)
index 0000000..efe8638
--- /dev/null
@@ -0,0 +1,11 @@
+
+using System;
+
+class Driver
+{
+       public static void Main ()
+       {
+               Console.Out.WriteLine ("Out");
+               Console.Error.WriteLine ("Error");
+       }
+}
diff --git a/mono/tests/console-output.exe.stderr.expected b/mono/tests/console-output.exe.stderr.expected
new file mode 100644 (file)
index 0000000..59fd4d6
--- /dev/null
@@ -0,0 +1 @@
+Error
diff --git a/mono/tests/console-output.exe.stdout.expected b/mono/tests/console-output.exe.stdout.expected
new file mode 100644 (file)
index 0000000..748eb3a
--- /dev/null
@@ -0,0 +1 @@
+Out
index de80d9f693f06a8e96a032c2da3cbb9423792e19..c0d094fc56f1f2a262d9a42d77ccf0e67c01fff2 100644 (file)
@@ -1109,6 +1109,14 @@ mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
        return (d ()) (55);
 }
 
+typedef int (STDCALL *VirtualDelegate) (int);
+
+LIBTEST_API int STDCALL
+mono_test_marshal_virtual_delegate (VirtualDelegate del)
+{
+       return del (42);
+}
+
 LIBTEST_API int STDCALL  
 mono_test_marshal_stringbuilder (char *s, int n)
 {
index 4b9a4b7f49a300186eb95ef72be806e21d897bfe..376e2000187f834b4b5ce0516fa1249cb5ced8cb 100644 (file)
@@ -191,6 +191,9 @@ public class Tests {
        [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_ref_delegate")]
        public static extern int mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del);
 
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_virtual_delegate")]
+       public static extern int mono_test_marshal_virtual_delegate (VirtualDelegate del);
+
        public delegate int TestDelegate (int a, ref SimpleStruct ss, int b);
 
        public delegate SimpleStruct SimpleDelegate2 (SimpleStruct ss);
@@ -215,6 +218,8 @@ public class Tests {
 
        public delegate int DelegateByrefDelegate (ref return_int_delegate del);
 
+       public delegate int VirtualDelegate (int i);
+
        public static int Main () {
                return TestDriver.RunTests (typeof (Tests));
        }
@@ -1134,4 +1139,26 @@ public class Tests {
                        return 0;
                }
     }
+
+       class Base {
+               public VirtualDelegate get_del () {
+                       return delegate_test;
+               }
+
+               public virtual int delegate_test (int i) {
+                       return i;
+               }
+       }
+
+       class Derived : Base {
+               public override int delegate_test (int i) {
+                       return i + 1;
+               }
+       }
+
+       public static int test_43_virtual () {
+               Base b = new Derived ();
+
+               return mono_test_marshal_virtual_delegate (b.get_del ());
+       }
 }
index db620f1690756d6c42f677d392d09b20be38060b..fd916a659061434fe2f093a56469eeb23170509a 100644 (file)
 #include <config.h>
 #include <glib.h>
 #include <mono/metadata/handle.h>
-#include <mono/metadata/handle-private.h>
-
-static void
-test1_arena_size ()
-{
-       for (gsize i = 1; i < 10; ++i) {
-               gsize sz = mono_handle_arena_size(i);
-               g_assert(sz >= i*sizeof(MonoHandle));
-       }
-}
 
 static void
 test2_arena_push_pop ()
 {
        MonoHandleArena *top = NULL;
 
-       const int n_handles = 3;
-       MonoHandleArena *new_arena1 = g_malloc0 (mono_handle_arena_size (n_handles));
-       mono_handle_arena_stack_push (&top, new_arena1, n_handles);
+       MonoHandleArena *new_arena1 = g_malloc0 (mono_handle_arena_size ());
+       mono_handle_arena_stack_push (&top, new_arena1);
 
-       MonoHandleArena *new_arena2 = g_malloc0 (mono_handle_arena_size (n_handles));
+       MonoHandleArena *new_arena2 = g_malloc0 (mono_handle_arena_size ());
 
-       mono_handle_arena_stack_push (&top, new_arena2, n_handles);
+       mono_handle_arena_stack_push (&top, new_arena2);
 
        g_assert (top == new_arena2);
 
-       mono_handle_arena_stack_pop (&top, new_arena2, n_handles);
+       mono_handle_arena_stack_pop (&top, new_arena2);
 
        g_free (new_arena2);
 
        g_assert (top == new_arena1);
 
-       mono_handle_arena_stack_pop (&top, new_arena1, n_handles);
+       mono_handle_arena_stack_pop (&top, new_arena1);
 
        g_assert (top == NULL);
        
@@ -54,8 +43,6 @@ test2_arena_push_pop ()
 int
 main (int argc, const char* argv[])
 {
-       test1_arena_size ();
-       
        test2_arena_push_pop ();
 
        return 0;
index 65bff4d26fba514ac65af3529cc1042adb631e43..624d1b88b8eb595500bcdad638d007d56f026ffe 100644 (file)
@@ -7,6 +7,7 @@
  * (C) 2015 Xamarin
  */
 #include <config.h>
+
 #ifdef CHECKED_BUILD
 
 #include <mono/utils/checked-build.h>
 #include <mono/metadata/reflection-internals.h>
 #include <glib.h>
 
+#ifdef HAVE_BACKTRACE_SYMBOLS
+#include <execinfo.h>
+#endif
+
+typedef struct {
+       GPtrArray *transitions;
+       guint32 in_gc_critical_region;
+} CheckState;
+
+static MonoNativeTlsKey thread_status;
+
+void
+checked_build_init (void)
+{
+       mono_native_tls_alloc (&thread_status, NULL);
+}
+
+static CheckState*
+get_state (void)
+{
+       CheckState *state = mono_native_tls_get_value (thread_status);
+       if (!state) {
+               state = g_new0 (CheckState, 1);
+               state->transitions = g_ptr_array_new ();
+               mono_native_tls_set_value (thread_status, state);
+       }
+
+       return state;
+}
+
+#if !defined(DISABLE_CHECKED_BUILD_THREAD)
+
 #define MAX_NATIVE_BT 6
 #define MAX_NATIVE_BT_PROBE (MAX_NATIVE_BT + 5)
 #define MAX_TRANSITIONS 3
 
-
 #ifdef HAVE_BACKTRACE_SYMBOLS
-#include <execinfo.h>
 
 //XXX We should collect just the IPs and lazily symbolificate them.
 static int
@@ -78,39 +109,12 @@ translate_backtrace (gpointer native_trace[], int size)
 
 #endif
 
-
-typedef struct {
-       GPtrArray *transitions;
-       gboolean in_gc_critical_region;
-} CheckState;
-
 typedef struct {
        const char *name;
        int from_state, next_state, suspend_count, suspend_count_delta, size;
        gpointer backtrace [MAX_NATIVE_BT_PROBE];
 } ThreadTransition;
 
-static MonoNativeTlsKey thread_status;
-
-void
-checked_build_init (void)
-{
-       mono_native_tls_alloc (&thread_status, NULL);
-}
-
-static CheckState*
-get_state (void)
-{
-       CheckState *state = mono_native_tls_get_value (thread_status);
-       if (!state) {
-               state = g_new0 (CheckState, 1);
-               state->transitions = g_ptr_array_new ();
-               mono_native_tls_set_value (thread_status, state);
-       }
-
-       return state;
-}
-
 static void
 free_transition (ThreadTransition *t)
 {
@@ -139,6 +143,10 @@ checked_build_thread_transition (const char *transition, void *info, int from_st
        g_ptr_array_add (state->transitions, t);
 }
 
+#endif /* !defined(DISABLE_CHECKED_BUILD_THREAD) */
+
+#if !defined(DISABLE_CHECKED_BUILD_GC)
+
 static void
 assertion_fail (const char *msg, ...)
 {
@@ -235,7 +243,7 @@ void *
 critical_gc_region_begin(void)
 {
        CheckState *state = get_state ();
-       state->in_gc_critical_region = TRUE;
+       state->in_gc_critical_region++;
        return state;
 }
 
@@ -245,20 +253,30 @@ critical_gc_region_end(void* token)
 {
        CheckState *state = get_state();
        g_assert (state == token);
-       state->in_gc_critical_region = FALSE;
+       state->in_gc_critical_region--;
 }
 
 void
 assert_not_in_gc_critical_region(void)
 {
        CheckState *state = get_state();
-       if (state->in_gc_critical_region) {
-               MonoThreadInfo *cur = mono_thread_info_current();
-               state = mono_thread_info_current_state(cur);
-               assertion_fail("Expected GC Unsafe mode, but was in %s state", mono_thread_state_name(state));
+       if (state->in_gc_critical_region > 0) {
+               assertion_fail("Expected GC Unsafe mode, but was in %s state", mono_thread_state_name (mono_thread_info_current_state (mono_thread_info_current ())));
        }
 }
 
+void
+assert_in_gc_critical_region (void)
+{
+       CheckState *state = get_state();
+       if (state->in_gc_critical_region == 0)
+               assertion_fail("Expected GC critical region");
+}
+
+#endif /* !defined(DISABLE_CHECKED_BUILD_GC) */
+
+#if !defined(DISABLE_CHECKED_BUILD_METADATA)
+
 // check_metadata_store et al: The goal of these functions is to verify that if there is a pointer from one mempool into
 // another, that the pointed-to memory is protected by the reference count mechanism for MonoImages.
 //
@@ -592,4 +610,6 @@ check_metadata_store_local (void *from, void *to)
     check_mempool_may_reference_mempool (from, to, TRUE);
 }
 
+#endif /* !defined(DISABLE_CHECKED_BUILD_METADATA) */
+
 #endif /* CHECKED_BUILD */
index 83efd67c054899a2865326e8d65fb9a0b35e34d4..28932d8c630204ff83e6bae5d3cd46cb49f2c062 100644 (file)
 // The current reason why this is needed is for pointers to constant strings, which the checker cannot verify yet.
 #define CHECKED_METADATA_WRITE_PTR_EXEMPT(ptr, val) do { (ptr) = (val); } while (0)
 
-#ifdef CHECKED_BUILD
+#if defined(CHECKED_BUILD)
 
 #define g_assert_checked g_assert
 
+/*
+This can be called by embedders
+*/
+#define MONO_REQ_API_ENTRYPOINT
+
+/*
+The JIT will generate code that will land on this function
+*/
+#define MONO_REQ_RUNTIME_ENTRYPOINT
+
+#define CHECKED_MONO_INIT() do { checked_build_init (); } while (0)
+
+void checked_build_init (void);
+
+#else
+
+#define g_assert_checked(...)
+
+#define MONO_REQ_API_ENTRYPOINT
+#define MONO_REQ_RUNTIME_ENTRYPOINT
+
+#define CHECKED_MONO_INIT()
+
+#endif /* CHECKED_BUILD */
+
+#if defined(CHECKED_BUILD) && !defined(DISABLE_CHECKED_BUILD_GC)
+
 /*
 GC runtime modes rules:
 
@@ -83,12 +110,12 @@ Functions that can be called from both coop or preept modes.
  * The GC critical region must only occur in unsafe mode.
  */
 #define MONO_PREPARE_GC_CRITICAL_REGION                                        \
-       MON_REQ_GC_UNSAFE_MODE                                          \
+       MONO_REQ_GC_UNSAFE_MODE                                         \
        do {                                                            \
                void* __critical_gc_region_cookie = critical_gc_region_begin()
 
 #define MONO_FINISH_GC_CRITICAL_REGION                 \
-       critical_gc_region_end(__critical_gc_region_cookie);    \
+               critical_gc_region_end(__critical_gc_region_cookie);    \
        } while(0)
 
 /* Verify that the thread is not currently in a GC critical region. */
@@ -96,6 +123,36 @@ Functions that can be called from both coop or preept modes.
                assert_not_in_gc_critical_region();     \
        } while(0)
 
+/* Verify that the thread is currently in a GC critical region. */
+#define MONO_REQ_GC_CRITICAL do {                      \
+               assert_in_gc_critical_region(); \
+       } while(0)
+
+void assert_gc_safe_mode (void);
+void assert_gc_unsafe_mode (void);
+void assert_gc_neutral_mode (void);
+
+void* critical_gc_region_begin(void);
+void critical_gc_region_end(void* token);
+void assert_not_in_gc_critical_region(void);
+void assert_in_gc_critical_region (void);
+
+#else
+
+#define MONO_REQ_GC_SAFE_MODE
+#define MONO_REQ_GC_UNSAFE_MODE
+#define MONO_REQ_GC_NEUTRAL_MODE
+
+#define MONO_PREPARE_GC_CRITICAL_REGION
+#define MONO_FINISH_GC_CRITICAL_REGION
+
+#define MONO_REQ_GC_NOT_CRITICAL
+#define MONO_REQ_GC_CRITICAL
+
+#endif /* defined(CHECKED_BUILD) && !defined(DISABLE_CHECKED_BUILD_GC) */
+
+#if defined(CHECKED_BUILD) && !defined(DISABLE_CHECKED_BUILD_METADATA)
+
 // Use when writing a pointer from one image or imageset to another.
 #define CHECKED_METADATA_WRITE_PTR(ptr, val) do {    \
     check_metadata_store (&(ptr), (val));    \
@@ -114,59 +171,29 @@ Functions that can be called from both coop or preept modes.
     mono_atomic_store_release (&(ptr), (val));    \
 } while (0);
 
-/*
-This can be called by embedders
-*/
-#define MONO_REQ_API_ENTRYPOINT
+void check_metadata_store(void *from, void *to);
+void check_metadata_store_local(void *from, void *to);
 
-/*
-The JIT will generate code that will land on this function
-*/
-#define MONO_REQ_RUNTIME_ENTRYPOINT
+#else
 
-#define CHECKED_MONO_INIT() do { checked_build_init (); } while (0)
+#define CHECKED_METADATA_WRITE_PTR(ptr, val) do { (ptr) = (val); } while (0)
+#define CHECKED_METADATA_WRITE_PTR_LOCAL(ptr, val) do { (ptr) = (val); } while (0)
+#define CHECKED_METADATA_WRITE_PTR_ATOMIC(ptr, val) do { mono_atomic_store_release (&(ptr), (val)); } while (0)
+
+#endif /* defined(CHECKED_BUILD) && !defined(DISABLE_CHECKED_BUILD_METADATA) */
+
+#if defined(CHECKED_BUILD) && !defined(DISABLE_CHECKED_BUILD_THREAD)
 
 #define CHECKED_BUILD_THREAD_TRANSITION(transition, info, from_state, suspend_count, next_state, suspend_count_delta) do {     \
        checked_build_thread_transition (transition, info, from_state, suspend_count, next_state, suspend_count_delta); \
 } while (0)
 
-void assert_gc_safe_mode (void);
-void assert_gc_unsafe_mode (void);
-void assert_gc_neutral_mode (void);
-
-void* critical_gc_region_begin(void);
-void critical_gc_region_end(void* token);
-void assert_not_in_gc_critical_region(void);
-
-void checked_build_init (void);
 void checked_build_thread_transition(const char *transition, void *info, int from_state, int suspend_count, int next_state, int suspend_count_delta);
 
-void check_metadata_store(void *from, void *to);
-void check_metadata_store_local(void *from, void *to);
-
 #else
 
-#define g_assert_checked(...)
-
-#define MONO_REQ_GC_SAFE_MODE
-#define MONO_REQ_GC_UNSAFE_MODE
-#define MONO_REQ_GC_NEUTRAL_MODE
-#define MONO_REQ_API_ENTRYPOINT
-#define MONO_REQ_RUNTIME_ENTRYPOINT
-
-#define MONO_PREPARE_GC_CRITICAL_REGION
-#define MONO_FINISH_GC_CRITICAL_REGION
-
-#define MONO_REQ_GC_NOT_CRITICAL
-
-
-#define CHECKED_MONO_INIT()
 #define CHECKED_BUILD_THREAD_TRANSITION(transition, info, from_state, suspend_count, next_state, suspend_count_delta)
 
-#define CHECKED_METADATA_WRITE_PTR(ptr, val) do { (ptr) = (val); } while (0)
-#define CHECKED_METADATA_WRITE_PTR_LOCAL(ptr, val) do { (ptr) = (val); } while (0)
-#define CHECKED_METADATA_WRITE_PTR_ATOMIC(ptr, val) do { mono_atomic_store_release (&(ptr), (val)); } while (0)
-
-#endif /* CHECKED_BUILD */
+#endif /* defined(CHECKED_BUILD) && !defined(DISABLE_CHECKED_BUILD_THREAD) */
 
-#endif
+#endif /* __CHECKED_BUILD_H__ */
index 606387c073ef9e93a815366808aee01bbe3d0cd6..89dfe54512f6c085d9872c4d26d0c0fe007ceb55 100644 (file)
@@ -177,7 +177,7 @@ mono_hazard_pointer_get (void)
 
        if (small_id < 0) {
                static MonoThreadHazardPointers emerg_hazard_table;
-               g_warning ("Thread %p may have been prematurely finalized", (gpointer)mono_native_thread_id_get ());
+               g_warning ("Thread %p may have been prematurely finalized", (gpointer) (gsize) mono_native_thread_id_get ());
                return &emerg_hazard_table;
        }
 
index cd6c4b2365ed268ae18949ecd92fd72974140d5d..81aff561ccab6650b420e92d2613a423e519b243 100644 (file)
@@ -47,7 +47,7 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
        mctx->eip = 0xDEADBEEF;
 #elif MONO_CROSS_COMPILE
        g_assert_not_reached ();
-#elif defined(MONO_SIGNAL_USE_SIGACTION)
+#elif defined(MONO_SIGNAL_USE_UCONTEXT_T)
        ucontext_t *ctx = (ucontext_t*)sigctx;
        
        mctx->eax = UCONTEXT_REG_EAX (ctx);
@@ -93,7 +93,7 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
        printf("WARNING: mono_arch_monoctx_to_sigctx() called!\n");
 #elif MONO_CROSS_COMPILE
        g_assert_not_reached ();
-#elif defined(MONO_SIGNAL_USE_SIGACTION)
+#elif defined(MONO_SIGNAL_USE_UCONTEXT_T)
        ucontext_t *ctx = (ucontext_t*)sigctx;
 
        UCONTEXT_REG_EAX (ctx) = mctx->eax;
@@ -149,7 +149,7 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
 
 #ifdef MONO_CROSS_COMPILE
        g_assert_not_reached ();
-#elif defined(UCONTEXT_REG_RAX)
+#elif defined(MONO_SIGNAL_USE_UCONTEXT_T)
        ucontext_t *ctx = (ucontext_t*)sigctx;
 
        mctx->gregs [AMD64_RAX] = UCONTEXT_REG_RAX (ctx);
@@ -203,7 +203,7 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 
 #ifdef MONO_CROSS_COMPILE
        g_assert_not_reached ();
-#elif defined(UCONTEXT_REG_RAX)
+#elif defined(MONO_SIGNAL_USE_UCONTEXT_T)
        ucontext_t *ctx = (ucontext_t*)sigctx;
 
        UCONTEXT_REG_RAX (ctx) = mctx->gregs [AMD64_RAX];
index 84bfc028783e1de259a255e87512244c1d3cd694..2661e657636dde188bb897b51a5284f77f254c3f 100644 (file)
 #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
        defined(__FreeBSD__) || defined(__OpenBSD__)
 #ifdef HAVE_SIGACTION
-#define MONO_SIGNAL_USE_SIGACTION 1
+#define MONO_SIGNAL_USE_UCONTEXT_T 1
 #endif
 #endif
 
 #if defined(__native_client__)
-#undef MONO_SIGNAL_USE_SIGACTION
+#undef MONO_SIGNAL_USE_UCONTEXT_T
 #endif
 
 #ifdef HOST_WIN32
@@ -152,7 +152,7 @@ typedef struct {
 #if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__)
 
 #ifdef HAVE_SIGACTION
-#define MONO_SIGNAL_USE_SIGACTION 1
+#define MONO_SIGNAL_USE_UCONTEXT_T 1
 #endif
 
 #endif
index b96cd54d2c7a8512454161d5c1da22e05b6278db..774203d343c852455a64f8f9c425684ba2f89bda 100644 (file)
@@ -18,11 +18,18 @@ typedef struct {
        MonoClass *klass;
        const char *full_message;
        const char *full_message_with_fields;
+       const char *first_argument;
 
-       void *padding [4];
-    char message [128];
+       void *padding [3];
 } MonoErrorInternal;
 
+#define error_init(error) do { \
+       (error)->error_code = MONO_ERROR_NONE;  \
+       (error)->flags = 0;     \
+} while (0);
+
+#define is_ok(error) ((error)->error_code == MONO_ERROR_NONE)
+
 void
 mono_error_assert_ok (MonoError *error);
 
index 841a354afaff6f61ea232b97a6a82be54d4af8d8..4ac7d6766ef2ddb4646c5b8d17be039edc4d468f 100644 (file)
 #include <mono/metadata/class-internals.h>
 #include <mono/metadata/debug-helpers.h>
 
-#define mono_internal_error_get_message(E) ((E)->full_message ? (E)->full_message : (E)->message)
-
 #define set_error_message() do { \
        va_list args; \
        va_start (args, msg_format); \
-       if (g_vsnprintf (error->message, sizeof (error->message), msg_format, args) >= sizeof (error->message)) {\
-               va_end (args); \
-               va_start (args, msg_format); \
-               if (!(error->full_message = g_strdup_vprintf (msg_format, args))) \
+       if (!(error->full_message = g_strdup_vprintf (msg_format, args))) \
                        error->flags |= MONO_ERROR_INCOMPLETE; \
-       } \
        va_end (args); \
 } while (0)
 
@@ -34,9 +28,8 @@ mono_error_prepare (MonoErrorInternal *error)
        if (error->error_code != MONO_ERROR_NONE)
                return;
 
-       error->type_name = error->assembly_name = error->member_name = error->full_message = error->exception_name_space = error->exception_name = error->full_message_with_fields = NULL;
+       error->type_name = error->assembly_name = error->member_name = error->full_message = error->exception_name_space = error->exception_name = error->full_message_with_fields = error->first_argument = NULL;
        error->klass = NULL;
-       error->message [0] = 0;
 }
 
 static const char*
@@ -92,6 +85,7 @@ mono_error_cleanup (MonoError *oerror)
        g_free ((char*)error->member_name);
        g_free ((char*)error->exception_name_space);
        g_free ((char*)error->exception_name);
+       g_free ((char*)error->first_argument);
 }
 
 gboolean
@@ -127,12 +121,12 @@ mono_error_get_message (MonoError *oerror)
                return error->full_message_with_fields;
 
        error->full_message_with_fields = g_strdup_printf ("%s assembly:%s type:%s member:%s",
-               mono_internal_error_get_message (error),
+               error->full_message,
                get_assembly_name (error),
                get_type_name (error),
                error->member_name ? error->member_name : "<none>");
 
-       return error->full_message_with_fields ? error->full_message_with_fields : mono_internal_error_get_message (error);
+       return error->full_message_with_fields ? error->full_message_with_fields : error->full_message;
 }
 
 /*
@@ -157,6 +151,7 @@ mono_error_dup_strings (MonoError *oerror, gboolean dup_strings)
                DUP_STR (member_name);
                DUP_STR (exception_name_space);
                DUP_STR (exception_name);
+               DUP_STR (first_argument);
        }
 #undef DUP_STR
 }
@@ -352,7 +347,7 @@ mono_error_set_from_loader_error (MonoError *oerror)
                error->error_code = MONO_ERROR_MISSING_METHOD;
                mono_error_set_type_name (oerror, loader_error->class_name);
                mono_error_set_member_name (oerror, loader_error->member_name);
-               g_snprintf (error->message, sizeof (error->message), "Failed for unknown reasons.");
+               error->full_message = g_strdup ("Failed for unknown reasons.");
                break;
 
        case MONO_EXCEPTION_MISSING_FIELD:
@@ -418,10 +413,10 @@ mono_loader_set_error_from_mono_error (MonoError *oerror)
                mono_loader_set_error_assembly_load (get_assembly_name (error), FALSE);
                break;
        case MONO_ERROR_BAD_IMAGE:
-               mono_loader_set_error_bad_image (g_strdup (mono_internal_error_get_message (error)));
+               mono_loader_set_error_bad_image (g_strdup (error->full_message));
                break;
        default:
-               mono_loader_set_error_bad_image (g_strdup_printf ("Non translatable error: %s", mono_internal_error_get_message (error)));
+               mono_loader_set_error_bad_image (g_strdup_printf ("Non translatable error: %s", error->full_message));
        }
 }
 
@@ -429,13 +424,11 @@ void
 mono_error_set_out_of_memory (MonoError *oerror, const char *msg_format, ...)
 {
        MonoErrorInternal *error = (MonoErrorInternal*)oerror;
-       va_list args;
        mono_error_prepare (error);
 
        error->error_code = MONO_ERROR_OUT_OF_MEMORY;
-       va_start (args, msg_format);
-       g_vsnprintf (error->message, sizeof (error->message), msg_format, args);
-       va_end (args);
+
+       set_error_message ();
 }
 
 void
@@ -445,7 +438,7 @@ mono_error_set_argument (MonoError *oerror, const char *argument, const char *ms
        mono_error_prepare (error);
 
        error->error_code = MONO_ERROR_ARGUMENT;
-       error->type_name = argument; /*use the first available string slot*/
+       error->first_argument = argument;
 
        set_error_message ();
 }
@@ -489,7 +482,7 @@ get_type_name_as_mono_string (MonoErrorInternal *error, MonoDomain *domain, Mono
 static void
 set_message_on_exception (MonoException *exception, MonoErrorInternal *error, MonoError *error_out)
 {
-       MonoString *msg = mono_string_new (mono_domain_get (), mono_internal_error_get_message (error));
+       MonoString *msg = mono_string_new (mono_domain_get (), error->full_message);
        if (msg)
                MONO_OBJECT_SETREF (exception, message, msg);
        else
@@ -528,7 +521,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                        if (exception)
                                set_message_on_exception (exception, error, error_out);
                } else {
-                       exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingMethodException", mono_internal_error_get_message (error));
+                       exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingMethodException", error->full_message);
                }
                break;
 
@@ -548,7 +541,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                        if (exception)
                                set_message_on_exception (exception, error, error_out);
                } else {
-                       exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingFieldException", mono_internal_error_get_message (error));
+                       exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingFieldException", error->full_message);
                }
                break;
 
@@ -570,14 +563,14 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                        if (exception)
                                set_message_on_exception (exception, error, error_out);
                } else {
-                       exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "TypeLoadException", mono_internal_error_get_message (error));
+                       exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "TypeLoadException", error->full_message);
                }
                break;
 
        case MONO_ERROR_FILE_NOT_FOUND:
        case MONO_ERROR_BAD_IMAGE:
                if (error->assembly_name) {
-                       msg = mono_string_new (domain, mono_internal_error_get_message (error));
+                       msg = mono_string_new (domain, error->full_message);
                        if (!msg) {
                                mono_error_set_out_of_memory (error_out, "Could not allocate message");
                                break;
@@ -597,9 +590,9 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                                exception = mono_exception_from_name_two_strings (mono_defaults.corlib, "System", "BadImageFormatException", msg, assembly_name);
                } else {
                        if (error->error_code == MONO_ERROR_FILE_NOT_FOUND)
-                               exception = mono_exception_from_name_msg (mono_get_corlib (), "System.IO", "FileNotFoundException", mono_internal_error_get_message (error));
+                               exception = mono_exception_from_name_msg (mono_get_corlib (), "System.IO", "FileNotFoundException", error->full_message);
                        else
-                               exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "BadImageFormatException", mono_internal_error_get_message (error));
+                               exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "BadImageFormatException", error->full_message);
                }
                break;
 
@@ -608,7 +601,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                break;
 
        case MONO_ERROR_ARGUMENT:
-               exception = mono_get_exception_argument (error->type_name, mono_internal_error_get_message (error));
+               exception = mono_get_exception_argument (error->first_argument, error->full_message);
                break;
 
        case MONO_ERROR_NOT_VERIFIABLE: {
@@ -620,7 +613,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                                break;
                        }
                }
-               message = g_strdup_printf ("Error in %s:%s %s", type_name, error->member_name, mono_internal_error_get_message (error));
+               message = g_strdup_printf ("Error in %s:%s %s", type_name, error->member_name, error->full_message);
                if (!message) {
                        g_free (type_name);
                        mono_error_set_out_of_memory (error_out, "Could not allocate message");
@@ -635,7 +628,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out)
                if (!error->exception_name_space || !error->exception_name)
                        mono_error_set_generic_error (error_out, "System", "ExecutionEngineException", "MonoError with generic error but no exception name was supplied");
                else
-                       exception = mono_exception_from_name_msg (mono_defaults.corlib, error->exception_name_space, error->exception_name, mono_internal_error_get_message (error));
+                       exception = mono_exception_from_name_msg (mono_defaults.corlib, error->exception_name_space, error->exception_name, error->full_message);
                break;
 
        default:
index 1da46d6f24025414c314a3824850f4827537c164..12747711fc4206244e052500c8e48a373cde246b 100644 (file)
@@ -38,7 +38,6 @@ typedef struct _MonoError {
     unsigned short hidden_0; /*DON'T TOUCH */
 
        void *hidden_1 [12]; /*DON'T TOUCH */
-    char hidden_2 [128]; /*DON'T TOUCH */
 } MonoError;
 
 MONO_BEGIN_DECLS
index ee88665ae6c185ceaf09da5d3b9ba6edf887d5d6..89e9a01023ab32bf0a3738271aa6141b5a397f72 100644 (file)
@@ -16,6 +16,7 @@ typedef enum {
        MONO_TRACE_SECURITY             = (1<<6),
        MONO_TRACE_THREADPOOL           = (1<<7),
        MONO_TRACE_IO_THREADPOOL        = (1<<8),
+       MONO_TRACE_IO_LAYER             = (1<<9),
        MONO_TRACE_ALL                  = MONO_TRACE_ASSEMBLY |
                                          MONO_TRACE_TYPE |
                                          MONO_TRACE_DLLIMPORT |
@@ -24,17 +25,21 @@ typedef enum {
                                          MONO_TRACE_AOT |
                                          MONO_TRACE_SECURITY |
                                          MONO_TRACE_THREADPOOL |
-                                         MONO_TRACE_IO_THREADPOOL
+                                         MONO_TRACE_IO_THREADPOOL |
+                                         MONO_TRACE_IO_LAYER
 } MonoTraceMask;
 
+extern GLogLevelFlags mono_internal_current_level;
+extern MonoTraceMask mono_internal_current_mask;
+
 void 
-mono_trace_cleanup (void);
+mono_trace_init (void);
 
 void 
-mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...);
+mono_trace_cleanup (void);
 
 void 
-mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args);
+mono_tracev_inner (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args);
 
 void 
 mono_trace_set_level (GLogLevelFlags level);
@@ -51,6 +56,33 @@ mono_trace_pop (void);
 gboolean
 mono_trace_is_traced (GLogLevelFlags level, MonoTraceMask mask);
 
+G_GNUC_UNUSED static void
+mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args)
+{
+       if(G_UNLIKELY (level <= mono_internal_current_level && mask & mono_internal_current_mask))
+               mono_tracev_inner (level, mask, format, args);
+}
+
+/**
+ * mono_trace:
+ *
+ *     @level: Verbose level of the specified message
+ *     @mask: Type of the specified message
+ *
+ * Traces a new message, depending on the current logging level
+ * and trace mask.
+ */
+G_GNUC_UNUSED static void
+mono_trace (GLogLevelFlags level, MonoTraceMask mask, const char *format, ...) 
+{
+       if(G_UNLIKELY (level <= mono_internal_current_level && mask & mono_internal_current_mask)) {
+               va_list args;
+               va_start (args, format);
+               mono_tracev_inner (level, mask, format, args);
+               va_end (args);
+       }
+}
+
 #ifdef G_HAVE_ISO_VARARGS
 #define mono_trace_error(...)  mono_trace(G_LOG_LEVEL_ERROR, \
                                                                                        __VA_ARGS__)
index 09d72dd2f008325724e2bf60c4d25b499a1eeed5..7d0c9ce12a4f811d33e6d5a3bca405b2f564da03 100644 (file)
@@ -11,11 +11,11 @@ typedef struct {
        MonoTraceMask   mask;
 } MonoLogLevelEntry;
 
-static GLogLevelFlags current_level            = G_LOG_LEVEL_ERROR;
-static MonoTraceMask current_mask              = MONO_TRACE_ALL;
+GLogLevelFlags mono_internal_current_level             = INT_MAX;
+MonoTraceMask  mono_internal_current_mask              = MONO_TRACE_ALL;
 
-static const char      *mono_log_domain        = "Mono";
 static GQueue          *level_stack            = NULL;
+static const char      *mono_log_domain        = "Mono";
 static MonoPrintCallback print_callback, printerr_callback;
 
 /**
@@ -23,10 +23,11 @@ static MonoPrintCallback print_callback, printerr_callback;
  *
  * Initializes the mono tracer.
  */
-static void 
+void 
 mono_trace_init (void)
 {
        if(level_stack == NULL) {
+               mono_internal_current_level = G_LOG_LEVEL_ERROR;
                level_stack = g_queue_new();
 
                mono_trace_set_mask_string(g_getenv("MONO_LOG_MASK"));
@@ -52,29 +53,6 @@ mono_trace_cleanup (void)
        }
 }
 
-/**
- * mono_trace:
- *
- *     @level: Verbose level of the specified message
- *     @mask: Type of the specified message
- *
- * Traces a new message, depending on the current logging level
- * and trace mask.
- */
-void
-mono_trace(GLogLevelFlags level, MonoTraceMask mask, const char *format, ...) 
-{
-       if(level_stack == NULL)
-               mono_trace_init();
-
-       if(level <= current_level && mask & current_mask) {
-               va_list args;
-               va_start (args, format);
-               g_logv (mono_log_domain, level, format, args);
-               va_end (args);
-       }
-}
-
 /**
  * mono_tracev:
  *
@@ -85,13 +63,15 @@ mono_trace(GLogLevelFlags level, MonoTraceMask mask, const char *format, ...)
  * and trace mask.
  */
 void 
-mono_tracev (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args)
+mono_tracev_inner (GLogLevelFlags level, MonoTraceMask mask, const char *format, va_list args)
 {
-       if (level_stack == NULL)
+       if (level_stack == NULL) {
                mono_trace_init ();
+               if(level > mono_internal_current_level || !(mask & mono_internal_current_mask))
+                       return;
+       }
 
-       if(level <= current_level && mask & current_mask)
-               g_logv (mono_log_domain, level, format, args);
+       g_logv (mono_log_domain, level, format, args);
 }
 
 /**
@@ -109,7 +89,7 @@ mono_trace_set_level (GLogLevelFlags level)
        if(level_stack == NULL)
                mono_trace_init();
 
-       current_level = level;
+       mono_internal_current_level = level;
 }
 
 /**
@@ -127,7 +107,7 @@ mono_trace_set_mask (MonoTraceMask mask)
        if(level_stack == NULL)
                mono_trace_init();
 
-       current_mask    = mask;
+       mono_internal_current_mask      = mask;
 }
 
 /**
@@ -146,15 +126,15 @@ mono_trace_push (GLogLevelFlags level, MonoTraceMask mask)
                g_error("%s: cannot use mono_trace_push without calling mono_trace_init first.", __func__);
        else {
                MonoLogLevelEntry *entry = (MonoLogLevelEntry *) g_malloc(sizeof(MonoLogLevelEntry));
-               entry->level    = current_level;
-               entry->mask             = current_mask;
+               entry->level    = mono_internal_current_level;
+               entry->mask             = mono_internal_current_mask;
 
                g_queue_push_head (level_stack, (gpointer)entry);
 
                /* Set the new level and mask
                 */
-               current_level = level;
-               current_mask  = mask;
+               mono_internal_current_level = level;
+               mono_internal_current_mask  = mask;
        }
 }
 
@@ -174,8 +154,8 @@ mono_trace_pop (void)
 
                        /*      Restore previous level and mask
                         */
-                       current_level = entry->level;
-                       current_mask  = entry->mask;
+                       mono_internal_current_level = entry->level;
+                       mono_internal_current_mask  = entry->mask;
 
                        g_free (entry);
                }
@@ -213,10 +193,10 @@ mono_trace_set_mask_string (const char *value)
        const char *tok;
        guint32 flags = 0;
 
-       const char *valid_flags[] = {"asm", "type", "dll", "gc", "cfg", "aot", "security", "threadpool", "io-threadpool", "all", NULL};
+       const char *valid_flags[] = {"asm", "type", "dll", "gc", "cfg", "aot", "security", "threadpool", "io-threadpool", "io-layer", "all", NULL};
        const MonoTraceMask     valid_masks[] = {MONO_TRACE_ASSEMBLY, MONO_TRACE_TYPE, MONO_TRACE_DLLIMPORT,
                                                 MONO_TRACE_GC, MONO_TRACE_CONFIG, MONO_TRACE_AOT, MONO_TRACE_SECURITY,
-                                                MONO_TRACE_THREADPOOL, MONO_TRACE_IO_THREADPOOL, MONO_TRACE_ALL };
+                                                MONO_TRACE_THREADPOOL, MONO_TRACE_IO_THREADPOOL, MONO_TRACE_IO_LAYER, MONO_TRACE_ALL };
 
        if(!value)
                return;
@@ -253,7 +233,7 @@ mono_trace_set_mask_string (const char *value)
 gboolean
 mono_trace_is_traced (GLogLevelFlags level, MonoTraceMask mask)
 {
-       return (level <= current_level && mask & current_mask);
+       return (level <= mono_internal_current_level && mask & mono_internal_current_mask);
 }
 
 static MonoLogCallback log_callback;
index 71be40b92bf7fc5abc22553512baf33f3c7c835a..f05e70481058e2e4e182569a75125a8312a2d52b 100644 (file)
 #define CRYPT_VERIFY_CONTEXT   0xF0000000
 #endif
 
+/**
+ * mono_rand_open:
+ *
+ * Returns: True if random source is global, false if mono_rand_init can be called repeatedly to get randomness instances.
+ *
+ * Initializes entire RNG system. Must be called once per process before calling mono_rand_init.
+ */
 gboolean
 mono_rand_open (void)
 {
-       /* FALSE == Local (instance) handle for randomness */
        return FALSE;
 }
 
+/**
+ * mono_rand_init:
+ * @seed: A string containing seed data
+ * @seed_size: Length of seed string
+ *
+ * Returns: On success, a non-NULL handle which can be used to fetch random data from mono_rand_try_get_bytes. On failure, NULL.
+ *
+ * Initializes an RNG client.
+ */
 gpointer
 mono_rand_init (guchar *seed, gint seed_size)
 {
@@ -77,6 +92,16 @@ mono_rand_init (guchar *seed, gint seed_size)
        return (gpointer) provider;
 }
 
+/**
+ * mono_rand_try_get_bytes:
+ * @handle: A pointer to an RNG handle. Handle is set to NULL on failure.
+ * @buffer: A buffer into which to write random data.
+ * @buffer_size: Number of bytes to write into buffer.
+ *
+ * Returns: FALSE on failure, TRUE on success.
+ *
+ * Extracts bytes from an RNG handle.
+ */
 gboolean
 mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gint buffer_size)
 {
@@ -99,6 +124,14 @@ mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gint buffer_size)
        return TRUE;
 }
 
+/**
+ * mono_rand_close:
+ * @handle: An RNG handle.
+ * @buffer: A buffer into which to write random data.
+ * @buffer_size: Number of bytes to write into buffer.
+ *
+ * Releases an RNG handle.
+ */
 void
 mono_rand_close (gpointer handle)
 {
@@ -215,7 +248,7 @@ mono_rand_open (void)
 gpointer
 mono_rand_init (guchar *seed, gint seed_size)
 {
-       /* if required exception will be thrown in managed code */
+       // file < 0 is expected in the egd case
        return (!use_egd && file < 0) ? NULL : GINT_TO_POINTER (file);
 }
 
@@ -282,7 +315,7 @@ mono_rand_open (void)
 gpointer
 mono_rand_init (guchar *seed, gint seed_size)
 {
-       return NULL;    
+       return "srand"; // NULL will be interpreted as failure; return arbitrary nonzero pointer
 }
 
 gboolean
@@ -316,6 +349,17 @@ mono_rand_close (gpointer provider)
 
 #endif
 
+/**
+ * mono_rand_try_get_uint32:
+ * @handle: A pointer to an RNG handle. Handle is set to NULL on failure.
+ * @val: A pointer to a 32-bit unsigned int, to which the result will be written.
+ * @min: Result will be greater than or equal to this value.
+ * @max: Result will be less than or equal to this value.
+ *
+ * Returns: FALSE on failure, TRUE on success.
+ *
+ * Extracts one 32-bit unsigned int from an RNG handle.
+ */
 gboolean
 mono_rand_try_get_uint32 (gpointer *handle, guint32 *val, guint32 min, guint32 max)
 {
@@ -323,7 +367,9 @@ mono_rand_try_get_uint32 (gpointer *handle, guint32 *val, guint32 min, guint32 m
        if (!mono_rand_try_get_bytes (handle, (guchar*) val, sizeof (guint32)))
                return FALSE;
 
-       *val = (guint32) (((gdouble) *val) / G_MAXUINT32 * (max - min) + min);
+       double randomDouble = ((gdouble) *val) / ( ((double)G_MAXUINT32) + 1 ); // Range is [0,1)
+       *val = (guint32) (randomDouble * (max - min + 1) + min);
+
        g_assert (*val >= min);
        g_assert (*val <= max);
 
index 5fe411dbe1ae05f60bfcd355b1b436204d57ae5a..111146811de55977a4b16717d77eeca992b5b478 100644 (file)
@@ -250,6 +250,9 @@ typedef struct {
        void *jit_data;
 
        MonoThreadInfoInterruptToken *interrupt_token;
+
+       /* MonoHandleArena for coop handles */
+       gpointer handle_arena;
 } MonoThreadInfo;
 
 typedef struct {
index f4be234ee2e1d035a49b4ca78acb097f950f650a..258f984d8e339e04ee1d49141e3f085ff31d6131 100644 (file)
@@ -56,6 +56,7 @@
     <ClCompile Include="..\mono\metadata\filewatcher.c" />\r
     <ClCompile Include="..\mono\metadata\gc-stats.c" />\r
     <ClCompile Include="..\mono\metadata\gc.c" />\r
+    <ClCompile Include="..\mono\metadata\handle.c" />\r
     <ClCompile Include="..\mono\metadata\icall.c" />\r
     <ClCompile Include="..\mono\metadata\image.c" />\r
     <ClCompile Include="..\mono\metadata\jit-info.c" />\r
     <ClInclude Include="..\mono\metadata\file-io.h" />\r
     <ClInclude Include="..\mono\metadata\filewatcher.h" />\r
     <ClInclude Include="..\mono\metadata\gc-internals.h" />\r
+    <ClInclude Include="..\mono\metadata\handle.h" />\r
     <ClInclude Include="..\mono\metadata\number-ms.h" />\r
     <ClInclude Include="..\mono\metadata\seq-points-data.h" />\r
     <ClInclude Include="..\mono\metadata\threadpool-ms-io.h" />\r
index 79154fc99bbd9b232eb8c4bd1e16119b07d9bb45..be3864cc9dab1facb674ed486098cf0efcf8c846 100644 (file)
@@ -161,7 +161,7 @@ refresh:
        --rename-member=st_mtime=st_mtime_                    \
        --rename-namespace=Mono.Unix.Native=Mono.Posix        \
        --library=MonoPosixHelper                             \
-       $(mcs_topdir)/class/lib/net_4_x/Mono.Posix.dll map
+       $(mcs_topdir_from_srcdir)/class/lib/net_4_x/Mono.Posix.dll map
 
 # Useful if mono is compiled with --enable-shared=no
 patch-libtool:
index ee61ae661d9be7e741c0997fdf7e6de54ccc5d9a..6201c260c93369f1e37c4ceb340fe7c693b9a055 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file was automatically generated by create-native-map from /home/kiesssn/prog/mono/mono/mcs/class/lib/net_4_x/Mono.Posix.dll.
+ * This file was automatically generated by create-native-map from ../mcs/class/lib/net_4_x/Mono.Posix.dll.
  *
  * DO NOT MODIFY.
  */
@@ -5149,6 +5149,172 @@ int Mono_Posix_ToSignum (int x, int *r)
        errno = EINVAL; return -1;
 }
 
+#ifdef HAVE_STRUCT_SOCKADDR_IN
+int
+Mono_Posix_FromSockaddrIn (struct Mono_Posix_SockaddrIn *from, struct sockaddr_in *to)
+{
+       _cnm_return_val_if_overflow (unsigned short, from->sin_port, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->sin_port = from->sin_port;
+       if (Mono_Posix_FromInAddr (&from->sin_addr, &to->sin_addr) != 0) {
+               return -1;
+       }
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN */
+
+
+#ifdef HAVE_STRUCT_SOCKADDR_IN
+int
+Mono_Posix_ToSockaddrIn (struct sockaddr_in *from, struct Mono_Posix_SockaddrIn *to)
+{
+       _cnm_return_val_if_overflow (unsigned short, from->sin_port, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->sin_port = from->sin_port;
+       if (Mono_Posix_ToInAddr (&from->sin_addr, &to->sin_addr) != 0) {
+               return -1;
+       }
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN */
+
+
+#ifdef HAVE_STRUCT_SOCKADDR_IN6
+int
+Mono_Posix_FromSockaddrIn6 (struct Mono_Posix_SockaddrIn6 *from, struct sockaddr_in6 *to)
+{
+       _cnm_return_val_if_overflow (unsigned short, from->sin6_port, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_flowinfo, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_scope_id, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->sin6_port     = from->sin6_port;
+       to->sin6_flowinfo = from->sin6_flowinfo;
+       if (Mono_Posix_FromIn6Addr (&from->sin6_addr, &to->sin6_addr) != 0) {
+               return -1;
+       }
+       to->sin6_scope_id = from->sin6_scope_id;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN6 */
+
+
+#ifdef HAVE_STRUCT_SOCKADDR_IN6
+int
+Mono_Posix_ToSockaddrIn6 (struct sockaddr_in6 *from, struct Mono_Posix_SockaddrIn6 *to)
+{
+       _cnm_return_val_if_overflow (unsigned short, from->sin6_port, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_flowinfo, -1);
+       _cnm_return_val_if_overflow (unsigned int, from->sin6_scope_id, -1);
+
+       memset (to, 0, sizeof(*to));
+
+       to->sin6_port     = from->sin6_port;
+       to->sin6_flowinfo = from->sin6_flowinfo;
+       if (Mono_Posix_ToIn6Addr (&from->sin6_addr, &to->sin6_addr) != 0) {
+               return -1;
+       }
+       to->sin6_scope_id = from->sin6_scope_id;
+
+       return 0;
+}
+#endif /* ndef HAVE_STRUCT_SOCKADDR_IN6 */
+
+
+int Mono_Posix_FromSockaddrType (int x, int *r)
+{
+       *r = 0;
+       if (x == Mono_Posix_SockaddrType_Invalid)
+#ifdef Invalid
+               {*r = Invalid; return 0;}
+#else /* def Invalid */
+               {errno = EINVAL; return -1;}
+#endif /* ndef Invalid */
+       if (x == Mono_Posix_SockaddrType_MustBeWrapped)
+#ifdef MustBeWrapped
+               {*r = MustBeWrapped; return 0;}
+#else /* def MustBeWrapped */
+               {errno = EINVAL; return -1;}
+#endif /* ndef MustBeWrapped */
+       if (x == Mono_Posix_SockaddrType_Sockaddr)
+#ifdef Sockaddr
+               {*r = Sockaddr; return 0;}
+#else /* def Sockaddr */
+               {errno = EINVAL; return -1;}
+#endif /* ndef Sockaddr */
+       if (x == Mono_Posix_SockaddrType_SockaddrIn)
+#ifdef SockaddrIn
+               {*r = SockaddrIn; return 0;}
+#else /* def SockaddrIn */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrIn */
+       if (x == Mono_Posix_SockaddrType_SockaddrIn6)
+#ifdef SockaddrIn6
+               {*r = SockaddrIn6; return 0;}
+#else /* def SockaddrIn6 */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrIn6 */
+       if (x == Mono_Posix_SockaddrType_SockaddrStorage)
+#ifdef SockaddrStorage
+               {*r = SockaddrStorage; return 0;}
+#else /* def SockaddrStorage */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrStorage */
+       if (x == Mono_Posix_SockaddrType_SockaddrUn)
+#ifdef SockaddrUn
+               {*r = SockaddrUn; return 0;}
+#else /* def SockaddrUn */
+               {errno = EINVAL; return -1;}
+#endif /* ndef SockaddrUn */
+       if (x == 0)
+               return 0;
+       errno = EINVAL; return -1;
+}
+
+int Mono_Posix_ToSockaddrType (int x, int *r)
+{
+       *r = 0;
+       if (x == 0)
+               return 0;
+#ifdef Invalid
+       if (x == Invalid)
+               {*r = Mono_Posix_SockaddrType_Invalid; return 0;}
+#endif /* ndef Invalid */
+#ifdef MustBeWrapped
+       if (x == MustBeWrapped)
+               {*r = Mono_Posix_SockaddrType_MustBeWrapped; return 0;}
+#endif /* ndef MustBeWrapped */
+#ifdef Sockaddr
+       if (x == Sockaddr)
+               {*r = Mono_Posix_SockaddrType_Sockaddr; return 0;}
+#endif /* ndef Sockaddr */
+#ifdef SockaddrIn
+       if (x == SockaddrIn)
+               {*r = Mono_Posix_SockaddrType_SockaddrIn; return 0;}
+#endif /* ndef SockaddrIn */
+#ifdef SockaddrIn6
+       if (x == SockaddrIn6)
+               {*r = Mono_Posix_SockaddrType_SockaddrIn6; return 0;}
+#endif /* ndef SockaddrIn6 */
+#ifdef SockaddrStorage
+       if (x == SockaddrStorage)
+               {*r = Mono_Posix_SockaddrType_SockaddrStorage; return 0;}
+#endif /* ndef SockaddrStorage */
+#ifdef SockaddrUn
+       if (x == SockaddrUn)
+               {*r = Mono_Posix_SockaddrType_SockaddrUn; return 0;}
+#endif /* ndef SockaddrUn */
+       errno = EINVAL; return -1;
+}
+
 int Mono_Posix_FromSysconfName (int x, int *r)
 {
        *r = 0;
@@ -7902,6 +8068,12 @@ int Mono_Posix_FromUnixAddressFamily (int x, int *r)
 #else /* def AF_X25 */
                {errno = EINVAL; return -1;}
 #endif /* ndef AF_X25 */
+       if (x == Mono_Posix_UnixAddressFamily_Unknown)
+#ifdef Unknown
+               {*r = Unknown; return 0;}
+#else /* def Unknown */
+               {errno = EINVAL; return -1;}
+#endif /* ndef Unknown */
        if (x == 0)
                return 0;
        errno = EINVAL; return -1;
@@ -8068,6 +8240,10 @@ int Mono_Posix_ToUnixAddressFamily (int x, int *r)
        if (x == AF_X25)
                {*r = Mono_Posix_UnixAddressFamily_AF_X25; return 0;}
 #endif /* ndef AF_X25 */
+#ifdef Unknown
+       if (x == Unknown)
+               {*r = Mono_Posix_UnixAddressFamily_Unknown; return 0;}
+#endif /* ndef Unknown */
        errno = EINVAL; return -1;
 }
 
index 9f89fcde93b94c6326a863c767ea2ff2b4b877c7..e95b4f9c4d8bc5a071be87db28a02f673ac28689 100644 (file)
@@ -1018,6 +1018,25 @@ enum Mono_Posix_Signum {
 int Mono_Posix_FromSignum (int x, int *r);
 int Mono_Posix_ToSignum (int x, int *r);
 
+enum Mono_Posix_SockaddrType {
+       Mono_Posix_SockaddrType_Invalid               = 0x00000000,
+       #define Mono_Posix_SockaddrType_Invalid         Mono_Posix_SockaddrType_Invalid
+       Mono_Posix_SockaddrType_MustBeWrapped         = 0x00008000,
+       #define Mono_Posix_SockaddrType_MustBeWrapped   Mono_Posix_SockaddrType_MustBeWrapped
+       Mono_Posix_SockaddrType_Sockaddr              = 0x00000003,
+       #define Mono_Posix_SockaddrType_Sockaddr        Mono_Posix_SockaddrType_Sockaddr
+       Mono_Posix_SockaddrType_SockaddrIn            = 0x00000004,
+       #define Mono_Posix_SockaddrType_SockaddrIn      Mono_Posix_SockaddrType_SockaddrIn
+       Mono_Posix_SockaddrType_SockaddrIn6           = 0x00000005,
+       #define Mono_Posix_SockaddrType_SockaddrIn6     Mono_Posix_SockaddrType_SockaddrIn6
+       Mono_Posix_SockaddrType_SockaddrStorage       = 0x00000001,
+       #define Mono_Posix_SockaddrType_SockaddrStorage Mono_Posix_SockaddrType_SockaddrStorage
+       Mono_Posix_SockaddrType_SockaddrUn            = 0x00000002,
+       #define Mono_Posix_SockaddrType_SockaddrUn      Mono_Posix_SockaddrType_SockaddrUn
+};
+int Mono_Posix_FromSockaddrType (int x, int *r);
+int Mono_Posix_ToSockaddrType (int x, int *r);
+
 enum Mono_Posix_SysconfName {
        Mono_Posix_SysconfName__SC_2_CHAR_TERM                        = 0x0000005f,
        #define Mono_Posix_SysconfName__SC_2_CHAR_TERM                  Mono_Posix_SysconfName__SC_2_CHAR_TERM
@@ -1587,6 +1606,8 @@ enum Mono_Posix_UnixAddressFamily {
        #define Mono_Posix_UnixAddressFamily_AF_WANPIPE    Mono_Posix_UnixAddressFamily_AF_WANPIPE
        Mono_Posix_UnixAddressFamily_AF_X25              = 0x00000009,
        #define Mono_Posix_UnixAddressFamily_AF_X25        Mono_Posix_UnixAddressFamily_AF_X25
+       Mono_Posix_UnixAddressFamily_Unknown             = 0x00010000,
+       #define Mono_Posix_UnixAddressFamily_Unknown       Mono_Posix_UnixAddressFamily_Unknown
 };
 int Mono_Posix_FromUnixAddressFamily (int x, int *r);
 int Mono_Posix_ToUnixAddressFamily (int x, int *r);
@@ -1799,9 +1820,13 @@ int Mono_Posix_ToXattrFlags (int x, int *r);
  */
 
 struct Mono_Posix_Flock;
+struct Mono_Posix_In6Addr;
+struct Mono_Posix_InAddr;
 struct Mono_Posix_Iovec;
 struct Mono_Posix_Linger;
 struct Mono_Posix_Pollfd;
+struct Mono_Posix_SockaddrIn;
+struct Mono_Posix_SockaddrIn6;
 struct Mono_Posix_Stat;
 struct Mono_Posix_Statvfs;
 struct Mono_Posix_Syscall__Dirent;
@@ -1813,6 +1838,8 @@ struct Mono_Posix_Timespec;
 struct Mono_Posix_Timeval;
 struct Mono_Posix_Timezone;
 struct Mono_Posix_Utimbuf;
+struct Mono_Posix__SockaddrDynamic;
+struct Mono_Posix__SockaddrHeader;
 struct Mono_Unix_UnixSignal_SignalInfo;
 
 /*
@@ -1823,6 +1850,8 @@ struct flock;
 struct iovec;
 struct linger;
 struct pollfd;
+struct sockaddr_in;
+struct sockaddr_in6;
 struct timespec;
 struct timeval;
 struct timezone;
@@ -1852,6 +1881,15 @@ int
 Mono_Posix_ToFlock (struct flock *from, struct Mono_Posix_Flock* to);
 
 
+struct Mono_Posix_In6Addr {
+       guint64 addr0;
+       guint64 addr1;
+};
+
+struct Mono_Posix_InAddr {
+       unsigned int s_addr;
+};
+
 struct Mono_Posix_Iovec {
        void*   iov_base;
        guint64 iov_len;
@@ -1886,6 +1924,34 @@ int
 Mono_Posix_ToPollfd (struct pollfd *from, struct Mono_Posix_Pollfd* to);
 
 
+struct Mono_Posix_SockaddrIn {
+       int                      type;
+       int                      _sa_family;
+       unsigned short           sin_port;
+       struct Mono_Posix_InAddr sin_addr;
+};
+
+int
+Mono_Posix_FromSockaddrIn (struct Mono_Posix_SockaddrIn* from, struct sockaddr_in *to);
+int
+Mono_Posix_ToSockaddrIn (struct sockaddr_in *from, struct Mono_Posix_SockaddrIn* to);
+
+
+struct Mono_Posix_SockaddrIn6 {
+       int                       type;
+       int                       _sa_family;
+       unsigned short            sin6_port;
+       unsigned int              sin6_flowinfo;
+       struct Mono_Posix_In6Addr sin6_addr;
+       unsigned int              sin6_scope_id;
+};
+
+int
+Mono_Posix_FromSockaddrIn6 (struct Mono_Posix_SockaddrIn6* from, struct sockaddr_in6 *to);
+int
+Mono_Posix_ToSockaddrIn6 (struct sockaddr_in6 *from, struct Mono_Posix_SockaddrIn6* to);
+
+
 struct Mono_Posix_Stat {
        guint64      st_dev;         /* dev_t     */
        guint64      st_ino;         /* ino_t     */
@@ -2013,6 +2079,18 @@ int
 Mono_Posix_ToUtimbuf (struct utimbuf *from, struct Mono_Posix_Utimbuf* to);
 
 
+struct Mono_Posix__SockaddrDynamic {
+       int            type;
+       int            sa_family;
+       unsigned char* data;
+       gint64         len;
+};
+
+struct Mono_Posix__SockaddrHeader {
+       int type;
+       int sa_family;
+};
+
 struct Mono_Unix_UnixSignal_SignalInfo {
        int   signum;
        int   count;
@@ -2036,14 +2114,17 @@ int map_Mono_Posix_AccessMode (int mode);
 int map_Mono_Posix_FileMode (int mode);
 int map_Mono_Posix_OpenFlags (int flags);
 int map_Mono_Posix_WaitOptions (int wait_options);
+int Mono_Posix_FromIn6Addr (struct Mono_Posix_In6Addr* source, void* destination);
+int Mono_Posix_FromInAddr (struct Mono_Posix_InAddr* source, void* destination);
 int Mono_Posix_FromRealTimeSignum (int offset, int* rval);
+int Mono_Posix_FromSockaddr (struct Mono_Posix__SockaddrHeader* source, void* destination);
 int Mono_Posix_FromStat (struct Mono_Posix_Stat* source, void* destination);
 int Mono_Posix_FromStatvfs (struct Mono_Posix_Statvfs* source, void* destination);
 int Mono_Posix_SIGRTMAX (void);
 int Mono_Posix_SIGRTMIN (void);
-int Mono_Posix_Stdlib__IOFBF (void);
-int Mono_Posix_Stdlib__IOLBF (void);
-int Mono_Posix_Stdlib__IONBF (void);
+int Mono_Posix_SockaddrStorage_get_size (void);
+int Mono_Posix_SockaddrUn_get_sizeof_sun_path (void);
+int Mono_Posix_Sockaddr_GetNativeSize (struct Mono_Posix__SockaddrHeader* address, gint64* size);
 int Mono_Posix_Stdlib_BUFSIZ (void);
 void* Mono_Posix_Stdlib_calloc (guint64 nmemb, guint64 size);
 int Mono_Posix_Stdlib_clearerr (void* stream);
@@ -2080,8 +2161,15 @@ void* Mono_Posix_Stdlib_stdin (void);
 void* Mono_Posix_Stdlib_stdout (void);
 guint64 Mono_Posix_Stdlib_strlen (void* s);
 int Mono_Posix_Stdlib_TMP_MAX (void);
+int Mono_Posix_Stdlib__IOFBF (void);
+int Mono_Posix_Stdlib__IOLBF (void);
+int Mono_Posix_Stdlib__IONBF (void);
+int Mono_Posix_Syscall_accept (int socket, struct Mono_Posix__SockaddrHeader* address);
+int Mono_Posix_Syscall_accept4 (int socket, struct Mono_Posix__SockaddrHeader* address, int flags);
+int Mono_Posix_Syscall_bind (int socket, struct Mono_Posix__SockaddrHeader* address);
 int Mono_Posix_Syscall_closelog (void);
 guint64 Mono_Posix_Syscall_confstr (int name, char* buf, guint64 len);
+int Mono_Posix_Syscall_connect (int socket, struct Mono_Posix__SockaddrHeader* address);
 int Mono_Posix_Syscall_creat (const char* pathname, unsigned int mode);
 int Mono_Posix_Syscall_endfsent (void);
 int Mono_Posix_Syscall_endgrent (void);
@@ -2105,9 +2193,6 @@ int Mono_Posix_Syscall_fstatvfs (int fd, struct Mono_Posix_Statvfs* buf);
 int Mono_Posix_Syscall_ftruncate (int fd, gint64 length);
 int Mono_Posix_Syscall_futimens (int fd, struct Mono_Posix_Timespec* times);
 int Mono_Posix_Syscall_futimes (int fd, struct Mono_Posix_Timeval* tvp);
-int Mono_Posix_Syscall_get_at_fdcwd (void);
-gint64 Mono_Posix_Syscall_get_utime_now (void);
-gint64 Mono_Posix_Syscall_get_utime_omit (void);
 void* Mono_Posix_Syscall_getcwd (char* buf, guint64 size);
 int Mono_Posix_Syscall_getdomainname (char* name, guint64 len);
 int Mono_Posix_Syscall_getfsent (struct Mono_Posix_Syscall__Fstab* fs);
@@ -2121,18 +2206,21 @@ int Mono_Posix_Syscall_getgrnam_r (const char* name, struct Mono_Posix_Syscall__
 gint64 Mono_Posix_Syscall_gethostid (void);
 int Mono_Posix_Syscall_gethostname (char* name, guint64 len);
 int Mono_Posix_Syscall_getlogin_r (char* name, guint64 bufsize);
+int Mono_Posix_Syscall_getpeername (int socket, struct Mono_Posix__SockaddrHeader* address);
 int Mono_Posix_Syscall_getpwent (struct Mono_Posix_Syscall__Passwd* pwbuf);
 int Mono_Posix_Syscall_getpwnam (const char* name, struct Mono_Posix_Syscall__Passwd* passwd);
 int Mono_Posix_Syscall_getpwnam_r (const char* name, struct Mono_Posix_Syscall__Passwd* pwbuf, void** pwbufp);
 int Mono_Posix_Syscall_getpwuid (unsigned int uid, struct Mono_Posix_Syscall__Passwd* passwd);
 int Mono_Posix_Syscall_getpwuid_r (unsigned int uid, struct Mono_Posix_Syscall__Passwd* pwbuf, void** pwbufp);
+int Mono_Posix_Syscall_getsockname (int socket, struct Mono_Posix__SockaddrHeader* address);
 int Mono_Posix_Syscall_getsockopt (int socket, int level, int option_name, void* option_value, gint64* option_len);
 int Mono_Posix_Syscall_getsockopt_linger (int socket, int level, int option_name, struct Mono_Posix_Linger* option_value);
 int Mono_Posix_Syscall_getsockopt_timeval (int socket, int level, int option_name, struct Mono_Posix_Timeval* option_value);
 int Mono_Posix_Syscall_gettimeofday (struct Mono_Posix_Timeval* tv, void* ignore);
 gint64 Mono_Posix_Syscall_getxattr (const char* path, const char* name, unsigned char* value, guint64 size);
-int Mono_Posix_Syscall_L_ctermid (void);
-int Mono_Posix_Syscall_L_cuserid (void);
+int Mono_Posix_Syscall_get_at_fdcwd (void);
+gint64 Mono_Posix_Syscall_get_utime_now (void);
+gint64 Mono_Posix_Syscall_get_utime_omit (void);
 gint64 Mono_Posix_Syscall_lgetxattr (const char* path, const char* name, unsigned char* value, guint64 size);
 gint64 Mono_Posix_Syscall_listxattr (const char* path, unsigned char* list, guint64 size);
 gint64 Mono_Posix_Syscall_llistxattr (const char* path, unsigned char* list, guint64 size);
@@ -2142,6 +2230,8 @@ gint64 Mono_Posix_Syscall_lseek (int fd, gint64 offset, int whence);
 int Mono_Posix_Syscall_lsetxattr (const char* path, const char* name, unsigned char* value, guint64 size, int flags);
 int Mono_Posix_Syscall_lstat (const char* file_name, struct Mono_Posix_Stat* buf);
 int Mono_Posix_Syscall_lutimes (const char* filename, struct Mono_Posix_Timeval* tvp);
+int Mono_Posix_Syscall_L_ctermid (void);
+int Mono_Posix_Syscall_L_cuserid (void);
 int Mono_Posix_Syscall_mincore (void* start, guint64 length, unsigned char* vec);
 int Mono_Posix_Syscall_mknod (const char* pathname, unsigned int mode, guint64 dev);
 int Mono_Posix_Syscall_mknodat (int dirfd, const char* pathname, unsigned int mode, guint64 dev);
@@ -2154,8 +2244,8 @@ int Mono_Posix_Syscall_munlock (void* start, guint64 len);
 int Mono_Posix_Syscall_munmap (void* start, guint64 length);
 int Mono_Posix_Syscall_nanosleep (struct Mono_Posix_Timespec* req, struct Mono_Posix_Timespec* rem);
 int Mono_Posix_Syscall_open (const char* pathname, int flags);
-int Mono_Posix_Syscall_open_mode (const char* pathname, int flags, unsigned int mode);
 int Mono_Posix_Syscall_openlog (void* ident, int option, int facility);
+int Mono_Posix_Syscall_open_mode (const char* pathname, int flags, unsigned int mode);
 gint64 Mono_Posix_Syscall_pathconf (const char* path, int name, int defaultError);
 int Mono_Posix_Syscall_pipe (int* reading, int* writing);
 int Mono_Posix_Syscall_posix_fadvise (int fd, gint64 offset, gint64 len, int advice);
@@ -2173,12 +2263,14 @@ gint64 Mono_Posix_Syscall_readlink (const char* path, unsigned char* buf, guint6
 gint64 Mono_Posix_Syscall_readlinkat (int dirfd, const char* pathname, unsigned char* buf, guint64 bufsiz);
 gint64 Mono_Posix_Syscall_readv (int fd, struct Mono_Posix_Iovec* iov, int iovcnt);
 gint64 Mono_Posix_Syscall_recv (int socket, void* buffer, guint64 length, int flags);
+gint64 Mono_Posix_Syscall_recvfrom (int socket, void* buffer, guint64 length, int flags, struct Mono_Posix__SockaddrHeader* address);
 int Mono_Posix_Syscall_remap_file_pages (void* start, guint64 size, int prot, gint64 pgoff, int flags);
 int Mono_Posix_Syscall_removexattr (const char* path, const char* name);
 int Mono_Posix_Syscall_rewinddir (void* dir);
 int Mono_Posix_Syscall_seekdir (void* dir, gint64 offset);
 gint64 Mono_Posix_Syscall_send (int socket, void* message, guint64 length, int flags);
 gint64 Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, gint64* offset, guint64 count);
+gint64 Mono_Posix_Syscall_sendto (int socket, void* message, guint64 length, int flags, struct Mono_Posix__SockaddrHeader* address);
 int Mono_Posix_Syscall_setdomainname (const char* name, guint64 len);
 int Mono_Posix_Syscall_setfsent (void);
 int Mono_Posix_Syscall_setgrent (void);
@@ -2217,6 +2309,9 @@ gint64 Mono_Posix_Syscall_write (int fd, void* buf, guint64 count);
 gint64 Mono_Posix_Syscall_writev (int fd, struct Mono_Posix_Iovec* iov, int iovcnt);
 int Mono_Posix_Syscall_WSTOPSIG (int status);
 int Mono_Posix_Syscall_WTERMSIG (int status);
+int Mono_Posix_ToIn6Addr (void* source, struct Mono_Posix_In6Addr* destination);
+int Mono_Posix_ToInAddr (void* source, struct Mono_Posix_InAddr* destination);
+int Mono_Posix_ToSockaddr (void* source, gint64 size, struct Mono_Posix__SockaddrHeader* destination);
 int Mono_Posix_ToStat (void* source, struct Mono_Posix_Stat* destination);
 int Mono_Posix_ToStatvfs (void* source, struct Mono_Posix_Statvfs* destination);
 void* Mono_Unix_UnixSignal_install (int signum);
index 188df56a18e25e6c978b73f8a4044a4fdaaddbc3..36da7d51661d14cff31ceec3ce37a2c08dad9657 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/time.h>
 #include <netinet/in.h>
 #include <sys/un.h>
+#include <unistd.h>
 
 #include <stddef.h>
 
 
 G_BEGIN_DECLS
 
+int
+Mono_Posix_SockaddrStorage_get_size (void)
+{
+       return sizeof (struct sockaddr_storage);
+}
+
+int
+Mono_Posix_SockaddrUn_get_sizeof_sun_path (void)
+{
+       struct sockaddr_un sun;
+       return sizeof (sun.sun_path);
+}
+
+int
+Mono_Posix_FromInAddr (struct Mono_Posix_InAddr* source, void* destination)
+{
+       memcpy (&((struct in_addr*)destination)->s_addr, &source->s_addr, 4);
+       return 0;
+}
+
+int
+Mono_Posix_ToInAddr (void* source, struct Mono_Posix_InAddr* destination)
+{
+       memcpy (&destination->s_addr, &((struct in_addr*)source)->s_addr, 4);
+       return 0;
+}
+
+int
+Mono_Posix_FromIn6Addr (struct Mono_Posix_In6Addr* source, void* destination)
+{
+       memcpy (&((struct in6_addr*)destination)->s6_addr, &source->addr0, 16);
+       return 0;
+}
+
+int
+Mono_Posix_ToIn6Addr (void* source, struct Mono_Posix_In6Addr* destination)
+{
+       memcpy (&destination->addr0, &((struct in6_addr*)source)->s6_addr, 16);
+       return 0;
+}
+
+
 int
 Mono_Posix_Syscall_socketpair (int domain, int type, int protocol, int* socket1, int* socket2)
 {
@@ -123,6 +166,295 @@ Mono_Posix_Syscall_setsockopt_linger (int socket, int level, int option_name, st
        return setsockopt (socket, level, option_name, &ling, sizeof (struct linger));
 }
 
+static int
+get_addrlen (struct Mono_Posix__SockaddrHeader* address, socklen_t* addrlen)
+{
+       if (!address) {
+               *addrlen = 0;
+               return 0;
+       }
+
+       switch (address->type) {
+       case Mono_Posix_SockaddrType_SockaddrStorage:
+               mph_return_if_socklen_t_overflow (((struct Mono_Posix__SockaddrDynamic*) address)->len);
+               *addrlen = ((struct Mono_Posix__SockaddrDynamic*) address)->len;
+               return 0;
+       case Mono_Posix_SockaddrType_SockaddrUn:
+               mph_return_if_socklen_t_overflow (offsetof (struct sockaddr_un, sun_path) + ((struct Mono_Posix__SockaddrDynamic*) address)->len);
+               *addrlen = offsetof (struct sockaddr_un, sun_path) + ((struct Mono_Posix__SockaddrDynamic*) address)->len;
+               return 0;
+       case Mono_Posix_SockaddrType_Sockaddr: *addrlen = sizeof (struct sockaddr); return 0;
+       case Mono_Posix_SockaddrType_SockaddrIn: *addrlen = sizeof (struct sockaddr_in); return 0;
+       case Mono_Posix_SockaddrType_SockaddrIn6: *addrlen = sizeof (struct sockaddr_in6); return 0;
+       default:
+               *addrlen = 0;
+               errno = EINVAL;
+               return -1;
+       }
+}
+
+int
+Mono_Posix_Sockaddr_GetNativeSize (struct Mono_Posix__SockaddrHeader* address, gint64* size)
+{
+       socklen_t value;
+       int r;
+
+       r = get_addrlen (address, &value);
+       *size = value;
+       return r;
+}
+
+int
+Mono_Posix_FromSockaddr (struct Mono_Posix__SockaddrHeader* source, void* destination)
+{
+       if (!source)
+               return 0;
+
+       switch (source->type) {
+       case Mono_Posix_SockaddrType_SockaddrStorage:
+               // Do nothing, don't copy source->sa_family into addr->sa_family
+               return 0;
+
+       case Mono_Posix_SockaddrType_SockaddrUn:
+               memcpy (((struct sockaddr_un*) destination)->sun_path, ((struct Mono_Posix__SockaddrDynamic*) source)->data, ((struct Mono_Posix__SockaddrDynamic*) source)->len);
+               break;
+
+       case Mono_Posix_SockaddrType_Sockaddr:
+               break;
+
+       case Mono_Posix_SockaddrType_SockaddrIn:
+               if (Mono_Posix_FromSockaddrIn ((struct Mono_Posix_SockaddrIn*) source, (struct sockaddr_in*) destination) != 0)
+                       return -1;
+               break;
+
+       case Mono_Posix_SockaddrType_SockaddrIn6:
+               if (Mono_Posix_FromSockaddrIn6 ((struct Mono_Posix_SockaddrIn6*) source, (struct sockaddr_in6*) destination) != 0)
+                       return -1;
+               break;
+
+       default:
+               errno = EINVAL;
+               return -1;
+       }
+
+       int family;
+       if (Mono_Posix_FromUnixAddressFamily (source->sa_family, &family) != 0)
+               return -1;
+       ((struct sockaddr*) destination)->sa_family = family;
+
+       return 0;
+}
+
+int
+Mono_Posix_ToSockaddr (void* source, gint64 size, struct Mono_Posix__SockaddrHeader* destination)
+{
+       struct Mono_Posix__SockaddrDynamic* destination_dyn;
+
+       if (!destination)
+               return 0;
+
+       switch (destination->type) {
+       case Mono_Posix_SockaddrType_Sockaddr:
+               if (size < offsetof (struct sockaddr, sa_family) + sizeof (sa_family_t)) {
+                       errno = ENOBUFS;
+                       return -1;
+               }
+               break;
+
+       case Mono_Posix_SockaddrType_SockaddrStorage:
+               destination_dyn = ((struct Mono_Posix__SockaddrDynamic*) destination);
+               if (size > destination_dyn->len) {
+                       errno = ENOBUFS;
+                       return -1;
+               }
+               destination_dyn->len = size;
+               break;
+
+       case Mono_Posix_SockaddrType_SockaddrUn:
+               destination_dyn = ((struct Mono_Posix__SockaddrDynamic*) destination);
+               if (size - offsetof (struct sockaddr_un, sun_path) > destination_dyn->len) {
+                       errno = ENOBUFS;
+                       return -1;
+               }
+               destination_dyn->len = size - offsetof (struct sockaddr_un, sun_path);
+               memcpy (destination_dyn->data, ((struct sockaddr_un*) source)->sun_path, size);
+               break;
+
+       case Mono_Posix_SockaddrType_SockaddrIn:
+               if (size != sizeof (struct sockaddr_in)) {
+                       errno = ENOBUFS;
+                       return -1;
+               }
+               if (Mono_Posix_ToSockaddrIn ((struct sockaddr_in*) source, (struct Mono_Posix_SockaddrIn*) destination) != 0)
+                       return -1;
+               break;
+
+       case Mono_Posix_SockaddrType_SockaddrIn6:
+               if (size != sizeof (struct sockaddr_in6)) {
+                       errno = ENOBUFS;
+                       return -1;
+               }
+               if (Mono_Posix_ToSockaddrIn6 ((struct sockaddr_in6*) source, (struct Mono_Posix_SockaddrIn6*) destination) != 0)
+                       return -1;
+               break;
+
+       default:
+               errno = EINVAL;
+               return -1;
+       }
+
+       if (Mono_Posix_ToUnixAddressFamily (((struct sockaddr*) source)->sa_family, &destination->sa_family) != 0)
+               destination->sa_family = Mono_Posix_UnixAddressFamily_Unknown;
+
+       return 0;
+}
+
+// Macro for allocating space for the native sockaddr_* structure
+// Must be a macro because it is using alloca()
+
+#define ALLOC_SOCKADDR                                                  \
+    socklen_t addrlen;                                                  \
+    struct sockaddr* addr;                                              \
+    gboolean need_free = 0;                                             \
+                                                                        \
+    if (get_addrlen (address, &addrlen) != 0)                           \
+        return -1;                                                      \
+    if (address == NULL) {                                              \
+        addr = NULL;                                                    \
+    } else if (address->type == Mono_Posix_SockaddrType_SockaddrStorage) { \
+        addr = (struct sockaddr*) ((struct Mono_Posix__SockaddrDynamic*) address)->data; \
+    } else if (address->type == Mono_Posix_SockaddrType_SockaddrUn) { \
+        /* Use alloca() for up to 2048 bytes, use malloc() otherwise */ \
+        need_free = addrlen > 2048;                                     \
+        addr = need_free ? malloc (addrlen) : alloca (addrlen);         \
+        if (!addr)                                                      \
+            return -1;                                                  \
+    } else {                                                            \
+        addr = alloca (addrlen);                                        \
+    }
+
+
+int
+Mono_Posix_Syscall_bind (int socket, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       ALLOC_SOCKADDR
+       if (Mono_Posix_FromSockaddr (address, addr) != 0) {
+               if (need_free)
+                       free (addr);
+               return -1;
+       }
+
+       r = bind (socket, addr, addrlen);
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
+int
+Mono_Posix_Syscall_connect (int socket, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       ALLOC_SOCKADDR
+       if (Mono_Posix_FromSockaddr (address, addr) != 0) {
+               if (need_free)
+                       free (addr);
+               return -1;
+       }
+
+       r = connect (socket, addr, addrlen);
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
+int
+Mono_Posix_Syscall_accept (int socket, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       ALLOC_SOCKADDR
+
+       r = accept (socket, addr, &addrlen);
+
+       if (r != -1 && Mono_Posix_ToSockaddr (addr, addrlen, address) != 0) {
+               close (r);
+               r = -1;
+       }
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
+int
+Mono_Posix_Syscall_accept4 (int socket, struct Mono_Posix__SockaddrHeader* address, int flags)
+{
+#ifdef HAVE_ACCEPT4
+       int r;
+
+       ALLOC_SOCKADDR
+
+       r = accept4 (socket, addr, &addrlen, flags);
+
+       if (r != -1 && Mono_Posix_ToSockaddr (addr, addrlen, address) != 0) {
+               close (r);
+               r = -1;
+       }
+
+       if (need_free)
+               free (addr);
+
+       return r;
+#else
+       errno = EINVAL;
+       return -1;
+#endif
+}
+
+int
+Mono_Posix_Syscall_getpeername (int socket, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       ALLOC_SOCKADDR
+
+       r = getpeername (socket, addr, &addrlen);
+
+       if (r != -1 && Mono_Posix_ToSockaddr (addr, addrlen, address) != 0)
+               r = -1;
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
+int
+Mono_Posix_Syscall_getsockname (int socket, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       ALLOC_SOCKADDR
+
+       r = getsockname (socket, addr, &addrlen);
+
+       if (r != -1 && Mono_Posix_ToSockaddr (addr, addrlen, address) != 0)
+               r = -1;
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
 gint64
 Mono_Posix_Syscall_recv (int socket, void* message, guint64 length, int flags)
 {
@@ -138,3 +470,52 @@ Mono_Posix_Syscall_send (int socket, void* message, guint64 length, int flags)
 
        return send (socket, message, length, flags);
 }
+
+gint64
+Mono_Posix_Syscall_recvfrom (int socket, void* buffer, guint64 length, int flags, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       mph_return_if_size_t_overflow (length);
+
+       ALLOC_SOCKADDR
+
+       r = recvfrom (socket, buffer, length, flags, addr, &addrlen);
+
+       if (r != -1 && Mono_Posix_ToSockaddr (addr, addrlen, address) != 0)
+               r = -1;
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
+gint64
+Mono_Posix_Syscall_sendto (int socket, void* message, guint64 length, int flags, struct Mono_Posix__SockaddrHeader* address)
+{
+       int r;
+
+       mph_return_if_size_t_overflow (length);
+
+       ALLOC_SOCKADDR
+       if (Mono_Posix_FromSockaddr (address, addr) != 0) {
+               if (need_free)
+                       free (addr);
+               return -1;
+       }
+
+       r = sendto (socket, message, length, flags, addr, addrlen);
+
+       if (need_free)
+               free (addr);
+
+       return r;
+}
+
+// vim: noexpandtab
+// Local Variables: 
+// tab-width: 4
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// End: 
index 9c100dd18db568d4a00c579c30f7516f33676cce..becba3e1da912fb96c30d66c30ffaf5ca005eda6 100644 (file)
@@ -1127,13 +1127,16 @@ namespace Mono.Tools.LocaleBuilder
                                if (el != null) {
                                        // CLDR uses unicode negative sign for some culture (e.g sv, is, lt, don't kwnow why) but .net always
                                        // uses simple - sign
-                                       if (el.InnerText == "\u2212") {
+                                       switch (el.InnerText) {
+                                       case "\u2212":
+                                       case "\u200F\u002D": // Remove any right-to-left mark characters
+                                       case "\u200E\u002D":
                                                ni.NegativeSign = "-";
-                                       } else if (el.InnerText ==  "\u200F\u002D") {
-                                               // Remove any right-to-left mark characters
-                                               ni.NegativeSign = "-";
-                                       } else
-                                               ni.NegativeSign = el.InnerText;                                 
+                                               break;
+                                       default:
+                                               ni.NegativeSign = el.InnerText;
+                                               break;
+                                       }
                                }
 
                                el = node.SelectSingleNode ("infinity");