Skip to content

rt: Namespace all C functions under rust_ #10440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pub mod rustrt {
use super::Tm;

extern {
pub fn get_time(sec: &mut i64, nsec: &mut i32);
pub fn precise_time_ns(ns: &mut u64);
pub fn rust_get_time(sec: &mut i64, nsec: &mut i32);
pub fn rust_precise_time_ns(ns: &mut u64);
pub fn rust_tzset();
pub fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
pub fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
Expand Down Expand Up @@ -66,7 +66,7 @@ pub fn get_time() -> Timespec {
unsafe {
let mut sec = 0i64;
let mut nsec = 0i32;
rustrt::get_time(&mut sec, &mut nsec);
rustrt::rust_get_time(&mut sec, &mut nsec);
return Timespec::new(sec, nsec);
}
}
Expand All @@ -79,7 +79,7 @@ pub fn get_time() -> Timespec {
pub fn precise_time_ns() -> u64 {
unsafe {
let mut ns = 0u64;
rustrt::precise_time_ns(&mut ns);
rustrt::rust_precise_time_ns(&mut ns);
ns
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ impl Drop for BasicPausible {

fn time() -> Time {
extern {
fn get_time(sec: &mut i64, nsec: &mut i32);
fn rust_get_time(sec: &mut i64, nsec: &mut i32);
}
let mut sec = 0;
let mut nsec = 0;
unsafe { get_time(&mut sec, &mut nsec) }
unsafe { rust_get_time(&mut sec, &mut nsec) }

Time { sec: sec as u64, nsec: nsec as u64 }
}
12 changes: 6 additions & 6 deletions src/libstd/rt/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Context {
// which we will then modify to call the given function when restored
let mut regs = new_regs();
unsafe {
swap_registers(transmute_mut_region(&mut *regs), transmute_region(&*regs));
rust_swap_registers(transmute_mut_region(&mut *regs), transmute_region(&*regs));
};

initialize_call_frame(&mut *regs, fp, argp, sp);
Expand Down Expand Up @@ -104,22 +104,22 @@ impl Context {
// stack limit in the OS-specified TLS slot. This also means that
// we cannot call any more rust functions after record_stack_bounds
// returns because they would all likely fail due to the limit being
// invalid for the current task. Lucky for us `swap_registers` is a
// C function so we don't have to worry about that!
// invalid for the current task. Lucky for us `rust_swap_registers`
// is a C function so we don't have to worry about that!
match in_context.stack_bounds {
Some((lo, hi)) => record_stack_bounds(lo, hi),
// If we're going back to one of the original contexts or
// something that's possibly not a "normal task", then reset
// the stack limit to 0 to make morestack never fail
None => record_stack_bounds(0, uint::max_value),
}
swap_registers(out_regs, in_regs)
rust_swap_registers(out_regs, in_regs)
}
}
}

extern {
fn swap_registers(out_regs: *mut Registers, in_regs: *Registers);
fn rust_swap_registers(out_regs: *mut Registers, in_regs: *Registers);
}

// Register contexts used in various architectures
Expand All @@ -142,7 +142,7 @@ extern {
//
// These structures/functions are roughly in-sync with the source files inside
// of src/rt/arch/$arch. The only currently used function from those folders is
// the `swap_registers` function, but that's only because for now segmented
// the `rust_swap_registers` function, but that's only because for now segmented
// stacks are disabled.

#[cfg(target_arch = "x86")]
Expand Down
4 changes: 2 additions & 2 deletions src/rt/arch/arm/_context.S
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
.align
#endif

.globl swap_registers
swap_registers:
.globl rust_swap_registers
rust_swap_registers:
str r0, [r0, #0]
str r3, [r0, #12]
str r4, [r0, #16]
Expand Down
4 changes: 2 additions & 2 deletions src/rt/arch/i386/_context.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ The registers_t variable is in (%esp)
*/

#if defined(__APPLE__) || defined(_WIN32)
#define SWAP_REGISTERS _swap_registers
#define SWAP_REGISTERS _rust_swap_registers
#else
#define SWAP_REGISTERS swap_registers
#define SWAP_REGISTERS rust_swap_registers
#endif

// swap_registers(registers_t *oregs, registers_t *regs)
Expand Down
8 changes: 4 additions & 4 deletions src/rt/arch/mips/_context.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

.text
.globl swap_registers
.globl rust_swap_registers
.align 2
.set nomips16
.ent swap_registers
swap_registers:
.ent rust_swap_registers
rust_swap_registers:
.set noreorder
.set nomacro
.set noat
Expand Down Expand Up @@ -85,4 +85,4 @@ swap_registers:

jr $31
nop
.end swap_registers
.end rust_swap_registers
4 changes: 2 additions & 2 deletions src/rt/arch/x86_64/_context.S
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ First four arguments:
*/

#if defined(__APPLE__)
#define SWAP_REGISTERS _swap_registers
#define SWAP_REGISTERS _rust_swap_registers
#else
#define SWAP_REGISTERS swap_registers
#define SWAP_REGISTERS rust_swap_registers
#endif

// swap_registers(registers_t *oregs, registers_t *regs)
Expand Down
6 changes: 3 additions & 3 deletions src/rt/rust_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extern "C" CDECL FILE* rust_get_stderr() {return stderr;}

#if defined(__WIN32__)
extern "C" CDECL void
get_time(int64_t *sec, int32_t *nsec) {
rust_get_time(int64_t *sec, int32_t *nsec) {
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);

Expand All @@ -187,7 +187,7 @@ get_time(int64_t *sec, int32_t *nsec) {
}
#else
extern "C" CDECL void
get_time(int64_t *sec, int32_t *nsec) {
rust_get_time(int64_t *sec, int32_t *nsec) {
#ifdef __APPLE__
struct timeval tv;
gettimeofday(&tv, NULL);
Expand All @@ -205,7 +205,7 @@ get_time(int64_t *sec, int32_t *nsec) {
const int64_t ns_per_s = 1000000000LL;

extern "C" CDECL void
precise_time_ns(uint64_t *ns) {
rust_precise_time_ns(uint64_t *ns) {

#ifdef __APPLE__
uint64_t time = mach_absolute_time();
Expand Down
6 changes: 3 additions & 3 deletions src/rt/rustrt.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ rust_dbg_abi_1
rust_dbg_abi_2
rust_dbg_static_mut
rust_dbg_static_mut_check_four
get_time
rust_get_time
rust_tzset
rust_gmtime
rust_localtime
rust_timegm
rust_mktime
precise_time_ns
rust_precise_time_ns
rust_path_is_dir
rust_path_is_dir_u16
rust_path_exists
Expand Down Expand Up @@ -43,7 +43,7 @@ rust_signal_little_lock
rust_wait_little_lock
tdefl_compress_mem_to_heap
tinfl_decompress_mem_to_heap
swap_registers
rust_swap_registers
rust_readdir
rust_opendir
rust_dbg_extern_identity_u32
Expand Down