unix: use SyscallNoError and RawSyscallNoError on Linux only

The SyscallNoError and RawSyscallNoError functions are only needed on
Linux. Make sure they are not used within the generated zsyscall_*.go
files if $GOOS != "linux".

Updates golang/go#22924

Change-Id: I3b2aa8624895b0527dcc832b2945a8d591f0ba1a
Reviewed-on: https://go-review.googlesource.com/90475
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/unix/mksyscall.pl b/unix/mksyscall.pl
index 73e26ca..1f6b926 100755
--- a/unix/mksyscall.pl
+++ b/unix/mksyscall.pl
@@ -210,13 +210,13 @@
 	# Determine which form to use; pad args with zeros.
 	my $asm = "Syscall";
 	if ($nonblock) {
-		if ($errvar ne "") {
-			$asm = "RawSyscall";
-		} else {
+		if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
 			$asm = "RawSyscallNoError";
+		} else {
+			$asm = "RawSyscall";
 		}
 	} else {
-		if ($errvar eq "") {
+		if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
 			$asm = "SyscallNoError";
 		}
 	}
@@ -292,10 +292,11 @@
 	if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
 		$text .= "\t$call\n";
 	} else {
-		if ($errvar ne "") {
-			$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
-		} else {
+		if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
+			# raw syscall without error on Linux, see golang.org/issue/22924
 			$text .= "\t$ret[0], $ret[1] := $call\n";
+		} else {
+			$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
 		}
 	}
 	$text .= $body;