}
}
+static void before_hash(struct tvec_state *tv, void *ctx)
+ { tvec_allocbuffer(&tv->in[RM].v); }
+
static void bench_crc32(const struct tvec_reg *in, struct tvec_reg *out,
void *ctx)
{ crc32(0, in[RM].v.bytes.p, in[RM].v.bytes.sz); }
+static const struct tvec_env crc32_benchenv =
+ { 0, 0, 0, before_hash };
static void test_unihash(const struct tvec_reg *in, struct tvec_reg *out,
void *ctx)
static void bench_unihash(const struct tvec_reg *in, struct tvec_reg *out,
void *ctx)
{ unihash_hash(ctx, 0, in[RM].v.bytes.p, in[RM].v.bytes.sz); }
-static int setup_unihash(struct tvec_state *tv,
- const struct tvec_env *env, void *pctx, void *ctx)
- { unihash_setkey(ctx, 0); return (0); }
+static void setup_unihash(struct tvec_state *tv,
+ const struct tvec_env *env, void *pctx, void *ctx)
+ { tvec_allocbuffer(&tv->in[RM].v); unihash_setkey(ctx, 0); }
static const struct tvec_env unihash_benchenv =
- { sizeof(unihash_info), setup_unihash, 0, 0 };
+ { sizeof(unihash_info), setup_unihash, 0, before_hash };
static void run_step(struct tvec_state *tv, tvec_testfn *fn, void *ctx)
{
static const struct tvec_env step_testenv = { 0, 0, 0, 0, run_step, 0, 0 };
static const struct tvec_regdef unihash_regs[] = {
- { "k", RK, &tvty_uint, 0, { &tvrange_u32 } },
- { "m", RM, &tvty_bytes, 0 },
- { "h", RH, &tvty_uint, 0, { &tvrange_u32 } },
- { 0, 0, 0, 0 }
+ { "k", &tvty_uint, RK, 0, { &tvrange_u32 } },
+ { "m", &tvty_bytes, RM, 0 },
+ { "h", &tvty_uint, RH, 0, { &tvrange_u32 } },
+ TVEC_ENDREGS
};
static const struct tvec_regdef crc32_regs[] = {
- { "m", RM, &tvty_bytes, 0 },
- { "h", RH, &tvty_uint, 0, { &tvrange_u32 } },
- { 0, 0, 0, 0 }
+ { "m", &tvty_bytes, RM, 0 },
+ { "h", &tvty_uint, RH, 0, { &tvrange_u32 } },
+ TVEC_ENDREGS
};
static const struct tvec_regdef bench_regs[] = {
- { "msz", RM, &tvty_buffer, TVRF_ID },
- { 0, 0, 0, 0 }
+ { "msz", &tvty_buffer, RM, TVRF_ID },
+ TVEC_ENDREGS
};
-static const struct tvec_bench crc32_bench =
- { TVEC_BENCHINIT, 1, -1, RM, 0 };
-static const struct tvec_bench unihash_bench =
+static const struct tvec_benchenv crc32_bench =
+ { TVEC_BENCHINIT, 1, -1, RM, &crc32_benchenv };
+static const struct tvec_benchenv unihash_bench =
{ TVEC_BENCHINIT, 1, -1, RM, &unihash_benchenv };
static const struct tvec_test tests[] = {
{ "unihash", unihash_regs, &step_testenv, test_unihash },
{ "crc32-bench", bench_regs, &crc32_bench._env, bench_crc32 },
{ "unihash-bench", bench_regs, &unihash_bench._env, bench_unihash },
- { 0, 0, 0, 0 }
+ TVEC_ENDTESTS
};
-static const struct tvec_info testinfo =
+static const struct tvec_config testconfig =
{ tests, NROUT, NREG, sizeof(struct tvec_reg) };
int main(int argc, char *argv[])
- { return (tvec_main(argc, argv, &testinfo, 0)); }
+ { return (tvec_main(argc, argv, &testconfig, 0)); }
/*----- That's all, folks -------------------------------------------------*/