# HG changeset patch # User Maxim Dounin # Date 1722992310 -10800 # Node ID d286426eab1a2953b27161829dbca27ce578c706 # Parent 32a5186a27058925bfa9280215ecee114a56d6be 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". diff --git a/src/core/ngx_cpuinfo.c b/src/core/ngx_cpuinfo.c --- a/src/core/ngx_cpuinfo.c +++ b/src/core/ngx_cpuinfo.c @@ -9,7 +9,8 @@ #include -#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); diff --git a/src/event/modules/ngx_iocp_module.c b/src/event/modules/ngx_iocp_module.c --- a/src/event/modules/ngx_iocp_module.c +++ b/src/event/modules/ngx_iocp_module.c @@ -172,7 +172,7 @@ ngx_iocp_timer(void *data) #endif } -#if defined(__WATCOMC__) || defined(__GNUC__) +#if defined(__WATCOMC__) || defined(__GNUC__) || defined(__clang__) return 0; #endif } diff --git a/src/os/unix/ngx_atomic.h b/src/os/unix/ngx_atomic.h --- a/src/os/unix/ngx_atomic.h +++ b/src/os/unix/ngx_atomic.h @@ -153,7 +153,7 @@ ngx_cpu_pause(void); #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 @@ ngx_cpu_pause(void); #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 @@ typedef volatile ngx_atomic_uint_t ngx_ #include "ngx_sunpro_atomic_sparc64.h" -#else /* ( __GNUC__ || __INTEL_COMPILER ) */ +#else /* ( __GNUC__ || __clang__ || __INTEL_COMPILER ) */ #define NGX_HAVE_ATOMIC_OPS 1