Add a warning interface to rust_srv.

This commit is contained in:
Michael Bebenita 2010-07-27 23:13:33 -07:00 committed by Graydon Hoare
parent 6afb6c767e
commit d786469785
3 changed files with 15 additions and 2 deletions

View File

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

View File

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

View File

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