1
0
mirror of https://github.com/golang/go synced 2024-11-25 13:07:57 -07:00

cmd/cgo: fix handling of errno for gccgo

Fixes #3332.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5868047
This commit is contained in:
Ian Lance Taylor 2012-03-21 10:38:58 -07:00
parent 0532f4d382
commit 3a3c5aad4e

View File

@ -284,8 +284,13 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name) {
} }
conf.Fprint(fgo2, fset, d) conf.Fprint(fgo2, fset, d)
fmt.Fprintf(fgo2, "{\n") 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, "\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") fmt.Fprintf(fgo2, "}\n")
// declare the C function. // declare the C function.
fmt.Fprintf(fgo2, "//extern %s\n", n.C) fmt.Fprintf(fgo2, "//extern %s\n", n.C)