Skip to content

Commit

Permalink
stress-funcret: add a helper function to set variable data
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Apr 12, 2022
1 parent 79115ca commit 634b1d8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions stress-funcret.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,24 @@ stress_funcret1(stress_uint64x128_t)
stress_funcret_deep1(stress_uint64x128_t)
stress_funcret_deeper1(stress_uint64x128_t)

static void stress_funcret_setvar(void *ptr, const size_t size)
{
register size_t i;
register uint8_t *ptr8 = (uint8_t *)ptr;

for (i = 0; i < size; i++)
ptr8[i] = stress_mwc8();
}

#define stress_funcret_type(type) \
static void NOINLINE stress_funcret_ ## type(const stress_args_t *args); \
\
static void NOINLINE stress_funcret_ ## type(const stress_args_t *args) \
{ \
register size_t i; \
type a; \
uint8_t data[sizeof(a)]; \
\
for (i = 0; i < sizeof(data); i++) \
data[i] = stress_mwc8(); \
(void)memcpy(&a, data, sizeof(a)); \
stress_funcret_setvar(&a, sizeof(a)); \
\
do { \
for (i = 0; i < 1000; i++) { \
Expand Down

0 comments on commit 634b1d8

Please sign in to comment.