-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
765 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright The OWASP Coraza contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM ghcr.io/corazawaf/coraza-proxy-wasm/buildtools-wasi-sdk:main | ||
|
||
RUN apt-get install -y cmake patch | ||
|
||
RUN mkdir -p /mimalloc && curl -L https://github.com/microsoft/mimalloc/archive/refs/tags/v2.0.6.tar.gz | tar -xz --strip-components 1 -C /mimalloc | ||
WORKDIR /mimalloc | ||
ADD mimalloc.patch mimalloc.patch | ||
RUN patch -p1 < mimalloc.patch | ||
RUN mkdir -p out/release && cd out/release && cmake ../.. -DMI_BUILD_SHARED=off -DMI_BUILD_TESTS=off && make && llvm-ranlib-14 libmimalloc.a | ||
|
||
CMD ["cp", "./out/release/libmimalloc.a", "/out/libmimalloc.a"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
diff --git a/include/mimalloc-atomic.h b/include/mimalloc-atomic.h | ||
index 7ad5da5..3029d97 100644 | ||
--- a/include/mimalloc-atomic.h | ||
+++ b/include/mimalloc-atomic.h | ||
@@ -325,7 +325,7 @@ static inline void mi_atomic_yield(void) { | ||
#elif defined(__wasi__) | ||
#include <sched.h> | ||
static inline void mi_atomic_yield(void) { | ||
- sched_yield(); | ||
+ // sched_yield(); | ||
} | ||
#else | ||
#include <unistd.h> | ||
diff --git a/src/alloc-override.c b/src/alloc-override.c | ||
index e29cb4b..19f6822 100644 | ||
--- a/src/alloc-override.c | ||
+++ b/src/alloc-override.c | ||
@@ -256,7 +256,7 @@ int reallocarr(void* p, size_t count, size_t size) { return mi_reallocarr(p | ||
void* memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); } | ||
void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); } | ||
|
||
-#if defined(__GLIBC__) && defined(__linux__) | ||
+#if defined(__GLIBC__) && defined(__linux__) || defined(__wasi__) | ||
// forward __libc interface (needed for glibc-based Linux distributions) | ||
void* __libc_malloc(size_t size) MI_FORWARD1(mi_malloc,size) | ||
void* __libc_calloc(size_t count, size_t size) MI_FORWARD2(mi_calloc,count,size) | ||
@@ -268,6 +268,7 @@ void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_allo | ||
void* __libc_pvalloc(size_t size) { return mi_pvalloc(size); } | ||
void* __libc_memalign(size_t alignment, size_t size) { return mi_memalign(alignment,size); } | ||
int __posix_memalign(void** p, size_t alignment, size_t size) { return mi_posix_memalign(p,alignment,size); } | ||
+ void* aligned_alloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); } | ||
#endif | ||
|
||
#ifdef __cplusplus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright The OWASP Coraza contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Package gc is a custom gargabe gollector for TinyGo. The main difference is instead of taking | ||
// ownership of the entire process heap, it uses malloc to allocate blocks for the GC to then | ||
// assign to allocated objects. | ||
// | ||
// Currently, only one block can be allocated meaning this has a fixed-size heap. | ||
package gc |
Oops, something went wrong.