PERFORCE change 222991 for review
Robert Watson
rwatson at FreeBSD.org
Sun Mar 17 23:45:35 UTC 2013
http://p4web.freebsd.org/@@222991?ac=10
Change 222991 by rwatson at rwatson_cinnamon on 2013/03/17 23:44:57
Merge updated libtesla from contrib to sys; loop back my build
changes and TESLA functional updates.
Affected files ...
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/debug.c#4 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/key.c#3 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/libtesla.h#4 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/state-perthread.c#6 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/state.c#5 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/store.c#6 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/tesla_internal.h#6 integrate
.. //depot/projects/ctsrd/tesla/src/sys/libtesla/update.c#5 integrate
Differences ...
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/debug.c#4 (text+ko) ====
@@ -45,9 +45,9 @@
char*
transition_matrix(const struct tesla_transitions *trans)
{
- static const char EACH[] = "(%d:0x%tx -> %d%s) ";
+ static const char EACH[] = "(%d:0x%tx -> %d%s%s%s) ";
- size_t needed = trans->length * (sizeof(EACH) + 4) + 4;
+ size_t needed = trans->length * (sizeof(EACH) + 12) + 4;
char *buffer = tesla_malloc(needed);
char *c = buffer;
@@ -56,7 +56,10 @@
for (size_t i = 0; i < trans->length; i++) {
const tesla_transition *t = trans->transitions + i;
c += sprintf(c, EACH, t->from, t->mask, t->to,
- t->fork ? " <fork>" : "");
+ (t->flags & TESLA_TRANS_FORK ? " <fork>" : ""),
+ (t->flags & TESLA_TRANS_INIT ? " <init>" : ""),
+ (t->flags & TESLA_TRANS_CLEANUP ? " <clean>" : "")
+ );
}
c += sprintf(c, "]");
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/key.c#3 (text+ko) ====
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/libtesla.h#4 (text+ko) ====
@@ -65,15 +65,15 @@
/** The state we are moving to. */
uint32_t to;
- /**
- * Explicit declaration that libtesla should fork on this transition.
- *
- * This is useful for e.g. TELSA "or" expressions, when we need to
- * allow either or both paths to be followed.
- */
- int fork;
+ /** Things we may need to do on this transition. */
+ int flags;
};
+#define TESLA_TRANS_FORK 0x01 /* Always fork on this transition. */
+#define TESLA_TRANS_INIT 0x02 /* May need to initialise the class. */
+#define TESLA_TRANS_CLEANUP 0x04 /* Clean up the class now. */
+
+
/**
* A set of permissible state transitions for an automata instance.
*
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/state-perthread.c#6 (text+ko) ====
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/state.c#5 (text+ko) ====
@@ -194,6 +194,8 @@
tesla_class_reset(struct tesla_class *c)
{
+ DEBUG_PRINT("tesla_class_reset(%" PRId64 ")\n", (uint64_t) c);
+
struct tesla_table *t = c->ts_table;
bzero(&t->tt_instances, sizeof(struct tesla_instance) * t->tt_length);
t->tt_free = t->tt_length;
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/store.c#6 (text+ko) ====
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/tesla_internal.h#6 (text+ko) ====
==== //depot/projects/ctsrd/tesla/src/sys/libtesla/update.c#5 (text+ko) ====
@@ -119,6 +119,9 @@
if (!tesla_key_matches(&masked, k))
continue;
+ if (k->tk_mask != t->mask)
+ continue;
+
if (inst->ti_state != t->from) {
// If the instance matches everything but the
// state, so there had better be a transition
@@ -136,7 +139,8 @@
// If the keys just match (and we haven't been explictly
// instructed to fork), just update the state.
- if (!t->fork && key->tk_mask == k->tk_mask) {
+ if (!(t->flags & TESLA_TRANS_FORK)
+ && key->tk_mask == k->tk_mask) {
VERBOSE_PRINT("update %td: %tx->%tx\n",
inst - start, t->from, t->to);
@@ -171,19 +175,22 @@
}
- // If there is a (0 -> anything) transition, create a new instance.
+ // Is the transition "special" (e.g. init/cleanup)?
for (uint32_t i = 0; i < trans->length; i++) {
const tesla_transition *t = trans->transitions + i;
- if (t->from != 0)
- continue;
+ if (t->from == 0) {
+ struct tesla_instance *inst;
+ CHECK(tesla_instance_new, class, key, t->to, &inst);
+ assert(tesla_instance_active(inst));
- struct tesla_instance *inst;
- CHECK(tesla_instance_new, class, key, t->to, &inst);
- assert(tesla_instance_active(inst));
+ matched_something = true;
+ VERBOSE_PRINT("new %td: %tx\n",
+ inst - start, inst->ti_state);
+ }
- matched_something = true;
- VERBOSE_PRINT("new %td: %tx\n",
- inst - start, inst->ti_state);
+ if (t->flags & TESLA_TRANS_CLEANUP) {
+ tesla_class_reset(class);
+ }
}
if (verbose_debug()) {
More information about the p4-projects
mailing list