提交 9b37d1bf 创建 作者: rsc's avatar rsc

Add user.h for prototypes.

Add cons_puts for cleaner output.
上级 b903b693
#include "user.h"
int int
puts(char *s) puts(char *s)
{ {
return cons_puts(s);
}
int
puts1(char *s)
{
int i; int i;
for(i = 0; s[i]; i++) for(i = 0; s[i]; i++)
......
int fork(void);
int exit(void) __attribute__((noreturn));
int wait(void);
int cons_putc(int);
int pipe(int*);
int write(int, void*, int);
int read(int, void*, int);
int close(int);
int block(void);
int kill(int);
int panic(char*);
int cons_puts(char*);
int puts(char*);
int puts1(char*);
#include "user.h"
char buf[32]; char buf[32];
int
main() main()
{ {
int pid, fds[2], n; int pid, fds[2], n;
...@@ -15,6 +18,5 @@ main() ...@@ -15,6 +18,5 @@ main()
puts(buf); puts(buf);
puts("\n"); puts("\n");
} }
while(1) for(;;);
;
} }
#include "user.h"
// file system tests // file system tests
char buf[1024]; char buf[1024];
int
main() main()
{ {
puts("userfs running\n"); puts("userfs running\n");
block(); block();
return 0;
} }
#include "user.h"
char buf[2048]; char buf[2048];
// simple fork and pipe read/write // simple fork and pipe read/write
...@@ -17,10 +19,10 @@ pipe1() ...@@ -17,10 +19,10 @@ pipe1()
buf[i] = seq++; buf[i] = seq++;
if(write(fds[1], buf, 1033) != 1033){ if(write(fds[1], buf, 1033) != 1033){
panic("pipe1 oops 1\n"); panic("pipe1 oops 1\n");
exit(1); exit();
} }
} }
exit(0); exit();
} else { } else {
close(fds[1]); close(fds[1]);
total = 0; total = 0;
...@@ -109,12 +111,13 @@ exitwait() ...@@ -109,12 +111,13 @@ exitwait()
return; return;
} }
} else { } else {
exit(0); exit();
} }
} }
puts("exitwait ok\n"); puts("exitwait ok\n");
} }
int
main() main()
{ {
puts("usertests starting\n"); puts("usertests starting\n");
...@@ -123,5 +126,6 @@ main() ...@@ -123,5 +126,6 @@ main()
preempt(); preempt();
exitwait(); exitwait();
panic("usertests finished successfuly"); panic("usertests succeeded");
return 0;
} }
...@@ -19,3 +19,4 @@ STUB(close) ...@@ -19,3 +19,4 @@ STUB(close)
STUB(block) STUB(block)
STUB(kill) STUB(kill)
STUB(panic) STUB(panic)
STUB(cons_puts)
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论