1515#include < array>
1616#include < cassert>
1717#include < cstdint>
18+ #include < cstring>
1819
1920#include " ../utils/bits.hpp"
2021#include " ./xsimd_config.hpp"
@@ -27,11 +28,12 @@ namespace xsimd
2728{
2829 namespace detail
2930 {
30- using cpuid_reg_t = std::array<int , 4 >;
31+ using x86_reg32_t = std::uint32_t ;
32+
33+ using cpuid_reg_t = std::array<x86_reg32_t , 4 >;
3134 inline cpuid_reg_t get_cpuid (int level, int count = 0 ) noexcept ;
3235
33- using xcr0_reg_t = std::uint32_t ;
34- inline xcr0_reg_t get_xcr0_low () noexcept ;
36+ inline x86_reg32_t get_xcr0_low () noexcept ;
3537 }
3638
3739 /* *
@@ -154,8 +156,8 @@ namespace xsimd
154156 */
155157 constexpr static x86_xcr0 safe_default () noexcept
156158 {
157- reg_t low = {};
158- low = utils::make_bit_mask (static_cast <reg_t >(bit::sse));
159+ x86_reg32_t low = {};
160+ low = utils::make_bit_mask (static_cast <x86_reg32_t >(bit::sse));
159161 return x86_xcr0 (low);
160162 }
161163
@@ -194,9 +196,9 @@ namespace xsimd
194196 }
195197
196198 private:
197- using reg_t = detail::xcr0_reg_t ;
199+ using x86_reg32_t = detail::x86_reg32_t ;
198200
199- enum class bit : reg_t
201+ enum class bit
200202 {
201203 /* * x87 FPU/MMX support (must be 1). */
202204 x87 = 0 ,
@@ -221,17 +223,17 @@ namespace xsimd
221223 };
222224
223225 template <bit... Bits>
224- static constexpr bool all_bits_set (reg_t value) noexcept
226+ static constexpr bool all_bits_set (x86_reg32_t value) noexcept
225227 {
226- return utils::all_bits_set<static_cast <reg_t >(Bits)...>(value);
228+ return utils::all_bits_set<static_cast <x86_reg32_t >(Bits)...>(value);
227229 }
228230
229231 /* * Parse a XCR0 value into individual components. */
230- constexpr explicit x86_xcr0 (reg_t low) noexcept
232+ constexpr explicit x86_xcr0 (x86_reg32_t low) noexcept
231233 : m_low(low)
232234 {
233235 }
234- reg_t m_low = {};
236+ x86_reg32_t m_low = {};
235237 };
236238
237239 namespace detail
@@ -242,10 +244,14 @@ namespace xsimd
242244 {
243245 cpuid_reg_t reg = {};
244246#if defined(_MSC_VER)
245- __cpuidex (reg.data (), leaf, subleaf);
247+ int buf[4 ];
248+ __cpuidex (buf, leaf, subleaf);
249+ std::memcpy (reg.data (), buf, sizeof (buf));
246250
247251#elif defined(__INTEL_COMPILER)
248- __cpuid (reg.data (), leaf);
252+ int buf[4 ];
253+ __cpuid (buf, leaf);
254+ std::memcpy (reg.data (), buf, sizeof (buf));
249255
250256#elif defined(__GNUC__) || defined(__clang__)
251257
@@ -299,7 +305,7 @@ namespace xsimd
299305 return {}; // All bits to zero
300306 }
301307
302- inline xcr0_reg_t get_xcr0_low () noexcept
308+ inline x86_reg32_t get_xcr0_low () noexcept
303309 {
304310 return {}; // All bits to zero
305311 }
0 commit comments