From: Viktor Szakats Date: Thu, 17 Jul 2025 16:13:37 +0000 (+0200) Subject: curl/system.h: fix for GCC 3.3.x and older X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d4e166b650956fb85b01dd2b82df820c9164ecf;p=thirdparty%2Fcurl.git curl/system.h: fix for GCC 3.3.x and older The guards implicitly and intentionally include clang, which reports itself as GCC 4.2.1. Ref: https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Other-Builtins.html#Other-Builtins Ref: https://www.haiku-os.org/guides/building/gcc-hybrid (Haiku uses gcc 2.95.3) Follow-up to 909af1a43b5a7fed8b5a4ca145e39f46b2f50325 #16761 Reported-by: Schrijvers Luc Fixes #17951 Closes #17954 --- diff --git a/include/curl/system.h b/include/curl/system.h index ebcdc5e4fd..e25e8b3127 100644 --- a/include/curl/system.h +++ b/include/curl/system.h @@ -336,8 +336,11 @@ # define CURL_FORMAT_CURL_OFF_TU "llu" # define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_TU ULL -# define CURL_POPCOUNT64(x) __builtin_popcountll(x) -# define CURL_CTZ64(x) __builtin_ctzll(x) +# if (__GNUC__ >= 4) || \ + ((__GNUC__ == 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 4)) +# define CURL_POPCOUNT64(x) __builtin_popcountll(x) +# define CURL_CTZ64(x) __builtin_ctzll(x) +# endif # elif defined(__LP64__) || \ defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \ defined(__e2k__) || \ @@ -348,8 +351,11 @@ # define CURL_FORMAT_CURL_OFF_TU "lu" # define CURL_SUFFIX_CURL_OFF_T L # define CURL_SUFFIX_CURL_OFF_TU UL -# define CURL_POPCOUNT64(x) __builtin_popcountl(x) -# define CURL_CTZ64(x) __builtin_ctzl(x) +# if (__GNUC__ >= 4) || \ + ((__GNUC__ == 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 4)) +# define CURL_POPCOUNT64(x) __builtin_popcountl(x) +# define CURL_CTZ64(x) __builtin_ctzl(x) +# endif # endif # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t # define CURL_PULL_SYS_TYPES_H 1