diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-21 03:45:48 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-21 03:45:48 -0400 |
commit | 8837ed6d19b3921c41a20413b20f4e52fdf7b183 (patch) | |
tree | a8c86f8ce0613a4aae8ea338711e238231c716f9 /usr.bin/oasm/emit.c | |
parent | 15fa59f6ffa55a0ec8f8f6b8fb3ba46c67fb3030 (diff) |
oasm: emit: Don't use TAILQ_FOREACH for processing
In order to have more control over the flow at which we grab the next
tokens, we should roll our own loop by hand using TAILQ_FIRST() and
TAILQ_NEXT()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/emit.c')
-rw-r--r-- | usr.bin/oasm/emit.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/oasm/emit.c b/usr.bin/oasm/emit.c index 0275d05..e3ee366 100644 --- a/usr.bin/oasm/emit.c +++ b/usr.bin/oasm/emit.c @@ -190,16 +190,17 @@ emit_process(struct oasm_state *oasm, struct emit_state *emit) } emit->out_fd = oasm->out_fd; - TAILQ_FOREACH(curtok, &emit->ir, link) { + curtok = TAILQ_FIRST(&emit->ir); + while (curtok != NULL) { switch (curtok->type) { case TT_MOV: curtok = emit_encode_mov(emit, curtok); break; - } - - if (curtok == NULL) { + default: + curtok = TAILQ_NEXT(curtok, link); break; } + } return 0; |