Commit Graph

601 Commits

Author SHA1 Message Date
4473ee4d49 LibAudio: Add an API to query free space in audio buffer
Also optimize and cleanup sample queueing
2026-07-02 22:54:45 +03:00
ded722fb4c LibC: bump SYMLOOP_MAX to 128 2026-07-02 20:02:24 +03:00
facc17c5a1 LibC: Implement {get,free}ifaddrs 2026-07-02 20:02:24 +03:00
26abd4e18e LibC: Add posix_fallocate stub 2026-07-02 20:02:24 +03:00
50fd526e6f LibC: Implement pthread_{get,set}name_np 2026-07-02 20:02:24 +03:00
c0e091b647 LibC: Implement pthread_{get,set}attr_default_np 2026-07-02 20:02:24 +03:00
372da006d0 LibC: Implement pthread_getattr_np 2026-07-02 20:02:24 +03:00
0dc74beb0f Kernel/LibC: Allocate thread stacks in userspace
This adds support for pthread function for stack manipulation.

Also keep track of main threads stack in the uthread
2026-07-02 20:02:24 +03:00
7bdd9d19d0 LibC: Cleanup uthread initialization
This is now done in a constructor function in pthread.cpp
2026-07-02 20:02:24 +03:00
b19b7f064a LibC: Make pthread_t pointer to uthread instead of a thread id
This will allow getting info about other threads in userspace!
2026-07-02 20:02:24 +03:00
f449ca8161 Kenrel: Separate pthread API from kernel API
It didn't really make sense for the syscalls to be named as the pthread
equivalents. Now the kernel just uses thread ids
2026-07-02 20:02:24 +03:00
8be90c49bc LibC: use auxv for getpagesize 2026-07-02 20:02:24 +03:00
c5cfa82ffb LibC: Check for malloc failure in setenv 2026-07-02 20:02:24 +03:00
c0d38862f2 LibC: Add sys/auxv.h with getauxval 2026-07-02 20:02:24 +03:00
74e94eedae LibC: Fix malloc bitmap allocator allocation
Use full pages for bitmap allocators and fix the capacity extension
condition
2026-07-02 15:22:52 +03:00
d241975ce1 Kernel: Remove SYS_SLEEP and cleanup SYS_NANOSLEEP
`sleep` is now implemented in terms of `nanosleep`. `nanosleep` is now
more precise and handles overflow when calculating wakeup time. I don't
think anything was depending on this, but I could see a program sleeping
for max time to block until signal.
2026-07-02 15:22:52 +03:00
6f002f0c07 LibC: Make pthread_{equal,self,testcancel} static inline
This allows using ::pthread_self or &pthread_self
2026-06-30 20:14:38 +03:00
9919cbf66e Kernel: Pass interpreter base address in auxiliary vector 2026-06-30 20:14:37 +03:00
59ec05c898 Kernel: Make TSC based timer monotonic
Prior to this I was just blindly rebasing the current TSC stats every
once in a while. Now I check for drift and scale the multiplier
accordingly to keep the timer from drifting
2026-06-27 03:24:15 +03:00
689494db63 LibGUI/WindowServer: Allow querying global cursor position 2026-06-23 23:31:17 +03:00
1287c8e335 LibGUI: Cleanup packet creation 2026-06-23 23:30:42 +03:00
4ad586552d LibGUI/WindowServer: Send window move events 2026-06-23 20:52:12 +03:00
43d03eb4a9 LibC: Add shm_open/shm_unlink
These can just open files in /tmp/shm. no need for anything fancier
2026-05-25 02:14:04 +03:00
2a6792b44a LibC: Make mlock, munlock and madvice no-ops
These don't have to do anything as I don't swap processes to disk
2026-05-25 02:14:04 +03:00
c72f2f9b31 LibC: Fix posix_spawn
signal was checking for NULL instead of SIG_ERR

there is no need to do post fork waiting in posix_spawn, we just have to
exit with 127 on error
2026-05-25 02:14:04 +03:00
62e2f4896a LibC: reorder LOCK_SH and LOCK_EX
Some software im porting has static asserts for these :)
2026-05-25 02:14:04 +03:00
9ccdebcd96 LibC: Implement/fix mk{,o}stemp{,s} 2026-05-25 02:14:04 +03:00
fe533c2e62 LibC: Fix freopen to preserve file state :) 2026-05-25 02:14:04 +03:00
ee5c225954 LibC: Add __fseterr
This is used by some ports to not require internal FILE structure
2026-05-25 02:14:04 +03:00
7ce68b0488 LibGUI: Allow timeout with Window::wait_events 2026-05-20 19:03:11 +03:00
f1a72cc9da Kernel: Implemented banos - a WIP C driver API
Banos is a stable WIP C driver API that is supposed to provide a simple
interface to interact with the kernel and load the modules dynamically.
It is WIP and atm this just implements module loading with a custom
banos_install syscall. Banos will not try to substitute parts of the
kernel instead it will just expose kernel functionality via a stable
BINARY API. Meaning binaries (should) remain forward and backward
compatible on a binary level.

Banos modules work similarly to those in linux, you expose symbols via
BANOS_EXPORT which allows you to export a name + addr paired symbol.
It puts it in the .banos-export section. Drivers provide metadata about
themselves in the REQUIRED .banos-driver section. Symbols are resolved
at runtime. The kernel exposes the driver functionality via the same
.banos-export export mechanism.

Banos modules are elf RELOCATABLE files (object files) which have
partial linking (only banos symbols should remain). Modules will
eventually define dependencies, will export symbols and will allow you
to build a complex object hierarchy.

This patch adds the banos_install syscall which takes in the driver
image to install and may only be executed by super users. The API
doesn't validate already loaded modules, as thats something the
userspace MAY choose to keep track of. Multi-instance functionality
shall be implemented via driver specific behaviuor (exposed in the dev
filesystem or some other means).

Modules are supposed to allow you to alter kernel behavior and extend
it, allowing you to create filesystems, drivers, networking
modifications, schedulers, probers, and more (hopefully) whilst
remaining binary compatible with any version of the kernel (again,
hopefully).
2026-05-20 17:52:19 +03:00
45e55d8907 LibC: Don't compare equal elements in qsort
This seemed to break supertuxkart which returned `less` in this case
2026-05-20 05:54:45 +03:00
1922d78661 Kernel: Add support for mkfifo{,at} mkdir at
Opening FIFOs still dont work as expected but at least you can create
them now :D
2026-05-18 23:53:09 +03:00
9c79971bdc LibC/Kernel: Add support for detached pthreads 2026-05-17 00:40:56 +03:00
ff75c15ba3 LibC: Move pthread keys to TCB
This removes all TLS relocations from libc which may become handy ;)
2026-05-17 00:29:20 +03:00
40dd29b876 LibC: Cleanup syscall macros 2026-05-17 00:29:20 +03:00
bf2121e166 LibC: Implement tc{get,set}winsize
These were added in POSIX issue 8 :^)
2026-05-15 17:08:02 +03:00
05c9f0640c Kernel/LibC: Replace terminal syscalls with ioctls
isatty, tc{get,set}attr, tc{get,set}pgrp are now implemented as ioctls
instead of separate syscalls
2026-05-15 17:03:33 +03:00
fe2c9f7d2d LibC: Rewrite malloc
The old linked list allocator with power of two pool sizes was kinda
weird. Now we use 1MiB bitmap allocators for allocations <64KiB and
directly call mmap for larger allocations. This allows userspace to
actually free unused memory on `free` :)
2026-05-15 17:03:33 +03:00
d7cdf3818c LibC: Make aio.h incudable in C++
aio stuff is not supported but now the header is at least includable in
C++ which was not possible before as __restrict was not allowed in array
size
2026-05-15 17:03:33 +03:00
6a2f041858 LibC: Handle negative size in fgets 2026-05-15 17:03:33 +03:00
f0c5fb3a87 LibC: Don't use ScopeGuard in exec
These ended up pulling `operator delete` which is not available when
linking with gcc :^)
2026-05-15 17:03:33 +03:00
d345f96387 LibC: Optimize qsort
Apply same optimizations as to BAN quick sort!
2026-05-13 04:37:25 +03:00
47650980f2 LibC: Reorder stack trace dump printing
If we fault while getting start of stack frame at least we now print
that we were trying to get the stack trace :^)
2026-05-05 13:54:51 +03:00
4b12770485 LibC: Don't leak FILEs on failed shebang exec 2026-05-05 13:52:52 +03:00
ba106f6bf5 LibC: Update argv[0] for shebang scripts to full path
This is needed so `dirname -- "$0"` works with shebang scripts found in
PATH
2026-05-05 12:48:04 +03:00
28499b890c LibC: Mark exit as noreturn 2026-05-04 20:26:02 +03:00
fde085e04b Kernel: Pass current cpu index as a GDT limit
I had no idea LSL was an instruction. This cleans up code to get the
current cpu by a lot and does not require extra segment usage :D
2026-05-04 20:26:02 +03:00
bef53c726b Userspace: Install libdl, libm, libpthread as symlinks to libc
Having dummy libraries was just unnecessary
2026-04-21 21:46:00 +03:00
eea0154f18 LibC: Cleanup RNG and properly initialize to srand(1) at startup 2026-04-21 00:26:41 +03:00