1 /* file: libm_support.h */
5 // Copyright (c) 2000 - 2004, Intel Corporation
6 // All rights reserved.
8 // Contributed 2000 by the Intel Numerics Group, Intel Corporation
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
14 // * Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
17 // * Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
21 // * The name of Intel Corporation may not be used to endorse or promote
22 // products derived from this software without specific prior written
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
34 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 // Intel Corporation is the author of this code, and requests that all
39 // problem reports or change requests be submitted to it directly at
40 // http://www.intel.com/software/products/opensource/libraries/num.htm.
43 // History: 02/02/2000 Initial version
44 // 2/28/2000 added tags for logb and nextafter
45 // 3/22/2000 Changes to support _LIB_VERSIONIMF variable
46 // and filled some enum gaps. Added support for C99.
47 // 5/31/2000 added prototypes for __libm_frexp_4l/8l
48 // 8/10/2000 Changed declaration of _LIB_VERSIONIMF to work for library
49 // builds and other application builds (precompiler directives).
50 // 8/11/2000 Added pointers-to-matherr-functions declarations to allow
51 // for user-defined matherr functions in the dll build.
52 // 12/07/2000 Added scalbn error_types values.
53 // 5/01/2001 Added error_types values for C99 nearest integer
55 // 6/07/2001 Added error_types values for fdim.
56 // 6/18/2001 Added include of complex_support.h.
57 // 8/03/2001 Added error_types values for nexttoward, scalbln.
58 // 8/23/2001 Corrected tag numbers from 186 and higher.
59 // 8/27/2001 Added check for long int and long long int definitions.
60 // 12/10/2001 Added error_types for erfc.
61 // 12/27/2001 Added error_types for degree argument functions.
62 // 01/02/2002 Added error_types for tand, cotd.
63 // 01/04/2002 Delete include of complex_support.h
64 // 01/23/2002 Deleted prototypes for __libm_frexp*. Added check for
65 // multiple int, long int, and long long int definitions.
66 // 05/20/2002 Added error_types for cot.
67 // 06/27/2002 Added error_types for sinhcosh.
68 // 12/05/2002 Added error_types for annuity and compound
69 // 04/10/2003 Added error_types for tgammal/tgamma/tgammaf
70 // 05/16/2003 FP-treatment macros copied here from IA32 libm_support.h
71 // 06/02/2003 Added pad into struct fp80 (12/16 bytes).
72 // 08/01/2003 Added struct ker80 and macros for multiprecision addition,
73 // subtraction, multiplication, division, square root.
74 // 08/07/2003 History section updated.
75 // 09/03/2003 ALIGN(n) macro added.
76 // 10/01/2003 LDOUBLE_ALIGN and fp80 corrected on linux to 16 bytes.
77 // 11/24/2004 Added ifdef around definitions of INT32/64
78 // 12/15/2004 Added error_types for exp10, nextafter, nexttoward
79 // underflow. Moved error codes into libm_error_codes.h.
83 #ifndef __LIBM_SUPPORT_H_INCLUDED__
84 #define __LIBM_SUPPORT_H_INCLUDED__
87 #if !(defined(_WIN32) || defined(_WIN64))
88 # pragma const_seg(".rodata") /* place constant data in text (code) section */
91 #if defined(__ICC) || defined(__ICL) || defined(__ECC) || defined(__ECL)
92 # pragma warning( disable : 1682 ) /* #1682: ixplicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) */
93 # pragma warning( disable : 1683 ) /* #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) */
97 /* macros to form a double value in hex representation (unsigned int type) */
99 #define DOUBLE_HEX(hi,lo) 0x##lo,0x##hi /*LITTLE_ENDIAN*/
101 #include "libm_cpu_defs.h"
103 #if !(defined (IA64))
104 # include "libm_dll.h"
105 # include "libm_dispatch.h"
108 #include "libm_error_codes.h"
114 float arg1
, arg2
, retval
;
122 double arg1
, arg2
, retval
;
131 double arg1
, arg2
, retval
;
140 long double arg1
, arg2
, retval
;
143 #if (defined (_MS_) && defined (IA64))
144 #define MATHERR_F _matherrf
145 #define MATHERR_D _matherr
147 #define MATHERR_F matherrf
148 #define MATHERR_D matherr
152 #define EXC_DECL_D __exception
154 // exception is a reserved name in C++
155 #define EXC_DECL_D exception
158 extern int MATHERR_F(struct exceptionf
*);
159 extern int MATHERR_D(struct EXC_DECL_D
*);
160 extern int matherrl(struct exceptionl
*);
163 // Add code to support _LIB_VERSIONIMF
166 _IEEE_
= -1, // IEEE-like behavior
167 _SVID_
, // SysV, Rel. 4 behavior
174 // This is a run-time variable and may affect
175 // floating point behavior of the libm functions
177 #if !defined( LIBM_BUILD )
179 extern _LIB_VERSION_TYPE
__declspec(dllimport
) _LIB_VERSIONIMF
;
181 extern _LIB_VERSION_TYPE _LIB_VERSIONIMF
;
184 extern int (*pmatherrf
)(struct exceptionf
*);
185 extern int (*pmatherr
)(struct EXC_DECL_D
*);
186 extern int (*pmatherrl
)(struct exceptionl
*);
187 #endif /* LIBM_BUILD */
189 /* memory format definitions (LITTLE_ENDIAN only) */
191 #if !(defined(SIZE_INT_32) || defined(SIZE_INT_64))
192 # error "You need to define SIZE_INT_32 or SIZE_INT_64"
195 #if (defined(SIZE_INT_32) && defined(SIZE_INT_64))
196 #error multiple integer size definitions; define SIZE_INT_32 or SIZE_INT_64
199 #if !(defined(SIZE_LONG_32) || defined(SIZE_LONG_64))
200 # error "You need to define SIZE_LONG_32 or SIZE_LONG_64"
203 #if (defined(SIZE_LONG_32) && defined(SIZE_LONG_64))
204 #error multiple integer size definitions; define SIZE_LONG_32 or SIZE_LONG_64
207 #if !defined(__USE_EXTERNAL_FPMEMTYP_H__)
209 #define BIAS_32 0x007F
210 #define BIAS_64 0x03FF
211 #define BIAS_80 0x3FFF
213 #define MAXEXP_32 0x00FE
214 #define MAXEXP_64 0x07FE
215 #define MAXEXP_80 0x7FFE
217 #define EXPINF_32 0x00FF
218 #define EXPINF_64 0x07FF
219 #define EXPINF_80 0x7FFF
221 struct fp32
{ /*// sign:1 exponent:8 significand:23 (implied leading 1)*/
222 #if defined(SIZE_INT_32)
223 unsigned significand
:23;
226 #elif defined(SIZE_INT_64)
227 unsigned significand
:23;
233 struct fp64
{ /*/ sign:1 exponent:11 significand:52 (implied leading 1)*/
234 #if defined(SIZE_INT_32)
235 unsigned lo_significand
:32;
236 unsigned hi_significand
:20;
237 unsigned exponent
:11;
239 #elif defined(SIZE_INT_64)
240 unsigned significand
:52;
241 unsigned exponent
:11;
246 struct fp80
{ /*/ sign:1 exponent:15 significand:64 (NO implied bits) */
247 #if defined(SIZE_INT_32)
248 unsigned lo_significand
;
249 unsigned hi_significand
;
250 unsigned exponent
:15;
252 #elif defined(SIZE_INT_64)
253 unsigned significand
;
254 unsigned exponent
:15;
258 #if !(defined(__unix__) && defined(__i386__))
263 #endif /*__USE_EXTERNAL_FPMEMTYP_H__*/
265 #if !(defined(opensource))
266 typedef __int32 INT32
;
267 typedef signed __int32 SINT32
;
268 typedef unsigned __int32 UINT32
;
270 typedef __int64 INT64
;
271 typedef signed __int64 SINT64
;
272 typedef unsigned __int64 UINT64
;
275 typedef signed int SINT32
;
276 typedef unsigned int UINT32
;
278 typedef long long INT64
;
279 typedef signed long long SINT64
;
280 typedef unsigned long long UINT64
;
283 #if (defined(_WIN32) || defined(_WIN64)) /* Windows */
284 # define I64CONST(bits) 0x##bits##i64
285 # define U64CONST(bits) 0x##bits##ui64
286 #elif (defined(__linux__) && defined(_M_IA64)) /* Linux,64 */
287 # define I64CONST(bits) 0x##bits##L
288 # define U64CONST(bits) 0x##bits##uL
290 # define I64CONST(bits) 0x##bits##LL
291 # define U64CONST(bits) 0x##bits##uLL
307 /* The result is sum rhi+rlo */
308 /* Temporary variables: t1 */
309 /* All variables are in long double precision */
310 /* Correct if no overflow (algorithm by D.Knuth) */
311 #define __LIBM_ADDL1_K80( rhi,rlo,x,y, t1 ) \
319 /* Addition: (xhi+xlo) + (yhi+ylo) */
320 /* The result is sum rhi+rlo */
321 /* Temporary variables: t1 */
322 /* All variables are in long double precision */
323 /* Correct if no overflow (algorithm by T.J.Dekker) */
324 #define __LIBM_ADDL2_K80( rhi,rlo,xhi,xlo,yhi,ylo, t1 ) \
326 if ( VALUE_GT_80(FP80(xhi),FP80(yhi)) ) { \
327 t1=xhi-rlo;t1=t1+yhi;t1=t1+ylo;t1=t1+xlo; \
329 t1=yhi-rlo;t1=t1+xhi;t1=t1+xlo;t1=t1+ylo; \
332 rlo=rlo-rhi;rlo=rlo+t1;
334 /* Addition: r=x+y */
335 /* Variables r,x,y are pointers to struct ker80, */
336 /* all other variables are in long double precision */
337 /* Temporary variables: t1 */
338 /* Correct if x and y belong to interval [2^-8000;2^8000], */
339 /* or when one or both of them are zero */
340 #if defined(SIZE_INT_32)
341 #define __LIBM_ADDL_K80(r,x,y, t1) \
342 if ( ((y)->ex+(y)->fphi.exponent-134 < \
343 (x)->ex+(x)->fphi.exponent) && \
344 ((x)->ex+(x)->fphi.exponent < \
345 (y)->ex+(y)->fphi.exponent+134) && \
346 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
347 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
349 /* y/2^134 < x < y*2^134, */ \
350 /* and x,y are nonzero finite numbers */ \
351 if ( (x)->ex != (y)->ex ) { \
352 /* adjust x->ex to y->ex */ \
353 /* t1 = 2^(x->ex - y->ex) */ \
354 FP80(t1)->sign = 0; \
355 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
356 /* exponent is correct because */ \
357 /* |x->ex - y->ex| = */ \
358 /* = | (x->ex + x->fphi.exponent) - */ \
359 /* -(y->ex + y->fphi.exponent) + */ \
360 /* + y->fphi.exponent - */ \
361 /* - x->fphi.exponent | < */ \
362 /* < | (x->ex+x->fphi.exponent) - */ \
363 /* -(y->ex+y->fphi.exponent) | + */ \
364 /* +| y->fphi.exponent - */ \
365 /* -x->fphi.exponent | < */ \
366 /* < 134 + 16000 */ \
367 FP80(t1)->hi_significand = 0x80000000; \
368 FP80(t1)->lo_significand = 0x00000000; \
375 __LIBM_ADDL2_K80( (r)->ldhi,(r)->ldlo, \
376 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
377 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
378 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
379 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
387 #elif defined(SIZE_INT_64)
388 #define __LIBM_ADDL_K80(r,x,y, t1) \
389 if ( ((y)->ex+(y)->fphi.exponent-134 < \
390 (x)->ex+(x)->fphi.exponent) && \
391 ((x)->ex+(x)->fphi.exponent < \
392 (y)->ex+(y)->fphi.exponent+134) && \
393 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
394 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
396 /* y/2^134 < x < y*2^134, */ \
397 /* and x,y are nonzero finite numbers */ \
398 if ( (x)->ex != (y)->ex ) { \
399 /* adjust x->ex to y->ex */ \
400 /* t1 = 2^(x->ex - y->ex) */ \
401 FP80(t1)->sign = 0; \
402 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
403 /* exponent is correct because */ \
404 /* |x->ex - y->ex| = */ \
405 /* = | (x->ex + x->fphi.exponent) - */ \
406 /* -(y->ex + y->fphi.exponent) + */ \
407 /* + y->fphi.exponent - */ \
408 /* - x->fphi.exponent | < */ \
409 /* < | (x->ex+x->fphi.exponent) - */ \
410 /* -(y->ex+y->fphi.exponent) | + */ \
411 /* +| y->fphi.exponent - */ \
412 /* -x->fphi.exponent | < */ \
413 /* < 134 + 16000 */ \
414 FP80(t1)->significand = 0x8000000000000000; \
421 __LIBM_ADDL2_K80( (r)->ldhi,(r)->ldlo, \
422 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
423 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
424 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
425 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
435 /* Addition: r=x+y */
436 /* Variables r,x,y are pointers to struct ker80, */
437 /* all other variables are in long double precision */
438 /* Temporary variables: t1 */
439 /* Correct for any finite x and y */
440 #define __LIBM_ADDL_NORM_K80(r,x,y, t1) \
441 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
442 ((x)->fphi.exponent-BIAS_80>+8000) || \
443 ((y)->fphi.exponent-BIAS_80<-8000) || \
444 ((y)->fphi.exponent-BIAS_80>+8000) ) \
446 __libm_normalizel_k80(x); \
447 __libm_normalizel_k80(y); \
449 __LIBM_ADDL_K80(r,x,y, t1)
451 /* Subtraction: x-y */
452 /* The result is sum rhi+rlo */
453 /* Temporary variables: t1 */
454 /* All variables are in long double precision */
455 /* Correct if no overflow (algorithm by D.Knuth) */
456 #define __LIBM_SUBL1_K80( rhi, rlo, x, y, t1 ) \
464 /* Subtraction: (xhi+xlo) - (yhi+ylo) */
465 /* The result is sum rhi+rlo */
466 /* Temporary variables: t1 */
467 /* All variables are in long double precision */
468 /* Correct if no overflow (algorithm by T.J.Dekker) */
469 #define __LIBM_SUBL2_K80( rhi,rlo,xhi,xlo,yhi,ylo, t1 ) \
471 if ( VALUE_GT_80(FP80(xhi),FP80(yhi)) ) { \
472 t1=xhi-rlo;t1=t1-yhi;t1=t1-ylo;t1=t1+xlo; \
474 t1=yhi+rlo;t1=xhi-t1;t1=t1+xlo;t1=t1-ylo; \
477 rlo=rlo-rhi;rlo=rlo+t1;
479 /* Subtraction: r=x-y */
480 /* Variables r,x,y are pointers to struct ker80, */
481 /* all other variables are in long double precision */
482 /* Temporary variables: t1 */
483 /* Correct if x and y belong to interval [2^-8000;2^8000], */
484 /* or when one or both of them are zero */
485 #if defined(SIZE_INT_32)
486 #define __LIBM_SUBL_K80(r,x,y, t1) \
487 if ( ((y)->ex+(y)->fphi.exponent-134 < \
488 (x)->ex+(x)->fphi.exponent) && \
489 ((x)->ex+(x)->fphi.exponent < \
490 (y)->ex+(y)->fphi.exponent+134) && \
491 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
492 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
494 /* y/2^134 < x < y*2^134, */ \
495 /* and x,y are nonzero finite numbers */ \
496 if ( (x)->ex != (y)->ex ) { \
497 /* adjust x->ex to y->ex */ \
498 /* t1 = 2^(x->ex - y->ex) */ \
499 FP80(t1)->sign = 0; \
500 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
501 /* exponent is correct because */ \
502 /* |x->ex - y->ex| = */ \
503 /* = | (x->ex + x->fphi.exponent) - */ \
504 /* -(y->ex + y->fphi.exponent) + */ \
505 /* + y->fphi.exponent - */ \
506 /* - x->fphi.exponent | < */ \
507 /* < | (x->ex+x->fphi.exponent) - */ \
508 /* -(y->ex+y->fphi.exponent) | + */ \
509 /* +| y->fphi.exponent - */ \
510 /* -x->fphi.exponent | < */ \
511 /* < 134 + 16000 */ \
512 FP80(t1)->hi_significand = 0x80000000; \
513 FP80(t1)->lo_significand = 0x00000000; \
520 __LIBM_SUBL2_K80( (r)->ldhi,(r)->ldlo, \
521 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
522 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
523 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
524 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
528 (r)->ldhi = -((y)->ldhi); \
529 (r)->ldlo = -((y)->ldlo); \
534 #elif defined(SIZE_INT_64)
535 #define __LIBM_SUBL_K80(r,x,y, t1) \
536 if ( ((y)->ex+(y)->fphi.exponent-134 < \
537 (x)->ex+(x)->fphi.exponent) && \
538 ((x)->ex+(x)->fphi.exponent < \
539 (y)->ex+(y)->fphi.exponent+134) && \
540 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
541 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
543 /* y/2^134 < x < y*2^134, */ \
544 /* and x,y are nonzero finite numbers */ \
545 if ( (x)->ex != (y)->ex ) { \
546 /* adjust x->ex to y->ex */ \
547 /* t1 = 2^(x->ex - y->ex) */ \
548 FP80(t1)->sign = 0; \
549 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
550 /* exponent is correct because */ \
551 /* |x->ex - y->ex| = */ \
552 /* = | (x->ex + x->fphi.exponent) - */ \
553 /* -(y->ex + y->fphi.exponent) + */ \
554 /* + y->fphi.exponent - */ \
555 /* - x->fphi.exponent | < */ \
556 /* < | (x->ex+x->fphi.exponent) - */ \
557 /* -(y->ex+y->fphi.exponent) | + */ \
558 /* +| y->fphi.exponent - */ \
559 /* -x->fphi.exponent | < */ \
560 /* < 134 + 16000 */ \
561 FP80(t1)->significand = 0x8000000000000000; \
568 __LIBM_SUBL2_K80( (r)->ldhi,(r)->ldlo, \
569 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
570 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
571 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
572 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
576 (r)->ldhi = -((y)->ldhi); \
577 (r)->ldlo = -((y)->ldlo); \
584 /* Subtraction: r=x+y */
585 /* Variables r,x,y are pointers to struct ker80, */
586 /* all other variables are in long double precision */
587 /* Temporary variables: t1 */
588 /* Correct for any finite x and y */
589 #define __LIBM_SUBL_NORM_K80(r,x,y, t1) \
590 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
591 ((x)->fphi.exponent-BIAS_80>+8000) || \
592 ((y)->fphi.exponent-BIAS_80<-8000) || \
593 ((y)->fphi.exponent-BIAS_80>+8000) ) \
595 __libm_normalizel_k80(x); \
596 __libm_normalizel_k80(y); \
598 __LIBM_SUBL_K80(r,x,y, t1)
600 /* Multiplication: x*y */
601 /* The result is sum rhi+rlo */
602 /* Here t32 is the constant 2^32+1 */
603 /* Temporary variables: t1,t2,t3,t4,t5,t6 */
604 /* All variables are in long double precision */
605 /* Correct if no over/underflow (algorithm by T.J.Dekker) */
606 #define __LIBM_MULL1_K80(rhi,rlo,x,y, \
607 t32,t1,t2,t3,t4,t5,t6) \
608 t1=(x)*(t32); t3=x-t1; t3=t3+t1; t4=x-t3; \
609 t1=(y)*(t32); t5=y-t1; t5=t5+t1; t6=y-t5; \
611 t2=(t3)*(t6)+(t4)*(t5); \
613 rlo=t1-rhi; rlo=rlo+t2; rlo=rlo+(t4*t6);
615 /* Multiplication: (xhi+xlo)*(yhi+ylo) */
616 /* The result is sum rhi+rlo */
617 /* Here t32 is the constant 2^32+1 */
618 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
619 /* All variables are in long double precision */
620 /* Correct if no over/underflow (algorithm by T.J.Dekker) */
621 #define __LIBM_MULL2_K80(rhi,rlo,xhi,xlo,yhi,ylo, \
622 t32,t1,t2,t3,t4,t5,t6,t7,t8) \
623 __LIBM_MULL1_K80(t7,t8,xhi,yhi, t32,t1,t2,t3,t4,t5,t6) \
624 t1=(xhi)*(ylo)+(xlo)*(yhi); t1=t1+t8; \
626 rlo=t7-rhi; rlo=rlo+t1;
628 /* Multiplication: r=x*y */
629 /* Variables r,x,y are pointers to struct ker80, */
630 /* all other variables are in long double precision */
631 /* Here t32 is the constant 2^32+1 */
632 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
633 /* Correct if x and y belong to interval [2^-8000;2^8000] */
634 #define __LIBM_MULL_K80(r,x,y, t32,t1,t2,t3,t4,t5,t6,t7,t8) \
635 (r)->ex = (x)->ex + (y)->ex; \
636 __LIBM_MULL2_K80((r)->ldhi,(r)->ldlo, \
637 (x)->ldhi,(x)->ldlo,(y)->ldhi,(y)->ldlo, \
638 t32,t1,t2,t3,t4,t5,t6,t7,t8)
640 /* Multiplication: r=x*y */
641 /* Variables r,x,y are pointers to struct ker80, */
642 /* all other variables are in long double precision */
643 /* Here t32 is the constant 2^32+1 */
644 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
645 /* Correct for any finite x and y */
646 #define __LIBM_MULL_NORM_K80(r,x,y, \
647 t32,t1,t2,t3,t4,t5,t6,t7,t8) \
648 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
649 ((x)->fphi.exponent-BIAS_80>+8000) || \
650 ((y)->fphi.exponent-BIAS_80<-8000) || \
651 ((y)->fphi.exponent-BIAS_80>+8000) ) \
653 __libm_normalizel_k80(x); \
654 __libm_normalizel_k80(y); \
656 __LIBM_MULL_K80(r,x,y, t32,t1,t2,t3,t4,t5,t6,t7,t8)
658 /* Division: (xhi+xlo)/(yhi+ylo) */
659 /* The result is sum rhi+rlo */
660 /* Here t32 is the constant 2^32+1 */
661 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
662 /* All variables are in long double precision */
663 /* Correct if no over/underflow (algorithm by T.J.Dekker) */
664 #define __LIBM_DIVL2_K80(rhi,rlo,xhi,xlo,yhi,ylo, \
665 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
667 __LIBM_MULL1_K80(t8,t9,t7,yhi, t32,t1,t2,t3,t4,t5,t6) \
668 t1=xhi-t8; t1=t1-t9; t1=t1+xlo; t1=t1-(t7)*(ylo); \
671 rlo=t7-rhi; rlo=rlo+t1;
673 /* Division: r=x/y */
674 /* Variables r,x,y are pointers to struct ker80, */
675 /* all other variables are in long double precision */
676 /* Here t32 is the constant 2^32+1 */
677 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
678 /* Correct if x and y belong to interval [2^-8000;2^8000] */
679 #define __LIBM_DIVL_K80(r,x,y, \
680 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
681 (r)->ex = (x)->ex - (y)->ex; \
682 __LIBM_DIVL2_K80( (r)->ldhi,(r)->ldlo, \
683 (x)->ldhi,(x)->ldlo,(y)->ldhi,(y)->ldlo, \
684 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9)
686 /* Division: r=x/y */
687 /* Variables r,x,y are pointers to struct ker80, */
688 /* all other variables are in long double precision */
689 /* Here t32 is the constant 2^32+1 */
690 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
691 /* Correct for any finite x and y */
692 #define __LIBM_DIVL_NORM_K80(r,x,y, \
693 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
694 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
695 ((x)->fphi.exponent-BIAS_80>+8000) || \
696 ((y)->fphi.exponent-BIAS_80<-8000) || \
697 ((y)->fphi.exponent-BIAS_80>+8000) ) \
699 __libm_normalizel_k80(x); \
700 __libm_normalizel_k80(y); \
702 __LIBM_DIVL_K80(r,x,y, t32,t1,t2,t3,t4,t5,t6,t7,t8,t9)
704 /* Square root: sqrt(xhi+xlo) */
705 /* The result is sum rhi+rlo */
706 /* Here t32 is the constant 2^32+1 */
707 /* half is the constant 0.5 */
708 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
709 /* All variables are in long double precision */
710 /* Correct for positive xhi+xlo (algorithm by T.J.Dekker) */
711 #define __LIBM_SQRTL2_NORM_K80(rhi,rlo,xhi,xlo, \
712 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
714 __LIBM_MULL1_K80(t8,t9,t7,t7, t32,t1,t2,t3,t4,t5,t6) \
715 t1=xhi-t8; t1=t1-t9; t1=t1+xlo; t1=(t1)*(half); \
718 rlo=t7-rhi; rlo=rlo+t1;
720 /* Square root: r=sqrt(x) */
721 /* Variables r,x,y are pointers to struct ker80, */
722 /* all other variables are in long double precision */
723 /* Here t32 is the constant 2^32+1 */
724 /* half is the constant 0.5 */
725 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
726 /* Correct if x belongs to interval [2^-16000;2^16000] */
727 #define __LIBM_SQRTL_K80(r,x, \
728 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
729 if ( ((x)->ex & 1) == 1 ) { \
730 (x)->ex = (x)->ex + 1; \
734 (r)->ex = (x)->ex >> 1; \
735 __LIBM_SQRTL2_NORM_K80( (r)->ldhi,(r)->ldlo, \
736 (x)->ldhi,(x)->ldlo, \
737 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9)
739 /* Square root: r=sqrt(x) */
740 /* Variables r,x,y are pointers to struct ker80, */
741 /* all other variables are in long double precision */
742 /* Here t32 is the constant 2^32+1 */
743 /* half is the constant 0.5 */
744 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
745 /* Correct for any positive x */
746 #define __LIBM_SQRTL_NORM_K80(r,x, \
747 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
748 if ( ((x)->fphi.exponent-BIAS_80<-16000) || \
749 ((x)->fphi.exponent-BIAS_80>+16000) ) \
751 __libm_normalizel_k80(x); \
753 __LIBM_SQRTL_K80(r,x, t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9)
756 #ifdef __INTEL_COMPILER
757 #define ALIGN(n) __declspec(align(n))
758 #else /* __INTEL_COMPILER */
760 #endif /* __INTEL_COMPILER */
762 /* macros to form a long double value in hex representation (unsigned short type) */
764 #if (defined(__unix__) && defined(__i386__))
765 # define LDOUBLE_ALIGN 12 /* IA32 Linux: 12-byte alignment */
766 #else /*__linux__ & IA32*/
767 # define LDOUBLE_ALIGN 16 /* EFI2/IA32 Win or IPF Win/Linux: 16-byte alignment */
768 #endif /*__linux__ & IA32*/
770 #if (LDOUBLE_ALIGN == 16)
771 #define _XPD_ ,0x0000,0x0000,0x0000
773 #define _XPD_ ,0x0000
776 #define LDOUBLE_HEX(w4,w3,w2,w1,w0) 0x##w0,0x##w1,0x##w2,0x##w3,0x##w4 _XPD_ /*LITTLE_ENDIAN*/
778 /* macros to sign-expand low 'num' bits of 'val' to native integer */
780 #if defined(SIZE_INT_32)
781 # define SIGN_EXPAND(val,num) ((int)(val) << (32-(num))) >> (32-(num)) /* sign expand of 'num' LSBs */
782 #elif defined(SIZE_INT_64)
783 # define SIGN_EXPAND(val,num) ((int)(val) << (64-(num))) >> (64-(num)) /* sign expand of 'num' LSBs */
786 /* macros to form pointers to FP number on-the-fly */
788 #define FP32(f) ((struct fp32 *)&f)
789 #define FP64(d) ((struct fp64 *)&d)
790 #define FP80(ld) ((struct fp80 *)&ld)
792 /* macros to extract signed low and high doubleword of long double */
794 #if defined(SIZE_INT_32)
795 # define HI_DWORD_80(ld) ((((FP80(ld)->sign << 15) | FP80(ld)->exponent) << 16) | \
796 ((FP80(ld)->hi_significand >> 16) & 0xFFFF))
797 # define LO_DWORD_80(ld) SIGN_EXPAND(FP80(ld)->lo_significand, 32)
798 #elif defined(SIZE_INT_64)
799 # define HI_DWORD_80(ld) ((((FP80(ld)->sign << 15) | FP80(ld)->exponent) << 16) | \
800 ((FP80(ld)->significand >> 48) & 0xFFFF))
801 # define LO_DWORD_80(ld) SIGN_EXPAND(FP80(ld)->significand, 32)
804 /* macros to extract hi bits of significand.
805 * note that explicit high bit do not count (returns as is)
808 #if defined(SIZE_INT_32)
809 # define HI_SIGNIFICAND_80(X,NBITS) ((X)->hi_significand >> (31 - (NBITS)))
810 #elif defined(SIZE_INT_64)
811 # define HI_SIGNIFICAND_80(X,NBITS) ((X)->significand >> (63 - (NBITS)))
814 /* macros to check, whether a significand bits are all zero, or some of them are non-zero.
815 * note that SIGNIFICAND_ZERO_80 tests high bit also, but SIGNIFICAND_NONZERO_80 does not
818 #define SIGNIFICAND_ZERO_32(X) ((X)->significand == 0)
819 #define SIGNIFICAND_NONZERO_32(X) ((X)->significand != 0)
821 #if defined(SIZE_INT_32)
822 # define SIGNIFICAND_ZERO_64(X) (((X)->hi_significand == 0) && ((X)->lo_significand == 0))
823 # define SIGNIFICAND_NONZERO_64(X) (((X)->hi_significand != 0) || ((X)->lo_significand != 0))
824 #elif defined(SIZE_INT_64)
825 # define SIGNIFICAND_ZERO_64(X) ((X)->significand == 0)
826 # define SIGNIFICAND_NONZERO_64(X) ((X)->significand != 0)
829 #if defined(SIZE_INT_32)
830 # define SIGNIFICAND_ZERO_80(X) (((X)->hi_significand == 0x00000000) && ((X)->lo_significand == 0))
831 # define SIGNIFICAND_NONZERO_80(X) (((X)->hi_significand != 0x80000000) || ((X)->lo_significand != 0))
832 #elif defined(SIZE_INT_64)
833 # define SIGNIFICAND_ZERO_80(X) ((X)->significand == 0x0000000000000000)
834 # define SIGNIFICAND_NONZERO_80(X) ((X)->significand != 0x8000000000000000)
837 /* macros to compare long double with constant value, represented as hex */
839 #define SIGNIFICAND_EQ_HEX_32(X,BITS) ((X)->significand == 0x ## BITS)
840 #define SIGNIFICAND_GT_HEX_32(X,BITS) ((X)->significand > 0x ## BITS)
841 #define SIGNIFICAND_GE_HEX_32(X,BITS) ((X)->significand >= 0x ## BITS)
842 #define SIGNIFICAND_LT_HEX_32(X,BITS) ((X)->significand < 0x ## BITS)
843 #define SIGNIFICAND_LE_HEX_32(X,BITS) ((X)->significand <= 0x ## BITS)
845 #if defined(SIZE_INT_32)
846 # define SIGNIFICAND_EQ_HEX_64(X,HI,LO) \
847 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand == 0x ## LO))
848 # define SIGNIFICAND_GT_HEX_64(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
849 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand > 0x ## LO)))
850 # define SIGNIFICAND_GE_HEX_64(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
851 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand >= 0x ## LO)))
852 # define SIGNIFICAND_LT_HEX_64(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
853 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand < 0x ## LO)))
854 # define SIGNIFICAND_LE_HEX_64(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
855 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand <= 0x ## LO)))
856 #elif defined(SIZE_INT_64)
857 # define SIGNIFICAND_EQ_HEX_64(X,HI,LO) ((X)->significand == 0x ## HI ## LO)
858 # define SIGNIFICAND_GT_HEX_64(X,HI,LO) ((X)->significand > 0x ## HI ## LO)
859 # define SIGNIFICAND_GE_HEX_64(X,HI,LO) ((X)->significand >= 0x ## HI ## LO)
860 # define SIGNIFICAND_LT_HEX_64(X,HI,LO) ((X)->significand < 0x ## HI ## LO)
861 # define SIGNIFICAND_LE_HEX_64(X,HI,LO) ((X)->significand <= 0x ## HI ## LO)
864 #if defined(SIZE_INT_32)
865 # define SIGNIFICAND_EQ_HEX_80(X,HI,LO) \
866 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand == 0x ## LO))
867 # define SIGNIFICAND_GT_HEX_80(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
868 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand > 0x ## LO)))
869 # define SIGNIFICAND_GE_HEX_80(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
870 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand >= 0x ## LO)))
871 # define SIGNIFICAND_LT_HEX_80(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
872 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand < 0x ## LO)))
873 # define SIGNIFICAND_LE_HEX_80(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
874 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand <= 0x ## LO)))
875 #elif defined(SIZE_INT_64)
876 # define SIGNIFICAND_EQ_HEX_80(X,HI,LO) ((X)->significand == 0x ## HI ## LO)
877 # define SIGNIFICAND_GT_HEX_80(X,HI,LO) ((X)->significand > 0x ## HI ## LO)
878 # define SIGNIFICAND_GE_HEX_80(X,HI,LO) ((X)->significand >= 0x ## HI ## LO)
879 # define SIGNIFICAND_LT_HEX_80(X,HI,LO) ((X)->significand < 0x ## HI ## LO)
880 # define SIGNIFICAND_LE_HEX_80(X,HI,LO) ((X)->significand <= 0x ## HI ## LO)
883 #define VALUE_EQ_HEX_32(X,EXP,BITS) \
884 (((X)->exponent == (EXP)) && (SIGNIFICAND_EQ_HEX_32(X, BITS)))
885 #define VALUE_GT_HEX_32(X,EXP,BITS) (((X)->exponent > (EXP)) || \
886 (((X)->exponent == (EXP)) && (SIGNIFICAND_GT_HEX_32(X, BITS))))
887 #define VALUE_GE_HEX_32(X,EXP,BITS) (((X)->exponent > (EXP)) || \
888 (((X)->exponent == (EXP)) && (SIGNIFICAND_GE_HEX_32(X, BITS))))
889 #define VALUE_LT_HEX_32(X,EXP,BITS) (((X)->exponent < (EXP)) || \
890 (((X)->exponent == (EXP)) && (SIGNIFICAND_LT_HEX_32(X, BITS))))
891 #define VALUE_LE_HEX_32(X,EXP,BITS) (((X)->exponent < (EXP)) || \
892 (((X)->exponent == (EXP)) && (SIGNIFICAND_LE_HEX_32(X, BITS))))
894 #define VALUE_EQ_HEX_64(X,EXP,HI,LO) \
895 (((X)->exponent == (EXP)) && (SIGNIFICAND_EQ_HEX_64(X, HI, LO)))
896 #define VALUE_GT_HEX_64(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
897 (((X)->exponent == (EXP)) && (SIGNIFICAND_GT_HEX_64(X, HI, LO))))
898 #define VALUE_GE_HEX_64(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
899 (((X)->exponent == (EXP)) && (SIGNIFICAND_GE_HEX_64(X, HI, LO))))
900 #define VALUE_LT_HEX_64(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
901 (((X)->exponent == (EXP)) && (SIGNIFICAND_LT_HEX_64(X, HI, LO))))
902 #define VALUE_LE_HEX_64(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
903 (((X)->exponent == (EXP)) && (SIGNIFICAND_LE_HEX_64(X, HI, LO))))
905 #define VALUE_EQ_HEX_80(X,EXP,HI,LO) \
906 (((X)->exponent == (EXP)) && (SIGNIFICAND_EQ_HEX_80(X, HI, LO)))
907 #define VALUE_GT_HEX_80(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
908 (((X)->exponent == (EXP)) && (SIGNIFICAND_GT_HEX_80(X, HI, LO))))
909 #define VALUE_GE_HEX_80(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
910 (((X)->exponent == (EXP)) && (SIGNIFICAND_GE_HEX_80(X, HI, LO))))
911 #define VALUE_LT_HEX_80(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
912 (((X)->exponent == (EXP)) && (SIGNIFICAND_LT_HEX_80(X, HI, LO))))
913 #define VALUE_LE_HEX_80(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
914 (((X)->exponent == (EXP)) && (SIGNIFICAND_LE_HEX_80(X, HI, LO))))
916 /* macros to compare two long doubles */
918 #define SIGNIFICAND_EQ_32(X,Y) ((X)->significand == (Y)->significand)
919 #define SIGNIFICAND_GT_32(X,Y) ((X)->significand > (Y)->significand)
920 #define SIGNIFICAND_GE_32(X,Y) ((X)->significand >= (Y)->significand)
921 #define SIGNIFICAND_LT_32(X,Y) ((X)->significand < (Y)->significand)
922 #define SIGNIFICAND_LE_32(X,Y) ((X)->significand <= (Y)->significand)
924 #if defined(SIZE_INT_32)
925 # define SIGNIFICAND_EQ_64(X,Y) \
926 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand == (Y)->lo_significand))
927 # define SIGNIFICAND_GT_64(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
928 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand > (Y)->lo_significand)))
929 # define SIGNIFICAND_GE_64(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
930 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand >= (Y)->lo_significand)))
931 # define SIGNIFICAND_LT_64(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
932 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand < (Y)->lo_significand)))
933 # define SIGNIFICAND_LE_64(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
934 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand <= (Y)->lo_significand)))
935 #elif defined(SIZE_INT_64)
936 # define SIGNIFICAND_EQ_64(X,Y) ((X)->significand == (Y)->significand)
937 # define SIGNIFICAND_GT_64(X,Y) ((X)->significand > (Y)->significand)
938 # define SIGNIFICAND_GE_64(X,Y) ((X)->significand >= (Y)->significand)
939 # define SIGNIFICAND_LT_64(X,Y) ((X)->significand < (Y)->significand)
940 # define SIGNIFICAND_LE_64(X,Y) ((X)->significand <= (Y)->significand)
943 #if defined(SIZE_INT_32)
944 # define SIGNIFICAND_EQ_80(X,Y) \
945 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand == (Y)->lo_significand))
946 # define SIGNIFICAND_GT_80(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
947 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand > (Y)->lo_significand)))
948 # define SIGNIFICAND_GE_80(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
949 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand >= (Y)->lo_significand)))
950 # define SIGNIFICAND_LT_80(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
951 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand < (Y)->lo_significand)))
952 # define SIGNIFICAND_LE_80(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
953 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand <= (Y)->lo_significand)))
954 #elif defined(SIZE_INT_64)
955 # define SIGNIFICAND_EQ_80(X,Y) ((X)->significand == (Y)->significand)
956 # define SIGNIFICAND_GT_80(X,Y) ((X)->significand > (Y)->significand)
957 # define SIGNIFICAND_GE_80(X,Y) ((X)->significand >= (Y)->significand)
958 # define SIGNIFICAND_LT_80(X,Y) ((X)->significand < (Y)->significand)
959 # define SIGNIFICAND_LE_80(X,Y) ((X)->significand <= (Y)->significand)
962 #define VALUE_EQ_32(X,Y) \
963 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_EQ_32(X, Y)))
964 #define VALUE_GT_32(X,Y) (((X)->exponent > (Y)->exponent) || \
965 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GT_32(X, Y))))
966 #define VALUE_GE_32(X,Y) (((X)->exponent > (Y)->exponent) || \
967 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GE_32(X, Y))))
968 #define VALUE_LT_32(X,Y) (((X)->exponent < (Y)->exponent) || \
969 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LT_32(X, Y))))
970 #define VALUE_LE_32(X,Y) (((X)->exponent < (Y)->exponent) || \
971 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LE_32(X, Y))))
973 #define VALUE_EQ_64(X,Y) \
974 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_EQ_64(X, Y)))
975 #define VALUE_GT_64(X,Y) (((X)->exponent > (Y)->exponent) || \
976 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GT_64(X, Y))))
977 #define VALUE_GE_64(X,Y) (((X)->exponent > (Y)->exponent) || \
978 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GE_64(X, Y))))
979 #define VALUE_LT_64(X,Y) (((X)->exponent < (Y)->exponent) || \
980 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LT_64(X, Y))))
981 #define VALUE_LE_64(X,Y) (((X)->exponent < (Y)->exponent) || \
982 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LE_64(X, Y))))
984 #define VALUE_EQ_80(X,Y) \
985 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_EQ_80(X, Y)))
986 #define VALUE_GT_80(X,Y) (((X)->exponent > (Y)->exponent) || \
987 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GT_80(X, Y))))
988 #define VALUE_GE_80(X,Y) (((X)->exponent > (Y)->exponent) || \
989 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GE_80(X, Y))))
990 #define VALUE_LT_80(X,Y) (((X)->exponent < (Y)->exponent) || \
991 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LT_80(X, Y))))
992 #define VALUE_LE_80(X,Y) (((X)->exponent < (Y)->exponent) || \
993 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LE_80(X, Y))))
995 /* add/subtract 1 ulp macros */
997 #if defined(SIZE_INT_32)
998 # define ADD_ULP_80(X) \
999 if ((++(X)->lo_significand == 0) && \
1000 (++(X)->hi_significand == (((X)->exponent == 0) ? 0x80000000 : 0))) \
1002 (X)->hi_significand |= 0x80000000; \
1005 # define SUB_ULP_80(X) \
1006 if (--(X)->lo_significand == 0xFFFFFFFF) { \
1007 --(X)->hi_significand; \
1008 if (((X)->exponent != 0) && \
1009 ((X)->hi_significand == 0x7FFFFFFF) && \
1010 (--(X)->exponent != 0)) \
1012 (X)->hi_significand |= 0x80000000; \
1015 #elif defined(SIZE_INT_64)
1016 # define ADD_ULP_80(X) \
1017 if (++(X)->significand == (((X)->exponent == 0) ? 0x8000000000000000 : 0))) { \
1018 (X)->significand |= 0x8000000000000000; \
1021 # define SUB_ULP_80(X) \
1023 --(X)->significand; \
1024 if (((X)->exponent != 0) && \
1025 ((X)->significand == 0x7FFFFFFFFFFFFFFF) && \
1026 (--(X)->exponent != 0)) \
1028 (X)->significand |= 0x8000000000000000; \
1036 #define DOMAIN 1 /* argument domain error */
1037 #define SING 2 /* argument singularity */
1038 #define OVERFLOW 3 /* overflow range error */
1039 #define UNDERFLOW 4 /* underflow range error */
1040 #define TLOSS 5 /* total loss of precision */
1041 #define PLOSS 6 /* partial loss of precision */
1045 #define VOLATILE_32 /*volatile*/
1046 #define VOLATILE_64 /*volatile*/
1047 #define VOLATILE_80 /*volatile*/
1049 #define QUAD_TYPE _Quad
1051 #endif /*__LIBM_SUPPORT_H_INCLUDED__*/