mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
syscall: remove sliceHeader, use unsafe.SliceData more
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user