diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-09 16:06:32 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-09 16:06:32 +0300 |
| commit | aba90a3a6f6c1caee28aaf3dadebb4daba5b5761 (patch) | |
| tree | 082fc1f5c374f4a0417f345507cee58c23d3a2ad /src/clock_domain.c | |
| parent | bc920e9de94e884597214da9c20525605cfce6d6 (diff) | |
| download | gran-aba90a3a6f6c1caee28aaf3dadebb4daba5b5761.tar.gz gran-aba90a3a6f6c1caee28aaf3dadebb4daba5b5761.zip | |
use newer conts
Diffstat (limited to 'src/clock_domain.c')
| -rw-r--r-- | src/clock_domain.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/clock_domain.c b/src/clock_domain.c index 74f0f03..c1f0450 100644 --- a/src/clock_domain.c +++ b/src/clock_domain.c @@ -12,10 +12,13 @@ #include <assert.h> #include <gran/clock_domain.h> -#include <gran/vec.h> + +#define VEC_NAME components +#define VEC_TYPE struct component * +#include <conts/vec.h> struct clock_domain { - struct vec components; + struct components components; struct clock_time time; tick period; @@ -39,23 +42,24 @@ struct clock_domain *create_clock_domain(tick period) return NULL; clk->period = period; - clk->components = vec_create(sizeof(struct component *)); + clk->components = components_create(0); return clk; } void destroy_clock_domain(struct clock_domain *clk) { - for (size_t i = 0; i < vec_len(&clk->components); ++i) - destroy(vect_at(struct component *, clk->components, i)); + foreach(components, c, &clk->components) { + destroy(*c); + } - vec_destroy(&clk->components); + components_destroy(&clk->components); free(clk); } stat clock_domain_add(struct clock_domain *clk, struct component *component) { - vect_append(struct component *, clk->components, &component); + components_append(&clk->components, component); return OK; } @@ -69,9 +73,8 @@ static void clocked_component_tick(struct clock_domain *clk, stat clock_domain_tick(struct clock_domain *clk) { - for (size_t i = 0; i < vec_len(&clk->components); ++i) { - clocked_component_tick(clk, - vect_at(struct component *, clk->components, i)); + foreach(components, c, &clk->components) { + clocked_component_tick(clk, *c); } advance_clock(clk); |
