diff options
Diffstat (limited to 'lib9p/idl.gen')
-rwxr-xr-x | lib9p/idl.gen | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib9p/idl.gen b/lib9p/idl.gen index f154cb1..b179415 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -73,7 +73,9 @@ def c_ver_cond(versions: set[str]) -> str: def c_typename(typ: idl.Type, parent: idl.Type | None = None) -> str: match typ: case idl.Primitive(): - if typ.value == 1 and parent and parent.name in ["d", "s"]: # SPECIAL + if ( + typ.value == 1 and parent and parent.name in ["d", "d_signed", "s"] + ): # SPECIAL return "[[gnu::nonstring]] char" return f"uint{typ.value*8}_t" case idl.Number(): @@ -499,7 +501,7 @@ LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) ret += f"{inline} static bool validate_{typ.name}(struct _validate_ctx *{argfn('ctx')}) {{\n" - if typ.name == "d": # SPECIAL + if typ.name == "d" or typ.name == "d_signed": # SPECIAL # Optimize... maybe the compiler could figure out to do # this, but let's make it obvious. ret += "\tuint32_t base_offset = ctx->net_offset;\n" @@ -672,7 +674,7 @@ LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *o ret += f"out->{member.name} = ctx->extra;\n" ret += f"{prefix}ctx->extra += sizeof(out->{member.name}[0]) * out->{member.cnt.name};\n" ret += f"{prefix}for (typeof(out->{member.cnt.name}) i = 0; i < out->{member.cnt.name}; i++)\n" - if typ.name in ["d", "s"]: # SPECIAL + if typ.name in ["d", "d_signed", "s"]: # SPECIAL # Special-case is that we cast from `char` to `uint8_t`. ret += f"{prefix}\tunmarshal_{member.typ.name}(ctx, (uint8_t *)&out->{member.name}[i]);\n" else: @@ -775,7 +777,7 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) ret += "({ bool err = false;\n" ret += f"\t for (typeof(val->{member.cnt.name}) i = 0; i < val->{member.cnt.name} && !err; i++)\n" ret += "\t \terr = " - if typ.name in ["d", "s"]: # SPECIAL + if typ.name in ["d", "d_signed", "s"]: # SPECIAL # Special-case is that we cast from `char` to `uint8_t`. ret += f"marshal_{member.typ.name}(ctx, (uint8_t *)&val->{member.name}[i]);\n" else: |