1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Math library compatibility modes</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="C and math library overview"
23 HREF="c-and-math-library-overview.html"><LINK
25 TITLE="C and math library overview"
26 HREF="c-and-math-library-overview.html"><LINK
28 TITLE="Some implementation details"
29 HREF="libc-implementation-details.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="c-and-math-library-overview.html"
65 >Chapter 13. C and math library overview</TD
71 HREF="libc-implementation-details.html"
85 NAME="MATH-LIBRARY-COMPATIBILITY-MODES">Math library compatibility modes</H1
87 >This math library is capable of being operated in several
88 different compatibility modes. These options deal solely with how
89 errors are handled. </P
91 >There are 4 compatibility modes: ANSI/POSIX 1003.1;
92 IEEE-754; X/Open Portability Guide issue 3 (XPG3); and
93 System V Interface Definition Edition 3. </P
95 >In IEEE mode, the <TT
99 (see below) is never called, no warning messages are printed on
100 the stderr output stream, and errno is never set. </P
102 >In ANSI/POSIX mode, errno is set correctly,
106 > is never called and no warning messages
107 are printed on the stderr output stream. </P
109 >In X/Open mode, errno is set correctly,
113 > is called, but no warning messages are printed
114 on the stderr output stream. </P
116 >In SVID mode, functions which overflow return
117 a value HUGE (defined in <TT
120 >), which is the maximum
121 single precision floating point value (as opposed to
122 HUGE_VAL which is meant to stand for infinity). errno is
123 set correctly and <TT
130 > returns 0, warning messages are printed on
131 the stderr output stream for some errors. </P
133 >The mode can be compiled-in as IEEE-only, or any one of the
134 above methods settable at run-time. </P
142 >This math library assumes that the hardware (or software floating
143 point emulation) supports IEEE-754 style arithmetic, 32-bit 2's
144 complement integer arithmetic, doubles are in 64-bit IEEE-754 format.</P
152 NAME="AEN10153">matherr()</H2
154 >As mentioned above, in X/Open or SVID modes, the user
155 can supply a function <TT
167 CLASS="PROGRAMLISTING"
171 >( struct exception *e )</PRE
176 >where struct exception is defined as:</P
184 CLASS="PROGRAMLISTING"
188 double arg1, arg2, retval;
194 >type is the exception type and is one of:</P
204 >argument domain exception</P
210 >argument singularity</P
216 >overflow range exception</P
222 >underflow range exception</P
228 >total loss of significance</P
234 >partial loss of significance</P
244 > is a string containing the name of the
258 arguments passed to the function</P
265 > is the default value that will be returned
266 by the function, and can be changed by <TT
277 >matherr must have “C” linkage, not “C++” linkage.</P
281 >If matherr returns zero, or the user doesn't supply
282 their own matherr, then the following <SPAN
295 >Table 13-1. Behavior of math exception handling</B
322 errno=EDOM, and a message printed on stderr</TD
333 sign is returned, errno=EDOM, and a message is printed
345 appropriate sign is returned, and errno=ERANGE</TD
356 returned and errno=ERANGE</TD
367 errno=ERANGE, and a message is printed on stderr</TD
378 implementation doesn't return this type</TD
384 >X/Open mode is similar except that the message is
385 not printed on stderr and HUGE_VAL is used in place of
393 NAME="AEN10226">Thread-safety and re-entrancy</H2
395 >With the appropriate configuration options set below, the
396 math library is fully thread-safe if:</P
402 >Depending on the compatibility mode, the
403 setting of the errno variable from the C library is
408 >Depending on the compatibility mode, sending error messages
409 to the stderr output stream using the C library
414 function is thread-safe </P
418 >Depending on the compatibility mode, the user-supplied
423 function and anything it depends on are thread-safe </P
427 >In addition, with the exception of the <TT
434 the math library is reentrant (and thus safe to use from interrupt handlers)
435 if the Math library is always in IEEE mode.</P
443 SUMMARY="Footer navigation table"
454 HREF="c-and-math-library-overview.html"
472 HREF="libc-implementation-details.html"
482 >C and math library overview</TD
488 HREF="c-and-math-library-overview.html"
496 >Some implementation details</TD