Mercurial > hg > CbC > CbC_xv6
view src/sys_read_impl.cbc @ 146:fd166dda4361
tweak return value at file_read.cbc
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Dec 2019 14:15:27 +0900 |
parents | 0c24464a66d8 |
children |
line wrap: on
line source
#include "../context.h" #interface "SysRead.h" // ---- // typedef struct SysReadImpl <Type, Isa> impl SysRead { // // } SysReadImpl; // ---- SysRead* createSysReadImpl(struct Context* cbc_context) { struct SysRead* sys_read = new SysRead(); struct SysReadImpl* sys_read_impl = new SysReadImpl(); sys_read->sys_read = (union Data*)sys_read_impl; sys_read->num = 0; sys_read->addr = NULL; sys_read->file = NULL; sys_read->r = 0; sys_read->pipe = NULL; sys_read->read = C_readSysReadImpl; sys_read->next = C_nextSysReadImpl; sys_read->cbc_fileread1 = C_cbc_fileread1SysReadImpl; sys_read->cbc_fileread = C_cbc_filereadSysReadImpl; sys_read->cbc_piperead1 = C_cbc_piperead1SysReadImpl; sys_read->cbc_piperead2 = C_cbc_piperead2SysReadImpl; sys_read->cbc_piperead3 = C_cbc_piperead3SysReadImpl; return sys_read; } __code readSysReadImpl(struct SysReadImpl* sys_read, __code next(...)) { goto next(...); } __code nextSysReadImpl(...) { } __code cbc_fileread1SysReadImpl(struct SysReadImpl* sys_read, int r) { } __code cbc_filereadSysReadImpl(struct SysReadImpl* sys_read, struct file* file, char* addr, int n, __code (*next)(int ret)) { goto (*next); } __code cbc_piperead1SysReadImpl(struct SysReadImpl* sys_read, struct pipe* p) { __code(*next)(int ret) = proc->cbc_arg.cbc_console_arg.next; if (p->nread == p->nwrite && p->writeopen){ if(proc->killed){ release(&p->lock); goto next(-1); } proc->cbc_arg.cbc_console_arg.p = p; goto cbc_sleep(&p->nread, &p->lock, cbc_piperead1); } goto cbc_piperead2SysReadImpl(sys_read,0,sys_read->n,sys_read->p); } __code cbc_piperead2SysReadImpl(struct SysReadImpl* sys_read, int i, int n,struct pipe* p, char* addr) { if (i < n && !(p->nread == p->nwrite)) { addr[i] = p->data[p->nread++ % PIPESIZE]; i ++; goto cbc_piperead2(sys_read,i,n,p,addr); } goto cbc_wakeup(&p->nwrite, cbc_piperead3); //DOC: piperead-wakeup } __code cbc_piperead3SysReadImpl(struct SysReadImpl* sys_read, struct pipe* p, int i) { } __code cbc_pipereadSysReadImpl(struct SysReadImpl* sys_read, struct pipe* p, char* addr, int n) { acquire(&p->lock); goto cbc_piperead1SysReadImpl(sys_read,p); }