haproxy/include/haproxy/stress.h
Amaury Denoyelle 9d19fc4cf7 MINOR: build: define DEBUG_STRESS
Define a new build mode DEBUG_STRESS. This will be used to stress some
code parts which cannot be reproduce easily with an alternative
suboptimal code.

First, a global <mode_stress> is set either to 1 or 0 depending on
DEBUG_STRESS compilation. A new global keyword "stress-level" is also
defined. It allows to specify a level from 0 to 9, to increase the
stress incurred on the code.

Helper macro STRESS_RUN* are defined for each stress level. This allows
to easily specify an instruction in default execution and a stress
counterpart if running on the corresponding stress level.
2024-12-12 11:19:10 +01:00

23 lines
985 B
C

#ifndef _HAPROXY_STRESS_H
#define _HAPROXY_STRESS_H
#ifdef DEBUG_STRESS
enum { mode_stress = 1 };
#else
enum { mode_stress = 0 };
#endif
extern int mode_stress_level;
#define STRESS_RUN1(a,b) (mode_stress && unlikely(mode_stress_level >= 1) ? (a) : (b))
#define STRESS_RUN2(a,b) (mode_stress && unlikely(mode_stress_level >= 2) ? (a) : (b))
#define STRESS_RUN3(a,b) (mode_stress && unlikely(mode_stress_level >= 3) ? (a) : (b))
#define STRESS_RUN4(a,b) (mode_stress && unlikely(mode_stress_level >= 4) ? (a) : (b))
#define STRESS_RUN5(a,b) (mode_stress && unlikely(mode_stress_level >= 5) ? (a) : (b))
#define STRESS_RUN6(a,b) (mode_stress && unlikely(mode_stress_level >= 6) ? (a) : (b))
#define STRESS_RUN7(a,b) (mode_stress && unlikely(mode_stress_level >= 7) ? (a) : (b))
#define STRESS_RUN8(a,b) (mode_stress && unlikely(mode_stress_level >= 8) ? (a) : (b))
#define STRESS_RUN9(a,b) (mode_stress && unlikely(mode_stress_level >= 9) ? (a) : (b))
#endif /* _HAPROXY_STRESS_H */