e576bb | 2002-10-11 | Martin Nilsson | |
|
1b10db | 2002-10-08 | Martin Nilsson | |
|
aad99b | 2001-03-28 | Fredrik Hübinette (Hubbe) | | #include "global.h"
#include "pike_cpulib.h"
#include "svalue.h"
|
d6ea43 | 2010-10-17 | Martin Stjernholm | | #ifdef HAVE_X86_ASM
#if !defined (CL_X86_ASM_STYLE) && !defined (GCC_X86_ASM_STYLE)
#error Dont know how to inline assembler with this compiler
#endif
PMOD_EXPORT void x86_get_cpuid(int oper, INT32 *cpuid_ptr)
{
#ifdef HAVE_X86_64_ASM
#define cpuid_supported 1
#else /* HAVE_IA32_ASM */
static int cpuid_supported = 0;
if (!cpuid_supported) {
int fbits=0;
#ifdef CL_X86_ASM_STYLE
__asm {
pushf
pop eax
mov ecx, eax
xor eax, 00200000h
push eax
popf
pushf
pop eax
xor ecx, eax
mov fbits, ecx
};
#else /* GCC_X86_ASM_STYLE */
__asm__("pushf\n\t"
"pop %%eax\n\t"
"movl %%eax, %%ecx\n\t"
"xorl $0x00200000, %%eax\n\t"
"push %%eax\n\t"
"popf\n\t"
"pushf\n\t"
"pop %%eax\n\t"
"xorl %%eax, %%ecx\n\t"
"movl %%ecx, %0"
: "=m" (fbits)
:
: "cc", "eax", "ecx");
#endif
if (fbits & 0x00200000) {
cpuid_supported = 1;
} else {
cpuid_supported = -1;
}
}
#endif /* HAVE_IA32_ASM */
|
aad99b | 2001-03-28 | Fredrik Hübinette (Hubbe) | |
|
d6ea43 | 2010-10-17 | Martin Stjernholm | | if (cpuid_supported > 0) {
#ifdef CL_X86_ASM_STYLE
__asm {
mov eax, oper;
mov edi, cpuid_ptr;
cpuid;
mov [edi], eax;
mov [edi+4], ebx;
mov [edi+8], edx;
mov [edi+12], ecx;
};
#else /* GCC_X86_ASM_STYLE */
|
13bbbc | 2012-04-27 | Bill Welliver | |
|
945e9f | 2012-04-29 | Henrik Grubbström (Grubba) | | #if SIZEOF_CHAR_P == 4
|
13bbbc | 2012-04-27 | Bill Welliver | | __asm__ __volatile__("pushl %%ebx \n\t"
"cpuid \n\t"
"movl %%ebx, %1 \n\t"
"popl %%ebx \n\t"
: "=a"(cpuid_ptr[0]),
"=r"(cpuid_ptr[1]),
"=c"(cpuid_ptr[2]),
"=d"(cpuid_ptr[3])
: "0"(oper)
: "cc");
|
945e9f | 2012-04-29 | Henrik Grubbström (Grubba) | | #else
__asm__ __volatile__("push %%rbx \n\t"
"cpuid \n\t"
"movl %%ebx, %1 \n\t"
"pop %%rbx \n\t"
: "=a"(cpuid_ptr[0]),
"=r"(cpuid_ptr[1]),
"=c"(cpuid_ptr[2]),
"=d"(cpuid_ptr[3])
: "0"(oper)
: "cc");
#endif
|
d6ea43 | 2010-10-17 | Martin Stjernholm | | #endif
} else {
cpuid_ptr[0] = cpuid_ptr[1] = cpuid_ptr[2] = cpuid_ptr[3] = 0;
}
}
#endif /* HAVE_IA32_ASM */
#ifdef PIKE_NEED_MEMLOCK
|
aad99b | 2001-03-28 | Fredrik Hübinette (Hubbe) | |
#define PIKE_MEM_HASH 17903
PIKE_MUTEX_T pike_memory_locks[PIKE_MEM_HASH];
|
45637c | 2001-04-07 | Fredrik Hübinette (Hubbe) | | void init_pike_cpulib(void)
|
aad99b | 2001-03-28 | Fredrik Hübinette (Hubbe) | | {
int e;
|
45637c | 2001-04-07 | Fredrik Hübinette (Hubbe) | | for(e=0;e<PIKE_MEM_HASH;e++)
mt_init_recursive(pike_memory_locks+e);
|
aad99b | 2001-03-28 | Fredrik Hübinette (Hubbe) | | }
#endif
|