Computer Laboratory

tesla_internal.h File Reference
#include <assert.h>
#include <err.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <libtesla.h>
#include <stdio.h>
+ Include dependency graph for tesla_internal.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tesla_class
 
struct  tesla_store
 

Macros

#define SUBSET(x, y)   ((x & y) == x)
 Is x a subset of y? More...
 
#define __unused
 
#define tesla_panic(...)   errx(1, __VA_ARGS__)
 errx() is the userspace equivalent of panic(). More...
 
#define tesla_assert(condition,...)   assert(condition)
 POSIX assert() doesn't let us provide an error message. More...
 
#define tesla_malloc(len)   calloc(1, len)
 
#define tesla_free(x)   free(x)
 
#define tesla_lock(l)   do { __debug int err = pthread_mutex_lock(l); assert(err == 0); } while(0)
 
#define tesla_unlock(l)   do { __debug int err = pthread_mutex_unlock(l); assert(err == 0); } while(0)
 
#define TESLA_MAX_CLASSES   128
 
#define TESLA_MAX_INSTANCES   128
 
#define SAFE_SPRINTF(current, end,...)
 Do a sprintf() into a buffer, checking bounds appropriately. More...
 
#define print(...)   printf(__VA_ARGS__)
 
#define error(...)   fprintf(stderr, __VA_ARGS__)
 
#define __debug
 
#define DEBUG(dclass,...)   if (tesla_debugging(#dclass)) printf(__VA_ARGS__)
 Emit debugging information with a debug name (e.g., libtesla.event). More...
 

Typedefs

typedef struct tesla_class tesla_class
 
typedef struct tesla_instance tesla_instance
 
typedef struct tesla_key tesla_key
 
typedef struct tesla_store tesla_store
 
typedef struct tesla_transition tesla_transition
 
typedef struct tesla_transitions tesla_transitions
 

Enumerations

enum  tesla_action_t {
  UPDATE, FORK, JOIN, IGNORE,
  FAIL
}
 Actions that can be taken by tesla_update_state. More...
 

Functions

void tesla_die (int32_t errno, const char *event) __attribute__((noreturn))
 Call this if things go catastrophically, unrecoverably wrong. More...
 
int32_t tesla_store_reset (struct tesla_store *store)
 Reset all automata in a store to the inactive state. More...
 
void tesla_store_free (struct tesla_store *)
 Clean up a tesla_store. More...
 
void tesla_class_reset (struct tesla_class *)
 Reset a tesla_class for re-use from a clean state. More...
 
void tesla_class_destroy (struct tesla_class *)
 Clean up a tesla_class. More...
 
int32_t tesla_instance_new (struct tesla_class *tclass, const struct tesla_key *name, uint32_t state, struct tesla_instance **out)
 Create a new tesla_instance. More...
 
int32_t tesla_instance_active (const struct tesla_instance *i)
 Checks whether or not a TESLA automata instance is active (in use). More...
 
int32_t tesla_instance_clone (struct tesla_class *tclass, const struct tesla_instance *orig, struct tesla_instance **copy)
 Clone an existing instance into a new instance. More...
 
void tesla_instance_clear (struct tesla_instance *tip)
 Zero an instance for re-use. More...
 
int32_t tesla_match (struct tesla_class *tclass, const struct tesla_key *key, struct tesla_instance **array, uint32_t *size)
 Find all automata instances in a class that match a particular key. More...
 
int32_t tesla_key_matches (const struct tesla_key *pattern, const struct tesla_key *k)
 Check to see if a key matches a pattern. More...
 
enum tesla_action_t tesla_action (const struct tesla_instance *, const struct tesla_key *, const struct tesla_transitions *, const struct tesla_transition **trigger)
 What is the correct action to perform on a given tesla_instance to satisfy a set of tesla_transitions? More...
 
int32_t tesla_key_union (struct tesla_key *dest, const struct tesla_key *source)
 Copy new entries from source into dest. More...
 
int tesla_store_init (tesla_store *, enum tesla_context context, uint32_t classes, uint32_t instances)
 Initialise tesla_store internals. More...
 
int tesla_class_init (struct tesla_class *, enum tesla_context context, uint32_t instances)
 Initialize tesla_class internals. More...
 
int32_t tesla_class_global_postinit (struct tesla_class *)
 
void tesla_class_global_acquire (struct tesla_class *)
 
void tesla_class_global_release (struct tesla_class *)
 
void tesla_class_global_destroy (struct tesla_class *)
 
int32_t tesla_class_perthread_postinit (struct tesla_class *)
 
void tesla_class_perthread_acquire (struct tesla_class *)
 
void tesla_class_perthread_release (struct tesla_class *)
 
void tesla_class_perthread_destroy (struct tesla_class *)
 
void ev_new_instance (struct tesla_class *, struct tesla_instance *)
 
void ev_transition (struct tesla_class *, struct tesla_instance *, const struct tesla_transition *)
 
void ev_clone (struct tesla_class *, struct tesla_instance *orig, struct tesla_instance *copy, const struct tesla_transition *)
 
void ev_no_instance (struct tesla_class *, const struct tesla_key *, const struct tesla_transitions *)
 
void ev_bad_transition (struct tesla_class *, struct tesla_instance *, const struct tesla_transitions *)
 
void ev_err (struct tesla_class *tcp, int errno, const char *message)
 
void ev_accept (struct tesla_class *, struct tesla_instance *)
 
void ev_ignored (const struct tesla_class *, const struct tesla_key *, const struct tesla_transitions *)
 
int32_t tesla_debugging (const char *)
 Are we in (verbose) debug mode? More...
 
void assert_instanceof (struct tesla_instance *i, struct tesla_class *tclass)
 Assert that a tesla_instance is an instance of a tesla_class. More...
 
char * key_string (char *buffer, const char *end, const struct tesla_key *)
 Print a key into a buffer. More...
 
void print_key (const char *debug_name, const struct tesla_key *key)
 Print a tesla_key to stderr. More...
 
void print_class (const struct tesla_class *)
 Print a tesla_class to stderr. More...
 
void print_transition (const char *debug, const struct tesla_transition *)
 Print a human-readable version of a tesla_transition. More...
 
char * sprint_transition (char *buffer, const char *end, const struct tesla_transition *)
 Print a human-readable version of a tesla_transition into a buffer. More...
 
void print_transitions (const char *debug, const struct tesla_transitions *)
 Print a human-readable version of tesla_transitions. More...
 
char * sprint_transitions (char *buffer, const char *end, const struct tesla_transitions *)
 Print a human-readable version of tesla_transitions into a buffer. More...