annotate src/impl/file_impl_none.cbc @ 258:71c7bd0d047e

build success
author menikon
date Thu, 06 Feb 2020 17:21:04 +0900
parents e2b0a3e0c97a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
180
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../context.h"
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #interface "file.h"
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 // ----
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // typedef struct none<Impl, Isa> impl file {
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 //
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 // } none;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 // ----
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 file* createnone(struct Context* cbc_context) {
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 struct file* file = new file();
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 struct none* none = new none();
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 file->file = (union Data*)none;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 file->remoe = 0;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 file->off = 0;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 file->st = NULL;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 file->addr = NULL;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 file->pipe = 0;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 file->inode = 0;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 file->n = 0;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 file->fd = 0;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 file->stat = C_statnone;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 file->read = C_readnone;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 file->write = C_writenone;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 file->close = C_closenone;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 return file;
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 __code statnone(struct none* file, struct stat* st, __code next(...)) {
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 goto next(...);
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 }
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 __code readnone(struct none* file, char* addr, __code next(...)) {
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 goto next(...);
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 }
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 __code writenone(struct none* file, char* addr, int n, __code next(...)) {
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 goto next(...);
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 }
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 __code closenone(struct none* file,int fd, __code next(...)) {
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
190
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
45 goto file->noneclose(file->file, next);
180
9f28b86fecc5 add nonefiles
menikon <e165723@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 }
190
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
47
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
48 __code noneclose(struct none* none, struct file* file, __code next(...){
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
49 struct file ff;
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
50 acquire(*ftable.loc)
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
51
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
52 if (f->ref < 1) {
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
53 goto cbc_context->kernel_error->panic("file close");
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
54 }
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
55 goto pipe->cbc_noneclose2(f,ff,next);
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
56 }
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
57
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
58 __code noneclose2(struct none* none,struct file* file, struct file* ff,__code next(...)){
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
59 if (--f->ref > 0) {
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
60 release(&ftable.lock);
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
61 goto cbc_context->return();
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
62 }
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
63 goto pipe->cbc_pipeclose3(f,ff,next);
e2b0a3e0c97a fix file_impl_none.cbc
menikon <e165723@ie.u-ryukyu.ac.jp>
parents: 180
diff changeset
64 }