Commit Graph
638 Commits
Author SHA1 Message Date
Bananymous 8368dec30b LibC: Fix posix_memalign return value
I was returning -1 with errno instead of the error code :P
2026-07-20 06:58:30 +03:00
Bananymous 7f25350c62 LibC: Fix malloc mmap byte tracking
I was incrementing instead of decrementing when freeing mmap allocs
2026-07-20 06:58:30 +03:00
Bananymous 64523b6c70 LibC: Fix futex return value handling 2026-07-20 06:58:30 +03:00
Bananymous bc622c8b51 LibC: Fix pthread default guard size and name 2026-07-20 06:58:30 +03:00
Bananymous 46e2d665e9 LibC: Make pthread_once block with a futex instead of yielding 2026-07-20 04:07:23 +03:00
Bananymous 390a7674b1 LibC: Fix uthread deallocation
Update dtv[0] to the max loadad module when loading dynamic modules

Free uthread if stack allocation or mprotect fails on pthread_create

Don't unmap the currently used stack when detached thread exits
2026-07-20 04:07:23 +03:00
Bananymous 583c2437b4 LibC: Don't munmap nullptr with 0 size in malloc 2026-07-20 04:07:23 +03:00
Bananymous efb25e5666 BAN/LibC: Move ldexp, scalbn to libc
They are now implemented with float decompostion to modify the exponent
bits directly
2026-07-20 04:07:23 +03:00
Bananymous f0e95ffe48 LibC: Make qsort_swap static
There is no need to export this
2026-07-20 04:07:23 +03:00
Bananymous 511ab7e99c LibC: Define locale_t as an poiter
A lot of ports seem to depend on this casting nullptr into locale_t
2026-07-20 04:07:23 +03:00
Bananymous 87006e277f LibC: Define winsize in both termios.h and sys/ioctl.h 2026-07-20 04:07:23 +03:00
Bananymous f6b91578ae LibC: Enable backtrace dumping by default
I'm not sure why I had turned this off
2026-07-20 04:07:23 +03:00
Bananymous e03a26cf01 LibC: Don't ASSERT in times
Return the current process CPU time as user time. We don't have a way to
get system/user time separation or CPU times of child processes
2026-07-20 04:07:23 +03:00
Bananymous 2a3eca5b36 LibC: Implement POSIX binary search trees
I used RB tree for this. The implementation is based on the code on
wikipedia about RB trees.
2026-07-20 04:07:23 +03:00
Bananymous 304f94f3b1 LibC: Implement __fpending
Some gnu programs want this and I don't want to make FILE non-opaque
2026-07-07 16:59:20 +03:00
Bananymous 20392c6cc1 LibC: Add malloc.h with some GNU extension
This adds `reallocarray`, `malloc_usable_size`, `mallinfo`, `mallinfo2`
2026-07-07 10:30:07 +03:00
Bananymous b62687f5e7 LibC: Cleanup backtrace code 2026-07-07 04:44:44 +03:00
Bananymous 896bb05073 LibC: Cleanup qsort implementation
Remove random template and just make qsort be a wrapper around qsort_r

Recurse only into the smaller partition. This removes the possibility of
O(n) recursion in the worst case

Use insertion sort for ranges shorter than 16 elements.

Split qsort_swap into qsort_swap_fixed and qsort_swap_general
- fixed one handles 1, 2, 4 and 8 byte elements which can be done directly
with mov instructions
- general copies 64 bytes at a time followed by a single copy for the
  rest. the 64 byte chunk loop gets nicely optimized into sse
2026-07-07 04:39:06 +03:00
Bananymous fc10de7ccb LibC: Implement pause 2026-07-07 04:36:55 +03:00
Bananymous eee0b7c3ff Kernel: Make ioctl take unsigned long instead of int
this is what linux does :D

also fix one or two `return ioctl` instead of `return ioctl_impl`
2026-07-07 03:12:39 +03:00
Bananymous 3e16e69602 LibC: Implement qsort_r
This is not really required by anything but i've seen few ports
optionally use it if available. This was trivial to implement so why not
add it :^)
2026-07-05 01:55:57 +03:00
Bananymous ac1fafedcc LibC: Cleanup and fix random functions
I was getting the size of random state incorrectly and ended up with
double the size user gave us leading to OOB access :D

Also remove hardcoded type -> size mappings and just use a looup table
2026-07-04 23:12:52 +03:00
Bananymous b480f783ec LibC: Fix regex anchor parsing 2026-07-04 19:17:07 +03:00
Bananymous 2957206718 LibC: Fix and cleanup stdio mode string parsing
The code is now much cleaner andd we are not as strict with the mode
string. Also add support for new 'e' and 'x' modifiers
2026-07-04 19:13:26 +03:00
Bananymous a41a3eeb66 LibGUI: Add query keymap request 2026-07-04 19:12:56 +03:00
Bananymous 6aa2329267 LibInput: Mark KeyboardLayout::key_event_from_raw const 2026-07-04 19:12:06 +03:00
Bananymous 5256fd2e0a LibInput: Add support for right super and application keys 2026-07-04 19:11:30 +03:00
Bananymous 652e170da9 LibGUI: Ignore failing smo maps in resize event
This can be caused by sending two back-to-back resize requests. When
handling the first, the server may have already replaced the smo key
with a new one.
2026-07-04 08:42:17 +03:00
Bananymous a2691bd70d LibGUI: Cleanup window initialization 2026-07-04 08:41:58 +03:00
Bananymous c9b3d50523 LibC: Fix printf zero padding on floats 2026-07-04 04:50:29 +03:00
Bananymous e717b95df0 LibC: Fix printf %g modifier
Apparently I had missed like half of the features it was supposed to do
2026-07-04 04:49:44 +03:00
Bananymous 0d8d731d91 LibC: Implement wsctoT functions 2026-07-04 04:13:21 +03:00
Bananymous 122c325a5b LibC: Move strtoT implementation to common header 2026-07-04 04:13:21 +03:00
Bananymous d5bc88584d LibC: Implement wcscasecmp and wcsncasecmp 2026-07-04 02:25:56 +03:00
Bananymous 63b2284324 Kernel/LibC: support RDTSCP based clock_gettime
RDTSCP seems to be faster than LSL and it removes the need for getting
the current cpu twice to make sure TSC is read on the correct CPU
2026-07-03 06:32:04 +03:00
Bananymous 917321eb5f LibC: Wait for thread before returning from pthread_create
We now make sure the thread starts up and sets its id. There was a race
condition where a process could create a thread and immediately try to
join it. If the thread had not initialized itself the join would fail
with EINVAL as we passed -1 as its id.
2026-07-03 02:14:10 +03:00
Bananymous 0a8b03d349 LibAudio: Make AudioLoaders return float instead of double
AudioBuffers already use floats internally so there is no need for
loaders to produces doubles
2026-07-02 22:54:45 +03:00
Bananymous 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
Bananymous ded722fb4c LibC: bump SYMLOOP_MAX to 128 2026-07-02 20:02:24 +03:00
Bananymous facc17c5a1 LibC: Implement {get,free}ifaddrs 2026-07-02 20:02:24 +03:00
Bananymous 26abd4e18e LibC: Add posix_fallocate stub 2026-07-02 20:02:24 +03:00
Bananymous 50fd526e6f LibC: Implement pthread_{get,set}name_np 2026-07-02 20:02:24 +03:00
Bananymous c0e091b647 LibC: Implement pthread_{get,set}attr_default_np 2026-07-02 20:02:24 +03:00
Bananymous 372da006d0 LibC: Implement pthread_getattr_np 2026-07-02 20:02:24 +03:00
Bananymous 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
Bananymous 7bdd9d19d0 LibC: Cleanup uthread initialization
This is now done in a constructor function in pthread.cpp
2026-07-02 20:02:24 +03:00
Bananymous 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
Bananymous 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
Bananymous 8be90c49bc LibC: use auxv for getpagesize 2026-07-02 20:02:24 +03:00
Bananymous c5cfa82ffb LibC: Check for malloc failure in setenv 2026-07-02 20:02:24 +03:00