Bananymous
b611c3fe48
LibC: Support in-place realloc for mmap backed allocations
...
When shrinking a mmap based allocation, we can just unmap the trailing
pages that will no longer be needed. When extending an allocation we try
to MMAP_FIXED_NOREPLACE the need extra data to avoid memcpy between old
and new allocation. I'm not sure if the extension logic is really worth
it but it is just 15 lines of code to avoid possibly very large memcpys.
2026-07-20 06:58:30 +03:00
Bananymous
8c6e402ee8
LibC: page align mmap backed malloc sizes
...
This will make reallocations cleaner
2026-07-20 06:58:30 +03:00
Bananymous
bd5be982e9
LibC: Don't memset 0 mmap'd callocs
...
There is no reason to page everything in and the kernel already
guarantees that the memory is zeroed in mmap
2026-07-20 06:58:30 +03:00
Bananymous
33f941f2fd
LibC: Unmap unused pages in aligned mallocs
2026-07-20 06:58:30 +03:00
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
583c2437b4
LibC: Don't munmap nullptr with 0 size in malloc
2026-07-20 04:07:23 +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
8be90c49bc
LibC: use auxv for getpagesize
2026-07-02 20:02:24 +03:00
Bananymous
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
Bananymous
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
Bananymous
80ffde5e1e
LibC: Implement aligned_malloc
...
This is part of POSIX issue 8
2025-07-31 22:47:40 +03:00
Bananymous
f26a445ce6
LibC: Make malloc actually allign to s_malloc_default_align boundary
2025-06-28 16:55:13 +03:00
Bananymous
87f348b48e
LibC: Fix my ugly and hacked posix_memalign
2025-06-18 14:17:17 +03:00
Bananymous
317f413746
LibC: Implement very hacky posix_memalign
...
I did not even test this and i know the code is super hacky. I could not
bother with writing proper code for this xD
2025-06-02 11:39:18 +03:00
Bananymous
543bb3cc4b
LibC: Rework malloc locking add proper realloc
2025-04-21 20:29:28 +03:00
Bananymous
cc2b4967ea
LibC: Make malloc thread safe with pthread_spinlock
2025-04-15 23:05:52 +03:00
Bananymous
3721dadd72
LibC: Make stdio and malloc initialization constructors
2025-04-15 22:01:57 +03:00
Bananymous
7542e55cb2
LibC: Add option to debug userspace malloc family calls
2024-11-10 14:03:25 +02:00
Bananymous
2c520391eb
Kernel/LibC: Add support for init_array and fini_array
2024-08-27 00:47:03 +03:00
Bananymous
c69919738b
BuildSystem: Move all userpace libraries under the userspace directory
...
As the number of libraries is increasing, root directory starts to
expand. This adds better organization for libraries
2024-06-18 13:14:35 +03:00