mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 23:13:40 +00:00
os: Implement Pipe for darwin, add smoke test.
Evidently when you read from pipes in Go, you have to adjust your slice length to reflect the number of bytes read. Verified upstream behaves the same way.
This commit is contained in:
@@ -246,6 +246,19 @@ func Fdopendir(fd int) (dir uintptr, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Pipe2(fds []int, flags int) (err error) {
|
||||
// Mac only has Pipe, which ignores the flags argument
|
||||
buf := make([]int32, 2)
|
||||
fail := int(libc_pipe(&buf[0]))
|
||||
if fail < 0 {
|
||||
err = getErrno()
|
||||
} else {
|
||||
fds[0] = int(buf[0])
|
||||
fds[1] = int(buf[1])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (err error) {
|
||||
e1 := libc_readdir_r(unsafe.Pointer(dir), unsafe.Pointer(entry), unsafe.Pointer(result))
|
||||
if e1 != 0 {
|
||||
@@ -278,3 +291,7 @@ func libc_fstat(fd int32, ptr unsafe.Pointer) int32
|
||||
// int lstat(const char *path, struct stat * buf);
|
||||
//export lstat$INODE64
|
||||
func libc_lstat(pathname *byte, ptr unsafe.Pointer) int32
|
||||
|
||||
// int pipe(int32 *fds);
|
||||
//export pipe
|
||||
func libc_pipe(fds *int32) int32
|
||||
|
||||
Reference in New Issue
Block a user