mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 06:05:29 +00:00
Introduced new platform detection code to p/invoke to uname rather than running it as a process.
This commit is contained in:
parent
23f4858e2c
commit
06bac23cf8
|
@ -11,6 +11,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenTK.Utilities")]
|
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenTK.Utilities")]
|
||||||
|
@ -92,13 +93,59 @@ namespace OpenTK
|
||||||
|
|
||||||
#region private static string DetectUnixKernel()
|
#region private static string DetectUnixKernel()
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
|
struct utsname
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string sysname;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string nodename;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string release;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string version;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string machine;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
|
||||||
|
public string extraJustInCase;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string DetectUnixKernel()
|
||||||
|
{
|
||||||
|
Debug.Print("Size: {0}", Marshal.SizeOf(typeof(utsname)).ToString());
|
||||||
|
Debug.Flush();
|
||||||
|
utsname uts = new utsname();
|
||||||
|
uname(out uts);
|
||||||
|
|
||||||
|
Debug.WriteLine("System:");
|
||||||
|
Debug.Indent();
|
||||||
|
Debug.WriteLine(uts.sysname);
|
||||||
|
Debug.WriteLine(uts.nodename);
|
||||||
|
Debug.WriteLine(uts.release);
|
||||||
|
Debug.WriteLine(uts.version);
|
||||||
|
Debug.WriteLine(uts.machine);
|
||||||
|
Debug.Unindent();
|
||||||
|
|
||||||
|
return uts.sysname.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("libc")]
|
||||||
|
private static extern void uname(out utsname uname_struct);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes "uname" which returns a string representing the name of the
|
/// Executes "uname" which returns a string representing the name of the
|
||||||
/// underlying Unix kernel.
|
/// underlying Unix kernel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>"Unix", "Linux", "Darwin" or null.</returns>
|
/// <returns>"Unix", "Linux", "Darwin" or null.</returns>
|
||||||
/// <remarks>Source code from "Mono: A Developer's Notebook"</remarks>
|
/// <remarks>Source code from "Mono: A Developer's Notebook"</remarks>
|
||||||
private static string DetectUnixKernel()
|
private static string oldDetectUnixKernel()
|
||||||
{
|
{
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||||
startInfo.Arguments = "-s";
|
startInfo.Arguments = "-s";
|
||||||
|
|
Loading…
Reference in a new issue