*
* Arguments: @struct tvec_state *tv@ = test vector state
* @const char *var@ = variable name to set
- * @const struct tvec_env *env@ = environment description
* @void *ctx@ = context pointer
*
* Returns: Zero on success, @-1@ on failure.
* environment, if there is one.
*/
-int tvec_benchset(struct tvec_state *tv, const char *var,
- const struct tvec_env *env, void *ctx)
+int tvec_benchset(struct tvec_state *tv, const char *var, void *ctx)
{
struct tvec_benchctx *bc = ctx;
- const struct tvec_benchenv *be = (const struct tvec_benchenv *)env;
+ const struct tvec_benchenv *be = bc->be;
const struct tvec_env *subenv = be->env;
union tvec_regval rv;
static const struct tvec_floatinfo fi = { TVFF_NOMAX, 0.0, 0.0, 0.0 };
{ "@target", -1, &tvty_float, 0, { &fi } };
if (STRCMP(var, ==, "@target")) {
+ if (bc->f&TVBF_SETTRG) return (tvec_dupreg(tv, var));
if (tvty_float.parse(&rv, &rd, tv)) return (-1);
- if (bc) bc->bst->target_s = rv.f;
- return (1);
+ bc->bst->target_s = rv.f; bc->f |= TVBF_SETTRG; return (1);
} else if (subenv && subenv->set)
- return (subenv->set(tv, var, subenv, bc->subctx));
+ return (subenv->set(tv, var, bc->subctx));
else
return (0);
}
/* Restore the benchmark state's old target. */
bc->bst->target_s = bc->dflt_target;
+ bc->f &= ~TVBF_SETTRG;
/* Pass the call on to the subsidiary environment. */
if (subenv && subenv->after) subenv->after(tv, bc->subctx);
const struct tvec_benchenv *be;
const struct tvec_env *subenv;
- if (!bc) return;
be = bc->be; subenv = be->env;
/* Tear down any subsidiary environment. */
- if (subenv && subenv->teardown && bc->subctx)
+ if (subenv && subenv->teardown)
subenv->teardown(tv, bc->subctx);
/* If the benchmark state was temporary, then dispose of it. */