util/ByteOrder: check only __GNUC__

Assume GCC/clang is recent enough.
This commit is contained in:
Max Kellermann 2023-03-06 16:30:42 +01:00
parent abdbaf605e
commit ff239fff4f
3 changed files with 8 additions and 14 deletions

View File

@ -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

View File

@ -4,8 +4,6 @@
#ifndef BYTE_ORDER_HXX
#define BYTE_ORDER_HXX
#include "Compiler.h"
#include <cstdint>
#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);

View File

@ -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