[clang] 22a748a - [Headers] Revise conditional for rdrand64_step

Paul Robinson via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 26 09:00:37 PDT 2023


Author: Paul Robinson
Date: 2023-04-26T09:00:29-07:00
New Revision: 22a748a51f2a2644f4dbc5e93615c9f3106e50d5

URL: https://github.com/llvm/llvm-project/commit/22a748a51f2a2644f4dbc5e93615c9f3106e50d5
DIFF: https://github.com/llvm/llvm-project/commit/22a748a51f2a2644f4dbc5e93615c9f3106e50d5.diff

LOG: [Headers] Revise conditional for rdrand64_step

Downstream doc tooling doesn't like an #if between the doc and the
function prototype. This change also guarantees that the prototype
stays the same for 32/64 bit users.

Added: 
    

Modified: 
    clang/lib/Headers/immintrin.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index dff4da2465d2..c5f84ae0286b 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -323,18 +323,14 @@ _rdrand32_step(unsigned int *__p)
 /// \param __p
 ///    A pointer to a 64-bit memory location to place the random value.
 /// \returns 1 if the value was successfully generated, 0 otherwise.
-#ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
 {
+#ifdef __x86_64__
   return (int)__builtin_ia32_rdrand64_step(__p);
-}
 #else
-// We need to emulate the functionality of 64-bit rdrand with 2 32-bit
-// rdrand instructions.
-static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
-_rdrand64_step(unsigned long long *__p)
-{
+  // We need to emulate the functionality of 64-bit rdrand with 2 32-bit
+  // rdrand instructions.
   unsigned int __lo, __hi;
   unsigned int __res_lo = __builtin_ia32_rdrand32_step(&__lo);
   unsigned int __res_hi = __builtin_ia32_rdrand32_step(&__hi);
@@ -345,8 +341,8 @@ _rdrand64_step(unsigned long long *__p)
     *__p = 0;
     return 0;
   }
-}
 #endif
+}
 #endif /* __RDRND__ */
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \


        


More information about the cfe-commits mailing list