OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [time/] [sys_plan9.go] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
// +build plan9
6
 
7
package time
8
 
9
import "syscall"
10
 
11
// for testing: whatever interrupts a sleep
12
func interrupt() {
13
        // cannot predict pid, don't want to kill group
14
}
15
 
16
// readFile reads and returns the content of the named file.
17
// It is a trivial implementation of ioutil.ReadFile, reimplemented
18
// here to avoid depending on io/ioutil or os.
19
func readFile(name string) ([]byte, error) {
20
        f, err := syscall.Open(name, syscall.O_RDONLY)
21
        if err != nil {
22
                return nil, err
23
        }
24
        defer syscall.Close(f)
25
        var (
26
                buf [4096]byte
27
                ret []byte
28
                n   int
29
        )
30
        for {
31
                n, err = syscall.Read(f, buf[:])
32
                if n > 0 {
33
                        ret = append(ret, buf[:n]...)
34
                }
35
                if n == 0 || err != nil {
36
                        break
37
                }
38
        }
39
        return ret, err
40
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.