Subject: [PATCH] _syscall macros

From: Jun Sun <[email-masked]>
Date: Wed, 9 Jul 2003 15:56:54 -0700

In testing some new syscalls, I found that the current 
_syscall macros do not return the right errno.  A little
further probing shows that errno now is a function call,
and on returning from the call original __v0 from syscall
is corrupted.

Here is a patch to fix this.  Looks good?

Jun
diff -Nru link/include/asm-mips/unistd.h.orig link/include/asm-mips/unistd.h
--- link/include/asm-mips/unistd.h.orig	Thu Nov  7 14:05:44 2002
+++ link/include/asm-mips/unistd.h	Wed Jul  9 15:42:32 2003
@@ -276,7 +276,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -302,7 +302,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -325,7 +325,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -349,7 +349,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -373,7 +373,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -406,7 +406,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -437,7 +437,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -471,7 +471,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
diff -Nru link/include/asm-mips64/unistd.h.orig link/include/asm-mips64/unistd.h
--- link/include/asm-mips64/unistd.h.orig	Wed Apr  9 14:40:24 2003
+++ link/include/asm-mips64/unistd.h	Wed Jul  9 15:43:11 2003
@@ -729,7 +729,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -755,7 +755,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -778,7 +778,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -802,7 +802,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -826,7 +826,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -853,7 +853,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -884,7 +884,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -916,7 +916,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -951,7 +951,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -982,7 +982,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }
 
@@ -1016,7 +1016,7 @@
 	\
 	if (__a3 == 0) \
 		return (type) __v0; \
-	errno = __v0; \
+	{ int ret = __v0; errno = ret; } \
 	return -1; \
 }