completely redesign how user mode memory is allocated, fix a few smp and scheduler bugs, terminating a process now terminates the process, telemetry, optimize text editor, new font, new color scheme

This commit is contained in:
maksw committed 2026-06-09 18:02:28 +02:00
1 parent 27b31f62b6
commit 325149006c
45 files changed
+2091 -760

No files matched your search

+4 -3
View File
@@ -1,6 +1,7 @@
// posix_dir.c - chdir, getcwd, opendir, readdir, closedir
#include <string.h>
#include <ntlite/syscall.h>
#include <stdlib.h>
#include "posix.h"
#include "posix_path.h"
@@ -38,8 +39,8 @@ __declspec(dllexport) DIR* opendir(const char* path) {
uint32_t s = SysOpenDir(&req);
if (s != 0) { errno = ENOENT; return (DIR*)0; }
// Allocate DIR on the kernel heap (SysAlloc) so it outlives the stack.
DIR* d = (DIR*)SysAlloc(sizeof(DIR));
// Allocate DIR on the kernel heap (malloc) so it outlives the stack.
DIR* d = (DIR*)malloc(sizeof(DIR));
if (!d) { SysCloseHandle(kh); errno = ENOMEM; return (DIR*)0; }
d->KHandle = kh;
d->Valid = false;
@@ -64,6 +65,6 @@ __declspec(dllexport) struct dirent* readdir(DIR* d) {
__declspec(dllexport) int closedir(DIR* d) {
if (!d) { errno = EBADF; return -1; }
SysCloseHandle(d->KHandle);
SysFree(d);
free(d);
return 0;
}
+1 -1
View File
@@ -7,7 +7,7 @@
#include "posix_path.h"
__declspec(dllexport) void clearscreen(void) {
SysScreenClear(0x00000000);
SysScreenClear(0x012456);
}
__declspec(dllexport) void clearkeyboard(void) {
+6 -5
View File
@@ -1,5 +1,6 @@
// posix_socket.c - POSIX-ish socket wrappers over native Sys* sockets.
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ntlite/syscall.h>
@@ -324,7 +325,7 @@ __declspec(dllexport) int getsockopt(int fd, int level, int optname, void* optva
__declspec(dllexport) int poll(struct pollfd* fds, nfds_t nfds, int timeout) {
if (!fds || nfds == 0 || nfds > 64) { errno = EINVAL; return -1; }
SYS_POLLFD* kfds = (SYS_POLLFD*)SysAlloc(sizeof(SYS_POLLFD) * nfds);
SYS_POLLFD* kfds = (SYS_POLLFD*)malloc(sizeof(SYS_POLLFD) * nfds);
if (!kfds) { errno = ENOMEM; return -1; }
for (nfds_t i = 0; i < nfds; i++) {
@@ -348,7 +349,7 @@ __declspec(dllexport) int poll(struct pollfd* fds, nfds_t nfds, int timeout) {
uint32_t timeoutMs = timeout < 0 ? SYS_POLL_TIMEOUT_INFINITE : (uint32_t)timeout;
uint32_t s = SysPoll(kfds, nfds, timeoutMs, &ready);
if (s != 0) {
SysFree(kfds);
free(kfds);
errno = PosixStatusToErrno(s);
return -1;
}
@@ -365,7 +366,7 @@ __declspec(dllexport) int poll(struct pollfd* fds, nfds_t nfds, int timeout) {
if (re) out++;
}
SysFree(kfds);
free(kfds);
return out;
}
@@ -446,7 +447,7 @@ __declspec(dllexport) int getaddrinfo(const char* node, const char* service,
a.Port = service ? ParsePort(service) : 0;
size_t total = sizeof(struct addrinfo) + sizeof(struct sockaddr_in);
struct addrinfo* ai = (struct addrinfo*)SysAlloc(total);
struct addrinfo* ai = (struct addrinfo*)malloc(total);
if (!ai) return ENOMEM;
memset(ai, 0, total);
@@ -467,5 +468,5 @@ __declspec(dllexport) int getaddrinfo(const char* node, const char* service,
}
__declspec(dllexport) void freeaddrinfo(struct addrinfo* res) {
if (res) SysFree(res);
if (res) free(res);
}
+4 -3
View File
@@ -1,5 +1,6 @@
// posix_thread.c - pthread_create, pthread_join, pthread_exit, pthread_mutex_*
#include <stddef.h>
#include <stdlib.h>
#include <ntlite/syscall.h>
#include "posix.h"
@@ -56,7 +57,7 @@ static void PthreadTrampoline(uintptr_t raw) {
PTHREAD_SLOT* slot = PthreadSlotFind(pid, tid);
if (!slot) slot = PthreadSlotAlloc(pid, tid);
SysFree(tr);
free(tr);
void* retval = fn(arg);
@@ -76,7 +77,7 @@ __declspec(dllexport) int pthread_create(pthread_t* t, const pthread_attr_t* att
uint32_t pid = SysGetCurrentPid();
PTHREAD_TRAMP* tr = (PTHREAD_TRAMP*)SysAlloc(sizeof(PTHREAD_TRAMP));
PTHREAD_TRAMP* tr = (PTHREAD_TRAMP*)malloc(sizeof(PTHREAD_TRAMP));
if (!tr) return ENOMEM;
tr->Fn = fn;
tr->Arg = arg;
@@ -86,7 +87,7 @@ __declspec(dllexport) int pthread_create(pthread_t* t, const pthread_attr_t* att
uint32_t s = SysCreateThread((uint64_t)PthreadTrampoline,
(uint64_t)tr, 1 /*PriorityNormal*/, &tid);
if (s != 0) {
SysFree(tr);
free(tr);
return EAGAIN;
}
// The trampoline allocates the retval slot itself after it knows its real