From owner-freebsd-questions Thu Sep 25 13:52:30 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id NAA12587 for questions-outgoing; Thu, 25 Sep 1997 13:52:30 -0700 (PDT) Received: from imdave.pr.mcs.net (imdave@imdave.pr.mcs.net [205.164.3.77]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id NAA12576 for ; Thu, 25 Sep 1997 13:52:24 -0700 (PDT) Received: (from imdave@localhost) by imdave.pr.mcs.net (8.8.7/8.8.7) id PAA01102; Thu, 25 Sep 1997 15:52:14 -0500 (CDT) Date: Thu, 25 Sep 1997 15:52:14 -0500 (CDT) From: Dave Bodenstab Message-Id: <199709252052.PAA01102@imdave.pr.mcs.net> To: freebsd-questions@FreeBSD.ORG, rlyon@ozemail.com.au Subject: Re: NIST ATM Network Simulator. Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > From: "Richard Lyon" > I am currently attempting to port the NIST ATM > simulator to FBSD. It compiles correctly but > does suffer from the dreaded floating point exceptions > during simulations. > > Has anyone run this application on FBSD successfully? > > Looking at the source, I can see most of the problems > relate to the differences between the original development > environment and FBSD. Not a big deal, but it will take a > few weeks work, which I would rather avoid if possible. Apparently many Unix's mask floating point exceptions by default. FreeBSD does not. Good? Bad? Well, it's just the way it is. I find that many application programs seem to rely on the exceptions being masked rather than being more careful how computations are done. A quick kludge is to simply mask all the exceptions... of course, whatever errors are hidden by this approach remain... Just insert the following in the function main(): : #include : : main() { : : #ifdef __FreeBSD__ /* * This goes near the beginning of main(), usually just after the variable * declarations. */ /* Round to nearest */ fpsetround( FP_RN ); /* Mask all exceptions */ fpsetmask( ~ (FP_X_INV | FP_X_DNML | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP) ); #endif : : #ifdef __FreeBSD__ /* * This goes near the end of main() before the final return. */ fpresetsticky( FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ | FP_X_IMP | FP_X_DNML ); #endif : : } Take a look at floatingpoint.h and machine/ieeefp.h Dave Bodenstab imdave@mcs.net