Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 0d455a4

Browse files
authored
Merge pull request #3053 from thewilsonator/test-fiber-guard-page
clean up test/thread/src/fiber_guard_page merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents 15a3f9d + 41481c4 commit 0d455a4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/thread/src/fiber_guard_page.d

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import core.thread;
22
import core.sys.posix.sys.mman;
33

4+
version (LDC) import ldc.attributes;
5+
else struct optStrategy { string a; }
6+
47
// this should be true for most architectures
58
// (taken from core.thread)
69
version = StackGrowsDown;
710

811
enum stackSize = 4096;
912

1013
// Simple method that causes a stack overflow
14+
@optStrategy("none")
1115
void stackMethod()
1216
{
1317
// Over the stack size, so it overflows the stack
@@ -21,18 +25,15 @@ void main()
2125
// allocate a page below (above) the fiber's stack to make stack overflows possible (w/o segfaulting)
2226
version (StackGrowsDown)
2327
{
24-
static assert(__traits(identifier, test_fiber.tupleof[8]) == "m_pmem");
25-
auto stackBottom = test_fiber.tupleof[8];
28+
auto stackBottom = __traits(getMember, test_fiber, "m_pmem");
2629
auto p = mmap(stackBottom - 8 * stackSize, 8 * stackSize,
2730
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
2831
assert(p !is null, "failed to allocate page");
2932
}
3033
else
3134
{
32-
auto m_sz = test_fiber.tupleof[7];
33-
auto m_pmem = test_fiber.tupleof[8];
34-
static assert(__traits(identifier, test_fiber.tupleof[7]) == "m_size");
35-
static assert(__traits(identifier, test_fiber.tupleof[8]) == "m_pmem");
35+
auto m_sz = __traits(getMember, test_fiber, "m_sz");
36+
auto m_pmem = __traits(getMember, test_fiber, "m_pmem");
3637

3738
auto stackTop = m_pmem + m_sz;
3839
auto p = mmap(stackTop, 8 * stackSize,

0 commit comments

Comments
 (0)