# HG changeset patch # User anatofuz # Date 1571478297 -32400 # Node ID 7d0ec88cdd229d9a14e24da4a078c5e6a4c5bee8 # Parent bc5bcfd2f6d608070ede631dd80b852a1db1937b fix read interface diff -r bc5bcfd2f6d6 -r 7d0ec88cdd22 src/sysfile.cbc --- a/src/sysfile.cbc Sat Oct 19 16:44:24 2019 +0900 +++ b/src/sysfile.cbc Sat Oct 19 18:44:57 2019 +0900 @@ -15,14 +15,15 @@ #include "fcntl.h" #include "arm.h" +#include "syscall.h" #interface "CbCSysFile.h" -extern int SYS_exec; #define __ncode __code struct CbCSysFile* create_cbc_sys_file(struct Context* cbc_context) { struct CbCSysFile* cbc_file = new CbCSysFile(); cbc_file->read = C_cbc_fileread; + cbc_file->cbc_file_ret = C_cbc_file_ret; return cbc_file; } @@ -100,31 +101,27 @@ return fd; } -__ncode cbc_read(__code (*next)(int ret)){ +__code cbc_read(struct CbCSysFile* cbc_file){ + //struct CbCSysFile* cbc_file = create_cbc_sys_file(cbc_context); + goto cbc_fileread(); +} + +__code cbc_read_stub(struct Context* cbc_context){ struct file *f; int n; char *p; - + + CbCSysFile* cbc_sys_file = (CbCSysFile*)Gearef(cbc_context,CbCSysFile); if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { - goto next(-1); + //__code cbc_file_ret(struct CbCSysFile* cbc_sys_file, struct UInteger* ret){ + UInteger* ret = (UInteger*)Gearef(cbc_context,UInteger); + ret->value = -1; + goto cbc_file_ret(cbc_context, cbc_sys_file, ret); } - goto cbc_fileread(f, p, n, next); -} - - -__code file_read(struct file *f, char *p, int n, __code next(...)){ - goto cbc_fileread(f, p, n, next); -} - -__code file_read_stub(struct Context* cbc_context, __code next(...)){ - struct CbCSysfile* cbc_file = create_cbc_sys_file(cbc_context); - struct file *f; - int n; - char *p; - if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { - goto next(-1); - } - goto file_read(cbc_context,f, p, n, next); + cbc_sys_file->f = f; + cbc_sys_file->n = n; + cbc_sys_file->p = p; + goto cbc_read(cbc_context,cbc_sys_file); } int sys_read(void)