MINOR: compiler: add a new "ASSUME" macro to help the compiler
authorWilly Tarreau <w@1wt.eu>
Thu, 7 Nov 2024 10:09:33 +0000 (11:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Apr 2025 15:04:35 +0000 (17:04 +0200)
commitcf2b5621d2e8e88dd00cd57bf3683f50440bee89
tree8338b0b315266b4259c8d2eea29c1626dd627739
parentd92f2e7b721a490b1e210ec47587dd60c4db5eb2
MINOR: compiler: add a new "ASSUME" macro to help the compiler

This macro takes an expression, tests it and calls an unreachable
statement if false. This allows the compiler to know that such a
combination does not happen, and totally eliminate tests that would
be related to this condition. When the statement is not available
in the compiler, we just perform a break from a do {} while loop
so that the expression remains evaluated if needed (e.g. function
call).

(cherry picked from commit efc897484b8b875f908c144d82313923be8c3392)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/compiler.h