diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 3a2a8e89415..ff4975fdcd8 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -99,53 +99,6 @@ rand_free(rust_rng *rng) { free(rng); } - -/* Debug helpers strictly to verify ABI conformance. - * - * FIXME (#2665): move these into a testcase when the testsuite - * understands how to have explicit C files included. - */ - -struct quad { - uint64_t a; - uint64_t b; - uint64_t c; - uint64_t d; -}; - -struct floats { - double a; - uint8_t b; - double c; -}; - -extern "C" quad -debug_abi_1(quad q) { - quad qq = { q.c + 1, - q.d - 1, - q.a + 1, - q.b - 1 }; - return qq; -} - -extern "C" floats -debug_abi_2(floats f) { - floats ff = { f.c + 1.0, - 0xff, - f.a - 1.0 }; - return ff; -} - -extern "C" int -debug_static_mut; - -int debug_static_mut = 3; - -extern "C" void -debug_static_mut_check_four() { - assert(debug_static_mut == 4); -} - extern "C" CDECL char* #if defined(__WIN32__) rust_list_dir_val(WIN32_FIND_DATA* entry_ptr) { diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp index b9be4f1e251..33fea72cca7 100644 --- a/src/rt/rust_test_helpers.cpp +++ b/src/rt/rust_test_helpers.cpp @@ -178,3 +178,49 @@ extern "C" CDECL intptr_t rust_get_test_int() { return 1; } + +/* Debug helpers strictly to verify ABI conformance. + * + * FIXME (#2665): move these into a testcase when the testsuite + * understands how to have explicit C files included. + */ + +struct quad { + uint64_t a; + uint64_t b; + uint64_t c; + uint64_t d; +}; + +struct floats { + double a; + uint8_t b; + double c; +}; + +extern "C" quad +rust_dbg_abi_1(quad q) { + quad qq = { q.c + 1, + q.d - 1, + q.a + 1, + q.b - 1 }; + return qq; +} + +extern "C" floats +rust_dbg_abi_2(floats f) { + floats ff = { f.c + 1.0, + 0xff, + f.a - 1.0 }; + return ff; +} + +extern "C" int +rust_dbg_static_mut; + +int rust_dbg_static_mut = 3; + +extern "C" void +rust_dbg_static_mut_check_four() { + assert(rust_dbg_static_mut == 4); +} diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 54b6dc2c602..f6c15925598 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -1,7 +1,7 @@ -debug_abi_1 -debug_abi_2 -debug_static_mut -debug_static_mut_check_four +rust_dbg_abi_1 +rust_dbg_abi_2 +rust_dbg_static_mut +rust_dbg_static_mut_check_four get_time rust_tzset rust_gmtime diff --git a/src/test/compile-fail/attrs-after-extern-mod.rs b/src/test/compile-fail/attrs-after-extern-mod.rs index 1903786eef8..3102fb2664f 100644 --- a/src/test/compile-fail/attrs-after-extern-mod.rs +++ b/src/test/compile-fail/attrs-after-extern-mod.rs @@ -16,8 +16,8 @@ use std::libc; #[nolink] extern { - static mut debug_static_mut: libc::c_int; - pub fn debug_static_mut_check_four(); + static mut rust_dbg_static_mut: libc::c_int; + pub fn rust_dbg_static_mut_check_four(); #[cfg(stage37)] //~ ERROR expected item after attributes } diff --git a/src/test/run-pass/static-mut-foreign.rs b/src/test/run-pass/static-mut-foreign.rs index 429b49375e0..0d042d002a1 100644 --- a/src/test/run-pass/static-mut-foreign.rs +++ b/src/test/run-pass/static-mut-foreign.rs @@ -16,8 +16,8 @@ use std::libc; #[nolink] extern { - static mut debug_static_mut: libc::c_int; - pub fn debug_static_mut_check_four(); + static mut rust_dbg_static_mut: libc::c_int; + pub fn rust_dbg_static_mut_check_four(); } unsafe fn static_bound(_: &'static libc::c_int) {} @@ -28,18 +28,18 @@ fn static_bound_set(a: &'static mut libc::c_int) { #[fixed_stack_segment] #[inline(never)] unsafe fn run() { - assert!(debug_static_mut == 3); - debug_static_mut = 4; - assert!(debug_static_mut == 4); - debug_static_mut_check_four(); - debug_static_mut += 1; - assert!(debug_static_mut == 5); - debug_static_mut *= 3; - assert!(debug_static_mut == 15); - debug_static_mut = -3; - assert!(debug_static_mut == -3); - static_bound(&debug_static_mut); - static_bound_set(&mut debug_static_mut); + assert!(rust_dbg_static_mut == 3); + rust_dbg_static_mut = 4; + assert!(rust_dbg_static_mut == 4); + rust_dbg_static_mut_check_four(); + rust_dbg_static_mut += 1; + assert!(rust_dbg_static_mut == 5); + rust_dbg_static_mut *= 3; + assert!(rust_dbg_static_mut == 15); + rust_dbg_static_mut = -3; + assert!(rust_dbg_static_mut == -3); + static_bound(&rust_dbg_static_mut); + static_bound_set(&mut rust_dbg_static_mut); } pub fn main() { diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index 1c39504ba71..3f63902eb31 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -16,8 +16,8 @@ mod rustrt { #[nolink] extern { - pub fn debug_abi_1(q: Quad) -> Quad; - pub fn debug_abi_2(f: Floats) -> Floats; + pub fn rust_dbg_abi_1(q: Quad) -> Quad; + pub fn rust_dbg_abi_2(f: Floats) -> Floats; } } @@ -28,7 +28,7 @@ fn test1() { b: 0xbbbb_bbbb_bbbb_bbbb_u64, c: 0xcccc_cccc_cccc_cccc_u64, d: 0xdddd_dddd_dddd_dddd_u64 }; - let qq = rustrt::debug_abi_1(q); + let qq = rustrt::rust_dbg_abi_1(q); error!("a: %x", qq.a as uint); error!("b: %x", qq.b as uint); error!("c: %x", qq.c as uint); @@ -48,7 +48,7 @@ fn test2() { let f = Floats { a: 1.234567890e-15_f64, b: 0b_1010_1010_u8, c: 1.0987654321e-15_f64 }; - let ff = rustrt::debug_abi_2(f); + let ff = rustrt::rust_dbg_abi_2(f); error!("a: %f", ff.a as float); error!("b: %u", ff.b as uint); error!("c: %f", ff.c as float);