From 0a1baef4f57b4ac8558a65b7bd8dc787ebf54840 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 22:29:04 -0700 Subject: rt: Remove timer --- src/rt/rust_test_helpers.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/rt/rust_test_helpers.cpp') diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp index b0aab9672ea..b9be4f1e251 100644 --- a/src/rt/rust_test_helpers.cpp +++ b/src/rt/rust_test_helpers.cpp @@ -11,7 +11,6 @@ // Helper functions used only in tests #include "rust_util.h" -#include "sync/timer.h" #include "sync/rust_thread.h" #include "sync/lock_and_signal.h" #include "rust_abi.h" -- cgit 1.4.1-3-g733a5 From c17447f8b30a11ce6624c7088f647a6261c70135 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 22:57:40 -0700 Subject: rt: Move some test functions to rust_test_helpers --- src/rt/rust_builtin.cpp | 47 ------------------------- src/rt/rust_test_helpers.cpp | 46 ++++++++++++++++++++++++ src/rt/rustrt.def.in | 8 ++--- src/test/compile-fail/attrs-after-extern-mod.rs | 4 +-- src/test/run-pass/static-mut-foreign.rs | 28 +++++++-------- src/test/run-pass/struct-return.rs | 8 ++--- 6 files changed, 70 insertions(+), 71 deletions(-) (limited to 'src/rt/rust_test_helpers.cpp') 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); -- cgit 1.4.1-3-g733a5 From 9cdfe1e6039598961838ba2cc88a6ed6aa5449bf Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 23:30:25 -0700 Subject: rt: Remove rust_abi --- mk/rt.mk | 1 - src/rt/rust_abi.cpp | 88 -------------------------------------------- src/rt/rust_abi.h | 78 --------------------------------------- src/rt/rust_builtin.cpp | 1 - src/rt/rust_test_helpers.cpp | 1 - 5 files changed, 169 deletions(-) delete mode 100644 src/rt/rust_abi.cpp delete mode 100644 src/rt/rust_abi.h (limited to 'src/rt/rust_test_helpers.cpp') diff --git a/mk/rt.mk b/mk/rt.mk index f4b0132ded8..6a9620c7364 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -74,7 +74,6 @@ RUNTIME_CXXS_$(1)_$(2) := \ rt/rust_log.cpp \ rt/isaac/randport.cpp \ rt/miniz.cpp \ - rt/rust_abi.cpp \ rt/memory_region.cpp \ rt/boxed_region.cpp \ rt/arch/$$(HOST_$(1))/context.cpp \ diff --git a/src/rt/rust_abi.cpp b/src/rt/rust_abi.cpp deleted file mode 100644 index fd1b7860b29..00000000000 --- a/src/rt/rust_abi.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ABI-specific routines. - -#include -#include -#include -#include -#include -#include "rust_abi.h" - -#if defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__) -#define HAVE_DLFCN_H -#include -#elif defined(_WIN32) -// Otherwise it's windows.h -- included in rust_abi.h -#endif - -#define END_OF_STACK_RA (void (*)())0xdeadbeef - -weak_symbol abi_version("rust_abi_version"); - -uint32_t get_abi_version() { - return (*abi_version == NULL) ? 0 : **abi_version; -} - -namespace stack_walk { - -#ifdef HAVE_DLFCN_H -std::string -frame::symbol() const { - std::stringstream ss; - - Dl_info info; - if (!dladdr((void *)ra, &info)) - ss << "??"; - else - ss << info.dli_sname; - - ss << " @ " << std::hex << (uintptr_t)ra; - return ss.str(); -} -#else -std::string -frame::symbol() const { - std::stringstream ss; - ss << std::hex << (uintptr_t)ra; - return ss.str(); -} -#endif - -std::vector -backtrace() { - std::vector frames; - - // Ideally we would use the current value of EIP here, but there's no - // portable way to get that and there are never any GC roots in our C++ - // frames anyhow. - frame f(__builtin_frame_address(0), (void (*)())NULL); - - while (f.ra != END_OF_STACK_RA) { - frames.push_back(f); - f.next(); - } - return frames; -} - -std::string -symbolicate(const std::vector &frames) { - std::stringstream ss; - std::vector::const_iterator begin(frames.begin()), - end(frames.end()); - while (begin != end) { - ss << begin->symbol() << std::endl; - ++begin; - } - return ss.str(); -} - -} // end namespace stack_walk diff --git a/src/rt/rust_abi.h b/src/rt/rust_abi.h deleted file mode 100644 index 4179bf75157..00000000000 --- a/src/rt/rust_abi.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ABI-specific routines. - -#ifndef RUST_ABI_H -#define RUST_ABI_H - -#include -#include -#include -#include - -#ifdef __WIN32__ -#include -#else -#include -#endif - -template -class weak_symbol { -private: - bool init; - T *data; - const char *name; - - void fill() { - if (init) - return; - -#ifdef __WIN32__ - data = (T *)GetProcAddress(GetModuleHandle(NULL), name); -#else - data = (T *)dlsym(RTLD_DEFAULT, name); -#endif - - init = true; - } - -public: - weak_symbol(const char *in_name) - : init(false), data(NULL), name(in_name) {} - - T *&operator*() { fill(); return data; } -}; - -namespace stack_walk { - -struct frame { - uint8_t *bp; // The frame pointer. - void (*ra)(); // The return address. - - frame(void *in_bp, void (*in_ra)()) : bp((uint8_t *)in_bp), ra(in_ra) {} - - inline void next() { - ra = *(void (**)())(bp + sizeof(void *)); - bp = *(uint8_t **)bp; - } - - std::string symbol() const; -}; - -std::vector backtrace(); -std::string symbolicate(const std::vector &frames); - -} // end namespace stack_walk - - -uint32_t get_abi_version(); - -#endif diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index ff4975fdcd8..6f3a3bd3686 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -15,7 +15,6 @@ #include "sync/lock_and_signal.h" #include "memory_region.h" #include "boxed_region.h" -#include "rust_abi.h" #include "rust_rng.h" #include "vg/valgrind.h" #include "sp.h" diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp index 33fea72cca7..f10a1f36938 100644 --- a/src/rt/rust_test_helpers.cpp +++ b/src/rt/rust_test_helpers.cpp @@ -13,7 +13,6 @@ #include "rust_util.h" #include "sync/rust_thread.h" #include "sync/lock_and_signal.h" -#include "rust_abi.h" // These functions are used in the unit tests for C ABI calls. -- cgit 1.4.1-3-g733a5