From a8d7ccc4e6b9f5edaa81fc961ff462ba56a43897 Mon Sep 17 00:00:00 2001 From: Drahflow Date: Tue, 6 Aug 2013 23:09:40 +0200 Subject: More syscalls translated --- elymas/lib/sys/linux.ey | 53 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'elymas/lib/sys') diff --git a/elymas/lib/sys/linux.ey b/elymas/lib/sys/linux.ey index 0c65bbc..87e28cb 100644 --- a/elymas/lib/sys/linux.ey +++ b/elymas/lib/sys/linux.ey @@ -1,5 +1,6 @@ -# The idea of sys .linux is to define an isomorphic yet +# The idea of sys .linux is to define an near-isomorphic yet # elymas-style interface to syscalls +# argument order tends to follow kernel API < 43 ==ACCEPT @@ -306,15 +307,59 @@ 1 ==WRITE 20 ==WRITEV + 0 ==errno + + bin .scan "->" via + + # defines a syscall which has identical argument order + # to kernel API and returns the raw return value + { # ==name ==f + -01 + { sys .asm .syscall =errno } ; + -01 + deff + }' /defStdSyscall deff + + { 0 0 0 0 0 CLOSE } /close defStdSyscall + # 0 <- raw return value # 1 <- seconds since 1970 # 2 <- microseconds since 1970 { # struct timeval takes 16 bytes on a x64 - 16 str .alloc ==timeval - timeval 0 0 0 0 0 GETTIMEOFDAY sys .asm .syscall -- - timeval bin .scanu64 bin .scanu64 -123 + 16 str .alloc ==buf + buf 0 0 0 0 0 GETTIMEOFDAY sys .asm .syscall =errno + buf ->u64 -01 ->u64 + -023 } /gettimeofday deff + + # 0 -> path to stat + # 0 <- raw return value + # 1 <- (struct stat)-like scope + { + # struct stat takes 144 bytes on a x64 + 144 str .alloc ==buf + buf 0 0 0 0 STAT sys .asm .syscall =errno + buf < + ->u64 ==dev + ->u64 ==ino + ->u64 ==mode + ->u64 ==nlink + ->u64 ==uid + ->u64 ==gid + ->u64 ==rdev + ->u64 ==size + ->u64 ==blksize + ->u64 ==blocks + ->u64 ==atime + ->u64 ==mtime + ->u64 ==ctime + > -02 + } /stat deff + + { 0 0 0 OPEN } /open defStdSyscall + { 0 0 0 READ } /read defStdSyscall + { 0 0 0 WRITE } /write defStdSyscall > /linux sys .defv # vim: syn=elymas -- cgit v1.2.3