diff options
| author | Simon BD <simon@server> | 2012-10-03 21:47:09 -0500 |
|---|---|---|
| committer | Simon BD <simon@server> | 2012-10-03 21:47:09 -0500 |
| commit | efcd2385ea2389f270ff8ac8bc256636f647b130 (patch) | |
| tree | 7e142ef709bc907a34ab1cb252eef6dcc0e83b91 /src/rt | |
| parent | 44f8a4401ab37a45ba49db56611d77807bcbce35 (diff) | |
| parent | 3ccf6f5932d8223fd6c5cbf7c6ac429ca9e8912a (diff) | |
Merge remote-tracking branch 'original/incoming' into incoming
Conflicts: src/libstd/json.rs src/libstd/sort.rs
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/rust.cpp | 2 | ||||
| -rw-r--r-- | src/rt/rust_builtin.cpp | 22 | ||||
| -rw-r--r-- | src/rt/rust_env.cpp | 5 | ||||
| -rw-r--r-- | src/rt/rust_env.h | 4 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 4 | ||||
| -rw-r--r-- | src/rt/sync/rust_thread.cpp | 12 |
6 files changed, 39 insertions, 10 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp index dc28f624415..11e65347f11 100644 --- a/src/rt/rust.cpp +++ b/src/rt/rust.cpp @@ -86,7 +86,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) { // Load runtime configuration options from the environment. // FIXME #1497: Should provide a way to get these from the command // line as well. - rust_env *env = load_env(); + rust_env *env = load_env(argc, argv); global_crate_map = crate_map; diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 91c5760d3e9..5baa95c7323 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -180,6 +180,11 @@ rand_new_seeded(rust_vec_box* seed) { return rctx; } +extern "C" CDECL void * +rand_new_seeded2(rust_vec_box** seed) { + return rand_new_seeded(*seed); +} + extern "C" CDECL size_t rand_next(randctx *rctx) { return isaac_rand(rctx); @@ -371,6 +376,11 @@ rust_list_files(rust_str *path) { return vec; } +extern "C" CDECL rust_vec_box* +rust_list_files2(rust_str **path) { + return rust_list_files(*path); +} + extern "C" CDECL int rust_path_is_dir(char *path) { struct stat buf; @@ -578,6 +588,18 @@ rust_num_threads() { return task->kernel->env->num_sched_threads; } +extern "C" CDECL int +rust_get_argc() { + rust_task *task = rust_get_current_task(); + return task->kernel->env->argc; +} + +extern "C" CDECL char** +rust_get_argv() { + rust_task *task = rust_get_current_task(); + return task->kernel->env->argv; +} + extern "C" CDECL rust_sched_id rust_new_sched(uintptr_t threads) { rust_task *task = rust_get_current_task(); diff --git a/src/rt/rust_env.cpp b/src/rt/rust_env.cpp index a54dc27c71f..4e653c8f9e6 100644 --- a/src/rt/rust_env.cpp +++ b/src/rt/rust_env.cpp @@ -107,7 +107,7 @@ copyenv(const char* name) { } rust_env* -load_env() { +load_env(int argc, char **argv) { rust_env *env = (rust_env*)malloc(sizeof(rust_env)); env->num_sched_threads = (size_t)get_num_threads(); @@ -118,7 +118,8 @@ load_env() { 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; return env; } diff --git a/src/rt/rust_env.h b/src/rt/rust_env.h index 007ac9b1e0b..0e3af9eae60 100644 --- a/src/rt/rust_env.h +++ b/src/rt/rust_env.h @@ -13,9 +13,11 @@ struct rust_env { bool detailed_leaks; char* rust_seed; bool poison_on_free; + int argc; + char **argv; }; -rust_env* load_env(); +rust_env* load_env(int argc, char **argv); void free_env(rust_env *rust_env); #endif diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 43f24f4dd4f..7412f06d8cd 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -27,9 +27,12 @@ rust_port_select rand_free rand_new rand_new_seeded +rand_new_seeded2 rand_next rand_seed rust_get_sched_id +rust_get_argc +rust_get_argv rust_new_sched rust_new_task_in_sched rust_num_threads @@ -40,6 +43,7 @@ rust_get_stdin rust_get_stdout rust_get_stderr rust_list_files +rust_list_files2 rust_log_console_on rust_log_console_off rust_port_begin_detach diff --git a/src/rt/sync/rust_thread.cpp b/src/rt/sync/rust_thread.cpp index 5d533acde3d..02fecd440f8 100644 --- a/src/rt/sync/rust_thread.cpp +++ b/src/rt/sync/rust_thread.cpp @@ -32,10 +32,10 @@ rust_thread::start() { thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL); #else pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, stack_sz); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - pthread_create(&thread, &attr, rust_thread_start, (void *) this); + CHECKED(pthread_attr_init(&attr)); + CHECKED(pthread_attr_setstacksize(&attr, stack_sz)); + CHECKED(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE)); + CHECKED(pthread_create(&thread, &attr, rust_thread_start, (void *) this)); #endif } @@ -46,7 +46,7 @@ rust_thread::join() { WaitForSingleObject(thread, INFINITE); #else if (thread) - pthread_join(thread, NULL); + CHECKED(pthread_join(thread, NULL)); #endif thread = 0; } @@ -56,6 +56,6 @@ rust_thread::detach() { #if !defined(__WIN32__) // Don't leak pthread resources. // http://crosstantine.blogspot.com/2010/01/pthreadcreate-memory-leak.html - pthread_detach(thread); + CHECKED(pthread_detach(thread)); #endif } |
