Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Sep 1997 15:52:14 -0500 (CDT)
From:      Dave Bodenstab <imdave@mcs.net>
To:        freebsd-questions@FreeBSD.ORG, rlyon@ozemail.com.au
Subject:   Re: NIST ATM Network Simulator.
Message-ID:  <199709252052.PAA01102@imdave.pr.mcs.net>

next in thread | raw e-mail | index | archive | help
> From: "Richard Lyon" <rlyon@ozemail.com.au>
> 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 <floatingpoint.h>
 :
 :
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709252052.PAA01102>