aboutgitcodelistschat:MatrixIRC
path: root/cooker/emit.c
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-06-07 16:54:53 +0200
committerAlice Frosi <afrosi@redhat.com>2023-06-07 16:57:23 +0200
commit1c1a9da7a4f9c4c1990192e14763ebf423d812a9 (patch)
treee7fea8962d166cd3d1cf70c84c9098cf6f8b3987 /cooker/emit.c
parentb2e31a6e7493c56f923cb7d86f7a8a32940393ec (diff)
downloadseitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.tar
seitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.tar.gz
seitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.tar.bz2
seitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.tar.lz
seitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.tar.xz
seitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.tar.zst
seitan-1c1a9da7a4f9c4c1990192e14763ebf423d812a9.zip
seitan, cooker: refactor op_return
Refactor OP_RETURN: - merged OP_BLOCK and OP_CONT into OP_RETURN - add desc field for op_return - updated the demo files
Diffstat (limited to 'cooker/emit.c')
-rw-r--r--cooker/emit.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/cooker/emit.c b/cooker/emit.c
index 7b1b14d..506a561 100644
--- a/cooker/emit.c
+++ b/cooker/emit.c
@@ -304,36 +304,32 @@ void emit_cmp_field(struct gluten_ctx *g, enum op_cmp_type cmp,
/**
* emit_return() - Emit OP_RETURN instruction: return value
* @g: gluten context
- * @v: Pointer to return value
+ * @v: offset of the return value
+ * @error: error value
+ * @cont if the filtered syscall needs to be executed
*/
-void emit_return(struct gluten_ctx *g, struct gluten_offset v)
+void emit_return(struct gluten_ctx *g, struct gluten_offset v, int32_t error,
+ bool cont)
{
struct op *op = (struct op *)gluten_ptr(&g->g, g->ip);
struct op_return *ret = &op->op.ret;
+ struct gluten_offset o;
+ struct return_desc *desc;
op->type = OP_RETURN;
- ret->val = v;
-
- debug(" %i: OP_RETURN:", g->ip.offset);
- if (++g->ip.offset > INST_MAX)
- die("Too many instructions");
-}
+ o = gluten_ro_alloc(g, sizeof(struct return_desc));
+ desc = (struct return_desc *)gluten_ptr(&g->g, o);
-/**
- * emit_block() - Emit OP_BLOCK instruction: return error value
- * @g: gluten context
- * @error: Error value
- */
-void emit_block(struct gluten_ctx *g, int32_t error)
-{
- struct op *op = (struct op *)gluten_ptr(&g->g, g->ip);
- struct op_block *block = &op->op.block;
+ desc->val = v;
+ desc->error = error;
+ desc->cont = cont;
- op->type = OP_BLOCK;
- block->error = error;
+ ret->desc = o;
- debug(" %i: OP_BLOCK: %d", g->ip.offset, error);
+ debug(" %i: OP_RETURN:", g->ip.offset);
+ debug(" \t val=(%s %d) errno=%d cont=%s", gluten_offset_name[v.type],
+ v.offset, error, cont ? "true" : "false");
if (++g->ip.offset > INST_MAX)
die("Too many instructions");