aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-16 21:40:39 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-16 21:40:39 +0000
commit425aae2408eb29a43cc9050b83c29b56e6213deb (patch)
treecdeeb5c144b1b93e3e2eef04c5ac49d3176c08c9 /runtime
parentfa7c6c438116a9ef4b0d323198d5f079e9288c56 (diff)
Use offset from start of entire object
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/effects.c3
-rw-r--r--runtime/src/gc.c2
-rw-r--r--runtime/src/std/unistd.h7
3 files changed, 7 insertions, 5 deletions
diff --git a/runtime/src/effects.c b/runtime/src/effects.c
index c69b4af8..87ece625 100644
--- a/runtime/src/effects.c
+++ b/runtime/src/effects.c
@@ -1,3 +1,4 @@
+#include <stddef.h>
#include "./std/unistd.h"
#include "./gc.h"
#include "./closures.h"
@@ -28,7 +29,7 @@ ShedEffectHandler* shed__runtime__effects_push_handler(
) {
ShedEffectHandler* handler = shed__runtime__gc_alloc(
sizeof(ShedEffectHandler) + sizeof(ShedClosurePointer) * method_count,
- sizeof(ShedEffectTag) + sizeof(struct ShedEffectHandler*),
+ offsetof(ShedEffectHandler, methods),
method_count
);
handler->effect_tag = effect_tag;
diff --git a/runtime/src/gc.c b/runtime/src/gc.c
index 6e210aa3..ba22a37f 100644
--- a/runtime/src/gc.c
+++ b/runtime/src/gc.c
@@ -39,7 +39,7 @@ void mark(struct ShedGcObjectHeader* object) {
object->mark = current_mark_value;
struct ShedGcObjectHeader** children = (struct ShedGcObjectHeader**) (
- ((void*) object) + sizeof(struct ShedGcObjectHeader) + object->children_offset
+ ((void*) object) + object->children_offset
);
for (size_t child_index = 0; child_index < object->children_count; child_index++) {
diff --git a/runtime/src/std/unistd.h b/runtime/src/std/unistd.h
index df0b9dcb..6a761e6f 100644
--- a/runtime/src/std/unistd.h
+++ b/runtime/src/std/unistd.h
@@ -2,10 +2,11 @@
#define SHED_STD_UNISTD_H
#ifdef __WASM__
-#include <stdint.h>
-typedef uint32_t size_t;
-typedef int32_t ssize_t;
+typedef unsigned long size_t;
+typedef long ssize_t;
+#ifndef NULL
#define NULL 0
+#endif
#else
#include <unistd.h>
#endif