syscall: remove sliceHeader, use unsafe.SliceData more

This commit is contained in:
Jake Bailey
2026-06-04 09:57:49 -07:00
committed by Nia
parent 5fabc203db
commit 2328d1e799
4 changed files with 13 additions and 32 deletions
+6 -8
View File
@@ -2,6 +2,8 @@
package syscall
import "unsafe"
// These are the default Read/Write/Pread/Pwrite implementations for
// libc-backed wasm targets that do NOT have the cooperative scheduler
// + wasip1 netpoll integration. They are simple pass-throughs to the
@@ -12,8 +14,7 @@ package syscall
// that park the goroutine on EAGAIN; see syscall_libc_wasip1.go.
func Write(fd int, p []byte) (n int, err error) {
buf, count := splitSlice(p)
n = libc_write(int32(fd), buf, uint(count))
n = libc_write(int32(fd), unsafe.SliceData(p), uint(len(p)))
if n < 0 {
err = getErrno()
}
@@ -21,8 +22,7 @@ func Write(fd int, p []byte) (n int, err error) {
}
func Read(fd int, p []byte) (n int, err error) {
buf, count := splitSlice(p)
n = libc_read(int32(fd), buf, uint(count))
n = libc_read(int32(fd), unsafe.SliceData(p), uint(len(p)))
if n < 0 {
err = getErrno()
}
@@ -30,8 +30,7 @@ func Read(fd int, p []byte) (n int, err error) {
}
func Pread(fd int, p []byte, offset int64) (n int, err error) {
buf, count := splitSlice(p)
n = libc_pread(int32(fd), buf, uint(count), offset)
n = libc_pread(int32(fd), unsafe.SliceData(p), uint(len(p)), offset)
if n < 0 {
err = getErrno()
}
@@ -39,8 +38,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
}
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
buf, count := splitSlice(p)
n = libc_pwrite(int32(fd), buf, uint(count), offset)
n = libc_pwrite(int32(fd), unsafe.SliceData(p), uint(len(p)), offset)
if n < 0 {
err = getErrno()
}