mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2025-12-24 00:04:51 +01:00
commit
1b3b98c3f7
20 changed files with 253 additions and 153 deletions
9
externals/xbyak/sample/test0.cpp
vendored
9
externals/xbyak/sample/test0.cpp
vendored
|
|
@ -162,18 +162,21 @@ int main()
|
|||
{
|
||||
// use memory allocated by user
|
||||
using namespace Xbyak;
|
||||
const size_t codeSize = 1024;
|
||||
const size_t codeSize = 4096;
|
||||
uint8 buf[codeSize + 16];
|
||||
uint8 *p = CodeArray::getAlignedAddress(buf);
|
||||
CodeArray::protect(p, codeSize, true);
|
||||
Sample s(p, codeSize);
|
||||
if (!CodeArray::protect(p, codeSize, CodeArray::PROTECT_RWE)) {
|
||||
fprintf(stderr, "can't protect\n");
|
||||
return 1;
|
||||
}
|
||||
int (*func)(int) = s.getCode<int (*)(int)>();
|
||||
if (Xbyak::CastTo<uint8*>(func) != p) {
|
||||
fprintf(stderr, "internal error %p %p\n", p, Xbyak::CastTo<uint8*>(func));
|
||||
return 1;
|
||||
}
|
||||
printf("0 + ... + %d = %d\n", 100, func(100));
|
||||
CodeArray::protect(p, codeSize, false);
|
||||
CodeArray::protect(p, codeSize, CodeArray::PROTECT_RW);
|
||||
}
|
||||
puts("OK");
|
||||
testReset();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue