Mercurial > hg > Members > menikon > CbC_xv6
changeset 193:a961a3378174
merge
author | menikon <e165723@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 22 Jan 2020 00:40:07 +0900 |
parents | e2b0a3e0c97a (diff) 000e247dc51d (current diff) |
children | 4cfff673e1f6 |
files | |
diffstat | 2 files changed, 67 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/file_impl_none.cbc Wed Jan 22 00:40:07 2020 +0900 @@ -0,0 +1,64 @@ +#include "../context.h" +#interface "file.h" + +// ---- +// typedef struct none<Impl, Isa> impl file { +// +// } none; +// ---- + +file* createnone(struct Context* cbc_context) { + struct file* file = new file(); + struct none* none = new none(); + file->file = (union Data*)none; + file->remoe = 0; + file->off = 0; + file->st = NULL; + file->addr = NULL; + file->pipe = 0; + file->inode = 0; + file->n = 0; + file->fd = 0; + file->stat = C_statnone; + file->read = C_readnone; + file->write = C_writenone; + file->close = C_closenone; + return file; +} +__code statnone(struct none* file, struct stat* st, __code next(...)) { + + goto next(...); +} + +__code readnone(struct none* file, char* addr, __code next(...)) { + + goto next(...); +} + +__code writenone(struct none* file, char* addr, int n, __code next(...)) { + + goto next(...); +} + +__code closenone(struct none* file,int fd, __code next(...)) { + + goto file->noneclose(file->file, next); +} + +__code noneclose(struct none* none, struct file* file, __code next(...){ + struct file ff; + acquire(*ftable.loc) + + if (f->ref < 1) { + goto cbc_context->kernel_error->panic("file close"); + } + goto pipe->cbc_noneclose2(f,ff,next); +} + +__code noneclose2(struct none* none,struct file* file, struct file* ff,__code next(...)){ + if (--f->ref > 0) { + release(&ftable.lock); + goto cbc_context->return(); + } + goto pipe->cbc_pipeclose3(f,ff,next); +}