Mail Archives: djgpp/2003/04/22/08:31:38
>Eric Rudd wrote:
>> On 2000-01-18, I submitted bug report 00314, which concerns incorrect
>> behavior of the div() and ldiv() functions. The DJGPP bug-tracking
>> system reports this bug as being fixed, but the latest source appears to
>> be still unchanged from before, and moreover a call to div() in the
>> libc.a dated 2001-12-24 from gcc 3.2.2-compiled code now bombs:
The 2.03 looks like it uses the div.c and ldiv.c revision 1.1 . The
fix went into rev 1.2 of the files and are only in the 2.04 WIP CVS
LIBC.
If you want to try out the 2.04 WIP test release goto the following
page and have a read:-
http://clio.rice.edu/djgpp/win2k/main.htm
The 204 LIBC div.c is:-
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
div_t
div(int num, int denom)
{
div_t r;
r.rem = num % denom;
r.quot = num / denom;
return r;
}
The 204 LIBC ldiv.c is:-
/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
lldiv_t
lldiv(long long int num, long long int denom)
{
lldiv_t r;
if (num > 0 && denom < 0)
{
num = -num;
denom = -denom;
}
r.quot = num / denom;
r.rem = num % denom;
if (num < 0 && denom > 0)
{
if (r.rem > 0)
{
r.quot++;
r.rem -= denom;
}
}
return r;
}
Andrew
- Raw text -