Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module std.experimental.allocator.building_blocks.allocator_list;
import std.experimental.allocator.building_blocks.null_allocator;
import std.experimental.allocator.common;
import std.experimental.allocator.gc_allocator;
version(unittest) import std.stdio;

// Turn this on for debugging
// debug = allocator_list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ struct BitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment
import std.typecons : Ternary;
import std.typecons : tuple, Tuple;

version(unittest)
@system unittest
{
import std.algorithm.comparison : max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct FallbackAllocator(Primary, Fallback)

// Need both allocators to be stateless
// This is to avoid using default initialized stateful allocators
version(unittest)
static if (!stateSize!Primary && !stateSize!Fallback)
@system unittest
{
Expand Down
1 change: 0 additions & 1 deletion std/experimental/allocator/building_blocks/free_list.d
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ struct FreeList(ParentAllocator,
_max = high;
}

version(unittest)
@system unittest
{
import std.experimental.allocator.common : chooseAtRuntime;
Expand Down
2 changes: 0 additions & 2 deletions std/experimental/allocator/building_blocks/free_tree.d
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ struct FreeTree(ParentAllocator)
return true;
}

version(unittest)
@system unittest // test a few simple configurations
{
import std.experimental.allocator.gc_allocator;
Expand All @@ -357,7 +356,6 @@ struct FreeTree(ParentAllocator)
assert(a.formatSizes == "(_)", a.formatSizes);
}

version(unittest)
@system unittest // build a complex free tree
{
import std.experimental.allocator.gc_allocator, std.range;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module std.experimental.allocator.building_blocks.kernighan_ritchie;
import std.experimental.allocator.building_blocks.null_allocator;

//debug = KRRegion;
version(unittest) import std.conv : text;
debug(KRRegion) import std.stdio;

// KRRegion
Expand Down Expand Up @@ -554,7 +553,6 @@ struct KRRegion(ParentAllocator = NullAllocator)
}

///
version(unittest)
@system unittest
{
import std.experimental.allocator.gc_allocator : GCAllocator;
Expand Down Expand Up @@ -776,7 +774,7 @@ it actually returns memory to the operating system when possible.
auto p = cast(KRRegion!()* ) store.ptr;
import core.stdc.string : memcpy;
import std.algorithm.mutation : move;
import std.conv : emplace;
import std.conv : text, emplace;

memcpy(p, &alloc, alloc.sizeof);
emplace(&alloc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ struct ScopedAllocator(ParentAllocator)
static if (!stateSize!ParentAllocator)
{
// This test is available only for stateless allocators
version(unittest)
@system unittest
{
testAllocator!(() => ScopedAllocator());
Expand Down
9 changes: 6 additions & 3 deletions std/experimental/allocator/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ Forwards each of the methods in `funs` (if defined) to `member`.

version(unittest)
{
import std.experimental.allocator : RCIAllocator, RCISharedAllocator;

package void testAllocator(alias make)()
{
Expand Down Expand Up @@ -608,9 +607,13 @@ version(unittest)
}

package void testAllocatorObject(RCAllocInterface)(RCAllocInterface a)
if (is(RCAllocInterface == RCIAllocator)
|| is (RCAllocInterface == shared RCISharedAllocator))
{
// this used to be a template constraint, but moving it inside prevents
// unnecessary import of std.experimental.allocator
import std.experimental.allocator : RCIAllocator, RCISharedAllocator;
static assert(is(RCAllocInterface == RCIAllocator)
|| is (RCAllocInterface == RCISharedAllocator));

import std.conv : text;
import std.math : isPowerOf2;
import std.stdio : writeln, stderr;
Expand Down
15 changes: 6 additions & 9 deletions std/experimental/allocator/mallocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import std.experimental.allocator.common;
*/
struct Mallocator
{
version(unittest)
@system unittest { testAllocator!(() => Mallocator.instance); }

/**
Expand Down Expand Up @@ -363,10 +362,6 @@ version(LDC_AddressSanitizer)
//...
}

version(unittest) version(CRuntime_DigitalMars)
@nogc nothrow
size_t addr(ref void* ptr) { return cast(size_t) ptr; }

version(Posix)
@nogc @system nothrow unittest
{
Expand Down Expand Up @@ -399,24 +394,26 @@ version(CRuntime_DigitalMars)
{
void* m;

size_t m_addr() { return cast(size_t) m; }

m = _aligned_malloc(16, 0x10);
if (m)
{
assert((m.addr & 0xF) == 0);
assert((m_addr & 0xF) == 0);
_aligned_free(m);
}

m = _aligned_malloc(16, 0x100);
if (m)
{
assert((m.addr & 0xFF) == 0);
assert((m_addr & 0xFF) == 0);
_aligned_free(m);
}

m = _aligned_malloc(16, 0x1000);
if (m)
{
assert((m.addr & 0xFFF) == 0);
assert((m_addr & 0xFFF) == 0);
_aligned_free(m);
}

Expand All @@ -425,7 +422,7 @@ version(CRuntime_DigitalMars)
{
assert((cast(size_t) m & 0xF) == 0);
m = _aligned_realloc(m, 32, 0x10000);
if (m) assert((m.addr & 0xFFFF) == 0);
if (m) assert((m_addr & 0xFFFF) == 0);
_aligned_free(m);
}

Expand Down