Changeset 55865 in vbox for trunk/include/iprt
- Timestamp:
- May 14, 2015 7:40:09 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/assert.h
r55192 r55865 457 457 # define RTAssertMsg1Weak(pszExpr, uLine, pszfile, pszFunction) \ 458 458 do { } while (0) 459 # define RTAssertMsg2Weak if ( 0)RTAssertMsg2Weak459 # define RTAssertMsg2Weak if (1) {} else RTAssertMsg2Weak 460 460 #endif 461 461 … … 499 499 # define Assert(expr) \ 500 500 do { \ 501 if (RT_UNLIKELY(!(expr))) \ 501 if (RT_LIKELY(!!(expr))) \ 502 { /* likely */ } \ 503 else \ 502 504 { \ 503 505 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 519 521 # define AssertStmt(expr, stmt) \ 520 522 do { \ 521 if (RT_UNLIKELY(!(expr))) \ 523 if (RT_LIKELY(!!(expr))) \ 524 { /* likely */ } \ 525 else \ 522 526 { \ 523 527 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 529 533 # define AssertStmt(expr, stmt) \ 530 534 do { \ 531 if (RT_UNLIKELY(!(expr))) \ 535 if (RT_LIKELY(!!(expr))) \ 536 { /* likely */ } \ 537 else \ 532 538 { \ 533 539 stmt; \ … … 547 553 # define AssertReturn(expr, rc) \ 548 554 do { \ 549 if (RT_UNLIKELY(!(expr))) \ 555 if (RT_LIKELY(!!(expr))) \ 556 { /* likely */ } \ 557 else \ 550 558 { \ 551 559 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 557 565 # define AssertReturn(expr, rc) \ 558 566 do { \ 559 if (RT_UNLIKELY(!(expr))) \ 567 if (RT_LIKELY(!!(expr))) \ 568 { /* likely */ } \ 569 else \ 560 570 return (rc); \ 561 571 } while (0) … … 576 586 # define AssertReturnStmt(expr, stmt, rc) \ 577 587 do { \ 578 if (RT_UNLIKELY(!(expr))) \ 588 if (RT_LIKELY(!!(expr))) \ 589 { /* likely */ } \ 590 else \ 579 591 { \ 580 592 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 587 599 # define AssertReturnStmt(expr, stmt, rc) \ 588 600 do { \ 589 if (RT_UNLIKELY(!(expr))) \ 601 if (RT_LIKELY(!!(expr))) \ 602 { /* likely */ } \ 603 else \ 590 604 { \ 591 605 stmt; \ … … 604 618 # define AssertReturnVoid(expr) \ 605 619 do { \ 606 if (RT_UNLIKELY(!(expr))) \ 620 if (RT_LIKELY(!!(expr))) \ 621 { /* likely */ } \ 622 else \ 607 623 { \ 608 624 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 614 630 # define AssertReturnVoid(expr) \ 615 631 do { \ 616 if (RT_UNLIKELY(!(expr))) \ 632 if (RT_LIKELY(!!(expr))) \ 633 { /* likely */ } \ 634 else \ 617 635 return; \ 618 636 } while (0) … … 631 649 # define AssertReturnVoidStmt(expr, stmt) \ 632 650 do { \ 633 if (RT_UNLIKELY(!(expr))) \ 651 if (RT_LIKELY(!!(expr))) \ 652 { /* likely */ } \ 653 else \ 634 654 { \ 635 655 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 642 662 # define AssertReturnVoidStmt(expr, stmt) \ 643 663 do { \ 644 if (RT_UNLIKELY(!(expr))) \ 664 if (RT_LIKELY(!!(expr))) \ 665 { /* likely */ } \ 666 else \ 645 667 { \ 646 668 stmt; \ … … 659 681 #ifdef RT_STRICT 660 682 # define AssertBreak(expr) \ 661 if (RT_UNLIKELY(!(expr))) \ 683 if (RT_LIKELY(!!(expr))) \ 684 { /* likely */ } \ 685 else if (1) \ 662 686 { \ 663 687 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 667 691 #else 668 692 # define AssertBreak(expr) \ 669 if (RT_UNLIKELY(!(expr))) \ 670 break; \ 671 else do {} while (0) 693 if (RT_LIKELY(!!(expr))) \ 694 { /* likely */ } \ 695 else \ 696 break 672 697 #endif 673 698 … … 681 706 #ifdef RT_STRICT 682 707 # define AssertBreakStmt(expr, stmt) \ 683 if (RT_UNLIKELY(!(expr))) { \ 708 if (RT_LIKELY(!!(expr))) \ 709 { /* likely */ } \ 710 else if (1) \ 711 { \ 684 712 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 685 713 RTAssertPanic(); \ … … 689 717 #else 690 718 # define AssertBreakStmt(expr, stmt) \ 691 if (RT_UNLIKELY(!(expr))) { \ 719 if (RT_LIKELY(!!(expr))) \ 720 { /* likely */ } \ 721 else if (1) \ 722 { \ 692 723 stmt; \ 693 724 break; \ … … 704 735 # define AssertMsg(expr, a) \ 705 736 do { \ 706 if (RT_UNLIKELY(!(expr))) \ 737 if (RT_LIKELY(!!(expr))) \ 738 { /* likely */ } \ 739 else \ 707 740 { \ 708 741 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 728 761 # define AssertMsgStmt(expr, a, stmt) \ 729 762 do { \ 730 if (RT_UNLIKELY(!(expr))) \ 763 if (RT_LIKELY(!!(expr))) \ 764 { /* likely */ } \ 765 else \ 731 766 { \ 732 767 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 739 774 # define AssertMsgStmt(expr, a, stmt) \ 740 775 do { \ 741 if (RT_UNLIKELY(!(expr))) \ 776 if (RT_LIKELY(!!(expr))) \ 777 { /* likely */ } \ 778 else \ 742 779 { \ 743 780 stmt; \ … … 757 794 # define AssertMsgReturn(expr, a, rc) \ 758 795 do { \ 759 if (RT_UNLIKELY(!(expr))) \ 796 if (RT_LIKELY(!!(expr))) \ 797 { /* likely */ } \ 798 else \ 760 799 { \ 761 800 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 768 807 # define AssertMsgReturn(expr, a, rc) \ 769 808 do { \ 770 if (RT_UNLIKELY(!(expr))) \ 809 if (RT_LIKELY(!!(expr))) \ 810 { /* likely */ } \ 811 else \ 771 812 return (rc); \ 772 813 } while (0) … … 788 829 # define AssertMsgReturnStmt(expr, a, stmt, rc) \ 789 830 do { \ 790 if (RT_UNLIKELY(!(expr))) \ 831 if (RT_LIKELY(!!(expr))) \ 832 { /* likely */ } \ 833 else \ 791 834 { \ 792 835 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 800 843 # define AssertMsgReturnStmt(expr, a, stmt, rc) \ 801 844 do { \ 802 if (RT_UNLIKELY(!(expr))) \ 845 if (RT_LIKELY(!!(expr))) \ 846 { /* likely */ } \ 847 else \ 803 848 { \ 804 849 stmt; \ … … 818 863 # define AssertMsgReturnVoid(expr, a) \ 819 864 do { \ 820 if (RT_UNLIKELY(!(expr))) \ 865 if (RT_LIKELY(!!(expr))) \ 866 { /* likely */ } \ 867 else \ 821 868 { \ 822 869 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 829 876 # define AssertMsgReturnVoid(expr, a) \ 830 877 do { \ 831 if (RT_UNLIKELY(!(expr))) \ 878 if (RT_LIKELY(!!(expr))) \ 879 { /* likely */ } \ 880 else \ 832 881 return; \ 833 882 } while (0) … … 842 891 * @param expr Expression which should be true. 843 892 * @param a printf argument list (in parenthesis). 844 * @param stmt Statement to execute before breakin case of a failed assertion.893 * @param stmt Statement to execute before return in case of a failed assertion. 845 894 */ 846 895 #ifdef RT_STRICT 847 896 # define AssertMsgReturnVoidStmt(expr, a, stmt) \ 848 897 do { \ 849 if (RT_UNLIKELY(!(expr))) \ 898 if (RT_LIKELY(!!(expr))) \ 899 { /* likely */ } \ 900 else \ 850 901 { \ 851 902 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 859 910 # define AssertMsgReturnVoidStmt(expr, a, stmt) \ 860 911 do { \ 861 if (RT_UNLIKELY(!(expr))) \ 912 if (RT_LIKELY(!!(expr))) \ 913 { /* likely */ } \ 914 else \ 862 915 { \ 863 916 stmt; \ … … 876 929 */ 877 930 #ifdef RT_STRICT 878 # define AssertMsgBreak(expr, a) \ 879 if (RT_UNLIKELY(!(expr))) \ 931 # define AssertMsgBreak(expr, a) \ 932 if (RT_LIKELY(!!(expr))) \ 933 { /* likely */ } \ 934 else if (1) \ 880 935 { \ 881 936 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 886 941 #else 887 942 # define AssertMsgBreak(expr, a) \ 888 if (RT_UNLIKELY(!(expr))) \ 889 break; \ 890 else do {} while (0) 943 if (RT_LIKELY(!!(expr))) \ 944 { /* likely */ } \ 945 else \ 946 break 891 947 #endif 892 948 … … 901 957 #ifdef RT_STRICT 902 958 # define AssertMsgBreakStmt(expr, a, stmt) \ 903 if (RT_UNLIKELY(!(expr))) { \ 959 if (RT_LIKELY(!!(expr))) \ 960 { /* likely */ } \ 961 else if (1) \ 962 { \ 904 963 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 905 964 RTAssertMsg2Weak a; \ … … 910 969 #else 911 970 # define AssertMsgBreakStmt(expr, a, stmt) \ 912 if (RT_UNLIKELY(!(expr))) { \ 971 if (RT_LIKELY(!!(expr))) \ 972 { /* likely */ } \ 973 else if (1) \ 974 { \ 913 975 stmt; \ 914 976 break; \ … … 1196 1258 #define AssertLogRel(expr) \ 1197 1259 do { \ 1198 if (RT_UNLIKELY(!(expr))) \ 1260 if (RT_LIKELY(!!(expr))) \ 1261 { /* likely */ } \ 1262 else \ 1199 1263 { \ 1200 1264 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1212 1276 #define AssertLogRelReturn(expr, rc) \ 1213 1277 do { \ 1214 if (RT_UNLIKELY(!(expr))) \ 1278 if (RT_LIKELY(!!(expr))) \ 1279 { /* likely */ } \ 1280 else \ 1215 1281 { \ 1216 1282 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1228 1294 #define AssertLogRelReturnVoid(expr) \ 1229 1295 do { \ 1230 if (RT_UNLIKELY(!(expr))) \ 1296 if (RT_LIKELY(!!(expr))) \ 1297 { /* likely */ } \ 1298 else \ 1231 1299 { \ 1232 1300 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1243 1311 */ 1244 1312 #define AssertLogRelBreak(expr) \ 1245 if (RT_UNLIKELY(!(expr))) \ 1313 if (RT_LIKELY(!!(expr))) \ 1314 { /* likely */ } \ 1315 else if (1) \ 1246 1316 { \ 1247 1317 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1259 1329 */ 1260 1330 #define AssertLogRelBreakStmt(expr, stmt) \ 1261 if (RT_UNLIKELY(!(expr))) \ 1331 if (RT_LIKELY(!!(expr))) \ 1332 { /* likely */ } \ 1333 else if (1) \ 1262 1334 { \ 1263 1335 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1276 1348 #define AssertLogRelMsg(expr, a) \ 1277 1349 do { \ 1278 if (RT_UNLIKELY(!(expr))) \ 1350 if (RT_LIKELY(!!(expr))) \ 1351 { /* likely */ } \ 1352 else\ 1279 1353 { \ 1280 1354 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1294 1368 #define AssertLogRelMsgStmt(expr, a, stmt) \ 1295 1369 do { \ 1296 if (RT_UNLIKELY(!(expr))) \ 1370 if (RT_LIKELY(!!(expr))) \ 1371 { /* likely */ } \ 1372 else\ 1297 1373 { \ 1298 1374 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1313 1389 #define AssertLogRelMsgReturn(expr, a, rc) \ 1314 1390 do { \ 1315 if (RT_UNLIKELY(!(expr))) \ 1391 if (RT_LIKELY(!!(expr))) \ 1392 { /* likely */ } \ 1393 else\ 1316 1394 { \ 1317 1395 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1335 1413 #define AssertLogRelMsgReturnStmt(expr, a, stmt, rcRet) \ 1336 1414 do { \ 1337 if (RT_UNLIKELY(!(expr))) \ 1415 if (RT_LIKELY(!!(expr))) \ 1416 { /* likely */ } \ 1417 else\ 1338 1418 { \ 1339 1419 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1354 1434 #define AssertLogRelMsgReturnVoid(expr, a) \ 1355 1435 do { \ 1356 if (RT_UNLIKELY(!(expr))) \ 1436 if (RT_LIKELY(!!(expr))) \ 1437 { /* likely */ } \ 1438 else\ 1357 1439 { \ 1358 1440 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1371 1453 */ 1372 1454 #define AssertLogRelMsgBreak(expr, a) \ 1373 if (RT_UNLIKELY(!(expr))) \ 1455 if (RT_LIKELY(!!(expr))) \ 1456 { /* likely */ } \ 1457 else if (1) \ 1374 1458 { \ 1375 1459 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1389 1473 */ 1390 1474 #define AssertLogRelMsgBreakStmt(expr, a, stmt) \ 1391 if (RT_UNLIKELY(!(expr))) \ 1475 if (RT_LIKELY(!!(expr))) \ 1476 { /* likely */ } \ 1477 else if (1) \ 1392 1478 { \ 1393 1479 RTAssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1612 1698 #define AssertRelease(expr) \ 1613 1699 do { \ 1614 if (RT_UNLIKELY(!(expr))) \ 1700 if (RT_LIKELY(!!(expr))) \ 1701 { /* likely */ } \ 1702 else \ 1615 1703 { \ 1616 1704 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__); \ … … 1627 1715 #define AssertReleaseReturn(expr, rc) \ 1628 1716 do { \ 1629 if (RT_UNLIKELY(!(expr))) \ 1717 if (RT_LIKELY(!!(expr))) \ 1718 { /* likely */ } \ 1719 else \ 1630 1720 { \ 1631 1721 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1642 1732 #define AssertReleaseReturnVoid(expr) \ 1643 1733 do { \ 1644 if (RT_UNLIKELY(!(expr))) \ 1734 if (RT_LIKELY(!!(expr))) \ 1735 { /* likely */ } \ 1736 else \ 1645 1737 { \ 1646 1738 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1657 1749 */ 1658 1750 #define AssertReleaseBreak(expr) \ 1659 if {\1660 if (RT_UNLIKELY(!(expr)))\1661 {\1662 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__);\1663 RTAssertReleasePanic(); \1664 break; \1665 }\1751 if (RT_LIKELY(!!(expr))) \ 1752 { /* likely */ } \ 1753 else if (1) \ 1754 { \ 1755 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 1756 RTAssertReleasePanic(); \ 1757 break; \ 1666 1758 } else do {} while (0) 1667 1759 … … 1673 1765 */ 1674 1766 #define AssertReleaseBreakStmt(expr, stmt) \ 1675 if (RT_UNLIKELY(!(expr))) \ 1767 if (RT_LIKELY(!!(expr))) \ 1768 { /* likely */ } \ 1769 else if (1) \ 1676 1770 { \ 1677 1771 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1690 1784 #define AssertReleaseMsg(expr, a) \ 1691 1785 do { \ 1692 if (RT_UNLIKELY(!(expr))) \ 1786 if (RT_LIKELY(!!(expr))) \ 1787 { /* likely */ } \ 1788 else \ 1693 1789 { \ 1694 1790 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1707 1803 #define AssertReleaseMsgReturn(expr, a, rc) \ 1708 1804 do { \ 1709 if (RT_UNLIKELY(!(expr))) \ 1805 if (RT_LIKELY(!!(expr))) \ 1806 { /* likely */ } \ 1807 else \ 1710 1808 { \ 1711 1809 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1724 1822 #define AssertReleaseMsgReturnVoid(expr, a) \ 1725 1823 do { \ 1726 if (RT_UNLIKELY(!(expr))) \ 1824 if (RT_LIKELY(!!(expr))) \ 1825 { /* likely */ } \ 1826 else \ 1727 1827 { \ 1728 1828 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1741 1841 */ 1742 1842 #define AssertReleaseMsgBreak(expr, a) \ 1743 if (RT_UNLIKELY(!(expr))) \ 1843 if (RT_LIKELY(!!(expr))) \ 1844 { /* likely */ } \ 1845 else if (1) \ 1744 1846 { \ 1745 1847 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ … … 1757 1859 */ 1758 1860 #define AssertReleaseMsgBreakStmt(expr, a, stmt) \ 1759 if (RT_UNLIKELY(!(expr))) { \ 1861 if (RT_LIKELY(!!(expr))) \ 1862 { /* likely */ } \ 1863 else if (1) \ 1864 { \ 1760 1865 RTAssertMsg1Weak(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \ 1761 1866 RTAssertMsg2Weak a; \ … … 1908 2013 #define AssertFatal(expr) \ 1909 2014 do { \ 1910 if (RT_UNLIKELY(!(expr))) \ 2015 if (RT_LIKELY(!!(expr))) \ 2016 { /* likely */ } \ 2017 else \ 1911 2018 for (;;) \ 1912 2019 { \ … … 1924 2031 #define AssertFatalMsg(expr, a) \ 1925 2032 do { \ 1926 if (RT_UNLIKELY(!(expr))) \ 2033 if (RT_LIKELY(!!(expr))) \ 2034 { /* likely */ } \ 2035 else \ 1927 2036 for (;;) \ 1928 2037 { \
Note:
See TracChangeset
for help on using the changeset viewer.