# HG changeset patch # User anatofuz # Date 1579082012 -32400 # Node ID 9c501dca25e34e4de1dc130e35315e9ff6fd775c # Parent d116d737fed0340951c9f56ec3438aba89af4e43 add file_impl_pipe.cbc diff -r d116d737fed0 -r 9c501dca25e3 src/impl/file_impl_pipe.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/file_impl_pipe.cbc Wed Jan 15 18:53:32 2020 +0900 @@ -0,0 +1,56 @@ +#include "../context.h" +#interface "file.h" + +// ---- +// typedef struct pipe impl file { +// #define PIPESIZE 512 +// struct spinlock lock; +// char data[PIPESIZE]; +// uint nread; // number of bytes read +// uint nwrite; // number of bytes written +// int readopen; // read fd is still open +// int writeopen; // write fd is still open +// } pipe; +// ---- + +file* createpipe(struct Context* cbc_context) { + struct file* file = new file(); + struct pipe* pipe = new pipe(); + file->file = (union Data*)pipe; + pipe->lock = 0; + pipe->spinlock = 0; + pipe->data = 0; + pipe->nread = 0; + pipe->nwrite = 0; + pipe->readopen = 0; + pipe->writeopen = 0; + file->off = 0; + file->st = NULL; + file->addr = NULL; + file->n = 0; + file->stat = C_statpipe; + file->read = C_readpipe; + file->write = C_writepipe; + file->close = C_closepipe; + return file; +} +__code statpipe(struct pipe* file, struct stat* st, __code next(...)) { + + goto next(...); +} + +__code readpipe(struct pipe* file, char* addr, __code next(...)) { + + goto next(...); +} + +__code writepipe(struct pipe* file, char* addr, int n, __code next(...)) { + + goto next(...); +} + +__code closepipe(struct pipe* file,__code next(...)) { + + goto next(...); +} +