OLD | NEW |
1 // Copyright 2014 The Go Authors. All rights reserved. | 1 // Copyright 2014 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 package runtime | 5 package runtime |
6 | 6 |
7 import "unsafe" | 7 import "unsafe" |
8 | 8 |
9 // Declarations for runtime services implemented in C or assembly. | 9 // Declarations for runtime services implemented in C or assembly. |
10 // C implementations of these functions are in stubs.goc. | 10 // C implementations of these functions are in stubs.goc. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 var nohashcode uintptr | 113 var nohashcode uintptr |
114 | 114 |
115 // Go version of runtime.throw. | 115 // Go version of runtime.throw. |
116 // in panic.c | 116 // in panic.c |
117 func gothrow(s string) | 117 func gothrow(s string) |
118 | 118 |
119 func golock(x *lock) | 119 func golock(x *lock) |
120 func gounlock(x *lock) | 120 func gounlock(x *lock) |
121 func semacquire(*uint32, bool) | 121 func semacquire(*uint32, bool) |
122 func semrelease(*uint32) | 122 func semrelease(*uint32) |
| 123 |
| 124 // Return the Go equivalent of the C Alg structure. |
| 125 // TODO: at some point Go will hold the truth for the layout |
| 126 // of runtime structures and C will be derived from it (if |
| 127 // needed at all). At that point this function can go away. |
| 128 type goalgtype struct { |
| 129 // function for hashing objects of this type |
| 130 // (ptr to object, size, seed) -> hash |
| 131 hash func(unsafe.Pointer, uintptr, uintptr) uintptr |
| 132 } |
| 133 |
| 134 func goalg(a *alg) *goalgtype { |
| 135 return (*goalgtype)(unsafe.Pointer(a)) |
| 136 } |
| 137 |
| 138 // noescape hides a pointer from escape analysis. noescape is |
| 139 // the identity function but escape analysis doesn't think the |
| 140 // output depends on the input. noescape is inlined and currently |
| 141 // compiles down to a single xor instruction. |
| 142 // USE CAREFULLY! |
| 143 func noescape(p unsafe.Pointer) unsafe.Pointer { |
| 144 x := uintptr(p) |
| 145 return unsafe.Pointer(x ^ 0) |
| 146 } |
OLD | NEW |