1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:54:45 -07:00

arm: bugfixes and syscall

- integer divide by zero raises panic
- float comparisons involving NaNs work
- syscall interface actually handles return
  values and errno correctly.

R=rsc, bradfitzpatrick
CC=golang-dev
https://golang.org/cl/1847047
This commit is contained in:
Kai Backman 2010-08-06 16:57:49 -07:00 committed by Russ Cox
parent c8c2bdbc59
commit df88fc6109
5 changed files with 446 additions and 393 deletions

View File

@ -1044,7 +1044,16 @@ bgen(Node *n, int true, Prog *to)
cgen(nr, &n2);
gcmp(optoas(OCMP, nr->type), &n1, &n2);
if(isfloat[nl->type->etype]) {
p1 = gbranch(ABVS, nr->type);
patch(gbranch(a, nr->type), to);
if(n->op == ONE)
patch(p1, to);
else
patch(p1, pc);
} else {
patch(gbranch(a, nr->type), to);
}
regfree(&n1);
regfree(&n2);

View File

@ -62,7 +62,7 @@ TEXT save<>(SB), 7, $0
MOVW 20(FP), R(D) /* denominator */
CMP $0, R(D)
BNE s1
SWI 0
BL panicdivide(SB)
/* MOVW -1(R(D)), R(TMP) /* divide by zero fault */
s1: RET

View File

@ -23,6 +23,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// declared here to avoid include of runtime.h
void panicstring(char*);
typedef unsigned long ulong;
typedef unsigned int uint;
typedef unsigned short ushort;
@ -31,6 +34,12 @@ typedef signed char schar;
#define SIGN(n) (1UL<<(n-1))
void
panicdivide(void)
{
panicstring("integer divide by zero");
}
typedef struct Vlong Vlong;
struct Vlong
{
@ -190,7 +199,7 @@ dodiv(Vlong num, Vlong den, Vlong *q, Vlong *r)
* get a divide by zero
*/
if(denlo==0 && denhi==0) {
numlo = numlo / denlo;
panicdivide();
}
/*

View File

@ -17,9 +17,21 @@ TEXT ·Syscall(SB),7,$0
MOVW 12(SP), R1
MOVW 16(SP), R2
SWI $0
MOVW $0xfffff001, R1
CMP R1, R0
BLS ok
MOVW $-1, R1
MOVW R1, 20(SP) // r1
MOVW $0, R2
MOVW R2, 24(SP) // r2
RSB $0, R0, R0
MOVW R0, 28(SP) // errno
BL runtime·exitsyscall(SB)
RET
ok:
MOVW R0, 20(SP) // r1
MOVW R1, 24(SP) // r2
MOVW $0, R0
MOVW R0, 24(SP) // r2
MOVW R0, 28(SP) // errno
BL runtime·exitsyscall(SB)
RET
@ -36,9 +48,21 @@ TEXT ·Syscall6(SB),7,$0
MOVW 24(SP), R4
MOVW 28(SP), R5
SWI $0
MOVW $0xfffff001, R1
CMP R1, R0
BLS ok6
MOVW $-1, R1
MOVW R1, 32(SP) // r1
MOVW $0, R2
MOVW R2, 36(SP) // r2
RSB $0, R0, R0
MOVW R0, 40(SP) // errno
BL runtime·exitsyscall(SB)
RET
ok6:
MOVW R0, 32(SP) // r1
MOVW R1, 36(SP) // r2
MOVW $0, R0
MOVW R0, 36(SP) // r2
MOVW R0, 40(SP) // errno
BL runtime·exitsyscall(SB)
RET
@ -50,8 +74,19 @@ TEXT ·RawSyscall(SB),7,$0
MOVW 12(SP), R1
MOVW 16(SP), R2
SWI $0
MOVW R0, 20(SP) // r1
MOVW R1, 24(SP) // r2
MOVW $0, R0
MOVW $0xfffff001, R1
CMP R1, R0
BLS ok1
MOVW $-1, R1
MOVW R1, 20(SP) // r1
MOVW $0, R2
MOVW R2, 24(SP) // r2
RSB $0, R0, R0
MOVW R0, 28(SP) // errno
RET
ok1:
MOVW R0, 20(SP) // r1
MOVW $0, R0
MOVW R0, 24(SP) // r2
MOVW R0, 28(SP) // errno
RET

View File

@ -43,7 +43,7 @@
./env.go
./escape.go
./float_lit.go
# ./floatcmp.go # fail, BUG
./floatcmp.go
./for.go
./func.go
./func1.go
@ -116,7 +116,7 @@
./varerr.go
./varinit.go
./vectors.go
# ./zerodivide.go # fail, BUG
./zerodivide.go
ken/array.go
ken/chan.go
ken/chan1.go