Skip to content

Rm more oldrt crud #8433

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

Closed
wants to merge 10 commits into from
Closed
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
2 changes: 0 additions & 2 deletions mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ RUNTIME_CXXS_$(1)_$(2) := \
rt/sync/rust_thread.cpp \
rt/rust_builtin.cpp \
rt/rust_run_program.cpp \
rt/rust_env.cpp \
rt/rust_rng.cpp \
rt/rust_stack.cpp \
rt/rust_upcall.cpp \
rt/rust_uv.cpp \
rt/rust_crate_map.cpp \
Expand Down
90 changes: 42 additions & 48 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,27 @@ pub enum LangItem {

StrEqFnLangItem, // 19
UniqStrEqFnLangItem, // 20
AnnihilateFnLangItem, // 21
LogTypeFnLangItem, // 22
FailFnLangItem, // 23
FailBoundsCheckFnLangItem, // 24
ExchangeMallocFnLangItem, // 25
ClosureExchangeMallocFnLangItem, // 26
ExchangeFreeFnLangItem, // 27
MallocFnLangItem, // 28
FreeFnLangItem, // 29
BorrowAsImmFnLangItem, // 30
BorrowAsMutFnLangItem, // 31
ReturnToMutFnLangItem, // 32
CheckNotBorrowedFnLangItem, // 33
StrDupUniqFnLangItem, // 34
RecordBorrowFnLangItem, // 35
UnrecordBorrowFnLangItem, // 36

StartFnLangItem, // 37

TyDescStructLangItem, // 38
TyVisitorTraitLangItem, // 39
OpaqueStructLangItem, // 40
LogTypeFnLangItem, // 21
FailFnLangItem, // 22
FailBoundsCheckFnLangItem, // 23
ExchangeMallocFnLangItem, // 24
ClosureExchangeMallocFnLangItem, // 25
ExchangeFreeFnLangItem, // 26
MallocFnLangItem, // 27
FreeFnLangItem, // 28
BorrowAsImmFnLangItem, // 29
BorrowAsMutFnLangItem, // 30
ReturnToMutFnLangItem, // 31
CheckNotBorrowedFnLangItem, // 32
StrDupUniqFnLangItem, // 33
RecordBorrowFnLangItem, // 34
UnrecordBorrowFnLangItem, // 35

StartFnLangItem, // 36

TyDescStructLangItem, // 37
TyVisitorTraitLangItem, // 38
OpaqueStructLangItem, // 39
}

pub struct LanguageItems {
Expand Down Expand Up @@ -122,28 +121,27 @@ impl LanguageItems {

19 => "str_eq",
20 => "uniq_str_eq",
21 => "annihilate",
22 => "log_type",
23 => "fail_",
24 => "fail_bounds_check",
25 => "exchange_malloc",
26 => "closure_exchange_malloc",
27 => "exchange_free",
28 => "malloc",
29 => "free",
30 => "borrow_as_imm",
31 => "borrow_as_mut",
32 => "return_to_mut",
33 => "check_not_borrowed",
34 => "strdup_uniq",
35 => "record_borrow",
36 => "unrecord_borrow",

37 => "start",

38 => "ty_desc",
39 => "ty_visitor",
40 => "opaque",
21 => "log_type",
22 => "fail_",
23 => "fail_bounds_check",
24 => "exchange_malloc",
25 => "closure_exchange_malloc",
26 => "exchange_free",
27 => "malloc",
28 => "free",
29 => "borrow_as_imm",
30 => "borrow_as_mut",
31 => "return_to_mut",
32 => "check_not_borrowed",
33 => "strdup_uniq",
34 => "record_borrow",
35 => "unrecord_borrow",

36 => "start",

37 => "ty_desc",
38 => "ty_visitor",
39 => "opaque",

_ => "???"
}
Expand Down Expand Up @@ -226,9 +224,6 @@ impl LanguageItems {
pub fn uniq_str_eq_fn(&self) -> Option<def_id> {
self.items[UniqStrEqFnLangItem as uint]
}
pub fn annihilate_fn(&self) -> Option<def_id> {
self.items[AnnihilateFnLangItem as uint]
}
pub fn log_type_fn(&self) -> Option<def_id> {
self.items[LogTypeFnLangItem as uint]
}
Expand Down Expand Up @@ -327,7 +322,6 @@ impl<'self> LanguageItemCollector<'self> {

item_refs.insert(@"str_eq", StrEqFnLangItem as uint);
item_refs.insert(@"uniq_str_eq", UniqStrEqFnLangItem as uint);
item_refs.insert(@"annihilate", AnnihilateFnLangItem as uint);
item_refs.insert(@"log_type", LogTypeFnLangItem as uint);
item_refs.insert(@"fail_", FailFnLangItem as uint);
item_refs.insert(@"fail_bounds_check",
Expand Down
16 changes: 2 additions & 14 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2906,24 +2906,12 @@ pub fn fill_crate_map(ccx: @mut CrateContext, map: ValueRef) {
}
subcrates.push(C_int(ccx, 0));

let llannihilatefn = match ccx.tcx.lang_items.annihilate_fn() {
Some(annihilate_def_id) => {
if annihilate_def_id.crate == ast::LOCAL_CRATE {
get_item_val(ccx, annihilate_def_id.node)
} else {
let annihilate_fn_type = csearch::get_type(ccx.tcx,
annihilate_def_id).ty;
trans_external_path(ccx, annihilate_def_id, annihilate_fn_type)
}
}
None => { C_null(Type::i8p()) }
};

unsafe {
let mod_map = create_module_map(ccx);
llvm::LLVMSetInitializer(map, C_struct(
[C_i32(1),
lib::llvm::llvm::LLVMConstPointerCast(llannihilatefn, Type::i8p().to_ref()),
// FIXME #8431 This used to be the annihilate function, now it's nothing
C_null(Type::i8p()),
p2i(ccx, mod_map),
C_array(ccx.int_type, subcrates)]));
}
Expand Down
5 changes: 0 additions & 5 deletions src/libstd/unstable/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ pub unsafe fn check_not_borrowed(a: *u8,
borrowck::check_not_borrowed(a, file, line)
}

#[lang="annihilate"]
pub unsafe fn annihilate() {
::cleanup::annihilate()
}

#[lang="start"]
pub fn start(main: *u8, argc: int, argv: **c_char,
crate_map: *u8) -> int {
Expand Down
1 change: 0 additions & 1 deletion src/rt/boxed_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "memory_region.h"
#include "boxed_region.h"
#include "rust_globals.h"
#include "rust_env.h"
#include "rust_util.h"

// #define DUMP_BOXED_REGION
Expand Down
64 changes: 63 additions & 1 deletion src/rt/rust_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,47 @@ rust_running_on_valgrind() {
return RUNNING_ON_VALGRIND;
}

extern int get_num_cpus();
#if defined(__WIN32__)
int
get_num_cpus() {
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);

return (int) sysinfo.dwNumberOfProcessors;
}
#elif defined(__BSD__)
int
get_num_cpus() {
/* swiped from http://stackoverflow.com/questions/150355/
programmatically-find-the-number-of-cores-on-a-machine */

unsigned int numCPU;
int mib[4];
size_t len = sizeof(numCPU);

/* set the mib for hw.ncpu */
mib[0] = CTL_HW;
mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU;

/* get the number of CPUs from the system */
sysctl(mib, 2, &numCPU, &len, NULL, 0);

if( numCPU < 1 ) {
mib[1] = HW_NCPU;
sysctl( mib, 2, &numCPU, &len, NULL, 0 );

if( numCPU < 1 ) {
numCPU = 1;
}
}
return numCPU;
}
#elif defined(__GNUC__)
int
get_num_cpus() {
return sysconf(_SC_NPROCESSORS_ONLN);
}
#endif

extern "C" CDECL uintptr_t
rust_get_num_cpus() {
Expand Down Expand Up @@ -629,6 +669,28 @@ rust_get_task() {
return 0;
}

static lock_and_signal env_lock;

extern "C" CDECL void
rust_take_env_lock() {
env_lock.lock();
}

extern "C" CDECL void
rust_drop_env_lock() {
env_lock.unlock();
}

extern "C" CDECL unsigned int
rust_valgrind_stack_register(void *start, void *end) {
return VALGRIND_STACK_REGISTER(start, end);
}

extern "C" CDECL void
rust_valgrind_stack_deregister(unsigned int id) {
VALGRIND_STACK_DEREGISTER(id);
}

//
// Local Variables:
// mode: C++
Expand Down
Loading