# HG changeset patch # User tobaru # Date 1571222437 -32400 # Node ID f38d8d39d617d8947d052fec00ad44f712c07d09 # Parent add5e775339ce0ab4b1a64a0fd7288bd16eafd46 add file interface diff -r add5e775339c -r f38d8d39d617 src/interface/File.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/interface/File.h Wed Oct 16 19:40:37 2019 +0900 @@ -0,0 +1,8 @@ +typedef struct File{ + union Data* file; + struct file *f; + int n; + char *p; + __code file_read(__code, next(...)); + __code next(...); +} File; diff -r add5e775339c -r f38d8d39d617 src/sysfile.cbc --- a/src/sysfile.cbc Tue Oct 15 20:13:25 2019 +0900 +++ b/src/sysfile.cbc Wed Oct 16 19:40:37 2019 +0900 @@ -87,6 +87,20 @@ goto cbc_fileread(f, p, n, next); } +__code file_read(struct file *f, int n, char *p, __code next(...)){ + goto cbc_fileread(f, p, n, next); +} + +__code file_read_stub(struct Context* 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 cbc_fileread(f, p, n, next); +} + int sys_read(void) { struct file *f;