Skip to content

Commit 7a90148

Browse files
committed
---
yaml --- r: 13227 b: refs/heads/master c: dad3007 h: refs/heads/master i: 13225: 62debd7 13223: 574db1e v: v3
1 parent c58ecd8 commit 7a90148

File tree

7 files changed

+33
-33
lines changed

7 files changed

+33
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9826541c0e5c1df9000bd9811215857249cd0376
2+
refs/heads/master: dad300758486b59ac1356d55dbc2accd8e8d9720
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rt/rust_log.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ append_string(char *buffer, const char *format, ...) {
8989
return buffer;
9090
}
9191

92+
void
93+
rust_log::log(rust_task* task, uint32_t level, char const *fmt, ...) {
94+
char buf[BUF_BYTES];
95+
va_list args;
96+
va_start(args, fmt);
97+
int formattedbytes = vsnprintf(buf, sizeof(buf), fmt, args);
98+
if( formattedbytes and (unsigned)formattedbytes > BUF_BYTES ){
99+
const char truncatedstr[] = "[...]";
100+
memcpy( &buf[BUF_BYTES-sizeof(truncatedstr)],
101+
truncatedstr,
102+
sizeof(truncatedstr));
103+
}
104+
trace_ln(task, level, buf);
105+
va_end(args);
106+
}
107+
92108
void
93109
rust_log::trace_ln(char *prefix, char *message) {
94110
char buffer[BUF_BYTES] = "";
@@ -302,6 +318,7 @@ void update_log_settings(void* crate_map, char* settings) {
302318
free(buffer);
303319
}
304320

321+
305322
//
306323
// Local Variables:
307324
// mode: C++

trunk/src/rt/rust_log.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const uint32_t log_debug = 3;
2323
do { \
2424
rust_sched_loop* _d_ = sched_loop; \
2525
if (log_rt_##field >= lvl && _d_->log_lvl >= lvl) { \
26-
_d_->log(task, lvl, __VA_ARGS__); \
26+
_d_->get_log().log(task, lvl, __VA_ARGS__); \
2727
} \
2828
} while (0)
2929

@@ -45,6 +45,7 @@ class rust_log {
4545
rust_log(rust_sched_loop *sched_loop);
4646
virtual ~rust_log();
4747

48+
void log(rust_task* task, uint32_t level, char const *fmt, ...);
4849
void trace_ln(rust_task *task, uint32_t level, char *message);
4950
void trace_ln(char *prefix, char *message);
5051
bool is_tracing(uint32_t type_bits);

trunk/src/rt/rust_sched_loop.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,10 @@ rust_sched_loop::activate(rust_task *task) {
4949
DLOG(this, task, "task has returned");
5050
}
5151

52-
// FIXME #2495: This logging code doesn't belong in the scheduler
53-
void
54-
rust_sched_loop::log(rust_task* task, uint32_t level, char const *fmt, ...) {
55-
char buf[BUF_BYTES];
56-
va_list args;
57-
va_start(args, fmt);
58-
int formattedbytes = vsnprintf(buf, sizeof(buf), fmt, args);
59-
if( formattedbytes and (unsigned)formattedbytes > BUF_BYTES ){
60-
const char truncatedstr[] = "[...]";
61-
memcpy( &buf[BUF_BYTES-sizeof(truncatedstr)],
62-
truncatedstr,
63-
sizeof(truncatedstr));
64-
}
65-
_log.trace_ln(task, level, buf);
66-
va_end(args);
67-
}
6852

6953
void
7054
rust_sched_loop::fail() {
71-
log(NULL, log_err, "domain %s @0x%" PRIxPTR " root task failed",
55+
_log.log(NULL, log_err, "domain %s @0x%" PRIxPTR " root task failed",
7256
name, this);
7357
kernel->fail();
7458
}
@@ -168,18 +152,18 @@ rust_sched_loop::log_state() {
168152
if (log_rt_task < log_debug) return;
169153

170154
if (!running_tasks.is_empty()) {
171-
log(NULL, log_debug, "running tasks:");
155+
_log.log(NULL, log_debug, "running tasks:");
172156
for (size_t i = 0; i < running_tasks.length(); i++) {
173-
log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR,
157+
_log.log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR,
174158
running_tasks[i]->name,
175159
running_tasks[i]);
176160
}
177161
}
178162

179163
if (!blocked_tasks.is_empty()) {
180-
log(NULL, log_debug, "blocked tasks:");
164+
_log.log(NULL, log_debug, "blocked tasks:");
181165
for (size_t i = 0; i < blocked_tasks.length(); i++) {
182-
log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR
166+
_log.log(NULL, log_debug, "\t task: %s @0x%" PRIxPTR
183167
", blocked on: 0x%" PRIxPTR " '%s'",
184168
blocked_tasks[i]->name, blocked_tasks[i],
185169
blocked_tasks[i]->get_cond(),

trunk/src/rt/rust_sched_loop.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ struct rust_sched_loop
9696
// domain.
9797
rust_sched_loop(rust_scheduler *sched, int id);
9898
void activate(rust_task *task);
99-
void log(rust_task *task, uint32_t level, char const *fmt, ...);
10099
rust_log & get_log();
101100
void fail();
102101

trunk/src/rt/rust_shape.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,6 @@ shape_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) {
624624

625625
log.walk();
626626

627-
task->sched_loop->log(task, level, "%s", ss.str().c_str());
627+
task->sched_loop->get_log().log(task, level, "%s", ss.str().c_str());
628628
}
629629

trunk/src/test/bench/shootout-mandelbrot.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,19 @@ fn writer(path: str, writech: comm::chan<comm::chan<line>>, size: uint)
141141
}
142142

143143
fn main(args: [str]) {
144+
let path = if vec::len(args) < 4_u { "" }
145+
else { args[3] };
146+
144147
let args = if os::getenv("RUST_BENCH").is_some() {
145148
["", "4000", "10"]
149+
} else if args.len() <= 1u {
150+
["", "80", "10"]
146151
} else {
147152
args
148153
};
149154

150-
let path = if vec::len(args) < 4_u { "" }
151-
else { args[3] };
152-
153-
let yieldevery = if vec::len(args) < 3_u { 10_u }
154-
else { uint::from_str(args[2]).get() };
155-
156-
let size = if vec::len(args) < 2_u { 80_u }
157-
else { uint::from_str(args[1]).get() };
155+
let size = uint::from_str(args[1]).get();
156+
let yieldevery = uint::from_str(args[2]).get();
158157

159158
let writep = comm::port();
160159
let writech = comm::chan(writep);

0 commit comments

Comments
 (0)