aboutsummaryrefslogtreecommitdiff
path: root/libgo/syscalls
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-05-20 00:18:15 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-05-20 00:18:15 +0000
commit9ff56c9570642711d5b7ab29920ecf5dbff14a27 (patch)
treec891bdec1e6f073f73fedeef23718bc3ac30d499 /libgo/syscalls
parent37cb25ed7acdb844b218231130e54b8b7a0ff6e6 (diff)
downloadgcc-9ff56c9570642711d5b7ab29920ecf5dbff14a27.zip
gcc-9ff56c9570642711d5b7ab29920ecf5dbff14a27.tar.gz
gcc-9ff56c9570642711d5b7ab29920ecf5dbff14a27.tar.bz2
Update to current version of Go library.
From-SVN: r173931
Diffstat (limited to 'libgo/syscalls')
-rw-r--r--libgo/syscalls/stringbyte.go13
-rw-r--r--libgo/syscalls/syscall_unix.go9
2 files changed, 22 insertions, 0 deletions
diff --git a/libgo/syscalls/stringbyte.go b/libgo/syscalls/stringbyte.go
index b673c9b..1761953 100644
--- a/libgo/syscalls/stringbyte.go
+++ b/libgo/syscalls/stringbyte.go
@@ -6,6 +6,8 @@
package syscall
+import "unsafe"
+
// StringByteSlice returns a NUL-terminated slice of bytes
// containing the text of s.
func StringByteSlice(s string) []byte {
@@ -22,3 +24,14 @@ func StringBytePtr(s string) *byte {
p := StringByteSlice(s);
return &p[0];
}
+
+// BytePtrToString takes a NUL-terminated array of bytes and convert
+// it to a Go string.
+func BytePtrToString(p *byte) string {
+ a := (*[10000]byte)(unsafe.Pointer(p))
+ i := 0
+ for a[i] != 0 {
+ i++
+ }
+ return string(a[:i])
+}
diff --git a/libgo/syscalls/syscall_unix.go b/libgo/syscalls/syscall_unix.go
index b5a660e..e633ea1 100644
--- a/libgo/syscalls/syscall_unix.go
+++ b/libgo/syscalls/syscall_unix.go
@@ -56,3 +56,12 @@ func munmap(addr uintptr, length uintptr) (errno int) {
}
return
}
+
+func libc_getrusage(who int, rusage *Rusage) int __asm__ ("getrusage")
+
+func Getrusage(who int, rusage *Rusage) (errno int) {
+ if libc_getrusage(who, rusage) < 0 {
+ errno = GetErrno()
+ }
+ return
+}