MINOR: lua: use bitfield and macro in place of integer and enum
In the future, the lua execution must return scheduling informations.
We want more than one flag, so I convert an integer used with an
enum into an interer used as bitfield.
diff --git a/include/proto/hlua.h b/include/proto/hlua.h
index b9530aa..1428673 100644
--- a/include/proto/hlua.h
+++ b/include/proto/hlua.h
@@ -7,6 +7,11 @@
#include <types/hlua.h>
+/* 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)
+#define HLUA_IS_RUNNING(__hlua) ((__hlua)->flags & HLUA_RUN)
+
#define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0)
/* Lua HAProxy integration functions. */
@@ -16,6 +21,8 @@
#else /* USE_LUA */
+#define HLUA_IS_RUNNING(__hlua) 0
+
#define HLUA_INIT(__hlua)
/* Empty function for compilation without Lua. */
diff --git a/include/types/hlua.h b/include/types/hlua.h
index 2257d5c..5920e03 100644
--- a/include/types/hlua.h
+++ b/include/types/hlua.h
@@ -16,10 +16,7 @@
struct session;
-enum hlua_state {
- HLUA_STOP = 0,
- HLUA_RUN,
-};
+#define HLUA_RUN 0x00000001
enum hlua_exec {
HLUA_E_OK = 0,
@@ -37,7 +34,7 @@
int Mref; /* The reference of the memory context in coroutine case.
-1 if the memory context is not used. */
int nargs; /* The number of arguments in the stack at the start of execution. */
- enum hlua_state state; /* The current execution state. */
+ unsigned int flags; /* The current execution flags. */
struct task *task; /* The task associated with the lua stack execution.
We must wake this task to continue the task execution */
struct list com; /* The list head of the signals attached to this task. */