summaryrefslogtreecommitdiffstats
path: root/pipeline.h
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-11-07 23:28:54 -0600
committerLibravatar bigfoot547 <[email protected]>2025-11-07 23:28:54 -0600
commit28ba35171bca7d911bcd74724bf4dfdca46b4590 (patch)
treecd90e78aa7f947bbf2ce51f5ea91b7c1b353d642 /pipeline.h
initial commit
Diffstat (limited to 'pipeline.h')
-rw-r--r--pipeline.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/pipeline.h b/pipeline.h
new file mode 100644
index 0000000..e164c58
--- /dev/null
+++ b/pipeline.h
@@ -0,0 +1,41 @@
+#ifndef PTXMC_PIPELINE_H_INCLUDED
+#define PTXMC_PIPELINE_H_INCLUDED
+
+#include <assert.h>
+#include <stddef.h>
+#include "config.h"
+
+#define PIPELINE_STAGE ATTR_WUR
+
+struct pipeline_ctx_t;
+typedef int (pipeline_stage_proc)(struct pipeline_ctx_t * /*ctx*/, void * /*data*/, size_t /*len*/) PIPELINE_STAGE;
+
+struct pipeline_stage_t
+{
+ const char *name;
+ pipeline_stage_proc *proc;
+ struct pipeline_stage_t *next;
+ void *user;
+};
+
+struct pipeline_t
+{
+ struct pipeline_stage_t *first;
+};
+
+struct pipeline_ctx_t
+{
+ struct pipeline_stage_t *stage;
+};
+
+int pipeline_add_stage_before(struct pipeline_t *pl, struct pipeline_stage_t *stage, const char *name);
+int pipeline_add_stage_after(struct pipeline_t *pl, struct pipeline_stage_t *stage, const char *name);
+
+ATTR_ALWAYS_INLINE inline int pipeline_next(struct pipeline_ctx_t *ctx, void *data, size_t len)
+{
+ assert(ctx->stage->next);
+ ctx->stage = ctx->stage->next;
+ return (ctx->stage->proc)(ctx, data, len);
+}
+
+#endif /* include guard */