1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 19:47:46 +00:00

AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places

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.
This commit is contained in:
Nico Weber 2022-10-04 15:04:13 -04:00 committed by Linus Groh
parent ff4b912b7c
commit 2af028132a
35 changed files with 64 additions and 49 deletions

View file

@ -4,7 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#ifdef __clang__
#include <AK/Platform.h>
#if defined(AK_COMPILER_CLANG)
# pragma clang optimize off
#else
# pragma GCC optimize("O0")

View file

@ -91,13 +91,13 @@ TEST_CASE(aligned_alloc_fuzz)
TEST_CASE(aligned_alloc_not_power2)
{
#ifdef __clang__
#if defined(AK_COMPILER_CLANG)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wnon-power-of-two-alignment"
#endif
EXPECT_EQ(aligned_alloc(7, 256), nullptr);
EXPECT_EQ(errno, EINVAL);
#ifdef __clang__
#if defined(AK_COMPILER_CLANG)
# pragma clang diagnostic pop
#endif
}