More robuust ness.

This commit is contained in:
2025-11-24 01:30:16 +01:00
parent a1eb00caff
commit 0db921cfa3
5 changed files with 9 additions and 20 deletions
+2
View File
@@ -489,6 +489,8 @@ long relational() {
if (op == Ne) val = val != val2;
if (op == Lt) val = val < val2;
if (op == Gt) val = val > val2;
if (op == Le) val = val <= val2;
if (op == Ge) val = val >= val2;
}
return val;
}
+1 -5
View File
@@ -361,7 +361,7 @@ void init_coroutines() {
int alloc_coroutine() {
init_coroutines();
pthread_mutex_lock(&coroutine_mutex);
for (int i = 0; i < MAX_COROUTINES; i++) {
for (int i = 1; i < MAX_COROUTINES; i++) {
if (!coroutines[i].active) {
coroutines[i].active = 1;
coroutines[i].complete = 0;
@@ -584,10 +584,6 @@ long native_gather(long *args, int argc) {
free(thread);
coro->thread = NULL;
}
pthread_mutex_lock(&coroutine_mutex);
coro->active = 0;
pthread_mutex_unlock(&coroutine_mutex);
}
return 1;
+3 -13
View File
@@ -36,26 +36,16 @@ long native_fread(long *args, int argc) {
return -1;
}
FILE *f = (FILE*)args[0];
int addr = (int)args[1];
char *buffer = (char*)args[1];
int size = (int)args[2];
if (!f || addr < 0 || addr >= MEM_SIZE || size <= 0) {
if (!f || !buffer || size <= 0) {
return -1;
}
if (addr + size > MEM_SIZE) {
size = MEM_SIZE - addr;
}
char temp_buf[8192];
if (size > 8192) size = 8192;
int result = fread(temp_buf, 1, size, f);
if (result > 0) {
for (int i = 0; i < result && addr + i < MEM_SIZE; i++) {
memory[addr + i] = temp_buf[i];
}
}
int result = fread(buffer, 1, size, f);
return result;
}