1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
|
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_fenv.h.html, _fenv.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Sean Kelly
* Source: $(DRUNTIMESRC core/stdc/_fenv.d)
* Standards: ISO/IEC 9899:1999 (E)
*/
module core.stdc.fenv;
version (OSX)
version = Darwin;
else version (iOS)
version = Darwin;
else version (TVOS)
version = Darwin;
else version (WatchOS)
version = Darwin;
extern (C):
@system:
nothrow:
@nogc:
version (ARM) version = ARM_Any;
version (AArch64) version = ARM_Any;
version (HPPA) version = HPPA_Any;
version (MIPS32) version = MIPS_Any;
version (MIPS64) version = MIPS_Any;
version (PPC) version = PPC_Any;
version (PPC64) version = PPC_Any;
version (RISCV32) version = RISCV_Any;
version (RISCV64) version = RISCV_Any;
version (S390) version = IBMZ_Any;
version (SPARC) version = SPARC_Any;
version (SPARC64) version = SPARC_Any;
version (SystemZ) version = IBMZ_Any;
version (X86) version = X86_Any;
version (X86_64) version = X86_Any;
version (MinGW)
version = GNUFP;
version (CRuntime_Glibc)
version = GNUFP;
version (GNUFP)
{
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu/bits/fenv.h
version (X86)
{
struct fenv_t
{
ushort __control_word;
ushort __unused1;
ushort __status_word;
ushort __unused2;
ushort __tags;
ushort __unused3;
uint __eip;
ushort __cs_selector;
ushort __opcode;
uint __data_offset;
ushort __data_selector;
ushort __unused5;
}
alias fexcept_t = ushort;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/fpu/bits/fenv.h
else version (X86_64)
{
struct fenv_t
{
ushort __control_word;
ushort __unused1;
ushort __status_word;
ushort __unused2;
ushort __tags;
ushort __unused3;
uint __eip;
ushort __cs_selector;
ushort __opcode;
uint __data_offset;
ushort __data_selector;
ushort __unused5;
uint __mxcsr;
}
alias fexcept_t = ushort;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/hppa/bits/fenv.h
else version (HPPA_Any)
{
struct fenv_t
{
uint __status_word;
uint[7] __exception;
}
alias fexcept_t = uint;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mips/bits/fenv.h
else version (MIPS_Any)
{
struct fenv_t
{
uint __fp_control_register;
}
alias fexcept_t = ushort;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/aarch64/bits/fenv.h
else version (AArch64)
{
struct fenv_t
{
uint __fpcr;
uint __fpsr;
}
alias fexcept_t = uint;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/arm/bits/fenv.h
else version (ARM)
{
struct fenv_t
{
uint __cw;
}
alias fexcept_t = uint;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/bits/fenv.h
else version (PPC_Any)
{
alias fenv_t = double;
alias fexcept_t = uint;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/riscv/bits/fenv.h
else version (RISCV_Any)
{
alias fenv_t = uint;
alias fexcept_t = uint;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/sparc/fpu/bits/fenv.h
else version (SPARC_Any)
{
import core.stdc.config : c_ulong;
alias fenv_t = c_ulong;
alias fexcept_t = c_ulong;
}
// https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/s390/fpu/bits/fenv.h
else version (IBMZ_Any)
{
struct fenv_t
{
fexcept_t __fpc;
void* __unused;
}
alias fexcept_t = uint;
}
else
{
static assert(0, "Unimplemented architecture");
}
}
else version (CRuntime_DigitalMars)
{
struct fenv_t
{
ushort status;
ushort control;
ushort round;
ushort[2] reserved;
}
alias fexcept_t = int;
}
else version (CRuntime_Microsoft)
{
struct fenv_t
{
uint ctl;
uint stat;
}
alias fexcept_t = uint;
}
else version (Darwin)
{
version (BigEndian)
{
alias uint fenv_t;
alias uint fexcept_t;
}
version (LittleEndian)
{
struct fenv_t
{
ushort __control;
ushort __status;
uint __mxcsr;
byte[8] __reserved;
}
alias ushort fexcept_t;
}
}
else version (FreeBSD)
{
struct fenv_t
{
ushort __control;
ushort __mxcsr_hi;
ushort __status;
ushort __mxcsr_lo;
uint __tag;
byte[16] __other;
}
alias ushort fexcept_t;
}
else version (NetBSD)
{
version (X86_64)
{
struct fenv_t
{
struct _x87
{
uint control; /* Control word register */
uint status; /* Status word register */
uint tag; /* Tag word register */
uint[4] others; /* EIP, Pointer Selector, etc */
}
_x87 x87;
uint mxcsr; /* Control and status register */
}
}
version (X86)
{
struct fenv_t
{
struct _x87
{
ushort control; /* Control word register */
ushort unused1;
ushort status; /* Status word register */
ushort unused2;
ushort tag; /* Tag word register */
ushort unused3;
uint[4] others; /* EIP, Pointer Selector, etc */
}
_x87 x87;
uint mxcsr; /* Control and status register */
}
}
alias uint fexcept_t;
}
else version (OpenBSD)
{
struct fenv_t
{
struct __x87
{
uint __control;
uint __status;
uint __tag;
uint[4] __others;
}
}
uint __mxcsr;
alias fexcept_t = uint;
}
else version (DragonFlyBSD)
{
struct fenv_t
{
struct _x87
{
uint control;
uint status;
uint tag;
uint[4] others;
}
_x87 x87;
uint mxcsr;
}
alias uint fexcept_t;
}
else version (CRuntime_Bionic)
{
version (X86)
{
struct fenv_t
{
ushort __control;
ushort __mxcsr_hi;
ushort __status;
ushort __mxcsr_lo;
uint __tag;
byte[16] __other;
}
alias ushort fexcept_t;
}
else version (ARM)
{
alias uint fenv_t;
alias uint fexcept_t;
}
else version (AArch64)
{
struct fenv_t
{
uint __control;
uint __status;
}
alias uint fexcept_t;
}
else version (X86_64)
{
struct fenv_t
{
struct _x87
{
uint __control;
uint __status;
uint __tag;
uint[4] __others;
}
_x87 __x87;
uint __mxcsr;
}
alias uint fexcept_t;
}
else
{
static assert(false, "Architecture not supported.");
}
}
else version (Solaris)
{
import core.stdc.config : c_ulong;
enum FEX_NUM_EXC = 12;
struct fex_handler_t
{
int __mode;
void function() __handler;
}
struct fenv_t
{
fex_handler_t[FEX_NUM_EXC] __handler;
c_ulong __fsr;
}
alias int fexcept_t;
}
else version (CRuntime_Musl)
{
version (AArch64)
{
struct fenv_t
{
uint __fpcr;
uint __fpsr;
}
alias uint fexcept_t;
}
else version (ARM)
{
import core.stdc.config : c_ulong;
struct fenv_t
{
c_ulong __cw;
}
alias c_ulong fexcept_t;
}
else version (IBMZ_Any)
{
alias uint fenv_t;
alias uint fexcept_t;
}
else version (MIPS_Any)
{
struct fenv_t
{
uint __cw;
}
alias ushort fexcept_t;
}
else version (PPC_Any)
{
alias double fenv_t;
alias uint fexcept_t;
}
else version (X86_Any)
{
struct fenv_t
{
ushort __control_word;
ushort __unused1;
ushort __status_word;
ushort __unused2;
ushort __tags;
ushort __unused3;
uint __eip;
ushort __cs_selector;
ushort __opcode;
uint __data_offset;
ushort __data_selector;
ushort __unused5;
version (X86_64)
uint __mxcsr;
}
alias ushort fexcept_t;
}
else
{
static assert(false, "Architecture not supported.");
}
}
else version (CRuntime_UClibc)
{
version (X86)
{
struct fenv_t
{
ushort __control_word;
ushort __unused1;
ushort __status_word;
ushort __unused2;
ushort __tags;
ushort __unused3;
uint __eip;
ushort __cs_selector;
ushort __opcode;
uint __data_offset;
ushort __data_selector;
ushort __unused5;
}
alias fexcept_t = ushort;
}
else version (X86_64)
{
struct fenv_t
{
ushort __control_word;
ushort __unused1;
ushort __status_word;
ushort __unused2;
ushort __tags;
ushort __unused3;
uint __eip;
ushort __cs_selector;
ushort __opcode;
uint __data_offset;
ushort __data_selector;
ushort __unused5;
uint __mxcsr;
}
alias fexcept_t = ushort;
}
else version (MIPS32)
{
struct fenv_t
{
uint __fp_control_register;
}
alias fexcept_t = ushort;
}
else version (ARM)
{
struct fenv_t
{
uint __cw;
}
alias fexcept_t = uint;
}
else
{
static assert(false, "Architecture not supported.");
}
}
else
{
static assert( false, "Unsupported platform" );
}
version (CRuntime_Microsoft)
{
enum
{
FE_INEXACT = 1, ///
FE_UNDERFLOW = 2, ///
FE_OVERFLOW = 4, ///
FE_DIVBYZERO = 8, ///
FE_INVALID = 0x10, ///
FE_ALL_EXCEPT = 0x1F, ///
FE_TONEAREST = 0, ///
FE_UPWARD = 0x100, ///
FE_DOWNWARD = 0x200, ///
FE_TOWARDZERO = 0x300, ///
}
}
else version (Solaris)
{
version (SPARC_Any)
{
enum
{
FE_TONEAREST = 0,
FE_TOWARDZERO = 1,
FE_UPWARD = 2,
FE_DOWNWARD = 3,
}
enum
{
FE_INEXACT = 0x01,
FE_DIVBYZERO = 0x02,
FE_UNDERFLOW = 0x04,
FE_OVERFLOW = 0x08,
FE_INVALID = 0x10,
FE_ALL_EXCEPT = 0x1f,
}
}
else version (X86_Any)
{
enum
{
FE_TONEAREST = 0,
FE_DOWNWARD = 1,
FE_UPWARD = 2,
FE_TOWARDZERO = 3,
}
enum
{
FE_INVALID = 0x01,
FE_DIVBYZERO = 0x04,
FE_OVERFLOW = 0x08,
FE_UNDERFLOW = 0x10,
FE_INEXACT = 0x20,
FE_ALL_EXCEPT = 0x3d,
}
}
else
{
static assert(0, "Unimplemented architecture");
}
}
else
{
version (X86)
{
// Define bits representing the exception.
enum
{
FE_INVALID = 0x01, ///
FE_DENORMAL = 0x02, /// non-standard
FE_DIVBYZERO = 0x04, ///
FE_OVERFLOW = 0x08, ///
FE_UNDERFLOW = 0x10, ///
FE_INEXACT = 0x20, ///
FE_ALL_EXCEPT = 0x3F, ///
}
// The ix87 FPU supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0, ///
FE_DOWNWARD = 0x400, ///
FE_UPWARD = 0x800, ///
FE_TOWARDZERO = 0xC00, ///
}
}
else version (X86_64)
{
// Define bits representing the exception.
enum
{
FE_INVALID = 0x01, ///
FE_DENORMAL = 0x02, /// non-standard
FE_DIVBYZERO = 0x04, ///
FE_OVERFLOW = 0x08, ///
FE_UNDERFLOW = 0x10, ///
FE_INEXACT = 0x20, ///
FE_ALL_EXCEPT = 0x3F, ///
}
// The ix87 FPU supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0, ///
FE_DOWNWARD = 0x400, ///
FE_UPWARD = 0x800, ///
FE_TOWARDZERO = 0xC00, ///
}
}
else version (ARM_Any)
{
// Define bits representing exceptions in the FPU status word.
enum
{
FE_INVALID = 1, ///
FE_DIVBYZERO = 2, ///
FE_OVERFLOW = 4, ///
FE_UNDERFLOW = 8, ///
FE_INEXACT = 16, ///
FE_ALL_EXCEPT = 31, ///
}
// VFP supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0, ///
FE_UPWARD = 0x400000, ///
FE_DOWNWARD = 0x800000, ///
FE_TOWARDZERO = 0xC00000, ///
}
}
else version (HPPA_Any)
{
// Define bits representing the exception.
enum
{
FE_INEXACT = 0x01, ///
FE_UNDERFLOW = 0x02, ///
FE_OVERFLOW = 0x04, ///
FE_DIVBYZERO = 0x08, ///
FE_INVALID = 0x10, ///
FE_ALL_EXCEPT = 0x1F, ///
}
// The HPPA FPU supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0x0, ///
FE_TOWARDZERO = 0x200, ///
FE_UPWARD = 0x400, ///
FE_DOWNWARD = 0x600, ///
}
}
else version (MIPS_Any)
{
// Define bits representing the exception.
enum
{
FE_INEXACT = 0x04, ///
FE_UNDERFLOW = 0x08, ///
FE_OVERFLOW = 0x10, ///
FE_DIVBYZERO = 0x20, ///
FE_INVALID = 0x40, ///
FE_ALL_EXCEPT = 0x7C, ///
}
// The MIPS FPU supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0x0, ///
FE_TOWARDZERO = 0x1, ///
FE_UPWARD = 0x2, ///
FE_DOWNWARD = 0x3, ///
}
}
else version (PPC_Any)
{
// Define bits representing the exception.
enum
{
FE_INEXACT = 0x2000000, ///
FE_DIVBYZERO = 0x4000000, ///
FE_UNDERFLOW = 0x8000000, ///
FE_OVERFLOW = 0x10000000, ///
FE_INVALID = 0x20000000, ///
FE_INVALID_SNAN = 0x1000000, /// non-standard
FE_INVALID_ISI = 0x800000, /// non-standard
FE_INVALID_IDI = 0x400000, /// non-standard
FE_INVALID_ZDZ = 0x200000, /// non-standard
FE_INVALID_IMZ = 0x100000, /// non-standard
FE_INVALID_COMPARE = 0x80000, /// non-standard
FE_INVALID_SOFTWARE = 0x400, /// non-standard
FE_INVALID_SQRT = 0x200, /// non-standard
FE_INVALID_INTEGER_CONVERSION = 0x100, /// non-standard
FE_ALL_INVALID = 0x1F80700, /// non-standard
FE_ALL_EXCEPT = 0x3E000000, ///
}
// PowerPC chips support all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0, ///
FE_TOWARDZERO = 1, ///
FE_UPWARD = 2, ///
FE_DOWNWARD = 3, ///
}
}
else version (RISCV_Any)
{
// Define bits representing exceptions in the FPSR status word.
enum
{
FE_INEXACT = 0x01, ///
FE_UNDERFLOW = 0x02, ///
FE_OVERFLOW = 0x04, ///
FE_DIVBYZERO = 0x08, ///
FE_INVALID = 0x10, ///
FE_ALL_EXCEPT = 0x1f, ///
}
// Define bits representing rounding modes in the FPCR Rmode field.
enum
{
FE_TONEAREST = 0x0, ///
FE_TOWARDZERO = 0x1, ///
FE_DOWNWARD = 0x2, ///
FE_UPWARD = 0x3, ///
}
}
else version (SPARC_Any)
{
// Define bits representing the exception.
enum
{
FE_INVALID = 0x200, ///
FE_OVERFLOW = 0x100, ///
FE_UNDERFLOW = 0x80, ///
FE_DIVBYZERO = 0x40, ///
FE_INEXACT = 0x20, ///
FE_ALL_EXCEPT = 0x3E0, ///
}
// The Sparc FPU supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0x0, ///
FE_TOWARDZERO = 0x40000000, ///
FE_UPWARD = 0x80000000, ///
FE_DOWNWARD = 0xc0000000, ///
}
}
else version (IBMZ_Any)
{
// Define bits representing the exception.
enum
{
FE_INVALID = 0x80, ///
FE_DIVBYZERO = 0x40, ///
FE_OVERFLOW = 0x20, ///
FE_UNDERFLOW = 0x10, ///
FE_INEXACT = 0x08, ///
FE_ALL_EXCEPT = 0xF8, ///
}
// SystemZ supports all of the four defined rounding modes.
enum
{
FE_TONEAREST = 0x0, ///
FE_DOWNWARD = 0x3, ///
FE_UPWARD = 0x2, ///
FE_TOWARDZERO = 0x1, ///
}
}
else
{
static assert(0, "Unimplemented architecture");
}
}
version (GNUFP)
{
///
enum FE_DFL_ENV = cast(fenv_t*)(-1);
}
else version (CRuntime_DigitalMars)
{
private extern __gshared fenv_t _FE_DFL_ENV;
///
enum fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
}
else version (CRuntime_Microsoft)
{
private extern __gshared fenv_t _Fenv0;
///
enum FE_DFL_ENV = &_Fenv0;
}
else version (Darwin)
{
private extern __gshared fenv_t _FE_DFL_ENV;
///
enum FE_DFL_ENV = &_FE_DFL_ENV;
}
else version (FreeBSD)
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version (NetBSD)
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version (OpenBSD)
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version (DragonFlyBSD)
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version (CRuntime_Bionic)
{
private extern const fenv_t __fe_dfl_env;
///
enum FE_DFL_ENV = &__fe_dfl_env;
}
else version (Solaris)
{
private extern const fenv_t __fenv_def_env;
///
enum FE_DFL_ENV = &__fenv_def_env;
}
else version (CRuntime_Musl)
{
///
enum FE_DFL_ENV = cast(fenv_t*)(-1);
}
else version (CRuntime_UClibc)
{
///
enum FE_DFL_ENV = cast(fenv_t*)(-1);
}
else
{
static assert( false, "Unsupported platform" );
}
///
int feclearexcept(int excepts);
///
int fetestexcept(int excepts);
///
int feholdexcept(fenv_t* envp);
///
int fegetexceptflag(fexcept_t* flagp, int excepts);
///
int fesetexceptflag(const scope fexcept_t* flagp, int excepts);
///
int fegetround();
///
int fesetround(int round);
///
int fegetenv(fenv_t* envp);
///
int fesetenv(const scope fenv_t* envp);
// MS define feraiseexcept() and feupdateenv() inline.
version (CRuntime_Microsoft) // supported since MSVCRT 12 (VS 2013) only
{
///
int feraiseexcept()(int excepts)
{
struct Entry
{
int exceptVal;
double num;
double denom;
}
static __gshared immutable(Entry[5]) table =
[ // Raise exception by evaluating num / denom:
{ FE_INVALID, 0.0, 0.0 },
{ FE_DIVBYZERO, 1.0, 0.0 },
{ FE_OVERFLOW, 1e+300, 1e-300 },
{ FE_UNDERFLOW, 1e-300, 1e+300 },
{ FE_INEXACT, 2.0, 3.0 }
];
if ((excepts &= FE_ALL_EXCEPT) == 0)
return 0;
// Raise the exceptions not masked:
double ans = void;
foreach (i; 0 .. table.length)
{
if ((excepts & table[i].exceptVal) != 0)
ans = table[i].num / table[i].denom;
}
return 0;
}
///
int feupdateenv()(const scope fenv_t* envp)
{
int excepts = fetestexcept(FE_ALL_EXCEPT);
return (fesetenv(envp) != 0 || feraiseexcept(excepts) != 0 ? 1 : 0);
}
}
else
{
///
int feraiseexcept(int excepts);
///
int feupdateenv(const scope fenv_t* envp);
}
|