Mercurial > hg > Members > menikon > CbC_xv6
changeset 170:9b0f4b421288
tweak
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 16 Jan 2020 20:34:18 +0900 |
parents | e0255e66e646 |
children | 5fa74a8989b0 |
files | src/gearsTools/trans_impl.pl src/impl/file_impl_pipe.cbc |
diffstat | 2 files changed, 36 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gearsTools/trans_impl.pl Thu Jan 16 16:20:19 2020 +0900 +++ b/src/gearsTools/trans_impl.pl Thu Jan 16 20:34:18 2020 +0900 @@ -176,12 +176,12 @@ if (@cg) { if (@cg == 2) { - print $out " if (:TODO:) {\n"; - print $out " goto ",shift(@cg),";\n"; - print $out " }\n"; - print $out " goto ",shift(@cg),";\n"; + print $out " if (:TODO:) {\n"; + print $out " goto ",shift(@cg),";\n"; + print $out " }\n"; + print $out " goto ",shift(@cg),";\n"; } else { - print $out " goto ",shift(@cg),";\n"; + print $out " goto ",shift(@cg),";\n"; } } print $out "}\n\n"; @@ -207,12 +207,12 @@ if (@cg) { if (@cg == 2) { - print $out " if (:TODO:) {\n"; - print $out " goto ",shift(@cg),";\n"; - print $out " }\n"; - print $out " goto ",shift(@cg),";\n"; + print $out " if (:TODO:) {\n"; + print $out " goto ",shift(@cg),";\n"; + print $out " }\n"; + print $out " goto ",shift(@cg),";\n"; } else { - print $out " goto ",shift(@cg),";\n"; + print $out " goto ",shift(@cg),";\n"; } } print $out "}\n\n";
--- a/src/impl/file_impl_pipe.cbc Thu Jan 16 16:20:19 2020 +0900 +++ b/src/impl/file_impl_pipe.cbc Thu Jan 16 20:34:18 2020 +0900 @@ -36,7 +36,7 @@ } __code statpipe(struct pipe* file, struct stat* st, __code next(...)) { - goto next(...); + goto next(...); } __code readpipe(struct pipe* file, char* addr, int n, __code next(...)) { @@ -85,11 +85,33 @@ } __code closepipe(struct pipe* file,int fd,__code next(...)) { - proc->ofile[fd] = 0; - goto cbc_fileclose(f,next); + proc->ofile[fd] = 0; + goto cbc_fileclose(f,next); } __code cbc_fileclose(struct file* file, __code next(...)) { - goto next(); + struct file ff; + acquire(*ftable.loc) + + if (f->ref < 1) { + goto cbc_context->kernel_error->panic("file close"); + } + goto cbc_fileclose2(f,ff,next); } + +__code cbc_fileclose2(struct file* file, struct file* ff,__code next(...)) { + if (--f->ref > 0) { + release(&ftable.lock); + goto cbc_context->return(); + } + goto cbc_fileclose3(f,ff,next); +} + +__code cbc_fileclose3(struct file* file, struct file* ff,__code next(...)) { + if (--f->ref > 0) { + release(&ftable.lock); + goto cbc_context->return(); + } + goto cbc_fileclose3(f,ff,next); +} \ No newline at end of file