On Tue, Aug 22, 2023 at 3:54 PM Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote: > > > I suppose we could switch to the ' if (!(LHS <op> RHS)) bpf_throw(); ' > sequence in C, force volatile load for LHS and __builtin_constant_p > for RHS to get the same behavior. Emitting these redundant checks is > definitely a bit weird just to emit BTF. I guess we can try #define bpf_assert(LHS, OP, RHS) if (!(LHS OP RHS)) bpf_throw(); with barrier_var(LHS) and __builtin_constant_p(RHS) and keep things completely in C, but there is no guarantee that the compiler will not convert == to !=, swap lhs and rhs, etc. Maybe we can have both asm and C style macros, then recommend C to start and switch to asm if things are dodgy. Feels like dangerous ambiguity.