delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/04/26/13:11:06

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Disclaimer: "The National Aerospace Laboratory NLR DOES NOT ACCEPT ANY FINANCIAL COMMITMENT derived from this message."
Message-ID: <3AE8325D.58118E09@nlr.nl>
Date: Thu, 26 Apr 2001 16:36:13 +0200
From: "M. Kiriakopoulos" <kopoulos AT nlr DOT nl>
Organization: National Aerospace Laboratory
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: IEEE floating point in gcc / g77

Dear all,

I have the following question with respect to the usage of IEEE handlers
in cygwin using either g77 or gcc:

Is it possible to catch the floating point exceptions and continue with
intentional underflow in CYGWIN ?


For your info, I attach a two paragraphs from the g77 info pages:

 1.
______________________________________________________________________

17.4.10 Floating-point precision

If your program depends on exact IEEE 754 floating-point handling it may
help on some systems--specifically x86 or m68k hardware--to use the
`-ffloat-store' option or
to reset the precision flag on the floating-point unit. See section 7.7
Options That Control Optimization.

However, it might be better simply to put the FPU into double precision
mode and not take the performance hit of `-ffloat-store'. On x86 and
m68k GNU systems you
can do this with a technique similar to that for turning on
floating-point exceptions (see section 18.3.29 Floating-point Exception
Handling). The control word could be set to
double precision by replacing the __setfpucw call with one like this:

    __setfpucw ((_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE);

(It is not clear whether this has any effect on the operation of the GNU
maths library, but we have no evidence of it causing trouble.)

Some targets (such as the Alpha) may need special options for full IEEE
conformance. See section `Hardware Models and Configurations' in Using
and Porting GNU CC.

2. _____________________________________________________________________

and the paragraph

18.3.29 Floating-point Exception Handling

The gcc backend and, consequently, g77, currently provides no general
control over whether or not floating-point exceptions are trapped or
ignored. (Ignoring them typically
results in NaN values being propagated in systems that conform to IEEE
754.) The behaviour is normally inherited from the system-dependent
startup code, though some targets,
such as the Alpha, have code generation options which change the
behaviour.

Most systems provide some C-callable mechanism to change this; this can
be invoked at startup using gcc's constructor attribute. For example,
just compiling and linking the
following C code with your program will turn on exception trapping for
the "common" exceptions on an x86-based GNU system:


  #include <fpu_control.h>
  static void __attribute__ ((constructor))
  trapfpe ()
  {
    __setfpucw (_FPU_DEFAULT &
                ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM));
  }


A convenient trick is to compile this something like:

  gcc -o libtrapfpe.a trapfpe.c


and then use it by adding `-trapfpe' to the g77 command line when
linking.

______________________________________________________________________________________________________________

Unfortunately, al the above seem to be O.K for LINUX users and not for
CYGWIN users since
fpu_nontrol.h is not there.
I understand that this has to do with the difficulty of compilig the
glibc under cygwin.
I have seen the efforts of Fabrice, Robert, Mumit and Earnie and I have
been through the last weeks with lots of reading
on floating point arithmetics but finally

is there a way in cygwin to have sth like the very friendly ieee_hndler
call under solaris ?


My best regards to all the cygwin users.

PS. I have just joined your group - and I remain.

--
------------------------------------------------------------------

    From:    Kiriakopoulos Michael

    Address: National Aerospace Lab.   E-Mail - kopoulos AT nlr DOT nl
             Voorsterweg 31
             8316 PR Marknesse         Phone    (+31)527 - 248792
             (The Netherlands)         telefax  (+31)527 - 248210

------------------------------------------------------------------



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019