aboutsummaryrefslogtreecommitdiffstats
path: root/docs/syscall_descriptions_syntax.md
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-01-10 16:13:34 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-01-13 12:52:09 +0100
commit6b52293f4defa6b45b564d037fd641be5d6d0e0e (patch)
tree53c7f28df3fd2666ca165ce7231d470c9d1e2dc5 /docs/syscall_descriptions_syntax.md
parent9dc808a65eb3f44d64e078b79bcac0f0510629f6 (diff)
pkg/compiler: support type templates
Netlink descriptions contain tons of code duplication, and need much more for proper descriptions. Introduce type templates to simplify writing such descriptions and remove code duplication. Note: type templates are experimental, have poor error handling and are subject to change. Type templates can be declared as follows: ``` type buffer[DIR] ptr[DIR, array[int8]] type fileoff[BASE] BASE type nlattr[TYPE, PAYLOAD] { nla_len len[parent, int16] nla_type const[TYPE, int16] payload PAYLOAD } [align_4] ``` and later used as follows: ``` syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]]) ```
Diffstat (limited to 'docs/syscall_descriptions_syntax.md')
-rw-r--r--docs/syscall_descriptions_syntax.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/syscall_descriptions_syntax.md b/docs/syscall_descriptions_syntax.md
index a0b7b45b5..b8ded85bf 100644
--- a/docs/syscall_descriptions_syntax.md
+++ b/docs/syscall_descriptions_syntax.md
@@ -168,6 +168,28 @@ type bool64 int64[0:1]
type boolptr intptr[0:1]
```
+## Type Templates
+
+**Note: type templates are experimental, can have error handling bugs and are subject to change**
+
+Type templates can be declared as follows:
+
+```
+type buffer[DIR] ptr[DIR, array[int8]]
+type fileoff[BASE] BASE
+type nlattr[TYPE, PAYLOAD] {
+ nla_len len[parent, int16]
+ nla_type const[TYPE, int16]
+ payload PAYLOAD
+} [align_4]
+```
+
+and later used as follows:
+
+```
+syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]])
+```
+
## Length
You can specify length of a particular field in struct or a named argument by using `len`, `bytesize` and `bitsize` types, for example: