blob: 0d4337a81fef94cada44c15c9171610a565773bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include <string.h>
#include "gate.h"
#include "error.h"
#define GATE_MAX 1024
static size_t gate_count;
static struct gate gates[GATE_MAX];
int
gate_count_guard(void) {
if (gate_count >= GATE_MAX) {
emit_error("Internal: too many gates\n");
}
return 1;
}
int
gate_add(struct gate *in1, struct gate *in2) {
struct gate g = {0};
if (gate_count_guard()) {
return 1;
}
g.in1 = in1;
g.in2 = in2;
gates[gate_count++] = g;
return 0;
}
int
tick(void) {
/* FIXME */
return 1;
}
void
gate_init(void) {
gate_count = 0;
memset(gates, 0, sizeof(gates));
}
|