mirror of
https://github.com/golang/go
synced 2024-11-18 23:24:39 -07:00
go/ssa/interp: make os.Pipe intrinsic POSIX-portable; disable on Windows
Change-Id: I6c2f495c7c75f86590a0d79f86423ca67d695347 Reviewed-on: https://go-review.googlesource.com/18325 Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
0f870d4d86
commit
c49318f04a
@ -237,21 +237,6 @@ func ext۰math۰Log(fr *frame, args []value) value {
|
|||||||
return math.Log(args[0].(float64))
|
return math.Log(args[0].(float64))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ext۰os۰Pipe(fr *frame, args []value) value {
|
|
||||||
// This is an inlining of linux's os.Pipe.
|
|
||||||
// func os.Pipe() (r *File, w *File, err error)
|
|
||||||
var p [2]int
|
|
||||||
if err := syscall.Pipe2(p[:], syscall.O_CLOEXEC); err != nil {
|
|
||||||
// TODO(adonovan): fix: return an *os.SyscallError.
|
|
||||||
return tuple{nil, nil, wrapError(err)}
|
|
||||||
}
|
|
||||||
|
|
||||||
NewFile := fr.i.prog.ImportedPackage("os").Func("NewFile")
|
|
||||||
r := call(fr.i, fr, 0, NewFile, []value{uintptr(p[0]), "|0"})
|
|
||||||
w := call(fr.i, fr, 0, NewFile, []value{uintptr(p[1]), "|1"})
|
|
||||||
return tuple{r, w, wrapError(nil)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ext۰os۰runtime_args(fr *frame, args []value) value {
|
func ext۰os۰runtime_args(fr *frame, args []value) value {
|
||||||
return fr.i.osArgs
|
return fr.i.osArgs
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,22 @@ package interp
|
|||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
|
func ext۰os۰Pipe(fr *frame, args []value) value {
|
||||||
|
// func os.Pipe() (r *File, w *File, err error)
|
||||||
|
|
||||||
|
// The portable POSIX pipe(2) call is good enough for our needs.
|
||||||
|
var p [2]int
|
||||||
|
if err := syscall.Pipe(p[:]); err != nil {
|
||||||
|
// TODO(adonovan): fix: return an *os.SyscallError.
|
||||||
|
return tuple{nil, nil, wrapError(err)}
|
||||||
|
}
|
||||||
|
|
||||||
|
NewFile := fr.i.prog.ImportedPackage("os").Func("NewFile")
|
||||||
|
r := call(fr.i, fr, 0, NewFile, []value{uintptr(p[0]), "|0"})
|
||||||
|
w := call(fr.i, fr, 0, NewFile, []value{uintptr(p[1]), "|1"})
|
||||||
|
return tuple{r, w, wrapError(nil)}
|
||||||
|
}
|
||||||
|
|
||||||
func fillStat(st *syscall.Stat_t, stat structure) {
|
func fillStat(st *syscall.Stat_t, stat structure) {
|
||||||
stat[0] = st.Dev
|
stat[0] = st.Dev
|
||||||
stat[1] = st.Ino
|
stat[1] = st.Ino
|
||||||
|
@ -6,6 +6,9 @@ package interp
|
|||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
|
func ext۰os۰Pipe(fr *frame, args []value) value {
|
||||||
|
panic("os.Pipe not yet implemented")
|
||||||
|
}
|
||||||
func ext۰syscall۰Close(fr *frame, args []value) value {
|
func ext۰syscall۰Close(fr *frame, args []value) value {
|
||||||
panic("syscall.Close not yet implemented")
|
panic("syscall.Close not yet implemented")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user