This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: update code example in g77 documentation
- To: Toon Moene <moene at knmi dot nl>
- Subject: Re: update code example in g77 documentation
- From: Andreas Jaeger <aj at suse dot de>
- Date: 21 Nov 2000 10:12:59 +0100
- Cc: gcc-patches at gcc dot gnu dot org
- References: <3A1A3AD8.6BD61FF1@knmi.nl>
>>>>> Toon Moene writes:
> Andreas Jaeger wrote:
>> I wrote:
>> > Andreas, could you look into the two examples given in f/g77.texi and
>> > give (exact) code examples on how to do this when using glibc 2.2 ?
>> I changed only the first example, the second example is really
>> nonportable and only applies to ia32 and m68k CPUs.
> But is the second example still correct (and working) with glibc 2.2 ?
Yes, it should still work.
>> Here's a patch. Shall I commit it?
>> 2000-11-21 Andreas Jaeger <aj@suse.de>
>> * g77.texi (Floating-point Exception Handling): Use feenableexcept
>> in example.
> Yes, this is OK.
I looked at the description for the second example again, it needs
changing to reflect my changes. I'm not totally happy with it, please
have a look.
I'd like to commit the following patch instead,
Andreas
2000-11-21 Andreas Jaeger <aj@suse.de>
* g77.texi (Floating-point Exception Handling): Use feenableexcept
in example.
(Floating-point precision): Change to match above change.
============================================================
Index: gcc/f/g77.texi
--- gcc/f/g77.texi 2000/11/19 18:57:05 1.66
+++ gcc/f/g77.texi 2000/11/21 09:12:12
@@ -10475,9 +10475,10 @@
and m68k GNU systems you can do this with a technique similar to that
for turning on floating-point exceptions
(@pxref{Floating-point Exception Handling}).
-The control word could be set to double precision by
-replacing the @code{__setfpucw} call or the @code{_FPU_SETCW} macro with one like this:
+The control word could be set to double precision by some code like this
+one:
@smallexample
+#include <fpu_control.h>
@{
fpu_control_t cw = (_FPU_DEFAULT & ~_FPU_EXTENDED) | _FPU_DOUBLE;
_FPU_SETCW(cw);
@@ -12150,17 +12151,17 @@
be invoked at startup using @code{gcc}'s @code{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:
+on a GNU system using glibc 2.2 or newer:
@smallexample
-#include <fpu_control.h>
+#define _GNU_SOURCE 1
+#include <fenv.h>
static void __attribute__ ((constructor))
trapfpe ()
@{
- fpu_control_t cw =
- _FPU_DEFAULT &
- ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM);
- _FPU_SETCW(cw);
+ /* Enable some exceptions. At startup all exceptions are masked. */
+
+ feenableexcept (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
@}
@end smallexample
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj