forked from corazawaf/coraza-proxy-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_tinygo.go
37 lines (29 loc) · 1.01 KB
/
init_tinygo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright The OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0
//go:build tinygo
package main
import (
"unsafe"
_ "github.com/wasilibs/nottinygc"
)
// Some host functions that are not implemented by Envoy end up getting imported anyways
// by code that gets compiled but not executed at runtime. Because we know they are not
// executed, we can stub them out to allow functioning on Envoy. Note, these match the
// names and signatures of wasi-libc, used by TinyGo, not WASI ABI. Review these exports when either
// the minimum supported version of Envoy changes or the maximum version of TinyGo.
//export sched_yield
func sched_yield() int32 {
return 0
}
// fdopendir is re-exported to avoid TinyGo 0.28's import of wasi_snapshot_preview1.fd_readdir.
//
//export fdopendir
func fdopendir(fd int32) unsafe.Pointer {
return nil
}
// readdir is re-exported to avoid TinyGo 0.28's import of wasi_snapshot_preview1.fd_readdir.
//
//export readdir
func readdir(unsafe.Pointer) unsafe.Pointer {
return nil
}