github.com/gramework/runtimer@v0.0.0-20211014201118-d25b6e2ccefd/links.go (about) 1 // Package runtimer provides you unsafe way to use runtime internals 2 package runtimer 3 4 import ( 5 "unsafe" // #nosec required to use go:linkname 6 ) 7 8 func Or8(ptr *uint8, val uint8) { 9 or8(ptr, val) 10 } 11 12 //go:noescape 13 //go:linkname or8 runtime.internal.atomic.Or8 14 func or8(ptr *uint8, val uint8) 15 16 //go:linkname PtrSize runtime.internal.sys.PtrSize 17 const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 18 19 func Cas(ptr *uint32, old, new uint32) bool { 20 return cas(ptr, old, new) 21 } 22 23 //go:noescape 24 //go:linkname cas runtime.internal.atomic.Cas 25 func cas(ptr *uint32, old, new uint32) bool 26 27 func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool { 28 return casp1(ptr, old, new) 29 } 30 31 // NO go:noescape annotation; see atomic_pointer.go. 32 //go:linkname casp1 runtime.internal.atomic.Casp1 33 func casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool 34 35 func Casuintptr(ptr *uintptr, old, new uintptr) bool { 36 return casuintptr(ptr, old, new) 37 } 38 39 //go:noescape 40 //go:linkname casuintptr runtime.internal.atomic.Casuintptr 41 func casuintptr(ptr *uintptr, old, new uintptr) bool 42 43 func Storeuintptr(ptr *uintptr, new uintptr) { 44 storeuintptr(ptr, new) 45 } 46 47 //go:noescape 48 //go:linkname storeuintptr runtime.internal.atomic.Storeuintptr 49 func storeuintptr(ptr *uintptr, new uintptr) 50 51 func Loaduintptr(ptr *uintptr) uintptr { 52 return loaduintptr(ptr) 53 } 54 55 //go:noescape 56 //go:linkname loaduintptr runtime.internal.atomic.Loaduintptr 57 func loaduintptr(ptr *uintptr) uintptr 58 59 func Loaduint(ptr *uint) uint { 60 return loaduint(ptr) 61 } 62 63 //go:noescape 64 //go:linkname loaduint runtime.internal.atomic.Loaduint 65 func loaduint(ptr *uint) uint 66 67 func Loadint64(ptr *int64) int64 { 68 return loadint64(ptr) 69 } 70 71 //go:noescape 72 //go:linkname loadint64 runtime.internal.atomic.Loadint64 73 func loadint64(ptr *int64) int64 74 75 func Fastrand() uint32 { 76 return fastrand() 77 } 78 79 //go:linkname fastrand runtime.fastrand 80 func fastrand() uint32 81 82 func Throw(s string) { 83 throw(s) 84 } 85 86 //go:linkname throw runtime.throw 87 func throw(s string) 88 89 func Newarray(typ *Type, n int) unsafe.Pointer { 90 return newarray(typ, n) 91 } 92 93 //go:linkname newarray runtime.newarray 94 func newarray(typ *Type, n int) unsafe.Pointer 95 96 func Newobject(typ *Type) unsafe.Pointer { 97 return mallocgc(typ.Size, typ, true) 98 } 99 100 //go:linkname mallocgc runtime.mallocgc 101 func mallocgc(size uintptr, typ *Type, needzero bool) unsafe.Pointer 102 103 func Typedmemmove(typ *Type, dst, src unsafe.Pointer) { 104 typedmemmove(typ, dst, src) 105 } 106 107 //go:linkname typedmemmove runtime.typedmemmove 108 func typedmemmove(typ *Type, dst, src unsafe.Pointer) 109 110 func Typedmemclr(typ *Type, ptr unsafe.Pointer) { 111 typedmemclr(typ, ptr) 112 } 113 114 //go:linkname typedmemclr runtime.typedmemclr 115 func typedmemclr(typ *Type, ptr unsafe.Pointer) 116 117 func Lock(l *Mutex) { 118 lock(l) 119 } 120 121 //go:linkname lock runtime.lock 122 func lock(l *Mutex) 123 124 func Unlock(l *Mutex) { 125 unlock(l) 126 } 127 128 //go:linkname unlock runtime.unlock 129 func unlock(l *Mutex) 130 131 func Msanread(addr unsafe.Pointer, sz uintptr) { 132 msanread(addr, sz) 133 } 134 135 //go:linkname msanread runtime.msanread 136 func msanread(addr unsafe.Pointer, sz uintptr) 137 138 func MemclrHasPointers(ptr unsafe.Pointer, n uintptr) { 139 memclrHasPointers(ptr, n) 140 } 141 142 //go:linkname memclrHasPointers runtime.memclrHasPointers 143 func memclrHasPointers(ptr unsafe.Pointer, n uintptr) 144 145 //go:linkname Hex runtime.hex 146 type Hex uint64 147 148 func MemclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) { 149 memclrNoHeapPointers(ptr, n) 150 } 151 152 //go:linkname memclrNoHeapPointers runtime.memclrNoHeapPointers 153 func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) 154 155 func Noescape(p unsafe.Pointer) unsafe.Pointer { 156 return noescape(p) 157 } 158 159 //go:linkname noescape runtime.noescape 160 func noescape(p unsafe.Pointer) unsafe.Pointer 161 162 func Xaddint64(ptr *int64, delta int64) int64 { 163 return xaddint64(ptr, delta) 164 } 165 166 //go:noescape 167 //go:linkname xaddint64 runtime.internal.atomic.Xaddint64 168 func xaddint64(ptr *int64, delta int64) int64 169 170 func Encoderune(p []byte, r rune) int { 171 return encoderune(p, r) 172 } 173 174 //go:linkname encoderune runtime.encoderune 175 func encoderune(p []byte, r rune) int 176 177 func Rawstring(size int) (s string, b []byte) { 178 return rawstring(size) 179 } 180 181 //go:linkname rawstring runtime.rawstring 182 func rawstring(size int) (s string, b []byte) 183 184 const ( 185 //go:linkname GOOS runtime.internal.sys.GOOS 186 GOOS = `unknown` 187 188 //go:linkname GoosAndroid runtime.internal.sys.GoosAndroid 189 GoosAndroid uint = 0 190 //go:linkname GoosDarwin runtime.internal.sys.GoosDarwin 191 GoosDarwin uint = 0 192 //go:linkname GoosDragonfly runtime.internal.sys.GoosDragonfly 193 GoosDragonfly uint = 0 194 //go:linkname GoosFreebsd runtime.internal.sys.GoosFreebsd 195 GoosFreebsd uint = 0 196 //go:linkname GoosLinux runtime.internal.sys.GoosLinux 197 GoosLinux uint = 0 198 //go:linkname GoosNacl runtime.internal.sys.GoosNacl 199 GoosNacl uint = 0 200 //go:linkname GoosNetbsd runtime.internal.sys.GoosNetbsd 201 GoosNetbsd uint = 0 202 //go:linkname GoosOpenbsd runtime.internal.sys.GoosOpenbsd 203 GoosOpenbsd uint = 0 204 //go:linkname GoosPlan9 runtime.internal.sys.GoosPlan9 205 GoosPlan9 uint = 0 206 //go:linkname GoosSolaris runtime.internal.sys.GoosSolaris 207 GoosSolaris uint = 0 208 //go:linkname GoosWindows runtime.internal.sys.GoosWindows 209 GoosWindows uint = 0 210 211 //go:linkname Goarch386 runtime.internal.sys.Goarch386 212 Goarch386 uint = 0 213 //go:linkname GoarchAmd64 runtime.internal.sys.GoarchAmd64 214 GoarchAmd64 uint = 0 215 //go:linkname GoarchAmd64p32 runtime.internal.sys.GoarchAmd64p32 216 GoarchAmd64p32 uint = 0 217 //go:linkname GoarchArm runtime.internal.sys.GoarchArm 218 GoarchArm uint = 0 219 //go:linkname GoarchArmbe runtime.internal.sys.GoarchArmbe 220 GoarchArmbe uint = 0 221 //go:linkname GoarchArm64 runtime.internal.sys.GoarchArm64 222 GoarchArm64 uint = 0 223 //go:linkname GoarchArm64be runtime.internal.sys.GoarchArm64be 224 GoarchArm64be uint = 0 225 //go:linkname GoarchPpc64 runtime.internal.sys.GoarchPpc64 226 GoarchPpc64 uint = 0 227 //go:linkname GoarchPpc64le runtime.internal.sys.GoarchPpc64le 228 GoarchPpc64le uint = 0 229 //go:linkname GoarchMips runtime.internal.sys.GoarchMips 230 GoarchMips uint = 0 231 //go:linkname GoarchMipsle runtime.internal.sys.GoarchMipsle 232 GoarchMipsle uint = 0 233 //go:linkname GoarchMips64 runtime.internal.sys.GoarchMips64 234 GoarchMips64 uint = 0 235 //go:linkname GoarchMips64le runtime.internal.sys.GoarchMips64le 236 GoarchMips64le uint = 0 237 //go:linkname GoarchMips64p32 runtime.internal.sys.GoarchMips64p32 238 GoarchMips64p32 uint = 0 239 //go:linkname GoarchMips64p32le runtime.internal.sys.GoarchMips64p32le 240 GoarchMips64p32le uint = 0 241 //go:linkname GoarchPpc runtime.internal.sys.GoarchPpc 242 GoarchPpc uint = 0 243 //go:linkname GoarchS390 runtime.internal.sys.GoarchS390 244 GoarchS390 uint = 0 245 //go:linkname GoarchS390x runtime.internal.sys.GoarchS390x 246 GoarchS390x uint = 0 247 //go:linkname GoarchSparc runtime.internal.sys.GoarchSparc 248 GoarchSparc uint = 0 249 //go:linkname GoarchSparc64 runtime.internal.sys.GoarchSparc64 250 GoarchSparc64 uint = 0 251 )