summaryrefslogtreecommitdiff
path: root/lib/sys/sys+openbsd-x64.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
committerOri Bernstein <ori@eigenstate.org>2016-05-17 22:00:50 -0700
commit7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9 (patch)
treec9434a55ea6850aee7103f608c6333cfe3148d60 /lib/sys/sys+openbsd-x64.myr
parentc96238b89583ed91e92ad909c507797d00015e95 (diff)
downloadmc-7aac15b2bfcc5eec279aa14f9f199685f9d7e0d9.tar.gz
New syntax for casts.
Diffstat (limited to 'lib/sys/sys+openbsd-x64.myr')
-rw-r--r--lib/sys/sys+openbsd-x64.myr80
1 files changed, 40 insertions, 40 deletions
diff --git a/lib/sys/sys+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index bdf7f26..975051c 100644
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -253,7 +253,7 @@ pkg sys =
const Fosetlk : fcntlcmd = 8 /* set record locking information */
/* return value for a failed mapping */
- const Mapbad : byte# = -1 castto(byte#)
+ const Mapbad : byte# = (-1 : byte#)
/* syscalls */
const Syssyscall : scno = 0
@@ -536,9 +536,9 @@ pkg sys =
/*
wraps a syscall argument, converting it to 64 bits for the syscall function. This is
-the same as casting, but more concise than writing castto(int64)
+the same as casting, but more concise than writing a cast to uint64
*/
-generic a = {x : @t; -> x castto(uint64)}
+generic a = {x : @t; -> (x : uint64)}
extern const cstring : (str : byte[:] -> byte#)
extern const alloca : (sz : size -> byte#)
@@ -548,12 +548,12 @@ extern const __freebsd_pipe : (fds : fd[2]# -> int64)
/* process management */
const exit = {status; syscall(Sysexit, a(status))}
-const getpid = {; -> syscall(Sysgetpid, 1) castto(pid)}
+const getpid = {; -> (syscall(Sysgetpid, 1) : pid)}
const kill = {pid, sig; -> syscall(Syskill, pid, sig)}
-const fork = {; -> syscall(Sysfork) castto(pid)}
+const fork = {; -> (syscall(Sysfork) : pid)}
const wait4 = {pid, loc, opt, usage; -> syscall(Syswait4, pid, loc, opt, usage)}
const waitpid = {pid, loc, opt;
- -> wait4(pid, loc, opt, 0 castto(rusage#))
+ -> wait4(pid, loc, opt, (0 : rusage#))
}
const execv = {cmd, args
@@ -562,11 +562,11 @@ const execv = {cmd, args
/* of course we fucking have to duplicate this code everywhere,
* since we want to stack allocate... */
p = alloca((args.len + 1)*sizeof(byte#))
- cargs = (p castto(byte##))[:args.len + 1]
+ cargs = (p : byte##)[:args.len + 1]
for i = 0; i < args.len; i++
cargs[i] = cstring(args[i])
;;
- cargs[args.len] = 0 castto(byte#)
+ cargs[args.len] = (0 : byte#)
-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
}
@@ -576,11 +576,11 @@ const execve = {cmd, args, env
/* copy the args */
p = alloca((args.len + 1)*sizeof(byte#))
- cargs = (p castto(byte##))[:args.len]
+ cargs = (p : byte##)[:args.len]
for i = 0; i < args.len; i++
cargs[i] = cstring(args[i])
;;
- cargs[args.len] = 0 castto(byte#)
+ cargs[args.len] = (0 : byte#)
/*
copy the env.
@@ -588,58 +588,58 @@ const execve = {cmd, args, env
since we want to stack allocate...
*/
p = alloca((env.len + 1)*sizeof(byte#))
- cenv = (p castto(byte##))[:env.len]
+ cenv = (p : byte##)[:env.len]
for i = 0; i < env.len; i++
cenv[i] = cstring(env[i])
;;
- cenv[env.len] = 0 castto(byte#)
+ cenv[env.len] = (0 : byte#)
-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
}
/* fd manipulation */
-const open = {path, opts; -> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
-const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
+const open = {path, opts; -> (syscall(Sysopen, cstring(path), a(opts), a(0o777)) : fd)}
+const openmode = {path, opts, mode; -> (syscall(Sysopen, cstring(path), a(opts), a(mode)) : fd)}
const close = {fd; -> syscall(Sysclose, a(fd))}
-const creat = {path, mode; -> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
-const unlink = {path; -> syscall(Sysunlink, cstring(path)) castto(int)}
-const read = {fd, buf; -> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const write = {fd, buf; -> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const creat = {path, mode; -> (openmode(path, Ocreat | Otrunc | Owronly, mode) : fd)}
+const unlink = {path; -> (syscall(Sysunlink, cstring(path)) : int)}
+const read = {fd, buf; -> (syscall(Sysread, a(fd), (buf : byte#), a(buf.len)) : size)}
+const write = {fd, buf; -> (syscall(Syswrite, a(fd), (buf : byte#), a(buf.len)) : size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, a(fd), a(off), a(whence))}
const stat = {path, sb; -> syscall(Sysstat, cstring(path), a(sb))}
const lstat = {path, sb; -> syscall(Syslstat, cstring(path), a(sb))}
const fstat = {fd, sb; -> syscall(Sysfstat, a(fd), a(sb))}
-const mkdir = {path, mode; -> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
-generic ioctl = {fd, req, arg; -> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)}
+const mkdir = {path, mode; -> (syscall(Sysmkdir, cstring(path), a(mode)) : int64)}
+generic ioctl = {fd, req, arg; -> (syscall(Sysioctl, a(fd), a(req), a(arg)) : int64)}
const chdir = {dir; -> syscall(Syschdir, cstring(dir))}
const __getcwd = {buf; -> syscall(Sys__getcwd, a(buf), a(buf.len))}
-const getdents = {fd, buf; -> syscall(Sysgetdents, a(buf), a(buf.len)) castto(int64)}
+const getdents = {fd, buf; -> (syscall(Sysgetdents, a(buf), a(buf.len)) : int64)}
/* file stuff */
const pipe = {fds; -> syscall(Syspipe, fds)}
-const dup = {fd; -> syscall(Sysdup, a(fd)) castto(fd)}
-const dup2 = {src, dst; -> syscall(Sysdup2, a(src), a(dst)) castto(fd)}
+const dup = {fd; -> (syscall(Sysdup, a(fd)) : fd)}
+const dup2 = {src, dst; -> (syscall(Sysdup2, a(src), a(dst)) : fd)}
const fcntl = {fd, cmd, args; -> syscall(Sysfcntl, a(fd), a(cmd), a(args))}
/* networking */
-const socket = {dom, stype, proto; -> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd) }
-const connect = {sock, addr, len; -> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
-const accept = {sock, addr, len; -> syscall(Sysaccept, a(sock), a(addr), a(len)) castto(fd)}
-const listen = {sock, backlog; -> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
-const bind = {sock, addr, len; -> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
-const setsockopt = {sock, lev, opt, val, len; -> syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) castto(int)}
-const getsockopt = {sock, lev, opt, val, len; -> syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) castto(int)}
+const socket = {dom, stype, proto; -> (syscall(Syssocket, a(dom), a(stype), a(proto)) : fd)}
+const connect = {sock, addr, len; -> (syscall(Sysconnect, a(sock), a(addr), a(len)) : int)}
+const accept = {sock, addr, len; -> (syscall(Sysaccept, a(sock), a(addr), a(len)) : fd)}
+const listen = {sock, backlog; -> (syscall(Syslisten, a(sock), a(backlog)) : int)}
+const bind = {sock, addr, len; -> (syscall(Sysbind, a(sock), a(addr), a(len)) : int)}
+const setsockopt = {sock, lev, opt, val, len; -> (syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) : int)}
+const getsockopt = {sock, lev, opt, val, len; -> (syscall(Syssetsockopt, a(sock), a(lev), a(opt), a(val), a(len)) : int)}
/* memory management */
const munmap = {addr, len; -> syscall(Sysmunmap, a(addr), a(len))}
const mmap = {addr, len, prot, flags, fd, off;
- -> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)
+ -> (syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) : byte#)}
}
/* time */
-const clock_getres = {clk, ts; -> syscall(Sysclock_getres, clockid(clk), a(ts)) castto(int32)}
-const clock_gettime = {clk, ts; -> syscall(Sysclock_gettime, clockid(clk), a(ts)) castto(int32)}
-const clock_settime = {clk, ts; -> syscall(Sysclock_settime, clockid(clk), a(ts)) castto(int32)}
+const clock_getres = {clk, ts; -> (syscall(Sysclock_getres, clockid(clk), a(ts)) : int32)}
+const clock_gettime = {clk, ts; -> (syscall(Sysclock_gettime, clockid(clk), a(ts)) : int32)}
+const clock_settime = {clk, ts; -> (syscall(Sysclock_settime, clockid(clk), a(ts)) : int32)}
const sleep = {time
var req, rem
@@ -647,7 +647,7 @@ const sleep = {time
-> nanosleep(&req, &rem)
}
-const nanosleep = {req, rem; -> syscall(Sysnanosleep, a(req), a(rem)) castto(int32)}
+const nanosleep = {req, rem; -> (syscall(Sysnanosleep, a(req), a(rem)) : int32)}
/* system information */
@@ -714,16 +714,16 @@ const sysctl = {mib, old, new
var newsz
var ret
- mibp = mib castto(byte#)
+ mibp = (mib : byte#)
mibsz = a(mib.len)
o = old#
- oldp = o castto(byte#)
- oldsz = o.len castto(int64)
- newp = new castto(byte#)
+ oldp = (o : byte#)
+ oldsz = (o.len : int64)
+ newp = (new : byte#)
newsz = a(new.len)
/* all args already passed through a() or ar ptrs */
- ret = syscall(Sys__sysctl, mibp, mibsz, oldp, a(&oldsz), newp, newsz) castto(int)
+ ret = (syscall(Sys__sysctl, mibp, mibsz, oldp, a(&oldsz), newp, newsz) : int)
old# = o[:oldsz]
-> ret