OSDN Git Service

syscall: Convert errno to error after Exitsyscall.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Mar 2012 21:10:47 +0000 (21:10 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 Mar 2012 21:10:47 +0000 (21:10 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186021 138bc75d-0d04-0410-961f-82ee72b054a4

libgo/go/syscall/mksyscall.awk

index 5e30e86..b817960 100644 (file)
@@ -199,6 +199,7 @@ BEGIN {
     }
     printf("c_%s(%s)\n", cfnname, args)
 
+    seterr = 0
     if (gofnresults != "") {
        fields = split(gofnresults, goresults, ", *")
        if (fields > 2) {
@@ -218,13 +219,17 @@ BEGIN {
            gotype = goparam[2]
 
            if (goname == "err") {
+               print "\tvar errno Errno"
+               print "\tsetErrno := false"
                if (cfnresult ~ /^\*/) {
                    print "\tif _r == nil {"
                } else {
                    print "\tif _r < 0 {"
                }
-               print "\t\terr = GetErrno()"
+               print "\t\terrno = GetErrno()"
+               print "\t\tsetErrno = true"
                print "\t}"
+               seterr = 1
            } else if (gotype == "uintptr" && cfnresult ~ /^\*/) {
                printf("\t%s = (%s)(unsafe.Pointer(_r))\n", goname, gotype)
            } else {
@@ -243,6 +248,12 @@ BEGIN {
        print "\tExitsyscall()"
     }
 
+    if (seterr) {
+       print "\tif setErrno {"
+       print "\t\terr = errno"
+       print "\t}"
+    }
+
     if (gofnresults != "") {
        print "\treturn"
     }