summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1999-08-20 09:09:57 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1999-08-20 09:09:57 +0000
commitb46dc0b27d2fdee92bde13802fcc03d2adb0b277 (patch)
treecd2068222a0fe1aa3b2b008b19cc1fa7fe8fee70
parentde6036dd6bfb94caf17805d70b433de8a2788546 (diff)
Fix faulty asms, that happened to work with old gcc, but not egcs
-rw-r--r--gnu/libexec/ld.so/ld.so/mips/syscall.h138
1 files changed, 81 insertions, 57 deletions
diff --git a/gnu/libexec/ld.so/ld.so/mips/syscall.h b/gnu/libexec/ld.so/ld.so/mips/syscall.h
index 2a7cb588610..8c1a6696790 100644
--- a/gnu/libexec/ld.so/ld.so/mips/syscall.h
+++ b/gnu/libexec/ld.so/ld.so/mips/syscall.h
@@ -20,82 +20,94 @@
extern inline int
_dl_exit (int status)
{
- register int __status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ __asm__ volatile ("li $2,%0\n\t"
+ "move $4,%1\n\t"
"syscall"
- : "=r" (__status)
- : "0" (SYS_exit), "r" (status)
+ : : "I" (SYS_exit), "r" (status)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
- while(1);
+ "$10","$11","$12","$13","$14","$15","$24","$25");
+ while (1)
+ ;
}
extern inline int
_dl_open (const char* addr, unsigned int flags)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"move $5,%3\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
- "1:"
+ "1:\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_open), "r" (addr), "r" (flags)
+ : "I" (SYS_open), "r" (addr), "r" (flags)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
extern inline int
_dl_close (int fd)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
- "1:"
+ "1:\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_close), "r" (fd)
+ : "I" (SYS_close), "r" (fd)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
extern inline int
_dl_write (int fd, const char* buf, int len)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
- "1:"
+ "1:\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_write), "r" (fd), "r" (buf), "r" (len)
+ : "I" (SYS_write), "r" (fd), "r" (buf), "r" (len)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
extern inline int
_dl_read (int fd, const char* buf, int len)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
"syscall\n\t"
"beq $7,$0,1f\n\t"
"li $2,-1\n\t"
- "1:"
+ "1:\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_read), "r" (fd), "r" (buf), "r" (len)
+ : "I" (SYS_read), "r" (fd), "r" (buf), "r" (len)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -103,14 +115,16 @@ extern inline int
_dl_mmap (void *addr, unsigned int size, unsigned int prot,
unsigned int flags, int fd, unsigned int f_offset)
{
- register int malloc_buffer __asm__ ("$2");
- __asm__ volatile ("addiu $29,-40\n\t"
+ register int malloc_buffer;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "addiu $29,-40\n\t"
"move $6,%2\n\t"
"move $7,%3\n\t"
"sw %4,16($29)\n\t"
"sw %5,20($29)\n\t"
#ifdef __MIPSEL__
- "li $4,197\n\t"
+ "li $4,%8\n\t"
"li $5,0\n\t"
"sw %6,24($29)\n\t"
"sw $0,28($29)\n\t"
@@ -119,7 +133,7 @@ _dl_mmap (void *addr, unsigned int size, unsigned int prot,
#else
#ifdef __MIPSEB__
"li $4,0\n\t"
- "li $5,197\n\t"
+ "li $5,%8\n\t"
"sw %6,24($29)\n\t"
"sw $0,28($29)\n\t"
"sw $0,32($29)\n\t"
@@ -129,27 +143,31 @@ _dl_mmap (void *addr, unsigned int size, unsigned int prot,
#endif
#endif
"syscall\n\t"
- "addiu $29,40"
+ "addiu $29,40\n\t"
+ "move %0,$2"
: "=r" (malloc_buffer)
- : "0" (SYS___syscall), "r" (addr), "r" (size), "r" (prot),
- "r" (flags), "r" (fd), "r" (f_offset)
+ : "I" (SYS___syscall), "r" (addr), "r" (size), "r" (prot),
+ "r" (flags), "r" (fd), "r" (f_offset), "I" (SYS_mmap)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return malloc_buffer;
}
extern inline int
_dl_mprotect (const void *addr, int size, int prot)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"move $5,%3\n\t"
"move $6,%4\n\t"
- "syscall"
+ "syscall\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_mprotect), "r" (addr), "r" (size), "r" (prot)
+ : "I" (SYS_mprotect), "r" (addr), "r" (size), "r" (prot)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
@@ -157,28 +175,34 @@ _dl_mprotect (const void *addr, int size, int prot)
extern inline int
_dl_stat (const char *addr, struct stat *sb)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"move $5,%3\n\t"
- "syscall"
+ "syscall\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_stat), "r" (addr), "r" (sb)
+ : "I" (SYS_stat), "r" (addr), "r" (sb)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
extern inline int
_dl_munmap (const void *addr, unsigned int size)
{
- register int status __asm__ ("$2");
- __asm__ volatile ("move $4,%2\n\t"
+ register int status;
+
+ __asm__ volatile ("li $2,%1\n\t"
+ "move $4,%2\n\t"
"move $5,%3\n\t"
- "syscall"
+ "syscall\n\t"
+ "move %0,$2"
: "=r" (status)
- : "0" (SYS_munmap), "r" (addr), "r" (size)
+ : "I" (SYS_munmap), "r" (addr), "r" (size)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
- "$10","$11","$12","$13","$14","$15","$24","$25");
+ "$10","$11","$12","$13","$14","$15","$24","$25");
return status;
}
#endif
@@ -191,20 +215,20 @@ _dl_suid_ok (void)
{
unsigned int uid, euid, gid, egid;
- __asm__ volatile ("move $2,%1; syscall; move %0,$2"
- : "=r" (uid) : "r" (SYS_getuid)
+ __asm__ volatile ("li $2,%1; syscall; move %0,$2"
+ : "=r" (uid) : "I" (SYS_getuid)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
- __asm__ volatile ("move $2,%1; syscall; move %0,$2"
- : "=r" (euid) : "r" (SYS_geteuid)
+ __asm__ volatile ("li $2,%1; syscall; move %0,$2"
+ : "=r" (euid) : "I" (SYS_geteuid)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
- __asm__ volatile ("move $2,%1; syscall; move %0,$2"
- : "=r" (gid) : "r" (SYS_getgid)
+ __asm__ volatile ("li $2,%1; syscall; move %0,$2"
+ : "=r" (gid) : "I" (SYS_getgid)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");
- __asm__ volatile ("move $2,%1; syscall; move %0,$2"
- : "=r" (egid) : "r" (SYS_getegid)
+ __asm__ volatile ("li $2,%1; syscall; move %0,$2"
+ : "=r" (egid) : "I" (SYS_getegid)
: "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9",
"$10","$11","$12","$13","$14","$15","$24","$25");