patch-2.1.1 linux/include/asm-i386/unistd.h
Next file: linux/include/linux/icmp.h
Previous file: linux/include/asm-i386/stat.h
Back to the patch index
Back to the overall index
- Lines: 90
- Date:
Thu Oct 3 11:23:15 1996
- Orig file:
v2.1.0/linux/include/asm-i386/unistd.h
- Orig date:
Fri Mar 22 08:34:02 1996
diff -u --recursive --new-file v2.1.0/linux/include/asm-i386/unistd.h linux/include/asm-i386/unistd.h
@@ -170,6 +170,17 @@
#define __NR_nanosleep 162
#define __NR_mremap 163
+/* user-visible error numbers are in the range -1 - -122: see <asm-i386/errno.h> */
+
+#define __syscall_return(type, res) \
+do { \
+ if ((unsigned long)(res) >= (unsigned long)(-125)) { \
+ errno = -(res); \
+ res = -1; \
+ } \
+ return (type) (res); \
+} while (0)
+
/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
#define _syscall0(type,name) \
type name(void) \
@@ -178,10 +189,7 @@
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name)); \
-if (__res >= 0) \
- return (type) __res; \
-errno = -__res; \
-return -1; \
+__syscall_return(type,__res); \
}
#define _syscall1(type,name,type1,arg1) \
@@ -191,10 +199,7 @@
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(arg1))); \
-if (__res >= 0) \
- return (type) __res; \
-errno = -__res; \
-return -1; \
+__syscall_return(type,__res); \
}
#define _syscall2(type,name,type1,arg1,type2,arg2) \
@@ -204,10 +209,7 @@
__asm__ volatile ("int $0x80" \
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2))); \
-if (__res >= 0) \
- return (type) __res; \
-errno = -__res; \
-return -1; \
+__syscall_return(type,__res); \
}
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
@@ -218,10 +220,7 @@
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3))); \
-if (__res>=0) \
- return (type) __res; \
-errno=-__res; \
-return -1; \
+__syscall_return(type,__res); \
}
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
@@ -232,10 +231,7 @@
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4))); \
-if (__res>=0) \
- return (type) __res; \
-errno=-__res; \
-return -1; \
+__syscall_return(type,__res); \
}
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
@@ -247,10 +243,7 @@
: "=a" (__res) \
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
-if (__res>=0) \
- return (type) __res; \
-errno=-__res; \
-return -1; \
+__syscall_return(type,__res); \
}
#ifdef __KERNEL_SYSCALLS__
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov