summaryrefslogtreecommitdiff
path: root/lib9p/core_gen/h.py
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-18 10:53:12 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-06-07 22:45:26 -0600
commit85a4545c213f1643d3b7a6dd83235b5559733023 (patch)
treec379bb04d1636ab2c802c464fb800785ceac211c /lib9p/core_gen/h.py
parent53d0b11262177cd212803fc9330e055871c348b3 (diff)
wip: lib9p: Multi-iovec replieslukeshu/9p-read-multi-iovec
Diffstat (limited to 'lib9p/core_gen/h.py')
-rw-r--r--lib9p/core_gen/h.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py
index 8c381f8..6ead5ba 100644
--- a/lib9p/core_gen/h.py
+++ b/lib9p/core_gen/h.py
@@ -162,6 +162,11 @@ def gen_h(versions: set[str], typs: list[idl.UserType]) -> str:
#ifndef _LIB9P_CORE_H_
\t#error Do not include <lib9p/_core_generated.h> directly; include <lib9p/core.h> instead
#endif
+
+struct {c9util.ident('_iovec_list')} {{
+\tstruct iovec *iov;
+\tint iovcnt;
+}};
"""
id2typ: dict[int, idl.Message] = {}
for msg in [msg for msg in typs if isinstance(msg, idl.Message)]:
@@ -523,7 +528,13 @@ def gen_struct(typ: idl.Struct) -> str: # and idl.Message
if member.val:
continue
ret += cutil.ifdef_push(2, c9util.ver_ifdef(member.in_versions))
- ret += f"\t{c9util.typename(member.typ, member):<{typewidth}} {'*' if member.cnt else ' '}{member.membname};\n"
+ ptr = bool(member.cnt)
+ if (
+ c9util.typename(member.typ, member)
+ == f"struct {c9util.ident('_iovec')}"
+ ): # SPECIAL (zerocopy)
+ ptr = False
+ ret += f"\t{c9util.typename(member.typ, member):<{typewidth}} {'*' if ptr else ' '}{member.membname};\n"
ret += cutil.ifdef_pop(1)
ret += "};\n"
return ret