@@@ timeout wip
[mLib] / test / tvec-bench.c
index 8c8cfdf..7086e14 100644 (file)
@@ -143,7 +143,6 @@ fail_timer:
  *
  * 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.
@@ -158,11 +157,10 @@ fail_timer:
  *             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 };
@@ -170,11 +168,11 @@ int tvec_benchset(struct tvec_state *tv, const char *var,
     { "@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);
 }
@@ -219,6 +217,7 @@ void tvec_benchafter(struct tvec_state *tv, void *ctx)
 
   /* 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);
@@ -240,11 +239,10 @@ void tvec_benchteardown(struct tvec_state *tv, void *ctx)
   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. */