Problem with multiplication of (long)'s in libc/crt.
Cyrus Rahman
cr at dukempd.UUCP
Fri Nov 28 19:44:33 AEST 1986
We have recently brought up 2.9bsd on our 11/70, and although
it has a number of bugs it is a generally good system. It would be
nice if symbolic links really worked, and the quota feature fails in
a spectacular way. But there is only one bug I am aware of now that
I need to fix quickly:
Subject: The libc/crt routines for hardware mult./divide don't work properly.
Index: /usr/src/lib/c/crt 2.9bsd
Description:
The routines run with the appropriate interrupt bits of the
fpu disabled, so when overflow occurs during long multiplication the
result is 0 instead of the truncated product.
Repeat-By:
Run something that uses rand(). This program demonstrates the
problem as well:
#include <stdio.h>
main() {
long x;
for (x = 2; x != 0; x *= 2 + 1)
printf("x is %ld\n");
}
The program will terminate if linked with libc.a, but will behave
properly if linked with libnonfpc.a.
Fix:
The problem is not difficult to solve, but fixing it properly
will require understanding how the fpu is managed by the
kernel and what state C expects to find it in.
If someone has already done this I would be grateful for
their advice.
--
Cyrus Rahman 1-919-684-8226
Duke University Dept. of Physics cr at dukempd.uucp
Durham, N.C. 27706 mcnc!duke!dukempd!cr
More information about the Comp.bugs.2bsd
mailing list