Skip to content

Commit

Permalink
Add user.h for prototypes.
Browse files Browse the repository at this point in the history
Add cons_puts for cleaner output.
  • Loading branch information
rsc committed Jul 16, 2006
1 parent b903b69 commit 9b37d1b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
8 changes: 8 additions & 0 deletions ulib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "user.h"

int
puts(char *s)
{
return cons_puts(s);
}

int
puts1(char *s)
{
int i;

Expand Down
15 changes: 15 additions & 0 deletions user.h
Original file line number Diff line number Diff line change
@@ -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*);
6 changes: 4 additions & 2 deletions user1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "user.h"

char buf[32];

int
main()
{
int pid, fds[2], n;
Expand All @@ -15,6 +18,5 @@ main()
puts(buf);
puts("\n");
}
while(1)
;
for(;;);
}
4 changes: 4 additions & 0 deletions userfs.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include "user.h"

// file system tests

char buf[1024];

int
main()
{
puts("userfs running\n");
block();
return 0;
}
12 changes: 8 additions & 4 deletions usertests.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "user.h"

char buf[2048];

// simple fork and pipe read/write
Expand All @@ -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;
Expand Down Expand Up @@ -109,12 +111,13 @@ exitwait()
return;
}
} else {
exit(0);
exit();
}
}
puts("exitwait ok\n");
}

int
main()
{
puts("usertests starting\n");
Expand All @@ -123,5 +126,6 @@ main()
preempt();
exitwait();

panic("usertests finished successfuly");
panic("usertests succeeded");
return 0;
}
1 change: 1 addition & 0 deletions usys.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ STUB(close)
STUB(block)
STUB(kill)
STUB(panic)
STUB(cons_puts)

0 comments on commit 9b37d1b

Please sign in to comment.