aboutsummaryrefslogtreecommitdiff
path: root/src/rt
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-27 23:13:33 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:28 -0700
commitd7864697854fc07192d537949f7712776d652156 (patch)
tree50d963ca92d6b1d707d52f187e99025a06094321 /src/rt
parentMove allocation-tracking into rust_srv. (diff)
downloadrust-d7864697854fc07192d537949f7712776d652156.tar.xz
rust-d7864697854fc07192d537949f7712776d652156.zip
Add a warning interface to rust_srv.
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust.cpp10
-rw-r--r--src/rt/rust.h1
-rw-r--r--src/rt/rust_internal.h6
3 files changed, 15 insertions, 2 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 37398655..2200df11 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -94,6 +94,16 @@ rust_srv::fatal(char const *expr, char const *file, size_t line)
exit(1);
}
+void
+rust_srv::warning(char const *expr, char const *file, size_t line)
+{
+ char buf[1024];
+ snprintf(buf, sizeof(buf),
+ "warning: '%s', at: %s:%d",
+ expr, file, (int)line);
+ log(buf);
+}
+
rust_srv *
rust_srv::clone()
{
diff --git a/src/rt/rust.h b/src/rt/rust.h
index c65d0eb1..9a61dca7 100644
--- a/src/rt/rust.h
+++ b/src/rt/rust.h
@@ -25,6 +25,7 @@ struct rust_srv {
virtual void log(char const *);
virtual void fatal(char const *, char const *, size_t);
+ virtual void warning(char const *, char const *, size_t);
virtual void *malloc(size_t);
virtual void *realloc(void *, size_t);
virtual void free(void *);
diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h
index 78ba85e8..bd9be504 100644
--- a/src/rt/rust_internal.h
+++ b/src/rt/rust_internal.h
@@ -44,10 +44,12 @@ extern "C" {
#error "Target CPU not supported."
#endif
-#define I(dom, e) ((e) ? (void)0 : \
+#define I(dom, e) ((e) ? (void)0 : \
(dom)->srv->fatal(#e, __FILE__, __LINE__))
+#define W(dom, e, s) ((e) ? (void)0 : \
+ (dom)->srv->warning(#e " : " #s, __FILE__, __LINE__))
-#define A(dom, e, s) ((e) ? (void)0 : \
+#define A(dom, e, s) ((e) ? (void)0 : \
(dom)->srv->fatal(#e " : " #s, __FILE__, __LINE__))
struct rust_task;