summaryrefslogtreecommitdiff
path: root/sysdeps/unix/mips
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/mips')
-rw-r--r--sysdeps/unix/mips/brk.S44
-rw-r--r--sysdeps/unix/mips/sysdep.S25
-rw-r--r--sysdeps/unix/mips/sysdep.h26
-rw-r--r--sysdeps/unix/mips/wait.S6
4 files changed, 59 insertions, 42 deletions
diff --git a/sysdeps/unix/mips/brk.S b/sysdeps/unix/mips/brk.S
index 197672669b..e38f735b92 100644
--- a/sysdeps/unix/mips/brk.S
+++ b/sysdeps/unix/mips/brk.S
@@ -24,46 +24,24 @@
#endif
#ifndef HAVE_GNU_LD
-#define __end end
+#define _end end
#endif
-.data
-.sdata
+ .data
ENTRY(__curbrk)
- .word __end
+ .word 0
.end __curbrk
-.text
-.set noreorder
-.set noat
-ENTRY(__brk)
- /* Minimum is one page. */
- lui v0, 4096
- lw v0, __end
- nop
-
- /* If they ask for less than a page, givvem the whole
- thing anyway. */
- sltu AT, a0, v0
- beq AT, zero, down1
- nop
- move a0, v0
-down1:
- li v0, SYS_brk
- syscall
- bne a3, zero, error
-
- /* Update __curbrk and exit cleanly. */
- lui AT, 4096
+ .text
+SYSCALL__(brk, 1)
+ .set reorder
+ /* Handle the query case. */
+ bnez a0, 1f
+ move a0,v0
+1: /* Update __curbrk and exit cleanly. */
sw a0, __curbrk
- j ra
move v0, zero
-
- /* What a horrible way to die. */
-error: j syscall_error
- nop
- nop
- nop
+ jr ra
.end __brk
weak_alias (__brk, brk)
diff --git a/sysdeps/unix/mips/sysdep.S b/sysdeps/unix/mips/sysdep.S
index 0cfc302770..ac8335fe5b 100644
--- a/sysdeps/unix/mips/sysdep.S
+++ b/sysdeps/unix/mips/sysdep.S
@@ -21,10 +21,23 @@
#define _ERRNO_H
#include <bits/errno.h>
-/* .globl errno */
-.set noreorder
+ .comm errno, 4
+#ifdef __ELF__
+ .type errno, @object
+#endif
+
+ .set noreorder
-ENTRY(syscall_error)
+ENTRY(__syscall_error)
+#ifdef __PIC__
+ .set noat
+ move $1, $31
+ bltzal $0, 0f
+ nop
+0: .cpload $31
+ move $31, $1
+ .set at
+#endif
#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN
/* We translate the system's EWOULDBLOCK error into EAGAIN.
The GNU C library always defines EWOULDBLOCK==EAGAIN.
@@ -40,4 +53,8 @@ skip:
/* And just kick back a -1. */
j ra
li v0, -1
- .end syscall_error
+ END(__syscall_error)
+
+/* We provide this alias for compatilility with other Unices
+ like IRIX 5 */
+weak_alias (__syscall_error, syscall_error)
diff --git a/sysdeps/unix/mips/sysdep.h b/sysdeps/unix/mips/sysdep.h
index 2f148d0938..cbafbdcd9a 100644
--- a/sysdeps/unix/mips/sysdep.h
+++ b/sysdeps/unix/mips/sysdep.h
@@ -32,19 +32,41 @@
/* Note that while it's better structurally, going back to call syscall_error
can make things confusing if you're debugging---it looks like it's jumping
backwards into the previous fn. */
+#ifdef __PIC__
+ #define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: la t9,syscall_error; \
+ jr t9; \
+ ENTRY(name) \
+ .set noreorder; \
+ .cpload t9; \
+ li v0, SYS_##syscall_name; \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+syse1:
+#else
#define PSEUDO(name, syscall_name, args) \
.set noreorder; \
.align 2; \
99: j syscall_error; \
- nop; \
ENTRY(name) \
+ .set noreorder; \
li v0, SYS_##syscall_name; \
syscall; \
+ .set reorder; \
bne a3, zero, 99b; \
- nop; \
syse1:
+#endif
+
+#undef PSEUDO_END
+#define PSEUDO_END(sym) .end sym
#define ret j ra ; nop
+
+#undef END
+#define END(sym) .end sym
+
#define r0 v0
#define r1 v1
/* The mips move insn is d,s. */
diff --git a/sysdeps/unix/mips/wait.S b/sysdeps/unix/mips/wait.S
index a544156c4e..9ea55bc7d0 100644
--- a/sysdeps/unix/mips/wait.S
+++ b/sysdeps/unix/mips/wait.S
@@ -28,14 +28,14 @@ ENTRY(__wait)
li v0, SYS_wait
syscall
- beq a3, zero, noerror
+ beqz a3, noerror
nop
- j syscall_error
+ j __syscall_error
nop
noerror:
/* If the arg is not NULL, store v1 there. */
- beq a0, zero, noarg
+ beqz a0, noarg
nop
sw v1, 0(a0)
nop