From ff239fff4fa0399b58d45dec8f6b83f48e090119 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Mar 2023 16:30:42 +0100 Subject: [PATCH] util/ByteOrder: check only __GNUC__ Assume GCC/clang is recent enough. --- src/config/Option.hxx | 6 ++---- src/util/ByteOrder.hxx | 8 +++----- src/util/Compiler.h | 8 +++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/config/Option.hxx b/src/config/Option.hxx index f8c352296..70fb4f150 100644 --- a/src/config/Option.hxx +++ b/src/config/Option.hxx @@ -4,9 +4,7 @@ #ifndef MPD_CONFIG_OPTION_HXX #define MPD_CONFIG_OPTION_HXX -#include "util/Compiler.h" - -#if defined(_WIN32) && CLANG_OR_GCC_VERSION(4,7) +#if defined(_WIN32) && defined(__GNUC__) /* "INPUT" is declared by winuser.h */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" @@ -85,7 +83,7 @@ enum class ConfigBlockOption { MAX }; -#if defined(_WIN32) && CLANG_OR_GCC_VERSION(4,7) +#if defined(_WIN32) && defined(__GNUC__) #pragma GCC diagnostic pop #endif diff --git a/src/util/ByteOrder.hxx b/src/util/ByteOrder.hxx index 3afe45b83..dae163b73 100644 --- a/src/util/ByteOrder.hxx +++ b/src/util/ByteOrder.hxx @@ -4,8 +4,6 @@ #ifndef BYTE_ORDER_HXX #define BYTE_ORDER_HXX -#include "Compiler.h" - #include #if defined(__i386__) || defined(__x86_64__) || defined(__ARMEL__) @@ -82,7 +80,7 @@ GenericByteSwap64(uint64_t value) noexcept constexpr uint16_t ByteSwap16(uint16_t value) noexcept { -#if CLANG_OR_GCC_VERSION(4,8) +#ifdef __GNUC__ return __builtin_bswap16(value); #else return GenericByteSwap16(value); @@ -92,7 +90,7 @@ ByteSwap16(uint16_t value) noexcept constexpr uint32_t ByteSwap32(uint32_t value) noexcept { -#if CLANG_OR_GCC_VERSION(4,3) +#ifdef __GNUC__ return __builtin_bswap32(value); #else return GenericByteSwap32(value); @@ -102,7 +100,7 @@ ByteSwap32(uint32_t value) noexcept constexpr uint64_t ByteSwap64(uint64_t value) noexcept { -#if CLANG_OR_GCC_VERSION(4,3) +#ifdef __GNUC__ return __builtin_bswap64(value); #else return GenericByteSwap64(value); diff --git a/src/util/Compiler.h b/src/util/Compiler.h index 855591039..47ab602c2 100644 --- a/src/util/Compiler.h +++ b/src/util/Compiler.h @@ -47,7 +47,7 @@ #define CLANG_CHECK_VERSION(major, minor) \ (CLANG_VERSION >= GCC_MAKE_VERSION(major, minor, 0)) -#if CLANG_OR_GCC_VERSION(4,0) +#ifdef __GNUC__ /* GCC 4.x */ @@ -67,10 +67,8 @@ #endif -#if GCC_CHECK_VERSION(7,0) +#ifdef __GNUC__ #define gcc_fallthrough __attribute__((fallthrough)) -#elif CLANG_CHECK_VERSION(10,0) && defined(__cplusplus) -#define gcc_fallthrough [[fallthrough]] #else #define gcc_fallthrough #endif @@ -78,7 +76,7 @@ #ifndef __cplusplus /* plain C99 has "restrict" */ #define gcc_restrict restrict -#elif CLANG_OR_GCC_VERSION(4,0) +#elif defined(__GNUC__) /* "__restrict__" is a GCC extension for C++ */ #define gcc_restrict __restrict__ #else