Skip to content

Commit

Permalink
Merge pull request mono#4628 from xmcclure/orbis-profile
Browse files Browse the repository at this point in the history
Platform support fixes
  • Loading branch information
xmcclure committed Mar 31, 2017
2 parents 17f0012 + bebbf51 commit 0568203
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 13 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions eglib/src/gfile-unix.c
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions mcs/build/profiles/orbis.make
Expand Up @@ -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 \
Expand All @@ -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,
7 changes: 6 additions & 1 deletion mcs/class/Makefile
Expand Up @@ -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)
Expand All @@ -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

Expand Down
@@ -0,0 +1 @@
#include common_System.Security.dll.sources
Expand Up @@ -42,7 +42,7 @@ static SystemCertificateValidator ()
{
#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);
Expand Down Expand Up @@ -156,6 +156,7 @@ static bool EvaluateSystem (X509CertificateCollection certs, X509CertificateColl
}
#else
if (is_macosx) {
#if !ORBIS
// Attempt to use OSX certificates
// Ideally we should return the SecTrustResult
OSX509Certificates.SecTrustResult trustResult = OSX509Certificates.SecTrustResult.Deny;
Expand All @@ -180,6 +181,9 @@ static bool EvaluateSystem (X509CertificateCollection certs, X509CertificateColl
status11 = (int)trustResult;
errors |= SslPolicyErrors.RemoteCertificateChainErrors;
}
#else
throw new PlatformNotSupportedException ();
#endif
} else {
result = BuildX509Chain (certs, chain, ref errors, ref status11);
}
Expand Down
28 changes: 28 additions & 0 deletions mcs/class/System/System.IO.Compression/DeflateStream.cs
Expand Up @@ -486,6 +486,7 @@ static void CheckResult (int result, string where)
const string LIBNAME = "MonoPosixHelper";
#endif

#if !ORBIS
[DllImport (LIBNAME, CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr CreateZStream (CompressionMode compress, bool gzip, UnmanagedReadOrWrite feeder, IntPtr data);

Expand All @@ -500,6 +501,33 @@ static void CheckResult (int result, string where)

[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

}
}

Expand Up @@ -42,8 +42,15 @@ abstract class CommonUnixIPGlobalProperties : IPGlobalProperties
[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; }
Expand Down
Expand Up @@ -101,7 +101,7 @@ public sealed class NetworkChange {

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)
Expand All @@ -126,7 +126,7 @@ static void MaybeDispose ()
}
}

#if !MONOTOUCH_WATCH
#if !MONOTOUCH_WATCH && !ORBIS
internal sealed class MacNetworkChange : INetworkChange
{
const string DL_LIB = "/usr/lib/libSystem.dylib";
Expand Down Expand Up @@ -322,7 +322,7 @@ static void HandleCallback (IntPtr reachability, NetworkReachabilityFlags flags,
}
#endif // !MONOTOUCH_WATCH

#if !NETWORK_CHANGE_STANDALONE && !MONOTOUCH
#if !NETWORK_CHANGE_STANDALONE && !MONOTOUCH && !ORBIS

internal sealed class LinuxNetworkChange : INetworkChange {
[Flags]
Expand Down
17 changes: 17 additions & 0 deletions mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs
Expand Up @@ -82,6 +82,22 @@ abstract class NetworkInterfaceFactory
{
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);

Expand All @@ -90,6 +106,7 @@ internal abstract class UnixNetworkInterfaceAPI : NetworkInterfaceFactory

[DllImport ("libc")]
protected static extern void freeifaddrs (IntPtr ifap);
#endif
}

class MacOsNetworkInterfaceAPI : UnixNetworkInterfaceAPI
Expand Down
4 changes: 2 additions & 2 deletions mcs/class/System/System.Net.NetworkInformation/Ping.cs
Expand Up @@ -89,7 +89,7 @@ struct cap_user_data_t

public event PingCompletedEventHandler PingCompleted;

#if !MONOTOUCH
#if !MONOTOUCH && !ORBIS
static Ping ()
{
if (Environment.OSVersion.Platform == PlatformID.Unix) {
Expand Down Expand Up @@ -122,7 +122,7 @@ public Ping ()
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);

Expand Down
8 changes: 8 additions & 0 deletions mcs/class/System/System/Platform.cs
Expand Up @@ -38,6 +38,14 @@ internal static class Platform {
isMacOS = true;
checkedOS = true;
}

#elif ORBIS
const bool isFreeBSD = true;

private static void CheckOS() {
checkedOS = true;
}

#else
static bool isFreeBSD;

Expand Down
2 changes: 2 additions & 0 deletions mcs/class/System/orbis_System.dll.exclude.sources
@@ -0,0 +1,2 @@
System.Net/MacProxy.cs
System.Security.Cryptography.X509Certificates/OSX509Certificates.cs
Expand Up @@ -504,7 +504,7 @@ protected virtual void GetObjectData(SerializationInfo serializationInfo, Stream
#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 ();
Expand Down
2 changes: 2 additions & 0 deletions mono/metadata/console-null.c
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion mono/mini/method-to-ir.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mono/sgen/sgen-gc.h
Expand Up @@ -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; \
Expand Down
7 changes: 4 additions & 3 deletions mono/utils/mono-log-common.c
Expand Up @@ -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",
Expand Down

0 comments on commit 0568203

Please sign in to comment.