Browse Source

Changes needed to build the ldso dir for m68k. I haven't tested it,
who knows if it will work, it just compiles cleanly :-)

David McCullough 24 years ago
parent
commit
e9499a8a60

+ 1 - 1
ldso/ldso/boot1.c

@@ -92,10 +92,10 @@
  */
  */
 
 
 #include <stdarg.h>
 #include <stdarg.h>
+#include "sysdep.h" /* before elf.h to get ELF_USES_RELOCA right */
 #include <elf.h>
 #include <elf.h>
 #include "linuxelf.h"
 #include "linuxelf.h"
 #include "link.h"
 #include "link.h"
-#include "sysdep.h"
 #include "hash.h"
 #include "hash.h"
 #include "syscall.h"
 #include "syscall.h"
 #include "string.h"
 #include "string.h"

+ 1 - 1
ldso/ldso/ld-uClibc.c

@@ -92,10 +92,10 @@
  */
  */
 
 
 #include <stdarg.h>
 #include <stdarg.h>
+#include "sysdep.h" /* before elf.h to get ELF_USES_RELOCA right */
 #include <elf.h>
 #include <elf.h>
 #include "linuxelf.h"
 #include "linuxelf.h"
 #include "link.h"
 #include "link.h"
-#include "sysdep.h"
 #include "hash.h"
 #include "hash.h"
 #include "syscall.h"
 #include "syscall.h"
 #include "string.h"
 #include "string.h"

+ 1 - 1
ldso/ldso/ldso.c

@@ -92,10 +92,10 @@
  */
  */
 
 
 #include <stdarg.h>
 #include <stdarg.h>
+#include "sysdep.h" /* before elf.h to get ELF_USES_RELOCA right */
 #include <elf.h>
 #include <elf.h>
 #include "linuxelf.h"
 #include "linuxelf.h"
 #include "link.h"
 #include "link.h"
-#include "sysdep.h"
 #include "hash.h"
 #include "hash.h"
 #include "syscall.h"
 #include "syscall.h"
 #include "string.h"
 #include "string.h"

+ 131 - 74
ldso/ldso/m68k/dl-syscalls.h

@@ -1,12 +1,20 @@
 #include <asm/unistd.h>
 #include <asm/unistd.h>
 
 
+#undef __syscall_return
+#undef _syscall0
+#undef _syscall1
+#undef _syscall2
+#undef _syscall3
+#undef _syscall4
+#undef _syscall5
+
 /* Here are the macros which define how this platform makes
 /* Here are the macros which define how this platform makes
  * system calls.  This particular variant does _not_ set 
  * system calls.  This particular variant does _not_ set 
  * errno (note how it is disabled in __syscall_return) since
  * errno (note how it is disabled in __syscall_return) since
  * these will get called before the errno symbol is dynamicly 
  * these will get called before the errno symbol is dynamicly 
  * linked. */
  * linked. */
 
 
-#undef __syscall_return
+
 #define __syscall_return(type, res) \
 #define __syscall_return(type, res) \
 do { \
 do { \
 	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
 	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
@@ -19,88 +27,137 @@ do { \
 	return (type) (res); \
 	return (type) (res); \
 } while (0)
 } while (0)
 
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-__asm__ __volatile__ ("trap  #0" \
-                      : "=g" (__res) \
-		      : "0" (__res) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall0(type, name)						\
+type name(void)								\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name)				\
+			: "cc", "%d0");					\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-		      : "0" (__res), "d" (__a) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall1(type, name, atype, a)					\
+type name(atype a)							\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%2, %%d1\n\t"				\
+  			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "g" ((long)a)					\
+			: "cc", "%d0", "%d1");				\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a,btype b) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall2(type, name, atype, a, btype, b)			\
+type name(atype a, btype b)						\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "g" ((long)b)					\
+			: "cc", "%d0", "%d1", "%d2");			\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a,btype b,ctype c) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall3(type, name, atype, a, btype, b, ctype, c)		\
+type name(atype a, btype b, ctype c)					\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "g" ((long)c)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3");		\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name (atype a, btype b, ctype c, dtype d) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-__asm__ __volatile__ ("trap  #0" \
-                      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d)  \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)	\
+type name(atype a, btype b, ctype c, dtype d)				\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%5, %%d4\n\t"				\
+			"movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "a" ((long)c),				\
+			  "g" ((long)d)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3",		\
+			  "%d4");					\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-register long __e __asm__ ("%d5") = (long)(e); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-		      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d), "d" (__e)  \
-                      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)\
+type name(atype a, btype b, ctype c, dtype d, etype e)			\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%6, %%d5\n\t"				\
+			"movel	%5, %%d4\n\t"				\
+			"movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "a" ((long)c),				\
+			  "a" ((long)d),				\
+			  "g" ((long)e)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3",		\
+			  "%d4", "%d5");				\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-

+ 6 - 6
ldso/ldso/m68k/elfinterp.c

@@ -118,8 +118,8 @@ _dl_linux_resolver (int dummy1, int dummy2,
 }
 }
 
 
 void
 void
-_dl_parse_lazy_relocation_information (struct elf_resolve *tpnt, int rel_addr,
-				       int rel_size, int type)
+_dl_parse_lazy_relocation_information (struct elf_resolve *tpnt,
+                       unsigned long rel_addr, unsigned long rel_size, int type)
 {
 {
   int i;
   int i;
   char *strtab;
   char *strtab;
@@ -171,8 +171,8 @@ _dl_parse_lazy_relocation_information (struct elf_resolve *tpnt, int rel_addr,
 }
 }
 
 
 int 
 int 
-_dl_parse_relocation_information (struct elf_resolve *tpnt, int rel_addr,
-				  int rel_size, int type)
+_dl_parse_relocation_information (struct elf_resolve *tpnt,
+                  unsigned long rel_addr, unsigned long rel_size, int type)
 {
 {
   int i;
   int i;
   char *strtab;
   char *strtab;
@@ -294,8 +294,8 @@ _dl_parse_relocation_information (struct elf_resolve *tpnt, int rel_addr,
    at all.  */
    at all.  */
 
 
 int 
 int 
-_dl_parse_copy_information (struct dyn_elf *xpnt, int rel_addr,
-			    int rel_size, int type)
+_dl_parse_copy_information (struct dyn_elf *xpnt, unsigned long rel_addr,
+			    unsigned long rel_size, int type)
 {
 {
   int i;
   int i;
   char *strtab;
   char *strtab;

+ 131 - 74
ldso/ldso/m68k/ld_syscalls.h

@@ -1,12 +1,20 @@
 #include <asm/unistd.h>
 #include <asm/unistd.h>
 
 
+#undef __syscall_return
+#undef _syscall0
+#undef _syscall1
+#undef _syscall2
+#undef _syscall3
+#undef _syscall4
+#undef _syscall5
+
 /* Here are the macros which define how this platform makes
 /* Here are the macros which define how this platform makes
  * system calls.  This particular variant does _not_ set 
  * system calls.  This particular variant does _not_ set 
  * errno (note how it is disabled in __syscall_return) since
  * errno (note how it is disabled in __syscall_return) since
  * these will get called before the errno symbol is dynamicly 
  * these will get called before the errno symbol is dynamicly 
  * linked. */
  * linked. */
 
 
-#undef __syscall_return
+
 #define __syscall_return(type, res) \
 #define __syscall_return(type, res) \
 do { \
 do { \
 	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
 	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
@@ -19,88 +27,137 @@ do { \
 	return (type) (res); \
 	return (type) (res); \
 } while (0)
 } while (0)
 
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-__asm__ __volatile__ ("trap  #0" \
-                      : "=g" (__res) \
-		      : "0" (__res) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall0(type, name)						\
+type name(void)								\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name)				\
+			: "cc", "%d0");					\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-		      : "0" (__res), "d" (__a) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall1(type, name, atype, a)					\
+type name(atype a)							\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%2, %%d1\n\t"				\
+  			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "g" ((long)a)					\
+			: "cc", "%d0", "%d1");				\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a,btype b) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall2(type, name, atype, a, btype, b)			\
+type name(atype a, btype b)						\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "g" ((long)b)					\
+			: "cc", "%d0", "%d1", "%d2");			\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a,btype b,ctype c) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall3(type, name, atype, a, btype, b, ctype, c)		\
+type name(atype a, btype b, ctype c)					\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "g" ((long)c)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3");		\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name (atype a, btype b, ctype c, dtype d) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-__asm__ __volatile__ ("trap  #0" \
-                      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d)  \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)	\
+type name(atype a, btype b, ctype c, dtype d)				\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%5, %%d4\n\t"				\
+			"movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "a" ((long)c),				\
+			  "g" ((long)d)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3",		\
+			  "%d4");					\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-register long __e __asm__ ("%d5") = (long)(e); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-		      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d), "d" (__e)  \
-                      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)\
+type name(atype a, btype b, ctype c, dtype d, etype e)			\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%6, %%d5\n\t"				\
+			"movel	%5, %%d4\n\t"				\
+			"movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "a" ((long)c),				\
+			  "a" ((long)d),				\
+			  "g" ((long)e)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3",		\
+			  "%d4", "%d5");				\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-

+ 131 - 74
ldso/ldso/m68k/syscalls.h

@@ -1,12 +1,20 @@
 #include <asm/unistd.h>
 #include <asm/unistd.h>
 
 
+#undef __syscall_return
+#undef _syscall0
+#undef _syscall1
+#undef _syscall2
+#undef _syscall3
+#undef _syscall4
+#undef _syscall5
+
 /* Here are the macros which define how this platform makes
 /* Here are the macros which define how this platform makes
  * system calls.  This particular variant does _not_ set 
  * system calls.  This particular variant does _not_ set 
  * errno (note how it is disabled in __syscall_return) since
  * errno (note how it is disabled in __syscall_return) since
  * these will get called before the errno symbol is dynamicly 
  * these will get called before the errno symbol is dynamicly 
  * linked. */
  * linked. */
 
 
-#undef __syscall_return
+
 #define __syscall_return(type, res) \
 #define __syscall_return(type, res) \
 do { \
 do { \
 	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
 	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
@@ -19,88 +27,137 @@ do { \
 	return (type) (res); \
 	return (type) (res); \
 } while (0)
 } while (0)
 
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-__asm__ __volatile__ ("trap  #0" \
-                      : "=g" (__res) \
-		      : "0" (__res) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall0(type, name)						\
+type name(void)								\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name)				\
+			: "cc", "%d0");					\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-		      : "0" (__res), "d" (__a) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall1(type, name, atype, a)					\
+type name(atype a)							\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%2, %%d1\n\t"				\
+  			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "g" ((long)a)					\
+			: "cc", "%d0", "%d1");				\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a,btype b) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall2(type, name, atype, a, btype, b)			\
+type name(atype a, btype b)						\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "g" ((long)b)					\
+			: "cc", "%d0", "%d1", "%d2");			\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a,btype b,ctype c) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c) \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall3(type, name, atype, a, btype, b, ctype, c)		\
+type name(atype a, btype b, ctype c)					\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "g" ((long)c)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3");		\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name (atype a, btype b, ctype c, dtype d) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-__asm__ __volatile__ ("trap  #0" \
-                      : "=d" (__res) \
-                      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d)  \
-		      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)	\
+type name(atype a, btype b, ctype c, dtype d)				\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%5, %%d4\n\t"				\
+			"movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "a" ((long)c),				\
+			  "g" ((long)d)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3",		\
+			  "%d4");					\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-register long __e __asm__ ("%d5") = (long)(e); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "=d" (__res) \
-		      : "0" (__res), "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d), "d" (__e)  \
-                      : "%d0"); \
-__syscall_return(type,__res); \
+#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)\
+type name(atype a, btype b, ctype c, dtype d, etype e)			\
+{									\
+  long __res;								\
+  __asm__ __volatile__ ("movel	%6, %%d5\n\t"				\
+			"movel	%5, %%d4\n\t"				\
+			"movel	%4, %%d3\n\t"				\
+			"movel	%3, %%d2\n\t"				\
+  			"movel	%2, %%d1\n\t"				\
+			"movel	%1, %%d0\n\t"				\
+  			"trap	#0\n\t"					\
+  			"movel	%%d0, %0"				\
+			: "=g" (__res)					\
+			: "i" (__NR_##name),				\
+			  "a" ((long)a),				\
+			  "a" ((long)b),				\
+			  "a" ((long)c),				\
+			  "a" ((long)d),				\
+			  "g" ((long)e)					\
+			: "cc", "%d0", "%d1", "%d2", "%d3",		\
+			  "%d4", "%d5");				\
+  if ((unsigned long)(__res) >= (unsigned long)(-125)) {			\
+    /* errno = -__res; */							\
+    __res = -1;								\
+  }									\
+  return (type)__res;							\
 }
 }
 
 
-