diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-12-13 17:36:53 -0500 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-12-13 17:36:53 -0500 |
commit | c755f88f8c6862ef1497375df2d09454c99a0632 (patch) | |
tree | 31aea0e4d35aaf78324ffed113d6499e338d3feb /lib9p | |
parent | 4b918e6f721f34e4014fa3f0b5032037991e321f (diff) |
Gather macros into libmisc/macro.h
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/9p.generated.c | 282 | ||||
-rwxr-xr-x | lib9p/idl.gen | 38 | ||||
-rw-r--r-- | lib9p/internal.h | 27 | ||||
-rw-r--r-- | lib9p/map.h | 14 |
4 files changed, 177 insertions, 184 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c index badeb95..d3dc36a 100644 --- a/lib9p/9p.generated.c +++ b/lib9p/9p.generated.c @@ -36,7 +36,7 @@ const char *lib9p_version_str(enum lib9p_version ver) { /* validate_* *****************************************************************/ -ALWAYS_INLINE static bool _validate_size_net(struct _validate_ctx *ctx, uint32_t n) { +LM_ALWAYS_INLINE static bool _validate_size_net(struct _validate_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 @@ -47,7 +47,7 @@ ALWAYS_INLINE static bool _validate_size_net(struct _validate_ctx *ctx, uint32_t return false; } -ALWAYS_INLINE static bool _validate_size_host(struct _validate_ctx *ctx, size_t n) { +LM_ALWAYS_INLINE static bool _validate_size_host(struct _validate_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 @@ -56,7 +56,7 @@ ALWAYS_INLINE static bool _validate_size_host(struct _validate_ctx *ctx, size_t return false; } -ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, +LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, size_t cnt, _validate_fn_t item_fn, size_t item_host_size) { for (size_t i = 0; i < cnt; i++) @@ -71,15 +71,15 @@ ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, #define validate_8(ctx) _validate_size_net(ctx, 8) #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u -ALWAYS_INLINE static bool validate_tag(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_tag(struct _validate_ctx *ctx) { return validate_2(ctx); } -ALWAYS_INLINE static bool validate_fid(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_fid(struct _validate_ctx *ctx) { return validate_4(ctx); } -ALWAYS_INLINE static bool validate_d(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_d(struct _validate_ctx *ctx) { uint32_t base_offset = ctx->net_offset; if (validate_4(ctx)) return true; @@ -87,7 +87,7 @@ ALWAYS_INLINE static bool validate_d(struct _validate_ctx *ctx) { return _validate_size_net(ctx, len) || _validate_size_host(ctx, len); } -ALWAYS_INLINE static bool validate_s(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_s(struct _validate_ctx *ctx) { uint32_t base_offset = ctx->net_offset; if (validate_2(ctx)) return true; @@ -110,7 +110,7 @@ static const lib9p_dm_t dm_masks[LIB9P_VER_NUM] = { [LIB9P_VER_9P2000_u] = 0b11101100101111000000000111111111, #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -ALWAYS_INLINE static bool validate_dm(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_dm(struct _validate_ctx *ctx) { if (validate_4(ctx)) return true; lib9p_dm_t mask = dm_masks[ctx->ctx->version]; @@ -131,7 +131,7 @@ static const lib9p_qt_t qt_masks[LIB9P_VER_NUM] = { [LIB9P_VER_9P2000_u] = 0b11101110, #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -ALWAYS_INLINE static bool validate_qt(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_qt(struct _validate_ctx *ctx) { if (validate_1(ctx)) return true; lib9p_qt_t mask = qt_masks[ctx->ctx->version]; @@ -141,7 +141,7 @@ ALWAYS_INLINE static bool validate_qt(struct _validate_ctx *ctx) { return false; } -ALWAYS_INLINE static bool validate_qid(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_qid(struct _validate_ctx *ctx) { return false || validate_qt(ctx) || validate_4(ctx) @@ -149,7 +149,7 @@ ALWAYS_INLINE static bool validate_qid(struct _validate_ctx *ctx) { ; } -ALWAYS_INLINE static bool validate_stat(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_stat(struct _validate_ctx *ctx) { uint16_t stat_size; uint32_t _kern_type_offset; return false @@ -187,7 +187,7 @@ static const lib9p_o_t o_masks[LIB9P_VER_NUM] = { [LIB9P_VER_9P2000_u] = 0b01010011, #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) { +LM_ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) { if (validate_1(ctx)) return true; lib9p_o_t mask = o_masks[ctx->ctx->version]; @@ -197,7 +197,7 @@ ALWAYS_INLINE static bool validate_o(struct _validate_ctx *ctx) { return false; } -FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -214,7 +214,7 @@ FLATTEN static bool validate_Tversion(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -231,7 +231,7 @@ FLATTEN static bool validate_Rversion(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tauth(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tauth(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -252,7 +252,7 @@ FLATTEN static bool validate_Tauth(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rauth(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rauth(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -268,7 +268,7 @@ FLATTEN static bool validate_Rauth(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -290,7 +290,7 @@ FLATTEN static bool validate_Tattach(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rattach(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rattach(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -306,7 +306,7 @@ FLATTEN static bool validate_Rattach(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -325,7 +325,7 @@ FLATTEN static bool validate_Rerror(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -341,7 +341,7 @@ FLATTEN static bool validate_Tflush(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rflush(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rflush(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -356,7 +356,7 @@ FLATTEN static bool validate_Rflush(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Twalk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Twalk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint16_t nwname; @@ -378,7 +378,7 @@ FLATTEN static bool validate_Twalk(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rwalk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rwalk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint16_t nwqid; @@ -398,7 +398,7 @@ FLATTEN static bool validate_Rwalk(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -415,7 +415,7 @@ FLATTEN static bool validate_Topen(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Ropen(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Ropen(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -432,7 +432,7 @@ FLATTEN static bool validate_Ropen(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -451,7 +451,7 @@ FLATTEN static bool validate_Tcreate(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rcreate(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rcreate(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -468,7 +468,7 @@ FLATTEN static bool validate_Rcreate(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tread(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -486,7 +486,7 @@ FLATTEN static bool validate_Tread(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -502,7 +502,7 @@ FLATTEN static bool validate_Rread(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -520,7 +520,7 @@ FLATTEN static bool validate_Twrite(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -536,7 +536,7 @@ FLATTEN static bool validate_Rwrite(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tclunk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tclunk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -552,7 +552,7 @@ FLATTEN static bool validate_Tclunk(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -567,7 +567,7 @@ FLATTEN static bool validate_Rclunk(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tremove(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tremove(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -583,7 +583,7 @@ FLATTEN static bool validate_Tremove(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -598,7 +598,7 @@ FLATTEN static bool validate_Rremove(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tstat(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -614,7 +614,7 @@ FLATTEN static bool validate_Tstat(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rstat(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint16_t nstat; @@ -635,7 +635,7 @@ FLATTEN static bool validate_Rstat(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint16_t nstat; @@ -657,7 +657,7 @@ FLATTEN static bool validate_Twstat(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -674,7 +674,7 @@ FLATTEN static bool validate_Rwstat(struct _validate_ctx *ctx) { #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_e -FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -690,7 +690,7 @@ FLATTEN static bool validate_Tsession(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rsession(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rsession(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -705,7 +705,7 @@ FLATTEN static bool validate_Rsession(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -723,7 +723,7 @@ FLATTEN static bool validate_Tsread(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -739,7 +739,7 @@ FLATTEN static bool validate_Rsread(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Tswrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Tswrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -758,7 +758,7 @@ FLATTEN static bool validate_Tswrite(struct _validate_ctx *ctx) { ; } -FLATTEN static bool validate_Rswrite(struct _validate_ctx *ctx) { +LM_FLATTEN static bool validate_Rswrite(struct _validate_ctx *ctx) { uint32_t size; uint8_t typ; uint32_t _size_offset; @@ -777,36 +777,36 @@ FLATTEN static bool validate_Rswrite(struct _validate_ctx *ctx) { /* unmarshal_* ****************************************************************/ -ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { +LM_ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 1; } -ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { +LM_ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 2; } -ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { +LM_ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 4; } -ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { +LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 8; } #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u -ALWAYS_INLINE static void unmarshal_tag(struct _unmarshal_ctx *ctx, lib9p_tag_t *out) { +LM_ALWAYS_INLINE static void unmarshal_tag(struct _unmarshal_ctx *ctx, lib9p_tag_t *out) { unmarshal_2(ctx, (uint16_t *)out); } -ALWAYS_INLINE static void unmarshal_fid(struct _unmarshal_ctx *ctx, lib9p_fid_t *out) { +LM_ALWAYS_INLINE static void unmarshal_fid(struct _unmarshal_ctx *ctx, lib9p_fid_t *out) { unmarshal_4(ctx, (uint32_t *)out); } -ALWAYS_INLINE static void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9p_d *out) { +LM_ALWAYS_INLINE static void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9p_d *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->len); out->dat = ctx->extra; @@ -815,7 +815,7 @@ ALWAYS_INLINE static void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9p_d unmarshal_1(ctx, (uint8_t *)&out->dat[i]); } -ALWAYS_INLINE static void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s *out) { +LM_ALWAYS_INLINE static void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s *out) { memset(out, 0, sizeof(*out)); unmarshal_2(ctx, &out->len); out->utf8 = ctx->extra; @@ -826,22 +826,22 @@ ALWAYS_INLINE static void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s out->utf8[out->len] = '\0'; } -ALWAYS_INLINE static void unmarshal_dm(struct _unmarshal_ctx *ctx, lib9p_dm_t *out) { +LM_ALWAYS_INLINE static void unmarshal_dm(struct _unmarshal_ctx *ctx, lib9p_dm_t *out) { unmarshal_4(ctx, (uint32_t *)out); } -ALWAYS_INLINE static void unmarshal_qt(struct _unmarshal_ctx *ctx, lib9p_qt_t *out) { +LM_ALWAYS_INLINE static void unmarshal_qt(struct _unmarshal_ctx *ctx, lib9p_qt_t *out) { unmarshal_1(ctx, (uint8_t *)out); } -ALWAYS_INLINE static void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) { +LM_ALWAYS_INLINE static void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) { memset(out, 0, sizeof(*out)); unmarshal_qt(ctx, &out->type); unmarshal_4(ctx, &out->vers); unmarshal_8(ctx, &out->path); } -ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { +LM_ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 2; unmarshal_2(ctx, &out->kern_type); @@ -863,11 +863,11 @@ ALWAYS_INLINE static void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9 #endif /* CONFIG_9P_ENABLE_9P2000_u */ } -ALWAYS_INLINE static void unmarshal_o(struct _unmarshal_ctx *ctx, lib9p_o_t *out) { +LM_ALWAYS_INLINE static void unmarshal_o(struct _unmarshal_ctx *ctx, lib9p_o_t *out) { unmarshal_1(ctx, (uint8_t *)out); } -FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { +LM_FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -876,7 +876,7 @@ FLATTEN static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_ unmarshal_s(ctx, &out->version); } -FLATTEN static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *out) { +LM_FLATTEN static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -885,7 +885,7 @@ FLATTEN static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_ unmarshal_s(ctx, &out->version); } -FLATTEN static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { +LM_FLATTEN static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -898,7 +898,7 @@ FLATTEN static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg #endif /* CONFIG_9P_ENABLE_9P2000_u */ } -FLATTEN static void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { +LM_FLATTEN static void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -906,7 +906,7 @@ FLATTEN static void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_qid(ctx, &out->aqid); } -FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *out) { +LM_FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -920,7 +920,7 @@ FLATTEN static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_m #endif /* CONFIG_9P_ENABLE_9P2000_u */ } -FLATTEN static void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { +LM_FLATTEN static void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -928,7 +928,7 @@ FLATTEN static void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_m unmarshal_qid(ctx, &out->qid); } -FLATTEN static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) { +LM_FLATTEN static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -939,7 +939,7 @@ FLATTEN static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_ms #endif /* CONFIG_9P_ENABLE_9P2000_u */ } -FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { +LM_FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -947,14 +947,14 @@ FLATTEN static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_2(ctx, &out->oldtag); } -FLATTEN static void unmarshal_Rflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rflush *out) { +LM_FLATTEN static void unmarshal_Rflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rflush *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); } -FLATTEN static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) { +LM_FLATTEN static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -968,7 +968,7 @@ FLATTEN static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_s(ctx, &out->wname[i]); } -FLATTEN static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { +LM_FLATTEN static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -980,7 +980,7 @@ FLATTEN static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_qid(ctx, &out->wqid[i]); } -FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { +LM_FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -989,7 +989,7 @@ FLATTEN static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_o(ctx, &out->mode); } -FLATTEN static void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *out) { +LM_FLATTEN static void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -998,7 +998,7 @@ FLATTEN static void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_4(ctx, &out->iounit); } -FLATTEN static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) { +LM_FLATTEN static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1009,7 +1009,7 @@ FLATTEN static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_m unmarshal_o(ctx, &out->mode); } -FLATTEN static void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *out) { +LM_FLATTEN static void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1018,7 +1018,7 @@ FLATTEN static void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_m unmarshal_4(ctx, &out->iounit); } -FLATTEN static void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *out) { +LM_FLATTEN static void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1028,7 +1028,7 @@ FLATTEN static void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_4(ctx, &out->count); } -FLATTEN static void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) { +LM_FLATTEN static void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1036,7 +1036,7 @@ FLATTEN static void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_d(ctx, &out->data); } -FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { +LM_FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1046,7 +1046,7 @@ FLATTEN static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_d(ctx, &out->data); } -FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { +LM_FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1054,7 +1054,7 @@ FLATTEN static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_4(ctx, &out->count); } -FLATTEN static void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { +LM_FLATTEN static void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1062,14 +1062,14 @@ FLATTEN static void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_fid(ctx, &out->fid); } -FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rclunk *out) { +LM_FLATTEN static void unmarshal_Rclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rclunk *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); } -FLATTEN static void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *out) { +LM_FLATTEN static void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1077,14 +1077,14 @@ FLATTEN static void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_m unmarshal_fid(ctx, &out->fid); } -FLATTEN static void unmarshal_Rremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rremove *out) { +LM_FLATTEN static void unmarshal_Rremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rremove *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); } -FLATTEN static void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { +LM_FLATTEN static void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1092,7 +1092,7 @@ FLATTEN static void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_fid(ctx, &out->fid); } -FLATTEN static void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) { +LM_FLATTEN static void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1101,7 +1101,7 @@ FLATTEN static void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg unmarshal_stat(ctx, &out->stat); } -FLATTEN static void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) { +LM_FLATTEN static void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1111,7 +1111,7 @@ FLATTEN static void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_stat(ctx, &out->stat); } -FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwstat *out) { +LM_FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwstat *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1120,7 +1120,7 @@ FLATTEN static void unmarshal_Rwstat(struct _unmarshal_ctx *ctx, struct lib9p_ms #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_e -FLATTEN static void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) { +LM_FLATTEN static void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1128,14 +1128,14 @@ FLATTEN static void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_ unmarshal_8(ctx, &out->key); } -FLATTEN static void unmarshal_Rsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsession *out) { +LM_FLATTEN static void unmarshal_Rsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsession *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; unmarshal_tag(ctx, &out->tag); } -FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *out) { +LM_FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1148,7 +1148,7 @@ FLATTEN static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_s(ctx, &out->wname[i]); } -FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) { +LM_FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1156,7 +1156,7 @@ FLATTEN static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_ms unmarshal_d(ctx, &out->data); } -FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) { +LM_FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1170,7 +1170,7 @@ FLATTEN static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_m unmarshal_d(ctx, &out->data); } -FLATTEN static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { +LM_FLATTEN static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { memset(out, 0, sizeof(*out)); ctx->net_offset += 4; ctx->net_offset += 1; @@ -1181,7 +1181,7 @@ FLATTEN static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_m /* marshal_* ******************************************************************/ -ALWAYS_INLINE static bool _marshal_too_large(struct _marshal_ctx *ctx) { +LM_ALWAYS_INLINE static 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"), @@ -1189,7 +1189,7 @@ ALWAYS_INLINE static bool _marshal_too_large(struct _marshal_ctx *ctx) { return true; } -ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { +LM_ALWAYS_INLINE static 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; @@ -1197,7 +1197,7 @@ ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { return false; } -ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { +LM_ALWAYS_INLINE static 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]); @@ -1205,7 +1205,7 @@ ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { return false; } -ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { +LM_ALWAYS_INLINE static 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]); @@ -1213,7 +1213,7 @@ ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { return false; } -ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { +LM_ALWAYS_INLINE static 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]); @@ -1222,15 +1222,15 @@ ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { } #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u -ALWAYS_INLINE static bool marshal_tag(struct _marshal_ctx *ctx, lib9p_tag_t *val) { +LM_ALWAYS_INLINE static bool marshal_tag(struct _marshal_ctx *ctx, lib9p_tag_t *val) { return marshal_2(ctx, (uint16_t *)val); } -ALWAYS_INLINE static bool marshal_fid(struct _marshal_ctx *ctx, lib9p_fid_t *val) { +LM_ALWAYS_INLINE static bool marshal_fid(struct _marshal_ctx *ctx, lib9p_fid_t *val) { return marshal_4(ctx, (uint32_t *)val); } -ALWAYS_INLINE static bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *val) { +LM_ALWAYS_INLINE static bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *val) { return false || marshal_4(ctx, &val->len) || ({ bool err = false; @@ -1240,7 +1240,7 @@ ALWAYS_INLINE static bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *va ; } -ALWAYS_INLINE static bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) { +LM_ALWAYS_INLINE static bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) { return false || marshal_2(ctx, &val->len) || ({ bool err = false; @@ -1250,17 +1250,17 @@ ALWAYS_INLINE static bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *va ; } -ALWAYS_INLINE static bool marshal_dm(struct _marshal_ctx *ctx, lib9p_dm_t *val) { +LM_ALWAYS_INLINE static bool marshal_dm(struct _marshal_ctx *ctx, lib9p_dm_t *val) { lib9p_dm_t masked_val = *val & dm_masks[ctx->ctx->version]; return marshal_4(ctx, (uint32_t *)&masked_val); } -ALWAYS_INLINE static bool marshal_qt(struct _marshal_ctx *ctx, lib9p_qt_t *val) { +LM_ALWAYS_INLINE static bool marshal_qt(struct _marshal_ctx *ctx, lib9p_qt_t *val) { lib9p_qt_t masked_val = *val & qt_masks[ctx->ctx->version]; return marshal_1(ctx, (uint8_t *)&masked_val); } -ALWAYS_INLINE static bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { +LM_ALWAYS_INLINE static bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { return false || marshal_qt(ctx, &val->type) || marshal_4(ctx, &val->vers) @@ -1268,7 +1268,7 @@ ALWAYS_INLINE static bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid ; } -ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { +LM_ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { uint32_t _stat_size_offset; uint32_t _kern_type_offset; return false @@ -1294,12 +1294,12 @@ ALWAYS_INLINE static bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_st ; } -ALWAYS_INLINE static bool marshal_o(struct _marshal_ctx *ctx, lib9p_o_t *val) { +LM_ALWAYS_INLINE static bool marshal_o(struct _marshal_ctx *ctx, lib9p_o_t *val) { lib9p_o_t masked_val = *val & o_masks[ctx->ctx->version]; return marshal_1(ctx, (uint8_t *)&masked_val); } -FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { +LM_FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1313,7 +1313,7 @@ FLATTEN static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_ ; } -FLATTEN static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *val) { +LM_FLATTEN static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1327,7 +1327,7 @@ FLATTEN static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_ ; } -FLATTEN static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) { +LM_FLATTEN static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1345,7 +1345,7 @@ FLATTEN static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tau ; } -FLATTEN static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { +LM_FLATTEN static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1358,7 +1358,7 @@ FLATTEN static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rau ; } -FLATTEN static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { +LM_FLATTEN static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1377,7 +1377,7 @@ FLATTEN static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_T ; } -FLATTEN static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *val) { +LM_FLATTEN static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1390,7 +1390,7 @@ FLATTEN static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_R ; } -FLATTEN static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { +LM_FLATTEN static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1406,7 +1406,7 @@ FLATTEN static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Re ; } -FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { +LM_FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1419,7 +1419,7 @@ FLATTEN static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tf ; } -FLATTEN static bool marshal_Rflush(struct _marshal_ctx *ctx, struct lib9p_msg_Rflush *val) { +LM_FLATTEN static bool marshal_Rflush(struct _marshal_ctx *ctx, struct lib9p_msg_Rflush *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1431,7 +1431,7 @@ FLATTEN static bool marshal_Rflush(struct _marshal_ctx *ctx, struct lib9p_msg_Rf ; } -FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { +LM_FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1450,7 +1450,7 @@ FLATTEN static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twa ; } -FLATTEN static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) { +LM_FLATTEN static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1467,7 +1467,7 @@ FLATTEN static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwa ; } -FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { +LM_FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1481,7 +1481,7 @@ FLATTEN static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Top ; } -FLATTEN static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *val) { +LM_FLATTEN static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1495,7 +1495,7 @@ FLATTEN static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Rop ; } -FLATTEN static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { +LM_FLATTEN static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1511,7 +1511,7 @@ FLATTEN static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_T ; } -FLATTEN static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *val) { +LM_FLATTEN static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1525,7 +1525,7 @@ FLATTEN static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_R ; } -FLATTEN static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { +LM_FLATTEN static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1540,7 +1540,7 @@ FLATTEN static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tre ; } -FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) { +LM_FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1553,7 +1553,7 @@ FLATTEN static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rre ; } -FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *val) { +LM_FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1568,7 +1568,7 @@ FLATTEN static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tw ; } -FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *val) { +LM_FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1581,7 +1581,7 @@ FLATTEN static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rw ; } -FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *val) { +LM_FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1594,7 +1594,7 @@ FLATTEN static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tc ; } -FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rclunk *val) { +LM_FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rclunk *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1606,7 +1606,7 @@ FLATTEN static bool marshal_Rclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Rc ; } -FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { +LM_FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1619,7 +1619,7 @@ FLATTEN static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_T ; } -FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_Rremove *val) { +LM_FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_Rremove *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1631,7 +1631,7 @@ FLATTEN static bool marshal_Rremove(struct _marshal_ctx *ctx, struct lib9p_msg_R ; } -FLATTEN static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *val) { +LM_FLATTEN static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1644,7 +1644,7 @@ FLATTEN static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tst ; } -FLATTEN static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { +LM_FLATTEN static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { uint32_t _size_offset; uint32_t _typ_offset; uint32_t _nstat_offset; @@ -1661,7 +1661,7 @@ FLATTEN static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rst ; } -FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { +LM_FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { uint32_t _size_offset; uint32_t _typ_offset; uint32_t _nstat_offset; @@ -1679,7 +1679,7 @@ FLATTEN static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tw ; } -FLATTEN static bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rwstat *val) { +LM_FLATTEN static bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rwstat *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1693,7 +1693,7 @@ FLATTEN static bool marshal_Rwstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rw #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_e -FLATTEN static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) { +LM_FLATTEN static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1706,7 +1706,7 @@ FLATTEN static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_ ; } -FLATTEN static bool marshal_Rsession(struct _marshal_ctx *ctx, struct lib9p_msg_Rsession *val) { +LM_FLATTEN static bool marshal_Rsession(struct _marshal_ctx *ctx, struct lib9p_msg_Rsession *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1718,7 +1718,7 @@ FLATTEN static bool marshal_Rsession(struct _marshal_ctx *ctx, struct lib9p_msg_ ; } -FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *val) { +LM_FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1736,7 +1736,7 @@ FLATTEN static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Ts ; } -FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) { +LM_FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1749,7 +1749,7 @@ FLATTEN static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rs ; } -FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) { +LM_FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -1768,7 +1768,7 @@ FLATTEN static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_T ; } -FLATTEN static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *val) { +LM_FLATTEN static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *val) { uint32_t _size_offset; uint32_t _typ_offset; return false @@ -2836,12 +2836,12 @@ struct _table_version _lib9p_versions[LIB9P_VER_NUM] = { #endif /* CONFIG_9P_ENABLE_9P2000_u */ }; -FLATTEN bool _lib9p_validate_stat(struct _validate_ctx *ctx) { +LM_FLATTEN bool _lib9p_validate_stat(struct _validate_ctx *ctx) { return validate_stat(ctx); } -FLATTEN void _lib9p_unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { +LM_FLATTEN void _lib9p_unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { unmarshal_stat(ctx, out); } -FLATTEN bool _lib9p_marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { +LM_FLATTEN bool _lib9p_marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { return marshal_stat(ctx, val); } diff --git a/lib9p/idl.gen b/lib9p/idl.gen index cca83da..ae7f1a5 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -708,7 +708,7 @@ def gen_c(versions: set[str], typs: list[Type]) -> str: return arg def unused(arg: str) -> str: - return f"UNUSED({arg})" + return f"LM_UNUSED({arg})" # strings ################################################################## ret += f""" @@ -736,7 +736,7 @@ const char *{idprefix}version_str(enum {idprefix}version ver) {{ ret += """ /* validate_* *****************************************************************/ -ALWAYS_INLINE static bool _validate_size_net(struct _validate_ctx *ctx, uint32_t n) { +LM_ALWAYS_INLINE static bool _validate_size_net(struct _validate_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 @@ -747,7 +747,7 @@ ALWAYS_INLINE static bool _validate_size_net(struct _validate_ctx *ctx, uint32_t return false; } -ALWAYS_INLINE static bool _validate_size_host(struct _validate_ctx *ctx, size_t n) { +LM_ALWAYS_INLINE static bool _validate_size_host(struct _validate_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 @@ -756,7 +756,7 @@ ALWAYS_INLINE static bool _validate_size_host(struct _validate_ctx *ctx, size_t return false; } -ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, +LM_ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, size_t cnt, _validate_fn_t item_fn, size_t item_host_size) { for (size_t i = 0; i < cnt; i++) @@ -771,7 +771,7 @@ ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, #define validate_8(ctx) _validate_size_net(ctx, 8) """ for typ in typs: - inline = "FLATTEN" if isinstance(typ, Message) else "ALWAYS_INLINE" + inline = "LM_FLATTEN" if isinstance(typ, Message) else "LM_ALWAYS_INLINE" argfn = unused if (isinstance(typ, Struct) and not typ.members) else used ret += "\n" ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) @@ -903,28 +903,28 @@ ALWAYS_INLINE static bool _validate_list(struct _validate_ctx *ctx, ret += """ /* unmarshal_* ****************************************************************/ -ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { +LM_ALWAYS_INLINE static void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 1; } -ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { +LM_ALWAYS_INLINE static void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 2; } -ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { +LM_ALWAYS_INLINE static void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 4; } -ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { +LM_ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 8; } """ for typ in typs: - inline = "FLATTEN" if isinstance(typ, Message) else "ALWAYS_INLINE" + inline = "LM_FLATTEN" if isinstance(typ, Message) else "LM_ALWAYS_INLINE" argfn = unused if (isinstance(typ, Struct) and not typ.members) else used ret += "\n" ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) @@ -976,7 +976,7 @@ ALWAYS_INLINE static void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) ret += """ /* marshal_* ******************************************************************/ -ALWAYS_INLINE static bool _marshal_too_large(struct _marshal_ctx *ctx) { +LM_ALWAYS_INLINE static 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"), @@ -984,7 +984,7 @@ ALWAYS_INLINE static bool _marshal_too_large(struct _marshal_ctx *ctx) { return true; } -ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { +LM_ALWAYS_INLINE static 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; @@ -992,7 +992,7 @@ ALWAYS_INLINE static bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { return false; } -ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { +LM_ALWAYS_INLINE static 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]); @@ -1000,7 +1000,7 @@ ALWAYS_INLINE static bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { return false; } -ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { +LM_ALWAYS_INLINE static 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]); @@ -1008,7 +1008,7 @@ ALWAYS_INLINE static bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { return false; } -ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { +LM_ALWAYS_INLINE static 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]); @@ -1017,7 +1017,7 @@ ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { } """ for typ in typs: - inline = "FLATTEN" if isinstance(typ, Message) else "ALWAYS_INLINE" + inline = "LM_FLATTEN" if isinstance(typ, Message) else "LM_ALWAYS_INLINE" argfn = unused if (isinstance(typ, Struct) and not typ.members) else used ret += "\n" ret += ifdef_push(1, c_ver_ifdef(typ.in_versions)) @@ -1136,13 +1136,13 @@ struct _table_version _{idprefix}versions[{c_ver_enum('NUM')}] = {{ ret += "};\n" ret += f""" -FLATTEN bool _{idprefix}validate_stat(struct _validate_ctx *ctx) {{ +LM_FLATTEN bool _{idprefix}validate_stat(struct _validate_ctx *ctx) {{ return validate_stat(ctx); }} -FLATTEN void _{idprefix}unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {{ +LM_FLATTEN void _{idprefix}unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) {{ unmarshal_stat(ctx, out); }} -FLATTEN bool _{idprefix}marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {{ +LM_FLATTEN bool _{idprefix}marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {{ return marshal_stat(ctx, val); }} """ diff --git a/lib9p/internal.h b/lib9p/internal.h index 07bb9d6..b1a367d 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -13,6 +13,8 @@ #define SSIZE_MAX (SIZE_MAX >> 1) #endif +#include <libmisc/macro.h> + #include <lib9p/9p.h> /* configuration **************************************************************/ @@ -39,15 +41,6 @@ static_assert(CONFIG_9P_MAX_ERR_SIZE <= UINT16_MAX); static_assert(CONFIG_9P_MAX_MSG_SIZE <= CONFIG_9P_MAX_HOSTMSG_SIZE); static_assert(CONFIG_9P_MAX_HOSTMSG_SIZE <= SSIZE_MAX); -/* C language *****************************************************************/ - -#define UNUSED(name) -#define ALWAYS_INLINE [[gnu::always_inline]] inline -#define FLATTEN [[gnu::flatten]] -#define ARRAY_LEN(arr) (sizeof(arr)/sizeof((arr)[0])) -#define CAT2(a, b) a##b -#define CAT3(a, b, c) a##b##c - /* specialized contexts *******************************************************/ struct _validate_ctx { @@ -102,22 +95,22 @@ bool _lib9p_marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val); /* unmarshal utilities ********************************************************/ -ALWAYS_INLINE static uint8_t decode_u8le(uint8_t *in) { +LM_ALWAYS_INLINE static uint8_t decode_u8le(uint8_t *in) { return in[0]; } -ALWAYS_INLINE static uint16_t decode_u16le(uint8_t *in) { +LM_ALWAYS_INLINE static uint16_t decode_u16le(uint8_t *in) { return (((uint16_t)(in[0])) << 0) | (((uint16_t)(in[1])) << 8) ; } -ALWAYS_INLINE static uint32_t decode_u32le(uint8_t *in) { +LM_ALWAYS_INLINE static uint32_t decode_u32le(uint8_t *in) { return (((uint32_t)(in[0])) << 0) | (((uint32_t)(in[1])) << 8) | (((uint32_t)(in[2])) << 16) | (((uint32_t)(in[3])) << 24) ; } -ALWAYS_INLINE static uint64_t decode_u64le(uint8_t *in) { +LM_ALWAYS_INLINE static uint64_t decode_u64le(uint8_t *in) { return (((uint64_t)(in[0])) << 0) | (((uint64_t)(in[1])) << 8) | (((uint64_t)(in[2])) << 16) @@ -155,20 +148,20 @@ static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) { /* marshal utilities **********************************************************/ -ALWAYS_INLINE static void encode_u8le(uint8_t in, uint8_t *out) { +LM_ALWAYS_INLINE static void encode_u8le(uint8_t in, uint8_t *out) { out[0] = in; } -ALWAYS_INLINE static void encode_u16le(uint16_t in, uint8_t *out) { +LM_ALWAYS_INLINE static void encode_u16le(uint16_t in, uint8_t *out) { out[0] = (uint8_t)((in >> 0) & 0xFF); out[1] = (uint8_t)((in >> 8) & 0xFF); } -ALWAYS_INLINE static void encode_u32le(uint32_t in, uint8_t *out) { +LM_ALWAYS_INLINE static void encode_u32le(uint32_t in, uint8_t *out) { out[0] = (uint8_t)((in >> 0) & 0xFF); out[1] = (uint8_t)((in >> 8) & 0xFF); out[2] = (uint8_t)((in >> 16) & 0xFF); out[3] = (uint8_t)((in >> 24) & 0xFF); } -ALWAYS_INLINE static void encode_u64le(uint64_t in, uint8_t *out) { +LM_ALWAYS_INLINE static void encode_u64le(uint64_t in, uint8_t *out) { out[0] = (uint8_t)((in >> 0) & 0xFF); out[1] = (uint8_t)((in >> 8) & 0xFF); out[2] = (uint8_t)((in >> 16) & 0xFF); diff --git a/lib9p/map.h b/lib9p/map.h index f42bb2c..b59c83d 100644 --- a/lib9p/map.h +++ b/lib9p/map.h @@ -25,10 +25,10 @@ #endif #ifndef MAP_KEY -#define MAP_KV(TNAME) CAT3(_,TNAME,_kv) -#define MAP_METHOD(TNAME, MNAME) CAT3(TNAME,_,MNAME) +#define MAP_KV(TNAME) LM_CAT3(_,TNAME,_kv) +#define MAP_METHOD(TNAME, MNAME) LM_CAT3(TNAME,_,MNAME) #define MAP_FOREACH(m, k, v) \ - for (size_t i = 0; i < ARRAY_LEN((m)->items); i++) \ + for (size_t i = 0; i < LM_ARRAY_LEN((m)->items); i++) \ if ( ({ k = (m)->items[i].key; v = &(m)->items[i].val; (m)->items[i].set; }) ) #endif @@ -58,7 +58,7 @@ struct NAME { static VAL_T *MAP_METHOD(NAME,load)(struct NAME *m, KEY_T k) { if (!m->len) return NULL; - for (size_t i = 0; i < ARRAY_LEN(m->items); i++) + for (size_t i = 0; i < LM_ARRAY_LEN(m->items); i++) if (m->items[i].set && m->items[i].key == k) return &(m->items[i].val); return NULL; @@ -74,9 +74,9 @@ static VAL_T *MAP_METHOD(NAME,store)(struct NAME *m, KEY_T k, VAL_T v) { *old = v; return old; } - if (m->len == ARRAY_LEN(m->items)) + if (m->len == LM_ARRAY_LEN(m->items)) return NULL; - for (size_t i = 0; i < ARRAY_LEN(m->items); i++) + for (size_t i = 0; i < LM_ARRAY_LEN(m->items); i++) if (!m->items[i].set) { m->len++; m->items[i].set = true; @@ -94,7 +94,7 @@ static VAL_T *MAP_METHOD(NAME,store)(struct NAME *m, KEY_T k, VAL_T v) { static bool MAP_METHOD(NAME,del)(struct NAME *m, KEY_T k) { if (!m->len) return NULL; - for (size_t i = 0; i < ARRAY_LEN(m->items); i++) + for (size_t i = 0; i < LM_ARRAY_LEN(m->items); i++) if (m->items[i].set && m->items[i].key == k) { m->items[i].set = false; m->len--; |