changeset 164:9c501dca25e3

add file_impl_pipe.cbc
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 15 Jan 2020 18:53:32 +0900
parents d116d737fed0
children 21e83548d738
files src/impl/file_impl_pipe.cbc
diffstat 1 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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, Isa> 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(...);
+}
+