aboutsummaryrefslogtreecommitdiffstats
path: root/sys/README.md
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@gmail.com>2017-01-23 18:15:39 +0100
committerGitHub <noreply@github.com>2017-01-23 18:15:39 +0100
commitbb1ff0b5592262d20e88397f56f18e48d47d56ea (patch)
tree6eb2d4bd3090f730f9b91fddd38e2726f1a31034 /sys/README.md
parentcd23722cf2dabd28d83fa321c3cbf50a956d3fb7 (diff)
parent07880f3c010a2a5d4078b8668e05a4894fd82046 (diff)
Merge pull request #113 from xairy/parent-parent
Make it possible to specify length of parent of parent
Diffstat (limited to 'sys/README.md')
-rw-r--r--sys/README.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/README.md b/sys/README.md
index 2e5f07ec1..b5b497bc6 100644
--- a/sys/README.md
+++ b/sys/README.md
@@ -133,6 +133,36 @@ accept(fd sock, ...) sock
listen(fd sock, backlog int32)
```
+### Length
+
+You can specify length of a particular field in struct or a named argument by using `len` and `bytesize` types, for example:
+```
+write(fd fd, buf buffer[in], count len[buf]) len[buf]
+
+sock_fprog {
+ len len[filter, int16]
+ filter ptr[in, array[sock_filter]]
+}
+```
+
+If `len`'s argument is a pointer (or a `buffer`), then the length of the pointee argument is used.
+
+To denote the length of a field in N-byte words use `bytesizeN`, possible values for N are 1, 2, 4 and 8.
+
+To denote the length of the parent struct, you can use `len[parent, int8]`.
+To denote the length of the higher level parent when structs are embedded into one another, you can specify the type name of the particular parent:
+```
+struct s1 {
+ f0 len[s2] # length of s2
+}
+
+struct s2 {
+ f0 s1
+ f1 array[int32]
+}
+
+```
+
### Proc
The `proc` type can be used to denote per process integers.