From 21064637ed8b8259d1305f21ace12c40b9561706 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 31 Mar 2012 23:12:06 -0700 Subject: [PATCH] rt: Fix whitespace --- src/rt/arch/x86_64/context.h | 6 +- src/rt/memory_region.h | 1 - src/rt/rust_box_annihilator.cpp | 5 +- src/rt/rust_cc.cpp | 6 +- src/rt/rust_env.cpp | 4 +- src/rt/rust_kernel.cpp | 3 +- src/rt/rust_port_selector.cpp | 8 +-- src/rt/rust_port_selector.h | 8 +-- src/rt/rust_scheduler.cpp | 10 +-- src/rt/rust_scheduler.h | 2 +- src/rt/rust_shape.cpp | 10 +-- src/rt/rust_shape.h | 7 ++- src/rt/rust_stack.cpp | 2 +- src/rt/rust_task.cpp | 8 ++- src/rt/rust_task.h | 2 +- src/rt/rust_task_thread.cpp | 6 +- src/rt/rust_upcall.cpp | 5 +- src/rt/rust_util.h | 6 +- src/rt/rust_uv.cpp | 106 ++++++++++++++++---------------- src/rt/sync/lock_and_signal.cpp | 3 +- 20 files changed, 109 insertions(+), 99 deletions(-) diff --git a/src/rt/arch/x86_64/context.h b/src/rt/arch/x86_64/context.h index 412d968599f..4101e82cc40 100644 --- a/src/rt/arch/x86_64/context.h +++ b/src/rt/arch/x86_64/context.h @@ -31,11 +31,11 @@ struct registers_t { class context { public: registers_t regs; - + context(); - + context *next; - + void swap(context &out); void call(void *f, void *arg, void *sp); }; diff --git a/src/rt/memory_region.h b/src/rt/memory_region.h index 57108ae58a8..68b4165edc6 100644 --- a/src/rt/memory_region.h +++ b/src/rt/memory_region.h @@ -41,7 +41,6 @@ private: inline alloc_header *get_header(void *mem); inline void *get_data(alloc_header *); - rust_srv *_srv; memory_region *_parent; diff --git a/src/rt/rust_box_annihilator.cpp b/src/rt/rust_box_annihilator.cpp index 8420c709296..b5abfde0274 100644 --- a/src/rt/rust_box_annihilator.cpp +++ b/src/rt/rust_box_annihilator.cpp @@ -58,7 +58,8 @@ class annihilator : public shape::data { } void walk_tag2(shape::tag_info &tinfo, uint32_t tag_variant) { - shape::data::walk_variant1(tinfo, tag_variant); + shape::data + ::walk_variant1(tinfo, tag_variant); } void walk_uniq2() { @@ -83,7 +84,7 @@ class annihilator : public shape::data { if (pair.env) { // free closed over data: shape::data::walk_fn_contents1(); - + // now free the ptr: task->kernel->free(pair.env); } diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp index 7403c077d5d..b0a1804d096 100644 --- a/src/rt/rust_cc.cpp +++ b/src/rt/rust_cc.cpp @@ -210,11 +210,11 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) { type_desc *tydesc = box->td; uint8_t *body = (uint8_t*) box_body(box); - LOG(task, gc, + LOG(task, gc, "determining internal ref counts: " "box=%p tydesc=%p body=%p", box, tydesc, body); - + shape::arena arena; shape::type_param *params = shape::type_param::from_tydesc_and_data(tydesc, body, arena); @@ -425,7 +425,7 @@ void mark::do_mark(rust_task *task, const std::vector &roots, std::set &marked) { - std::vector::const_iterator + std::vector::const_iterator begin(roots.begin()), end(roots.end()); while (begin != end) { diff --git a/src/rt/rust_env.cpp b/src/rt/rust_env.cpp index ab9bf9d75fa..9237e8b593c 100644 --- a/src/rt/rust_env.cpp +++ b/src/rt/rust_env.cpp @@ -84,10 +84,10 @@ static size_t get_max_stk_size() { char *maxsz = getenv(RUST_MAX_STACK); if (maxsz) { - return strtol(maxsz, NULL, 0); + return strtol(maxsz, NULL, 0); } else { - return 1024*1024*8; + return 1024*1024*8; } } diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index e74819ab318..896a4de660b 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -67,7 +67,8 @@ rust_kernel::create_scheduler(size_t num_threads) { sched = new (this, "rust_scheduler") rust_scheduler(this, srv, num_threads, id); bool is_new = sched_table - .insert(std::pair(id, sched)).second; + .insert(std::pair(id, sched)).second; A(this, is_new, "Reusing a sched id?"); } sched->start_task_threads(); diff --git a/src/rt/rust_port_selector.cpp b/src/rt/rust_port_selector.cpp index 5a3aaf0c65b..d958eac187c 100644 --- a/src/rt/rust_port_selector.cpp +++ b/src/rt/rust_port_selector.cpp @@ -50,10 +50,10 @@ rust_port_selector::select(rust_task *task, rust_port **dptr, task->rendezvous_ptr = (uintptr_t*)dptr; task->block(this, "waiting for select rendezvous"); - // Blocking the task might fail if the task has already been - // killed, but in the event of both failure and success the - // task needs to yield. On success, it yields and waits to be - // unblocked. On failure it yields and is then fails the task. + // Blocking the task might fail if the task has already been + // killed, but in the event of both failure and success the + // task needs to yield. On success, it yields and waits to be + // unblocked. On failure it yields and is then fails the task. *yield = true; } diff --git a/src/rt/rust_port_selector.h b/src/rt/rust_port_selector.h index 8b4d902a249..3bfc454aaf8 100644 --- a/src/rt/rust_port_selector.h +++ b/src/rt/rust_port_selector.h @@ -16,10 +16,10 @@ class rust_port_selector : public rust_cond { rust_port_selector(); void select(rust_task *task, - rust_port **dptr, - rust_port **ports, - size_t n_ports, - uintptr_t *yield); + rust_port **dptr, + rust_port **ports, + size_t n_ports, + uintptr_t *yield); void msg_sent_on(rust_port *port); }; diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 482739ded99..5ef266f890d 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -2,9 +2,9 @@ #include "rust_util.h" rust_scheduler::rust_scheduler(rust_kernel *kernel, - rust_srv *srv, - size_t num_threads, - rust_sched_id id) : + rust_srv *srv, + size_t num_threads, + rust_sched_id id) : kernel(kernel), srv(srv), env(srv->env), @@ -107,8 +107,8 @@ rust_scheduler::release_task() { } } if (need_exit) { - // There are no more tasks on this scheduler. Time to leave - exit(); + // There are no more tasks on this scheduler. Time to leave + exit(); } } diff --git a/src/rt/rust_scheduler.h b/src/rt/rust_scheduler.h index dae867536fb..e75bafbe41d 100644 --- a/src/rt/rust_scheduler.h +++ b/src/rt/rust_scheduler.h @@ -33,7 +33,7 @@ private: public: rust_scheduler(rust_kernel *kernel, rust_srv *srv, size_t num_threads, - rust_sched_id id); + rust_sched_id id); ~rust_scheduler(); void start_task_threads(); diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 9883400d173..c361dd4d441 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -362,7 +362,8 @@ public: void walk_fn2(char) { return cmp_two_pointers(); } void walk_obj2() { return cmp_two_pointers(); } - void walk_tag2(tag_info &tinfo, const data_pair &tag_variants); + void walk_tag2(tag_info &tinfo, + const data_pair &tag_variants); void walk_struct2(const uint8_t *end_sp); void walk_res2(const rust_fn *dtor, uint16_t n_ty_params, const type_param *ty_params_sp, const uint8_t *end_sp, @@ -400,7 +401,8 @@ cmp::walk_vec2(bool is_pod, const std::pair &data_range) { } void -cmp::walk_tag2(tag_info &tinfo, const data_pair &tag_variants) { +cmp::walk_tag2(tag_info &tinfo, + const data_pair &tag_variants) { cmp_number(tag_variants); if (result != 0) return; @@ -548,8 +550,8 @@ log::walk_res2(const rust_fn *dtor, unsigned n_params, extern "C" void shape_cmp_type(int8_t *result, const type_desc *tydesc, - const type_desc **subtydescs, uint8_t *data_0, - uint8_t *data_1, uint8_t cmp_type) { + const type_desc **subtydescs, uint8_t *data_0, + uint8_t *data_1, uint8_t cmp_type) { rust_task *task = rust_task_thread::get_task(); shape::arena arena; diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index 64de224464e..ad3841b5443 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -395,7 +395,7 @@ ctxt::get_variant_sp(tag_info &tinfo, tag_variant_t variant_id) { const uint8_t *variant_ptr = tables->tags + variant_offset; uint16_t variant_len = get_u16_bump(variant_ptr); const uint8_t *variant_end = variant_ptr + variant_len; - + return std::make_pair(variant_ptr, variant_end); } @@ -936,7 +936,7 @@ public: } template - void walk_number1() { + void walk_number1() { //DATA_SIMPLE(W, walk_number2()); ALIGN_TO(rust_alignof()); U end_dp = dp + sizeof(WN); @@ -1158,7 +1158,8 @@ private: variant_ptr_and_end); void walk_string2(const std::pair &data); void walk_res2(const rust_fn *dtor, unsigned n_params, - const type_param *params, const uint8_t *end_sp, bool live); + const type_param *params, const uint8_t *end_sp, + bool live); template inline void walk_number2() { diff --git a/src/rt/rust_stack.cpp b/src/rt/rust_stack.cpp index 4b760afad1e..adcf7e4b4ba 100644 --- a/src/rt/rust_stack.cpp +++ b/src/rt/rust_stack.cpp @@ -22,7 +22,7 @@ reuse_valgrind_stack(stk_seg *stk, uint8_t *sp) { // 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"); + && "Stack pointer must be inside stack segment"); size_t sz = stk->end - (uintptr_t)sp; (void) VALGRIND_MAKE_MEM_UNDEFINED(sp, sz); (void) sz; diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index d77c7cf733e..83a357f9e19 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -44,7 +44,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_state state, supervisor(spawner) { LOGPTR(thread, "new task", (uintptr_t)this); - DLOG(thread, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this); + DLOG(thread, task, "sizeof(task) = %d (0x%x)", + sizeof *this, sizeof *this); new_stack(init_stack_sz); if (supervisor) { @@ -136,7 +137,7 @@ void task_start_wrapper(spawn_args *a) bool threw_exception = false; try { - // The first argument is the return pointer; as the task fn + // The first argument is the return pointer; as the task fn // must have void return type, we can safely pass 0. a->f(0, a->envptr, a->argptr); } catch (rust_task *ex) { @@ -400,7 +401,8 @@ rust_task::wakeup(rust_cond *from) { A(thread, cond != NULL, "Cannot wake up unblocked task."); LOG(this, task, "Blocked on 0x%" PRIxPTR " woken up on 0x%" PRIxPTR, (uintptr_t) cond, (uintptr_t) from); - A(thread, cond == from, "Cannot wake up blocked task on wrong condition."); + A(thread, cond == from, + "Cannot wake up blocked task on wrong condition."); transition(task_state_blocked, task_state_running, NULL, "none"); } diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h index fb6448cfae8..6a192c2c7cd 100644 --- a/src/rt/rust_task.h +++ b/src/rt/rust_task.h @@ -252,7 +252,7 @@ public: void prev_stack(); void record_stack_limit(); void reset_stack_limit(); - + bool on_rust_stack(); void check_stack_canary(); void delete_all_stacks(); diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp index 6a5b8bc2ab0..62644d077fa 100644 --- a/src/rt/rust_task_thread.cpp +++ b/src/rt/rust_task_thread.cpp @@ -176,8 +176,8 @@ rust_task_thread::log_state() { if (!blocked_tasks.is_empty()) { log(NULL, log_debug, "blocked tasks:"); for (size_t i = 0; i < blocked_tasks.length(); i++) { - log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR ", blocked on: 0x%" - PRIxPTR " '%s'", + log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR + ", blocked on: 0x%" PRIxPTR " '%s'", blocked_tasks[i]->name, blocked_tasks[i], blocked_tasks[i]->get_cond(), blocked_tasks[i]->get_cond_name()); @@ -300,7 +300,7 @@ rust_task_thread::state_name(rust_task_state state) { } } -void +void rust_task_thread::transition(rust_task *task, rust_task_state src, rust_task_state dst, rust_cond *cond, const char* cond_name) { diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 647927d5c4b..b5fc36c4dde 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -118,7 +118,7 @@ extern "C" CDECL void upcall_s_fail(s_fail_args *args) { rust_task *task = rust_task_thread::get_task(); LOG_UPCALL_ENTRY(task); - LOG_ERR(task, upcall, "upcall fail '%s', %s:%" PRIdPTR, + LOG_ERR(task, upcall, "upcall fail '%s', %s:%" PRIdPTR, args->expr, args->file, args->line); task->fail(); } @@ -416,7 +416,8 @@ extern "C" void upcall_cmp_type(int8_t *result, const type_desc *tydesc, const type_desc **subtydescs, uint8_t *data_0, uint8_t *data_1, uint8_t cmp_type) { - s_cmp_type_args args = {result, tydesc, subtydescs, data_0, data_1, cmp_type}; + s_cmp_type_args args = {result, tydesc, subtydescs, + data_0, data_1, cmp_type}; UPCALL_SWITCH_STACK(&args, upcall_s_cmp_type); } diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index 76bcfd36fdc..2c4eb8cd174 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -95,7 +95,8 @@ vec_data(rust_vec *v) { inline void reserve_vec_exact(rust_task* task, rust_vec** vpp, size_t size) { if (size > (*vpp)->alloc) { - *vpp = (rust_vec*)task->kernel->realloc(*vpp, size + sizeof(rust_vec)); + *vpp = (rust_vec*)task->kernel + ->realloc(*vpp, size + sizeof(rust_vec)); (*vpp)->alloc = size; } } @@ -107,7 +108,8 @@ inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) { typedef rust_vec rust_str; inline rust_str * -make_str(rust_kernel* kernel, const char* c, size_t strlen, const char* name) { +make_str(rust_kernel* kernel, const char* c, size_t strlen, + const char* name) { size_t str_fill = strlen + 1; size_t str_alloc = str_fill; rust_str *str = (rust_str *) diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 096d40d2235..af587746090 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -3,18 +3,18 @@ // crust fn pointers typedef void (*crust_async_op_cb)(uv_loop_t* loop, void* data, - uv_async_t* op_handle); + uv_async_t* op_handle); typedef void (*crust_simple_cb)(uint8_t* id_buf, void* loop_data); typedef void (*crust_close_cb)(uint8_t* id_buf, void* handle, - void* data); + void* data); // data types #define RUST_UV_HANDLE_LEN 16 struct handle_data { - uint8_t id_buf[RUST_UV_HANDLE_LEN]; - crust_simple_cb cb; - crust_close_cb close_cb; + uint8_t id_buf[RUST_UV_HANDLE_LEN]; + crust_simple_cb cb; + crust_close_cb close_cb; }; // helpers @@ -31,40 +31,40 @@ current_kernel_free(void* ptr) { static handle_data* new_handle_data_from(uint8_t* buf, crust_simple_cb cb) { - handle_data* data = (handle_data*)current_kernel_malloc( - sizeof(handle_data), - "handle_data"); - memcpy(data->id_buf, buf, RUST_UV_HANDLE_LEN); - data->cb = cb; - return data; + handle_data* data = (handle_data*)current_kernel_malloc( + sizeof(handle_data), + "handle_data"); + memcpy(data->id_buf, buf, RUST_UV_HANDLE_LEN); + data->cb = cb; + return data; } // libuv callback impls static void native_crust_async_op_cb(uv_async_t* handle, int status) { crust_async_op_cb cb = (crust_async_op_cb)handle->data; - void* loop_data = handle->loop->data; - cb(handle->loop, loop_data, handle); + void* loop_data = handle->loop->data; + cb(handle->loop, loop_data, handle); } static void native_async_cb(uv_async_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); + 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 native_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); + 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 native_close_cb(uv_handle_t* handle) { - handle_data* data = (handle_data*)handle->data; - data->close_cb(data->id_buf, handle, handle->loop->data); + handle_data* data = (handle_data*)handle->data; + data->close_cb(data->id_buf, handle, handle->loop->data); } static void @@ -91,15 +91,15 @@ rust_uv_loop_set_data(uv_loop_t* loop, void* data) { extern "C" void* rust_uv_bind_op_cb(uv_loop_t* loop, crust_async_op_cb cb) { - uv_async_t* async = (uv_async_t*)current_kernel_malloc( - sizeof(uv_async_t), - "uv_async_t"); - uv_async_init(loop, async, native_crust_async_op_cb); - async->data = (void*)cb; - // decrement the ref count, so that our async bind - // doesn't count towards keeping the loop alive - //uv_unref(loop); - return async; + uv_async_t* async = (uv_async_t*)current_kernel_malloc( + sizeof(uv_async_t), + "uv_async_t"); + uv_async_init(loop, async, native_crust_async_op_cb); + async->data = (void*)cb; + // decrement the ref count, so that our async bind + // doesn't count towards keeping the loop alive + //uv_unref(loop); + return async; } extern "C" void @@ -109,14 +109,14 @@ rust_uv_stop_op_cb(uv_handle_t* op_handle) { extern "C" void rust_uv_run(uv_loop_t* loop) { - uv_run(loop); + uv_run(loop); } extern "C" void rust_uv_close(uv_handle_t* handle, crust_close_cb cb) { - handle_data* data = (handle_data*)handle->data; - data->close_cb = cb; - uv_close(handle, native_close_cb); + handle_data* data = (handle_data*)handle->data; + data->close_cb = cb; + uv_close(handle, native_close_cb); } extern "C" void @@ -138,38 +138,38 @@ rust_uv_async_send(uv_async_t* handle) { extern "C" void* rust_uv_async_init(uv_loop_t* loop, crust_simple_cb cb, - uint8_t* buf) { - uv_async_t* async = (uv_async_t*)current_kernel_malloc( - sizeof(uv_async_t), - "uv_async_t"); - uv_async_init(loop, async, native_async_cb); - handle_data* data = new_handle_data_from(buf, cb); - async->data = data; + uint8_t* buf) { + uv_async_t* async = (uv_async_t*)current_kernel_malloc( + sizeof(uv_async_t), + "uv_async_t"); + uv_async_init(loop, async, native_async_cb); + handle_data* data = new_handle_data_from(buf, cb); + async->data = data; - return async; + return async; } extern "C" void* rust_uv_timer_init(uv_loop_t* loop, crust_simple_cb cb, - uint8_t* buf) { - uv_timer_t* new_timer = (uv_timer_t*)current_kernel_malloc( - sizeof(uv_timer_t), - "uv_timer_t"); - uv_timer_init(loop, new_timer); - handle_data* data = new_handle_data_from(buf, cb); - new_timer->data = data; + uint8_t* buf) { + uv_timer_t* new_timer = (uv_timer_t*)current_kernel_malloc( + sizeof(uv_timer_t), + "uv_timer_t"); + uv_timer_init(loop, new_timer); + handle_data* data = new_handle_data_from(buf, cb); + new_timer->data = data; - return new_timer; + return new_timer; } extern "C" void rust_uv_timer_start(uv_timer_t* the_timer, uint32_t timeout, - uint32_t repeat) { - uv_timer_start(the_timer, native_timer_cb, timeout, repeat); + uint32_t repeat) { + uv_timer_start(the_timer, native_timer_cb, timeout, repeat); } extern "C" void rust_uv_timer_stop(uv_timer_t* the_timer) { - uv_timer_stop(the_timer); + uv_timer_stop(the_timer); } diff --git a/src/rt/sync/lock_and_signal.cpp b/src/rt/sync/lock_and_signal.cpp index 35576f7fd97..0e904ae99bb 100644 --- a/src/rt/sync/lock_and_signal.cpp +++ b/src/rt/sync/lock_and_signal.cpp @@ -25,7 +25,8 @@ lock_and_signal::lock_and_signal() // TODO? Consider checking GetProcAddress("InitializeCriticalSectionEx") // so Windows >= Vista we can use CRITICAL_SECTION_NO_DEBUG_INFO to avoid // allocating CRITICAL_SECTION debug info that is never released. See: - // http://stackoverflow.com/questions/804848/critical-sections-leaking-memory-on-vista-win2008#889853 + // http://stackoverflow.com/questions/804848/ + // critical-sections-leaking-memory-on-vista-win2008#889853 } #else