github.com/eh-steve/goloader@v0.0.0-20240111193454-90ff3cfdae39/iface.go (about) 1 package goloader 2 3 import "unsafe" 4 5 // Mutual exclusion locks. In the uncontended case, 6 // as fast as spin locks (just a few user-level instructions), 7 // but on the contention path they sleep in the kernel. 8 // A zeroed Mutex is unlocked (no need to initialize each lock). 9 type mutex struct { 10 // Futex-based impl treats it as uint32 key, 11 // while sema-based impl as M* waitm. 12 // Used to be a union, but unions break precise GC. 13 key uintptr 14 } 15 16 //go:linkname lock runtime.lock 17 func lock(l *mutex) 18 19 //go:linkname unlock runtime.unlock 20 func unlock(l *mutex) 21 22 //go:linkname atomicstorep runtime.atomicstorep 23 func atomicstorep(ptr unsafe.Pointer, new unsafe.Pointer)