summaryrefslogtreecommitdiff
path: root/AK/Platform.h
AgeCommit message (Collapse)Author
2023-04-14AK: Remove workaround for old macOS SDKNico Weber
https://github.com/SerenityOS/serenity/pull/9716#issuecomment-1508606204 has details.
2023-04-14AK: Remove unused AK_ARCH_ definesNico Weber
ARCH() uses the AK_IS_ARCH_ macros internally since 349e54d5375a4a, and all user code uses the ARCH() macro instead of AK_ARCH_. (Why it's called ARCH() and not AK_ARCH(), I don't know.) If any ports not in the main repo use AK_ARCH_, they should switch to using ARCH() instead.
2023-04-14Everywhere: Use ARCH(AARCH64) instead of AK_ARCH_AARCH64Nico Weber
The former is typo-resistant after 349e54d5375a4a, so make use of that.
2023-04-08AK: Bake CLion IDE check into AK_COMPILER_CLANGAndreas Kling
For whatever reason, when CLion does its code indexing thing, it doesn't define __clang__ despite using Clang. This causes it to run into various problems that we've solved by checking for Clang. Since CLion does define __CLION_IDE__ (or sometimes __CLION_IDE_, no idea why but I have seen this issue locally), let's make that part of the AK_COMPILER_CLANG check. This makes CLion stop highlighting various things as errors.
2023-03-04AK: Add Solaris to platform detectionnipos
2023-03-03AK+readelf: Issue error when using ARCH(arch) with nonexistent archDan Klishch
This disallows erroneous `#if ARCH(x86_64)` (note lowercase x).
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. :/