aboutsummaryrefslogtreecommitdiff
path: root/rt
diff options
context:
space:
mode:
Diffstat (limited to 'rt')
-rw-r--r--rt/include/foreign_intf.h33
-rw-r--r--rt/include/plugin.h13
-rw-r--r--rt/src/plugin.c32
3 files changed, 17 insertions, 61 deletions
diff --git a/rt/include/foreign_intf.h b/rt/include/foreign_intf.h
deleted file mode 100644
index 6558fab..0000000
--- a/rt/include/foreign_intf.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Contains a structure, which contains functions to back-call into
- * the harness code. */
-
-#ifndef __FOREIGN_INTERFACE
-#define __FOREIGN_INTERFACE
-
-#define EXPORT(a) a
-
-typedef void *ctx_t;
-
-typedef struct FOREIGN_INTERFACE {
- /* DO NOT ADD ANY UNEXPORTED VARIABLES HERE */
-
- /* The context, which needs to be passed to each function. This context is
- * opaque to the plugin and should not be changed. */
- EXPORT(ctx_t ctx);
-
- /* Requests the harness hot reload the current plugin. */
- EXPORT(void (*request_hot_reload)(ctx_t ctx));
-
- /* Requests the harness hot reload the current plugin. */
- EXPORT(void (*do_log)(ctx_t ctx, const char *str));
-
- /* Requestes that the whole system exit. Exits with the given return code. */
- EXPORT(void (*request_exit)(ctx_t ctx, int rc));
-
- /* Returns the seat associated with the server. */
- EXPORT(void *(*get_seat)(ctx_t ctx));
-} foreign_interface_t;
-
-#undef EXPORT
-
-#endif /* __FOREIGN_INTERFACE */
diff --git a/rt/include/plugin.h b/rt/include/plugin.h
index 4d69d76..16823e8 100644
--- a/rt/include/plugin.h
+++ b/rt/include/plugin.h
@@ -5,13 +5,11 @@
#include <linux/limits.h>
#include <pthread.h>
#include <stdint.h>
-#include <stdlib.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_pointer.h>
#include "plugin_types.h"
-#include <foreign_intf.h>
/*
* Marker macro to define what functions should be exported. This generates the
@@ -22,7 +20,6 @@
#define EXPORT_INCLUDE(a)
// clang-format off
-EXPORT_INCLUDE(<foreign_intf.h>)
EXPORT_INCLUDE(<wlr/types/wlr_keyboard.h>)
EXPORT_INCLUDE(<wlr/types/wlr_input_device.h>)
EXPORT_INCLUDE(<wlr/types/wlr_pointer.h>)
@@ -61,9 +58,6 @@ typedef struct PLUGIN {
/* Filename the plugin is loaded from. */
char filename[PATH_MAX];
- /* Interface to the harness that this plugin can use. */
- foreign_interface_t foreign_intf;
-
/* Opaque state of this plugin. The state is usually some kind of pointer to
* the plugin state, but all the harness knows is the opaque state is a
* pointer-sized piece of data.
@@ -104,7 +98,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));
/* Start the plugin with the marshalled state from the previous plugin.
*
@@ -115,13 +109,14 @@ typedef struct PLUGIN {
* hot-reloading can produce incompatibilities between the old state and the
* new state, and this should not cause a failure.
*/
- EXPORT(opqst_t (*plugin_hot_start)(uint8_t *mashalled_state, uint32_t n));
+ EXPORT(opqst_t (*plugin_hot_start)(void *self, uint8_t *mashalled_state,
+ uint32_t n));
/*
* Starts the plugin without a marshalled state. Happens during the first boot
* when there is not state.
*/
- EXPORT(opqst_t (*plugin_cold_start)());
+ EXPORT(opqst_t (*plugin_cold_start)(void* self));
/*
* Marshals the state to a bytestring. The returned pointer should be malloc'd
diff --git a/rt/src/plugin.c b/rt/src/plugin.c
index 0799b9c..3edf486 100644
--- a/rt/src/plugin.c
+++ b/rt/src/plugin.c
@@ -1,15 +1,14 @@
#include "plugin.h"
-#include "foreign_intf.h"
#include "wl.h"
-#include <sys/stat.h>
-#include <unistd.h>
#include <ctype.h>
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
/* Utility function for showing the marshalled states as hex code */
static void shx(uint8_t *state, uint32_t sz)
@@ -59,7 +58,7 @@ static int plugin_hot_reload_same_state_action_(plugin_t *plugin, void *ignore)
return plugin_hot_reload_same_state(plugin);
}
-void do_request_hot_reload(void *plugv)
+void montis_do_request_hot_reload(void *plugv)
{
plugin_t *plugin = plugv;
@@ -77,7 +76,7 @@ static int plugin_do_log(plugin_t *plugin, void *chrs)
return 0;
}
-void do_request_log(void *plugv, const char *str)
+void montis_do_request_log(void *plugv, const char *str)
{
plugin_t *plugin = plugv;
@@ -89,27 +88,28 @@ void do_request_log(void *plugv, const char *str)
}
}
-static int plugin_do_exit(void *plugv, int ec)
+static int montis_plugin_do_exit(void *plugv, int ec)
{
exit(ec);
return 0;
}
-void do_request_exit(void *plugv, int ec)
+void montis_do_request_exit(void *plugv, int ec)
{
plugin_t *plugin = plugv;
size_t n = plugin->n_requested_actions++;
if (n < 8) {
plugin->requested_actions[n].action =
- (int (*)(plugin_t *, void *))plugin_do_exit;
+ (int (*)(plugin_t *, void *))montis_plugin_do_exit;
plugin->requested_actions[n].int_arg = ec;
plugin->requested_actions[n].arg_dtor = NULL;
}
}
-static void* plugin_get_seat(void* ctx) {
- struct montis_server* server = wl_container_of(ctx, server, plugin);
+void *montis_plugin_get_seat(void *ctx)
+{
+ struct montis_server *server = wl_container_of(ctx, server, plugin);
return server->seat;
}
@@ -136,13 +136,7 @@ static int load_plugin_from_file_(int argc, char **argv, const char *filename,
plugin->argc = argc;
plugin->argv = argv;
- plugin->foreign_intf.ctx = plugin;
- plugin->foreign_intf.request_hot_reload = do_request_hot_reload;
- plugin->foreign_intf.do_log = do_request_log;
- plugin->foreign_intf.request_exit = do_request_exit;
- plugin->foreign_intf.get_seat = plugin_get_seat;
-
- plugin->plugin_load(plugin->argc, plugin->argv, &plugin->foreign_intf);
+ plugin->plugin_load(plugin->argc, plugin->argv);
end:
return ec;
}
@@ -231,7 +225,7 @@ int plugin_hot_reload(int argc, char **argv, const char *filepath,
}
printf("Hot starting plugin ...\n");
- plugin->state = plugin->plugin_hot_start(marshalled_state, sz);
+ plugin->state = plugin->plugin_hot_start(plugin, marshalled_state, sz);
fail:
free(marshalled_state);
@@ -261,6 +255,6 @@ void plugin_run_requested_actions(plugin_t *plugin)
void plugin_cold_start(plugin_t *plugin)
{
lock(plugin);
- plugin->state = plugin->plugin_cold_start();
+ plugin->state = plugin->plugin_cold_start(plugin);
unlock(plugin);
}