[clang] 134e645 - [clang][X86] Fix -Wundef warning in cpuid.h (#89842)

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 26 05:14:51 PDT 2024


Author: Dan Klishch
Date: 2024-04-26T08:14:47-04:00
New Revision: 134e645645832af6fe9c15d121551de989aa81cf

URL: https://github.com/llvm/llvm-project/commit/134e645645832af6fe9c15d121551de989aa81cf
DIFF: https://github.com/llvm/llvm-project/commit/134e645645832af6fe9c15d121551de989aa81cf.diff

LOG: [clang][X86] Fix -Wundef warning in cpuid.h (#89842)

Caught by compiling a project (SerenityOS) that uses compiler-rt and not
silencing warnings from system headers.

Added: 
    

Modified: 
    clang/lib/Headers/cpuid.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 0bb9912b465ffe..bb7692efb78ffe 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -10,7 +10,7 @@
 #ifndef __CPUID_H
 #define __CPUID_H
 
-#if !(__x86_64__ || __i386__)
+#if !defined(__x86_64__) && !defined(__i386__)
 #error this header is for x86 only
 #endif
 
@@ -256,7 +256,7 @@
 #define bit_AVX10_256   0x00020000
 #define bit_AVX10_512   0x00040000
 
-#if __i386__
+#ifdef __i386__
 #define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \
     __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
                   : "0"(__leaf))
@@ -285,7 +285,7 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf,
                                               unsigned int *__sig)
 {
     unsigned int __eax, __ebx, __ecx, __edx;
-#if __i386__
+#ifdef __i386__
     int __cpuid_supported;
 
     __asm("  pushfl\n"


        


More information about the cfe-commits mailing list