view src/impl/file_impl_none.cbc @ 198:6e28bd30e8a7

fix
author menikon <e165723@ie.u-ryukyu.ac.jp>
date Wed, 22 Jan 2020 20:28:26 +0900
parents e2b0a3e0c97a
children
line wrap: on
line source

#include "../context.h"
#interface "file.h"

// ----
// typedef struct none<Impl, Isa> impl file {
//
// } none;
// ----

file* createnone(struct Context* cbc_context) {
    struct file* file  = new file();
    struct none* none = new none();
    file->file = (union Data*)none;
    file->remoe  = 0;
    file->off = 0;
    file->st = NULL;
    file->addr = NULL;
    file->pipe  = 0;
    file->inode  = 0;
    file->n  = 0;
    file->fd  = 0;
    file->stat = C_statnone;
    file->read = C_readnone;
    file->write = C_writenone;
    file->close = C_closenone;
    return file;
}
__code statnone(struct none* file, struct stat* st, __code next(...)) {

    goto next(...);
}

__code readnone(struct none* file, char* addr, __code next(...)) {

    goto next(...);
}

__code writenone(struct none* file, char* addr, int n, __code next(...)) {

    goto next(...);
}

__code closenone(struct none* file,int fd, __code next(...)) {

    goto file->noneclose(file->file, next);
}

__code noneclose(struct none* none, struct file* file, __code next(...){
  struct file ff;
  acquire(*ftable.loc)

  if (f->ref < 1) {
     goto cbc_context->kernel_error->panic("file close");
  }
  goto pipe->cbc_noneclose2(f,ff,next);
}

__code noneclose2(struct none* none,struct file* file, struct file* ff,__code next(...)){
  if (--f->ref > 0) {
     release(&ftable.lock);
     goto cbc_context->return();
  }
  goto pipe->cbc_pipeclose3(f,ff,next);
}