diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-12-11 05:10:18 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-12-11 05:10:18 +0000 |
commit | aeca18e7af8fa0df6d9852de2c364a89ed4008d3 (patch) | |
tree | 853013cb2c7144ff3d4abb469f0531bf1ddd4930 /lib/libc | |
parent | 48d6b0594cc146182f3898897fa986ef3a45be90 (diff) |
More changes to avoid truncating 64 bit pointers to 32 bits and sign-extending
them; allows userland with stack beyond 2GB to run.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/mips64/gen/setjmp.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/bcmp.S | 40 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/bcopy.S | 46 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/bzero.S | 18 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/index.S | 6 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/rindex.S | 6 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/strcmp.S | 10 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/strlen.S | 8 |
8 files changed, 69 insertions, 69 deletions
diff --git a/lib/libc/arch/mips64/gen/setjmp.S b/lib/libc/arch/mips64/gen/setjmp.S index 7c165cecb9c..b534105b154 100644 --- a/lib/libc/arch/mips64/gen/setjmp.S +++ b/lib/libc/arch/mips64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: setjmp.S,v 1.6 2009/12/11 05:10:15 miod Exp $ */ /* * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -64,7 +64,7 @@ NON_LEAF(setjmp, FRAMESZ, ra) jal _thread_sys_sigaltstack REG_L a0, A0OFF(sp) # restore jmpbuf - lw v1, REGSZ+4(sp) # get old ss_onstack + ld v1, REGSZ(sp) # get old ss_onstack and v1, v1, 1 # extract onstack flag REG_S v1, SC_ONSTACK(a0) # save it in sc_onstack REG_L ra, RAOFF(sp) diff --git a/lib/libc/arch/mips64/string/bcmp.S b/lib/libc/arch/mips64/string/bcmp.S index 5b1c23b5797..2ff4a6e817e 100644 --- a/lib/libc/arch/mips64/string/bcmp.S +++ b/lib/libc/arch/mips64/string/bcmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bcmp.S,v 1.3 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: bcmp.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -40,66 +40,66 @@ LEAF(bcmp, 0) blt a2, 16, small # is it worth any trouble? xor v0, a0, a1 # compare low two bits of addresses and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address + dsubu a3, zero, a1 # compute # bytes to word align address bne v0, zero, unaligned # not possible to align addresses and a3, a3, 3 beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count + dsubu a2, a2, a3 # subtract from remaining count move v0, v1 # init v0,v1 so unmodified bytes match LWHI v0, 0(a0) # read 1, 2, or 3 bytes LWHI v1, 0(a1) - addu a1, a1, a3 + daddu a1, a1, a3 bne v0, v1, nomatch - addu a0, a0, a3 + daddu a0, a0, a3 1: and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address + dsubu a2, a2, a3 # which has to be >= (16-3) & ~3 + daddu a3, a3, a0 # compute ending address 2: lw v0, 0(a0) # compare words lw v1, 0(a1) - addu a0, a0, 4 + daddu a0, a0, 4 bne v0, v1, nomatch - addu a1, a1, 4 + daddu a1, a1, 4 bne a0, a3, 2b nop b small # finish remainder nop unaligned: beq a3, zero, 2f - subu a2, a2, a3 # subtract from remaining count - addu a3, a3, a0 # compute ending address + dsubu a2, a2, a3 # subtract from remaining count + daddu a3, a3, a0 # compute ending address 1: lbu v0, 0(a0) # compare bytes until a1 word aligned lbu v1, 0(a1) - addu a0, a0, 1 + daddu a0, a0, 1 bne v0, v1, nomatch - addu a1, a1, 1 + daddu a1, a1, 1 bne a0, a3, 1b nop 2: and a3, a2, ~3 # compute number of whole words left - subu a2, a2, a3 # which has to be >= (16-3) & ~3 - addu a3, a3, a0 # compute ending address + dsubu a2, a2, a3 # which has to be >= (16-3) & ~3 + daddu a3, a3, a0 # compute ending address 3: LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned LWLO v0, 3(a0) lw v1, 0(a1) - addu a0, a0, 4 + daddu a0, a0, 4 bne v0, v1, nomatch - addu a1, a1, 4 + daddu a1, a1, 4 bne a0, a3, 3b nop small: ble a2, zero, match - addu a3, a2, a0 # compute ending address + daddu a3, a2, a0 # compute ending address 1: lbu v0, 0(a0) lbu v1, 0(a1) - addu a0, a0, 1 + daddu a0, a0, 1 bne v0, v1, nomatch - addu a1, a1, 1 + daddu a1, a1, 1 bne a0, a3, 1b nop match: diff --git a/lib/libc/arch/mips64/string/bcopy.S b/lib/libc/arch/mips64/string/bcopy.S index 00ef040f11a..e5098a2cffc 100644 --- a/lib/libc/arch/mips64/string/bcopy.S +++ b/lib/libc/arch/mips64/string/bcopy.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bcopy.S,v 1.3 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: bcopy.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -38,7 +38,7 @@ LEAF(bcopy, 0) .set noreorder - addu t0, a0, a2 # t0 = end of s1 region + daddu t0, a0, a2 # t0 = end of s1 region sltu t1, a1, t0 sltu t2, a0, a1 and t1, t1, t2 # t1 = true if from < to < (from+len) @@ -46,11 +46,11 @@ LEAF(bcopy, 0) slt t2, a2, 12 # check for small copy ble a2, zero, 2f - addu t1, a1, a2 # t1 = end of to region + daddu t1, a1, a2 # t1 = end of to region 1: lb v0, -1(t0) # copy bytes backwards, - subu t0, t0, 1 # does not happen often so do slow way - subu t1, t1, 1 + dsubu t0, t0, 1 # does not happen often so do slow way + dsubu t1, t1, 1 bne t0, a0, 1b sb v0, 0(t1) 2: @@ -60,56 +60,56 @@ forward: bne t2, zero, smallcpy # do a small bcopy xor v0, a0, a1 # compare low two bits of addresses and v0, v0, 3 - subu a3, zero, a1 # compute # bytes to word align address + dsubu a3, zero, a1 # compute # bytes to word align address beq v0, zero, aligned # addresses can be word aligned and a3, a3, 3 beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count + dsubu a2, a2, a3 # subtract from remaining count LWHI v0, 0(a0) # get next 4 bytes (unaligned) LWLO v0, 3(a0) - addu a0, a0, a3 + daddu a0, a0, a3 SWHI v0, 0(a1) # store 1, 2, or 3 bytes to align a1 - addu a1, a1, a3 + daddu a1, a1, a3 1: and v0, a2, 3 # compute number of words left - subu a3, a2, v0 + dsubu a3, a2, v0 move a2, v0 - addu a3, a3, a0 # compute ending address + daddu a3, a3, a0 # compute ending address 2: LWHI v0, 0(a0) # copy words a0 unaligned, a1 aligned LWLO v0, 3(a0) - addu a0, a0, 4 - addu a1, a1, 4 + daddu a0, a0, 4 + daddu a1, a1, 4 bne a0, a3, 2b sw v0, -4(a1) b smallcpy nop aligned: beq a3, zero, 1f - subu a2, a2, a3 # subtract from remaining count + dsubu a2, a2, a3 # subtract from remaining count LWHI v0, 0(a0) # copy 1, 2, or 3 bytes to align - addu a0, a0, a3 + daddu a0, a0, a3 SWHI v0, 0(a1) - addu a1, a1, a3 + daddu a1, a1, a3 1: and v0, a2, 3 # compute number of whole words left - subu a3, a2, v0 + dsubu a3, a2, v0 move a2, v0 - addu a3, a3, a0 # compute ending address + daddu a3, a3, a0 # compute ending address 2: lw v0, 0(a0) # copy words - addu a0, a0, 4 - addu a1, a1, 4 + daddu a0, a0, 4 + daddu a1, a1, 4 bne a0, a3, 2b sw v0, -4(a1) smallcpy: ble a2, zero, 2f - addu a3, a2, a0 # compute ending address + daddu a3, a2, a0 # compute ending address 1: lbu v0, 0(a0) # copy bytes - addu a0, a0, 1 - addu a1, a1, 1 + daddu a0, a0, 1 + daddu a1, a1, 1 bne a0, a3, 1b sb v0, -1(a1) 2: diff --git a/lib/libc/arch/mips64/string/bzero.S b/lib/libc/arch/mips64/string/bzero.S index 52d8ffb67b9..0b0c477aaa7 100644 --- a/lib/libc/arch/mips64/string/bzero.S +++ b/lib/libc/arch/mips64/string/bzero.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bzero.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: bzero.S,v 1.5 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -38,26 +38,26 @@ LEAF(bzero, 0) .set noreorder blt a1, 12, smallclr # small amount to clear? - subu a3, zero, a0 # compute # bytes to word align address + dsubu a3, zero, a0 # compute # bytes to word align address and a3, a3, 3 beq a3, zero, 1f # skip if word aligned - subu a1, a1, a3 # subtract from remaining count + dsubu a1, a1, a3 # subtract from remaining count SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align - addu a0, a0, a3 + daddu a0, a0, a3 1: and v0, a1, 3 # compute number of words left - subu a3, a1, v0 + dsubu a3, a1, v0 move a1, v0 - addu a3, a3, a0 # compute ending address + daddu a3, a3, a0 # compute ending address 2: - addu a0, a0, 4 # clear words + daddu a0, a0, 4 # clear words bne a0, a3, 2b # unrolling loop does not help sw zero, -4(a0) # since we are limited by memory speed smallclr: ble a1, zero, 2f - addu a3, a1, a0 # compute ending address + daddu a3, a1, a0 # compute ending address 1: - addu a0, a0, 1 # clear bytes + daddu a0, a0, 1 # clear bytes bne a0, a3, 1b sb zero, -1(a0) 2: diff --git a/lib/libc/arch/mips64/string/index.S b/lib/libc/arch/mips64/string/index.S index e8b87a2f05d..83c916f3be7 100644 --- a/lib/libc/arch/mips64/string/index.S +++ b/lib/libc/arch/mips64/string/index.S @@ -1,4 +1,4 @@ -/* $OpenBSD: index.S,v 1.4 2009/11/01 20:04:30 miod Exp $ */ +/* $OpenBSD: index.S,v 1.5 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -37,13 +37,13 @@ LEAF(index, 0) .set reorder 0: lbu a2, 0(a0) # get a byte - addu a0, a0, 1 + daddu a0, a0, 1 beq a2, a1, fnd bne a2, zero, 0b notfnd: move v0, zero j ra fnd: - subu v0, a0, 1 + dsubu v0, a0, 1 j ra END(index) diff --git a/lib/libc/arch/mips64/string/rindex.S b/lib/libc/arch/mips64/string/rindex.S index dea77f02e32..6fa480bcc0a 100644 --- a/lib/libc/arch/mips64/string/rindex.S +++ b/lib/libc/arch/mips64/string/rindex.S @@ -1,4 +1,4 @@ -/* $OpenBSD: rindex.S,v 1.3 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: rindex.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -38,9 +38,9 @@ LEAF(rindex, 0) move v0, zero # default if not found 1: lbu a3, 0(a0) # get a byte - addu a0, a0, 1 + daddu a0, a0, 1 bne a3, a1, 2f - subu v0, a0, 1 # save address of last match + dsubu v0, a0, 1 # save address of last match 2: bne a3, zero, 1b # continue if not end j ra diff --git a/lib/libc/arch/mips64/string/strcmp.S b/lib/libc/arch/mips64/string/strcmp.S index ef093e4f8e0..7193a6bf131 100644 --- a/lib/libc/arch/mips64/string/strcmp.S +++ b/lib/libc/arch/mips64/string/strcmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strcmp.S,v 1.3 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: strcmp.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -45,14 +45,14 @@ LEAF(strcmp, 0) bne t0, t1, NotEq lbu t0, 1(a0) # unroll loop lbu t1, 1(a1) - add a0, a0, 2 + dadd a0, a0, 2 beq t0, zero, LessOrEq # end of first string? - add a1, a1, 2 + dadd a1, a1, 2 beq t0, t1, 1b NotEq: - subu v0, t0, t1 + dsubu v0, t0, t1 j ra LessOrEq: - subu v0, zero, t1 + dsubu v0, zero, t1 j ra END(strcmp) diff --git a/lib/libc/arch/mips64/string/strlen.S b/lib/libc/arch/mips64/string/strlen.S index bac41601fe3..5bc80bf847c 100644 --- a/lib/libc/arch/mips64/string/strlen.S +++ b/lib/libc/arch/mips64/string/strlen.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strlen.S,v 1.3 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: strlen.S,v 1.4 2009/12/11 05:10:17 miod Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -35,11 +35,11 @@ LEAF(strlen, 0) .set reorder - addu v1, a0, 1 + daddu v1, a0, 1 1: lb v0, 0(a0) # get byte from string - addu a0, a0, 1 # increment pointer + daddu a0, a0, 1 # increment pointer bne v0, zero, 1b # continue if not end - subu v0, a0, v1 # compute length - 1 for '\0' char + dsubu v0, a0, v1 # compute length - 1 for '\0' char j ra END(strlen) |