Example #1
0
func StoreUintptr(addr *uintptr, val uintptr) {
	runtime.RaceSemacquire(&mtx)
	runtime.RaceRead(unsafe.Pointer(addr))
	*addr = val
	runtime.RaceRelease(unsafe.Pointer(addr))
	runtime.RaceSemrelease(&mtx)
}
Example #2
0
func LoadUintptr(addr *uintptr) (val uintptr) {
	runtime.RaceSemacquire(&mtx)
	runtime.RaceRead(unsafe.Pointer(addr))
	runtime.RaceAcquire(unsafe.Pointer(addr))
	val = *addr
	runtime.RaceSemrelease(&mtx)
	return
}
Example #3
0
File: race.go Project: h8liu/golang
func StorePointer(addr *unsafe.Pointer, val unsafe.Pointer) {
	_ = *addr
	runtime.RaceSemacquire(&mtx)
	runtime.RaceRead(unsafe.Pointer(addr))
	*addr = val
	runtime.RaceRelease(unsafe.Pointer(addr))
	runtime.RaceSemrelease(&mtx)
}
Example #4
0
func AddUint32(val *uint32, delta uint32) (new uint32) {
	runtime.RaceSemacquire(&mtx)
	runtime.RaceRead(unsafe.Pointer(val))
	runtime.RaceAcquire(unsafe.Pointer(val))
	*val = *val + delta
	new = *val
	runtime.RaceReleaseMerge(unsafe.Pointer(val))
	runtime.RaceSemrelease(&mtx)

	return
}
Example #5
0
File: race.go Project: h8liu/golang
func SwapPointer(addr *unsafe.Pointer, new unsafe.Pointer) (old unsafe.Pointer) {
	_ = *addr
	runtime.RaceSemacquire(&mtx)
	runtime.RaceRead(unsafe.Pointer(addr))
	runtime.RaceAcquire(unsafe.Pointer(addr))
	old = *addr
	*addr = new
	runtime.RaceReleaseMerge(unsafe.Pointer(addr))
	runtime.RaceSemrelease(&mtx)
	return
}
Example #6
0
func CompareAndSwapUintptr(val *uintptr, old, new uintptr) (swapped bool) {
	swapped = false
	runtime.RaceSemacquire(&mtx)
	runtime.RaceRead(unsafe.Pointer(val))
	runtime.RaceAcquire(unsafe.Pointer(val))
	if *val == old {
		*val = new
		swapped = true
		runtime.RaceReleaseMerge(unsafe.Pointer(val))
	}
	runtime.RaceSemrelease(&mtx)
	return
}
Example #7
0
func Read(addr unsafe.Pointer) {
	runtime.RaceRead(addr)
}