From 9b37d1bfaa65c96e7a465c285599aa45117182ea Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 16 Jul 2006 15:36:31 +0000 Subject: [PATCH] Add user.h for prototypes. Add cons_puts for cleaner output. --- ulib.c | 8 ++++++++ user.h | 15 +++++++++++++++ user1.c | 6 ++++-- userfs.c | 4 ++++ usertests.c | 12 ++++++++---- usys.S | 1 + 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 user.h diff --git a/ulib.c b/ulib.c index 543323c..97afc8c 100644 --- a/ulib.c +++ b/ulib.c @@ -1,5 +1,13 @@ +#include "user.h" + int puts(char *s) +{ + return cons_puts(s); +} + +int +puts1(char *s) { int i; diff --git a/user.h b/user.h new file mode 100644 index 0000000..7571767 --- /dev/null +++ b/user.h @@ -0,0 +1,15 @@ +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*); diff --git a/user1.c b/user1.c index d414699..bbe6f5b 100644 --- a/user1.c +++ b/user1.c @@ -1,5 +1,8 @@ +#include "user.h" + char buf[32]; +int main() { int pid, fds[2], n; @@ -15,6 +18,5 @@ main() puts(buf); puts("\n"); } - while(1) - ; + for(;;); } diff --git a/userfs.c b/userfs.c index 5de90e6..f7da24b 100644 --- a/userfs.c +++ b/userfs.c @@ -1,9 +1,13 @@ +#include "user.h" + // file system tests char buf[1024]; +int main() { puts("userfs running\n"); block(); + return 0; } diff --git a/usertests.c b/usertests.c index e277839..78b9477 100644 --- a/usertests.c +++ b/usertests.c @@ -1,3 +1,5 @@ +#include "user.h" + char buf[2048]; // simple fork and pipe read/write @@ -17,10 +19,10 @@ pipe1() buf[i] = seq++; if(write(fds[1], buf, 1033) != 1033){ panic("pipe1 oops 1\n"); - exit(1); + exit(); } } - exit(0); + exit(); } else { close(fds[1]); total = 0; @@ -109,12 +111,13 @@ exitwait() return; } } else { - exit(0); + exit(); } } puts("exitwait ok\n"); } +int main() { puts("usertests starting\n"); @@ -123,5 +126,6 @@ main() preempt(); exitwait(); - panic("usertests finished successfuly"); + panic("usertests succeeded"); + return 0; } diff --git a/usys.S b/usys.S index 0e35035..45d6ca8 100644 --- a/usys.S +++ b/usys.S @@ -19,3 +19,4 @@ STUB(close) STUB(block) STUB(kill) STUB(panic) +STUB(cons_puts)