summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-05-29 00:13:09 -0700
committerRuss Cox <rsc@golang.org>2009-05-29 00:13:09 -0700
commit69a38f266ca177cd55563d1b78a98c1b8273d90b (patch)
tree0a4606bc3eb551a3574c053e7c09456b030b27f3 /src/runtime
parent3c4d5b246db843a29edbe3a20dbe8a2954421c31 (diff)
downloadgolang-69a38f266ca177cd55563d1b78a98c1b8273d90b.tar.gz
64-bit integer arithmetic.
passes ridiculous test from CL 29569. R=ken OCL=29571 CL=29573
Diffstat (limited to 'src/runtime')
-rwxr-xr-xsrc/runtime/386/vlrt.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/386/vlrt.c b/src/runtime/386/vlrt.c
index e7726127e..093cca70d 100755
--- a/src/runtime/386/vlrt.c
+++ b/src/runtime/386/vlrt.c
@@ -311,6 +311,13 @@ _divv(Vlong *q, Vlong n, Vlong d)
long nneg, dneg;
if(n.hi == (((long)n.lo)>>31) && d.hi == (((long)d.lo)>>31)) {
+ if((long)n.lo == -0x80000000 && (long)d.lo == -1) {
+ // special case: 32-bit -0x80000000 / -1 causes divide error,
+ // but it's okay in this 64-bit context.
+ q->lo = 0x80000000;
+ q->hi = 0;
+ return;
+ }
q->lo = (long)n.lo / (long)d.lo;
q->hi = ((long)q->lo) >> 31;
return;
@@ -338,6 +345,13 @@ _modv(Vlong *r, Vlong n, Vlong d)
long nneg, dneg;
if(n.hi == (((long)n.lo)>>31) && d.hi == (((long)d.lo)>>31)) {
+ if((long)n.lo == -0x80000000 && (long)d.lo == -1) {
+ // special case: 32-bit -0x80000000 % -1 causes divide error,
+ // but it's okay in this 64-bit context.
+ r->lo = 0;
+ r->hi = 0;
+ return;
+ }
r->lo = (long)n.lo % (long)d.lo;
r->hi = ((long)r->lo) >> 31;
return;