mirror of
https://github.com/golang/go
synced 2024-10-05 14:01:21 -06:00
0c1f0549b8
The memory sanitizer (msan) is a nice compiler feature that can dynamically check for memory errors in C code. It's not useful for Go code, since Go is memory safe. But it is useful to be able to use the memory sanitizer on C code that is linked into a Go program via cgo. Without this change it does not work, as msan considers memory passed from Go to C as uninitialized. To make this work, change the runtime to call the C mmap function when using cgo. When using msan the mmap call will be intercepted and marked as returning initialized memory. Work around what appears to be an msan bug by calling malloc before we call mmap. Change-Id: I8ab7286d7595ae84782f68a98bef6d3688b946f9 Reviewed-on: https://go-review.googlesource.com/15170 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
30 lines
654 B
Go
30 lines
654 B
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build !plan9
|
|
// +build !solaris
|
|
// +build !windows
|
|
// +build !nacl
|
|
|
|
package runtime
|
|
|
|
import "unsafe"
|
|
|
|
func read(fd int32, p unsafe.Pointer, n int32) int32
|
|
func closefd(fd int32) int32
|
|
|
|
func exit(code int32)
|
|
func nanotime() int64
|
|
func usleep(usec uint32)
|
|
|
|
func munmap(addr unsafe.Pointer, n uintptr)
|
|
|
|
//go:noescape
|
|
func write(fd uintptr, p unsafe.Pointer, n int32) int32
|
|
|
|
//go:noescape
|
|
func open(name *byte, mode, perm int32) int32
|
|
|
|
func madvise(addr unsafe.Pointer, n uintptr, flags int32)
|