view src/impl/pipe.h @ 285:26be78edaf83

impl auto collection for data gears from interface
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 03 Feb 2020 17:12:35 +0900
parents 000e247dc51d
children
line wrap: on
line source

typedef struct pipe<Impl, Isa> impl file {
    #define PIPESIZE 512
    union Data* file;
    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

    int ref;   // reference count
    /*
    char readable;
    char writable;
    */
    unsigned int off;

    // interface field
    int n;
    char* addr;

    // private code gear
    __code piperead1(Impl* pipe, char* addr, int n, __code next(...));
    __code piperead2(Impl* pipe, char* addr, int n, __code next(...));
    __code cbc_pipeclose(Impl* pipe, Isa* file, __code next(...));
    __code cbc_pipeclose2(Impl* pipe, Isa* file, Isa* ff,  __code next(...));
    __code cbc_pipeclose3(Impl* pipe, Isa* file, Isa* ff,  __code next(...));
    __code cbc_pipeclose4(Impl* pipe, int writable, __code next(...));
    __code cbc_pipe_close_writeopen(Impl* pipe, __code next(...));
    __code cbc_pipe_close_readopen(Impl* pipe, __code next(...));
} pipe;