mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 21:13:39 +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:
@@ -153,10 +153,6 @@ func Kill(pid int, sig Signal) (err error) {
|
||||
|
||||
type SysProcAttr struct{}
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) {
|
||||
return ENOSYS // TODO
|
||||
}
|
||||
|
||||
// TODO
|
||||
type WaitStatus uint32
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -63,3 +63,7 @@ var libcErrno uintptr
|
||||
func getErrno() error {
|
||||
return Errno(libcErrno)
|
||||
}
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) {
|
||||
return ENOSYS // TODO
|
||||
}
|
||||
|
||||
@@ -292,6 +292,10 @@ func Lstat(path string, p *Stat_t) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Pipe2(p []int, flags int) (err error) {
|
||||
return ENOSYS // TODO
|
||||
}
|
||||
|
||||
// int stat(const char *path, struct stat * buf);
|
||||
//export stat
|
||||
func libc_stat(pathname *byte, ptr unsafe.Pointer) int32
|
||||
|
||||
@@ -180,6 +180,9 @@ type SysProcAttr struct {
|
||||
func Getgroups() ([]int, error) { return []int{1}, nil }
|
||||
func Gettimeofday(tv *Timeval) error { return ENOSYS }
|
||||
func Kill(pid int, signum Signal) error { return ENOSYS }
|
||||
func Pipe2(p []int, flags int) (err error) {
|
||||
return ENOSYS // TODO
|
||||
}
|
||||
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||
return 0, ENOSYS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user