From 28ba35171bca7d911bcd74724bf4dfdca46b4590 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Fri, 7 Nov 2025 23:28:54 -0600 Subject: initial commit --- pipeline.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pipeline.h (limited to 'pipeline.h') 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 +#include +#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 */ -- cgit v1.2.3-70-g09d2