From b817c337dc2c5d8efda710f445114aa9a9344611 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 18 Feb 2012 00:33:52 +0000
Subject: On Windows automatically load the correct native ODE library
depending on whether the process is 32-bit or 64-bit
In theory, this means that a 64-bit Windows OS user can now run OpenSim.exe with ODE and use more than 2 (or 3) GB of memory.
However, this is completely untested since I don't currently own a 64-bit Windows box. Feedback appreciated.
Using OpenSim.32BitLaunch.exe should continue to work. Other platforms are unaffected.
This will currently not work with sqlite - I will add that too if this works.
---
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 4 ++-
OpenSim/Framework/Util.cs | 38 +++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 545e76c..0dd01af 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -308,7 +308,9 @@ namespace OpenSim.Framework.Servers
// clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
// the clr version number doesn't match the project version number under Mono.
//m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine);
- m_log.Info("[STARTUP]: Operating system version: " + Environment.OSVersion + Environment.NewLine);
+ m_log.InfoFormat(
+ "[STARTUP]: Operating system version: {0}, .NET platform {1}, {2}-bit\n",
+ Environment.OSVersion, Environment.OSVersion.Platform, Util.Is64BitProcess() ? "64" : "32");
StartupSpecific();
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 4b0b13c..b3ec5c2 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -35,7 +35,8 @@ using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.Sockets;
-using System.Reflection;
+using System.Reflection;
+using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Cryptography;
@@ -375,6 +376,20 @@ namespace OpenSim.Framework
}
return sb.ToString();
+ }
+
+ ///
+ /// Is the platform Windows?
+ ///
+ /// true if so, false otherwise
+ public static bool IsWindows()
+ {
+ PlatformID platformId = Environment.OSVersion.Platform;
+
+ return (platformId == PlatformID.Win32NT
+ || platformId == PlatformID.Win32S
+ || platformId == PlatformID.Win32Windows
+ || platformId == PlatformID.WinCE);
}
public static bool IsEnvironmentSupported(ref string reason)
@@ -1457,6 +1472,27 @@ namespace OpenSim.Framework
}
return data;
+ }
+
+ ///
+ /// Used to trigger an early library load on Windows systems.
+ ///
+ ///
+ /// Required to get 32-bit and 64-bit processes to automatically use the
+ /// appropriate native library.
+ ///
+ ///
+ ///
+ [DllImport("kernel32.dll")]
+ public static extern IntPtr LoadLibrary(string dllToLoad);
+
+ ///
+ /// Determine whether the current process is 64 bit
+ ///
+ /// true if so, false if not
+ public static bool Is64BitProcess()
+ {
+ return IntPtr.Size == 8;
}
#region FireAndForget Threading Pattern
--
cgit v1.1