Commit 3a3c5aad authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/cgo: fix handling of errno for gccgo

Fixes #3332.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5868047
parent 0532f4d3
......@@ -284,8 +284,13 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name) {
}
conf.Fprint(fgo2, fset, d)
fmt.Fprintf(fgo2, "{\n")
fmt.Fprintf(fgo2, "\tsyscall.SetErrno(0)\n")
fmt.Fprintf(fgo2, "\tr := %s(%s)\n", cname, strings.Join(paramnames, ", "))
fmt.Fprintf(fgo2, "\treturn r, syscall.GetErrno()\n")
fmt.Fprintf(fgo2, "\te := syscall.GetErrno()\n")
fmt.Fprintf(fgo2, "\tif e != 0 {\n")
fmt.Fprintf(fgo2, "\t\treturn r, e\n")
fmt.Fprintf(fgo2, "\t}\n")
fmt.Fprintf(fgo2, "\treturn r, nil\n")
fmt.Fprintf(fgo2, "}\n")
// declare the C function.
fmt.Fprintf(fgo2, "//extern %s\n", n.C)
......
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