Commit graph

14 commits

Author SHA1 Message Date
Peter Ross
feb19646df LibC: Increase alignment for malloc() BigAllocationBlocks to 16 bytes
commit 5f3773b715 increased alignment
for ChunckedBlocks, but not for BigAllocationBlocks.

This is required to make SSE instructions work.
2022-03-02 11:40:37 +01:00
Peter Ross
36af2fdc4f LibC: Replace [[gnu::aligned(16)]] with C++ standard alignas(16) 2022-03-02 11:40:37 +01:00
kleines Filmröllchen
2f50d8f4d3 AK+LibC+LibPthread: Introduce NoAllocationGuard
NoAllocationGuard is an RAII stack guard that prevents allocations
while it exists. This is done through a thread-local global flag which
causes malloc to crash on a VERIFY if it is false. The guard allows for
recursion.

The intended use case for this class is in real-time audio code. In such
code, allocations are really bad, and this is an easy way of dynamically
enforcing the no-allocations rule while giving the user good feedback if
it is violated. Before real-time audio code is executed, e.g. in LibDSP,
a NoAllocationGuard is instantiated. This is not done with this commit,
as currently some code in LibDSP may still incorrectly allocate in real-
time situations.

Other use cases for the Kernel have also been added, so this commit
builds on the previous to add the support both in Userland and in the
Kernel.
2022-01-11 00:08:58 +01:00
Ali Mohammad Pur
5a0cdb15b0 AK+Everywhere: Reduce the number of template parameters of IntrusiveList
This makes the user-facing type only take the node member pointer, and
lets the compiler figure out the other needed types from that.
2021-09-10 18:05:46 +03:00
Gunnar Beutner
5f3773b715 LibC: Increase minimum alignment for malloc() to 16 bytes
This is required to make SSE instructions work when building with
Clang. Apparently Clang uses SSE instructions where GCC didn't so
we didn't previously run into this problem.
2021-07-13 17:31:22 +02:00
Sahan Fernando
6fb08f20e3 LibC: Expose PAGE_ROUND_UP in mallocdefs.h 2021-06-12 22:50:40 +04:30
Brian Gianforcaro
e37f39d980 LibC: Switch ChunkedBlock to IntrusiveList from InlineLinkedList 2021-06-03 13:27:40 +02:00
Andreas Kling
7957f13e98 Revert "LibC: Simplify malloc size classes"
This reverts commit f91bcb8895.
2021-05-18 08:32:05 +02:00
Lenny Maiorani
f91bcb8895 LibC: Simplify malloc size classes
Problem:
- `size_classes` is a C-style array which makes it difficult to use in
  algorithms.
- `all_of` algorithm is re-written for the specific implementation.

Solution:
- Change `size_classes` to be an `Array`.
- Directly use the generic `all_of` algorithm instead of
  reimplementing.
2021-05-18 08:06:01 +02:00
Gunnar Beutner
3438829431 LibC: Lazily initialize malloc chunks
By default malloc manages memory internally in larger blocks. When
one of those blocks is added we initialize a free list by touching
each of the new block's pages, thereby committing all that memory
upfront.

This changes malloc to build the free list on demand which as a
bonus also distributes the latency hit for new blocks more evenly
because the page faults for the zero pages now don't happen all at
once.
2021-05-06 10:38:46 +02:00
Idan Horowitz
edfe81b1ee LibC: static_assert that all malloc size classes have an alignment of 8
This will help prevent issues like the one fixed by #6703 from
happening again.
2021-04-28 19:57:06 +02:00
Gunnar Beutner
ae5ee2220c LibC: Make sure malloc() returns addresses that have an alignment of 8 2021-04-28 14:26:56 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Renamed from Libraries/LibC/mallocdefs.h (Browse further)