feat: add SYS_FUTEX_WAIT and SYS_FUTEX_WAKE syscalls; revamp desktop application categories

This commit is contained in:
daniel committed 2026-10-13 07:11:39 +02:00
1 parent 60ca9c78c7
commit abfd9de8f6
35 files changed
+545 -70

No files matched your search

+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 296
#define MONTAUK_BUILD_NUMBER 302
+8
View File
@@ -302,6 +302,14 @@ namespace montauk::abi {
return Sched::GetCurrentTid();
}
static int Sys_FutexWait(uint64_t addr, uint32_t expected, uint64_t timeoutNs) {
return Sched::FutexWait(addr, expected, timeoutNs);
}
static int Sys_FutexWake(uint64_t addr, uint32_t count) {
return Sched::FutexWake(addr, count);
}
static int Sys_Chdir(const char* path) {
auto* proc = Sched::GetCurrentProcessPtr();
if (proc == nullptr || path == nullptr) return InvalidArgument;
+7
View File
@@ -545,6 +545,13 @@ namespace montauk::abi {
return Sys_ThreadJoin((int)frame->arg1, (int*)frame->arg2);
case SYS_THREAD_SELF:
return Sys_ThreadSelf();
case SYS_FUTEX_WAIT:
// Validation demand-commits the page so the scheduler can
// read the word with its lock held without faulting.
if (!UserMemory::Readable<uint32_t>(frame->arg1)) return BadPointer;
return Sys_FutexWait(frame->arg1, (uint32_t)frame->arg2, frame->arg3);
case SYS_FUTEX_WAKE:
return Sys_FutexWake(frame->arg1, (uint32_t)frame->arg2);
case SYS_BTSCAN:
if (!Sched::HasCapability(CAP_DEVICE_ADMIN)) return CapabilityDenied;
if ((int64_t)frame->arg2 < 0) return InvalidArgument;
+11
View File
@@ -364,6 +364,17 @@ namespace montauk::abi {
static constexpr uint64_t SYS_GETKEY_EX = 194; // (KeyEvent*, size) -> 0; blocks like SYS_GETKEY
static constexpr uint64_t SYS_CHILDIO_WRITEKEY_EX = 195; // (childPid, const KeyEvent*, size) -> status
/* Futexes: process-private wait queues keyed by a user address. WAIT
blocks only if *addr still equals `expected` (checked atomically with
enrollment). timeoutNs: FUTEX_WAIT_FOREVER = no deadline, 0 = check
only; rounded up to the 1 ms scheduler tick. WAIT returns 0 when woken,
WouldBlock on value mismatch, TimedOut on deadline. WAKE returns the
number of threads woken (count = FUTEX_WAKE_ALL wakes every waiter). */
static constexpr uint64_t SYS_FUTEX_WAIT = 196; // (uint32_t* addr, expected, timeoutNs) -> status
static constexpr uint64_t SYS_FUTEX_WAKE = 197; // (uint32_t* addr, count) -> woken, or status
static constexpr uint64_t FUTEX_WAIT_FOREVER = ~0ULL;
static constexpr uint32_t FUTEX_WAKE_ALL = 0xFFFFFFFFu;
/* Kernel-owned process capabilities. User identities may namespace
per-user resources, but never participate in authorization decisions. */
static constexpr uint64_t CAP_PROCESS_ADMIN = 1ULL << 0;