summaryrefslogtreecommitdiff
path: root/AK/Platform.h
AgeCommit message (Collapse)Author
2022-12-28AK: Remove ARCH(I386) macroAndreas Kling
2022-12-28AK: Remove i686 supportLiav A
2022-12-12AK: Actually don't include <unistd.h> for windows in Platform.hAli Mohammad Pur
I got the conditions wrong last time, oops :^)
2022-12-12AK: Don't try to include <unistd.h> on windows for PAGE_SIZEAli Mohammad Pur
2022-12-03Everywhere: Remove 'clang-format off' comments that are no longer neededLinus Groh
https://github.com/SerenityOS/serenity/pull/15654#issuecomment-1322554496
2022-11-26AK: Make it possible to not `using` AK classes into the global namespaceAndreas Kling
This patch adds the `USING_AK_GLOBALLY` macro which is enabled by default, but can be overridden by build flags. This is a step towards integrating Jakt and AK types.
2022-11-26Everywhere: Add support for compilation under emscriptenAli Mohammad Pur
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2022-10-16Kernel: Add VALIDATE_IS_AARCH64 guard macroGunnar Beutner
2022-10-14AK: Stub out the NAKED macro on AARCH64Gunnar Beutner
This is almost certainly incorrect but we'll see about that once the kernel actually gets to userspace init.
2022-10-12AK: Fix FreeBSD compilation for clockAl Hoang
FreeBSD introduced CLOCK_MONOTONIC_COARSE and CLOCK_REALTIME_COARSE. This update fixes ladybird builds from FreeBSD 13.1 see clock_gettime(2) https://www.freebsd.org/cgi/man.cgi?query=clock_gettime&apropos=0&sektion=0&manpath=FreeBSD+13.1-RELEASE&arch=default&format=ascii
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-10-04AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most placesNico Weber
Doesn't use them in libc headers so that those don't have to pull in AK/Platform.h. AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is defined in clang builds as well.) Using AK_COMPILER_GCC simplifies things some. AK_COMPILER_CLANG isn't as much of a win, other than that it's consistent with AK_COMPILER_GCC.
2022-10-02AK: Add more AK_OS_FOO macros, including AK_OS_SERENITYAndreas Kling
2022-09-29Lagom: Win32 support baby stepsDiego Iastrubni
This is the initial port of Lagom to win32. This will enable developers to use Lagom as an alternative to vanilla STL/StandardC++Library - which gives a much richer environment (think QtCore - but modern). My main incentive - is to have a native Windows Ladybird working. I am starting with AK, which does not yet fully compile (on mingw). When AK is compiling (currently fails building StringBuffer.cpp) - I will continue to LibCore and then the rest of the user space libraries (excluding the GUI, which will be another different effort). Most of the code is happily stollen from Andrew Kaster's fork - he deserves the credit. Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2022-09-21AK+LibJS: Handle NaN-boxing pointers on AArch64Daniel Bertalan
JS::Value stores 48 bit pointers to separately allocated objects in its payload. On x86-64, canonical addresses have their top 16 bits set to the same value as bit 47, effectively meaning that the value has to be sign-extended to get the pointer. AArch64, however, expects the topmost bits to be all zeros. This commit gates sign extension behind `#if ARCH(X86_64)`, and adds an `#error` for unsupported architectures, so that we do not forget to think about pointer handling when porting to a new architecture. Fixes #15290 Fixes SerenityOS/ladybird#56
2022-08-01AK: Prefix CACHE_ALIGNED & SYSTEM_CACHE_ALIGNMENT_SIZEBrian Gianforcaro
2022-07-19AK: Add support for building on Android with API version >= 30Andrew Kaster
2022-06-26AK: Recognize __CLION_IDE__ as well as __CLION_IDE_Ali Mohammad Pur
This used to be `__CLION_IDE_` before, but it seems to have been fixed in the latest EAP.
2022-04-21AK: Allow alignment to cache line size with CACHE_ALIGNEDkleines Filmröllchen
This is particularly important to avoid false sharing, which thrashes performance when two process-shared atomics are on the same cache line.
2021-12-21AK+Everywhere: Replace __builtin bit functionsNick Johnson
In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount}, this commit removes all calls to these functions and replaces them with the equivalent functions in AK/BuiltinWrappers.h.
2021-12-01Kernel: Add VALIDATE_IS_X86 macroJames Mintram
2021-11-23AK: On macOS host builds, wrap unistd.h with missing extern "C"csb6
During the build process on macOS, multiple versions of <unistd.h> were being included (Apple's version and GCC's version). It appears that all other places #include the version from GCC, but in Platform.h the Apple header was being used. GCC's <unistd.h> is wrapped in `extern "C"`, while Apple's is not. This causes a conflicting declaration, so we need to wrap the #include with extern "C". Issue has been observed on macOS Mojave. See https://github.com/microsoft/vcpkg/issues/11320 for a similar issue.
2021-11-08AK: Don't define AK_HAS_CONDITIONALLY_TRIVIAL when parsed by CLion IDEAndreas Kling
This feature confuses CLion's parser, so let's turn it off if we see the __CLION_IDE_ macro as well.
2021-10-11AK: Add support for ARCH(AARCH64) to Platform.hJames Mintram
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.