#ifndef BOOST_ATOMIC_CPUID_HPP_INCLUDED_
#define BOOST_ATOMIC_CPUID_HPP_INCLUDED_
#include <boost/predef/architecture/x86.h>
#if BOOST_ARCH_X86
#if defined(_MSC_VER)
#include <intrin.h>
#endif
#include <boost/cstdint.hpp>
#include <boost/atomic/detail/config.hpp>
#include <boost/atomic/detail/header.hpp>
namespace boost {
namespace atomics {
namespace detail {
inline void cpuid(uint32_t& eax, uint32_t& ebx, uint32_t& ecx, uint32_t& edx)
{
#if defined(__GNUC__)
#if (defined(__i386__) || defined(__VXWORKS__)) && (defined(__PIC__) || defined(__PIE__)) && !(defined(__clang__) || (defined(BOOST_GCC) && BOOST_GCC >= 50100))
#if defined(__x86_64__)
uint64_t rbx = ebx;
__asm__ __volatile__
(
"xchgq %%rbx, %0\n\t"
"cpuid\n\t"
"xchgq %%rbx, %0\n\t"
: "+DS" (rbx), "+a" (eax), "+c" (ecx), "+d" (edx)
);
ebx = static_cast< uint32_t >(rbx);
#else
__asm__ __volatile__
(
"xchgl %%ebx, %0\n\t"
"cpuid\n\t"
"xchgl %%ebx, %0\n\t"
: "+DS" (ebx), "+a" (eax), "+c" (ecx), "+d" (edx)
);
#endif #else
__asm__ __volatile__
(
"cpuid\n\t"
: "+a" (eax), "+b" (ebx), "+c" (ecx), "+d" (edx)
);
#endif
#elif defined(_MSC_VER)
int regs[4] = {};
__cpuid(regs, eax);
eax = regs[0];
ebx = regs[1];
ecx = regs[2];
edx = regs[3];
#else
#error "Boost.Atomic: Unsupported compiler, cpuid instruction cannot be generated"
#endif
}
} } }
#include <boost/atomic/detail/footer.hpp>
#endif
#endif