github.com/primecitizens/pcz/std@v0.2.1/core/race/race.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2012 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 package race 9 10 import ( 11 "unsafe" 12 13 "github.com/primecitizens/pcz/std/core/abi" 14 "github.com/primecitizens/pcz/std/core/assert" 15 ) 16 17 // TODO 18 19 // runtime.raceinit 20 func Init() (uintptr, uintptr) { 21 if Enabled { 22 assert.TODO() 23 } 24 25 return 0, 0 26 } 27 28 // runtime.racefini 29 func Fini() { 30 if Enabled { 31 assert.TODO() 32 } 33 } 34 35 // runtime.raceproccreate 36 func ProcCreate() uintptr { 37 if Enabled { 38 assert.TODO() 39 } 40 41 return 0 42 } 43 44 // runtime.raceprocdestroy 45 func ProcDestroy(ctx uintptr) { 46 if Enabled { 47 assert.TODO() 48 } 49 } 50 51 // runtime.racefuncenter 52 func FuncEnter(pc uintptr) { 53 if Enabled { 54 assert.TODO() 55 } 56 } 57 58 // runtime.racefuncenterfp 59 func FuncEnterFP(fp uintptr) { 60 if Enabled { 61 assert.TODO() 62 } 63 } 64 65 // runtime.racefuncexit 66 func FuncExit() { 67 if Enabled { 68 assert.TODO() 69 } 70 } 71 72 // runtime.racemapshadow 73 func MapShadow(addr unsafe.Pointer, size uintptr) { 74 if Enabled { 75 assert.TODO() 76 } 77 } 78 func Read(p unsafe.Pointer) { 79 if Enabled { 80 assert.TODO() 81 } 82 } 83 84 // runtime.racereadrange 85 func ReadRange(addr unsafe.Pointer, size uintptr) { 86 if Enabled { 87 assert.TODO() 88 } 89 } 90 91 // runtime.racereadpc 92 func ReadPC(addr unsafe.Pointer, callpc, pc uintptr) { 93 if Enabled { 94 assert.TODO() 95 } 96 } 97 98 // runtime.racereadrangepc 99 func ReadRangePC(addr unsafe.Pointer, sz, callerpc, pc uintptr) { 100 if Enabled { 101 assert.TODO() 102 } 103 } 104 105 // runtime.raceReadObjectPC 106 // 107 // For all functions accepting callerpc and pc, 108 // callerpc is a return PC of the function that calls this function, 109 // pc is start PC of the function that calls this function. 110 func ReadObjectPC(t *abi.Type, addr unsafe.Pointer, callerpc, pc uintptr) { 111 switch t.Kind() { 112 case abi.KindArray, abi.KindStruct: 113 // for composite objects we have to read every address 114 // because a write might happen to any subobject. 115 ReadRangePC(addr, t.Size_, callerpc, pc) 116 default: 117 // for non-composite objects we can read just the start 118 // address, as any write must write the first byte. 119 ReadPC(addr, callerpc, pc) 120 } 121 } 122 123 // runtime.racewrite 124 func Write(p unsafe.Pointer) { 125 if Enabled { 126 assert.TODO() 127 } 128 } 129 130 // runtime.racewriterange 131 func WriteRange(addr unsafe.Pointer, size uintptr) { 132 if Enabled { 133 assert.TODO() 134 } 135 } 136 137 // runtime.racewritepc 138 func WritePC(addr unsafe.Pointer, callpc, pc uintptr) { 139 if Enabled { 140 assert.TODO() 141 } 142 } 143 144 // runtime.racewriterangepc 145 func WriteRangePC(addr unsafe.Pointer, sz, callerpc, pc uintptr) { 146 if Enabled { 147 assert.TODO() 148 } 149 } 150 151 // runtime.raceWriteObjectPC 152 func WriteObjectPC(t *abi.Type, addr unsafe.Pointer, callerpc, pc uintptr) { 153 switch t.Kind() { 154 case abi.KindArray, abi.KindStruct: 155 // for composite objects we have to write every address 156 // because a write might happen to any subobject. 157 WriteRangePC(addr, t.Size_, callerpc, pc) 158 default: 159 // for non-composite objects we can write just the start 160 // address, as any write must write the first byte. 161 WritePC(addr, callerpc, pc) 162 } 163 } 164 165 // runtime.raceacquire 166 func Acquire(addr unsafe.Pointer) { 167 if Enabled { 168 assert.TODO() 169 } 170 } 171 172 // runtime.raceacquirectx 173 func AcquireCtx(racectx uintptr, addr unsafe.Pointer) { 174 if Enabled { 175 assert.TODO() 176 } 177 } 178 179 // runtime.racerelease 180 func Release(addr unsafe.Pointer) { 181 if Enabled { 182 assert.TODO() 183 } 184 } 185 186 // runtime.racereleaseacquire 187 func ReleaseAcquire(addr unsafe.Pointer) { 188 if Enabled { 189 assert.TODO() 190 } 191 } 192 193 // runtime.releasemerge 194 func ReleaseMerge(addr unsafe.Pointer) { 195 if Enabled { 196 assert.TODO() 197 } 198 } 199 200 // runtime.racemalloc 201 func Malloc(p unsafe.Pointer, sz uintptr) { 202 if Enabled { 203 assert.TODO() 204 } 205 } 206 207 // runtime.racefree 208 func Free(p unsafe.Pointer, sz uintptr) { 209 if Enabled { 210 assert.TODO() 211 } 212 } 213 214 // runtime.racefingo 215 func Fingo() { 216 if Enabled { 217 assert.TODO() 218 } 219 } 220 221 // runtime.racegostart 222 func Gostart(pc uintptr) uintptr { 223 if Enabled { 224 assert.TODO() 225 } 226 return 0 227 } 228 229 // runtime.racegoend 230 func Goend() { 231 if Enabled { 232 assert.TODO() 233 } 234 } 235 236 // runtime.racectxend 237 func Ctxend(racectx uintptr) { 238 if Enabled { 239 assert.TODO() 240 } 241 }