Combined cherrypick of changes between mono-4.8.0-branch and orbis-branch-30
authorAndi McClure <andi.mcclure@xamarin.com>
Mon, 20 Mar 2017 21:25:18 +0000 (17:25 -0400)
committerAndi McClure <andi.mcclure@xamarin.com>
Thu, 30 Mar 2017 21:57:00 +0000 (17:57 -0400)
ORBIS #ifdefs in BCL, exclude several files and assembly directories
from the orbis build, HAVE_LOCALTIME_R define in C.

14 files changed:
configure.ac
mcs/build/profiles/orbis.make
mcs/class/Makefile
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/sgen/sgen-gc.h
mono/utils/mono-log-common.c

index bb1aecfa5ee583c8f59ec299599ca8582c06c7cb..4cebcc176fed53fd7382d5fb7be710faa1f90ed6 100644 (file)
@@ -2407,6 +2407,7 @@ 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_SIZEOF(size_t)
        AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , 
                [#include <sys/types.h>
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 3f981f77aba50c4f2f1a4a430cff729bf516cc23..964c683620eb6b1c770e7d6fbc0501f39baf559d 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
 
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..8d74999fb48089debb2872e70ba3cb7394680052 100644 (file)
@@ -82,6 +82,7 @@ namespace System.Net.NetworkInformation {
        {
                internal abstract class UnixNetworkInterfaceAPI : NetworkInterfaceFactory
                {
+#if !ORBIS
                        [DllImport("libc")]
                        public static extern int if_nametoindex(string ifname);
 
@@ -90,6 +91,22 @@ namespace System.Net.NetworkInformation {
 
                        [DllImport ("libc")]
                        protected static extern void freeifaddrs (IntPtr ifap);
+#else
+                       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 ();
+                       }
+#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 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",