Skip to content

Calling native cpuid obviously doesn't work in windows with Visual studio compiler #17

Closed
@wireshrink

Description

@wireshrink

(Who needs it at all, anyway) ?

With visual studio compiler it should look like

...
#if defined(_MSC_VER)
#include <intrin.h>
#endif
...
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. */
	
#if !defined(_MSC_VER)
	
	asm volatile("cpuid"
		: "=a" (*eax),
		"=b" (*ebx),
		"=c" (*ecx),
		"=d" (*edx)
		: "0" (*eax), "2" (*ecx));

#else 
	int registers[4] = {0,0,0,0};
	
	__cpuidex(registers, *eax, *ecx);
	*eax = registers[0];
	*ebx = registers[1];
	*ecx = registers[2];
	*edx = registers[3];

#endif
}

I know that it works in windows but unfortunately can not check that it still works in other places.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions