diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:23:02 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:23:02 +0200 |
commit | 8fcc691d6fa80c9ddf38bf0d34b803bab0e421d5 (patch) | |
tree | ba71646a10b518372d110532d86fcf0b98edc14f /src/pkg/runtime/race/race.go | |
parent | 3bb719bbf3cdb97b3901f3baaa2da9d02a5c3cdb (diff) | |
parent | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (diff) | |
download | golang-8fcc691d6fa80c9ddf38bf0d34b803bab0e421d5.tar.gz |
Merge tag 'upstream/1.3' into debian-sid
Upstream version 1.3
Diffstat (limited to 'src/pkg/runtime/race/race.go')
-rw-r--r-- | src/pkg/runtime/race/race.go | 118 |
1 files changed, 6 insertions, 112 deletions
diff --git a/src/pkg/runtime/race/race.go b/src/pkg/runtime/race/race.go index 5b44bde83..e53cacf4a 100644 --- a/src/pkg/runtime/race/race.go +++ b/src/pkg/runtime/race/race.go @@ -6,116 +6,10 @@ package race -/* -void __tsan_init(void **racectx); -void __tsan_fini(void); -void __tsan_map_shadow(void *addr, void *size); -void __tsan_go_start(void *racectx, void **chracectx, void *pc); -void __tsan_go_end(void *racectx); -void __tsan_read(void *racectx, void *addr, void *pc); -void __tsan_write(void *racectx, void *addr, void *pc); -void __tsan_read_range(void *racectx, void *addr, long sz, long step, void *pc); -void __tsan_write_range(void *racectx, void *addr, long sz, long step, void *pc); -void __tsan_func_enter(void *racectx, void *pc); -void __tsan_func_exit(void *racectx); -void __tsan_malloc(void *racectx, void *p, long sz, void *pc); -void __tsan_free(void *p); -void __tsan_acquire(void *racectx, void *addr); -void __tsan_release(void *racectx, void *addr); -void __tsan_release_merge(void *racectx, void *addr); -void __tsan_finalizer_goroutine(void *racectx); -*/ -import "C" - -import ( - "runtime" - "unsafe" -) - -func Initialize(racectx *uintptr) { - C.__tsan_init((*unsafe.Pointer)(unsafe.Pointer(racectx))) -} - -func Finalize() { - C.__tsan_fini() -} - -func MapShadow(addr, size uintptr) { - C.__tsan_map_shadow(unsafe.Pointer(addr), unsafe.Pointer(size)) -} - -func FinalizerGoroutine(racectx uintptr) { - C.__tsan_finalizer_goroutine(unsafe.Pointer(racectx)) -} - -func Read(racectx uintptr, addr, pc uintptr) { - C.__tsan_read(unsafe.Pointer(racectx), unsafe.Pointer(addr), unsafe.Pointer(pc)) -} - -func Write(racectx uintptr, addr, pc uintptr) { - C.__tsan_write(unsafe.Pointer(racectx), unsafe.Pointer(addr), unsafe.Pointer(pc)) -} - -func ReadRange(racectx uintptr, addr, sz, pc uintptr) { - C.__tsan_read_range(unsafe.Pointer(racectx), unsafe.Pointer(addr), - C.long(sz), 0 /*step is unused*/, unsafe.Pointer(pc)) -} - -func WriteRange(racectx uintptr, addr, sz, pc uintptr) { - C.__tsan_write_range(unsafe.Pointer(racectx), unsafe.Pointer(addr), - C.long(sz), 0 /*step is unused*/, unsafe.Pointer(pc)) -} +// This file merely ensures that we link in runtime/cgo in race build, +// this is turn ensures that runtime uses pthread_create to create threads. +// The prebuilt race runtime lives in race_GOOS_GOARCH.syso. +// Calls to the runtime are done directly from src/pkg/runtime/race.c. -func FuncEnter(racectx uintptr, pc uintptr) { - C.__tsan_func_enter(unsafe.Pointer(racectx), unsafe.Pointer(pc)) -} - -func FuncExit(racectx uintptr) { - C.__tsan_func_exit(unsafe.Pointer(racectx)) -} - -func Malloc(racectx uintptr, p, sz, pc uintptr) { - C.__tsan_malloc(unsafe.Pointer(racectx), unsafe.Pointer(p), C.long(sz), unsafe.Pointer(pc)) -} - -func Free(p uintptr) { - C.__tsan_free(unsafe.Pointer(p)) -} - -func GoStart(racectx uintptr, chracectx *uintptr, pc uintptr) { - C.__tsan_go_start(unsafe.Pointer(racectx), (*unsafe.Pointer)(unsafe.Pointer(chracectx)), unsafe.Pointer(pc)) -} - -func GoEnd(racectx uintptr) { - C.__tsan_go_end(unsafe.Pointer(racectx)) -} - -func Acquire(racectx uintptr, addr uintptr) { - C.__tsan_acquire(unsafe.Pointer(racectx), unsafe.Pointer(addr)) -} - -func Release(racectx uintptr, addr uintptr) { - C.__tsan_release(unsafe.Pointer(racectx), unsafe.Pointer(addr)) -} - -func ReleaseMerge(racectx uintptr, addr uintptr) { - C.__tsan_release_merge(unsafe.Pointer(racectx), unsafe.Pointer(addr)) -} - -//export __tsan_symbolize -func __tsan_symbolize(pc uintptr, fun, file **C.char, line, off *C.int) C.int { - f := runtime.FuncForPC(pc) - if f == nil { - *fun = C.CString("??") - *file = C.CString("-") - *line = 0 - *off = C.int(pc) - return 1 - } - fi, l := f.FileLine(pc) - *fun = C.CString(f.Name()) - *file = C.CString(fi) - *line = C.int(l) - *off = C.int(pc - f.Entry()) - return 1 -} +// void __race_unused_func(void); +import "C" |