Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ all: test

CC?=clang
LD?=wasm-ld
AR?=llvm-ar
RANLIB?=llvm-ranlib
JS?=node

.PHONY: test
Expand All @@ -15,6 +17,10 @@ test: test.js test.wasm
test.wasm: test.o walloc.o
$(LD) --no-entry --import-memory -o $@ $^

libwalloc.a: walloc.o
$(AR) rc $@ $<
$(RANLIB) $@

.PHONY: clean
clean:
rm -f *.o *.wasm
rm -f *.o *.a *.wasm
4 changes: 4 additions & 0 deletions walloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ typedef __UINT8_TYPE__ uint8_t;
static inline size_t max(size_t a, size_t b) {
return a < b ? b : a;
}
#if __has_constexpr_builtin(__builtin_align_up)
#define align __builtin_align_up
#else
static inline uintptr_t align(uintptr_t val, uintptr_t alignment) {
return (val + alignment - 1) & ~(alignment - 1);
}
#endif
#define ASSERT_ALIGNED(x, y) ASSERT((x) == align((x), y))

#define CHUNK_SIZE 256
Expand Down