blob: e164c589434baa7fac6b9e4af3bf9b3ec520c3bf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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 */
|