Compare commits
No commits in common. "1c57368f43ea2cc093138887daadde2e51533223" and "728eaf88fb376025bd729b7047a7a73553005dd9" have entirely different histories.
1c57368f43
...
728eaf88fb
@ -19,30 +19,13 @@ import tanya.memory.allocator;
|
|||||||
import tanya.memory.op;
|
import tanya.memory.op;
|
||||||
import tanya.os.error;
|
import tanya.os.error;
|
||||||
|
|
||||||
version (Windows)
|
extern(C) pragma(mangle, "mmap")
|
||||||
{
|
private void* mapMemory(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
|
||||||
import core.sys.windows.basetsd : SIZE_T;
|
@nogc nothrow pure @system;
|
||||||
import core.sys.windows.windef : BOOL, DWORD;
|
|
||||||
import core.sys.windows.winnt : MEM_COMMIT, MEM_RELEASE, PAGE_READWRITE, PVOID;
|
|
||||||
|
|
||||||
extern (Windows)
|
extern(C) pragma(mangle, "munmap")
|
||||||
private PVOID VirtualAlloc(PVOID, SIZE_T, DWORD, DWORD)
|
private bool unmapMemory(shared void* addr, size_t length)
|
||||||
@nogc nothrow pure @system;
|
@nogc nothrow pure @system;
|
||||||
|
|
||||||
extern (Windows)
|
|
||||||
private BOOL VirtualFree(shared PVOID, SIZE_T, DWORD)
|
|
||||||
@nogc nothrow pure @system;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
extern(C) pragma(mangle, "mmap")
|
|
||||||
private void* mapMemory(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
|
|
||||||
@nogc nothrow pure @system;
|
|
||||||
|
|
||||||
extern(C) pragma(mangle, "munmap")
|
|
||||||
private bool unmapMemory(shared void* addr, size_t length)
|
|
||||||
@nogc nothrow pure @system;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This allocator allocates memory in regions (multiple of 64 KB for example).
|
* This allocator allocates memory in regions (multiple of 64 KB for example).
|
||||||
@ -209,9 +192,6 @@ final class MmapPool : Allocator
|
|||||||
{
|
{
|
||||||
block.region.next.prev = block.region.prev;
|
block.region.next.prev = block.region.prev;
|
||||||
}
|
}
|
||||||
version (Windows)
|
|
||||||
return VirtualFree(block.region, 0, MEM_RELEASE) != 0;
|
|
||||||
else
|
|
||||||
return unmapMemory(block.region, block.region.size) == 0;
|
return unmapMemory(block.region, block.region.size) == 0;
|
||||||
}
|
}
|
||||||
// Merge blocks if neigbours are free.
|
// Merge blocks if neigbours are free.
|
||||||
@ -400,19 +380,6 @@ final class MmapPool : Allocator
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
version (Windows)
|
|
||||||
{
|
|
||||||
void* p = VirtualAlloc(null,
|
|
||||||
regionSize,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (p is null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
void* p = mapMemory(null,
|
void* p = mapMemory(null,
|
||||||
regionSize,
|
regionSize,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
@ -423,7 +390,6 @@ final class MmapPool : Allocator
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Region region = cast(Region) p;
|
Region region = cast(Region) p;
|
||||||
region.blocks = 1;
|
region.blocks = 1;
|
||||||
|
@ -22,22 +22,8 @@ import tanya.range;
|
|||||||
|
|
||||||
version (Windows)
|
version (Windows)
|
||||||
{
|
{
|
||||||
private union NET_LUID_LH { ulong Value, Info; }
|
import tanya.sys.windows.ifdef;
|
||||||
private alias NET_LUID = NET_LUID_LH;
|
import tanya.sys.windows.iphlpapi;
|
||||||
private alias NET_IFINDEX = uint;
|
|
||||||
private enum IF_MAX_STRING_SIZE = 256;
|
|
||||||
extern(Windows) @nogc nothrow private @system
|
|
||||||
{
|
|
||||||
uint ConvertInterfaceNameToLuidA(const(char)* InterfaceName,
|
|
||||||
NET_LUID* InterfaceLuid);
|
|
||||||
uint ConvertInterfaceLuidToIndex(const(NET_LUID)* InterfaceLuid,
|
|
||||||
NET_IFINDEX* InterfaceIndex);
|
|
||||||
uint ConvertInterfaceIndexToLuid(NET_IFINDEX InterfaceIndex,
|
|
||||||
NET_LUID* InterfaceLuid);
|
|
||||||
uint ConvertInterfaceLuidToNameA(const(NET_LUID)* InterfaceLuid,
|
|
||||||
char* InterfaceName,
|
|
||||||
size_t Length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else version (Posix)
|
else version (Posix)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user