aboutsummaryrefslogtreecommitdiff
path: root/src/packet.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-09-24 16:51:51 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-09-24 18:47:13 +0300
commitfecb86f6093c1e8aed6ab05c29c5af9d0cb93157 (patch)
tree10171c839d77167fc98fbae0b315d2c87aa13fa5 /src/packet.c
parentb1d67364b4b4832b8efed112f7b0ead1a0b3cd3b (diff)
downloadgran-fecb86f6093c1e8aed6ab05c29c5af9d0cb93157.tar.gz
gran-fecb86f6093c1e8aed6ab05c29c5af9d0cb93157.zip
initial work towards message passing interface
+ As they are currently implemented, grid *may* get stuck if two nodes try to send to eachother at the same time, I should probably add in some kind of input buffer as well
Diffstat (limited to 'src/packet.c')
-rw-r--r--src/packet.c92
1 files changed, 0 insertions, 92 deletions
diff --git a/src/packet.c b/src/packet.c
deleted file mode 100644
index 9442307..0000000
--- a/src/packet.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* SPDX-License-Identifier: copyleft-next-0.3.1 */
-/* Copyright 2023 Kim Kuparinen < kimi.h.kuparinen@gmail.com > */
-
-#include <gran/packet.h>
-#include <stdlib.h>
-#include <assert.h>
-
-struct packet {
- enum packet_state state;
- enum packet_type type;
-
- uintptr_t addr;
- size_t size;
- void *data;
-};
-
-
-struct packet *create_packet(enum packet_type type, uintptr_t addr, size_t size)
-{
- struct packet *pkt = malloc(sizeof(struct packet) + size);
- if (!pkt)
- return NULL;
-
- pkt->state = PACKET_INIT;
- pkt->type = type;
- pkt->addr = addr;
- pkt->size = size;
- pkt->data = pkt + 1;
- return pkt;
-}
-
-struct packet *create_packet_with(enum packet_type type, uintptr_t addr,
- size_t size, void *data)
-{
- struct packet *pkt = malloc(sizeof(struct packet));
- if (!pkt)
- return NULL;
-
- pkt->state = PACKET_INIT;
- pkt->type = type;
- pkt->addr = addr;
- pkt->size = size;
- pkt->data = data;
- return pkt;
-}
-
-struct packet *reuse_packet(struct packet *pkt, enum packet_type type,
- uintptr_t addr, size_t size, void *data)
-{
- assert(pkt->state == PACKET_DONE);
- pkt->state = PACKET_INIT;
- pkt->type = type;
- pkt->addr = addr;
- pkt->size = size;
- pkt->data = data;
- return pkt;
-}
-
-enum packet_type packet_type(struct packet *pkt)
-{
- return pkt->type;
-}
-
-enum packet_state packet_state(struct packet *pkt)
-{
- return pkt->state;
-}
-
-void packet_set_state(struct packet *pkt, enum packet_state state)
-{
- pkt->state = state;
-}
-
-size_t packet_size(struct packet *pkt)
-{
- return pkt->size;
-}
-
-uintptr_t packet_addr(struct packet *pkt)
-{
- return pkt->addr;
-}
-
-void *packet_data(struct packet *pkt)
-{
- return pkt->data;
-}
-
-void destroy_packet(struct packet *pkt)
-{
- free(pkt);
-}