Date: Wed, 25 Nov 1998 14:05:41 -0700 From: Nate Williams <nate@mt.sri.com> To: Nate Williams <nate@rocky.mt.sri.com> Cc: current@FreeBSD.ORG Subject: Re: FWD: src/lib/libc/quad/moddi3.c broken! Message-ID: <199811252105.OAA10347@mt.sri.com> In-Reply-To: <199811252038.NAA10234@mt.sri.com> References: <199811252038.NAA10234@mt.sri.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> Keith White just fixed a bug in the JDK that turned out to be a bug in > the libc source code. It's not normally seen because the version in > libgcc.a works, and is used before the libc version. ...... > The version in /usr/src/lib/libc/quad/moddi3.c looked a > little suspicious. To verify the problem, I built the following test > program: > > --- > main() { > long long a, b, c, d; > a = -12L; b = -5L; > c = a % b; > d = a - (a / b) * b; > > printf("long long '%%' %s\n", (c == d) ? "passed" : "failed"); > } > --- > like this: > cc -o remtest remtest.c > ./remtest > long long '%' passed > > cc -c remtest.c > ld -r -o x.o remtest.o -lc > cc -o remtest x.o > ./remtest > long long '%' failed > > Then I was convinced there was a problem with libc. Here is my fix for it which appears to work. I'm not math whiz, but we're using the same sort of logic that exists in the gcc sources, and there is only a slight difference. Note, this 'fix' is also in the NetBSD sources in a slightly different form. They essentially copy the same algorithm as exists in the libgcc2 sources, while I minimized the changes and kept the original format for my fix. If no-one objects, I'll commit this when I get back next week. Nate ---------------- [ Warning, cut-n-paste done here so white-space is hosed ] Index: moddi3.c =================================================================== RCS file: /data/FreeBSD/CVS/src/lib/libc/quad/moddi3.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 moddi3.c --- moddi3.c 1994/05/27 04:57:21 1.1.1.1 +++ moddi3.c 1998/11/25 21:02:23 @@ -59,7 +59,7 @@ else ua = a, neg = 0; if (b < 0) - ub = -(u_quad_t)b, neg ^= 1; + ub = -(u_quad_t)b; else ub = b; (void)__qdivrem(ua, ub, &ur); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811252105.OAA10347>