summaryrefslogtreecommitdiff
path: root/libgo/go/time/sys_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/time/sys_unix.go')
-rw-r--r--libgo/go/time/sys_unix.go38
1 files changed, 37 insertions, 1 deletions
diff --git a/libgo/go/time/sys_unix.go b/libgo/go/time/sys_unix.go
index 56a7414e0ce..7f69b492c9f 100644
--- a/libgo/go/time/sys_unix.go
+++ b/libgo/go/time/sys_unix.go
@@ -6,7 +6,10 @@
package time
-import "syscall"
+import (
+ "errors"
+ "syscall"
+)
// for testing: whatever interrupts a sleep
func interrupt() {
@@ -38,3 +41,36 @@ func readFile(name string) ([]byte, error) {
}
return ret, err
}
+
+func open(name string) (uintptr, error) {
+ fd, err := syscall.Open(name, syscall.O_RDONLY, 0)
+ if err != nil {
+ return 0, err
+ }
+ return uintptr(fd), nil
+}
+
+func closefd(fd uintptr) {
+ syscall.Close(int(fd))
+}
+
+func preadn(fd uintptr, buf []byte, off int) error {
+ whence := 0
+ if off < 0 {
+ whence = 2
+ }
+ if _, err := syscall.Seek(int(fd), int64(off), whence); err != nil {
+ return err
+ }
+ for len(buf) > 0 {
+ m, err := syscall.Read(int(fd), buf)
+ if m <= 0 {
+ if err == nil {
+ return errors.New("short read")
+ }
+ return err
+ }
+ buf = buf[m:]
+ }
+ return nil
+}