ref: de0a04474a050a5b877ccc9be2381b870c17e222
parent: 3b6a42aaa1dfb75db06e9bf8cb7953cecefc647f
author: Frank Smit <frank@61924.nl>
date: Sun Oct 25 12:10:09 EDT 2020
Add missing flowinfo to sockaddr_in6 struct.
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -11,18 +11,18 @@
type time = int64 /* milliseconds since epoch */
type scno = int64 /* syscall */
type ioctlno = int64 /* ioctl */
-
+
/* processes/threads */
type pid = int /* process id */
type tid = int /* thread id */
type cloneopt = int64 /* options for clone(2) */
-
+
/* file descriptor manipulation */
type fdopt = int64 /* fd options */
type fd = int32 /* fd */
type whence = uint64 /* seek from whence */
type filemode = uint32 /* file open mode */
-
+
type mprot = int64 /* memory protection */
type mopt = int64 /* memory mapping options */
type socktype = int64 /* socket type */
@@ -31,13 +31,13 @@
type sockopt = int64
type msgflags = uint32
type cmsgtype = uint32
-
+
type epollflags = uint32
type epollop = uint32
type epollevttype = uint32
-
+
type pollevt = uint16
-
+
type futexop = uint32
type signo = int32
type sigflags = int64
@@ -46,8 +46,8 @@
type aiocontext = uint64
type msg = void#
type arch_prctlop = uint64
-
-
+
+
type clock = union
`Clockrealtime
`Clockmonotonic
@@ -60,7 +60,7 @@
`Clockrealtimealarm
`Clockboottimealarm
;;
-
+
type waitstatus = union
`Waitexit int32
`Waitsig int32
@@ -67,11 +67,11 @@
`Waitstop int32
`Waitfail int32
;;
-
+
type sigset = struct
bits : uint32[2]
;;
-
+
type sigaction = struct
handler : byte# /* code pointer */
flags : sigflags
@@ -78,21 +78,21 @@
restore : byte# /* code pointer */
mask : sigset
;;
-
+
const Sipadsz = 128
type siginfo = struct
signo : int
errno : int
code : int
-
+
_pad : int[Sipadsz]
;;
-
+
/* union { int, void* } */
type sigval = struct
_pad : void#
;;
-
+
const Sigevmaxsz = 64
const Sigevpadsz = Sigevmaxsz / sizeof(int) - 4
type sigevent = struct
@@ -101,17 +101,17 @@
notify : int
_pad : int[Sigevpadsz]
;;
-
+
type timespec = struct
sec : int64
nsec : int64
;;
-
+
type timeval = struct
sec : int64
usec : int64
;;
-
+
type timex = struct
modes : uint /* mode selector */
offset : int64 /* time offset (usec) */
@@ -124,7 +124,7 @@
tolerance : int64 /* clock frequency tolerance (ppm) */
time : timeval /* (read only, except for ADJ_SETOFFSET) */
tick : int64 /* (modified) usecs between clock ticks */
-
+
ppsfreq : int64 /* pps frequency (scaled ppm) (ro) */
jitter : int64 /* pps jitter (us) (ro) */
shift : int /* interval duration (s) (shift) (ro) */
@@ -133,41 +133,41 @@
calcnt : int64 /* calibration intervals (ro) */
errcnt : int64 /* calibration errors (ro) */
stbcnt : int64 /* stability limit exceeded (ro) */
-
+
tai : int /* TAI offset (ro) */
-
+
__pad : int[11]
;;
-
-
+
+
type rusage = struct
utime : timeval /* user time */
stime : timeval /* system time */
_opaque : uint64[14] /* padding (darwin-specific data) */
;;
-
+
type sched_param = struct
priority : int
;;
-
+
type sched_attr = struct
size : uint32
sched_policy : uint32
sched_flags : uint64
-
+
/* SCHED_NORMAL, SCHED_BATCH */
sched_nice : int32
-
+
/* SCHED_FIFO, SCHED_RR */
sched_priority : uint32
-
+
/* SCHED_DEADLINE */
sched_runtime : uint64
sched_deadline : uint64
sched_period : uint64
-
+
;;
-
+
type statbuf = struct
dev : uint64
ino : uint64
@@ -185,7 +185,7 @@
ctime : timespec
__pad1 : uint64[3]
;;
-
+
type statfs = struct
kind : uint64
bsize : uint64
@@ -200,7 +200,7 @@
flags : uint64
spare : uint64[4]
;;
-
+
type ustat = struct
tfree : uint32; /* Number of free blocks. */
tinode : uint64; /* Number of free inodes. */
@@ -207,7 +207,7 @@
fname : byte[6]
fpack : byte[6]
;;
-
+
type dirent64 = struct
ino : uint64
off : uint64
@@ -215,7 +215,7 @@
etype : byte
name : byte[...] /* special case; zero length => unchecked indexing */
;;
-
+
type utsname = struct
system : byte[65]
node : byte[65]
@@ -224,12 +224,12 @@
machine : byte[65]
domain : byte[65]
;;
-
+
type sockaddr = struct
fam : sockfam
data : byte[14]
;;
-
+
type sockaddr_in = struct
fam : sockfam
port : uint16
@@ -236,25 +236,26 @@
addr : byte[4]
zero : byte[8]
;;
-
+
type sockaddr_in6 = struct
fam : sockfam
port : uint16
+ flowinfo : uint32
addr : byte[16]
scope : uint32
;;
-
+
type sockaddr_un = struct
fam : sockfam
path : byte[108]
;;
-
+
type sockaddr_storage = struct
fam : sockfam
__align : uint32
__pad : byte[112]
;;
-
+
type bpfgattr = void#
type bpfmapattr = struct
maptype : uint32
@@ -263,7 +264,7 @@
mapents : uint32
mapflg : uint32
;;
-
+
type bpfeltattr = struct
fd : uint32
key : uint64
@@ -270,7 +271,7 @@
val : uint64
flg : uint64
;;
-
+
type bpfprogattr = struct
kind : uint32
insncnt : uint32
@@ -281,12 +282,12 @@
logbuf : uint64
kvers : uint32
;;
-
+
type bpfobjattr = struct
path : uint64
fd : uint32
;;
-
+
type bfpattachattr = struct
targfd : uint32
fd : uint32
@@ -293,38 +294,38 @@
kind : uint32
flags : uint32
;;
-
+
type epollevt = struct
events : epollevttype
data : byte[8]
;;
-
+
type pollfd = struct
fd : fd
events : pollevt
revents : pollevt
;;
-
+
type file_handle = struct
bytes : uint
kind : int
handle : byte[...]
;;
-
+
type iovec = struct
base : byte#
len : uint64
;;
-
+
type semun = struct
__pad : void#
;;
-
+
type msgbuf = struct
mtype : int64
buf : byte[...]
;;
-
+
type msghdr = struct
name : sockaddr#
namelen : int32
@@ -334,11 +335,11 @@
controllen : uint64
flags : msgflags
;;
-
+
type getcpu_cache = struct
__opaque : byte[128]
;;
-
+
type perf_event_attr = struct
kind : uint32
size : uint32
@@ -359,12 +360,12 @@
samplestack : uint16
reserved : uint16
;;
-
+
type mmsghdr = struct
hdr : msghdr
len : uint32
;;
-
+
type cmsghdr = struct
len : uint64
level : sockproto
@@ -371,18 +372,18 @@
cmtype : cmsgtype
data : byte[...]
;;
-
+
type capuserheader = struct
version : uint32
pid : int
;;
-
+
type capuserdata = struct
effective : uint32
permitted : uint32
inheritable : uint32
;;
-
+
type kexec_segment = struct
buf : void#
bufsz : size
@@ -389,7 +390,7 @@
mem : void#
memsz : size
;;
-
+
/* clone options */
const Clonesignal : cloneopt = 0xff
const Clonevm : cloneopt = 0x100
@@ -414,10 +415,10 @@
const Clonenewpid : cloneopt = 0x20000000
const Clonenewnet : cloneopt = 0x40000000
const Cloneio : cloneopt = 0x80000000
-
+
type ptregs = struct
;;
-
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
@@ -433,7 +434,7 @@
const Onofollow : fdopt = 0x20000
const Onoatime : fdopt = 0x40000
const Ocloexec : fdopt = 0x80000
-
+
/* stat modes */
const Sifmt : filemode = 0xf000
const Sififo : filemode = 0x1000
@@ -443,7 +444,7 @@
const Sifreg : filemode = 0x8000
const Siflnk : filemode = 0xa000
const Sifsock : filemode = 0xc000
-
+
/* mmap protection */
const Mprotnone : mprot = 0x0
const Mprotrd : mprot = 0x1
@@ -450,7 +451,7 @@
const Mprotwr : mprot = 0x2
const Mprotexec : mprot = 0x4
const Mprotrw : mprot = 0x3 /* convenience */
-
+
/* mmap options */
const Mshared : mopt = 0x1
const Mpriv : mopt = 0x2
@@ -458,13 +459,13 @@
const Mfile : mopt = 0x0
const Manon : mopt = 0x20
const M32bit : mopt = 0x40
-
+
/* socket families. INCOMPLETE. */
const Afunspec : sockfam = 0
const Afunix : sockfam = 1
const Afinet : sockfam = 2
const Afinet6 : sockfam = 10
-
+
/* socket types. */
const Sockstream : socktype = 1 /* sequenced, reliable byte stream */
const Sockdgram : socktype = 2 /* datagrams */
@@ -473,7 +474,7 @@
const Sockseqpacket : socktype = 5 /* sequenced, reliable packets */
const Sockdccp : socktype = 6 /* data congestion control protocol */
const Sockpack : socktype = 10 /* linux specific packet */
-
+
/* socket options */
const Sodebug : sockopt = 1
const Soreuseaddr : sockopt = 2
@@ -498,10 +499,10 @@
const Sosndlowat : sockopt = 19
const Sorcvtimeo : sockopt = 20
const Sosndtimeo : sockopt = 21
-
+
/* socket option levels */
const Solsocket : sockproto = 1
-
+
/* network protocols */
const Ipproto_ip : sockproto = 0
const Ipproto_icmp : sockproto = 1
@@ -508,7 +509,7 @@
const Ipproto_tcp : sockproto = 6
const Ipproto_udp : sockproto = 17
const Ipproto_raw : sockproto = 255
-
+
/* message flags */
const Msgoob : msgflags = 0x0001
const Msgpeek : msgflags = 0x0002
@@ -518,18 +519,18 @@
const Msgeor : msgflags = 0x0080
const Msgwaitall : msgflags = 0x0100
const Msgnosignal : msgflags = 0x4000
-
+
/* ancillary data */
const Scmrights : cmsgtype = 1
-
+
/* epoll flags */
const Epollcloexec : epollflags = 0o2000000
-
+
/* epoll ops */
const Epollctladd : epollop = 1
const Epollctlmod : epollop = 2
const Epollctldel : epollop = 3
-
+
/* epoll events */
const Epollin : epollevttype = 0x001
const Epollpri : epollevttype = 0x002
@@ -545,7 +546,7 @@
const Epollwakeup : epollevttype = 1 << 29
const Epolloneshot : epollevttype = 1 << 30
const Epolledge : epollevttype = 1 << 31
-
+
/* futex ops */
const Futexwait : futexop = 0
const Futexwake : futexop = 1
@@ -560,12 +561,12 @@
const Futexwakebitset : futexop = 10
const Futexwaitrequeuepi : futexop = 11
const Futexcmprequeuepi : futexop = 12
-
+
const Futexpriv : futexop = 128
const Futexclockrt : futexop = 256
-
+
const Futexbitsetmatchany : int32 = -1
-
+
/* poll events : posix */
const Pollin : pollevt = 0x001 /* There is data to read. */
const Pollpri : pollevt = 0x002 /* There is urgent data to read. */
@@ -573,22 +574,22 @@
const Pollerr : pollevt = 0x008 /* Error condition. */
const Pollhup : pollevt = 0x010 /* Hung up. */
const Pollnval : pollevt = 0x020 /* Invalid polling request. */
-
+
/* poll events: xopen */
const Pollrdnorm : pollevt = 0x040 /* Normal data may be read. */
const Pollrdband : pollevt = 0x080 /* Priority data may be read. */
const Pollwrnorm : pollevt = 0x100 /* Writing now will not block. */
const Pollwrband : pollevt = 0x200 /* Priority data may be written. */
-
+
/* poll events: linux */
const Pollmsg : pollevt = 0x400
const Pollremove : pollevt = 0x1000
const Pollrdhup : pollevt = 0x2000
-
+
const Seekset : whence = 0
const Seekcur : whence = 1
const Seekend : whence = 2
-
+
/* return value for a failed mapping */
const Mapbad : byte# = (-1 : byte#)
@@ -597,7 +598,7 @@
const Archsetfs : arch_prctlop = 0x1002
const Archgetfs : arch_prctlop = 0x1003
const Archgetgs : arch_prctlop = 0x1004
-
+
/* signal flags */
const Sanocldstop : sigflags = 0x00000001
const Sanocldwait : sigflags = 0x00000002
@@ -609,7 +610,7 @@
const Saresethand : sigflags = 0x80000000
const Sanomask : sigflags = Sanodefer
const Saoneshot : sigflags = Saresethand
-
+
/* signal numbers */
const Sighup : signo = 1
const Sigint : signo = 2
@@ -642,7 +643,7 @@
const Sigwinch : signo = 28
const Sigio : signo = 29
const Sigpoll : signo = Sigio
-
+
/* fallocate mode */
const Fallockeepsize : fallocmode = 0x01
const Fallocpunchhole : fallocmode = 0x02
@@ -650,14 +651,14 @@
const Falloccollapserange : fallocmode = 0x08
const Falloczerorange : fallocmode = 0x10
const Fallocinsertrange : fallocmode = 0x20
-
+
/* memfd flags */
const Mfdcloexec : mfdflags = 0x01
const Mfdallowsealing : mfdflags = 0x02
-
+
/* exported values: initialized by start code */
extern var __cenvp : byte##
-
+
type kernel_clock = int64
type uid = uint
type gid = uint
@@ -679,61 +680,61 @@
type kernel_ipc_pid = int
type kernel_long = int64
type s32 = int
-
+
type timezone = struct
minuteswest : int
dsttime : int
-
+
;;
-
+
type tms = struct
utime : kernel_clock
stime : kernel_clock
cutime : kernel_clock
cstime : kernel_clock
-
+
;;
-
+
type user_cap_header_struct = struct
version : uint32
pid : int
-
+
;;
-
+
type user_cap_data_struct = struct
effective : uint32
permitted : uint32
inheritable : uint32
-
+
;;
-
+
type sigaltstack = struct
sp : void#
flags : int
size : size
-
+
;;
-
+
type itimerval = struct
interval : timeval
value : timeval
-
+
;;
-
+
type itimerspec = struct
interval : timespec
value : timespec
-
+
;;
-
+
type io_event = struct
data : uint64
obj : uint64
res : s64
res2 : s64
-
+
;;
-
+
type iocb = struct
data : uint64
key : uint32
@@ -747,32 +748,32 @@
reserved2 : uint64
flags : uint32
resfd : uint32
-
+
;;
-
+
type utimbuf = struct
actime : kernel_time
modtime : kernel_time
-
+
;;
-
+
type fdset = struct
bits : fd_mask[16]
-
+
;;
-
+
type rlimit = struct
cur : kernel_ulong
max : kernel_ulong
-
+
;;
-
+
type rlimit64 = struct
cur : uint64
max : uint64
-
+
;;
-
+
type ipc_perm = struct
key : kernel_key
uid : kernel_uid
@@ -781,9 +782,9 @@
cgid : kernel_gid
mode : kernel_mode
seq : uint16
-
+
;;
-
+
type msqid_ds = struct
perm : ipc_perm
first : msg#
@@ -798,16 +799,16 @@
qbytes : uint16
lspid : kernel_ipc_pid
lrpid : kernel_ipc_pid
-
+
;;
-
+
type sembuf = struct
num : uint16
op : int16
flg : int16
-
+
;;
-
+
type shmid_ds = struct
perm : ipc_perm
segsz : int
@@ -820,9 +821,9 @@
unused : uint16
unused2 : void#
unused3 : void#
-
+
;;
-
+
type mq_attr = struct
mq_flags : kernel_long
mq_maxmsg : kernel_long
@@ -829,9 +830,9 @@
mq_msgsize : kernel_long
mq_curmsgs : kernel_long
__reserved : kernel_long[4]
-
+
;;
-
+
type sysctl_args = struct
name : int#
nlen : int
@@ -840,9 +841,9 @@
newval : void#
newlen : size
__unused : uint64[4]
-
+
;;
-
+
type sysinfo = struct
uptime : kernel_long
loads : kernel_ulong[3]
@@ -858,22 +859,22 @@
freehigh : kernel_ulong
mem_unit : uint32
_f : byte[0]
-
+
;;
-
+
type robust_list = struct
next : robust_list#
-
+
;;
-
+
type robust_list_head = struct
list : robust_list
futex_offset : int64
list_op_pending : robust_list#
-
+
;;
-
+
const Systime : scno = 201
const Sysgettimeofday : scno = 96
const Syssettimeofday : scno = 164
@@ -1574,39 +1575,39 @@
/* start manual overrides { */
/* getting to the os */
-
+
/* process management */
/* FIXME: where the fuck is 'struct pt_reg' defined?? */
/* wrappers to extract wait status */
-
+
/* file manipulation */
-
+
/* signals */
-
+
/* fd stuff */
-
+
/* threading */
-
+
/* polling */
-
+
/* networking */
-
+
/* memory mapping */
-
+
/* time */
-
+
/* user/group management */
-
+
/* system information */
-
+
/*
wraps a syscall argument, converting it to 64 bits for the syscall function.
This is the same as casting, but more concise than writing a cast to int64.
*/
generic a = {x : @t; -> (x : uint64)}
-
+
/* asm stubs from util.s */
-
+
/* process management */
const exit = {status; syscall(Sysexit, a(status))}
const exit_group = {status; syscall(Sysexit_group, a(status))}
@@ -1619,10 +1620,10 @@
var rusage
-> wait4(pid, loc, opt, &rusage)
}
-
+
const execv = {cmd, args
var p, cargs, i
-
+
/* of course we fucking have to duplicate this code everywhere,
* since we want to stack allocate... */
p = alloca((args.len + 1)*sizeof(byte#))
@@ -1633,11 +1634,11 @@
cargs[args.len] = (0 : byte#)
-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
}
-
+
const execve = {cmd, args, env
var cargs, cenv, i
var ap, ep
-
+
/* copy the args */
ap = alloca((args.len + 1)*sizeof(byte#))
cargs = (ap : byte##)[:args.len + 1]
@@ -1645,7 +1646,7 @@
cargs[i] = cstring(args[i])
;;
cargs[args.len] = (0 : byte#)
-
+
/*
copy the env.
of course we fucking have to duplicate this code everywhere,
@@ -1657,10 +1658,10 @@
cenv[i] = cstring(env[i])
;;
cenv[env.len] = (0 : byte#)
-
+
-> syscall(Sysexecve, cstring(cmd), a(ap), a(ep))
}
-
+
/* file manipulation */
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)}
@@ -1686,12 +1687,12 @@
const recvmsg = {fd, msg, flags; -> syscall(Sysrecvmsg, a(fd), msg, a(flags))}
const fallocate = {fd, mode, off, len; -> syscall(Sysfallocate, a(fd), a(mode), a(off), a(len))}
const memfdcreate = {name, flags; -> (syscall(Sysmemfd_create, cstring(name), a(flags)) : fd)}
-
+
/* file stuff */
const pipe = {fds; -> syscall(Syspipe, a(fds))}
const dup = {fd; -> (syscall(Sysdup, a(fd)) : fd)}
const dup2 = {src, dst; -> (syscall(Sysdup2, a(src), a(dst)) : fd)}
-
+
const sigaction = {sig, act, oact;
if act.restore == (0 : byte#)
act.flags |= Sarestorer
@@ -1700,7 +1701,7 @@
-> (syscall(Sysrt_sigaction, a(sig), a(act), a(oact), a(sizeof(sigflags))) : int)
}
const sigprocmask = {sig, act, oact; -> (syscall(Sysrt_sigprocmask, a(sig), a(act), a(oact), a(sizeof(sigflags))) : int)}
-
+
/* threading */
const futex = {uaddr, op, val, timeout, uaddr2, val3
-> (syscall(Sysfutex, a(uaddr), a(op), a(val), a(timeout), a(uaddr2), a(val3)) : int)
@@ -1708,7 +1709,7 @@
const semctl = {semid, semnum, cmd, arg
-> (syscall(Syssemctl, a(semnum), a(cmd), a(arg)) : int)
}
-
+
/* poll */
const poll = {pfd, timeout; -> (syscall(Syspoll, (pfd : pollfd#), a(pfd.len), a(timeout)) : int)}
const epollctl = {epfd, op, fd, evt;
@@ -1716,7 +1717,7 @@
const epollwait = {epfd, evts, timeout;
-> (syscall(Sysepoll_wait, a(epfd), (evts : epollevt#), a(evts.len), a(timeout)) : int)}
const epollcreate = {flg; -> (syscall(Sysepoll_create1, a(flg)) : fd)}
-
+
/* networking */
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)}
@@ -1725,28 +1726,28 @@
const accept = {sock, addr, lenp; -> (syscall(Sysaccept, a(sock), a(addr), a(lenp)) : fd)}
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 mapping */
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)) : byte#)
}
-
+
/* time */
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 nanosleep = {req, rem; -> (syscall(Sysnanosleep, a(req), a(rem)) : int32)}
-
+
/* user/group management */
const getuid = {; -> (syscall(Sysgetuid) : uint32)}
const getgid = {; -> (syscall(Sysgetgid) : uint32)}
const setuid = {uid; -> (syscall(Syssetuid, a(uid)) : int32)}
const setgid = {gid; -> (syscall(Syssetgid, a(gid)) : int32)}
-
+
/* system information */
const uname = {buf; -> (syscall(Sysuname, buf) : int)}
-
+
const clockid = {clk
match clk
| `Clockrealtime: -> 0
@@ -1762,8 +1763,8 @@
;;
-> -1
}
-
-
+
+
const waitstatus = {st
if st & 0x7f == 0 /* if exited */
-> `Waitexit ((st & 0xff00) >> 8)
--- a/support/syscall-gen/types+linux-x64.frag
+++ b/support/syscall-gen/types+linux-x64.frag
@@ -233,6 +233,7 @@
type sockaddr_in6 = struct
fam : sockfam
port : uint16
+ flowinfo : uint32
addr : byte[16]
scope : uint32
;;