mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
auto merge of #8433 : brson/rust/rm-more-oldrt-crud, r=brson
Just deleting more stuff.
This commit is contained in:
commit
cb8a231eb8
2
mk/rt.mk
2
mk/rt.mk
@ -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 \
|
||||
|
@ -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
|
||||
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, // 37
|
||||
StartFnLangItem, // 36
|
||||
|
||||
TyDescStructLangItem, // 38
|
||||
TyVisitorTraitLangItem, // 39
|
||||
OpaqueStructLangItem, // 40
|
||||
TyDescStructLangItem, // 37
|
||||
TyVisitorTraitLangItem, // 38
|
||||
OpaqueStructLangItem, // 39
|
||||
}
|
||||
|
||||
pub struct LanguageItems {
|
||||
@ -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",
|
||||
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",
|
||||
|
||||
37 => "start",
|
||||
36 => "start",
|
||||
|
||||
38 => "ty_desc",
|
||||
39 => "ty_visitor",
|
||||
40 => "opaque",
|
||||
37 => "ty_desc",
|
||||
38 => "ty_visitor",
|
||||
39 => "opaque",
|
||||
|
||||
_ => "???"
|
||||
}
|
||||
@ -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]
|
||||
}
|
||||
@ -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",
|
||||
|
@ -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)]));
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
@ -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++
|
||||
|
@ -1,163 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// The runtime wants to pull a number of variables out of the
|
||||
// environment but calling getenv is not threadsafe, so every value
|
||||
// that might come from the environment is loaded here, once, during
|
||||
// init.
|
||||
|
||||
#include "sync/lock_and_signal.h"
|
||||
#include "rust_env.h"
|
||||
|
||||
// The environment variables that the runtime knows about
|
||||
#define RUST_THREADS "RUST_THREADS"
|
||||
#define RUST_MIN_STACK "RUST_MIN_STACK"
|
||||
#define RUST_MAX_STACK "RUST_MAX_STACK"
|
||||
#define RUST_LOG "RUST_LOG"
|
||||
#define DETAILED_LEAKS "DETAILED_LEAKS"
|
||||
#define RUST_SEED "RUST_SEED"
|
||||
#define RUST_POISON_ON_FREE "RUST_POISON_ON_FREE"
|
||||
#define RUST_DEBUG_MEM "RUST_DEBUG_MEM"
|
||||
#define RUST_DEBUG_BORROW "RUST_DEBUG_BORROW"
|
||||
|
||||
#define DEFAULT_RUST_MIN_STACK_32 0x300
|
||||
#define DEFAULT_RUST_MIN_STACK_64 0x400000
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
static int
|
||||
get_num_threads()
|
||||
{
|
||||
char *env = getenv(RUST_THREADS);
|
||||
if(env) {
|
||||
int num = atoi(env);
|
||||
if(num > 0)
|
||||
return num;
|
||||
}
|
||||
return get_num_cpus();
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_min_stk_size() {
|
||||
char *minsz = getenv(RUST_MIN_STACK);
|
||||
if(minsz) {
|
||||
return strtol(minsz, NULL, 0);
|
||||
}
|
||||
else if (sizeof(size_t) > 4) {
|
||||
return DEFAULT_RUST_MIN_STACK_64;
|
||||
} else {
|
||||
return DEFAULT_RUST_MIN_STACK_32;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t
|
||||
get_max_stk_size() {
|
||||
char *maxsz = getenv(RUST_MAX_STACK);
|
||||
if (maxsz) {
|
||||
return strtol(maxsz, NULL, 0);
|
||||
}
|
||||
else {
|
||||
return 1024*1024*1024;
|
||||
}
|
||||
}
|
||||
|
||||
static char*
|
||||
copyenv(const char* name) {
|
||||
char *envvar = getenv(name);
|
||||
if (!envvar) {
|
||||
return NULL;
|
||||
} else {
|
||||
size_t slen = strlen(envvar);
|
||||
size_t buflen = slen + 1;
|
||||
char *var = (char*)malloc(buflen);
|
||||
memset(var, 0, buflen);
|
||||
strncpy(var, envvar, slen);
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
rust_env*
|
||||
load_env(int argc, char **argv) {
|
||||
scoped_lock with(env_lock);
|
||||
|
||||
rust_env *env = (rust_env*)malloc(sizeof(rust_env));
|
||||
|
||||
env->num_sched_threads = (size_t)get_num_threads();
|
||||
env->min_stack_size = get_min_stk_size();
|
||||
env->max_stack_size = get_max_stk_size();
|
||||
env->logspec = copyenv(RUST_LOG);
|
||||
env->detailed_leaks = getenv(DETAILED_LEAKS) != NULL;
|
||||
env->rust_seed = copyenv(RUST_SEED);
|
||||
env->poison_on_free = getenv(RUST_POISON_ON_FREE) != NULL;
|
||||
env->argc = argc;
|
||||
env->argv = argv;
|
||||
env->debug_mem = getenv(RUST_DEBUG_MEM) != NULL;
|
||||
env->debug_borrow = getenv(RUST_DEBUG_BORROW) != NULL;
|
||||
return env;
|
||||
}
|
||||
|
||||
void
|
||||
free_env(rust_env *env) {
|
||||
free(env->logspec);
|
||||
free(env->rust_seed);
|
||||
free(env);
|
||||
}
|
@ -1,37 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
#ifndef RUST_ENV_H
|
||||
#define RUST_ENV_H
|
||||
|
||||
#include "rust_globals.h"
|
||||
|
||||
// Avoiding 'bool' type here since I'm not sure it has a standard size
|
||||
typedef uint8_t rust_bool;
|
||||
|
||||
struct rust_env {
|
||||
size_t num_sched_threads;
|
||||
size_t min_stack_size;
|
||||
size_t max_stack_size;
|
||||
char* logspec;
|
||||
rust_bool detailed_leaks;
|
||||
char* rust_seed;
|
||||
rust_bool poison_on_free;
|
||||
int argc;
|
||||
char **argv;
|
||||
rust_bool debug_mem;
|
||||
rust_bool debug_borrow;
|
||||
};
|
||||
|
||||
rust_env* load_env(int argc, char **argv);
|
||||
void free_env(rust_env *rust_env);
|
||||
|
||||
#endif
|
@ -81,15 +81,12 @@ extern "C" {
|
||||
#define CDECL __cdecl
|
||||
#endif
|
||||
#ifndef FASTCALL
|
||||
#define FASTCALL __fastcall
|
||||
#endif
|
||||
#else
|
||||
#define CDECL __attribute__((cdecl))
|
||||
#define FASTCALL __attribute__((fastcall))
|
||||
#endif
|
||||
#else
|
||||
#define CDECL
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
#define CHECKED(call) \
|
||||
@ -104,22 +101,4 @@ extern "C" {
|
||||
} \
|
||||
}
|
||||
|
||||
#define MUST_CHECK __attribute__((warn_unused_result))
|
||||
|
||||
#define PTR "0x%" PRIxPTR
|
||||
|
||||
// This accounts for logging buffers.
|
||||
static size_t const BUF_BYTES = 2048;
|
||||
|
||||
#define INIT_TASK_ID 1
|
||||
|
||||
// The error status to use when the process fails
|
||||
#define PROC_FAIL_CODE 101
|
||||
|
||||
// A cond(ition) is something we can block on. This can be a channel
|
||||
// (writing), a port (reading) or a task (waiting).
|
||||
struct rust_cond { };
|
||||
|
||||
extern void* global_crate_map;
|
||||
|
||||
#endif /* RUST_GLOBALS_H */
|
||||
|
@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "rust_log.h"
|
||||
#include "rust_crate_map.h"
|
||||
#include "util/array_list.h"
|
||||
#include "rust_util.h"
|
||||
@ -25,6 +24,12 @@ struct log_directive {
|
||||
size_t level;
|
||||
};
|
||||
|
||||
|
||||
const uint32_t log_err = 1;
|
||||
const uint32_t log_warn = 2;
|
||||
const uint32_t log_info = 3;
|
||||
const uint32_t log_debug = 4;
|
||||
|
||||
const size_t max_log_directives = 255;
|
||||
const size_t max_log_level = 255;
|
||||
const size_t default_log_level = log_err;
|
||||
@ -84,12 +89,6 @@ static void update_entry(const mod_entry* entry, void *cookie) {
|
||||
}
|
||||
}
|
||||
|
||||
void update_module_map(const mod_entry* map, log_directive* dirs,
|
||||
size_t n_dirs, size_t *n_matches) {
|
||||
update_entry_args args = { dirs, n_dirs, n_matches };
|
||||
iter_module_map(map, update_entry, &args);
|
||||
}
|
||||
|
||||
void update_crate_map(const cratemap* map, log_directive* dirs,
|
||||
size_t n_dirs, size_t *n_matches) {
|
||||
update_entry_args args = { dirs, n_dirs, n_matches };
|
||||
@ -104,40 +103,6 @@ void print_crate_log_map(const cratemap* map) {
|
||||
iter_crate_map(map, print_mod_name, NULL);
|
||||
}
|
||||
|
||||
// These are pseudo-modules used to control logging in the runtime.
|
||||
|
||||
uint32_t log_rt_mem;
|
||||
uint32_t log_rt_box;
|
||||
uint32_t log_rt_comm;
|
||||
uint32_t log_rt_task;
|
||||
uint32_t log_rt_dom;
|
||||
uint32_t log_rt_trace;
|
||||
uint32_t log_rt_cache;
|
||||
uint32_t log_rt_upcall;
|
||||
uint32_t log_rt_timer;
|
||||
uint32_t log_rt_gc;
|
||||
uint32_t log_rt_stdlib;
|
||||
uint32_t log_rt_kern;
|
||||
uint32_t log_rt_backtrace;
|
||||
uint32_t log_rt_callback;
|
||||
|
||||
static const mod_entry _rt_module_map[] =
|
||||
{{"::rt::mem", &log_rt_mem},
|
||||
{"::rt::box", &log_rt_box},
|
||||
{"::rt::comm", &log_rt_comm},
|
||||
{"::rt::task", &log_rt_task},
|
||||
{"::rt::dom", &log_rt_dom},
|
||||
{"::rt::trace", &log_rt_trace},
|
||||
{"::rt::cache", &log_rt_cache},
|
||||
{"::rt::upcall", &log_rt_upcall},
|
||||
{"::rt::timer", &log_rt_timer},
|
||||
{"::rt::gc", &log_rt_gc},
|
||||
{"::rt::stdlib", &log_rt_stdlib},
|
||||
{"::rt::kern", &log_rt_kern},
|
||||
{"::rt::backtrace", &log_rt_backtrace},
|
||||
{"::rt::callback", &log_rt_callback},
|
||||
{NULL, NULL}};
|
||||
|
||||
void update_log_settings(void* crate_map, char* settings) {
|
||||
char* buffer = NULL;
|
||||
log_directive dirs[256];
|
||||
@ -160,7 +125,6 @@ void update_log_settings(void* crate_map, char* settings) {
|
||||
}
|
||||
|
||||
size_t n_matches = 0;
|
||||
update_module_map(_rt_module_map, &dirs[0], n_dirs, &n_matches);
|
||||
update_crate_map((const cratemap*)crate_map, &dirs[0],
|
||||
n_dirs, &n_matches);
|
||||
|
||||
|
@ -1,38 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#ifndef RUST_LOG_H
|
||||
#define RUST_LOG_H
|
||||
|
||||
#include "rust_globals.h"
|
||||
|
||||
const uint32_t log_err = 1;
|
||||
const uint32_t log_warn = 2;
|
||||
const uint32_t log_info = 3;
|
||||
const uint32_t log_debug = 4;
|
||||
|
||||
void update_log_settings(void* crate_map, char* settings);
|
||||
|
||||
extern uint32_t log_rt_mem;
|
||||
extern uint32_t log_rt_box;
|
||||
extern uint32_t log_rt_comm;
|
||||
extern uint32_t log_rt_task;
|
||||
extern uint32_t log_rt_dom;
|
||||
extern uint32_t log_rt_trace;
|
||||
extern uint32_t log_rt_cache;
|
||||
extern uint32_t log_rt_upcall;
|
||||
extern uint32_t log_rt_timer;
|
||||
extern uint32_t log_rt_gc;
|
||||
extern uint32_t log_rt_stdlib;
|
||||
extern uint32_t log_rt_kern;
|
||||
extern uint32_t log_rt_backtrace;
|
||||
extern uint32_t log_rt_callback;
|
||||
|
||||
#endif /* RUST_LOG_H */
|
@ -1,31 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
#ifndef RUST_REFCOUNT_H
|
||||
#define RUST_REFCOUNT_H
|
||||
|
||||
#include "sync/sync.h"
|
||||
|
||||
// Refcounting defines
|
||||
typedef unsigned long ref_cnt_t;
|
||||
|
||||
#define RUST_ATOMIC_REFCOUNT() \
|
||||
private: \
|
||||
intptr_t ref_count; \
|
||||
public: \
|
||||
void ref() { \
|
||||
intptr_t old = sync::increment(ref_count); \
|
||||
assert(old > 0); \
|
||||
} \
|
||||
void deref() { if(0 == sync::decrement(ref_count)) { delete_this(); } } \
|
||||
intptr_t get_ref_count() { return sync::read(ref_count); }
|
||||
|
||||
#endif
|
@ -1,27 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#ifndef RUST_SIGNAL_H
|
||||
#define RUST_SIGNAL_H
|
||||
|
||||
// Just an abstract class that represents something that can be signalled
|
||||
class rust_signal {
|
||||
public:
|
||||
virtual void signal() = 0;
|
||||
virtual ~rust_signal() {}
|
||||
rust_signal() {}
|
||||
|
||||
private:
|
||||
// private and undefined to disable copying
|
||||
rust_signal(const rust_signal& rhs);
|
||||
rust_signal& operator=(const rust_signal& rhs);
|
||||
};
|
||||
|
||||
#endif /* RUST_SIGNAL_H */
|
@ -1,105 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
#include "rust_stack.h"
|
||||
#include "vg/valgrind.h"
|
||||
#include "vg/memcheck.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#ifdef _LP64
|
||||
const uintptr_t canary_value = 0xABCDABCDABCDABCD;
|
||||
#else
|
||||
const uintptr_t canary_value = 0xABCDABCD;
|
||||
#endif
|
||||
|
||||
void
|
||||
register_valgrind_stack(stk_seg *stk) {
|
||||
stk->valgrind_id =
|
||||
VALGRIND_STACK_REGISTER(&stk->data[0],
|
||||
stk->end);
|
||||
}
|
||||
|
||||
void
|
||||
reuse_valgrind_stack(stk_seg *stk, uint8_t *sp) {
|
||||
// Establish that the stack is accessible. This must be done when reusing
|
||||
// old stack segments, since the act of popping the stack previously
|
||||
// caused valgrind to consider the whole thing inaccessible.
|
||||
assert(sp >= stk->data && sp <= (uint8_t*) stk->end
|
||||
&& "Stack pointer must be inside stack segment");
|
||||
size_t sz = stk->end - (uintptr_t)sp;
|
||||
(void) VALGRIND_MAKE_MEM_UNDEFINED(sp, sz);
|
||||
(void) sz;
|
||||
}
|
||||
|
||||
void
|
||||
deregister_valgrind_stack(stk_seg *stk) {
|
||||
VALGRIND_STACK_DEREGISTER(stk->valgrind_id);
|
||||
}
|
||||
|
||||
void
|
||||
add_stack_canary(stk_seg *stk) {
|
||||
stk->canary = canary_value;
|
||||
}
|
||||
|
||||
void
|
||||
check_stack_canary(stk_seg *stk) {
|
||||
assert(stk->canary == canary_value && "Somebody killed the canary");
|
||||
}
|
||||
|
||||
// XXX: Duplication here between the local and exchange heap constructors
|
||||
|
||||
stk_seg *
|
||||
create_stack(memory_region *region, size_t sz) {
|
||||
size_t total_sz = sizeof(stk_seg) + sz;
|
||||
stk_seg *stk = (stk_seg *)region->malloc(total_sz, "stack");
|
||||
memset(stk, 0, sizeof(stk_seg));
|
||||
stk->end = (uintptr_t) &stk->data[sz];
|
||||
stk->is_big = 0;
|
||||
add_stack_canary(stk);
|
||||
register_valgrind_stack(stk);
|
||||
return stk;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_stack(memory_region *region, stk_seg *stk) {
|
||||
deregister_valgrind_stack(stk);
|
||||
region->free(stk);
|
||||
}
|
||||
|
||||
stk_seg *
|
||||
create_exchange_stack(rust_exchange_alloc *exchange, size_t sz) {
|
||||
size_t total_sz = sizeof(stk_seg) + sz;
|
||||
stk_seg *stk = (stk_seg *)exchange->malloc(total_sz);
|
||||
memset(stk, 0, sizeof(stk_seg));
|
||||
stk->end = (uintptr_t) &stk->data[sz];
|
||||
stk->is_big = 0;
|
||||
add_stack_canary(stk);
|
||||
register_valgrind_stack(stk);
|
||||
return stk;
|
||||
}
|
||||
|
||||
void
|
||||
destroy_exchange_stack(rust_exchange_alloc *exchange, stk_seg *stk) {
|
||||
deregister_valgrind_stack(stk);
|
||||
exchange->free(stk);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
@ -1,54 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#ifndef RUST_STACK_H
|
||||
#define RUST_STACK_H
|
||||
|
||||
#include "rust_globals.h"
|
||||
#include "rust_exchange_alloc.h"
|
||||
#include "memory_region.h"
|
||||
|
||||
struct rust_task;
|
||||
|
||||
struct stk_seg {
|
||||
stk_seg *prev;
|
||||
stk_seg *next;
|
||||
uintptr_t end;
|
||||
unsigned int valgrind_id;
|
||||
uint8_t is_big;
|
||||
|
||||
rust_task *task;
|
||||
uintptr_t canary;
|
||||
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
stk_seg *
|
||||
create_stack(memory_region *region, size_t sz);
|
||||
|
||||
void
|
||||
destroy_stack(memory_region *region, stk_seg *stk);
|
||||
|
||||
stk_seg *
|
||||
create_exchange_stack(rust_exchange_alloc *exchange, size_t sz);
|
||||
|
||||
void
|
||||
destroy_exchange_stack(rust_exchange_alloc *exchange, stk_seg *stk);
|
||||
|
||||
// Must be called before each time a stack is reused to tell valgrind
|
||||
// that the stack is accessible.
|
||||
void
|
||||
reuse_valgrind_stack(stk_seg *stk, uint8_t *sp);
|
||||
|
||||
// Run a sanity check
|
||||
void
|
||||
check_stack_canary(stk_seg *stk);
|
||||
|
||||
#endif /* RUST_STACK_H */
|
@ -13,7 +13,6 @@
|
||||
#define RUST_TYPE_H
|
||||
|
||||
#include "rust_globals.h"
|
||||
#include "rust_refcount.h"
|
||||
|
||||
struct rust_opaque_box;
|
||||
|
||||
@ -28,6 +27,8 @@ struct type_desc;
|
||||
typedef void CDECL (glue_fn)(void *,
|
||||
void *);
|
||||
|
||||
typedef unsigned long ref_cnt_t;
|
||||
|
||||
// Corresponds to the boxed data in the @ region. The body follows the
|
||||
// header; you can obtain a ptr via box_body() below.
|
||||
struct rust_opaque_box {
|
||||
@ -61,8 +62,6 @@ struct type_desc {
|
||||
size_t borrow_offset;
|
||||
};
|
||||
|
||||
extern "C" type_desc *rust_clone_type_desc(type_desc*);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "rust_globals.h"
|
||||
#include "rust_upcall.h"
|
||||
#include "rust_util.h"
|
||||
|
||||
//Unwinding ABI declarations.
|
||||
|
@ -1,14 +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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#ifndef RUST_UPCALL_H
|
||||
#define RUST_UPCALL_H
|
||||
|
||||
#endif
|
@ -14,7 +14,6 @@
|
||||
#include <limits.h>
|
||||
#include "rust_exchange_alloc.h"
|
||||
#include "rust_type.h"
|
||||
#include "rust_env.h"
|
||||
|
||||
extern struct type_desc str_body_tydesc;
|
||||
|
||||
|
@ -17,34 +17,6 @@
|
||||
|
||||
#include "rust_globals.h"
|
||||
|
||||
// extern fn pointers
|
||||
typedef void (*extern_async_op_cb)(uv_loop_t* loop, void* data,
|
||||
uv_async_t* op_handle);
|
||||
typedef void (*extern_simple_cb)(uint8_t* id_buf, void* loop_data);
|
||||
typedef void (*extern_close_cb)(uint8_t* id_buf, void* handle,
|
||||
void* data);
|
||||
|
||||
// data types
|
||||
#define RUST_UV_HANDLE_LEN 16
|
||||
|
||||
struct handle_data {
|
||||
uint8_t id_buf[RUST_UV_HANDLE_LEN];
|
||||
extern_simple_cb cb;
|
||||
extern_close_cb close_cb;
|
||||
};
|
||||
|
||||
static void
|
||||
foreign_timer_cb(uv_timer_t* handle, int status) {
|
||||
handle_data* handle_d = (handle_data*)handle->data;
|
||||
void* loop_data = handle->loop->data;
|
||||
handle_d->cb(handle_d->id_buf, loop_data);
|
||||
}
|
||||
|
||||
static void
|
||||
foreign_close_cb(uv_handle_t* handle) {
|
||||
handle_data* data = (handle_data*)handle->data;
|
||||
data->close_cb(data->id_buf, handle, handle->loop->data);
|
||||
}
|
||||
extern "C" void*
|
||||
rust_uv_loop_new() {
|
||||
return (void*)uv_loop_new();
|
||||
@ -91,13 +63,6 @@ rust_uv_walk(uv_loop_t* loop, uv_walk_cb cb, void* arg) {
|
||||
uv_walk(loop, cb, arg);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
rust_uv_hilvl_close(uv_handle_t* handle, extern_close_cb cb) {
|
||||
handle_data* data = (handle_data*)handle->data;
|
||||
data->close_cb = cb;
|
||||
uv_close(handle, foreign_close_cb);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
rust_uv_async_send(uv_async_t* handle) {
|
||||
uv_async_send(handle);
|
||||
@ -110,12 +75,6 @@ rust_uv_async_init(uv_loop_t* loop_handle,
|
||||
return uv_async_init(loop_handle, async_handle, cb);
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
rust_uv_hilvl_timer_start(uv_timer_t* the_timer, uint32_t timeout,
|
||||
uint32_t repeat) {
|
||||
uv_timer_start(the_timer, foreign_timer_cb, timeout, repeat);
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
rust_uv_timer_init(uv_loop_t* loop, uv_timer_t* timer) {
|
||||
return uv_timer_init(loop, timer);
|
||||
@ -301,58 +260,6 @@ rust_uv_accept(uv_stream_t* server, uv_stream_t* client) {
|
||||
return uv_accept(server, client);
|
||||
}
|
||||
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_tcp_t_size() {
|
||||
return sizeof(uv_tcp_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_connect_t_size() {
|
||||
return sizeof(uv_connect_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_buf_t_size() {
|
||||
return sizeof(uv_buf_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_write_t_size() {
|
||||
return sizeof(uv_write_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_err_t_size() {
|
||||
return sizeof(uv_err_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_sockaddr_in_size() {
|
||||
return sizeof(sockaddr_in);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_sockaddr_in6_size() {
|
||||
return sizeof(sockaddr_in6);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_async_t_size() {
|
||||
return sizeof(uv_async_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_timer_t_size() {
|
||||
return sizeof(uv_timer_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_addr_in_size() {
|
||||
return sizeof(sockaddr_in6);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_uv_getaddrinfo_t_size() {
|
||||
return sizeof(uv_getaddrinfo_t);
|
||||
}
|
||||
extern "C" size_t
|
||||
rust_uv_helper_addrinfo_size() {
|
||||
return sizeof(addrinfo);
|
||||
}
|
||||
extern "C" unsigned int
|
||||
rust_uv_helper_get_INADDR_NONE() {
|
||||
return INADDR_NONE;
|
||||
}
|
||||
extern "C" uv_stream_t*
|
||||
rust_uv_get_stream_handle_from_connect_req(uv_connect_t* connect) {
|
||||
return connect->handle;
|
||||
|
@ -40,10 +40,8 @@ rust_uv_walk
|
||||
rust_uv_loop_set_data
|
||||
rust_uv_run
|
||||
rust_uv_close
|
||||
rust_uv_hilvl_close
|
||||
rust_uv_async_send
|
||||
rust_uv_async_init
|
||||
rust_uv_hilvl_timer_start
|
||||
rust_uv_timer_init
|
||||
rust_uv_timer_start
|
||||
rust_uv_timer_stop
|
||||
@ -92,19 +90,6 @@ rust_uv_is_ipv6_addrinfo
|
||||
rust_uv_get_next_addrinfo
|
||||
rust_uv_addrinfo_as_sockaddr_in
|
||||
rust_uv_addrinfo_as_sockaddr_in6
|
||||
rust_uv_helper_uv_tcp_t_size
|
||||
rust_uv_helper_uv_connect_t_size
|
||||
rust_uv_helper_uv_buf_t_size
|
||||
rust_uv_helper_uv_write_t_size
|
||||
rust_uv_helper_uv_err_t_size
|
||||
rust_uv_helper_sockaddr_in_size
|
||||
rust_uv_helper_sockaddr_in6_size
|
||||
rust_uv_helper_addr_in_size
|
||||
rust_uv_helper_addrinfo_size
|
||||
rust_uv_helper_uv_getaddrinfo_t_size
|
||||
rust_uv_helper_get_INADDR_NONE
|
||||
rust_uv_helper_uv_async_t_size
|
||||
rust_uv_helper_uv_timer_t_size
|
||||
rust_uv_get_stream_handle_from_connect_req
|
||||
rust_uv_get_stream_handle_from_write_req
|
||||
rust_uv_get_loop_for_uv_handle
|
||||
|
Loading…
Reference in New Issue
Block a user