From fd421e32780cad46782c16cd4e15947f295a08c7 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Fri, 27 Mar 2020 22:47:57 +0100 Subject: Initial, untested version of controller and worker Worker has been tested to a marginal extent, but the controller is litereally untested. --- examples/kaas/Makefile | 9 +++++++++ examples/kaas/kaas.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 examples/kaas/Makefile create mode 100644 examples/kaas/kaas.c (limited to 'examples/kaas') diff --git a/examples/kaas/Makefile b/examples/kaas/Makefile new file mode 100644 index 0000000..e7d5154 --- /dev/null +++ b/examples/kaas/Makefile @@ -0,0 +1,9 @@ +.PHONY: all clean + +all: kaas.so + +clean: + rm -f kaas.so + +kaas.so: kaas.c + gcc -Wall -Wextra -fPIC -shared $< -o $@ diff --git a/examples/kaas/kaas.c b/examples/kaas/kaas.c new file mode 100644 index 0000000..f823442 --- /dev/null +++ b/examples/kaas/kaas.c @@ -0,0 +1,32 @@ +#include +#include +#include + +__attribute__((constructor)) +void constr() { + printf("kaas: constructor!\n"); +} + +__attribute__((destructor)) +void destr() { + printf("kaas: destructor!\n"); +} + +int worker_init(int version) { + printf("kaas: initialised with version %d\n", version); + return 0; +} + +int worker_run_job(size_t size, void *input_, size_t *outsize, void **outputp) { + const char *input = input_; + char *output = malloc(size); + for (size_t i = 0; i < size; i++) output[i] = toupper(input[i]); + *outsize = size; + *outputp = output; + return 0; +} + +void worker_free_outdata(size_t size, void *data) { + (void)size; + free(data); +} -- cgit v1.2.3-70-g09d2