PERFORCE change 230769 for review

Jonathan Anderson jonathan at FreeBSD.org
Sun Jul 7 01:41:01 UTC 2013


http://p4web.freebsd.org/@@230769?ac=10

Change 230769 by jonathan at jonathan-on-joe on 2013/07/07 01:40:34

	Update libtesla to latest GitHub version.

Affected files ...

.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/libtesla.h#10 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla-macros.h#6 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla.h#3 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_class.c#6 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_internal.h#8 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#13 edit
.. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#9 edit

Differences ...

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/libtesla.h#10 (text+ko) ====

@@ -278,8 +278,9 @@
 
 #ifdef _KERNEL
 #define	TESLA_KERN_PRINTF_EV	0x1
-#define	TESLA_KERN_DTRACE_EV	0x2
-#define	TESLA_KERN_PANIC_EV	0x4
+#define	TESLA_KERN_PRINTERR_EV	0x2
+#define	TESLA_KERN_DTRACE_EV	0x4
+#define	TESLA_KERN_PANIC_EV	0x8
 #endif
 
 /** @} */

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla-macros.h#6 (text+ko) ====

@@ -78,6 +78,9 @@
 #define	strict(...)		__tesla_strict(TIGNORE, __VA_ARGS__)
 #define	conditional(...)	__tesla_conditional(TIGNORE, __VA_ARGS__)
 
+#define	flags(...)		__tesla_flags(__VA_ARGS__)
+#define	bitmask(...)		__tesla_mask(__VA_ARGS__)
+
 #define	TESLA_NOW __tesla_now
 
 

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/tesla.h#3 (text+ko) ====

@@ -99,6 +99,12 @@
 /** Function events inside this predicate refer to the caller context. */
 struct __tesla_event* __tesla_caller(__tesla_event*, ...);
 
+/** A mask of flags we expect to see. */
+int __tesla_flags(int);
+
+/** A bitmask that an argument must not exceed. */
+int __tesla_mask(int);
+
 /**
  * Events named in this predicate should only occur exactly as described.
  *

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_class.c#6 (text+ko) ====

@@ -170,6 +170,14 @@
 }
 
 void
+tesla_instance_clear(struct tesla_instance *tip)
+{
+
+	bzero(tip, sizeof(*tip));
+	assert(!tesla_instance_active(tip));
+}
+
+void
 tesla_class_put(struct tesla_class *tsp)
 {
 	switch (tsp->tc_context) {

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_internal.h#8 (text+ko) ====

@@ -120,13 +120,8 @@
 int32_t	tesla_instance_clone(struct tesla_class *tclass,
 	    const struct tesla_instance *orig, struct tesla_instance **copy);
 
-/**
- * This interface releases an instance for reuse; some types of automata will
- * prefer tesla_class_reset(), which clears all instances associated with a
- * particular tesla_class.
- */
-void	tesla_instance_destroy(struct tesla_class *tsp,
-	    struct tesla_instance *tip);
+/** Zero an instance for re-use. */
+void	tesla_instance_clear(struct tesla_instance *tip);
 
 
 /**
@@ -161,6 +156,9 @@
 	/** The instance should be copied to a new instance. */
 	FORK,
 
+	/** The instance should be merged into another instance. */
+	JOIN,
+
 	/** The instance is irrelevant to the given transitions. */
 	IGNORE,
 

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_notification.c#13 (text+ko) ====

@@ -192,7 +192,7 @@
 print_new_instance(struct tesla_class *tcp, struct tesla_instance *tip)
 {
 
-	DEBUG(libtesla.instance.new, "new    %td: %tx\n",
+	DEBUG(libtesla.instance.new, "new    %td: %d\n",
 		tip - tcp->tc_instances, tip->ti_state);
 }
 
@@ -201,7 +201,7 @@
     struct tesla_instance *tip, const struct tesla_transition *transp)
 {
 
-	DEBUG(libtesla.state.transition, "update %td: %tx->%tx\n",
+	DEBUG(libtesla.state.transition, "update %td: %d->%d\n",
 		tip - tcp->tc_instances, transp->from, transp->to);
 }
 
@@ -211,7 +211,7 @@
     const struct tesla_transition *transp)
 {
 
-	DEBUG(libtesla.instance.clone, "clone  %td:%tx -> %td:%tx\n",
+	DEBUG(libtesla.instance.clone, "clone  %td:%d -> %td:%d\n",
 		old_instance - tcp->tc_instances, transp->from,
 		new_instance - tcp->tc_instances, transp->to);
 }
@@ -308,6 +308,16 @@
 	.teh_ignored		= print_ignored,
 };
 
+static const struct tesla_event_handlers printf_on_failure = {
+	.teh_init		= ev_noop,
+	.teh_transition		= ev_noop,
+	.teh_clone		= ev_noop,
+	.teh_fail_no_instance	= print_no_instance,
+	.teh_bad_transition	= print_bad_transition,
+	.teh_err		= print_error,
+	.teh_accept		= ev_noop,
+	.teh_ignored		= ev_noop,
+};
 
 /*
  * Wrappers that panic on failure:
@@ -330,21 +340,12 @@
 	tesla_panic("TESLA: failure in '%s': bad transition", tcp->tc_name);
 }
 
-static void
-panic_err(struct tesla_class *tcp, int errno, const char *message)
-{
-
-	tesla_panic("TESLA: error in '%s': %s (%d)", tcp->tc_name, message,
-	    errno);
-}
-
 static const struct tesla_event_handlers failstop_handlers = {
 	.teh_init		= ev_noop,
 	.teh_transition		= ev_noop,
 	.teh_clone		= ev_noop,
 	.teh_fail_no_instance	= panic_no_instance,
 	.teh_bad_transition	= panic_bad_transition,
-	.teh_err		= panic_err,
 	.teh_accept		= ev_noop,
 	.teh_ignored		= ev_noop,
 };
@@ -356,6 +357,7 @@
  */
 const static struct tesla_event_handlers* const default_handlers[] = {
 	&printf_handlers,
+	&printf_on_failure,
 #if defined(_KERNEL) && defined(KDTRACE_HOOKS)
 	&dtrace_handlers,
 #endif
@@ -365,9 +367,9 @@
 static struct tesla_event_metahandler default_event_handlers = {
 	.tem_length = sizeof(default_handlers) / sizeof(*default_handlers),
 #if defined(_KERNEL) && defined(KDTRACE_HOOKS)
-	.tem_mask = 0x2,
+	.tem_mask = TESLA_KERN_DTRACE_EV,
 #else
-	.tem_mask = 0x3,
+	.tem_mask = 0x5,
 #endif
 	.tem_handlers = default_handlers,
 };

==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#9 (text+ko) ====

@@ -138,6 +138,23 @@
 			matched_something = true;
 			break;
 		}
+
+		case JOIN:
+#ifndef	NDEBUG
+			{
+			int target = -1;
+			for (int j = 0; j < class->tc_limit; j++) {
+				tesla_instance *t = class->tc_instances + j;
+				if (t->ti_state == trigger->to) {
+					target = j;
+					break;
+				}
+			}
+			assert(target >= 0);
+			}
+#endif
+			tesla_instance_clear(inst);
+			break;
 		}
 
 		if (trigger && (trigger->flags & TESLA_TRANS_CLEANUP))
@@ -230,7 +247,6 @@
 
 		if (t->from == inst->ti_state) {
 			assert(inst->ti_key.tk_mask == t->from_mask);
-			assert(SUBSET(t->from_mask, t->to_mask));
 
 			/*
 			 * We need to match events against a pattern based on
@@ -246,10 +262,20 @@
 			pattern.tk_mask &= t->from_mask;
 
 			/*
+			 * Losing information implies a join
+			 * (except during automaton instance cleanup).
+			 */
+			if (!SUBSET(t->from_mask, t->to_mask)
+			    && ((t->flags & TESLA_TRANS_CLEANUP) == 0)) {
+				*trigger = t;
+				return JOIN;
+			}
+
+			/*
 			 * Does the transition cause key data to be added
 			 * to the instance's name?
 			 */
-			if (t->from_mask == t->to_mask) {
+			if (SUBSET(t->to_mask, t->from_mask)) {
 				/*
 				 * No: just just update the instance
 				 *     if its (masked) name matches.


More information about the p4-projects mailing list