Commit graph

13 commits

Author SHA1 Message Date
Tom b17a889320 Kernel: Add safe atomic functions
This allows us to perform atomic operations on potentially unsafe
user space pointers.
2021-01-17 20:30:31 +01:00
Tom fb84f0ec9c AK: Add default memory order as template argument for Atomic<T>
This is useful for collecting statistics, e.g.
Atomic<unsigned, MemoryOrder::memory_order_relaxed> would allow
using operators such as ++ to use relaxed semantics throughout
without having to explicitly call fetch_add with the memory order.
2021-01-04 19:13:52 +01:00
Ben Wiederhake 8940bc3503 Meta+AK: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Brian Gianforcaro 3319803bd9 AK: Decorate atomic compare exchange operations with [[nodiscard]]
All CAS operations should always check return values, so they are
robust to failure in the event of conflict in parallel operation.
2020-08-05 17:28:44 +02:00
Tom 137e1dc7bd AK: Fixes for atomic pointers 2020-07-03 19:32:34 +02:00
Sergey Bugaev 5624f8d8ee AK: ALWAYS_INLINE most Atomic<T> methods 2020-06-12 16:08:45 +02:00
Tom 93b9832fac AK: Add atomic free functions
This allows for using atomic operations on any variables,
not only those wrapped in AK::Atomic<T>
2020-06-04 18:15:23 +02:00
Andreas Kling 67cc7d09a2 Revert "AK: Add AtomicRef, for atomically accesing a reference to a varaible"
This reverts commit aff594f1e7.
2020-05-20 16:24:26 +02:00
Andrew Kaster aff594f1e7 AK: Add AtomicRef, for atomically accesing a reference to a varaible
This is distintly different from Atomic<T*>, because we want to
atomically access a variable that the atomic object itself does not own.
2020-05-20 08:37:50 +02:00
Andreas Kling 94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling 61e6b1fb7c AK: Run clang-format on Atomic.h
Also use <AK/Types.h> instead of <stddef.h>
2020-01-12 18:45:13 +01:00
Andreas Kling 39e2b69153 AK: Atomic.h needs <stddef.h> for ptrdiff_t 2019-11-16 12:18:25 +01:00
Tom b0773a8ea6 AK: Add Atomic.h
Use gcc built-in atomics
2019-10-12 19:30:59 +02:00