bufptr bread(uint16_t dev, blkno_t blk, bool rewrite)
{
- register bufptr bp;
+ regptr bufptr bp;
if ((bp = bfind(dev, blk)) != NULL) {
if (bp->bf_busy == BF_BUSY)
}
-int bfree(bufptr bp, uint8_t dirty)
+int bfree(regptr bufptr bp, uint8_t dirty)
{ /* dirty: 0=clean, 1=dirty (write back), 2=dirty+immediate write */
if (dirty)
bp->bf_dirty = true;
*/
void *tmpbuf(void)
{
- bufptr bp;
+ regptr bufptr bp;
bp = freebuf();
bp->bf_dev = NO_DEVICE;
on platforms where we split disk and temporary buffers */
void *zerobuf(void)
{
- void *b;
-
- b = tmpbuf();
+ void *b = tmpbuf();
memset(b, 0, 512);
return b;
}
-static void bdput(bufptr bp)
+static void bdput(regptr bufptr bp)
{
bdwrite(bp);
if (bp->bf_busy == BF_FREE)
void bufsync(void)
{
- bufptr bp;
+ regptr bufptr bp;
/* FIXME: this can generate a lot of d_flush calls when you have
plenty of buffers */
void bdrop(uint16_t dev)
{
- bufptr bp;
+ regptr bufptr bp;
for (bp = bufpool; bp < bufpool_end; ++bp) {
if (bp->bf_dev == dev) {
bufptr freebuf(void)
{
- bufptr bp;
+ regptr bufptr bp;
bufptr oldest;
int16_t oldtime;
inoptr i_open(uint16_t dev, uint16_t ino)
{
struct blkbuf *buf;
- inoptr nindex, j;
+ regptr inoptr nindex;
+ regptr inoptr j;
struct mount *m;
bool isnew = false;
inoptr newfile(inoptr pino, char *name)
{
- inoptr nindex;
+ regptr inoptr nindex;
uint8_t j;
/* No parent? */
fsptr getdev(uint16_t dev)
{
- struct mount *mnt;
+ regptr struct mount *mnt;
time_t t;
mnt = fs_tab_get(dev);
staticfast fsptr dev;
staticfast blkno_t blk;
struct blkbuf *buf;
- struct dinode *di;
+ regptr struct dinode *di;
staticfast uint16_t j;
uint16_t k;
unsigned ino;
* and if we are dropping a lock that is not exclusive we must own one of
* the non exclusive locks.
*/
-void deflock(struct oft *ofptr)
+void deflock(regptr struct oft *ofptr)
{
inoptr i = ofptr->o_inode;
uint8_t c = i->c_flags & CFLOCK;
* links, the inode itself and its blocks(if not a device) is freed.
*/
-void i_deref(inoptr ino)
+void i_deref(regptr inoptr ino)
{
uint8_t mode = getmode(ino);
/* F_trunc frees all the blocks associated with the file, if it
* is a disk file.
*/
-int f_trunc(inoptr ino)
+int f_trunc(regptr inoptr ino)
{
uint16_t dev;
int8_t j;
void freeblk(uint16_t dev, blkno_t blk, uint8_t level)
{
struct blkbuf *buf;
- blkno_t *bn;
+ regptr blkno_t *bn;
int16_t j;
if(!blk)
void freeblk(uint16_t dev, blkno_t blk, uint8_t level)
{
struct blkbuf *buf;
- blkno_t *bn;
+ regptr blkno_t *bn;
int16_t j;
if(!blk)
bool fmount(uint16_t dev, inoptr ino, uint16_t flags)
{
struct mount *m;
- struct filesys *fp;
+ regptr struct filesys *fp;
bufptr buf;
if(d_open(dev, 0) != 0)
}
/* Writei (and readi) need more i/o error handling */
-void readi(inoptr ino, uint8_t flag)
+void readi(regptr inoptr ino, uint8_t flag)
{
usize_t amount;
usize_t toread;
-void writei(inoptr ino, uint8_t flag)
+void writei(regptr inoptr ino, uint8_t flag)
{
usize_t amount;
usize_t towrite;
{
int8_t oftindex;
struct oft *oftp;
- inoptr ino;
+ regptr inoptr ino;
uint16_t flush_dev = NO_DEVICE;
uint8_t m;
inoptr rwsetup(bool is_read, uint8_t * flag)
{
inoptr ino;
- struct oft *oftp;
+ regptr struct oft *oftp;
udata.u_sysio = false; /* I/O to user data space */
udata.u_base = (unsigned char *) udata.u_argn1; /* buf */
void sync(void)
{
- inoptr ino;
- struct mount *m;
+ regptr inoptr ino;
+ regptr struct mount *m;
bufptr buf;
/* Write out modified inodes */
arg_t _pipe(void)
{
int8_t u1, u2, oft1, oft2;
- inoptr ino;
+ regptr inoptr ino;
/* bug fix SN */
if ((u1 = uf_alloc()) == -1)
arg_t _utime(void)
{
- inoptr ino;
+ regptr inoptr ino;
time_t t[2];
if (!(ino = n_open(file, NULLINOPTR)))
{
#ifndef CONFIG_LEVEL_0
inoptr ino;
- struct oft *o;
+ regptr struct oft *o;
staticfast uint8_t c;
staticfast uint8_t lock;
staticfast int self;
static int do_umount(uint16_t dev)
{
- struct mount *mnt;
+ regptr struct mount *mnt;
uint8_t rm = flags & MS_REMOUNT;
- inoptr ptr;
+ regptr inoptr ptr;
mnt = fs_tab_get(dev);
if (mnt == NULL) {
/* For performance reasons scale as
passed to the kernel is a shift value
not a divider */
- ptptr p = udata.u_ptab;
+ regptr ptptr p = udata.u_ptab;
if (scale == 0) {
p->p_profscale = scale;
arg_t _nice(void)
{
- ptptr p = udata.u_ptab;
+ regptr ptptr p = udata.u_ptab;
int16_t np;
if (pri < 0 && !esuper())
arg_t _waitpid(void)
{
- ptptr p;
+ regptr ptptr p;
int retval;
+ uint8_t found;
if (statloc && !valaddr((char *) statloc, sizeof(int))) {
udata.u_error = EFAULT;
return (-1);
}
- /* FIXME: move this scan into the main loop and also error
- on a complete loop finding no matchi for pid */
- /* See if we have any children. */
- for (p = ptab; p < ptab_end; ++p) {
- if (p->p_status && p->p_pptr == udata.u_ptab
- && p != udata.u_ptab)
- goto ok;
- }
- udata.u_error = ECHILD;
- return (-1);
- ok:
if (pid == 0)
pid = -udata.u_ptab->p_pgrp;
/* Search for an exited child; */
udata.u_error = EINTR;
return -1;
}
+ /* Each scan we check that we have a child, if we have a child
+ then all is good. If not then we ECHILD out */
+ found = 0;
for (p = ptab; p < ptab_end; ++p) {
- if (p->p_pptr == udata.u_ptab &&
- (pid == -1 || p->p_pid == pid ||
- p->p_pgrp == -pid)) {
- if (p->p_status == P_ZOMBIE) {
- if (statloc)
- uputi(p->p_exitval, statloc);
- retval = p->p_pid;
- p->p_status = P_EMPTY;
-
- /* Add in child's time info. It was stored on top */
- /* of p_priority in the childs process table entry. */
- /* FIXME: make these a union so we don't do type
- punning and break strict aliasing */
- udata.u_cutime += ((clock_t *)&p->p_priority)[0];
- udata.u_cstime += ((clock_t *)&p->p_priority)[1];
- return retval;
- }
- if (p->p_event && (options & WUNTRACED)) {
- retval = (uint16_t)p->p_event << 8 | _WSTOPPED;
- p->p_event = 0;
- return retval;
+ if (p->p_status && p->p_pptr == udata.u_ptab) {
+ found = 1;
+ if (pid == -1 || p->p_pid == pid ||
+ p->p_pgrp == -pid) {
+ if (p->p_status == P_ZOMBIE) {
+ if (statloc)
+ uputi(p->p_exitval, statloc);
+ retval = p->p_pid;
+ p->p_status = P_EMPTY;
+
+ /* Add in child's time info. It was stored on top */
+ /* of p_priority in the childs process table entry. */
+ /* FIXME: make these a union so we don't do type
+ punning and break strict aliasing */
+ udata.u_cutime += ((clock_t *)&p->p_priority)[0];
+ udata.u_cstime += ((clock_t *)&p->p_priority)[1];
+ return retval;
+ }
+ if (p->p_event && (options & WUNTRACED)) {
+ retval = (uint16_t)p->p_event << 8 | _WSTOPPED;
+ p->p_event = 0;
+ return retval;
+ }
}
}
}
+ if (!found) {
+ udata.u_error = ECHILD;
+ return -1;
+ }
/* Nothing yet, so wait */
if (options & WNOHANG)
break;
arg_t _kill(void)
{
- ptptr p;
+ regptr ptptr p;
int f = 0, s = 0;
if (sig < 0 || sig >= NSIGS) {