-betterC works on linux with DMD
This commit is contained in:
parent
633aad6cb7
commit
cde772c077
2 changed files with 24 additions and 3 deletions
|
|
@ -131,9 +131,8 @@ static struct Mallocator
|
||||||
|
|
||||||
static void* alignAlloc(size_t length, size_t alignment) nothrow @nogc
|
static void* alignAlloc(size_t length, size_t alignment) nothrow @nogc
|
||||||
{
|
{
|
||||||
|
|
||||||
void* ret;
|
void* ret;
|
||||||
version(Posix)ret = aligned_alloc(alignment, length);
|
version(Posix)posix_memalign(&ret, alignment, length);//ret = aligned_alloc(alignment, length);
|
||||||
else version(Windows)ret = _aligned_malloc(length, alignment);
|
else version(Windows)ret = _aligned_malloc(length, alignment);
|
||||||
else static assert(0, "Unimplemented platform!");
|
else static assert(0, "Unimplemented platform!");
|
||||||
//posix_memalign(&ret, alignment, length);
|
//posix_memalign(&ret, alignment, length);
|
||||||
|
|
@ -149,7 +148,7 @@ static struct Mallocator
|
||||||
static void alignDispose(T)(T object)
|
static void alignDispose(T)(T object)
|
||||||
{
|
{
|
||||||
static if(__traits(hasMember, T, "__dtor"))object.__dtor();
|
static if(__traits(hasMember, T, "__dtor"))object.__dtor();
|
||||||
version(Posix)aligned_free(cast(void*)object);
|
version(Posix)free(cast(void*)object);
|
||||||
else version(Windows)_aligned_free(cast(void*)object);
|
else version(Windows)_aligned_free(cast(void*)object);
|
||||||
else static assert(0, "Unimplemented platform!");
|
else static assert(0, "Unimplemented platform!");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,28 @@ version(Windows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else version(Posix)
|
||||||
|
{
|
||||||
|
import core.sys.posix.time;
|
||||||
|
struct Time
|
||||||
|
{
|
||||||
|
static long getUSecTime()
|
||||||
|
{
|
||||||
|
time_t time;
|
||||||
|
timespec spec;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_REALTIME, &spec);
|
||||||
|
|
||||||
|
//time = spec.tv_sec;
|
||||||
|
return spec.tv_sec * 1000_000 + spec.tv_nsec / 1000;//time / 1000_000;
|
||||||
|
|
||||||
|
/*LARGE_INTEGER time, freq;
|
||||||
|
QueryPerformanceFrequency(&freq);
|
||||||
|
QueryPerformanceCounter(&time);
|
||||||
|
return time.QuadPart / (freq.QuadPart / 1000_000);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct TestEvent
|
struct TestEvent
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue