summaryrefslogtreecommitdiff
path: root/lib9p
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-13 18:49:15 -0500
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-13 18:49:15 -0500
commitc578a300c7d0d46662fcd0bdce69af95a821bc18 (patch)
treea99de333f2812d7c018820f39d78b8c4e744f705 /lib9p
parent6a719c63ecb83a850c317ea94b8932aa0c857770 (diff)
parent57cc0523f600575feda09bd9fae13f685ce85b0f (diff)
Merge commit '57cc0523f600575feda09bd9fae13f685ce85b0f'
Diffstat (limited to 'lib9p')
-rw-r--r--lib9p/9p.c7
-rw-r--r--lib9p/9p.generated.c285
-rwxr-xr-xlib9p/idl.gen41
-rw-r--r--lib9p/internal.h32
-rw-r--r--lib9p/map.h14
-rw-r--r--lib9p/srv.c6
6 files changed, 195 insertions, 190 deletions
diff --git a/lib9p/9p.c b/lib9p/9p.c
index 5943b42..a3d81d0 100644
--- a/lib9p/9p.c
+++ b/lib9p/9p.c
@@ -65,8 +65,11 @@ int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, .
}
const char *lib9p_msg_type_str(struct lib9p_ctx *ctx, enum lib9p_msg_type typ) {
- assert(0 <= typ && typ <= 0xFF);
- return _lib9p_versions[ctx->version].msgs[typ].name;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+ assert(0 <= typ && typ <= 0xFF);
+#pragma GCC diagnostic pop
+ return _lib9p_versions[ctx->version].msgs[typ].name;
}
/* main message functions *****************************************************/
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index f3a907b..d3dc36a 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -27,13 +27,16 @@ static const char *version_strs[LIB9P_VER_NUM] = {
};
const char *lib9p_version_str(enum lib9p_version ver) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
assert(0 <= ver && ver < LIB9P_VER_NUM);
+#pragma GCC diagnostic pop
return version_strs[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
@@ -44,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
@@ -53,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++)
@@ -68,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;
@@ -84,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;
@@ -107,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];
@@ -128,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];
@@ -138,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)
@@ -146,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
@@ -184,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];
@@ -194,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;
@@ -211,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;
@@ -228,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;
@@ -249,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;
@@ -265,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;
@@ -287,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;
@@ -303,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;
@@ -322,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;
@@ -338,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;
@@ -353,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;
@@ -375,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;
@@ -395,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;
@@ -412,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;
@@ -429,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;
@@ -448,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;
@@ -465,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;
@@ -483,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;
@@ -499,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;
@@ -517,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;
@@ -533,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;
@@ -549,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;
@@ -564,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;
@@ -580,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;
@@ -595,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;
@@ -611,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;
@@ -632,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;
@@ -654,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;
@@ -671,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;
@@ -687,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;
@@ -702,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;
@@ -720,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;
@@ -736,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;
@@ -755,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;
@@ -774,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;
@@ -812,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;
@@ -823,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);
@@ -860,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;
@@ -873,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;
@@ -882,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;
@@ -895,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;
@@ -903,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;
@@ -917,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;
@@ -925,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;
@@ -936,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;
@@ -944,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;
@@ -965,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;
@@ -977,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;
@@ -986,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;
@@ -995,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;
@@ -1006,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;
@@ -1015,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;
@@ -1025,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;
@@ -1033,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;
@@ -1043,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;
@@ -1051,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;
@@ -1059,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;
@@ -1074,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;
@@ -1089,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;
@@ -1098,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;
@@ -1108,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;
@@ -1117,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;
@@ -1125,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;
@@ -1145,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;
@@ -1153,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;
@@ -1167,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;
@@ -1178,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"),
@@ -1186,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;
@@ -1194,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]);
@@ -1202,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]);
@@ -1210,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]);
@@ -1219,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;
@@ -1237,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;
@@ -1247,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)
@@ -1265,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
@@ -1291,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
@@ -1310,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
@@ -1324,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
@@ -1342,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
@@ -1355,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
@@ -1374,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
@@ -1387,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
@@ -1403,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
@@ -1416,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
@@ -1428,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
@@ -1447,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
@@ -1464,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
@@ -1478,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
@@ -1492,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
@@ -1508,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
@@ -1522,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
@@ -1537,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
@@ -1550,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
@@ -1565,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
@@ -1578,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
@@ -1591,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
@@ -1603,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
@@ -1616,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
@@ -1628,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
@@ -1641,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;
@@ -1658,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;
@@ -1676,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
@@ -1690,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
@@ -1703,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
@@ -1715,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
@@ -1733,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
@@ -1746,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
@@ -1765,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
@@ -2833,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 262e5f0..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"""
@@ -724,7 +724,10 @@ static const char *version_strs[{c_ver_enum('NUM')}] = {{
ret += "};\n"
ret += f"""
const char *{idprefix}version_str(enum {idprefix}version ver) {{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
assert(0 <= ver && ver < {c_ver_enum('NUM')});
+#pragma GCC diagnostic pop
return version_strs[ver];
}}
"""
@@ -733,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
@@ -744,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
@@ -753,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++)
@@ -768,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))
@@ -900,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))
@@ -973,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"),
@@ -981,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;
@@ -989,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]);
@@ -997,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]);
@@ -1005,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]);
@@ -1014,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))
@@ -1133,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 57f7aa7..b1a367d 100644
--- a/lib9p/internal.h
+++ b/lib9p/internal.h
@@ -8,7 +8,12 @@
#define _LIB9P_INTERNAL_H_
#include <stddef.h> /* for size_t */
-#include <limits.h> /* for SSIZE_MAX */
+#include <limits.h> /* for SSIZE_MAX, not set by newlib */
+#ifndef SSIZE_MAX
+#define SSIZE_MAX (SIZE_MAX >> 1)
+#endif
+
+#include <libmisc/macro.h>
#include <lib9p/9p.h>
@@ -36,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 {
@@ -99,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)
@@ -152,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--;
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 2fb2120..3535f9a 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -6,7 +6,6 @@
#include <alloca.h>
#include <inttypes.h> /* for PRI* */
-#include <string.h> /* for strerror() */
#include <libcr/coroutine.h>
#include <libcr_ipc/chan.h>
@@ -14,6 +13,7 @@
#include <libcr_ipc/select.h>
#include <libmisc/assert.h>
#include <libmisc/vcall.h>
+#include <libhw/generic/net.h>
#define LOG_NAME 9P_SRV
#include <libmisc/log.h>
@@ -170,7 +170,7 @@ static void respond_error(struct _lib9p_srv_req *req) {
req->net_bytes, decode_u32le(req->net_bytes));
cr_mutex_unlock(&sess->parent_conn->writelock);
if (r < 0)
- nonrespond_errorf("write: %s", strerror(-r));
+ nonrespond_errorf("write: %s", net_strerror(-r));
}
/* read coroutine *************************************************************/
@@ -182,7 +182,7 @@ static bool read_at_least(implements_net_stream_conn *fd, uint8_t *buf, size_t g
while (*done < goal) {
ssize_t r = VCALL(fd, read, &buf[*done], CONFIG_9P_MAX_MSG_SIZE - *done);
if (r < 0) {
- nonrespond_errorf("read: %s", strerror(-r));
+ nonrespond_errorf("read: %s", net_strerror(-r));
return true;
} else if (r == 0) {
if (*done != 0)