OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 // +build darwin dragonfly freebsd linux netbsd openbsd solaris | 5 // +build darwin dragonfly freebsd linux netbsd openbsd solaris |
6 | 6 |
7 package syscall | 7 package syscall |
8 | 8 |
9 import ( | 9 import ( |
10 "runtime" | 10 "runtime" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 return nil, errno | 49 return nil, errno |
50 } | 50 } |
51 | 51 |
52 // Slice memory layout | 52 // Slice memory layout |
53 var sl = struct { | 53 var sl = struct { |
54 addr uintptr | 54 addr uintptr |
55 len int | 55 len int |
56 cap int | 56 cap int |
57 }{addr, length, length} | 57 }{addr, length, length} |
58 | 58 |
59 » // Use unsafeto turn sl into a []byte. | 59 » // Use unsafe to turn sl into a []byte. |
60 b := *(*[]byte)(unsafe.Pointer(&sl)) | 60 b := *(*[]byte)(unsafe.Pointer(&sl)) |
61 | 61 |
62 // Register mapping in m and return it. | 62 // Register mapping in m and return it. |
63 p := &b[cap(b)-1] | 63 p := &b[cap(b)-1] |
64 m.Lock() | 64 m.Lock() |
65 defer m.Unlock() | 65 defer m.Unlock() |
66 m.active[p] = b | 66 m.active[p] = b |
67 return b, nil | 67 return b, nil |
68 } | 68 } |
69 | 69 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 290 } |
291 | 291 |
292 func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
rror) { | 292 func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
rror) { |
293 if raceenabled { | 293 if raceenabled { |
294 raceReleaseMerge(unsafe.Pointer(&ioSync)) | 294 raceReleaseMerge(unsafe.Pointer(&ioSync)) |
295 } | 295 } |
296 return sendfile(outfd, infd, offset, count) | 296 return sendfile(outfd, infd, offset, count) |
297 } | 297 } |
298 | 298 |
299 var ioSync int64 | 299 var ioSync int64 |
OLD | NEW |