OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Plan 9 system calls. | 5 // Plan 9 system calls. |
6 // This file is compiled as ordinary Go code, | 6 // This file is compiled as ordinary Go code, |
7 // but it is also input to mksyscall, | 7 // but it is also input to mksyscall, |
8 // which parses the //sys lines and generates system call stubs. | 8 // which parses the //sys lines and generates system call stubs. |
9 // Note that sometimes we use a lowercase //sys name and | 9 // Note that sometimes we use a lowercase //sys name and |
10 // wrap it in our own nicer implementation. | 10 // wrap it in our own nicer implementation. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 n, _ := readnum("#c/pid") | 108 n, _ := readnum("#c/pid") |
109 return int(n) | 109 return int(n) |
110 } | 110 } |
111 | 111 |
112 func Getppid() (ppid int) { | 112 func Getppid() (ppid int) { |
113 n, _ := readnum("#c/ppid") | 113 n, _ := readnum("#c/ppid") |
114 return int(n) | 114 return int(n) |
115 } | 115 } |
116 | 116 |
117 func Read(fd int, p []byte) (n int, err error) { | 117 func Read(fd int, p []byte) (n int, err error) { |
118 » return Pread(fd, p, -1) | 118 » n, err = Pread(fd, p, -1) |
| 119 » if raceenabled && err == nil { |
| 120 » » raceAcquire(unsafe.Pointer(&ioSync)) |
| 121 » } |
| 122 » return |
119 } | 123 } |
120 | 124 |
121 func Write(fd int, p []byte) (n int, err error) { | 125 func Write(fd int, p []byte) (n int, err error) { |
| 126 if raceenabled { |
| 127 raceReleaseMerge(unsafe.Pointer(&ioSync)) |
| 128 } |
122 return Pwrite(fd, p, -1) | 129 return Pwrite(fd, p, -1) |
123 } | 130 } |
124 | 131 |
| 132 var ioSync int64 |
| 133 |
125 func Getwd() (wd string, err error) { | 134 func Getwd() (wd string, err error) { |
126 fd, e := Open(".", O_RDONLY) | 135 fd, e := Open(".", O_RDONLY) |
127 | 136 |
128 if e != nil { | 137 if e != nil { |
129 return "", e | 138 return "", e |
130 } | 139 } |
131 defer Close(fd) | 140 defer Close(fd) |
132 | 141 |
133 return Fd2path(fd) | 142 return Fd2path(fd) |
134 } | 143 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 //sys Pread(fd int, p []byte, offset int64) (n int, err error) | 354 //sys Pread(fd int, p []byte, offset int64) (n int, err error) |
346 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) | 355 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) |
347 //sys Close(fd int) (err error) | 356 //sys Close(fd int) (err error) |
348 //sys Chdir(path string) (err error) | 357 //sys Chdir(path string) (err error) |
349 //sys Bind(name string, old string, flag int) (err error) | 358 //sys Bind(name string, old string, flag int) (err error) |
350 //sys Mount(fd int, afd int, old string, flag int, aname string) (err error) | 359 //sys Mount(fd int, afd int, old string, flag int, aname string) (err error) |
351 //sys Stat(path string, edir []byte) (n int, err error) | 360 //sys Stat(path string, edir []byte) (n int, err error) |
352 //sys Fstat(fd int, edir []byte) (n int, err error) | 361 //sys Fstat(fd int, edir []byte) (n int, err error) |
353 //sys Wstat(path string, edir []byte) (err error) | 362 //sys Wstat(path string, edir []byte) (err error) |
354 //sys Fwstat(fd int, edir []byte) (err error) | 363 //sys Fwstat(fd int, edir []byte) (err error) |
OLD | NEW |