Add an allocation limit injection facility

parent 90a80e1f
...@@ -100,6 +100,18 @@ fc_inj_err(const char *err) ...@@ -100,6 +100,18 @@ fc_inj_err(const char *err)
#define FC_INJ fc_inj_injected(__func__, __LINE__) #define FC_INJ fc_inj_injected(__func__, __LINE__)
#define FC_ERRSTR(x) fc_inj_err(x) #define FC_ERRSTR(x) fc_inj_err(x)
_Thread_local size_t size_limit = SIZE_MAX;
#define FC_INJ_SZLIM(x) do { \
if (x > size_limit) { \
DBG("%s limited from %zu to %zu", \
#x, x, size_limit); \
x = size_limit; \
} \
size_limit = SIZE_MAX; \
} while (0)
#define FC_INJ_SZLIM_SET(x) size_limit = x
#else // FCERR_INJECT #else // FCERR_INJECT
#define FC_INJ 0 #define FC_INJ 0
...@@ -107,6 +119,7 @@ fc_inj_err(const char *err) ...@@ -107,6 +119,7 @@ fc_inj_err(const char *err)
#define fc_inj_reset() (void)0 #define fc_inj_reset() (void)0
#define fc_inj_set(x) (void)0 #define fc_inj_set(x) (void)0
#define fc_inj_count() 0 #define fc_inj_count() 0
#define FC_INJ_SZLIM(x) (void)0
#define FC_INJ_SZLIM_SET(x) (void)0
#endif // FCERR_INJECT #endif // FCERR_INJECT
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
// symbol not ref (constructor) // symbol not ref (constructor)
-esym(528, init_fcos_transitions, assert_fcos*) -esym(528, init_fcos_transitions, assert_fcos*)
-esym(755, BWIT_*) -esym(755, BWIT_*)
-esym(755, fc_inj_*) -esym(755, fc_inj_*, FC_INJ_SZLIM_SET) // not referenced
// fellow_io_uring.c // fellow_io_uring.c
-emacro(835, BLKDISCARD) -emacro(835, BLKDISCARD)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment