From: Eric Biggers Date: Thu, 30 Mar 2023 07:00:56 +0000 (-0700) Subject: endianness.h: use builtins directly X-Git-Tag: v1.14.0~48 X-Git-Url: https://wimlib.net/git/?a=commitdiff_plain;h=92930ec029a6619a4a8e774da2cb97f2e7265c38;p=wimlib endianness.h: use builtins directly The compiler_bswap* macros serve no real purpose. In endianness.h, just use the builtins directly. --- diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 7f48e4fe..dc0c1c98 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -153,21 +153,6 @@ #endif #define SWAP(a, b) swap((a), (b)) -/* (Optional) Efficiently swap the bytes of a 16-bit integer. */ -#if GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16) -# define compiler_bswap16 __builtin_bswap16 -#endif - -/* (Optional) Efficiently swap the bytes of a 32-bit integer. */ -#if GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap32) -# define compiler_bswap32 __builtin_bswap32 -#endif - -/* (Optional) Efficiently swap the bytes of a 64-bit integer. */ -#if GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64) -# define compiler_bswap64 __builtin_bswap64 -#endif - /* Optional definitions for checking with 'sparse'. */ #ifdef __CHECKER__ # define _bitwise_attr __attribute__((bitwise)) diff --git a/include/wimlib/endianness.h b/include/wimlib/endianness.h index c8a603c9..d72d50a9 100644 --- a/include/wimlib/endianness.h +++ b/include/wimlib/endianness.h @@ -64,8 +64,8 @@ static forceinline u16 do_bswap16(u16 n) { -#ifdef compiler_bswap16 - return compiler_bswap16(n); +#if GCC_PREREQ(4, 8) || __has_builtin(__builtin_bswap16) + return __builtin_bswap16(n); #else return bswap16_const(n); #endif @@ -73,8 +73,8 @@ static forceinline u16 do_bswap16(u16 n) static forceinline u32 do_bswap32(u32 n) { -#ifdef compiler_bswap32 - return compiler_bswap32(n); +#if GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap32) + return __builtin_bswap32(n); #else return bswap32_const(n); #endif @@ -82,8 +82,8 @@ static forceinline u32 do_bswap32(u32 n) static forceinline u64 do_bswap64(u64 n) { -#ifdef compiler_bswap64 - return compiler_bswap64(n); +#if GCC_PREREQ(4, 3) || __has_builtin(__builtin_bswap64) + return __builtin_bswap64(n); #else return bswap64_const(n); #endif