From 5c0733db9a13516cd664926bd4273844db0ec98d Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Wed, 10 Jun 2026 14:17:22 +0200 Subject: [PATCH] MEDIUM: lua: move longjmp annotation macros to hlua.h __LJMP, WILL_LJMP() and MAY_LJMP() were defined locally in hlua.c, making them unavailable to other modules that implement Lua bindings. Move them to include/haproxy/hlua.h so they can be used outside of hlua.c. --- include/haproxy/hlua.h | 11 +++++++++++ src/hlua.c | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/haproxy/hlua.h b/include/haproxy/hlua.h index 38952da3b..31a7af083 100644 --- a/include/haproxy/hlua.h +++ b/include/haproxy/hlua.h @@ -26,6 +26,17 @@ #ifdef USE_LUA +/* Lua uses longjmp to perform yield or throwing errors. This + * macro is used only for identifying the function that can + * not return because a longjmp is executed. + * __LJMP marks a prototype of hlua file that can use longjmp. + * WILL_LJMP() marks an lua function that will use longjmp. + * MAY_LJMP() marks an lua function that may use longjmp. + */ +#define __LJMP +#define WILL_LJMP(func) do { func; my_unreachable(); } while(0) +#define MAY_LJMP(func) func + /* The following macros are used to set flags. */ #define HLUA_SET_RUN(__hlua) do {(__hlua)->flags |= HLUA_RUN;} while(0) #define HLUA_CLR_RUN(__hlua) do {(__hlua)->flags &= ~HLUA_RUN;} while(0) diff --git a/src/hlua.c b/src/hlua.c index 70e0a33a8..d2734d101 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -105,16 +105,6 @@ static uint8_t hlua_body = 1; */ static uint8_t hlua_bool_sample_conversion = HLUA_BOOL_SAMPLE_CONVERSION_UNK; -/* Lua uses longjmp to perform yield or throwing errors. This - * macro is used only for identifying the function that can - * not return because a longjmp is executed. - * __LJMP marks a prototype of hlua file that can use longjmp. - * WILL_LJMP() marks an lua function that will use longjmp. - * MAY_LJMP() marks an lua function that may use longjmp. - */ -#define __LJMP -#define WILL_LJMP(func) do { func; my_unreachable(); } while(0) -#define MAY_LJMP(func) func /* This couple of function executes securely some Lua calls outside of * the lua runtime environment. Each Lua call can return a longjmp