aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/mips/sys
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/mips/sys')
-rw-r--r--lib/libc/mips/sys/Ovfork.S11
-rw-r--r--lib/libc/mips/sys/brk.S18
-rw-r--r--lib/libc/mips/sys/cerror.S53
-rw-r--r--lib/libc/mips/sys/exect.S11
-rw-r--r--lib/libc/mips/sys/fork.S12
-rw-r--r--lib/libc/mips/sys/pipe.S11
-rw-r--r--lib/libc/mips/sys/ptrace.S53
-rw-r--r--lib/libc/mips/sys/sbrk.S32
8 files changed, 83 insertions, 118 deletions
diff --git a/lib/libc/mips/sys/Ovfork.S b/lib/libc/mips/sys/Ovfork.S
index 99a5526d1f45..9df93ea59e9d 100644
--- a/lib/libc/mips/sys/Ovfork.S
+++ b/lib/libc/mips/sys/Ovfork.S
@@ -49,21 +49,16 @@ __FBSDID("$FreeBSD$");
*/
LEAF(__sys_vfork)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
WEAK_ALIAS(vfork, __sys_vfork)
WEAK_ALIAS(_vfork, __sys_vfork)
+ PIC_PROLOGUE(__sys_vfork)
li v0, SYS_vfork # system call number for vfork
syscall
beq a3, zero, 1f # jump if no errors
- la t9, __cerror
- jr t9
+ PIC_TAILCALL(__cerror)
1:
beq v1, zero, 2f # parent process ?
move v0, zero # return zero in child
2:
- j ra
+ PIC_RETURN()
END(__sys_vfork)
diff --git a/lib/libc/mips/sys/brk.S b/lib/libc/mips/sys/brk.S
index aeaf7912f351..ceb29b9d587c 100644
--- a/lib/libc/mips/sys/brk.S
+++ b/lib/libc/mips/sys/brk.S
@@ -49,25 +49,23 @@ __FBSDID("$FreeBSD$");
_C_LABEL(minbrk):
.word _C_LABEL(_end)
+ .text
LEAF(__sys_brk)
WEAK_ALIAS(brk, __sys_brk)
WEAK_ALIAS(_brk, __sys_brk)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
- lw v0, _C_LABEL(minbrk)
+ PIC_PROLOGUE(__sys_brk)
+ PTR_LA v0, _C_LABEL(minbrk)
+ PTR_L v0, 0(v0)
bgeu a0, v0, 1f
move a0, v0 # dont allow break < minbrk
1:
li v0, SYS_break
syscall
bne a3, zero, 2f
- sw a0, _C_LABEL(__curbrk)
+ PTR_LA t0, _C_LABEL(__curbrk)
+ PTR_S a0, 0(t0)
move v0, zero
- j ra
+ PIC_RETURN()
2:
- la t9, _C_LABEL(__cerror)
- jr t9
+ PIC_TAILCALL(__cerror)
END(__sys_brk)
diff --git a/lib/libc/mips/sys/cerror.S b/lib/libc/mips/sys/cerror.S
index 535fbe063b6c..c504d73afa3f 100644
--- a/lib/libc/mips/sys/cerror.S
+++ b/lib/libc/mips/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $NetBSD: cerror.S,v 1.13 2003/08/07 16:42:17 agc Exp $ */
+/* $NetBSD: cerror.S,v 1.14 2009/12/14 01:07:42 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,35 +37,36 @@ __FBSDID("$FreeBSD$");
#include "SYS.h"
#if defined(LIBC_SCCS) && !defined(lint)
- ASMSTR("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93")
- ASMSTR("$NetBSD: cerror.S,v 1.13 2003/08/07 16:42:17 agc Exp $")
+#if 0
+ RCSID("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93")
+#else
+ RCSID("$NetBSD: cerror.S,v 1.14 2009/12/14 01:07:42 matt Exp $")
+#endif
#endif /* LIBC_SCCS and not lint */
+ .globl _C_LABEL(__error)
+NESTED_NOPROFILE(__cerror, CALLFRAME_SIZ, ra)
+ .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
+ SETUP_GP
+ PTR_SUBU sp, sp, CALLFRAME_SIZ
+ SETUP_GP64(CALLFRAME_GP, __cerror)
+ SAVE_GP(CALLFRAME_GP)
- /*
- * The __error() function is thread aware. For non-threaded
- * programs and the initial threaded in threaded programs,
- * it returns a pointer to the global errno variable.
- */
- .globl _C_LABEL(__error)
- .type _C_LABEL(__error),%function
+ PTR_S ra, CALLFRAME_RA(sp)
+ REG_S v0, CALLFRAME_S0(sp) # save errno value
-LEAF(__cerror)
- .frame sp, CALLFRAME_SIZ, ra
- PIC_PROLOGUE(__cerror, t9)
- subu sp, sp, CALLFRAME_SIZ
- .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
- sw ra, CALLFRAME_RA(sp)
- sw v0, 12(sp) # save errno value
+ PTR_LA t9, _C_LABEL(__error) # locate address of errno
+ jalr t9
+
+ REG_L t0, CALLFRAME_S0(sp)
+ PTR_L ra, CALLFRAME_RA(sp)
+ INT_S t0, 0(v0) # update errno value
+
+ RESTORE_GP64
+ PTR_ADDU sp, sp, CALLFRAME_SIZ
- la t9, _C_LABEL(__error) # locate address of errno
- jalr t9
+ li v0, -1
+ li v1, -1
- lw t0, 12(sp)
- lw ra, CALLFRAME_RA(sp)
- sw t0, 0(v0) # update errno value
- addiu sp, sp, CALLFRAME_SIZ
- li v0, -1
- li v1, -1
- j ra
+ j ra
END(__cerror)
diff --git a/lib/libc/mips/sys/exect.S b/lib/libc/mips/sys/exect.S
index 702015d96ed3..613d47c5d6d5 100644
--- a/lib/libc/mips/sys/exect.S
+++ b/lib/libc/mips/sys/exect.S
@@ -41,16 +41,11 @@ __FBSDID("$FreeBSD$");
#endif /* LIBC_SCCS and not lint */
LEAF(exect)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
+ PIC_PROLOGUE(exect)
li v0, SYS_execve
syscall
bne a3, zero, 1f
- j ra
+ PIC_RETURN()
1:
- la t9, _C_LABEL(__cerror)
- jr t9
+ PIC_TAILCALL(__cerror)
END(exect)
diff --git a/lib/libc/mips/sys/fork.S b/lib/libc/mips/sys/fork.S
index 2d1f14b855e7..7636bd379292 100644
--- a/lib/libc/mips/sys/fork.S
+++ b/lib/libc/mips/sys/fork.S
@@ -44,20 +44,14 @@ __FBSDID("$FreeBSD$");
LEAF(__sys_fork)
WEAK_ALIAS(fork, __sys_fork)
WEAK_ALIAS(_fork, __sys_fork)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
- fork = __sys_fork
+ PIC_PROLOGUE(__sys_fork)
li v0, SYS_fork # pid = fork()
syscall
bne a3, zero, 2f
beq v1, zero, 1f # v1 == 0 in parent, 1 in child
move v0, zero
1:
- j ra
+ PIC_RETURN()
2:
- la t9, _C_LABEL(__cerror)
- jr t9
+ PIC_TAILCALL(__cerror)
END(__sys_fork)
diff --git a/lib/libc/mips/sys/pipe.S b/lib/libc/mips/sys/pipe.S
index 224b78c8aafc..01465328f834 100644
--- a/lib/libc/mips/sys/pipe.S
+++ b/lib/libc/mips/sys/pipe.S
@@ -44,19 +44,14 @@ __FBSDID("$FreeBSD$");
LEAF(__sys_pipe)
WEAK_ALIAS(pipe, __sys_pipe)
WEAK_ALIAS(_pipe, __sys_pipe)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
+ PIC_PROLOGUE(__sys_pipe)
li v0, SYS_pipe # pipe(fildes) int fildes[2];
syscall
bne a3, zero, 1f
sw v0, 0(a0) # store the two file descriptors
sw v1, 4(a0)
move v0, zero
- j ra
+ PIC_RETURN()
1:
- la t9, _C_LABEL(__cerror)
- jr t9
+ PIC_TAILCALL(__cerror)
END(__sys_pipe)
diff --git a/lib/libc/mips/sys/ptrace.S b/lib/libc/mips/sys/ptrace.S
index 09b82c5255f9..8cf984a9c727 100644
--- a/lib/libc/mips/sys/ptrace.S
+++ b/lib/libc/mips/sys/ptrace.S
@@ -41,32 +41,31 @@ __FBSDID("$FreeBSD$");
ASMSTR("$NetBSD: ptrace.S,v 1.9 2003/08/07 16:42:17 agc Exp $")
#endif /* LIBC_SCCS and not lint */
-LEAF(ptrace)
- .frame sp, 40, ra
- .mask 0x80000000, -8
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
- subu sp, sp, 40
- sw ra, 32(sp)
-#ifdef __ABICALLS__
- .cprestore 16
-#endif
- la t9, _C_LABEL(__error) # locate address of errno
- jalr t9
-#ifdef __ABICALLS__
- lw gp, 16(sp)
-#endif
- sw zero, 0(v0)
- lw ra, 32(sp)
- addu sp, sp, 40
- li v0, SYS_ptrace
+NESTED_NOPROFILE(ptrace, CALLFRAME_SIZ, ra)
+ .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
+ SETUP_GP
+ PTR_SUBU sp, sp, CALLFRAME_SIZ
+ SETUP_GP64(CALLFRAME_GP, ptrace)
+ SAVE_GP(CALLFRAME_GP)
+
+ PTR_S ra, CALLFRAME_RA(sp)
+
+ PTR_LA t9, _C_LABEL(__error) # locate address of errno
+ jalr t9
+
+ PTR_L ra, CALLFRAME_RA(sp)
+ INT_S zero, 0(v0) # update errno value
+
+ li v0, SYS_ptrace
syscall
- bne a3, zero, 1f
- j ra
-1:
- la t9, _C_LABEL(__cerror)
- jr t9
+
+ # Load __cerror's address using our gp, then restore it.
+ PTR_LA t9, __cerror
+ RESTORE_GP64
+ PTR_ADDU sp, sp, CALLFRAME_SIZ
+
+ bne a3, zero, 1f
+
+ j ra
+1: j t9
END(ptrace)
diff --git a/lib/libc/mips/sys/sbrk.S b/lib/libc/mips/sys/sbrk.S
index c53536010066..8ab981d740c8 100644
--- a/lib/libc/mips/sys/sbrk.S
+++ b/lib/libc/mips/sys/sbrk.S
@@ -52,34 +52,22 @@ _C_LABEL(__curbrk):
LEAF(__sys_sbrk)
WEAK_ALIAS(sbrk, __sys_sbrk)
WEAK_ALIAS(_sbrk, __sys_sbrk)
-#ifdef __ABICALLS__
- .set noreorder
- .cpload t9
- .set reorder
-#endif
- addu sp, sp, -16
- sw s0, 0(sp) # Preserve s0 value in stack
- # it should be the same on return
- # We can't use v1 as temporary
- # register since syscall uses it
- # to return 64-bit values
- lw s0, _C_LABEL(__curbrk)
- li v0, SYS_break
- addu a0, a0, s0 # compute current break
+ PIC_PROLOGUE(__sys_sbrk)
+ PTR_LA t0, _C_LABEL(__curbrk)
+ PTR_L t0, 0(t0)
+ PTR_ADDU a0, a0, t0
+ li v0, SYS_break
syscall
bne a3, zero, 1f
nop
- move v0, s0 # return old val of curbrk from above
- lw s0, 0(sp)
- addu sp, sp, 16
- sw a0, _C_LABEL(__curbrk) # save current val of curbrk from above
+ move v0, t0 # return old val of curbrk from above
+ PTR_LA t0, _C_LABEL(__curbrk)
+ PTR_S a0, 0(t0) # save current val of curbrk from above
+ PIC_RETURN()
j ra
1:
- lw s0, 0(sp)
- addu sp, sp, 16
- la t9, _C_LABEL(__cerror)
- jr t9
+ PIC_TAILCALL(__cerror)
END(__sys_sbrk)