1 /* file: libm_support.h */
5 // Copyright (c) 2000 - 2004, Intel Corporation
6 // All rights reserved.
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
13 // * Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
16 // * Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
20 // * The name of Intel Corporation may not be used to endorse or promote
21 // products derived from this software without specific prior written
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
33 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 // Intel Corporation is the author of this code, and requests that all
38 // problem reports or change requests be submitted to it directly at
39 // http://www.intel.com/software/products/opensource/libraries/num.htm.
42 // History: 02/02/2000 Initial version
43 // 2/28/2000 added tags for logb and nextafter
44 // 3/22/2000 Changes to support _LIB_VERSIONIMF variable
45 // and filled some enum gaps. Added support for C99.
46 // 5/31/2000 added prototypes for __libm_frexp_4l/8l
47 // 8/10/2000 Changed declaration of _LIB_VERSIONIMF to work for library
48 // builds and other application builds (precompiler directives).
49 // 8/11/2000 Added pointers-to-matherr-functions declarations to allow
50 // for user-defined matherr functions in the dll build.
51 // 12/07/2000 Added scalbn error_types values.
52 // 5/01/2001 Added error_types values for C99 nearest integer
54 // 6/07/2001 Added error_types values for fdim.
55 // 6/18/2001 Added include of complex_support.h.
56 // 8/03/2001 Added error_types values for nexttoward, scalbln.
57 // 8/23/2001 Corrected tag numbers from 186 and higher.
58 // 8/27/2001 Added check for long int and long long int definitions.
59 // 12/10/2001 Added error_types for erfc.
60 // 12/27/2001 Added error_types for degree argument functions.
61 // 01/02/2002 Added error_types for tand, cotd.
62 // 01/04/2002 Delete include of complex_support.h
63 // 01/23/2002 Deleted prototypes for __libm_frexp*. Added check for
64 // multiple int, long int, and long long int definitions.
65 // 05/20/2002 Added error_types for cot.
66 // 06/27/2002 Added error_types for sinhcosh.
67 // 12/05/2002 Added error_types for annuity and compound
68 // 04/10/2003 Added error_types for tgammal/tgamma/tgammaf
69 // 05/16/2003 FP-treatment macros copied here from IA32 libm_support.h
70 // 06/02/2003 Added pad into struct fp80 (12/16 bytes).
71 // 08/01/2003 Added struct ker80 and macros for multiprecision addition,
72 // subtraction, multiplication, division, square root.
73 // 08/07/2003 History section updated.
74 // 09/03/2003 ALIGN(n) macro added.
75 // 10/01/2003 LDOUBLE_ALIGN and fp80 corrected on linux to 16 bytes.
76 // 11/24/2004 Added ifdef around definitions of INT32/64
77 // 12/15/2004 Added error_types for exp10, nextafter, nexttoward
78 // underflow. Moved error codes into libm_error_codes.h.
82 #ifndef __LIBM_SUPPORT_H_INCLUDED__
83 #define __LIBM_SUPPORT_H_INCLUDED__
85 #include <math-svid-compat.h>
88 #if !(defined(_WIN32) || defined(_WIN64))
89 # pragma const_seg(".rodata") /* place constant data in text (code) section */
92 #if defined(__ICC) || defined(__ICL) || defined(__ECC) || defined(__ECL)
93 # pragma warning( disable : 1682 ) /* #1682: ixplicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) */
94 # pragma warning( disable : 1683 ) /* #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) */
98 /* macros to form a double value in hex representation (unsigned int type) */
100 #define DOUBLE_HEX(hi,lo) 0x##lo,0x##hi /*LITTLE_ENDIAN*/
102 #include "libm_cpu_defs.h"
104 #if !(defined (IA64))
105 # include "libm_dll.h"
106 # include "libm_dispatch.h"
109 #include "libm_error_codes.h"
115 float arg1
, arg2
, retval
;
123 double arg1
, arg2
, retval
;
132 double arg1
, arg2
, retval
;
141 long double arg1
, arg2
, retval
;
144 #if (defined (_MS_) && defined (IA64))
145 #define MATHERR_F _matherrf
146 #define MATHERR_D _matherr
148 #define MATHERR_F matherrf
149 #define MATHERR_D matherr
153 #define EXC_DECL_D __exception
155 // exception is a reserved name in C++
156 #define EXC_DECL_D exception
159 extern int MATHERR_F(struct exceptionf
*);
160 extern int matherrl(struct exceptionl
*);
162 /* memory format definitions (LITTLE_ENDIAN only) */
164 #if !(defined(SIZE_INT_32) || defined(SIZE_INT_64))
165 # error "You need to define SIZE_INT_32 or SIZE_INT_64"
168 #if (defined(SIZE_INT_32) && defined(SIZE_INT_64))
169 #error multiple integer size definitions; define SIZE_INT_32 or SIZE_INT_64
172 #if !(defined(SIZE_LONG_32) || defined(SIZE_LONG_64))
173 # error "You need to define SIZE_LONG_32 or SIZE_LONG_64"
176 #if (defined(SIZE_LONG_32) && defined(SIZE_LONG_64))
177 #error multiple integer size definitions; define SIZE_LONG_32 or SIZE_LONG_64
180 #if !defined(__USE_EXTERNAL_FPMEMTYP_H__)
182 #define BIAS_32 0x007F
183 #define BIAS_64 0x03FF
184 #define BIAS_80 0x3FFF
186 #define MAXEXP_32 0x00FE
187 #define MAXEXP_64 0x07FE
188 #define MAXEXP_80 0x7FFE
190 #define EXPINF_32 0x00FF
191 #define EXPINF_64 0x07FF
192 #define EXPINF_80 0x7FFF
194 struct fp32
{ /*// sign:1 exponent:8 significand:23 (implied leading 1)*/
195 #if defined(SIZE_INT_32)
196 unsigned significand
:23;
199 #elif defined(SIZE_INT_64)
200 unsigned significand
:23;
206 struct fp64
{ /*/ sign:1 exponent:11 significand:52 (implied leading 1)*/
207 #if defined(SIZE_INT_32)
208 unsigned lo_significand
:32;
209 unsigned hi_significand
:20;
210 unsigned exponent
:11;
212 #elif defined(SIZE_INT_64)
213 unsigned significand
:52;
214 unsigned exponent
:11;
219 struct fp80
{ /*/ sign:1 exponent:15 significand:64 (NO implied bits) */
220 #if defined(SIZE_INT_32)
221 unsigned lo_significand
;
222 unsigned hi_significand
;
223 unsigned exponent
:15;
225 #elif defined(SIZE_INT_64)
226 unsigned significand
;
227 unsigned exponent
:15;
231 #if !(defined(__unix__) && defined(__i386__))
236 #endif /*__USE_EXTERNAL_FPMEMTYP_H__*/
238 #if !(defined(opensource))
239 typedef __int32 INT32
;
240 typedef signed __int32 SINT32
;
241 typedef unsigned __int32 UINT32
;
243 typedef __int64 INT64
;
244 typedef signed __int64 SINT64
;
245 typedef unsigned __int64 UINT64
;
248 typedef signed int SINT32
;
249 typedef unsigned int UINT32
;
251 typedef long long INT64
;
252 typedef signed long long SINT64
;
253 typedef unsigned long long UINT64
;
256 #if (defined(_WIN32) || defined(_WIN64)) /* Windows */
257 # define I64CONST(bits) 0x##bits##i64
258 # define U64CONST(bits) 0x##bits##ui64
259 #elif (defined(__linux__) && defined(_M_IA64)) /* Linux,64 */
260 # define I64CONST(bits) 0x##bits##L
261 # define U64CONST(bits) 0x##bits##uL
263 # define I64CONST(bits) 0x##bits##LL
264 # define U64CONST(bits) 0x##bits##uLL
280 /* The result is sum rhi+rlo */
281 /* Temporary variables: t1 */
282 /* All variables are in long double precision */
283 /* Correct if no overflow (algorithm by D.Knuth) */
284 #define __LIBM_ADDL1_K80( rhi,rlo,x,y, t1 ) \
292 /* Addition: (xhi+xlo) + (yhi+ylo) */
293 /* The result is sum rhi+rlo */
294 /* Temporary variables: t1 */
295 /* All variables are in long double precision */
296 /* Correct if no overflow (algorithm by T.J.Dekker) */
297 #define __LIBM_ADDL2_K80( rhi,rlo,xhi,xlo,yhi,ylo, t1 ) \
299 if ( VALUE_GT_80(FP80(xhi),FP80(yhi)) ) { \
300 t1=xhi-rlo;t1=t1+yhi;t1=t1+ylo;t1=t1+xlo; \
302 t1=yhi-rlo;t1=t1+xhi;t1=t1+xlo;t1=t1+ylo; \
305 rlo=rlo-rhi;rlo=rlo+t1;
307 /* Addition: r=x+y */
308 /* Variables r,x,y are pointers to struct ker80, */
309 /* all other variables are in long double precision */
310 /* Temporary variables: t1 */
311 /* Correct if x and y belong to interval [2^-8000;2^8000], */
312 /* or when one or both of them are zero */
313 #if defined(SIZE_INT_32)
314 #define __LIBM_ADDL_K80(r,x,y, t1) \
315 if ( ((y)->ex+(y)->fphi.exponent-134 < \
316 (x)->ex+(x)->fphi.exponent) && \
317 ((x)->ex+(x)->fphi.exponent < \
318 (y)->ex+(y)->fphi.exponent+134) && \
319 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
320 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
322 /* y/2^134 < x < y*2^134, */ \
323 /* and x,y are nonzero finite numbers */ \
324 if ( (x)->ex != (y)->ex ) { \
325 /* adjust x->ex to y->ex */ \
326 /* t1 = 2^(x->ex - y->ex) */ \
327 FP80(t1)->sign = 0; \
328 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
329 /* exponent is correct because */ \
330 /* |x->ex - y->ex| = */ \
331 /* = | (x->ex + x->fphi.exponent) - */ \
332 /* -(y->ex + y->fphi.exponent) + */ \
333 /* + y->fphi.exponent - */ \
334 /* - x->fphi.exponent | < */ \
335 /* < | (x->ex+x->fphi.exponent) - */ \
336 /* -(y->ex+y->fphi.exponent) | + */ \
337 /* +| y->fphi.exponent - */ \
338 /* -x->fphi.exponent | < */ \
339 /* < 134 + 16000 */ \
340 FP80(t1)->hi_significand = 0x80000000; \
341 FP80(t1)->lo_significand = 0x00000000; \
348 __LIBM_ADDL2_K80( (r)->ldhi,(r)->ldlo, \
349 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
350 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
351 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
352 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
360 #elif defined(SIZE_INT_64)
361 #define __LIBM_ADDL_K80(r,x,y, t1) \
362 if ( ((y)->ex+(y)->fphi.exponent-134 < \
363 (x)->ex+(x)->fphi.exponent) && \
364 ((x)->ex+(x)->fphi.exponent < \
365 (y)->ex+(y)->fphi.exponent+134) && \
366 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
367 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
369 /* y/2^134 < x < y*2^134, */ \
370 /* and x,y are nonzero finite numbers */ \
371 if ( (x)->ex != (y)->ex ) { \
372 /* adjust x->ex to y->ex */ \
373 /* t1 = 2^(x->ex - y->ex) */ \
374 FP80(t1)->sign = 0; \
375 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
376 /* exponent is correct because */ \
377 /* |x->ex - y->ex| = */ \
378 /* = | (x->ex + x->fphi.exponent) - */ \
379 /* -(y->ex + y->fphi.exponent) + */ \
380 /* + y->fphi.exponent - */ \
381 /* - x->fphi.exponent | < */ \
382 /* < | (x->ex+x->fphi.exponent) - */ \
383 /* -(y->ex+y->fphi.exponent) | + */ \
384 /* +| y->fphi.exponent - */ \
385 /* -x->fphi.exponent | < */ \
386 /* < 134 + 16000 */ \
387 FP80(t1)->significand = 0x8000000000000000; \
394 __LIBM_ADDL2_K80( (r)->ldhi,(r)->ldlo, \
395 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
396 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
397 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
398 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
408 /* Addition: r=x+y */
409 /* Variables r,x,y are pointers to struct ker80, */
410 /* all other variables are in long double precision */
411 /* Temporary variables: t1 */
412 /* Correct for any finite x and y */
413 #define __LIBM_ADDL_NORM_K80(r,x,y, t1) \
414 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
415 ((x)->fphi.exponent-BIAS_80>+8000) || \
416 ((y)->fphi.exponent-BIAS_80<-8000) || \
417 ((y)->fphi.exponent-BIAS_80>+8000) ) \
419 __libm_normalizel_k80(x); \
420 __libm_normalizel_k80(y); \
422 __LIBM_ADDL_K80(r,x,y, t1)
424 /* Subtraction: x-y */
425 /* The result is sum rhi+rlo */
426 /* Temporary variables: t1 */
427 /* All variables are in long double precision */
428 /* Correct if no overflow (algorithm by D.Knuth) */
429 #define __LIBM_SUBL1_K80( rhi, rlo, x, y, t1 ) \
437 /* Subtraction: (xhi+xlo) - (yhi+ylo) */
438 /* The result is sum rhi+rlo */
439 /* Temporary variables: t1 */
440 /* All variables are in long double precision */
441 /* Correct if no overflow (algorithm by T.J.Dekker) */
442 #define __LIBM_SUBL2_K80( rhi,rlo,xhi,xlo,yhi,ylo, t1 ) \
444 if ( VALUE_GT_80(FP80(xhi),FP80(yhi)) ) { \
445 t1=xhi-rlo;t1=t1-yhi;t1=t1-ylo;t1=t1+xlo; \
447 t1=yhi+rlo;t1=xhi-t1;t1=t1+xlo;t1=t1-ylo; \
450 rlo=rlo-rhi;rlo=rlo+t1;
452 /* Subtraction: r=x-y */
453 /* Variables r,x,y are pointers to struct ker80, */
454 /* all other variables are in long double precision */
455 /* Temporary variables: t1 */
456 /* Correct if x and y belong to interval [2^-8000;2^8000], */
457 /* or when one or both of them are zero */
458 #if defined(SIZE_INT_32)
459 #define __LIBM_SUBL_K80(r,x,y, t1) \
460 if ( ((y)->ex+(y)->fphi.exponent-134 < \
461 (x)->ex+(x)->fphi.exponent) && \
462 ((x)->ex+(x)->fphi.exponent < \
463 (y)->ex+(y)->fphi.exponent+134) && \
464 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
465 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
467 /* y/2^134 < x < y*2^134, */ \
468 /* and x,y are nonzero finite numbers */ \
469 if ( (x)->ex != (y)->ex ) { \
470 /* adjust x->ex to y->ex */ \
471 /* t1 = 2^(x->ex - y->ex) */ \
472 FP80(t1)->sign = 0; \
473 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
474 /* exponent is correct because */ \
475 /* |x->ex - y->ex| = */ \
476 /* = | (x->ex + x->fphi.exponent) - */ \
477 /* -(y->ex + y->fphi.exponent) + */ \
478 /* + y->fphi.exponent - */ \
479 /* - x->fphi.exponent | < */ \
480 /* < | (x->ex+x->fphi.exponent) - */ \
481 /* -(y->ex+y->fphi.exponent) | + */ \
482 /* +| y->fphi.exponent - */ \
483 /* -x->fphi.exponent | < */ \
484 /* < 134 + 16000 */ \
485 FP80(t1)->hi_significand = 0x80000000; \
486 FP80(t1)->lo_significand = 0x00000000; \
493 __LIBM_SUBL2_K80( (r)->ldhi,(r)->ldlo, \
494 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
495 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
496 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
497 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
501 (r)->ldhi = -((y)->ldhi); \
502 (r)->ldlo = -((y)->ldlo); \
507 #elif defined(SIZE_INT_64)
508 #define __LIBM_SUBL_K80(r,x,y, t1) \
509 if ( ((y)->ex+(y)->fphi.exponent-134 < \
510 (x)->ex+(x)->fphi.exponent) && \
511 ((x)->ex+(x)->fphi.exponent < \
512 (y)->ex+(y)->fphi.exponent+134) && \
513 !SIGNIFICAND_ZERO_80(&((x)->fphi)) && \
514 !SIGNIFICAND_ZERO_80(&((y)->fphi)) ) \
516 /* y/2^134 < x < y*2^134, */ \
517 /* and x,y are nonzero finite numbers */ \
518 if ( (x)->ex != (y)->ex ) { \
519 /* adjust x->ex to y->ex */ \
520 /* t1 = 2^(x->ex - y->ex) */ \
521 FP80(t1)->sign = 0; \
522 FP80(t1)->exponent = BIAS_80 + (x)->ex-(y)->ex; \
523 /* exponent is correct because */ \
524 /* |x->ex - y->ex| = */ \
525 /* = | (x->ex + x->fphi.exponent) - */ \
526 /* -(y->ex + y->fphi.exponent) + */ \
527 /* + y->fphi.exponent - */ \
528 /* - x->fphi.exponent | < */ \
529 /* < | (x->ex+x->fphi.exponent) - */ \
530 /* -(y->ex+y->fphi.exponent) | + */ \
531 /* +| y->fphi.exponent - */ \
532 /* -x->fphi.exponent | < */ \
533 /* < 134 + 16000 */ \
534 FP80(t1)->significand = 0x8000000000000000; \
541 __LIBM_SUBL2_K80( (r)->ldhi,(r)->ldlo, \
542 (x)->ldhi,(x)->ldlo, (y)->ldhi,(y)->ldlo, t1 ); \
543 } else if ( SIGNIFICAND_ZERO_80(&((x)->fphi)) || \
544 ((y)->ex+(y)->fphi.exponent-BIAS_80 - 134 >= \
545 (x)->ex+(x)->fphi.exponent-BIAS_80) ) \
549 (r)->ldhi = -((y)->ldhi); \
550 (r)->ldlo = -((y)->ldlo); \
557 /* Subtraction: r=x+y */
558 /* Variables r,x,y are pointers to struct ker80, */
559 /* all other variables are in long double precision */
560 /* Temporary variables: t1 */
561 /* Correct for any finite x and y */
562 #define __LIBM_SUBL_NORM_K80(r,x,y, t1) \
563 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
564 ((x)->fphi.exponent-BIAS_80>+8000) || \
565 ((y)->fphi.exponent-BIAS_80<-8000) || \
566 ((y)->fphi.exponent-BIAS_80>+8000) ) \
568 __libm_normalizel_k80(x); \
569 __libm_normalizel_k80(y); \
571 __LIBM_SUBL_K80(r,x,y, t1)
573 /* Multiplication: x*y */
574 /* The result is sum rhi+rlo */
575 /* Here t32 is the constant 2^32+1 */
576 /* Temporary variables: t1,t2,t3,t4,t5,t6 */
577 /* All variables are in long double precision */
578 /* Correct if no over/underflow (algorithm by T.J.Dekker) */
579 #define __LIBM_MULL1_K80(rhi,rlo,x,y, \
580 t32,t1,t2,t3,t4,t5,t6) \
581 t1=(x)*(t32); t3=x-t1; t3=t3+t1; t4=x-t3; \
582 t1=(y)*(t32); t5=y-t1; t5=t5+t1; t6=y-t5; \
584 t2=(t3)*(t6)+(t4)*(t5); \
586 rlo=t1-rhi; rlo=rlo+t2; rlo=rlo+(t4*t6);
588 /* Multiplication: (xhi+xlo)*(yhi+ylo) */
589 /* The result is sum rhi+rlo */
590 /* Here t32 is the constant 2^32+1 */
591 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
592 /* All variables are in long double precision */
593 /* Correct if no over/underflow (algorithm by T.J.Dekker) */
594 #define __LIBM_MULL2_K80(rhi,rlo,xhi,xlo,yhi,ylo, \
595 t32,t1,t2,t3,t4,t5,t6,t7,t8) \
596 __LIBM_MULL1_K80(t7,t8,xhi,yhi, t32,t1,t2,t3,t4,t5,t6) \
597 t1=(xhi)*(ylo)+(xlo)*(yhi); t1=t1+t8; \
599 rlo=t7-rhi; rlo=rlo+t1;
601 /* Multiplication: r=x*y */
602 /* Variables r,x,y are pointers to struct ker80, */
603 /* all other variables are in long double precision */
604 /* Here t32 is the constant 2^32+1 */
605 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
606 /* Correct if x and y belong to interval [2^-8000;2^8000] */
607 #define __LIBM_MULL_K80(r,x,y, t32,t1,t2,t3,t4,t5,t6,t7,t8) \
608 (r)->ex = (x)->ex + (y)->ex; \
609 __LIBM_MULL2_K80((r)->ldhi,(r)->ldlo, \
610 (x)->ldhi,(x)->ldlo,(y)->ldhi,(y)->ldlo, \
611 t32,t1,t2,t3,t4,t5,t6,t7,t8)
613 /* Multiplication: r=x*y */
614 /* Variables r,x,y are pointers to struct ker80, */
615 /* all other variables are in long double precision */
616 /* Here t32 is the constant 2^32+1 */
617 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
618 /* Correct for any finite x and y */
619 #define __LIBM_MULL_NORM_K80(r,x,y, \
620 t32,t1,t2,t3,t4,t5,t6,t7,t8) \
621 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
622 ((x)->fphi.exponent-BIAS_80>+8000) || \
623 ((y)->fphi.exponent-BIAS_80<-8000) || \
624 ((y)->fphi.exponent-BIAS_80>+8000) ) \
626 __libm_normalizel_k80(x); \
627 __libm_normalizel_k80(y); \
629 __LIBM_MULL_K80(r,x,y, t32,t1,t2,t3,t4,t5,t6,t7,t8)
631 /* Division: (xhi+xlo)/(yhi+ylo) */
632 /* The result is sum rhi+rlo */
633 /* Here t32 is the constant 2^32+1 */
634 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
635 /* All variables are in long double precision */
636 /* Correct if no over/underflow (algorithm by T.J.Dekker) */
637 #define __LIBM_DIVL2_K80(rhi,rlo,xhi,xlo,yhi,ylo, \
638 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
640 __LIBM_MULL1_K80(t8,t9,t7,yhi, t32,t1,t2,t3,t4,t5,t6) \
641 t1=xhi-t8; t1=t1-t9; t1=t1+xlo; t1=t1-(t7)*(ylo); \
644 rlo=t7-rhi; rlo=rlo+t1;
646 /* Division: r=x/y */
647 /* Variables r,x,y are pointers to struct ker80, */
648 /* all other variables are in long double precision */
649 /* Here t32 is the constant 2^32+1 */
650 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
651 /* Correct if x and y belong to interval [2^-8000;2^8000] */
652 #define __LIBM_DIVL_K80(r,x,y, \
653 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
654 (r)->ex = (x)->ex - (y)->ex; \
655 __LIBM_DIVL2_K80( (r)->ldhi,(r)->ldlo, \
656 (x)->ldhi,(x)->ldlo,(y)->ldhi,(y)->ldlo, \
657 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9)
659 /* Division: r=x/y */
660 /* Variables r,x,y are pointers to struct ker80, */
661 /* all other variables are in long double precision */
662 /* Here t32 is the constant 2^32+1 */
663 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8 */
664 /* Correct for any finite x and y */
665 #define __LIBM_DIVL_NORM_K80(r,x,y, \
666 t32,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
667 if ( ((x)->fphi.exponent-BIAS_80<-8000) || \
668 ((x)->fphi.exponent-BIAS_80>+8000) || \
669 ((y)->fphi.exponent-BIAS_80<-8000) || \
670 ((y)->fphi.exponent-BIAS_80>+8000) ) \
672 __libm_normalizel_k80(x); \
673 __libm_normalizel_k80(y); \
675 __LIBM_DIVL_K80(r,x,y, t32,t1,t2,t3,t4,t5,t6,t7,t8,t9)
677 /* Square root: sqrt(xhi+xlo) */
678 /* The result is sum rhi+rlo */
679 /* Here t32 is the constant 2^32+1 */
680 /* half is the constant 0.5 */
681 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
682 /* All variables are in long double precision */
683 /* Correct for positive xhi+xlo (algorithm by T.J.Dekker) */
684 #define __LIBM_SQRTL2_NORM_K80(rhi,rlo,xhi,xlo, \
685 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
687 __LIBM_MULL1_K80(t8,t9,t7,t7, t32,t1,t2,t3,t4,t5,t6) \
688 t1=xhi-t8; t1=t1-t9; t1=t1+xlo; t1=(t1)*(half); \
691 rlo=t7-rhi; rlo=rlo+t1;
693 /* Square root: r=sqrt(x) */
694 /* Variables r,x,y are pointers to struct ker80, */
695 /* all other variables are in long double precision */
696 /* Here t32 is the constant 2^32+1 */
697 /* half is the constant 0.5 */
698 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
699 /* Correct if x belongs to interval [2^-16000;2^16000] */
700 #define __LIBM_SQRTL_K80(r,x, \
701 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
702 if ( ((x)->ex & 1) == 1 ) { \
703 (x)->ex = (x)->ex + 1; \
707 (r)->ex = (x)->ex >> 1; \
708 __LIBM_SQRTL2_NORM_K80( (r)->ldhi,(r)->ldlo, \
709 (x)->ldhi,(x)->ldlo, \
710 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9)
712 /* Square root: r=sqrt(x) */
713 /* Variables r,x,y are pointers to struct ker80, */
714 /* all other variables are in long double precision */
715 /* Here t32 is the constant 2^32+1 */
716 /* half is the constant 0.5 */
717 /* Temporary variables: t1,t2,t3,t4,t5,t6,t7,t8,t9 */
718 /* Correct for any positive x */
719 #define __LIBM_SQRTL_NORM_K80(r,x, \
720 t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9) \
721 if ( ((x)->fphi.exponent-BIAS_80<-16000) || \
722 ((x)->fphi.exponent-BIAS_80>+16000) ) \
724 __libm_normalizel_k80(x); \
726 __LIBM_SQRTL_K80(r,x, t32,half,t1,t2,t3,t4,t5,t6,t7,t8,t9)
729 #ifdef __INTEL_COMPILER
730 #define ALIGN(n) __declspec(align(n))
731 #else /* __INTEL_COMPILER */
733 #endif /* __INTEL_COMPILER */
735 /* macros to form a long double value in hex representation (unsigned short type) */
737 #if (defined(__unix__) && defined(__i386__))
738 # define LDOUBLE_ALIGN 12 /* IA32 Linux: 12-byte alignment */
739 #else /*__linux__ & IA32*/
740 # define LDOUBLE_ALIGN 16 /* EFI2/IA32 Win or IPF Win/Linux: 16-byte alignment */
741 #endif /*__linux__ & IA32*/
743 #if (LDOUBLE_ALIGN == 16)
744 #define _XPD_ ,0x0000,0x0000,0x0000
746 #define _XPD_ ,0x0000
749 #define LDOUBLE_HEX(w4,w3,w2,w1,w0) 0x##w0,0x##w1,0x##w2,0x##w3,0x##w4 _XPD_ /*LITTLE_ENDIAN*/
751 /* macros to sign-expand low 'num' bits of 'val' to native integer */
753 #if defined(SIZE_INT_32)
754 # define SIGN_EXPAND(val,num) ((int)(val) << (32-(num))) >> (32-(num)) /* sign expand of 'num' LSBs */
755 #elif defined(SIZE_INT_64)
756 # define SIGN_EXPAND(val,num) ((int)(val) << (64-(num))) >> (64-(num)) /* sign expand of 'num' LSBs */
759 /* macros to form pointers to FP number on-the-fly */
761 #define FP32(f) ((struct fp32 *)&f)
762 #define FP64(d) ((struct fp64 *)&d)
763 #define FP80(ld) ((struct fp80 *)&ld)
765 /* macros to extract signed low and high doubleword of long double */
767 #if defined(SIZE_INT_32)
768 # define HI_DWORD_80(ld) ((((FP80(ld)->sign << 15) | FP80(ld)->exponent) << 16) | \
769 ((FP80(ld)->hi_significand >> 16) & 0xFFFF))
770 # define LO_DWORD_80(ld) SIGN_EXPAND(FP80(ld)->lo_significand, 32)
771 #elif defined(SIZE_INT_64)
772 # define HI_DWORD_80(ld) ((((FP80(ld)->sign << 15) | FP80(ld)->exponent) << 16) | \
773 ((FP80(ld)->significand >> 48) & 0xFFFF))
774 # define LO_DWORD_80(ld) SIGN_EXPAND(FP80(ld)->significand, 32)
777 /* macros to extract hi bits of significand.
778 * note that explicit high bit do not count (returns as is)
781 #if defined(SIZE_INT_32)
782 # define HI_SIGNIFICAND_80(X,NBITS) ((X)->hi_significand >> (31 - (NBITS)))
783 #elif defined(SIZE_INT_64)
784 # define HI_SIGNIFICAND_80(X,NBITS) ((X)->significand >> (63 - (NBITS)))
787 /* macros to check, whether a significand bits are all zero, or some of them are non-zero.
788 * note that SIGNIFICAND_ZERO_80 tests high bit also, but SIGNIFICAND_NONZERO_80 does not
791 #define SIGNIFICAND_ZERO_32(X) ((X)->significand == 0)
792 #define SIGNIFICAND_NONZERO_32(X) ((X)->significand != 0)
794 #if defined(SIZE_INT_32)
795 # define SIGNIFICAND_ZERO_64(X) (((X)->hi_significand == 0) && ((X)->lo_significand == 0))
796 # define SIGNIFICAND_NONZERO_64(X) (((X)->hi_significand != 0) || ((X)->lo_significand != 0))
797 #elif defined(SIZE_INT_64)
798 # define SIGNIFICAND_ZERO_64(X) ((X)->significand == 0)
799 # define SIGNIFICAND_NONZERO_64(X) ((X)->significand != 0)
802 #if defined(SIZE_INT_32)
803 # define SIGNIFICAND_ZERO_80(X) (((X)->hi_significand == 0x00000000) && ((X)->lo_significand == 0))
804 # define SIGNIFICAND_NONZERO_80(X) (((X)->hi_significand != 0x80000000) || ((X)->lo_significand != 0))
805 #elif defined(SIZE_INT_64)
806 # define SIGNIFICAND_ZERO_80(X) ((X)->significand == 0x0000000000000000)
807 # define SIGNIFICAND_NONZERO_80(X) ((X)->significand != 0x8000000000000000)
810 /* macros to compare long double with constant value, represented as hex */
812 #define SIGNIFICAND_EQ_HEX_32(X,BITS) ((X)->significand == 0x ## BITS)
813 #define SIGNIFICAND_GT_HEX_32(X,BITS) ((X)->significand > 0x ## BITS)
814 #define SIGNIFICAND_GE_HEX_32(X,BITS) ((X)->significand >= 0x ## BITS)
815 #define SIGNIFICAND_LT_HEX_32(X,BITS) ((X)->significand < 0x ## BITS)
816 #define SIGNIFICAND_LE_HEX_32(X,BITS) ((X)->significand <= 0x ## BITS)
818 #if defined(SIZE_INT_32)
819 # define SIGNIFICAND_EQ_HEX_64(X,HI,LO) \
820 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand == 0x ## LO))
821 # define SIGNIFICAND_GT_HEX_64(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
822 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand > 0x ## LO)))
823 # define SIGNIFICAND_GE_HEX_64(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
824 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand >= 0x ## LO)))
825 # define SIGNIFICAND_LT_HEX_64(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
826 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand < 0x ## LO)))
827 # define SIGNIFICAND_LE_HEX_64(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
828 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand <= 0x ## LO)))
829 #elif defined(SIZE_INT_64)
830 # define SIGNIFICAND_EQ_HEX_64(X,HI,LO) ((X)->significand == 0x ## HI ## LO)
831 # define SIGNIFICAND_GT_HEX_64(X,HI,LO) ((X)->significand > 0x ## HI ## LO)
832 # define SIGNIFICAND_GE_HEX_64(X,HI,LO) ((X)->significand >= 0x ## HI ## LO)
833 # define SIGNIFICAND_LT_HEX_64(X,HI,LO) ((X)->significand < 0x ## HI ## LO)
834 # define SIGNIFICAND_LE_HEX_64(X,HI,LO) ((X)->significand <= 0x ## HI ## LO)
837 #if defined(SIZE_INT_32)
838 # define SIGNIFICAND_EQ_HEX_80(X,HI,LO) \
839 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand == 0x ## LO))
840 # define SIGNIFICAND_GT_HEX_80(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
841 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand > 0x ## LO)))
842 # define SIGNIFICAND_GE_HEX_80(X,HI,LO) (((X)->hi_significand > 0x ## HI) || \
843 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand >= 0x ## LO)))
844 # define SIGNIFICAND_LT_HEX_80(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
845 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand < 0x ## LO)))
846 # define SIGNIFICAND_LE_HEX_80(X,HI,LO) (((X)->hi_significand < 0x ## HI) || \
847 (((X)->hi_significand == 0x ## HI) && ((X)->lo_significand <= 0x ## LO)))
848 #elif defined(SIZE_INT_64)
849 # define SIGNIFICAND_EQ_HEX_80(X,HI,LO) ((X)->significand == 0x ## HI ## LO)
850 # define SIGNIFICAND_GT_HEX_80(X,HI,LO) ((X)->significand > 0x ## HI ## LO)
851 # define SIGNIFICAND_GE_HEX_80(X,HI,LO) ((X)->significand >= 0x ## HI ## LO)
852 # define SIGNIFICAND_LT_HEX_80(X,HI,LO) ((X)->significand < 0x ## HI ## LO)
853 # define SIGNIFICAND_LE_HEX_80(X,HI,LO) ((X)->significand <= 0x ## HI ## LO)
856 #define VALUE_EQ_HEX_32(X,EXP,BITS) \
857 (((X)->exponent == (EXP)) && (SIGNIFICAND_EQ_HEX_32(X, BITS)))
858 #define VALUE_GT_HEX_32(X,EXP,BITS) (((X)->exponent > (EXP)) || \
859 (((X)->exponent == (EXP)) && (SIGNIFICAND_GT_HEX_32(X, BITS))))
860 #define VALUE_GE_HEX_32(X,EXP,BITS) (((X)->exponent > (EXP)) || \
861 (((X)->exponent == (EXP)) && (SIGNIFICAND_GE_HEX_32(X, BITS))))
862 #define VALUE_LT_HEX_32(X,EXP,BITS) (((X)->exponent < (EXP)) || \
863 (((X)->exponent == (EXP)) && (SIGNIFICAND_LT_HEX_32(X, BITS))))
864 #define VALUE_LE_HEX_32(X,EXP,BITS) (((X)->exponent < (EXP)) || \
865 (((X)->exponent == (EXP)) && (SIGNIFICAND_LE_HEX_32(X, BITS))))
867 #define VALUE_EQ_HEX_64(X,EXP,HI,LO) \
868 (((X)->exponent == (EXP)) && (SIGNIFICAND_EQ_HEX_64(X, HI, LO)))
869 #define VALUE_GT_HEX_64(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
870 (((X)->exponent == (EXP)) && (SIGNIFICAND_GT_HEX_64(X, HI, LO))))
871 #define VALUE_GE_HEX_64(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
872 (((X)->exponent == (EXP)) && (SIGNIFICAND_GE_HEX_64(X, HI, LO))))
873 #define VALUE_LT_HEX_64(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
874 (((X)->exponent == (EXP)) && (SIGNIFICAND_LT_HEX_64(X, HI, LO))))
875 #define VALUE_LE_HEX_64(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
876 (((X)->exponent == (EXP)) && (SIGNIFICAND_LE_HEX_64(X, HI, LO))))
878 #define VALUE_EQ_HEX_80(X,EXP,HI,LO) \
879 (((X)->exponent == (EXP)) && (SIGNIFICAND_EQ_HEX_80(X, HI, LO)))
880 #define VALUE_GT_HEX_80(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
881 (((X)->exponent == (EXP)) && (SIGNIFICAND_GT_HEX_80(X, HI, LO))))
882 #define VALUE_GE_HEX_80(X,EXP,HI,LO) (((X)->exponent > (EXP)) || \
883 (((X)->exponent == (EXP)) && (SIGNIFICAND_GE_HEX_80(X, HI, LO))))
884 #define VALUE_LT_HEX_80(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
885 (((X)->exponent == (EXP)) && (SIGNIFICAND_LT_HEX_80(X, HI, LO))))
886 #define VALUE_LE_HEX_80(X,EXP,HI,LO) (((X)->exponent < (EXP)) || \
887 (((X)->exponent == (EXP)) && (SIGNIFICAND_LE_HEX_80(X, HI, LO))))
889 /* macros to compare two long doubles */
891 #define SIGNIFICAND_EQ_32(X,Y) ((X)->significand == (Y)->significand)
892 #define SIGNIFICAND_GT_32(X,Y) ((X)->significand > (Y)->significand)
893 #define SIGNIFICAND_GE_32(X,Y) ((X)->significand >= (Y)->significand)
894 #define SIGNIFICAND_LT_32(X,Y) ((X)->significand < (Y)->significand)
895 #define SIGNIFICAND_LE_32(X,Y) ((X)->significand <= (Y)->significand)
897 #if defined(SIZE_INT_32)
898 # define SIGNIFICAND_EQ_64(X,Y) \
899 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand == (Y)->lo_significand))
900 # define SIGNIFICAND_GT_64(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
901 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand > (Y)->lo_significand)))
902 # define SIGNIFICAND_GE_64(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
903 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand >= (Y)->lo_significand)))
904 # define SIGNIFICAND_LT_64(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
905 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand < (Y)->lo_significand)))
906 # define SIGNIFICAND_LE_64(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
907 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand <= (Y)->lo_significand)))
908 #elif defined(SIZE_INT_64)
909 # define SIGNIFICAND_EQ_64(X,Y) ((X)->significand == (Y)->significand)
910 # define SIGNIFICAND_GT_64(X,Y) ((X)->significand > (Y)->significand)
911 # define SIGNIFICAND_GE_64(X,Y) ((X)->significand >= (Y)->significand)
912 # define SIGNIFICAND_LT_64(X,Y) ((X)->significand < (Y)->significand)
913 # define SIGNIFICAND_LE_64(X,Y) ((X)->significand <= (Y)->significand)
916 #if defined(SIZE_INT_32)
917 # define SIGNIFICAND_EQ_80(X,Y) \
918 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand == (Y)->lo_significand))
919 # define SIGNIFICAND_GT_80(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
920 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand > (Y)->lo_significand)))
921 # define SIGNIFICAND_GE_80(X,Y) (((X)->hi_significand > (Y)->hi_significand) || \
922 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand >= (Y)->lo_significand)))
923 # define SIGNIFICAND_LT_80(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
924 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand < (Y)->lo_significand)))
925 # define SIGNIFICAND_LE_80(X,Y) (((X)->hi_significand < (Y)->hi_significand) || \
926 (((X)->hi_significand == (Y)->hi_significand) && ((X)->lo_significand <= (Y)->lo_significand)))
927 #elif defined(SIZE_INT_64)
928 # define SIGNIFICAND_EQ_80(X,Y) ((X)->significand == (Y)->significand)
929 # define SIGNIFICAND_GT_80(X,Y) ((X)->significand > (Y)->significand)
930 # define SIGNIFICAND_GE_80(X,Y) ((X)->significand >= (Y)->significand)
931 # define SIGNIFICAND_LT_80(X,Y) ((X)->significand < (Y)->significand)
932 # define SIGNIFICAND_LE_80(X,Y) ((X)->significand <= (Y)->significand)
935 #define VALUE_EQ_32(X,Y) \
936 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_EQ_32(X, Y)))
937 #define VALUE_GT_32(X,Y) (((X)->exponent > (Y)->exponent) || \
938 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GT_32(X, Y))))
939 #define VALUE_GE_32(X,Y) (((X)->exponent > (Y)->exponent) || \
940 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GE_32(X, Y))))
941 #define VALUE_LT_32(X,Y) (((X)->exponent < (Y)->exponent) || \
942 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LT_32(X, Y))))
943 #define VALUE_LE_32(X,Y) (((X)->exponent < (Y)->exponent) || \
944 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LE_32(X, Y))))
946 #define VALUE_EQ_64(X,Y) \
947 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_EQ_64(X, Y)))
948 #define VALUE_GT_64(X,Y) (((X)->exponent > (Y)->exponent) || \
949 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GT_64(X, Y))))
950 #define VALUE_GE_64(X,Y) (((X)->exponent > (Y)->exponent) || \
951 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GE_64(X, Y))))
952 #define VALUE_LT_64(X,Y) (((X)->exponent < (Y)->exponent) || \
953 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LT_64(X, Y))))
954 #define VALUE_LE_64(X,Y) (((X)->exponent < (Y)->exponent) || \
955 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LE_64(X, Y))))
957 #define VALUE_EQ_80(X,Y) \
958 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_EQ_80(X, Y)))
959 #define VALUE_GT_80(X,Y) (((X)->exponent > (Y)->exponent) || \
960 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GT_80(X, Y))))
961 #define VALUE_GE_80(X,Y) (((X)->exponent > (Y)->exponent) || \
962 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_GE_80(X, Y))))
963 #define VALUE_LT_80(X,Y) (((X)->exponent < (Y)->exponent) || \
964 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LT_80(X, Y))))
965 #define VALUE_LE_80(X,Y) (((X)->exponent < (Y)->exponent) || \
966 (((X)->exponent == (Y)->exponent) && (SIGNIFICAND_LE_80(X, Y))))
968 /* add/subtract 1 ulp macros */
970 #if defined(SIZE_INT_32)
971 # define ADD_ULP_80(X) \
972 if ((++(X)->lo_significand == 0) && \
973 (++(X)->hi_significand == (((X)->exponent == 0) ? 0x80000000 : 0))) \
975 (X)->hi_significand |= 0x80000000; \
978 # define SUB_ULP_80(X) \
979 if (--(X)->lo_significand == 0xFFFFFFFF) { \
980 --(X)->hi_significand; \
981 if (((X)->exponent != 0) && \
982 ((X)->hi_significand == 0x7FFFFFFF) && \
983 (--(X)->exponent != 0)) \
985 (X)->hi_significand |= 0x80000000; \
988 #elif defined(SIZE_INT_64)
989 # define ADD_ULP_80(X) \
990 if (++(X)->significand == (((X)->exponent == 0) ? 0x8000000000000000 : 0))) { \
991 (X)->significand |= 0x8000000000000000; \
994 # define SUB_ULP_80(X) \
996 --(X)->significand; \
997 if (((X)->exponent != 0) && \
998 ((X)->significand == 0x7FFFFFFFFFFFFFFF) && \
999 (--(X)->exponent != 0)) \
1001 (X)->significand |= 0x8000000000000000; \
1009 #define VOLATILE_32 /*volatile*/
1010 #define VOLATILE_64 /*volatile*/
1011 #define VOLATILE_80 /*volatile*/
1013 #define QUAD_TYPE _Quad
1015 #endif /*__LIBM_SUPPORT_H_INCLUDED__*/