test_util.cpp supports OpenBSD
This commit is contained in:
parent
77ffe71737
commit
8d1e41b650
1 changed files with 7 additions and 2 deletions
|
@ -1,12 +1,13 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define XBYAK_NO_OP_NAMES
|
|
||||||
#include "xbyak/xbyak_util.h"
|
#include "xbyak/xbyak_util.h"
|
||||||
|
|
||||||
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
|
||||||
struct PopCountTest : public Xbyak::CodeGenerator {
|
struct PopCountTest : public Xbyak::CodeGenerator {
|
||||||
PopCountTest(int n)
|
PopCountTest(int n)
|
||||||
|
: Xbyak::CodeGenerator(4096, Xbyak::DontSetProtectRWE)
|
||||||
{
|
{
|
||||||
|
ret();
|
||||||
mov(eax, n);
|
mov(eax, n);
|
||||||
popcnt(eax, eax);
|
popcnt(eax, eax);
|
||||||
ret();
|
ret();
|
||||||
|
@ -92,12 +93,16 @@ void putCPUinfo()
|
||||||
if (cpu.has(Cpu::tPOPCNT)) {
|
if (cpu.has(Cpu::tPOPCNT)) {
|
||||||
const int n = 0x12345678; // bitcount = 13
|
const int n = 0x12345678; // bitcount = 13
|
||||||
const int ok = 13;
|
const int ok = 13;
|
||||||
int r = PopCountTest(n).getCode<int (*)()>()();
|
PopCountTest code(n);
|
||||||
|
code.setProtectModeRE();
|
||||||
|
int (*f)() = code.getCode<int (*)()>();
|
||||||
|
int r = f();
|
||||||
if (r == ok) {
|
if (r == ok) {
|
||||||
puts("popcnt ok");
|
puts("popcnt ok");
|
||||||
} else {
|
} else {
|
||||||
printf("popcnt ng %d %d\n", r, ok);
|
printf("popcnt ng %d %d\n", r, ok);
|
||||||
}
|
}
|
||||||
|
code.setProtectModeRW();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
displayFamily displayModel
|
displayFamily displayModel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue