From: Nathan Moinvaziri Date: Sun, 11 Jan 2026 21:11:08 +0000 (-0800) Subject: Add fallback for __has_builtin to prevent unmatched parenthesis warning X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fe8a5ee41053c35ad746edc360172ee44281ffb;p=thirdparty%2Fzlib-ng.git Add fallback for __has_builtin to prevent unmatched parenthesis warning Occurs on MSVC. --- diff --git a/fallback_builtins.h b/fallback_builtins.h index ca285a524..8ac842106 100644 --- a/fallback_builtins.h +++ b/fallback_builtins.h @@ -1,6 +1,11 @@ #ifndef FALLBACK_BUILTINS_H #define FALLBACK_BUILTINS_H +/* Provide fallback for compilers that don't support __has_builtin */ +# ifndef __has_builtin +# define __has_builtin(x) 0 +# endif + #if defined(_MSC_VER) && !defined(__clang__) #include @@ -42,13 +47,13 @@ Z_FORCEINLINE static int __builtin_ctzll(unsigned long long value) { #endif // _MSC_VER && !__clang__ -#if !(defined(__has_builtin) && __has_builtin(__builtin_bitreverse16)) +#if !__has_builtin(__builtin_bitreverse16) # if defined(ARCH_ARM) && defined(ARCH_64BIT) && !defined(_MSC_VER) /* ARM bit reversal for 16-bit values using rbit instruction */ Z_FORCEINLINE static uint16_t __builtin_bitreverse16(uint16_t value) { uint32_t res; -# if defined(__has_builtin) && __has_builtin(__builtin_rbit) +# if __has_builtin(__builtin_rbit) res = __builtin_rbit((uint32_t)value); # else __asm__ volatile("rbit %w0, %w1" : "=r"(res) : "r"((uint32_t)value));