Merge pull request #4628 from xmcclure/orbis-profile
authorAndi McClure <andi.mcclure@xamarin.com>
Fri, 31 Mar 2017 20:14:47 +0000 (16:14 -0400)
committerGitHub <noreply@github.com>
Fri, 31 Mar 2017 20:14:47 +0000 (16:14 -0400)
Platform support fixes

18 files changed:
configure.ac
eglib/src/gfile-unix.c
mcs/build/profiles/orbis.make
mcs/class/Makefile
mcs/class/System.Security/orbis_System.Security.dll.sources [new file with mode: 0644]
mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs
mcs/class/System/System.IO.Compression/DeflateStream.cs
mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs
mcs/class/System/System.Net.NetworkInformation/NetworkChange.cs
mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
mcs/class/System/System.Net.NetworkInformation/Ping.cs
mcs/class/System/System/Platform.cs
mcs/class/System/orbis_System.dll.exclude.sources [new file with mode: 0644]
mcs/class/referencesource/System/net/System/Net/webproxy.cs
mono/metadata/console-null.c
mono/mini/method-to-ir.c
mono/sgen/sgen-gc.h
mono/utils/mono-log-common.c

index bb1aecfa5ee583c8f59ec299599ca8582c06c7cb..2100aa1a4c0eba53c61763fa29d54e0f145e239f 100644 (file)
@@ -2407,6 +2407,8 @@ if test x$host_win32 = xno; then
        AC_CHECK_FUNCS(system)
        AC_CHECK_FUNCS(fork execv execve)
        AC_CHECK_FUNCS(accept4)
+       AC_CHECK_FUNCS(localtime_r)
+       AC_CHECK_FUNCS(mkdtemp)
        AC_CHECK_SIZEOF(size_t)
        AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , 
                [#include <sys/types.h>
index 9c34d8756930f4fa7e898995c1d02329843f1be9..ab1fbb483bd53d995c6b86f216655563cfc2b757 100644 (file)
@@ -82,7 +82,11 @@ g_file_test (const gchar *filename, GFileTest test)
 gchar *
 g_mkdtemp (char *tmp_template)
 {
+#ifdef HAVE_MKDTEMP
        char *template_copy = g_strdup (tmp_template);
 
        return mkdtemp (template_copy);
+#else
+       g_error("Function not supported");
+#endif
 }
index a43693e04b37a3f79ab77743e051bb2f213c880a..2a73e5139cb0bf4c53a4594fd99b7308915fe05e 100644 (file)
@@ -24,6 +24,7 @@ PROFILE_MCS_FLAGS = \
        -d:MOBILE,MOBILE_LEGACY \
        -d:FULL_AOT_DESKTOP     \
        -d:FULL_AOT_RUNTIME \
+       -d:ORBIS \
        -d:DISABLE_REMOTING \
        -d:DISABLE_COM \
        -nowarn:1699 \
@@ -40,6 +41,7 @@ ALWAYS_AOT = yes
 MOBILE_PROFILE = yes
 NO_VTS_TEST = yes
 NO_CONSOLE = yes
+PROFILE_DISABLE_BTLS = yes
 
 # Note need for trailing comma. If you add, keep it
 PROFILE_TEST_HARNESS_EXCLUDES = MobileNotWorking,PKITS,
index d9782620e36ecb72bd34f791461e19deeacfe5b5..5463f65160f305ace1e967b1275821aa213b18f2 100644 (file)
@@ -335,6 +335,11 @@ xbuild_4_0_dirs := \
        $(xbuild_2_0_dirs)      \
        Microsoft.Build
 
+orbis_exclude_dirs := \
+       Microsoft.CSharp \
+       Mono.CSharp \
+       Mono.Data.Sqlite
+
 monodroid_SUBDIRS := $(monodroid_dirs)
 monotouch_SUBDIRS := $(monotouch_dirs)
 monotouch_watch_SUBDIRS := $(monotouch_watch_dirs)
@@ -352,7 +357,7 @@ net_4_x_PARALLEL_SUBDIRS := $(net_4_x_parallel_dirs)
 xbuild_12_SUBDIRS := $(xbuild_4_0_dirs)
 xbuild_14_SUBDIRS := $(xbuild_4_0_dirs) Microsoft.NuGet.Build.Tasks
 winaot_SUBDIRS := $(winaot_dirs)
-orbis_SUBDIRS := $(monotouch_dirs)
+orbis_SUBDIRS := $(filter-out $(orbis_exclude_dirs),$(monotouch_dirs))
 
 include ../build/rules.make
 
diff --git a/mcs/class/System.Security/orbis_System.Security.dll.sources b/mcs/class/System.Security/orbis_System.Security.dll.sources
new file mode 100644 (file)
index 0000000..599b7fa
--- /dev/null
@@ -0,0 +1 @@
+#include common_System.Security.dll.sources
index 5b3aae1a70d010f91cc05a96296c9c7e8ccb2f56..00c77a9f0430497a4641fb359c8ef7f33dc26810 100644 (file)
@@ -42,7 +42,7 @@ namespace Mono.Net.Security
                {
 #if MONOTOUCH
                        is_macosx = true;
-#elif MONODROID
+#elif MONODROID || ORBIS
                        is_macosx = false;
 #else
                        is_macosx = Environment.OSVersion.Platform != PlatformID.Win32NT && System.IO.File.Exists (OSX509Certificates.SecurityLibrary);
@@ -156,6 +156,7 @@ namespace Mono.Net.Security
                        }
 #else
                        if (is_macosx) {
+#if !ORBIS
                                // Attempt to use OSX certificates
                                // Ideally we should return the SecTrustResult
                                OSX509Certificates.SecTrustResult trustResult = OSX509Certificates.SecTrustResult.Deny;
@@ -180,6 +181,9 @@ namespace Mono.Net.Security
                                        status11 = (int)trustResult;
                                        errors |= SslPolicyErrors.RemoteCertificateChainErrors;
                                }
+#else
+                               throw new PlatformNotSupportedException ();
+#endif
                        } else {
                                result = BuildX509Chain (certs, chain, ref errors, ref status11);
                        }
index 9d8dd61eb2415641247d742c0cc3f77c7130ed3f..8249d786c2e1a5d68f72e0981878d3c0aec30e80 100644 (file)
@@ -486,6 +486,7 @@ namespace System.IO.Compression
                const string LIBNAME = "MonoPosixHelper";
 #endif
 
+#if !ORBIS
                [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
                static extern IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data);
 
@@ -500,6 +501,33 @@ namespace System.IO.Compression
 
                [DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
                static extern int WriteZStream (IntPtr stream, IntPtr buffer, int length);
+#else
+               static IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data)
+               {
+                       throw new PlatformNotSupportedException ();
+               }
+
+               static int CloseZStream (IntPtr stream)
+               {
+                       throw new PlatformNotSupportedException ();
+               }
+
+               static int Flush (IntPtr stream)
+               {
+                       throw new PlatformNotSupportedException ();
+               }
+
+               static int ReadZStream (IntPtr stream, IntPtr buffer, int length)
+               {
+                       throw new PlatformNotSupportedException ();
+               }
+
+               static int WriteZStream (IntPtr stream, IntPtr buffer, int length)
+               {
+                       throw new PlatformNotSupportedException ();
+               }
+#endif
+
        }
 }
 
index 0048b72c986f0c52287686cc5fc1a42eb17f7c8d..92bd3ffb363ed22d41fcae547bdece2f68ef9632 100644 (file)
@@ -42,8 +42,15 @@ namespace System.Net.NetworkInformation {
                [DllImport ("libc")]
                static extern int gethostname ([MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] name, int len);
 
+#if !ORBIS
                [DllImport ("libc")]
                static extern int getdomainname ([MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] name, int len);
+#else
+               static int getdomainname ([MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] name, int len)
+               {
+                       throw new PlatformNotSupportedException ();
+               }
+#endif
 
                public override string DhcpScopeName {
                        get { return String.Empty; }
index 9b6b1e5df94842d45a14909a04e72e1d87449881..8304ac82b4fdb1615c3b6ff48a38d25b0b91d389 100644 (file)
@@ -101,7 +101,7 @@ namespace System.Net.NetworkInformation {
 
                static void MaybeCreate ()
                {
-#if MONOTOUCH_WATCH
+#if MONOTOUCH_WATCH || ORBIS
                        throw new PlatformNotSupportedException ("NetworkInformation.NetworkChange is not supported on the current platform.");
 #else
                        if (networkChange != null)
@@ -126,7 +126,7 @@ namespace System.Net.NetworkInformation {
                }
        }
 
-#if !MONOTOUCH_WATCH
+#if !MONOTOUCH_WATCH && !ORBIS
        internal sealed class MacNetworkChange : INetworkChange
        {
                const string DL_LIB = "/usr/lib/libSystem.dylib";
@@ -322,7 +322,7 @@ namespace System.Net.NetworkInformation {
        }
 #endif // !MONOTOUCH_WATCH
 
-#if !NETWORK_CHANGE_STANDALONE && !MONOTOUCH
+#if !NETWORK_CHANGE_STANDALONE && !MONOTOUCH && !ORBIS
 
        internal sealed class LinuxNetworkChange : INetworkChange {
                [Flags]
index 0967c80485dd8988f9c0936f0017bf3981fa2446..a97bcc8049c8a789e509a37c3f25efcf8e28a993 100644 (file)
@@ -82,6 +82,22 @@ namespace System.Net.NetworkInformation {
        {
                internal abstract class UnixNetworkInterfaceAPI : NetworkInterfaceFactory
                {
+#if ORBIS
+                       public static int if_nametoindex(string ifname)
+                       {
+                               throw new PlatformNotSupportedException ();
+                       }
+
+                       protected static int getifaddrs (out IntPtr ifap)
+                       {
+                               throw new PlatformNotSupportedException ();
+                       }
+
+                       protected static void freeifaddrs (IntPtr ifap)
+                       {
+                               throw new PlatformNotSupportedException ();
+                       }
+#else
                        [DllImport("libc")]
                        public static extern int if_nametoindex(string ifname);
 
@@ -90,6 +106,7 @@ namespace System.Net.NetworkInformation {
 
                        [DllImport ("libc")]
                        protected static extern void freeifaddrs (IntPtr ifap);
+#endif
                }
 
                class MacOsNetworkInterfaceAPI : UnixNetworkInterfaceAPI
index 90d0e3a59ca568e3ed6340b534f1c9a7237e1f2c..f1f5936be75cab98e14fe59bf44fafafe3cef09f 100644 (file)
@@ -89,7 +89,7 @@ namespace System.Net.NetworkInformation {
                
                public event PingCompletedEventHandler PingCompleted;
 
-#if !MONOTOUCH
+#if !MONOTOUCH && !ORBIS
                static Ping ()
                {
                        if (Environment.OSVersion.Platform == PlatformID.Unix) {
@@ -122,7 +122,7 @@ namespace System.Net.NetworkInformation {
                        identifier = (ushort)(randomIdentifier [0] + (randomIdentifier [1] << 8));
                }
 
-#if !MONOTOUCH
+#if !MONOTOUCH && !ORBIS
                [DllImport ("libc", EntryPoint="capget")]
                static extern int capget (ref cap_user_header_t header, ref cap_user_data_t data);
 
index 8afd40370cd599aeae22ae1b8ad0b908f5fdc81f..f4214393fc32627110284f0b72ecc62db5c41ae1 100644 (file)
@@ -38,6 +38,14 @@ namespace System {
                        isMacOS = true;
                        checkedOS = true;
                }
+
+#elif ORBIS
+               const bool isFreeBSD = true;
+
+               private static void CheckOS() {
+                       checkedOS = true;
+               }
+
 #else
                static bool isFreeBSD;
 
diff --git a/mcs/class/System/orbis_System.dll.exclude.sources b/mcs/class/System/orbis_System.dll.exclude.sources
new file mode 100644 (file)
index 0000000..88149d6
--- /dev/null
@@ -0,0 +1,2 @@
+System.Net/MacProxy.cs
+System.Security.Cryptography.X509Certificates/OSX509Certificates.cs
index b4ec154380d1bad74d5eb0f6a6c5e9e3e865fd66..80fef4d94d1ba5c65c20b16a99a0e26f2e8b79e5 100644 (file)
@@ -504,7 +504,7 @@ namespace System.Net {
 #if MONO
         public static IWebProxy CreateDefaultProxy ()
         {
-#if FEATURE_NO_BSD_SOCKETS
+#if FEATURE_NO_BSD_SOCKETS || ORBIS
             throw new PlatformNotSupportedException ();
 #elif MONOTOUCH
             return Mono.Net.CFNetwork.GetDefaultProxy ();
index 83145afb536bd489eaa70f3e958b0ccd4c43def9..749a43452d05b6066c6ed1fbc4d6ed3996bb4c35 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <mono/metadata/console-io.h>
 #include <mono/metadata/exception.h>
+#include <mono/metadata/w32file.h>
+#include <mono/utils/w32api.h>
 
 void
 mono_console_init (void)
index 62bc0f5fc52ad32eaa28fe5b38d88c038492544f..6929340ba6ced071ff3b44fe0c7c807749692cdd 100644 (file)
@@ -3008,11 +3008,18 @@ emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value)
                wbarrier->sreg1 = ptr->dreg;
                wbarrier->sreg2 = value->dreg;
                MONO_ADD_INS (cfg->cbb, wbarrier);
-       } else if (card_table && !cfg->compile_aot && !mono_gc_card_table_nursery_check ()) {
+       } else if (card_table) {
                int offset_reg = alloc_preg (cfg);
                int card_reg;
                MonoInst *ins;
 
+               /*
+                * We emit a fast light weight write barrier. This always marks cards as in the concurrent
+                * collector case, so, for the serial collector, it might slightly slow down nursery
+                * collections. We also expect that the host system and the target system have the same card
+                * table configuration, which is the case if they have the same pointer size.
+                */
+
                MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_UN_IMM, offset_reg, ptr->dreg, card_table_shift_bits);
                if (card_table_mask)
                        MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PAND_IMM, offset_reg, offset_reg, card_table_mask);
index e8df83337a63fc88e57f4a40aa34a0ea8c68f39b..74d985252816aee3e6093e11c1df03580852e6d3 100644 (file)
@@ -117,7 +117,7 @@ extern guint64 stat_objects_copied_major;
                g_error (__VA_ARGS__);  \
 } } while (0)
 
-#ifndef HOST_WIN32
+#ifdef HAVE_LOCALTIME_R
 # define LOG_TIMESTAMP  \
        do {    \
                time_t t;                                                                       \
index 6590cb54bdcae62b31fe2cb216c6f94ab3a24687..dd20f86b138618eba103b430fac6ca15d20286f5 100644 (file)
@@ -107,19 +107,20 @@ mono_log_write_logfile (const char *log_domain, GLogLevelFlags level, mono_bool
                pid_t pid;
                char logTime [80];
 
-#ifndef HOST_WIN32
+#ifdef HAVE_LOCALTIME_R
                struct tm tod;
                time(&t);
                localtime_r(&t, &tod);
-               pid = getpid();
                strftime(logTime, sizeof(logTime), "%Y-%m-%d %H:%M:%S", &tod);
 #else
                struct tm *tod;
                time(&t);
                tod = localtime(&t);
-               pid = mono_process_current_pid ();
                strftime(logTime, sizeof(logTime), "%F %T", tod);
 #endif
+
+               pid = mono_process_current_pid ();
+
                fprintf (logFile, "%s level[%c] mono[%d]: %s\n", logTime, mapLogFileLevel (level), pid, message);
        } else {
                fprintf (logFile, "%s%s%s\n",