summaryrefslogtreecommitdiff
path: root/AK/Platform.h
AgeCommit message (Collapse)Author
2021-07-18Kernel: Introduce basic pre-kernel environmentGunnar Beutner
This implements a simple bootloader that is capable of loading ELF64 kernel images. It does this by using QEMU/GRUB to load the kernel image from disk and pass it to our bootloader as a Multiboot module. The bootloader then parses the ELF image and sets it up appropriately. The kernel's entry point is a C++ function with architecture-native code. Co-authored-by: Liav A <liavalb@gmail.com>
2021-07-16Kernel+AK: Generate compile-time error for non-sized `delete`Daniel Bertalan
This is a much more ergonomic option than getting a `VERIFY_NOT_REACHED()` failure at run-time. I encountered this issue with Clang, where sized deallocation is not the default due to ABI breakage concerns. Note that we can't simply just not declare these functions, because the C++ standard states: > If this function with size parameter is defined, the program shall > also define the version without the size parameter.
2021-07-10AK: Remove unused NO_RETURN macroGunnar Beutner
2021-07-05Kernel: Replace raw asm functions with naked onesHendiadyoin1
2021-07-05Kernel: Merge the x86 and x86_64 boot code into a single fileGunnar Beutner
They're mostly the same apart from some x86_64-specific parts.
2021-07-04AK: Use conditionally trivial special member functionsDaniel Bertalan
This commit makes use of the conditionally trivial special member functions introduced in C++20. Basically, `Optional` and `Variant` inherits whether its wrapped type is trivially copy constructible, trivially copy assignable or trivially destructible. This lets the compiler optimize optimize a large number of their use cases. The constraints have been applied to `Optional`'s converting constructors too in order to make the API more explicit. This feature is not supported by Clang yet, so we use conditional compilation so that Lagom can be built on macOS. Once Clang has P0848R3 support, these can be removed.
2021-06-29AK: Add RETURNS_NONNULL attribute and use itDaniel Bertalan
This attribute tells compilers that the pointer returned by a function is never null, which lets it optimize away null checks in some places. This seems like a nice addition to `NonnullOwnPtr` and `NonnullRefPtr`. Using this attribute causes extra UBSan checks to be emitted. To offset its performance loss, some additional methods were marked ALWAYS_INLINE, which lets the compiler optimize duplicate checks
2021-06-24AK: Use `__attribute__((name))` for functions everywhereDaniel Bertalan
Clang enforces the ordering that attributes specified with the `[[attr_name]]` syntax must comes before those defines as `__attribute__((attr_name))`. We don't want to deal with that, so we should stick to a single syntax (for functions, at least). This commit favors the latter, as it's used more widely in the code (for declaring more "exotic" options), and changing those would be a larger effort than modifying this single file.
2021-05-28AK: Add platform macros to detect presence of AddressSanitizerAndrew Kaster
The ASAN_[UN]POISON_MEMORY_REGION macros can be used to manually notify the AddressSanitizer runtime about the reachability of instrumented code accessing a memory region. This is most useful for manually managed heaps and arenas that do not go directly to malloc or alligned_alloc.
2021-05-14AK: Fix redefinition of macro inside AK/Platform.hJean-Baptiste Boric
2021-05-14AK: Add #define for [[gnu::no_sanitize_address]]Andrew Kaster
This lines up with other attribute global #defines
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-03-03AK+Kernel: Remove NO_DISCARD macro hackLinus Groh
This was added as clang-format would mess up the formatting when using [[nodiscard]] on a class, which is no longer the case.
2021-01-30LibGfx: Fix dynamic bitmasks in BMPsBen Wiederhake
I overlooked a corner case where we might call the built-in ctz() on zero. Furthermore, the calculation of the shift was wrong and the results were often unusable. Both issue were caused by a forgotten 36daeee34ff04f64c933e94a9cdffe9080061fb0. This time I made sure to look at bmpsuite_files first, and now they look good. Found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28985
2021-01-12LibC+Everywhere: Remove open_with_path_length() in favor of open()Andreas Kling
This API was a mostly gratuitous deviation from POSIX that gave up some portability in exchange for avoiding the occasional strlen(). I don't think that was actually achieving anything valuable, so let's just chill out and have the same open() API as everyone else. :^)
2020-12-28AK: Add CLOCK_*_COARSE aliases for darwin and BSD variantsAndrew Kaster
The coarse clocks in time.h are a linux extension that we've adopted. MacOS and the BSDs don't have it, so we need an alias in a platform header for Lagom builds.
2020-12-27AK: Add NO_DISCARD macro to allow clang-format friendly class annotationsBrian Gianforcaro
clang-format seems to barf on these attributes, to make it easier to use these attributes and have clang-format not mangle the following code we can hide them behind a macro so clang-format doesn't have to handle it.
2020-08-25AK: Add Endian.h header to replace NetworkOrdered.h.asynts
2020-05-16AK: Remove experimental clang -Wconsumed stuffAndreas Kling
This stopped working quite some time ago due to Clang losing track of typestates for some reason and everything becoming "unknown". Since we're primarily using GCC anyway, it doesn't seem worth it to try and maintain this non-working experiment for a secondary compiler. Also it doesn't look like the Clang team is actively maintaining this flag anyway. So good-bye, -Wconsumed. :/
2020-04-30AK: Add ALWAYS_INLINE, NEVER_INLINE and FLATTEN macrosAndreas Kling
It's tedious to write (and look at) [[gnu::always_inline]] etc. :^)
2020-04-07AK: Disable the consumable annotation checking to fix Clang buildAndreas Kling
Clang keeps whining that NonnullFooPtrs are in "unknown" state and I'm not sure how to resolve that right now. Disable the checking until we can figure it out.
2020-04-06Bitmap: Add Bitmap::find_next_range_of_unset_bits()nimelehin
AK::Bitmap is extended with find_next_range_of_unset_bits(). The function is implemented using count_trailing_zeroes_32(), which is optimized on many platforms, that gives a huge performance boost. Functions find_longest_range_of_unset_bits() and find_first_fit() are implemented with find_next_range_of_unset_bits(). According to benchmarks, they are 60-100% faster.
2020-04-06AK: Add count_trailing_zeroes_32()nimelehin
Add count_trailing_zeroes_32() which is implemented with builtins if available, otherwise there's a generic fallback.
2020-02-19AK: Use endianness flags to determine if conversion is necessaryLiav A
2020-01-18Meta: Add license header to source filesAndreas Kling
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.
2019-07-25AK: Shim open_with_path_length() for non-Serenity builds.Andreas Kling
This is pretty ugly but I don't want to *not* use open_with_path_length() so let's just shim it.
2019-07-25AK: Allow NonnullRefPtr::ptr() when in "unknown" typestate.Andreas Kling
Clang loses the typestate when passing NonnullRefPtr's via lambda captures. This is unfortunate, but not much we can do about it. Allowing ptr() makes it possible to use captured NonnullRefPtrs as you'd expect.
2019-07-24AK: Move clang-specific consumable annotation helpers to Platform.hAndreas Kling
2019-07-09AK: Add Platform.h with an ARCH() macro.Andreas Kling
You can currently use this to detect the CPU architecture like so: #if ARCH(I386) ... #elif ARCH(X86_64) ... #else ... #endif This will be helpful for separating out architecture-specific code blocks.