blob: 7ad5a99ef39285fc1608bea49807578d40e52458 [file] [log] [blame]
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +01001#ifndef _PROTO_HLUA_H
2#define _PROTO_HLUA_H
3
Thierry FOURNIERa718b292015-03-04 16:48:34 +01004#ifdef USE_LUA
5
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +01006#include <lua.h>
7
8#include <types/hlua.h>
9
Thierry FOURNIERa097fdf2015-03-03 15:17:35 +010010/* The following macros are used to set flags. */
11#define HLUA_SET_RUN(__hlua) do {(__hlua)->flags |= HLUA_RUN;} while(0)
12#define HLUA_CLR_RUN(__hlua) do {(__hlua)->flags &= ~HLUA_RUN;} while(0)
13#define HLUA_IS_RUNNING(__hlua) ((__hlua)->flags & HLUA_RUN)
Thierry FOURNIER4abd3ae2015-03-03 17:29:06 +010014#define HLUA_SET_CTRLYIELD(__hlua) do {(__hlua)->flags |= HLUA_CTRLYIELD;} while(0)
15#define HLUA_CLR_CTRLYIELD(__hlua) do {(__hlua)->flags &= ~HLUA_CTRLYIELD;} while(0)
16#define HLUA_IS_CTRLYIELDING(__hlua) ((__hlua)->flags & HLUA_CTRLYIELD)
Thierry FOURNIERef6a2112015-03-05 17:45:34 +010017#define HLUA_SET_WAKERESWR(__hlua) do {(__hlua)->flags |= HLUA_WAKERESWR;} while(0)
18#define HLUA_CLR_WAKERESWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKERESWR;} while(0)
19#define HLUA_IS_WAKERESWR(__hlua) ((__hlua)->flags & HLUA_WAKERESWR)
Thierry FOURNIER53e08ec2015-03-06 00:35:53 +010020#define HLUA_SET_WAKEREQWR(__hlua) do {(__hlua)->flags |= HLUA_WAKEREQWR;} while(0)
21#define HLUA_CLR_WAKEREQWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKEREQWR;} while(0)
22#define HLUA_IS_WAKEREQWR(__hlua) ((__hlua)->flags & HLUA_WAKEREQWR)
Thierry FOURNIERa097fdf2015-03-03 15:17:35 +010023
Thierry FOURNIERa718b292015-03-04 16:48:34 +010024#define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0)
25
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +010026/* Lua HAProxy integration functions. */
Thierry FOURNIER380d0932015-01-23 14:27:52 +010027void hlua_ctx_destroy(struct hlua *lua);
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +010028void hlua_init();
Thierry FOURNIERa4a0f3d2015-01-23 12:08:30 +010029int hlua_post_init();
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +010030
Thierry FOURNIERa718b292015-03-04 16:48:34 +010031#else /* USE_LUA */
32
Thierry FOURNIERa097fdf2015-03-03 15:17:35 +010033#define HLUA_IS_RUNNING(__hlua) 0
34
Thierry FOURNIERa718b292015-03-04 16:48:34 +010035#define HLUA_INIT(__hlua)
36
37/* Empty function for compilation without Lua. */
38static inline void hlua_init() { }
39static inline int hlua_post_init() { return 1; }
Willy Tarreauce7b4de2015-06-17 20:18:54 +020040static inline void hlua_ctx_destroy(struct hlua *lua) { }
Thierry FOURNIERa718b292015-03-04 16:48:34 +010041
42#endif /* USE_LUA */
43
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +010044#endif /* _PROTO_HLUA_H */