mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-12 19:36:57 +00:00
Merge pull request #43 from GloriousTacoo/main
fix(memory): remove the inclusion of mman.h on windows.
This commit is contained in:
commit
7918261214
1 changed files with 6 additions and 3 deletions
|
|
@ -1,18 +1,21 @@
|
||||||
#include "arena.h"
|
#include "arena.h"
|
||||||
#include <sys/mman.h>
|
|
||||||
#include "Base/Assert.h"
|
#include "Base/Assert.h"
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
Memory::Arena Memory::arena_init() {
|
Memory::Arena Memory::arena_init() {
|
||||||
// TODO(GloriousEggroll): Replace malloc with a windows memory mapping API.
|
// TODO(GloriousEggroll): Replace malloc with a windows memory mapping API.
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static_cast<uint8_t*>(malloc(sizeof(uint8_t) * MEMORY_CAPACITY));
|
auto data =
|
||||||
|
static_cast<uint8_t*>(malloc(sizeof(uint8_t) * MEMORY_CAPACITY));
|
||||||
#else
|
#else
|
||||||
void* data = mmap(nullptr, MEMORY_CAPACITY, PROT_READ | PROT_WRITE,
|
void* data = mmap(nullptr, MEMORY_CAPACITY, PROT_READ | PROT_WRITE,
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||||
#endif
|
|
||||||
if (data == MAP_FAILED) {
|
if (data == MAP_FAILED) {
|
||||||
return {0, 0, nullptr}; // Return invalid arena on failure
|
return {0, 0, nullptr}; // Return invalid arena on failure
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Memory::Arena arena = {
|
Memory::Arena arena = {
|
||||||
.capacity = MEMORY_CAPACITY,
|
.capacity = MEMORY_CAPACITY,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue