feat: add proclist command, fix TLS bug, link libc for system programs

This commit is contained in:
2026-06-19 12:03:12 +02:00
parent ac25a4edd5
commit f2aaa39ca6
7 changed files with 31 additions and 3 deletions
+1 -1
View File
@@ -348,7 +348,7 @@ $(BINDIR)/config/%: $(CONFIGDIR)/%
$(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile
mkdir -p $(BINDIR)/os obj/$*
$(CXX) $(CXXFLAGS) -c src/$*/main.cpp -o obj/$*/main.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o -o $@
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o lib/libc/liblibc.a -o $@
clean:
rm -rf $(BINDIR) obj
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -151,7 +151,7 @@ void get_bearssl_time(uint32_t* days, uint32_t* seconds) {
montauk::gettime(&dt);
int y = dt.Year, m = dt.Month, d = dt.Day;
uint32_t total = 365u * (uint32_t)y
+ (uint32_t)(y/4) - (uint32_t)(y/100) + (uint32_t)(y/400);
+ (uint32_t)((y+3)/4) - (uint32_t)((y+99)/100) + (uint32_t)((y+399)/400);
const int md[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
for (int mo = 1; mo < m && mo <= 12; mo++) total += md[mo];
if (y%4==0 && (y%100!=0 || y%400==0) && m > 2) total++;
+28
View File
@@ -0,0 +1,28 @@
/*
* main.cpp
* Process list command for MontaukOS userspace
* Copyright (c) 2026 Daniel Hammer
*/
#include <montauk/syscall.h>
#include <libc/stdio.h>
extern "C" void _start() {
static montauk::abi::ProcInfo processes[256];
int n = montauk::proclist(processes, 256);
if (n <= 0) {
montauk::print("Failed to query processes.\n");
montauk::exit(-1);
}
montauk::print(" PID\tHeap\tImage Name\n");
for (int i = 0; i < n; i++) {
unsigned heapMb = (unsigned)(processes[i].heapUsed / (1024 * 1024));
printf(" %d\t%d MB\t%s\n", processes[i].pid, heapMb, processes[i].name);
}
montauk::exit(0);
}