提交 aab8fae3 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

A user die function.

上级 ca52df2f
......@@ -35,7 +35,7 @@ printint(void (*putch) (void*, char), void *putarg,
// Only understands %d, %x, %p, %s.
void
vprintfmt(void (*putch) (void*, char), void *putarg,
char *fmt, va_list ap)
const char *fmt, va_list ap)
{
char *s;
int c, i, state;
......@@ -143,3 +143,15 @@ snprintf(char *buf, u32 n, char *fmt, ...)
vsnprintf(buf, n, fmt, ap);
va_end(ap);
}
void __attribute__((noreturn))
die(const char* errstr, ...)
{
va_list ap;
va_start(ap, errstr);
vprintfmt(writec, (void*) (u64)1, errstr, ap);
va_end(ap);
printf(1, "\n");
exit();
}
......@@ -32,8 +32,6 @@ char* strcpy(char*, char*);
void *memmove(void*, void*, int);
char* strchr(const char*, char c);
int strcmp(const char*, const char*);
void printf(int, char*, ...);
void snprintf(char *buf, unsigned int n, char *fmt, ...);
char* gets(char*, int max);
unsigned int strlen(char*);
void* memset(void*, int, unsigned int);
......@@ -43,3 +41,8 @@ int atoi(const char*);
// uthread.S
int forkt(void *sp, void *pc, void *arg);
// printf.c
void printf(int, char*, ...);
void snprintf(char *buf, unsigned int n, char *fmt, ...);
void die(const char* errstr, ...) __attribute__((noreturn));
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论