From aba90a3a6f6c1caee28aaf3dadebb4daba5b5761 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 9 Aug 2025 16:06:32 +0300 Subject: use newer conts --- src/bus/simple_bus.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/bus') diff --git a/src/bus/simple_bus.c b/src/bus/simple_bus.c index 1932419..e1e9a88 100644 --- a/src/bus/simple_bus.c +++ b/src/bus/simple_bus.c @@ -3,7 +3,6 @@ #include #include -#include struct bus_region { uint64_t addr; @@ -11,9 +10,13 @@ struct bus_region { struct component *component; }; +#define VEC_NAME regions +#define VEC_TYPE struct bus_region +#include + struct simple_bus { struct component component; - struct vec regions; + struct regions regions; struct component *send; struct packet pkt; @@ -22,8 +25,7 @@ struct simple_bus { static struct bus_region *find_bus_region(struct simple_bus *bus, uint64_t addr) { - foreach_vec(i, bus->regions) { - struct bus_region *r = vec_at(&bus->regions, i); + foreach(regions, r, &bus->regions) { if (addr >= r->addr && addr < (r->addr + r->size)) return r; } @@ -70,7 +72,7 @@ static stat simple_bus_receive(struct simple_bus *bus, struct component *from, s static void simple_bus_destroy(struct simple_bus *bus) { - vec_destroy(&bus->regions); + regions_destroy(&bus->regions); free(bus); } @@ -84,7 +86,7 @@ struct component *create_simple_bus() bus->component.clock = (clock_callback)simple_bus_clock; bus->component.destroy = (destroy_callback)simple_bus_destroy; - bus->regions = vec_create(sizeof(struct bus_region)); + bus->regions = regions_create(0); return (struct component *)bus; } @@ -112,6 +114,6 @@ stat simple_bus_add(struct component *bus, struct component *component, .size = size }; - vect_append(struct bus_region, b->regions, &new); + regions_append(&b->regions, new); return OK; } -- cgit v1.3