Mercurial > hg > CbC > CbC_xv6
view src/sys_pipe_read.cbc @ 153:49d8aba0002a
switch use sys_pipe_read.cbc
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Dec 2019 15:55:22 +0900 |
parents | |
children | 343f8f3c8f18 |
line wrap: on
line source
#include "../context.h" #interface "SysRead.h" // ---- // typedef struct PipeRead<Type, Isa> impl SysRead { // struct pipe* p; // int i; // int n; // __code cbc_piperead1(Type* sys_read, struct pipe* p, __code next(...)); // __code cbc_piperead2(Type* sys_read, int i, int n, struct pipe* p, __code next(...)); // __code cbc_piperead3(Type* sys_read, int i, struct pipe* p, __code next(...)); // __code next(...); // } PipeRead; // ---- SysRead* createPipeRead(struct Context* cbc_context) { struct SysRead* sys_read = new SysRead(); struct PipeRead* pipe_read = new PipeRead(); sys_read->sys_read = (union Data*)pipe_read; pipe_read->p = NULL; pipe_read->i = 0; pipe_read->n = 0; sys_read->impl = NULL; sys_read->addr = NULL; sys_read->n = 0; pipe_read->cbc_piperead1 = C_cbc_piperead1PipeRead; pipe_read->cbc_piperead2 = C_cbc_piperead2PipeRead; pipe_read->cbc_piperead3 = C_cbc_piperead3PipeRead; sys_read->read = C_readPipeRead; return sys_read; } __code cbc_piperead1PipeRead(struct PipeRead* sys_read, struct pipe* p, __code next(...)) { if (p->nread == p->nwrite && p->writeopen){ if(proc->killed){ release(&p->lock); goto next(); } 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_piperead2PipeRead(struct PipeRead* sys_read, int i, int n, struct pipe* p, __code next(...)) { 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_piperead3PipeRead(struct PipeRead* sys_read, int i, struct pipe* p, __code next(...)) { goto next(...); } __code nextPipeRead(...) { } __code readPipeRead(struct PipeRead* sys_read, union Data* impl, char* addr, int n, __code next(int ret,...)) { goto next(int ret,...); }