rt: Fix whitespace

This commit is contained in:
Brian Anderson 2012-03-31 23:12:06 -07:00
parent cf0c4cd7d2
commit 21064637ed
20 changed files with 109 additions and 99 deletions

View File

@ -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);
};

View File

@ -41,7 +41,6 @@ private:
inline alloc_header *get_header(void *mem);
inline void *get_data(alloc_header *);
rust_srv *_srv;
memory_region *_parent;

View File

@ -58,7 +58,8 @@ class annihilator : public shape::data<annihilator,shape::ptr> {
}
void walk_tag2(shape::tag_info &tinfo, uint32_t tag_variant) {
shape::data<annihilator,shape::ptr>::walk_variant1(tinfo, tag_variant);
shape::data<annihilator,shape::ptr>
::walk_variant1(tinfo, tag_variant);
}
void walk_uniq2() {
@ -83,7 +84,7 @@ class annihilator : public shape::data<annihilator,shape::ptr> {
if (pair.env) {
// free closed over data:
shape::data<annihilator,shape::ptr>::walk_fn_contents1();
// now free the ptr:
task->kernel->free(pair.env);
}

View File

@ -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<rust_opaque_box *> &roots,
std::set<rust_opaque_box *> &marked) {
std::vector<rust_opaque_box *>::const_iterator
std::vector<rust_opaque_box *>::const_iterator
begin(roots.begin()),
end(roots.end());
while (begin != end) {

View File

@ -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;
}
}

View File

@ -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<rust_sched_id, rust_scheduler*>(id, sched)).second;
.insert(std::pair<rust_sched_id,
rust_scheduler*>(id, sched)).second;
A(this, is_new, "Reusing a sched id?");
}
sched->start_task_threads();

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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();
}
}

View File

@ -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();

View File

@ -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_variant_t> &tag_variants);
void walk_tag2(tag_info &tinfo,
const data_pair<tag_variant_t> &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<ptr_pair,ptr_pair> &data_range) {
}
void
cmp::walk_tag2(tag_info &tinfo, const data_pair<tag_variant_t> &tag_variants) {
cmp::walk_tag2(tag_info &tinfo,
const data_pair<tag_variant_t> &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;

View File

@ -395,7 +395,7 @@ ctxt<T>::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<typename WN>
void walk_number1() {
void walk_number1() {
//DATA_SIMPLE(W, walk_number2<W>());
ALIGN_TO(rust_alignof<WN>());
U end_dp = dp + sizeof(WN);
@ -1158,7 +1158,8 @@ private:
variant_ptr_and_end);
void walk_string2(const std::pair<ptr,ptr> &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<typename T>
inline void walk_number2() {

View File

@ -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;

View File

@ -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");
}

View File

@ -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();

View File

@ -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) {

View File

@ -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);
}

View File

@ -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 *)

View File

@ -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);
}

View File

@ -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