Skip to content

Commit

Permalink
internal: just a bunch of hacked up files here
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Dec 8, 2023
1 parent 68dac5b commit 2f07e8d
Show file tree
Hide file tree
Showing 30 changed files with 107 additions and 18 deletions.
4 changes: 4 additions & 0 deletions internal/platform/mmap_tinygo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ func mmapCodeSegmentAMD64(size int) ([]byte, error) {
func mmapCodeSegmentARM64(size int) ([]byte, error) {
return nil, errNotYetSupported
}

func MprotectRX(b []byte) (err error) {
return errNotYetSupported
}
2 changes: 1 addition & 1 deletion internal/sock/sock_supported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !plan9 && !js
//go:build !plan9 && !js && !tinygo

package sock

Expand Down
2 changes: 1 addition & 1 deletion internal/sock/sock_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build plan9 || js
//go:build plan9 || js || tinygo

package sock

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/datasync_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build linux && !tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/datasync_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !linux
//go:build !linux || tinygo

package sysfs

Expand Down
2 changes: 2 additions & 0 deletions internal/sysfs/dirfs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !tinygo

package sysfs

import (
Expand Down
11 changes: 11 additions & 0 deletions internal/sysfs/dirfs_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build tinygo

package sysfs

import (
experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
)

func DirFS(dir string) experimentalsys.FS {
return nil
}
2 changes: 1 addition & 1 deletion internal/sysfs/file_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build unix
//go:build unix && !tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/file_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !unix && !windows
//go:build (!unix && !windows) || tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/futimens.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux || darwin
//go:build (linux || darwin) && !tinygo

package sysfs

Expand Down
2 changes: 2 additions & 0 deletions internal/sysfs/futimens_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !tinygo

package sysfs

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/futimens_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows && !linux && !darwin
//go:build (!windows && !linux && !darwin) || tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/ino.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows && !plan9
//go:build !windows && !plan9 && !tinygo

package sysfs

Expand Down
15 changes: 15 additions & 0 deletions internal/sysfs/ino_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build tinygo

package sysfs

import (
"io/fs"

experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/sys"
)

// inoFromFileInfo uses stat to get the inode information of the file.
func inoFromFileInfo(dirPath string, info fs.FileInfo) (ino sys.Inode, errno experimentalsys.Errno) {
return 0, 0
}
15 changes: 15 additions & 0 deletions internal/sysfs/nonblock_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build tinygo

package sysfs

import (
"github.com/tetratelabs/wazero/experimental/sys"
)

func setNonblock(fd uintptr, enable bool) sys.Errno {
return 0
}

func isNonblock(f *osFile) bool {
return false
}
2 changes: 1 addition & 1 deletion internal/sysfs/nonblock_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows && !plan9
//go:build !windows && !plan9 && !tinygo

package sysfs

Expand Down
2 changes: 2 additions & 0 deletions internal/sysfs/open_file_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !tinygo

package sysfs

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/open_file_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !darwin && !linux && !windows && !illumos && !solaris && !freebsd
//go:build (!darwin && !linux && !windows && !illumos && !solaris && !freebsd) || tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/poll.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build windows || linux || darwin
//go:build (windows || linux || darwin) && !tinygo

package sysfs

Expand Down
2 changes: 2 additions & 0 deletions internal/sysfs/poll_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !tinygo

package sysfs

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/poll_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !linux && !darwin && !windows
//go:build (!linux && !darwin && !windows) || tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/rename.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows && !plan9
//go:build !windows && !plan9 && !tinygo

package sysfs

Expand Down
11 changes: 11 additions & 0 deletions internal/sysfs/rename_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build tinygo

package sysfs

import (
"github.com/tetratelabs/wazero/experimental/sys"
)

func rename(from, to string) sys.Errno {
return 0
}
2 changes: 1 addition & 1 deletion internal/sysfs/sock_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux || darwin
//go:build (linux || darwin) && !tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/sock_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !linux && !darwin && !windows
//go:build (!linux && !darwin && !windows) || tinygo

package sysfs

Expand Down
2 changes: 1 addition & 1 deletion internal/sysfs/unlink.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !windows && !plan9
//go:build !windows && !plan9 && !tinygo

package sysfs

Expand Down
11 changes: 11 additions & 0 deletions internal/sysfs/unlink_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build tinygo

package sysfs

import (
"github.com/tetratelabs/wazero/experimental/sys"
)

func unlink(name string) (errno sys.Errno) {
return 0
}
2 changes: 1 addition & 1 deletion internal/wasm/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (m *MemoryInstance) Grow(delta uint32) (result uint32, ok bool) {
return currentPages, true
} else { // We already have the capacity we need.
sp := (*reflect.SliceHeader)(unsafe.Pointer(&m.Buffer))
sp.Len = int(MemoryPagesToBytesNum(newPages))
sp.Len = lengthMemoryPages(newPages)
return currentPages, true
}
}
Expand Down
7 changes: 7 additions & 0 deletions internal/wasm/memorypages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !tinygo

package wasm

func lengthMemoryPages(newPage uint32) int {
return int(MemoryPagesToBytesNum(newPage))
}
7 changes: 7 additions & 0 deletions internal/wasm/memorypages_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build tinygo

package wasm

func lengthMemoryPages(newPage uint32) uintptr {
return uintptr(MemoryPagesToBytesNum(newPage))
}

0 comments on commit 2f07e8d

Please sign in to comment.