diff options
author | MITSUNARI Shigeo <[email protected]> | 2021-01-02 11:40:41 +0900 |
---|---|---|
committer | MITSUNARI Shigeo <[email protected]> | 2021-01-02 11:40:41 +0900 |
commit | 8d1e41b650890080fb77548372b6236bbd4079f9 (patch) | |
tree | def2af9b967ff5d5d5d65dc7f5f2a8a0cc4a73c7 /sample/test_util.cpp | |
parent | 77ffe717376d194f1e5cc910bbd755d99bbba94e (diff) | |
download | xbyak-8d1e41b650890080fb77548372b6236bbd4079f9.tar.gz xbyak-8d1e41b650890080fb77548372b6236bbd4079f9.zip |
test_util.cpp supports OpenBSD
Diffstat (limited to 'sample/test_util.cpp')
-rw-r--r-- | sample/test_util.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sample/test_util.cpp b/sample/test_util.cpp index 98176fc..18dcce5 100644 --- a/sample/test_util.cpp +++ b/sample/test_util.cpp @@ -1,12 +1,13 @@ #include <stdio.h> -#define XBYAK_NO_OP_NAMES #include "xbyak/xbyak_util.h" #define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0])) struct PopCountTest : public Xbyak::CodeGenerator { PopCountTest(int n) + : Xbyak::CodeGenerator(4096, Xbyak::DontSetProtectRWE) { +ret(); mov(eax, n); popcnt(eax, eax); ret(); @@ -92,12 +93,16 @@ void putCPUinfo() if (cpu.has(Cpu::tPOPCNT)) { const int n = 0x12345678; // bitcount = 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) { puts("popcnt ok"); } else { printf("popcnt ng %d %d\n", r, ok); } + code.setProtectModeRW(); } /* displayFamily displayModel |