MINOR: htx: Add helper function to get type and size from the block info field

__htx_blkinfo_type() and __htx_blkinfo_size() function was added to return,
respectively, the type and the size from the block info field. The main
usage for these functions is internal to the htx code.
This commit is contained in:
Christopher Faulet 2026-04-13 19:04:20 +02:00
parent 6ff659db06
commit ebaa88a23a

View file

@ -165,28 +165,38 @@ static inline struct htx_blk *htx_get_blk(const struct htx *htx, uint32_t pos)
return (struct htx_blk *)(htx->blocks + htx_pos_to_addr(htx, pos));
}
static inline enum htx_blk_type __htx_blkinfo_type(uint32_t info)
{
return (info >> 28);
}
/* Returns the type of the block <blk> */
static inline enum htx_blk_type htx_get_blk_type(const struct htx_blk *blk)
{
return (blk->info >> 28);
return __htx_blkinfo_type(blk->info);
}
/* Returns the size of the block <blk>, depending of its type */
static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
static inline enum htx_blk_type __htx_blkinfo_size(uint32_t info)
{
enum htx_blk_type type = htx_get_blk_type(blk);
enum htx_blk_type type = __htx_blkinfo_type(info);
switch (type) {
case HTX_BLK_HDR:
case HTX_BLK_TLR:
/* name.length + value.length */
return ((blk->info & 0xff) + ((blk->info >> 8) & 0xfffff));
return ((info & 0xff) + ((info >> 8) & 0xfffff));
default:
/* value.length */
return (blk->info & 0xfffffff);
return (info & 0xfffffff);
}
}
/* Returns the size of the block <blk>, depending of its type */
static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
{
return __htx_blkinfo_size(blk->info);
}
/* Returns the position of the oldest entry (head). It returns a signed 32-bits
* integer, -1 means the HTX message is empty.
*/