Commit 99b6e9f7 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

race: cmd/cgo changes

This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
This change breaks circular dependency between runtime/race and syscall packages.

R=rsc
CC=golang-dev
https://golang.org/cl/6498079
parent 0e60019a
......@@ -147,6 +147,7 @@ var gccgo = flag.Bool("gccgo", false, "generate files for use with gccgo")
var gccgoprefix = flag.String("gccgoprefix", "", "-fgo-prefix option used with gccgo")
var gccgopkgpath = flag.String("gccgopkgpath", "", "-fgo-pkgpath option used with gccgo")
var importRuntimeCgo = flag.Bool("import_runtime_cgo", true, "import runtime/cgo in generated code")
var importSyscall = flag.Bool("import_syscall", true, "import syscall in generated code")
var goarch, goos string
func main() {
......
......@@ -51,12 +51,16 @@ func (p *Package) writeDefs() {
fmt.Fprintf(fgo2, "// Created by cgo - DO NOT EDIT\n\n")
fmt.Fprintf(fgo2, "package %s\n\n", p.PackageName)
fmt.Fprintf(fgo2, "import \"unsafe\"\n\n")
fmt.Fprintf(fgo2, "import \"syscall\"\n\n")
if *importSyscall {
fmt.Fprintf(fgo2, "import \"syscall\"\n\n")
}
if !*gccgo && *importRuntimeCgo {
fmt.Fprintf(fgo2, "import _ \"runtime/cgo\"\n\n")
}
fmt.Fprintf(fgo2, "type _ unsafe.Pointer\n\n")
fmt.Fprintf(fgo2, "func _Cerrno(dst *error, x int) { *dst = syscall.Errno(x) }\n")
if *importSyscall {
fmt.Fprintf(fgo2, "func _Cerrno(dst *error, x int) { *dst = syscall.Errno(x) }\n")
}
typedefNames := make([]string, 0, len(typedef))
for name := range typedef {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment