block_of_code: rename PAGE_SIZE to DYNARMIC_PAGE_SIZE to prevent use of reserved name
PAGE_SIZE is a kernel symbol and depending on the libc in use, it will "leak". In this case dynarmic was using it's own PAGE_SIZE and in combination with the Musl libc the compiler would complain it was overwriting the kernel symbol
This commit is contained in:
parent
bf422a190a
commit
e49fee0ca1
1 changed files with 5 additions and 5 deletions
|
@ -59,13 +59,13 @@ constexpr size_t CONSTANT_POOL_SIZE = 2 * 1024 * 1024;
|
||||||
class CustomXbyakAllocator : public Xbyak::Allocator {
|
class CustomXbyakAllocator : public Xbyak::Allocator {
|
||||||
public:
|
public:
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static constexpr size_t PAGE_SIZE = 4096;
|
static constexpr size_t DYNARMIC_PAGE_SIZE = 4096;
|
||||||
|
|
||||||
// Can't subclass Xbyak::MmapAllocator because it is not a pure interface
|
// Can't subclass Xbyak::MmapAllocator because it is not a pure interface
|
||||||
// and doesn't expose its construtor
|
// and doesn't expose its construtor
|
||||||
uint8_t* alloc(size_t size) override {
|
uint8_t* alloc(size_t size) override {
|
||||||
// Waste a page to store the size
|
// Waste a page to store the size
|
||||||
size += PAGE_SIZE;
|
size += DYNARMIC_PAGE_SIZE;
|
||||||
|
|
||||||
# if defined(MAP_ANONYMOUS)
|
# if defined(MAP_ANONYMOUS)
|
||||||
int mode = MAP_PRIVATE | MAP_ANONYMOUS;
|
int mode = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||||
|
@ -83,13 +83,13 @@ public:
|
||||||
throw Xbyak::Error(Xbyak::ERR_CANT_ALLOC);
|
throw Xbyak::Error(Xbyak::ERR_CANT_ALLOC);
|
||||||
}
|
}
|
||||||
std::memcpy(p, &size, sizeof(size_t));
|
std::memcpy(p, &size, sizeof(size_t));
|
||||||
return static_cast<uint8_t*>(p) + PAGE_SIZE;
|
return static_cast<uint8_t*>(p) + DYNARMIC_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free(uint8_t* p) override {
|
void free(uint8_t* p) override {
|
||||||
size_t size;
|
size_t size;
|
||||||
std::memcpy(&size, p - PAGE_SIZE, sizeof(size_t));
|
std::memcpy(&size, p - DYNARMIC_PAGE_SIZE, sizeof(size_t));
|
||||||
munmap(p - PAGE_SIZE, size);
|
munmap(p - DYNARMIC_PAGE_SIZE, size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue