forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrust_srv.cpp
88 lines (76 loc) · 1.74 KB
/
rust_srv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "rust_internal.h"
#include "rust_srv.h"
rust_srv::rust_srv(rust_env *env) :
env(env),
local_region(this, false) {
}
rust_srv::~rust_srv() {}
void
rust_srv::free(void *p) {
::free(p);
}
void *
rust_srv::malloc(size_t bytes) {
return ::malloc(bytes);
}
void *
rust_srv::realloc(void *p, size_t bytes) {
return ::realloc(p, bytes);
}
void
rust_srv::log(char const *msg) {
fprintf(stderr, "rust: %s\n", msg);
// FIXME: flushing each time is expensive, but at the moment
// necessary to get output through before a rust_task::fail
// call. This should be changed.
fflush(stderr);
}
void
rust_srv::fatal(const char *expression,
const char *file,
size_t line,
const char *format,
...) {
char buf[BUF_BYTES];
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
char msg[BUF_BYTES];
snprintf(msg, sizeof(msg),
"fatal, '%s' failed, %s:%d %s",
expression, file, (int)line, buf);
log(msg);
abort();
}
void
rust_srv::warning(char const *expression,
char const *file,
size_t line,
const char *format,
...) {
char buf[BUF_BYTES];
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
char msg[BUF_BYTES];
snprintf(msg, sizeof(msg),
"warning: '%s', at: %s:%d %s",
expression, file, (int)line, buf);
log(msg);
}
rust_srv *
rust_srv::clone() {
return new rust_srv(env);
}
//
// Local Variables:
// mode: C++
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
//