mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-23 15:40:14 +08:00
bbfe79fb72
Commit e1ce752a1d, "Cygwin: remove miscellaneous 32-bit code", removed most occurrences of '#ifdef __x86_64__'. Restore those occurrences that guarded code specific to the AMD64 processor, and #error out if the processor is different. This will make it easier to find AMD64-specific code if we ever want to add support for a different 64-bit processor (e.g., ARM64).
47 lines
934 B
C
47 lines
934 B
C
/* cpuid.h: Define cpuid instruction
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#ifndef CPUID_H
|
|
#define CPUID_H
|
|
|
|
static inline void __attribute ((always_inline))
|
|
cpuid (uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t ain,
|
|
uint32_t cin = 0)
|
|
{
|
|
asm volatile ("cpuid"
|
|
: "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d)
|
|
: "a" (ain), "c" (cin));
|
|
}
|
|
|
|
#ifdef __x86_64__
|
|
static inline bool __attribute ((always_inline))
|
|
can_set_flag (uint32_t long flag)
|
|
{
|
|
uint32_t long r1, r2;
|
|
|
|
asm volatile ("pushfq\n"
|
|
"popq %0\n"
|
|
"movq %0, %1\n"
|
|
"xorq %2, %0\n"
|
|
"pushq %0\n"
|
|
"popfq\n"
|
|
"pushfq\n"
|
|
"popq %0\n"
|
|
"pushq %1\n"
|
|
"popfq\n"
|
|
: "=&r" (r1), "=&r" (r2)
|
|
: "ir" (flag)
|
|
);
|
|
return ((r1 ^ r2) & flag) != 0;
|
|
}
|
|
#else
|
|
#error unimplemented for this target
|
|
#endif
|
|
|
|
#endif // !CPUID_H
|