Re: ModuloTest fails on mips

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Mon Feb 08 1999 - 13:28:37 EST


>
> 0x8...0 % 0xf...f generates an arithmetic exception on mips. The
> following programs demonstrates this.
>
> Should we test for this failure at configure time and generate extra
> code to expand `a%b' to `(b==-1)?0:(a%b)' ? :-(
>

The FAQ already mentions that it's broken on netbsd and other platforms.

I would like a configure test.

However, note that on broken FreeBSDs and on the netbsd/arm, what we
want to return is simply -(a%b) if sgn(a%b) != sgn(a), I think.
(See the cvs log for soft.c)

Note that on netbsd this affects the interpreter also, so intrp/icode.h
(or whatever the file is must be changed to make use of a macro or
something.)

Maybe these patches can be unified?

Like
#define lrem(a, b) (a < 0 ? (-a % -b) : (a % b))
so some such?

        - Godmar

>
> #ifndef T
> #define T long long
> /* #define T long */
> /* #define T int */
> #endif
>
> typedef T t;
> typedef unsigned T ut;
>
> t foo(t i, t j);
> int main() {
> t i = 0, j = -1;
> i = ((ut)(~i)>>1)+1; /* 0x80...0 */
> if (foo(i, j))
> abort();
> return 0;
> }
>
> t foo(t i, t j) {
> return i % j;
> }
>
>
> --
> Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org}
> oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
> Universidade Estadual de Campinas, SP, Brasil
>
>


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:58:01 EDT