mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-20 16:51:37 +00:00
The test for fpu transition will require to do a runtime check for the cpu features it's running on. For this sake we need to use cpuid. Thus make it more widely available by providing in the general header. The code is adopted from the linux kernel code. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
39 lines
856 B
C
39 lines
856 B
C
#ifndef ZDTM_CPUID_H__
|
|
#define ZDTM_CPUID_H__
|
|
|
|
/*
|
|
* Adopted from linux kernel code.
|
|
*/
|
|
|
|
static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
|
|
unsigned int *ecx, unsigned int *edx)
|
|
{
|
|
/* ecx is often an input as well as an output. */
|
|
asm volatile("cpuid"
|
|
: "=a" (*eax),
|
|
"=b" (*ebx),
|
|
"=c" (*ecx),
|
|
"=d" (*edx)
|
|
: "0" (*eax), "2" (*ecx)
|
|
: "memory");
|
|
}
|
|
|
|
static inline void cpuid(unsigned int op,
|
|
unsigned int *eax, unsigned int *ebx,
|
|
unsigned int *ecx, unsigned int *edx)
|
|
{
|
|
*eax = op;
|
|
*ecx = 0;
|
|
native_cpuid(eax, ebx, ecx, edx);
|
|
}
|
|
|
|
static inline void cpuid_count(unsigned int op, unsigned int count,
|
|
unsigned int *eax, unsigned int *ebx,
|
|
unsigned int *ecx, unsigned int *edx)
|
|
{
|
|
*eax = op;
|
|
*ecx = count;
|
|
native_cpuid(eax, ebx, ecx, edx);
|
|
}
|
|
|
|
#endif /* ZDTM_CPUID_H__ */
|