Makefile
This commit is contained in:
@@ -651,15 +651,18 @@ static nn_Exit luaArch_handler(nn_ArchitectureRequest *req) {
|
||||
nn_Computer *computer = req->computer;
|
||||
luaArch *arch = req->localState;
|
||||
nn_Context *ctx = nn_getComputerContext(computer);
|
||||
// the memory scale, used to give Lua extra memory in 64-bit systems
|
||||
// due to it also using more memory.
|
||||
double memScale = sizeof(void *) > 4 ? 1.8 : 1;
|
||||
switch(req->action) {
|
||||
case NN_ARCH_FREEMEM:
|
||||
req->freeMemory = arch->freeMem / nn_getMemoryScale(computer);
|
||||
req->freeMemory = arch->freeMem / memScale;
|
||||
return NN_OK;
|
||||
case NN_ARCH_INIT:
|
||||
// wrapped in a block to prevent L from leaking, because L is common in Lua code so it may be used by mistake
|
||||
{
|
||||
arch = nn_alloc(ctx, sizeof(*arch));
|
||||
arch->freeMem = nn_getTotalMemory(computer) * nn_getMemoryScale(computer);
|
||||
arch->freeMem = nn_getTotalMemory(computer) * memScale;
|
||||
arch->computer = computer;
|
||||
#if LUA_VERSION_NUM >= 505L
|
||||
lua_State *L = lua_newstate(luaArch_alloc, arch, rand());
|
||||
|
||||
@@ -447,6 +447,7 @@ int main(int argc, char **argv) {
|
||||
nn_Component *testDrive = ncl_createDrive(u, NULL, &nn_defaultDrives[3], testDriveData, strlen(testDriveData), false);
|
||||
nn_Component *testFlash = ncl_createFlash(u, NULL, &nn_defaultSSDs[3], testDriveData, strlen(testDriveData), false);
|
||||
|
||||
ncl_setCLabel(eepromCard, "EEPROM");
|
||||
ncl_setCLabel(managedfs, "Main Filesystem");
|
||||
ncl_setCLabel(testingfs, "Secondary Filesystem");
|
||||
ncl_setCLabel(testDrive, "Unmanaged Storage");
|
||||
@@ -454,6 +455,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
size_t ramTotal = 0;
|
||||
ramTotal += 4 * nn_ramSizes[5];
|
||||
//ramTotal += nn_ramSizes[0];
|
||||
|
||||
SetExitKey(KEY_NULL);
|
||||
|
||||
@@ -495,9 +497,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
nn_setCallBudget(c, 0);
|
||||
|
||||
// default for 64-bit
|
||||
if(sizeof(void *) > 4) nn_setMemoryScale(c, 1.8);
|
||||
|
||||
nn_setArchitecture(c, &arch);
|
||||
nn_addSupportedArchitecture(c, &arch);
|
||||
|
||||
|
||||
@@ -1056,7 +1056,6 @@ typedef struct nn_Computer {
|
||||
size_t signalCount;
|
||||
size_t userCount;
|
||||
double idleTimestamp;
|
||||
double memoryScale;
|
||||
nn_Beep beep;
|
||||
nn_Value callstack[NN_MAX_STACK];
|
||||
char errorBuffer[NN_MAX_ERROR_SIZE];
|
||||
@@ -1180,7 +1179,6 @@ nn_Computer *nn_createComputer(nn_Universe *universe, void *userdata, const char
|
||||
c->signalCount = 0;
|
||||
c->userCount = 0;
|
||||
c->idleTimestamp = 0;
|
||||
c->memoryScale = 1;
|
||||
// set to empty string
|
||||
c->errorBuffer[0] = '\0';
|
||||
nn_clearComputerBeep(c);
|
||||
@@ -1447,14 +1445,6 @@ void nn_setEnergyHandler(nn_Computer *computer, void *energyState, nn_EnergyHand
|
||||
computer->energyHandler = handler;
|
||||
}
|
||||
|
||||
void nn_setMemoryScale(nn_Computer *computer, double scale) {
|
||||
computer->memoryScale = scale;
|
||||
}
|
||||
|
||||
double nn_getMemoryScale(nn_Computer *computer) {
|
||||
return computer->memoryScale;
|
||||
}
|
||||
|
||||
size_t nn_getTotalMemory(nn_Computer *computer) {
|
||||
return computer->totalMemory;
|
||||
}
|
||||
|
||||
@@ -451,18 +451,6 @@ const char *nn_getComputerAddress(nn_Computer *computer);
|
||||
nn_Universe *nn_getComputerUniverse(nn_Computer *computer);
|
||||
nn_Context *nn_getUniverseContext(nn_Universe *universe);
|
||||
nn_Context *nn_getComputerContext(nn_Computer *computer);
|
||||
// Sets the memory scale, which defaults to 1.
|
||||
// For context, OC will set the memory scale to 1.8 on 64-bit systems by default.
|
||||
// This scale affects how much real-world memory an amount of VM actually takes up.
|
||||
// This means if the total memory is 4 MiB, and the scale is set to 2, the computer can take up to 8MiB of actual RAM.
|
||||
// However, nn_getTotalMemory() will still return 4 MiB.
|
||||
// The architecture is meant to ensure that the reported free memory is also scaled. As in, the real-world free memory
|
||||
// is divided by this scale to ensure it is within the correct range.
|
||||
// It is undefined behavior to change the memory scale *after* the first call to nn_tick().
|
||||
// Some architectures may ignore this, if they are very low-level and thus
|
||||
// do not have any implicit changes of sizes between 32-bit and 64-bit.
|
||||
void nn_setMemoryScale(nn_Computer *computer, double scale);
|
||||
double nn_getMemoryScale(nn_Computer *computer);
|
||||
|
||||
// Returns the memory usage limit of the computer.
|
||||
size_t nn_getTotalMemory(nn_Computer *computer);
|
||||
|
||||
Reference in New Issue
Block a user