aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gran/component.h1
-rw-r--r--include/gran/grid/node3d.h38
-rw-r--r--include/gran/packet.h7
3 files changed, 40 insertions, 6 deletions
diff --git a/include/gran/component.h b/include/gran/component.h
index 289d0a6..4b728a4 100644
--- a/include/gran/component.h
+++ b/include/gran/component.h
@@ -36,6 +36,7 @@ struct component {
static inline stat send(struct component *from, struct component *to, struct packet pkt)
{
+ assert(to && from);
if (!to->receive) {
/* printf formatted asserts would maybe be preferable? */
error(
diff --git a/include/gran/grid/node3d.h b/include/gran/grid/node3d.h
new file mode 100644
index 0000000..e424d9b
--- /dev/null
+++ b/include/gran/grid/node3d.h
@@ -0,0 +1,38 @@
+#ifndef GRAN_GRID_NODE3D_H
+#define GRAN_GRID_NODE3D_H
+
+/** @todo rename to mesh to follow conventions a bit better */
+
+#include <gran/component.h>
+#include <stdint.h>
+
+struct component *create_grid_node3d(uint8_t x, uint8_t y, uint8_t z);
+
+stat grid_node3d_connect(struct component *node,
+ struct component *n,
+ struct component *s,
+ struct component *w,
+ struct component *e,
+ struct component *u,
+ struct component *d,
+ struct component *l);
+
+static inline uint64_t grid3d_addr(uint8_t x, uint8_t y, uint8_t z, uint32_t off)
+{
+ return off
+ | ((uint64_t)x << 32)
+ | ((uint64_t)y << 40)
+ | ((uint64_t)z << 48)
+ ;
+}
+
+static inline void addr_grid3d(uint64_t addr, uint8_t *x, uint8_t *y, uint8_t *z, uint32_t *off)
+{
+ if (off) *off = addr & 0xffffffff;
+ if (x) *x = (addr >> 32) & 0xff;
+ if (y) *y = (addr >> 40) & 0xff;
+ if (z) *z = (addr >> 48) & 0xff;
+ assert(((addr >> 56) & 0xff) == 0);
+}
+
+#endif /* GRAN_GRID_NODE3D_H */
diff --git a/include/gran/packet.h b/include/gran/packet.h
index 2fec036..85ff961 100644
--- a/include/gran/packet.h
+++ b/include/gran/packet.h
@@ -179,20 +179,15 @@ static inline uint64_t packet_convu64(struct packet *pkt)
return res;
}
-/* not good, should be taken from the local clock domain or something
- * but eh for now */
-extern uint64_t ticker;
-
static inline struct packet create_packet(uint64_t from, uint64_t to, uint64_t size, void *data, enum packet_flags flags)
{
assert(size <= 64);
assert(packet_align(from) == from);
-
uint64_t aligned = packet_align(to);
uint64_t mask = packet_mask(to, size);
struct packet pkt = (struct packet){
- .timestamp = ticker++,
+ .timestamp = 0,
.from = from,
.to = aligned,
.mask = mask,