Ensure mux channels are registered in the bay
This commit is contained in:
parent
f40a0a8d12
commit
97b96801d1
@ -142,6 +142,18 @@ mux_init(struct mux *mux,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Ensure both channels are registered */
|
||||
if (bay_find(bay, select->name) == NULL) {
|
||||
err("mux_init: select channel %s not registered in bay\n",
|
||||
select->name);
|
||||
return -1;
|
||||
}
|
||||
if (bay_find(bay, output->name) == NULL) {
|
||||
err("mux_init: output channel %s not registered in bay\n",
|
||||
output->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The output channel must accept multiple writes in the same
|
||||
* propagation phase while the channel is dirty, as we may write to the
|
||||
* input and select channel at the same time. */
|
||||
|
@ -223,14 +223,24 @@ main(void)
|
||||
}
|
||||
|
||||
/* Register all channels in the bay */
|
||||
bay_register(&bay, &output);
|
||||
bay_register(&bay, &select);
|
||||
if (bay_register(&bay, &select) != 0)
|
||||
die("bay_register failed\n");
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
bay_register(&bay, &inputs[i]);
|
||||
if(bay_register(&bay, &inputs[i]) != 0)
|
||||
die("bay_register failed\n");
|
||||
}
|
||||
|
||||
struct mux mux;
|
||||
mux_init(&mux, &bay, &select, &output, NULL);
|
||||
/* Attempt to init the mux without registering the output */
|
||||
if (mux_init(&mux, &bay, &select, &output, NULL) == 0)
|
||||
die("mux_init didn't fail\n");
|
||||
|
||||
if (bay_register(&bay, &output) != 0)
|
||||
die("bay_register failed\n");
|
||||
|
||||
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]);
|
||||
|
Loading…
Reference in New Issue
Block a user