Ejemplo n.º 1
0
        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref System.Runtime.InteropServices.OSPlatform instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.Object:
            {
                __mStack[ptr_of_this_method->Value] = instance_of_this_method;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.InteropServices.OSPlatform[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
            }
            break;
            }
        }
Ejemplo n.º 2
0
        static StackObject *IsOSPlatform_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Runtime.InteropServices.OSPlatform @osPlatform = (System.Runtime.InteropServices.OSPlatform) typeof(System.Runtime.InteropServices.OSPlatform).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 16);
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(@osPlatform);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
        public static bool IsOSPlatform(OSPlatform osPlatform)
        {
            switch (Environment.Platform)
            {
            case PlatformID.Win32NT:
                return(osPlatform == OSPlatform.Windows);

            case PlatformID.MacOSX:
                return(osPlatform == OSPlatform.OSX);

            case PlatformID.Unix:
                return(osPlatform == OSPlatform.Linux);

            default:
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static bool IsOSPlatform(OSPlatform osPlatform)
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                return(osPlatform == OSPlatform.Windows);

            case PlatformID.Unix:
                if (File.Exists("/usr/lib/libc.dylib"))
                {
                    return(osPlatform == OSPlatform.OSX);
                }

                return(osPlatform == OSPlatform.Linux);

            default:
                return(false);
            }
        }
Ejemplo n.º 5
0
        static OSPlatform _GetOSPlatform()
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
            case PlatformID.Win32Windows:
            case PlatformID.Win32S:
                return(OSPlatform.Windows);

            case PlatformID.MacOSX:
                return(OSPlatform.OSX);

            case PlatformID.Unix:
                // TODO: Support Mono on Linux/macOS/... scenario.
                return(OSPlatform.Create("UNIX"));

            default:
                return(OSPlatform.Create("UNKNOWN"));
            }
        }
Ejemplo n.º 6
0
        public static bool IsOSPlatform(OSPlatform osPlatform)
        {
            // TODO: very barebones implementation

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                return(osPlatform == OSPlatform.Windows);
            }

            if (Environment.OSVersion.Platform == PlatformID.Unix && File.Exists("/usr/lib/libc.dylib"))
            {
                return(osPlatform == OSPlatform.OSX);
            }

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                return(osPlatform == OSPlatform.Linux);
            }

            return(false);
        }
        public static bool IsOSPlatform(OSPlatform osPlatform)
        {
#if WASM
            return(osPlatform == OSPlatform.Create("WEBASSEMBLY"));
#else
            switch (Environment.Platform)
            {
            case PlatformID.Win32NT:
                return(osPlatform == OSPlatform.Windows);

            case PlatformID.MacOSX:
                return(osPlatform == OSPlatform.OSX);

            case PlatformID.Unix:
                return(osPlatform == OSPlatform.Linux);

            default:
                return(false);
            }
#endif
        }
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     return(OSPlatform.Windows == osPlatform);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Indicates whether the current application is running on the specified platform.
 /// </summary>
 public static bool IsOSPlatform(OSPlatform osPlatform) => OperatingSystem.IsOSPlatform(osPlatform.Name);
Ejemplo n.º 10
0
        public static bool IsOSPlatform(OSPlatform osPlatform)
        {
            string name = s_osPlatformName ??= Interop.Sys.GetUnixName();

            return(osPlatform.Equals(name));
        }
Ejemplo n.º 11
0
        static RuntimeInformation()
        {
            // we can use the runtime's compiled config options for DllMaps here
            // process architecure for us is runtime architecture
            // see for values: mono-config.c
            var runtimeArchitecture = GetRuntimeArchitecture();
            var osName = GetOSName();

            // check OS/process architecture
            switch (runtimeArchitecture)
            {
            case "arm":
                _osArchitecture      = Environment.Is64BitOperatingSystem ? Architecture.Arm64 : Architecture.Arm;
                _processArchitecture = Architecture.Arm;
                break;

            case "armv8":
                _osArchitecture      = Environment.Is64BitOperatingSystem ? Architecture.Arm64 : Architecture.Arm;
                _processArchitecture = Architecture.Arm64;
                break;

            case "x86":
                _osArchitecture      = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86;
                _processArchitecture = Architecture.X86;
                break;

            case "x86-64":
                _osArchitecture      = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86;
                _processArchitecture = Architecture.X64;
                break;

            // upstream only has these values; try to pretend we're x86 if nothing matches
            // want more? bug: https://github.com/dotnet/corefx/issues/30706
            default:
                _osArchitecture      = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86;
                _processArchitecture = Environment.Is64BitProcess ? Architecture.X64 : Architecture.X86;
                break;
            }

            // check OS platform
            switch (osName)
            {
            case "linux":
                _osPlatform = OSPlatform.Linux;
                break;

            case "osx":
                _osPlatform = OSPlatform.OSX;
                break;

            case "windows":
                _osPlatform = OSPlatform.Windows;
                break;

            case "solaris":
                _osPlatform = OSPlatform.Create("SOLARIS");
                break;

            case "freebsd":
                _osPlatform = OSPlatform.Create("FREEBSD");
                break;

            case "netbsd":
                _osPlatform = OSPlatform.Create("NETBSD");
                break;

            case "openbsd":
                _osPlatform = OSPlatform.Create("OPENBSD");
                break;

            case "aix":
                _osPlatform = OSPlatform.Create("AIX");
                break;

            case "hpux":
                _osPlatform = OSPlatform.Create("HPUX");
                break;

            case "haiku":
                _osPlatform = OSPlatform.Create("HAIKU");
                break;

            case "wasm":
                _osPlatform = OSPlatform.Create("WEBASSEMBLY");
                break;

            default:
                _osPlatform = OSPlatform.Create("UNKNOWN");
                break;
            }
        }
Ejemplo n.º 12
0
 public static bool IsOSPlatform(OSPlatform osPlatform)
 {
     return(_osPlatform == osPlatform);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Indicates whether the current application is running on the specified platform.
 /// </summary>
 public static bool IsOSPlatform(OSPlatform osPlatform) => osPlatform.IsCurrent;
Ejemplo n.º 14
0
 public bool IsOS(System.Runtime.InteropServices.OSPlatform osPlatform)
 {
     return(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(osPlatform));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Indicates whether the current app is running on the specified platform.
 /// </summary>
 /// <param name="osPlatform">A platform.</param>
 /// <returns><c>true</c> if the current app is running on the specified platform; otherwise, <c>false</c>.</returns>
 public static bool IsOSPlatform(OSPlatform osPlatform) => _OSPlatform.Value == osPlatform;