diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-30 08:05:40 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-30 11:19:50 -0600 |
commit | d82d7f59f9227a0ea33d13af3c7ed95e16fdd2e3 (patch) | |
tree | 0b911ceb5b89642f963faf5f3324eb6eef3d459a /lib9p | |
parent | 2ec9929e7bab7c87d3851e932baf0c1146981657 (diff) |
lib9p: Use __attribute__((always_inline)) and __attribute__((flatten))
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib9p/internal.h | 20 | ||||
-rw-r--r-- | lib9p/types.c | 246 | ||||
-rwxr-xr-x | lib9p/types.gen | 30 |
4 files changed, 149 insertions, 148 deletions
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt index cd3156c..811e81a 100644 --- a/lib9p/CMakeLists.txt +++ b/lib9p/CMakeLists.txt @@ -13,4 +13,3 @@ target_sources(lib9p INTERFACE target_link_libraries(lib9p INTERFACE libcr_ipc ) -set_source_files_properties(types.c PROPERTIES COMPILE_FLAGS -O3) diff --git a/lib9p/internal.h b/lib9p/internal.h index f67735b..d1da014 100644 --- a/lib9p/internal.h +++ b/lib9p/internal.h @@ -22,7 +22,9 @@ static_assert(CONFIG_9P_MAX_ERR_SIZE + CONFIG_9P_MAX_MSG_SIZE + 2*CONFIG_9P_MAX_ /* C language *****************************************************************/ -#define UNUSED(name) /* name __attribute__ ((unused)) */ +#define UNUSED(name) /* name __attribute__((unused)) */ +#define ALWAYS_INLINE inline __attribute__((always_inline)) +#define FLATTEN __attribute__((flatten)) /* types **********************************************************************/ @@ -86,22 +88,22 @@ extern struct _vtable_version _lib9p_vtables[LIB9P_VER_NUM]; /* unmarshal utilities ********************************************************/ -static inline uint8_t decode_u8le(uint8_t *in) { +static ALWAYS_INLINE uint8_t decode_u8le(uint8_t *in) { return in[0]; } -static inline uint16_t decode_u16le(uint8_t *in) { +static ALWAYS_INLINE uint16_t decode_u16le(uint8_t *in) { return (((uint16_t)(in[0])) << 0) | (((uint16_t)(in[1])) << 8) ; } -static inline uint32_t decode_u32le(uint8_t *in) { +static ALWAYS_INLINE 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) ; } -static inline uint64_t decode_u64le(uint8_t *in) { +static ALWAYS_INLINE uint64_t decode_u64le(uint8_t *in) { return (((uint64_t)(in[0])) << 0) | (((uint64_t)(in[1])) << 8) | (((uint64_t)(in[2])) << 16) @@ -139,20 +141,20 @@ static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) { /* marshal utilities **********************************************************/ -static inline void encode_u8le(uint8_t in, uint8_t *out) { +static ALWAYS_INLINE void encode_u8le(uint8_t in, uint8_t *out) { out[0] = in; } -static inline void encode_u16le(uint16_t in, uint8_t *out) { +static ALWAYS_INLINE void encode_u16le(uint16_t in, uint8_t *out) { out[0] = (uint8_t)((in >> 0) & 0xFF); out[1] = (uint8_t)((in >> 8) & 0xFF); } -static inline void encode_u32le(uint32_t in, uint8_t *out) { +static ALWAYS_INLINE 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); } -static inline void encode_u64le(uint64_t in, uint8_t *out) { +static ALWAYS_INLINE 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/types.c b/lib9p/types.c index 0c03bd5..19ed322 100644 --- a/lib9p/types.c +++ b/lib9p/types.c @@ -290,7 +290,7 @@ const char *lib9p_msg_type_str(enum lib9p_msg_type typ) { /* checksize_* (internals of unmarshal_size()) ********************************/ -static inline bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { +static ALWAYS_INLINE bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { if (__builtin_add_overflow(ctx->net_offset, n, &ctx->net_offset)) /* If needed-net-size overflowed uint32_t, then * there's no way that actual-net-size will live up to @@ -301,7 +301,7 @@ static inline bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { return false; } -static inline bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { +static ALWAYS_INLINE bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { if (__builtin_add_overflow(ctx->host_extra, n, &ctx->host_extra)) /* If needed-host-size overflowed size_t, then there's * no way that actual-net-size will live up to @@ -310,7 +310,7 @@ static inline bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { return false; } -static inline bool _checksize_list(struct _checksize_ctx *ctx, +static ALWAYS_INLINE bool _checksize_list(struct _checksize_ctx *ctx, size_t cnt, _checksize_fn_t item_fn, size_t item_host_size) { for (size_t i = 0; i < cnt; i++) if (_checksize_host(ctx, item_host_size) || item_fn(ctx)) @@ -323,7 +323,7 @@ static inline bool _checksize_list(struct _checksize_ctx *ctx, #define checksize_4(ctx) _checksize_net(ctx, 4) #define checksize_8(ctx) _checksize_net(ctx, 8) -static inline bool checksize_d(struct _checksize_ctx *ctx) { +static ALWAYS_INLINE bool checksize_d(struct _checksize_ctx *ctx) { uint32_t base_offset = ctx->net_offset; if (checksize_4(ctx)) return true; @@ -331,7 +331,7 @@ static inline bool checksize_d(struct _checksize_ctx *ctx) { return _checksize_net(ctx, len) || _checksize_host(ctx, len); } -static inline bool checksize_s(struct _checksize_ctx *ctx) { +static ALWAYS_INLINE bool checksize_s(struct _checksize_ctx *ctx) { uint32_t base_offset = ctx->net_offset; if (checksize_2(ctx)) return true; @@ -343,13 +343,13 @@ static inline bool checksize_s(struct _checksize_ctx *ctx) { return false; } -static inline bool checksize_qid(struct _checksize_ctx *ctx) { +static ALWAYS_INLINE bool checksize_qid(struct _checksize_ctx *ctx) { return checksize_1(ctx) || checksize_4(ctx) || checksize_8(ctx); } -static inline bool checksize_stat(struct _checksize_ctx *ctx) { +static ALWAYS_INLINE bool checksize_stat(struct _checksize_ctx *ctx) { return checksize_2(ctx) || checksize_2(ctx) || checksize_4(ctx) @@ -368,190 +368,190 @@ static inline bool checksize_stat(struct _checksize_ctx *ctx) { || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ); } -static bool checksize_Tversion(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tversion(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_s(ctx); } -static bool checksize_Rversion(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rversion(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_s(ctx); } -static bool checksize_Tauth(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tauth(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_s(ctx) || checksize_s(ctx) || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ); } -static bool checksize_Rauth(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rauth(struct _checksize_ctx *ctx) { return checksize_qid(ctx); } -static bool checksize_Tattach(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tattach(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_4(ctx) || checksize_s(ctx) || checksize_s(ctx); } -static bool checksize_Rattach(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rattach(struct _checksize_ctx *ctx) { return checksize_qid(ctx); } -static bool checksize_Rerror(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rerror(struct _checksize_ctx *ctx) { return checksize_s(ctx) || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && checksize_4(ctx) ); } -static bool checksize_Tflush(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tflush(struct _checksize_ctx *ctx) { return checksize_2(ctx); } -static bool checksize_Rflush(struct _checksize_ctx *UNUSED(ctx)) { +static FLATTEN bool checksize_Rflush(struct _checksize_ctx *UNUSED(ctx)) { return false; } -static bool checksize_Twalk(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Twalk(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_4(ctx) || checksize_2(ctx) || _checksize_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), checksize_s, sizeof(struct lib9p_s)); } -static bool checksize_Rwalk(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rwalk(struct _checksize_ctx *ctx) { return checksize_2(ctx) || _checksize_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), checksize_qid, sizeof(struct lib9p_qid)); } -static bool checksize_Topen(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Topen(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_1(ctx); } -static bool checksize_Ropen(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Ropen(struct _checksize_ctx *ctx) { return checksize_qid(ctx) || checksize_4(ctx); } -static bool checksize_Tcreate(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tcreate(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_s(ctx) || checksize_4(ctx) || checksize_1(ctx); } -static bool checksize_Rcreate(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rcreate(struct _checksize_ctx *ctx) { return checksize_qid(ctx) || checksize_4(ctx); } -static bool checksize_Tread(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tread(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_8(ctx) || checksize_4(ctx); } -static bool checksize_Rread(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rread(struct _checksize_ctx *ctx) { return checksize_d(ctx); } -static bool checksize_Twrite(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Twrite(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_8(ctx) || checksize_d(ctx); } -static bool checksize_Rwrite(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rwrite(struct _checksize_ctx *ctx) { return checksize_4(ctx); } -static bool checksize_Tclunk(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tclunk(struct _checksize_ctx *ctx) { return checksize_4(ctx); } -static bool checksize_Rclunk(struct _checksize_ctx *UNUSED(ctx)) { +static FLATTEN bool checksize_Rclunk(struct _checksize_ctx *UNUSED(ctx)) { return false; } -static bool checksize_Tremove(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tremove(struct _checksize_ctx *ctx) { return checksize_4(ctx); } -static bool checksize_Rremove(struct _checksize_ctx *UNUSED(ctx)) { +static FLATTEN bool checksize_Rremove(struct _checksize_ctx *UNUSED(ctx)) { return false; } -static bool checksize_Tstat(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tstat(struct _checksize_ctx *ctx) { return checksize_4(ctx); } -static bool checksize_Rstat(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rstat(struct _checksize_ctx *ctx) { return checksize_stat(ctx); } -static bool checksize_Twstat(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Twstat(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_stat(ctx); } -static bool checksize_Rwstat(struct _checksize_ctx *UNUSED(ctx)) { +static FLATTEN bool checksize_Rwstat(struct _checksize_ctx *UNUSED(ctx)) { return false; } -static bool checksize_Tsession(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tsession(struct _checksize_ctx *ctx) { return checksize_8(ctx); } -static bool checksize_Rsession(struct _checksize_ctx *UNUSED(ctx)) { +static FLATTEN bool checksize_Rsession(struct _checksize_ctx *UNUSED(ctx)) { return false; } -static bool checksize_Tsread(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tsread(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_2(ctx) || _checksize_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), checksize_s, sizeof(struct lib9p_s)); } -static bool checksize_Rsread(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rsread(struct _checksize_ctx *ctx) { return checksize_d(ctx); } -static bool checksize_Tswrite(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Tswrite(struct _checksize_ctx *ctx) { return checksize_4(ctx) || checksize_2(ctx) || _checksize_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), checksize_s, sizeof(struct lib9p_s)) || checksize_d(ctx); } -static bool checksize_Rswrite(struct _checksize_ctx *ctx) { +static FLATTEN bool checksize_Rswrite(struct _checksize_ctx *ctx) { return checksize_4(ctx); } /* unmarshal_* ****************************************************************/ -static inline void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { +static ALWAYS_INLINE void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 1; } -static inline void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { +static ALWAYS_INLINE void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 2; } -static inline void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { +static ALWAYS_INLINE void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 4; } -static inline void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { +static ALWAYS_INLINE void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 8; } -static inline void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9p_d *out) { +static ALWAYS_INLINE 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; @@ -560,7 +560,7 @@ static inline void unmarshal_d(struct _unmarshal_ctx *ctx, struct lib9p_d *out) unmarshal_1(ctx, &out->dat[i]); } -static inline void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s *out) { +static ALWAYS_INLINE 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; @@ -569,14 +569,14 @@ static inline void unmarshal_s(struct _unmarshal_ctx *ctx, struct lib9p_s *out) unmarshal_1(ctx, &out->utf8[i]); } -static inline void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) { +static ALWAYS_INLINE void unmarshal_qid(struct _unmarshal_ctx *ctx, struct lib9p_qid *out) { memset(out, 0, sizeof(*out)); unmarshal_1(ctx, &out->type); unmarshal_4(ctx, &out->vers); unmarshal_8(ctx, &out->path); } -static inline void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { +static ALWAYS_INLINE void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat *out) { memset(out, 0, sizeof(*out)); unmarshal_2(ctx, &out->stat_size); unmarshal_2(ctx, &out->kern_type); @@ -596,19 +596,19 @@ static inline void unmarshal_stat(struct _unmarshal_ctx *ctx, struct lib9p_stat if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->file_last_modified_n_uid); } -static void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { +static FLATTEN void unmarshal_Tversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tversion *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->max_msg_size); unmarshal_s(ctx, &out->version); } -static void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *out) { +static FLATTEN void unmarshal_Rversion(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rversion *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->max_msg_size); unmarshal_s(ctx, &out->version); } -static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { +static FLATTEN void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->afid); unmarshal_s(ctx, &out->uname); @@ -616,12 +616,12 @@ static void unmarshal_Tauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tauth * if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->n_uname); } -static void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { +static FLATTEN void unmarshal_Rauth(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rauth *out) { memset(out, 0, sizeof(*out)); unmarshal_qid(ctx, &out->aqid); } -static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *out) { +static FLATTEN void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tattach *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_4(ctx, &out->afid); @@ -629,27 +629,27 @@ static void unmarshal_Tattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tatta unmarshal_s(ctx, &out->aname); } -static void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { +static FLATTEN void unmarshal_Rattach(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rattach *out) { memset(out, 0, sizeof(*out)); unmarshal_qid(ctx, &out->qid); } -static void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) { +static FLATTEN void unmarshal_Rerror(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rerror *out) { memset(out, 0, sizeof(*out)); unmarshal_s(ctx, &out->ename); if ( (ctx->ctx->version==LIB9P_VER_9P2000_u) ) unmarshal_4(ctx, &out->errno); } -static void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { +static FLATTEN void unmarshal_Tflush(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tflush *out) { memset(out, 0, sizeof(*out)); unmarshal_2(ctx, &out->oldtag); } -static void unmarshal_Rflush(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rflush *out) { +static FLATTEN void unmarshal_Rflush(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rflush *out) { memset(out, 0, sizeof(*out)); } -static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) { +static FLATTEN void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_4(ctx, &out->newfid); @@ -660,7 +660,7 @@ static void unmarshal_Twalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twalk * unmarshal_s(ctx, &out->wname[i]); } -static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { +static FLATTEN void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk *out) { memset(out, 0, sizeof(*out)); unmarshal_2(ctx, &out->nwqid); out->wqid = ctx->extra; @@ -669,19 +669,19 @@ static void unmarshal_Rwalk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwalk * unmarshal_qid(ctx, &out->wqid[i]); } -static void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { +static FLATTEN void unmarshal_Topen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Topen *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_1(ctx, &out->mode); } -static void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *out) { +static FLATTEN void unmarshal_Ropen(struct _unmarshal_ctx *ctx, struct lib9p_msg_Ropen *out) { memset(out, 0, sizeof(*out)); unmarshal_qid(ctx, &out->qid); unmarshal_4(ctx, &out->iounit); } -static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) { +static FLATTEN void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcreate *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_s(ctx, &out->name); @@ -689,84 +689,84 @@ static void unmarshal_Tcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tcrea unmarshal_1(ctx, &out->mode); } -static void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *out) { +static FLATTEN void unmarshal_Rcreate(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rcreate *out) { memset(out, 0, sizeof(*out)); unmarshal_qid(ctx, &out->qid); unmarshal_4(ctx, &out->iounit); } -static void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *out) { +static FLATTEN void unmarshal_Tread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tread *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_8(ctx, &out->offset); unmarshal_4(ctx, &out->count); } -static void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) { +static FLATTEN void unmarshal_Rread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rread *out) { memset(out, 0, sizeof(*out)); unmarshal_d(ctx, &out->data); } -static void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { +static FLATTEN void unmarshal_Twrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twrite *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_8(ctx, &out->offset); unmarshal_d(ctx, &out->data); } -static void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { +static FLATTEN void unmarshal_Rwrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rwrite *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->count); } -static void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { +static FLATTEN void unmarshal_Tclunk(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tclunk *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); } -static void unmarshal_Rclunk(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rclunk *out) { +static FLATTEN void unmarshal_Rclunk(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rclunk *out) { memset(out, 0, sizeof(*out)); } -static void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *out) { +static FLATTEN void unmarshal_Tremove(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tremove *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); } -static void unmarshal_Rremove(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rremove *out) { +static FLATTEN void unmarshal_Rremove(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rremove *out) { memset(out, 0, sizeof(*out)); } -static void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { +static FLATTEN void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tstat *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); } -static void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) { +static FLATTEN void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) { memset(out, 0, sizeof(*out)); unmarshal_stat(ctx, &out->stat); } -static void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) { +static FLATTEN void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_stat(ctx, &out->stat); } -static void unmarshal_Rwstat(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *out) { +static FLATTEN void unmarshal_Rwstat(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *out) { memset(out, 0, sizeof(*out)); } -static void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) { +static FLATTEN void unmarshal_Tsession(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsession *out) { memset(out, 0, sizeof(*out)); unmarshal_8(ctx, &out->key); } -static void unmarshal_Rsession(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rsession *out) { +static FLATTEN void unmarshal_Rsession(struct _unmarshal_ctx *UNUSED(ctx), struct lib9p_msg_Rsession *out) { memset(out, 0, sizeof(*out)); } -static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *out) { +static FLATTEN void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_2(ctx, &out->nwname); @@ -776,12 +776,12 @@ static void unmarshal_Tsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tsread unmarshal_s(ctx, &out->wname[i]); } -static void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) { +static FLATTEN void unmarshal_Rsread(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rsread *out) { memset(out, 0, sizeof(*out)); unmarshal_d(ctx, &out->data); } -static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) { +static FLATTEN void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswrite *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->fid); unmarshal_2(ctx, &out->nwname); @@ -792,14 +792,14 @@ static void unmarshal_Tswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Tswri unmarshal_d(ctx, &out->data); } -static void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { +static FLATTEN void unmarshal_Rswrite(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rswrite *out) { memset(out, 0, sizeof(*out)); unmarshal_4(ctx, &out->count); } /* marshal_* ******************************************************************/ -static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { +static ALWAYS_INLINE bool _marshal_too_large(struct _marshal_ctx *ctx) { lib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")", (ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message", ctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"), @@ -807,7 +807,7 @@ static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { return true; } -static inline bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { +static ALWAYS_INLINE bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { if (ctx->net_offset + 1 > ctx->ctx->max_msg_size) return _marshal_too_large(ctx); ctx->net_bytes[ctx->net_offset] = *val; @@ -815,7 +815,7 @@ static inline bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { return false; } -static inline bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { +static ALWAYS_INLINE bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { if (ctx->net_offset + 2 > ctx->ctx->max_msg_size) return _marshal_too_large(ctx); encode_u16le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -823,7 +823,7 @@ static inline bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { return false; } -static inline bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { +static ALWAYS_INLINE bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { if (ctx->net_offset + 4 > ctx->ctx->max_msg_size) return true; encode_u32le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -831,7 +831,7 @@ static inline bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { return false; } -static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { +static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { if (ctx->net_offset + 8 > ctx->ctx->max_msg_size) return true; encode_u64le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -839,7 +839,7 @@ static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { return false; } -static inline bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *val) { +static ALWAYS_INLINE bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *val) { return marshal_4(ctx, &val->len) || ({ bool err = false; @@ -849,7 +849,7 @@ static inline bool marshal_d(struct _marshal_ctx *ctx, struct lib9p_d *val) { }); } -static inline bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) { +static ALWAYS_INLINE bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) { return marshal_2(ctx, &val->len) || ({ bool err = false; @@ -859,13 +859,13 @@ static inline bool marshal_s(struct _marshal_ctx *ctx, struct lib9p_s *val) { }); } -static inline bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { +static ALWAYS_INLINE bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid *val) { return marshal_1(ctx, &val->type) || marshal_4(ctx, &val->vers) || marshal_8(ctx, &val->path); } -static inline bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { +static ALWAYS_INLINE bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) { return marshal_2(ctx, &val->stat_size) || marshal_2(ctx, &val->kern_type) || marshal_4(ctx, &val->kern_dev) @@ -884,52 +884,52 @@ static inline bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_last_modified_n_uid) ); } -static bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { +static FLATTEN bool marshal_Tversion(struct _marshal_ctx *ctx, struct lib9p_msg_Tversion *val) { return marshal_4(ctx, &val->max_msg_size) || marshal_s(ctx, &val->version); } -static bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *val) { +static FLATTEN bool marshal_Rversion(struct _marshal_ctx *ctx, struct lib9p_msg_Rversion *val) { return marshal_4(ctx, &val->max_msg_size) || marshal_s(ctx, &val->version); } -static bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) { +static FLATTEN bool marshal_Tauth(struct _marshal_ctx *ctx, struct lib9p_msg_Tauth *val) { return marshal_4(ctx, &val->afid) || marshal_s(ctx, &val->uname) || marshal_s(ctx, &val->aname) || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->n_uname) ); } -static bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { +static FLATTEN bool marshal_Rauth(struct _marshal_ctx *ctx, struct lib9p_msg_Rauth *val) { return marshal_qid(ctx, &val->aqid); } -static bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { +static FLATTEN bool marshal_Tattach(struct _marshal_ctx *ctx, struct lib9p_msg_Tattach *val) { return marshal_4(ctx, &val->fid) || marshal_4(ctx, &val->afid) || marshal_s(ctx, &val->uname) || marshal_s(ctx, &val->aname); } -static bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *val) { +static FLATTEN bool marshal_Rattach(struct _marshal_ctx *ctx, struct lib9p_msg_Rattach *val) { return marshal_qid(ctx, &val->qid); } -static bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { +static FLATTEN bool marshal_Rerror(struct _marshal_ctx *ctx, struct lib9p_msg_Rerror *val) { return marshal_s(ctx, &val->ename) || ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->errno) ); } -static bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { +static FLATTEN bool marshal_Tflush(struct _marshal_ctx *ctx, struct lib9p_msg_Tflush *val) { return marshal_2(ctx, &val->oldtag); } -static bool marshal_Rflush(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rflush *UNUSED(val)) { +static FLATTEN bool marshal_Rflush(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rflush *UNUSED(val)) { return false; } -static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { +static FLATTEN bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) { return marshal_4(ctx, &val->fid) || marshal_4(ctx, &val->newfid) || marshal_2(ctx, &val->nwname) @@ -941,7 +941,7 @@ static bool marshal_Twalk(struct _marshal_ctx *ctx, struct lib9p_msg_Twalk *val) }); } -static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) { +static FLATTEN bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) { return marshal_2(ctx, &val->nwqid) || ({ bool err = false; @@ -951,90 +951,90 @@ static bool marshal_Rwalk(struct _marshal_ctx *ctx, struct lib9p_msg_Rwalk *val) }); } -static bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { +static FLATTEN bool marshal_Topen(struct _marshal_ctx *ctx, struct lib9p_msg_Topen *val) { return marshal_4(ctx, &val->fid) || marshal_1(ctx, &val->mode); } -static bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *val) { +static FLATTEN bool marshal_Ropen(struct _marshal_ctx *ctx, struct lib9p_msg_Ropen *val) { return marshal_qid(ctx, &val->qid) || marshal_4(ctx, &val->iounit); } -static bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { +static FLATTEN bool marshal_Tcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Tcreate *val) { return marshal_4(ctx, &val->fid) || marshal_s(ctx, &val->name) || marshal_4(ctx, &val->perm) || marshal_1(ctx, &val->mode); } -static bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *val) { +static FLATTEN bool marshal_Rcreate(struct _marshal_ctx *ctx, struct lib9p_msg_Rcreate *val) { return marshal_qid(ctx, &val->qid) || marshal_4(ctx, &val->iounit); } -static bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { +static FLATTEN bool marshal_Tread(struct _marshal_ctx *ctx, struct lib9p_msg_Tread *val) { return marshal_4(ctx, &val->fid) || marshal_8(ctx, &val->offset) || marshal_4(ctx, &val->count); } -static bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) { +static FLATTEN bool marshal_Rread(struct _marshal_ctx *ctx, struct lib9p_msg_Rread *val) { return marshal_d(ctx, &val->data); } -static bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *val) { +static FLATTEN bool marshal_Twrite(struct _marshal_ctx *ctx, struct lib9p_msg_Twrite *val) { return marshal_4(ctx, &val->fid) || marshal_8(ctx, &val->offset) || marshal_d(ctx, &val->data); } -static bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *val) { +static FLATTEN bool marshal_Rwrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rwrite *val) { return marshal_4(ctx, &val->count); } -static bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *val) { +static FLATTEN bool marshal_Tclunk(struct _marshal_ctx *ctx, struct lib9p_msg_Tclunk *val) { return marshal_4(ctx, &val->fid); } -static bool marshal_Rclunk(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rclunk *UNUSED(val)) { +static FLATTEN bool marshal_Rclunk(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rclunk *UNUSED(val)) { return false; } -static bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { +static FLATTEN bool marshal_Tremove(struct _marshal_ctx *ctx, struct lib9p_msg_Tremove *val) { return marshal_4(ctx, &val->fid); } -static bool marshal_Rremove(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rremove *UNUSED(val)) { +static FLATTEN bool marshal_Rremove(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rremove *UNUSED(val)) { return false; } -static bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *val) { +static FLATTEN bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tstat *val) { return marshal_4(ctx, &val->fid); } -static bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { +static FLATTEN bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) { return marshal_stat(ctx, &val->stat); } -static bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { +static FLATTEN bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) { return marshal_4(ctx, &val->fid) || marshal_stat(ctx, &val->stat); } -static bool marshal_Rwstat(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *UNUSED(val)) { +static FLATTEN bool marshal_Rwstat(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *UNUSED(val)) { return false; } -static bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) { +static FLATTEN bool marshal_Tsession(struct _marshal_ctx *ctx, struct lib9p_msg_Tsession *val) { return marshal_8(ctx, &val->key); } -static bool marshal_Rsession(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rsession *UNUSED(val)) { +static FLATTEN bool marshal_Rsession(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rsession *UNUSED(val)) { return false; } -static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *val) { +static FLATTEN bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *val) { return marshal_4(ctx, &val->fid) || marshal_2(ctx, &val->nwname) || ({ @@ -1045,11 +1045,11 @@ static bool marshal_Tsread(struct _marshal_ctx *ctx, struct lib9p_msg_Tsread *va }); } -static bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) { +static FLATTEN bool marshal_Rsread(struct _marshal_ctx *ctx, struct lib9p_msg_Rsread *val) { return marshal_d(ctx, &val->data); } -static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) { +static FLATTEN bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite *val) { return marshal_4(ctx, &val->fid) || marshal_2(ctx, &val->nwname) || ({ @@ -1061,7 +1061,7 @@ static bool marshal_Tswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Tswrite * || marshal_d(ctx, &val->data); } -static bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *val) { +static FLATTEN bool marshal_Rswrite(struct _marshal_ctx *ctx, struct lib9p_msg_Rswrite *val) { return marshal_4(ctx, &val->count); } diff --git a/lib9p/types.gen b/lib9p/types.gen index a597022..9946e35 100755 --- a/lib9p/types.gen +++ b/lib9p/types.gen @@ -379,7 +379,7 @@ const char *{idprefix}msg_type_str(enum {idprefix}msg_type typ) {{ ret += """ /* checksize_* (internals of unmarshal_size()) ********************************/ -static inline bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { +static ALWAYS_INLINE bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { if (__builtin_add_overflow(ctx->net_offset, n, &ctx->net_offset)) /* If needed-net-size overflowed uint32_t, then * there's no way that actual-net-size will live up to @@ -390,7 +390,7 @@ static inline bool _checksize_net(struct _checksize_ctx *ctx, uint32_t n) { return false; } -static inline bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { +static ALWAYS_INLINE bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { if (__builtin_add_overflow(ctx->host_extra, n, &ctx->host_extra)) /* If needed-host-size overflowed size_t, then there's * no way that actual-net-size will live up to @@ -399,7 +399,7 @@ static inline bool _checksize_host(struct _checksize_ctx *ctx, size_t n) { return false; } -static inline bool _checksize_list(struct _checksize_ctx *ctx, +static ALWAYS_INLINE bool _checksize_list(struct _checksize_ctx *ctx, size_t cnt, _checksize_fn_t item_fn, size_t item_host_size) { for (size_t i = 0; i < cnt; i++) if (_checksize_host(ctx, item_host_size) || item_fn(ctx)) @@ -413,7 +413,7 @@ static inline bool _checksize_list(struct _checksize_ctx *ctx, #define checksize_8(ctx) _checksize_net(ctx, 8) """ for struct in structs: - inline = " inline" if struct.msgid is None else "" + inline = " ALWAYS_INLINE" if struct.msgid is None else " FLATTEN" argfn = used if struct.members else unused ret += "\n" ret += f"static{inline} bool checksize_{struct.name}(struct _checksize_ctx *{argfn('ctx')}) {{" @@ -475,28 +475,28 @@ static inline bool _checksize_list(struct _checksize_ctx *ctx, ret += """ /* unmarshal_* ****************************************************************/ -static inline void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { +static ALWAYS_INLINE void unmarshal_1(struct _unmarshal_ctx *ctx, uint8_t *out) { *out = decode_u8le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 1; } -static inline void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { +static ALWAYS_INLINE void unmarshal_2(struct _unmarshal_ctx *ctx, uint16_t *out) { *out = decode_u16le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 2; } -static inline void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { +static ALWAYS_INLINE void unmarshal_4(struct _unmarshal_ctx *ctx, uint32_t *out) { *out = decode_u32le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 4; } -static inline void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { +static ALWAYS_INLINE void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { *out = decode_u64le(&ctx->net_bytes[ctx->net_offset]); ctx->net_offset += 8; } """ for struct in structs: - inline = " inline" if struct.msgid is None else "" + inline = " ALWAYS_INLINE" if struct.msgid is None else " FLATTEN" argfn = used if struct.members else unused ret += "\n" ret += f"static{inline} void unmarshal_{struct.name}(struct _unmarshal_ctx *{argfn('ctx')}, {c_typename(idprefix, struct)} *out) {{\n" @@ -527,7 +527,7 @@ static inline void unmarshal_8(struct _unmarshal_ctx *ctx, uint64_t *out) { ret += """ /* marshal_* ******************************************************************/ -static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { +static ALWAYS_INLINE bool _marshal_too_large(struct _marshal_ctx *ctx) { lib9p_errorf(ctx->ctx, LINUX_ERANGE, "%s too large to marshal into %s limit (limit=%"PRIu32")", (ctx->net_bytes[4] % 2 == 0) ? "T-message" : "R-message", ctx->ctx->version ? "negotiated" : ((ctx->net_bytes[4] % 2 == 0) ? "client" : "server"), @@ -535,7 +535,7 @@ static inline bool _marshal_too_large(struct _marshal_ctx *ctx) { return true; } -static inline bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { +static ALWAYS_INLINE bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { if (ctx->net_offset + 1 > ctx->ctx->max_msg_size) return _marshal_too_large(ctx); ctx->net_bytes[ctx->net_offset] = *val; @@ -543,7 +543,7 @@ static inline bool marshal_1(struct _marshal_ctx *ctx, uint8_t *val) { return false; } -static inline bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { +static ALWAYS_INLINE bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { if (ctx->net_offset + 2 > ctx->ctx->max_msg_size) return _marshal_too_large(ctx); encode_u16le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -551,7 +551,7 @@ static inline bool marshal_2(struct _marshal_ctx *ctx, uint16_t *val) { return false; } -static inline bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { +static ALWAYS_INLINE bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { if (ctx->net_offset + 4 > ctx->ctx->max_msg_size) return true; encode_u32le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -559,7 +559,7 @@ static inline bool marshal_4(struct _marshal_ctx *ctx, uint32_t *val) { return false; } -static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { +static ALWAYS_INLINE bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { if (ctx->net_offset + 8 > ctx->ctx->max_msg_size) return true; encode_u64le(*val, &ctx->net_bytes[ctx->net_offset]); @@ -568,7 +568,7 @@ static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { } """ for struct in structs: - inline = " inline" if struct.msgid is None else "" + inline = " ALWAYS_INLINE" if struct.msgid is None else " FLATTEN" argfn = used if struct.members else unused ret += "\n" ret += f"static{inline} bool marshal_{struct.name}(struct _marshal_ctx *{argfn('ctx')}, {c_typename(idprefix, struct)} *{argfn('val')}) {{" |