github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/src/runtime/os_solaris.go (about) 1 // Copyright 2014 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 package runtime 6 7 import "unsafe" 8 9 type mts struct { 10 tv_sec int64 11 tv_nsec int64 12 } 13 14 type mscratch struct { 15 v [6]uintptr 16 } 17 18 type mOS struct { 19 waitsema uintptr // semaphore for parking on locks 20 perrno *int32 // pointer to tls errno 21 // these are here because they are too large to be on the stack 22 // of low-level NOSPLIT functions. 23 //LibCall libcall; 24 ts mts 25 scratch mscratch 26 } 27 28 type libcFunc uintptr 29 30 var asmsysvicall6 libcFunc 31 32 //go:nosplit 33 func sysvicall0(fn *libcFunc) uintptr { 34 // Leave caller's PC/SP around for traceback. 35 gp := getg() 36 var mp *m 37 if gp != nil { 38 mp = gp.m 39 } 40 if mp != nil && mp.libcallsp == 0 { 41 mp.libcallg.set(gp) 42 mp.libcallpc = getcallerpc() 43 // sp must be the last, because once async cpu profiler finds 44 // all three values to be non-zero, it will use them 45 mp.libcallsp = getcallersp() 46 } else { 47 mp = nil // See comment in sys_darwin.go:libcCall 48 } 49 50 var libcall libcall 51 libcall.fn = uintptr(unsafe.Pointer(fn)) 52 libcall.n = 0 53 libcall.args = uintptr(unsafe.Pointer(fn)) // it's unused but must be non-nil, otherwise crashes 54 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 55 if mp != nil { 56 mp.libcallsp = 0 57 } 58 return libcall.r1 59 } 60 61 //go:nosplit 62 func sysvicall1(fn *libcFunc, a1 uintptr) uintptr { 63 // Leave caller's PC/SP around for traceback. 64 gp := getg() 65 var mp *m 66 if gp != nil { 67 mp = gp.m 68 } 69 if mp != nil && mp.libcallsp == 0 { 70 mp.libcallg.set(gp) 71 mp.libcallpc = getcallerpc() 72 // sp must be the last, because once async cpu profiler finds 73 // all three values to be non-zero, it will use them 74 mp.libcallsp = getcallersp() 75 } else { 76 mp = nil 77 } 78 79 var libcall libcall 80 libcall.fn = uintptr(unsafe.Pointer(fn)) 81 libcall.n = 1 82 // TODO(rsc): Why is noescape necessary here and below? 83 libcall.args = uintptr(noescape(unsafe.Pointer(&a1))) 84 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 85 if mp != nil { 86 mp.libcallsp = 0 87 } 88 return libcall.r1 89 } 90 91 //go:nosplit 92 func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr { 93 // Leave caller's PC/SP around for traceback. 94 gp := getg() 95 var mp *m 96 if gp != nil { 97 mp = gp.m 98 } 99 if mp != nil && mp.libcallsp == 0 { 100 mp.libcallg.set(gp) 101 mp.libcallpc = getcallerpc() 102 // sp must be the last, because once async cpu profiler finds 103 // all three values to be non-zero, it will use them 104 mp.libcallsp = getcallersp() 105 } else { 106 mp = nil 107 } 108 109 var libcall libcall 110 libcall.fn = uintptr(unsafe.Pointer(fn)) 111 libcall.n = 2 112 libcall.args = uintptr(noescape(unsafe.Pointer(&a1))) 113 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 114 if mp != nil { 115 mp.libcallsp = 0 116 } 117 return libcall.r1 118 } 119 120 //go:nosplit 121 func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr { 122 // Leave caller's PC/SP around for traceback. 123 gp := getg() 124 var mp *m 125 if gp != nil { 126 mp = gp.m 127 } 128 if mp != nil && mp.libcallsp == 0 { 129 mp.libcallg.set(gp) 130 mp.libcallpc = getcallerpc() 131 // sp must be the last, because once async cpu profiler finds 132 // all three values to be non-zero, it will use them 133 mp.libcallsp = getcallersp() 134 } else { 135 mp = nil 136 } 137 138 var libcall libcall 139 libcall.fn = uintptr(unsafe.Pointer(fn)) 140 libcall.n = 3 141 libcall.args = uintptr(noescape(unsafe.Pointer(&a1))) 142 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 143 if mp != nil { 144 mp.libcallsp = 0 145 } 146 return libcall.r1 147 } 148 149 //go:nosplit 150 func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr { 151 // Leave caller's PC/SP around for traceback. 152 gp := getg() 153 var mp *m 154 if gp != nil { 155 mp = gp.m 156 } 157 if mp != nil && mp.libcallsp == 0 { 158 mp.libcallg.set(gp) 159 mp.libcallpc = getcallerpc() 160 // sp must be the last, because once async cpu profiler finds 161 // all three values to be non-zero, it will use them 162 mp.libcallsp = getcallersp() 163 } else { 164 mp = nil 165 } 166 167 var libcall libcall 168 libcall.fn = uintptr(unsafe.Pointer(fn)) 169 libcall.n = 4 170 libcall.args = uintptr(noescape(unsafe.Pointer(&a1))) 171 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 172 if mp != nil { 173 mp.libcallsp = 0 174 } 175 return libcall.r1 176 } 177 178 //go:nosplit 179 func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr { 180 // Leave caller's PC/SP around for traceback. 181 gp := getg() 182 var mp *m 183 if gp != nil { 184 mp = gp.m 185 } 186 if mp != nil && mp.libcallsp == 0 { 187 mp.libcallg.set(gp) 188 mp.libcallpc = getcallerpc() 189 // sp must be the last, because once async cpu profiler finds 190 // all three values to be non-zero, it will use them 191 mp.libcallsp = getcallersp() 192 } else { 193 mp = nil 194 } 195 196 var libcall libcall 197 libcall.fn = uintptr(unsafe.Pointer(fn)) 198 libcall.n = 5 199 libcall.args = uintptr(noescape(unsafe.Pointer(&a1))) 200 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 201 if mp != nil { 202 mp.libcallsp = 0 203 } 204 return libcall.r1 205 } 206 207 //go:nosplit 208 func sysvicall6(fn *libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr { 209 // Leave caller's PC/SP around for traceback. 210 gp := getg() 211 var mp *m 212 if gp != nil { 213 mp = gp.m 214 } 215 if mp != nil && mp.libcallsp == 0 { 216 mp.libcallg.set(gp) 217 mp.libcallpc = getcallerpc() 218 // sp must be the last, because once async cpu profiler finds 219 // all three values to be non-zero, it will use them 220 mp.libcallsp = getcallersp() 221 } else { 222 mp = nil 223 } 224 225 var libcall libcall 226 libcall.fn = uintptr(unsafe.Pointer(fn)) 227 libcall.n = 6 228 libcall.args = uintptr(noescape(unsafe.Pointer(&a1))) 229 asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&libcall)) 230 if mp != nil { 231 mp.libcallsp = 0 232 } 233 return libcall.r1 234 }