Article View: comp.bugs.2bsd
Article #135Problem with multiplication of (long)'s in libc/crt.
From: Cyrus Rahman
Date: Fri, 28 Nov 1986 09:44
Date: Fri, 28 Nov 1986 09:44
44 lines
1867 bytes
1867 bytes
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@dukempd.uucp
Durham, N.C. 27706 mcnc!duke!dukempd!cr
Technical Details
Message-ID:
<276@dukempd.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!decvax!mcnc!duke!dukempd!crShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!decvax!mcnc!duke!dukempd!cr From: cr@dukempd.UUCP (Cyrus Rahman) Newsgroups: comp.bugs.2bsd Subject: Problem with multiplication of (long)'s in libc/crt. Message-ID: <276@dukempd.UUCP> Date: Fri, 28-Nov-86 04:44:33 EST Article-I.D.: dukempd.276 Posted: Fri Nov 28 04:44:33 1986 Date-Received: Sat, 29-Nov-86 07:51:10 EST Organization: Duke University Physics Dept.; Durham, N.C. Lines: 44 Keywords: lmul.s long