diff options
Diffstat (limited to 'lib9p/types.gen')
-rwxr-xr-x | lib9p/types.gen | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib9p/types.gen b/lib9p/types.gen index a597022..9946e35 100755 --- a/lib9p/types.gen +++ b/lib9p/types.gen @@ -379,7 +379,7 @@ const char *{idprefix}msg_type_str(enum {idprefix}msg_type typ) {{ ret += """ /* checksize_* (internals of unmarshal_size()) ********************************/ -static inline bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { +static ALWAYS_INLINE bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { if (__builtin_add_overflow(ctx->net_offset, n, &ctx->net_offset)) /* If needed-net-size overflowed uint32_t, then * there's no way that actual-net-size will live up to @@ -390,7 +390,7 @@ static inline bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { return false; } -static inline bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { +static ALWAYS_INLINE bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { if (__builtin_add_overflow(ctx->host_extra, n, &ctx->host_extra)) /* If needed-host-size overflowed size_t, then there's * no way that actual-net-size will live up to @@ -399,7 +399,7 @@ static inline bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { return false; } -static inline bool _checksize_list(struct _checksize_ctx *ctx, +static ALWAYS_INLINE bool _checksize_list(struct _checksize_ctx *ctx, size_t cnt, _checksize_fn_t item_fn, size_t item_host_size) { for (size_t i = 0; i < cnt; i++) if (_checksize_host(ctx, item_host_size) || item_fn(ctx)) @@ -413,7 +413,7 @@ static inline bool _checksize_list(struct _checksize_ctx *ctx, #define checksize_8(ctx) _checksize_net(ctx, 8) """ for struct in structs: - inline = " inline" if struct.msgid is None else "" + inline = " ALWAYS_INLINE" if struct.msgid is None else " FLATTEN" argfn = used if struct.members else unused ret += "\n" ret += f"static{inline} bool checksize_{struct.name}(struct _checksize_ctx *{argfn('ctx')}) {{" @@ -475,28 +475,28 @@ static inline bool _checksize_list(struct _checksize_ctx *ctx, ret += """ /* unmarshal_* ****************************************************************/ -static inline void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { +static ALWAYS_INLINE void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 1; } -static inline void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { +static ALWAYS_INLINE void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 2; } -static inline void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { +static ALWAYS_INLINE void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 4; } -static inline void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { +static ALWAYS_INLINE void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 8; } """ for struct in structs: - inline = " inline" if struct.msgid is None else "" + inline = " ALWAYS_INLINE" if struct.msgid is None else " FLATTEN" argfn = used if struct.members else unused ret += "\n" ret += f"static{inline} void unmarshal_{struct.name}(struct _unmarshal_ctx *{argfn('ctx')}, {c_typename(idprefix, struct)} *out) {{\n" @@ -527,7 +527,7 @@ static inline void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { ret += """ /* marshal_* ******************************************************************/ -static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { +static ALWAYS_INLINE bool _marshal_too_large(struct _marshal_ctx *ctx) { lib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")", (ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message", ctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"), @@ -535,7 +535,7 @@ static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { return true; } -static inline bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { +static ALWAYS_INLINE bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { if (ctx->net_offset + 1 > ctx->ctx->max_msg_size) return _marshal_too_large(ctx); ctx->net_bytes[ctx->net_offset] = *val; @@ -543,7 +543,7 @@ static inline bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { return false; } -static inline bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { +static ALWAYS_INLINE bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { if (ctx->net_offset + 2 > ctx->ctx->max_msg_size) return _marshal_too_large(ctx); encode_u16le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -551,7 +551,7 @@ static inline bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { return false; } -static inline bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { +static ALWAYS_INLINE bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { if (ctx->net_offset + 4 > ctx->ctx->max_msg_size) return true; encode_u32le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -559,7 +559,7 @@ static inline bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { return false; } -static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { +static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { if (ctx->net_offset + 8 > ctx->ctx->max_msg_size) return true; encode_u64le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -568,7 +568,7 @@ static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { } """ for struct in structs: - inline = " inline" if struct.msgid is None else "" + inline = " ALWAYS_INLINE" if struct.msgid is None else " FLATTEN" argfn = used if struct.members else unused ret += "\n" ret += f"static{inline} bool marshal_{struct.name}(struct _marshal_ctx *{argfn('ctx')}, {c_typename(idprefix, struct)} *{argfn('val')}) {{" |