mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
bpf: Convert bpf_get_spilled_reg macro to static inline function
Convert the bpf_get_spilled_reg() macro to a static inline function for better type safety and readability. This also simplifies the macro definition in preparation for upcoming stack argument support which will introduce additional macros. No functional change. Signed-off-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/20260513044954.2382693-1-yonghong.song@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
6318f11d53
commit
ede2dc5c6b
|
|
@ -552,10 +552,14 @@ struct bpf_verifier_state {
|
|||
u32 may_goto_depth;
|
||||
};
|
||||
|
||||
#define bpf_get_spilled_reg(slot, frame, mask) \
|
||||
(((slot < frame->allocated_stack / BPF_REG_SIZE) && \
|
||||
((1 << frame->stack[slot].slot_type[BPF_REG_SIZE - 1]) & (mask))) \
|
||||
? &frame->stack[slot].spilled_ptr : NULL)
|
||||
static inline struct bpf_reg_state *
|
||||
bpf_get_spilled_reg(int slot, struct bpf_func_state *frame, u32 mask)
|
||||
{
|
||||
if (slot < frame->allocated_stack / BPF_REG_SIZE &&
|
||||
(1 << frame->stack[slot].slot_type[BPF_REG_SIZE - 1]) & mask)
|
||||
return &frame->stack[slot].spilled_ptr;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Iterate over 'frame', setting 'reg' to either NULL or a spilled register. */
|
||||
#define bpf_for_each_spilled_reg(iter, frame, reg, mask) \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user