diff --git a/src/emu/bay.h b/src/emu/bay.h index 9f9770a..414815e 100644 --- a/src/emu/bay.h +++ b/src/emu/bay.h @@ -58,11 +58,12 @@ struct bay { struct bay_chan *dirty; }; -void bay_init(struct bay *bay); -int bay_register(struct bay *bay, struct chan *chan); -int bay_remove(struct bay *bay, struct chan *chan); -struct chan *bay_find(struct bay *bay, const char *name); -int bay_add_cb(struct bay *bay, enum bay_cb_type type, struct chan *chan, bay_cb_func_t func, void *arg); -int bay_propagate(struct bay *bay); + void bay_init(struct bay *bay); +USE_RET int bay_register(struct bay *bay, struct chan *chan); +USE_RET int bay_remove(struct bay *bay, struct chan *chan); +USE_RET struct chan *bay_find(struct bay *bay, const char *name); +USE_RET int bay_add_cb(struct bay *bay, enum bay_cb_type type, + struct chan *chan, bay_cb_func_t func, void *arg); +USE_RET int bay_propagate(struct bay *bay); #endif /* BAY_H */ diff --git a/src/emu/chan.h b/src/emu/chan.h index 2c84bbd..02705c9 100644 --- a/src/emu/chan.h +++ b/src/emu/chan.h @@ -19,6 +19,7 @@ enum chan_type { enum chan_prop { CHAN_DIRTY_WRITE = 0, CHAN_DUPLICATES, + CHAN_ROW, CHAN_MAXPROP, }; @@ -47,22 +48,15 @@ struct chan { void *dirty_arg; }; -//int chan_enable(struct chan *chan); -//int chan_disable(struct chan *chan); -//int chan_is_enabled(const struct chan *chan); - -void chan_init(struct chan *chan, enum chan_type type, const char *name); -int chan_set(struct chan *chan, struct value value); -int chan_push(struct chan *chan, struct value value); -int chan_pop(struct chan *chan, struct value expected); -int chan_read(struct chan *chan, struct value *value); -enum chan_type chan_get_type(struct chan *chan); -int chan_flush(struct chan *chan); - -void chan_prop_set(struct chan *chan, enum chan_prop prop, int value); -int chan_prop_get(struct chan *chan, enum chan_prop prop); - -/* Called when it becomes dirty */ -void chan_set_dirty_cb(struct chan *chan, chan_cb_t func, void *arg); + void chan_init(struct chan *chan, enum chan_type type, const char *name); +USE_RET int chan_set(struct chan *chan, struct value value); +USE_RET int chan_push(struct chan *chan, struct value value); +USE_RET int chan_pop(struct chan *chan, struct value expected); +USE_RET int chan_read(struct chan *chan, struct value *value); +USE_RET enum chan_type chan_get_type(struct chan *chan); +USE_RET int chan_flush(struct chan *chan); + void chan_prop_set(struct chan *chan, enum chan_prop prop, int value); +USE_RET int chan_prop_get(struct chan *chan, enum chan_prop prop); + void chan_set_dirty_cb(struct chan *chan, chan_cb_t func, void *arg); #endif /* CHAN_H */ diff --git a/src/emu/mux.h b/src/emu/mux.h index f85597b..42e3596 100644 --- a/src/emu/mux.h +++ b/src/emu/mux.h @@ -30,20 +30,20 @@ void mux_input_init(struct mux_input *mux, struct value key, struct chan *chan); -int mux_init(struct mux *mux, +USE_RET int mux_init(struct mux *mux, struct bay *bay, struct chan *select, struct chan *output, mux_select_func_t select_func); -struct mux_input *mux_find_input(struct mux *mux, +USE_RET struct mux_input *mux_find_input(struct mux *mux, struct value key); -int mux_add_input(struct mux *mux, +USE_RET int mux_add_input(struct mux *mux, struct value key, struct chan *input); -int mux_register(struct mux *mux, +USE_RET int mux_register(struct mux *mux, struct bay *bay); #endif /* MUX_H */ diff --git a/test/unit/mux.c b/test/unit/mux.c index 504e09c..88c4e52 100644 --- a/test/unit/mux.c +++ b/test/unit/mux.c @@ -242,8 +242,10 @@ main(void) if (mux_init(&mux, &bay, &select, &output, NULL) != 0) die("mux_init failed\n"); - for (int i = 0; i < N; i++) - mux_add_input(&mux, value_int64(i), &inputs[i]); + for (int i = 0; i < N; i++) { + if (mux_add_input(&mux, value_int64(i), &inputs[i]) != 0) + die("mux_add_input failed\n"); + } /* Write something to the input channels */ for (int i = 0; i < N; i++) {