aboutsummaryrefslogtreecommitdiff
path: root/harness/include/plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'harness/include/plugin.h')
-rw-r--r--harness/include/plugin.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/harness/include/plugin.h b/harness/include/plugin.h
index db56845..1e4a161 100644
--- a/harness/include/plugin.h
+++ b/harness/include/plugin.h
@@ -7,7 +7,7 @@
#include <stdint.h>
#include <stdlib.h>
-#include "foreign_intf.h"
+#include <foreign_intf.h>
/*
* Marker macro to define what functions should be exported. This generates the
@@ -15,6 +15,12 @@
*/
#define EXPORT(a) a
+#define EXPORT_INCLUDE(a)
+
+EXPORT_INCLUDE(<foreign_intf.h>)
+
+#define MAX_QUEUED_ACTIONS 8
+
typedef void *dlhandle_t;
/* Opaque state for a plugin. Not to be touched by the harness (not that it
@@ -25,7 +31,9 @@ struct PLUGIN;
/* This structure represents an action requested by the plugin for the harness.
*/
typedef struct {
- int (*action)(struct PLUGIN *requester);
+ int (*action)(struct PLUGIN *requester, void* arg);
+ void (*arg_dtor)(void* arg);
+ void* arg;
} requested_action_t;
/*
@@ -62,6 +70,9 @@ typedef struct PLUGIN {
* outcomes. */
pthread_mutex_t lock;
+ /** Set to not-zero if this plugin is initialized, otherwise set to zero. */
+ int initialized;
+
/* The handle to the shared library. */
dlhandle_t library_handle;
@@ -73,7 +84,7 @@ typedef struct PLUGIN {
/** Intializes the plugin with the given argc/argv. This is the first thing
* called on the plugin and is called immediately after the library is loaded.
*/
- EXPORT(void (*plugin_load)(int argc, char **argv, foreign_interface_t *intf));
+ EXPORT(void (*plugin_load)(int argc, char** argv, foreign_interface_t *intf));
/* Start the plugin with the marshalled state from the previous plugin.
*
@@ -122,10 +133,11 @@ typedef struct PLUGIN {
* allowed at one time. That should be plenty. The actions should be flushed
* after each call to a handler anyway. */
size_t n_requested_actions;
- requested_action_t requested_actions[8];
+ requested_action_t requested_actions[MAX_QUEUED_ACTIONS];
} plugin_t;
#undef EXPORT
+#undef EXPORT_INCLUDE
/* Reloads the plugin. This tears down the existing plugin, marshals the state
* for it and reloads it.
@@ -141,6 +153,9 @@ int plugin_hot_reload(int argc, char **argv, const char *filepath,
*/
int plugin_hot_reload_same_state(plugin_t *plugin);
+/* Starts a plugin in a cold state. Called after load_plugin_from_file. */
+void plugin_cold_start(plugin_t* plugin);
+
/* Reads a plugin from a filename. */
int load_plugin_from_file(int argc, char **argv, const char *filename,
plugin_t *plugin);