Mercurial > hg > nginx
changeset 9315:d286426eab1a
Support for Clang with "-fgnuc-version=0".
Previously, the code assumed that Clang pretends to be GCC and defines
the __GNUC__ macro, which might not be the case if the "-fgnuc-version=0"
flag is used. Fix is to explicitly check for __clang__ as well.
In practice, with this change ngx_cpuinfo() is now available on Linux
with "-fgnuc-version=0".
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 07 Aug 2024 03:58:30 +0300 |
parents | 32a5186a2705 |
children | b40149d062cb |
files | src/core/ngx_cpuinfo.c src/event/modules/ngx_iocp_module.c src/os/unix/ngx_atomic.h |
diffstat | 3 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_cpuinfo.c Wed Aug 07 03:56:59 2024 +0300 +++ b/src/core/ngx_cpuinfo.c Wed Aug 07 03:58:30 2024 +0300 @@ -9,7 +9,8 @@ #include <ngx_core.h> -#if (( __i386__ || __amd64__ ) && ( __GNUC__ || __INTEL_COMPILER )) +#if (( __i386__ || __amd64__ ) \ + && ( __GNUC__ || __clang__ || __INTEL_COMPILER )) static ngx_inline void ngx_cpuid(uint32_t i, uint32_t *buf);
--- a/src/event/modules/ngx_iocp_module.c Wed Aug 07 03:56:59 2024 +0300 +++ b/src/event/modules/ngx_iocp_module.c Wed Aug 07 03:58:30 2024 +0300 @@ -172,7 +172,7 @@ #endif } -#if defined(__WATCOMC__) || defined(__GNUC__) +#if defined(__WATCOMC__) || defined(__GNUC__) || defined(__clang__) return 0; #endif }
--- a/src/os/unix/ngx_atomic.h Wed Aug 07 03:56:59 2024 +0300 +++ b/src/os/unix/ngx_atomic.h Wed Aug 07 03:58:30 2024 +0300 @@ -153,7 +153,7 @@ #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") -#else /* ( __GNUC__ || __INTEL_COMPILER ) */ +#else /* ( __GNUC__ || __clang__ || __INTEL_COMPILER ) */ #define NGX_HAVE_ATOMIC_OPS 1 @@ -194,7 +194,7 @@ #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") -#else /* ( __GNUC__ || __INTEL_COMPILER ) */ +#else /* ( __GNUC__ || __clang__ || __INTEL_COMPILER ) */ #define NGX_HAVE_ATOMIC_OPS 1 @@ -229,7 +229,7 @@ #include "ngx_sunpro_atomic_sparc64.h" -#else /* ( __GNUC__ || __INTEL_COMPILER ) */ +#else /* ( __GNUC__ || __clang__ || __INTEL_COMPILER ) */ #define NGX_HAVE_ATOMIC_OPS 1