#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 */