diff --git a/Source/OpenTK/Configuration.cs b/Source/OpenTK/Configuration.cs index 34d09950..605f957d 100644 --- a/Source/OpenTK/Configuration.cs +++ b/Source/OpenTK/Configuration.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.IO; +using System.Runtime.InteropServices; [assembly: CLSCompliant(true)] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenTK.Utilities")] @@ -92,13 +93,59 @@ namespace OpenTK #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); + + /// /// Executes "uname" which returns a string representing the name of the /// underlying Unix kernel. /// /// "Unix", "Linux", "Darwin" or null. /// Source code from "Mono: A Developer's Notebook" - private static string DetectUnixKernel() + private static string oldDetectUnixKernel() { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.Arguments = "-s";