1 // This file deliberately uses low level linux-specific API for thread creation because:
2 // - instruction-stepping over thread creation using higher-level functions was very slow
3 // - it was also unreliable due to single-stepping bugs unrelated to this test
4 // - some threading libraries do not create or destroy threads when we would expect them to
11 enum { STACK_SIZE
= 0x2000 };
13 static uint8_t child_stack
[STACK_SIZE
];
17 std::atomic
<bool> flag(false);
19 int thread_main(void *)
21 while (! flag
) // Make sure the thread does not exit prematurely
29 int ret
= clone(thread_main
,
30 child_stack
+ STACK_SIZE
/2, // Don't care whether the stack grows up or down,
31 // just point to the middle
32 CLONE_CHILD_CLEARTID
| CLONE_FILES
| CLONE_FS
| CLONE_PARENT_SETTID
|
33 CLONE_SIGHAND
| CLONE_SYSVSEM
| CLONE_THREAD
| CLONE_VM
,
34 nullptr, // thread_main argument