go/ssa/interp: add syscall.Readlink intrinsic, needed by os package

Change-Id: Ie408fd5ffb2be2d60773eb3fda91912887df0a7e
Reviewed-on: https://go-review.googlesource.com/33147
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Alan Donovan 2016-11-11 16:39:39 -05:00
parent 22ba3f367c
commit 5e2ae75eb7
1 changed files with 8 additions and 0 deletions

View File

@ -142,6 +142,7 @@ func init() {
"syscall.RawSyscall": ext۰syscall۰RawSyscall, "syscall.RawSyscall": ext۰syscall۰RawSyscall,
"syscall.Read": ext۰syscall۰Read, "syscall.Read": ext۰syscall۰Read,
"syscall.ReadDirent": ext۰syscall۰ReadDirent, "syscall.ReadDirent": ext۰syscall۰ReadDirent,
"syscall.Readlink": ext۰syscall۰Readlink,
"syscall.Stat": ext۰syscall۰Stat, "syscall.Stat": ext۰syscall۰Stat,
"syscall.Write": ext۰syscall۰Write, "syscall.Write": ext۰syscall۰Write,
"syscall.runtime_envs": ext۰runtime۰environ, "syscall.runtime_envs": ext۰runtime۰environ,
@ -485,6 +486,13 @@ func ext۰syscall۰Getpid(fr *frame, args []value) value {
return syscall.Getpid() return syscall.Getpid()
} }
func ext۰syscall۰Readlink(fr *frame, args []value) value {
path := args[0].(string)
buf := valueToBytes(args[1])
n, err := syscall.Readlink(path, buf)
return tuple{n, wrapError(err)}
}
func valueToBytes(v value) []byte { func valueToBytes(v value) []byte {
in := v.([]value) in := v.([]value)
b := make([]byte, len(in)) b := make([]byte, len(in))