dol: initial dol commit
[jump.git] / dol / examples / examplewindowedfifo / src / square.c
1 #include <stdio.h>
2
3 #include "square.h"
4
5 void square_init(DOLProcess *p) {
6     p->local->index = 0;
7     p->local->len = LENGTH;
8 }
9
10 int square_fire(DOLProcess *p) {
11     float *i, *j;
12
13     if (p->local->index < p->local->len) {
14         DOL_capture((void*)PORT_IN, &i, sizeof(float), p);
15         DOL_reserve((void*)PORT_OUT, &j, sizeof(float), p);
16         *j = *i * *i;
17         DOL_consume((void*)PORT_IN, p);
18         DOL_release((void*)PORT_OUT, p);
19         p->local->index++;
20     }
21
22     if (p->local->index >= p->local->len) {
23         DOL_detach(p);
24         return -1;
25     }
26
27     return 0;
28 }
29