mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Remove is64Bit check, replace with more robust pointer width check
This commit is contained in:
parent
e7df708b32
commit
2b40e8a5d0
@ -162,8 +162,8 @@ dependencies {
|
||||
compile 'com.google.code.findbugs:jsr305:1.3.9' // Annotations used by google libs.
|
||||
|
||||
embedded name: 'OC-LuaJ', version: '20220907.1', ext: 'jar'
|
||||
embedded name: 'OC-JNLua', version: '20220904.0', ext: 'jar'
|
||||
embedded name: 'OC-JNLua-Natives', version: '20220904.0', ext: 'jar'
|
||||
embedded name: 'OC-JNLua', version: '20220928.0', ext: 'jar'
|
||||
embedded name: 'OC-JNLua-Natives', version: '20220928.0', ext: 'jar'
|
||||
|
||||
testCompile "org.mockito:mockito-all:1.10.19"
|
||||
testCompile "org.scalactic:scalactic_2.11:2.2.6"
|
||||
|
@ -173,20 +173,6 @@ abstract class LuaStateFactory {
|
||||
|
||||
def isAvailable = haveNativeLibrary
|
||||
|
||||
val is64Bit = {
|
||||
val dataModel = try System.getProperty("sun.arch.data.model") catch {
|
||||
case ex: SecurityException => null
|
||||
}
|
||||
|
||||
if (dataModel != null)
|
||||
"64".equals(dataModel)
|
||||
else {
|
||||
// Best effort, will probably miss some esoteric architectures
|
||||
// Examples this works for: x86_64, ppc64le, aarch64_be
|
||||
SystemUtils.OS_ARCH.matches(".*64_?([bl]e)?")
|
||||
}
|
||||
}
|
||||
|
||||
// Since we use native libraries we have to do some work. This includes
|
||||
// figuring out what we're running on, so that we can load the proper shared
|
||||
// libraries compiled for that system. It also means we have to unpack the
|
||||
|
@ -42,7 +42,7 @@ abstract class NativeLuaArchitecture(val machine: api.machine.Machine) extends A
|
||||
|
||||
private[machine] var kernelMemory = 0
|
||||
|
||||
private[machine] val ramScale = if (factory.is64Bit) Settings.get.ramScaleFor64Bit else 1.0
|
||||
private[machine] var ramScale: Double = 1.0
|
||||
|
||||
private val persistence = new PersistenceAPI(this)
|
||||
|
||||
@ -150,16 +150,16 @@ abstract class NativeLuaArchitecture(val machine: api.machine.Machine) extends A
|
||||
override def isInitialized = kernelMemory > 0
|
||||
|
||||
override def recomputeMemory(components: java.lang.Iterable[ItemStack]) = {
|
||||
val memory = math.ceil(memoryInBytes(components) * ramScale).toInt
|
||||
val memoryBytes = memoryInBytes(components)
|
||||
Option(lua) match {
|
||||
case Some(l) if Settings.get.limitMemory =>
|
||||
l.setTotalMemory(Int.MaxValue)
|
||||
if (kernelMemory > 0) {
|
||||
l.setTotalMemory(kernelMemory + memory)
|
||||
l.setTotalMemory(kernelMemory + math.ceil(memoryBytes * ramScale).toInt)
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
memory > 0
|
||||
memoryBytes > 0
|
||||
}
|
||||
|
||||
private def memoryInBytes(components: java.lang.Iterable[ItemStack]) = components.foldLeft(0.0)((acc, stack) => acc + (Option(api.Driver.driverFor(stack)) match {
|
||||
@ -314,6 +314,7 @@ abstract class NativeLuaArchitecture(val machine: api.machine.Machine) extends A
|
||||
return false
|
||||
case Some(value) => lua = value
|
||||
}
|
||||
ramScale = if (lua.getPointerWidth >= 8) Settings.get.ramScaleFor64Bit else 1.0
|
||||
|
||||
apis.foreach(_.initialize())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user