1 // This test attempts to force the dynamic linker to resolve
2 // external symbols as close to the red zone as possible.
9 fn set_min_stack(size: uint);
10 fn debug_get_stk_seg() -> *u8;
13 fn last_os_error() -> str;
14 fn rust_getcwd() -> str;
15 fn refcount(box: @int);
24 fn calllink01() { rustrt::unsupervise(); }
25 fn calllink02() { rustrt::last_os_error(); }
26 fn calllink03() { rustrt::rust_getcwd(); }
27 fn calllink04() { rustrt::refcount(@0); }
28 fn calllink05() { rustrt::do_gc(); }
29 fn calllink06() { rustrt::pin_task(); }
30 fn calllink07() { rustrt::unpin_task(); }
31 fn calllink08() { rustrt::get_task_id(); }
32 fn calllink09() { rustrt::sched_threads(); }
33 fn calllink10() { rustrt::rust_get_task(); }
35 fn runtest(f: sendfn(), frame_backoff: u32) {
36 runtest2(f, frame_backoff, 0 as *u8);
39 fn runtest2(f: sendfn(), frame_backoff: u32, last_stk: *u8) -> u32 {
40 let curr_stk = rustrt::debug_get_stk_seg();
41 if (last_stk != curr_stk && last_stk != 0 as *u8) {
42 // We switched stacks, go back and try to hit the dynamic linker
45 let frame_backoff = runtest2(f, frame_backoff, curr_stk);
46 if frame_backoff > 1u32 {
48 } else if frame_backoff == 1u32 {
70 let rng = rand::mk_rng();
72 let sz = rng.next() % 256u32 + 256u32;
73 let frame_backoff = rng.next() % 10u32 + 1u32;
74 rustrt::set_min_stack(sz as uint);
75 task::join(task::spawn_joinable {|| runtest(f, frame_backoff);});