aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/syscall
diff options
context:
space:
mode:
authorDan Kegel <[email protected]>2022-06-10 17:20:54 -0700
committerAyke <[email protected]>2022-06-12 01:15:42 +0200
commit8754f64f3b77596dc211dfd830e50de69fc1770f (patch)
tree23d9e8d3ac1c2f0a0a5cb347303638ede01bdbb3 /src/syscall
parentcaf405b01d150de33ed55cec6ec60731885551d4 (diff)
downloadtinygo-8754f64f3b77596dc211dfd830e50de69fc1770f.tar.gz
tinygo-8754f64f3b77596dc211dfd830e50de69fc1770f.zip
syscall.Getpagesize(): add test, implement for Linux and Windows
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/syscall_libc.go8
-rw-r--r--src/syscall/syscall_libc_darwin.go8
-rw-r--r--src/syscall/syscall_libc_nintendoswitch.go4
-rw-r--r--src/syscall/syscall_libc_wasi.go5
-rw-r--r--src/syscall/syscall_nonhosted.go6
5 files changed, 23 insertions, 8 deletions
diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go
index 3fa3db043..a02187b5f 100644
--- a/src/syscall/syscall_libc.go
+++ b/src/syscall/syscall_libc.go
@@ -251,10 +251,6 @@ func Mprotect(b []byte, prot int) (err error) {
return
}
-func Getpagesize() int {
- return int(libc_getpagesize())
-}
-
func Environ() []string {
// This function combines all the environment into a single allocation.
@@ -372,10 +368,6 @@ func libc_munmap(addr unsafe.Pointer, length uintptr) int32
//export mprotect
func libc_mprotect(addr unsafe.Pointer, len uintptr, prot int32) int32
-// int getpagesize();
-//export getpagesize
-func libc_getpagesize() int32
-
// int chdir(const char *pathname, mode_t mode);
//export chdir
func libc_chdir(pathname *byte) int32
diff --git a/src/syscall/syscall_libc_darwin.go b/src/syscall/syscall_libc_darwin.go
index 0342add2e..4b1f1716d 100644
--- a/src/syscall/syscall_libc_darwin.go
+++ b/src/syscall/syscall_libc_darwin.go
@@ -267,6 +267,14 @@ func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (err error) {
return
}
+func Getpagesize() int {
+ return int(libc_getpagesize())
+}
+
// int pipe(int32 *fds);
//export pipe
func libc_pipe(fds *int32) int32
+
+// int getpagesize();
+//export getpagesize
+func libc_getpagesize() int32
diff --git a/src/syscall/syscall_libc_nintendoswitch.go b/src/syscall/syscall_libc_nintendoswitch.go
index 52b739394..5b120c936 100644
--- a/src/syscall/syscall_libc_nintendoswitch.go
+++ b/src/syscall/syscall_libc_nintendoswitch.go
@@ -67,3 +67,7 @@ func getErrno() error {
func Pipe2(p []int, flags int) (err error) {
return ENOSYS // TODO
}
+
+func Getpagesize() int {
+ return 4096 // TODO
+}
diff --git a/src/syscall/syscall_libc_wasi.go b/src/syscall/syscall_libc_wasi.go
index cf9da47f6..ec9d2304e 100644
--- a/src/syscall/syscall_libc_wasi.go
+++ b/src/syscall/syscall_libc_wasi.go
@@ -296,6 +296,11 @@ func Pipe2(p []int, flags int) (err error) {
return ENOSYS // TODO
}
+func Getpagesize() int {
+ // per upstream
+ return 65536
+}
+
// int stat(const char *path, struct stat * buf);
//export stat
func libc_stat(pathname *byte, ptr unsafe.Pointer) int32
diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go
index 3528087f8..399e97428 100644
--- a/src/syscall/syscall_nonhosted.go
+++ b/src/syscall/syscall_nonhosted.go
@@ -205,3 +205,9 @@ type Timeval struct {
Sec int64
Usec int64
}
+
+func Getpagesize() int {
+ // There is no right value to return here, but 4096 is a
+ // common assumption when pagesize is unknown
+ return 4096
+}