2010-08-16 14:13:08 -07:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "rust_internal.h"
|
|
|
|
#include "rust_srv.h"
|
|
|
|
|
2010-08-17 23:40:07 -07:00
|
|
|
rust_srv::rust_srv() :
|
2011-07-06 16:42:02 -07:00
|
|
|
local_region(this, false) {
|
2010-08-16 14:13:08 -07:00
|
|
|
// Nop.
|
|
|
|
}
|
|
|
|
|
2011-04-19 12:21:57 +02:00
|
|
|
rust_srv::~rust_srv() {}
|
2010-08-17 23:40:07 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
rust_srv::free(void *p) {
|
|
|
|
::free(p);
|
2010-08-16 14:13:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
rust_srv::malloc(size_t bytes) {
|
2010-08-17 23:40:07 -07:00
|
|
|
return ::malloc(bytes);
|
2010-08-16 14:13:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
rust_srv::realloc(void *p, size_t bytes) {
|
2010-08-17 23:40:07 -07:00
|
|
|
return ::realloc(p, bytes);
|
2010-08-16 14:13:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rust_srv::log(char const *msg) {
|
|
|
|
printf("rt: %s\n", msg);
|
2011-05-10 17:47:38 -07:00
|
|
|
// 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(stdout);
|
2010-08-16 14:13:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rust_srv::fatal(const char *expression,
|
|
|
|
const char *file,
|
|
|
|
size_t line,
|
|
|
|
const char *format,
|
|
|
|
...) {
|
2011-01-14 13:41:39 -08:00
|
|
|
char buf[BUF_BYTES];
|
2010-08-16 14:13:08 -07:00
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
|
|
vsnprintf(buf, sizeof(buf), format, args);
|
|
|
|
va_end(args);
|
|
|
|
|
2011-01-14 13:41:39 -08:00
|
|
|
char msg[BUF_BYTES];
|
2010-08-16 14:13:08 -07:00
|
|
|
snprintf(msg, sizeof(msg),
|
|
|
|
"fatal, '%s' failed, %s:%d %s",
|
|
|
|
expression, file, (int)line, buf);
|
|
|
|
log(msg);
|
2011-07-06 12:48:43 -07:00
|
|
|
abort();
|
2010-08-16 14:13:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rust_srv::warning(char const *expression,
|
|
|
|
char const *file,
|
|
|
|
size_t line,
|
|
|
|
const char *format,
|
|
|
|
...) {
|
2011-01-14 13:41:39 -08:00
|
|
|
char buf[BUF_BYTES];
|
2010-08-16 14:13:08 -07:00
|
|
|
va_list args;
|
|
|
|
va_start(args, format);
|
|
|
|
vsnprintf(buf, sizeof(buf), format, args);
|
|
|
|
va_end(args);
|
|
|
|
|
2011-01-14 13:41:39 -08:00
|
|
|
char msg[BUF_BYTES];
|
2010-08-16 14:13:08 -07:00
|
|
|
snprintf(msg, sizeof(msg),
|
|
|
|
"warning: '%s', at: %s:%d %s",
|
|
|
|
expression, file, (int)line, buf);
|
|
|
|
log(msg);
|
|
|
|
}
|
2010-09-07 18:39:07 -07:00
|
|
|
|
|
|
|
rust_srv *
|
|
|
|
rust_srv::clone() {
|
|
|
|
return new rust_srv();
|
|
|
|
}
|