diff options
Diffstat (limited to 'src/microhttpd/internal.h')
-rw-r--r-- | src/microhttpd/internal.h | 161 |
1 files changed, 82 insertions, 79 deletions
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index ac43d819..5cf35790 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -55,14 +55,16 @@ | |||
55 | * | 55 | * |
56 | * @param msg error message (const char *) | 56 | * @param msg error message (const char *) |
57 | */ | 57 | */ |
58 | #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); BUILTIN_NOT_REACHED; } while (0) | 58 | #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); \ |
59 | BUILTIN_NOT_REACHED; } while (0) | ||
59 | #else | 60 | #else |
60 | /** | 61 | /** |
61 | * Trigger 'panic' action based on fatal errors. | 62 | * Trigger 'panic' action based on fatal errors. |
62 | * | 63 | * |
63 | * @param msg error message (const char *) | 64 | * @param msg error message (const char *) |
64 | */ | 65 | */ |
65 | #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); BUILTIN_NOT_REACHED; } while (0) | 66 | #define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); \ |
67 | BUILTIN_NOT_REACHED; } while (0) | ||
66 | #endif | 68 | #endif |
67 | 69 | ||
68 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) | 70 | #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) |
@@ -78,9 +80,9 @@ | |||
78 | * @param fd the FD to close | 80 | * @param fd the FD to close |
79 | */ | 81 | */ |
80 | #define MHD_fd_close_chk_(fd) do { \ | 82 | #define MHD_fd_close_chk_(fd) do { \ |
81 | if ( (0 != close ((fd)) && (EBADF == errno)) ) \ | 83 | if ( (0 != close ((fd)) && (EBADF == errno)) ) \ |
82 | MHD_PANIC(_("Failed to close FD.\n")); \ | 84 | MHD_PANIC (_ ("Failed to close FD.\n")); \ |
83 | } while(0) | 85 | } while (0) |
84 | 86 | ||
85 | /** | 87 | /** |
86 | * Should we perform additional sanity checks at runtime (on our internal | 88 | * Should we perform additional sanity checks at runtime (on our internal |
@@ -113,10 +115,11 @@ extern MHD_PanicCallback mhd_panic; | |||
113 | extern void *mhd_panic_cls; | 115 | extern void *mhd_panic_cls; |
114 | 116 | ||
115 | /* If we have Clang or gcc >= 4.5, use __buildin_unreachable() */ | 117 | /* If we have Clang or gcc >= 4.5, use __buildin_unreachable() */ |
116 | #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) | 118 | #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= \ |
117 | #define BUILTIN_NOT_REACHED __builtin_unreachable() | 119 | 5) |
120 | #define BUILTIN_NOT_REACHED __builtin_unreachable () | ||
118 | #elif defined(_MSC_FULL_VER) | 121 | #elif defined(_MSC_FULL_VER) |
119 | #define BUILTIN_NOT_REACHED __assume(0) | 122 | #define BUILTIN_NOT_REACHED __assume (0) |
120 | #else | 123 | #else |
121 | #define BUILTIN_NOT_REACHED | 124 | #define BUILTIN_NOT_REACHED |
122 | #endif | 125 | #endif |
@@ -125,7 +128,7 @@ extern void *mhd_panic_cls; | |||
125 | /** | 128 | /** |
126 | * Determine length of static string / macro strings at compile time. | 129 | * Determine length of static string / macro strings at compile time. |
127 | */ | 130 | */ |
128 | #define MHD_STATICSTR_LEN_(macro) (sizeof(macro)/sizeof(char) - 1) | 131 | #define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1) |
129 | #endif /* ! MHD_STATICSTR_LEN_ */ | 132 | #endif /* ! MHD_STATICSTR_LEN_ */ |
130 | 133 | ||
131 | 134 | ||
@@ -250,7 +253,7 @@ struct MHD_NonceNc | |||
250 | */ | 253 | */ |
251 | void | 254 | void |
252 | MHD_DLOG (const struct MHD_Daemon *daemon, | 255 | MHD_DLOG (const struct MHD_Daemon *daemon, |
253 | const char *format, | 256 | const char *format, |
254 | ...); | 257 | ...); |
255 | #endif | 258 | #endif |
256 | 259 | ||
@@ -1758,15 +1761,15 @@ struct MHD_Daemon | |||
1758 | * @param element element to insert | 1761 | * @param element element to insert |
1759 | */ | 1762 | */ |
1760 | #define DLL_insert(head,tail,element) do { \ | 1763 | #define DLL_insert(head,tail,element) do { \ |
1761 | mhd_assert (NULL == (element)->next); \ | 1764 | mhd_assert (NULL == (element)->next); \ |
1762 | mhd_assert (NULL == (element)->prev); \ | 1765 | mhd_assert (NULL == (element)->prev); \ |
1763 | (element)->next = (head); \ | 1766 | (element)->next = (head); \ |
1764 | (element)->prev = NULL; \ | 1767 | (element)->prev = NULL; \ |
1765 | if ((tail) == NULL) \ | 1768 | if ((tail) == NULL) \ |
1766 | (tail) = element; \ | 1769 | (tail) = element; \ |
1767 | else \ | 1770 | else \ |
1768 | (head)->prev = element; \ | 1771 | (head)->prev = element; \ |
1769 | (head) = (element); } while (0) | 1772 | (head) = (element); } while (0) |
1770 | 1773 | ||
1771 | 1774 | ||
1772 | /** | 1775 | /** |
@@ -1779,18 +1782,18 @@ struct MHD_Daemon | |||
1779 | * @param element element to remove | 1782 | * @param element element to remove |
1780 | */ | 1783 | */ |
1781 | #define DLL_remove(head,tail,element) do { \ | 1784 | #define DLL_remove(head,tail,element) do { \ |
1782 | mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ | 1785 | mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ |
1783 | mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ | 1786 | mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ |
1784 | if ((element)->prev == NULL) \ | 1787 | if ((element)->prev == NULL) \ |
1785 | (head) = (element)->next; \ | 1788 | (head) = (element)->next; \ |
1786 | else \ | 1789 | else \ |
1787 | (element)->prev->next = (element)->next; \ | 1790 | (element)->prev->next = (element)->next; \ |
1788 | if ((element)->next == NULL) \ | 1791 | if ((element)->next == NULL) \ |
1789 | (tail) = (element)->prev; \ | 1792 | (tail) = (element)->prev; \ |
1790 | else \ | 1793 | else \ |
1791 | (element)->next->prev = (element)->prev; \ | 1794 | (element)->next->prev = (element)->prev; \ |
1792 | (element)->next = NULL; \ | 1795 | (element)->next = NULL; \ |
1793 | (element)->prev = NULL; } while (0) | 1796 | (element)->prev = NULL; } while (0) |
1794 | 1797 | ||
1795 | 1798 | ||
1796 | 1799 | ||
@@ -1803,15 +1806,15 @@ struct MHD_Daemon | |||
1803 | * @param element element to insert | 1806 | * @param element element to insert |
1804 | */ | 1807 | */ |
1805 | #define XDLL_insert(head,tail,element) do { \ | 1808 | #define XDLL_insert(head,tail,element) do { \ |
1806 | mhd_assert (NULL == (element)->nextX); \ | 1809 | mhd_assert (NULL == (element)->nextX); \ |
1807 | mhd_assert (NULL == (element)->prevX); \ | 1810 | mhd_assert (NULL == (element)->prevX); \ |
1808 | (element)->nextX = (head); \ | 1811 | (element)->nextX = (head); \ |
1809 | (element)->prevX = NULL; \ | 1812 | (element)->prevX = NULL; \ |
1810 | if (NULL == (tail)) \ | 1813 | if (NULL == (tail)) \ |
1811 | (tail) = element; \ | 1814 | (tail) = element; \ |
1812 | else \ | 1815 | else \ |
1813 | (head)->prevX = element; \ | 1816 | (head)->prevX = element; \ |
1814 | (head) = (element); } while (0) | 1817 | (head) = (element); } while (0) |
1815 | 1818 | ||
1816 | 1819 | ||
1817 | /** | 1820 | /** |
@@ -1824,18 +1827,18 @@ struct MHD_Daemon | |||
1824 | * @param element element to remove | 1827 | * @param element element to remove |
1825 | */ | 1828 | */ |
1826 | #define XDLL_remove(head,tail,element) do { \ | 1829 | #define XDLL_remove(head,tail,element) do { \ |
1827 | mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ | 1830 | mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ |
1828 | mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ | 1831 | mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ |
1829 | if (NULL == (element)->prevX) \ | 1832 | if (NULL == (element)->prevX) \ |
1830 | (head) = (element)->nextX; \ | 1833 | (head) = (element)->nextX; \ |
1831 | else \ | 1834 | else \ |
1832 | (element)->prevX->nextX = (element)->nextX; \ | 1835 | (element)->prevX->nextX = (element)->nextX; \ |
1833 | if (NULL == (element)->nextX) \ | 1836 | if (NULL == (element)->nextX) \ |
1834 | (tail) = (element)->prevX; \ | 1837 | (tail) = (element)->prevX; \ |
1835 | else \ | 1838 | else \ |
1836 | (element)->nextX->prevX = (element)->prevX; \ | 1839 | (element)->nextX->prevX = (element)->prevX; \ |
1837 | (element)->nextX = NULL; \ | 1840 | (element)->nextX = NULL; \ |
1838 | (element)->prevX = NULL; } while (0) | 1841 | (element)->prevX = NULL; } while (0) |
1839 | 1842 | ||
1840 | 1843 | ||
1841 | /** | 1844 | /** |
@@ -1847,13 +1850,13 @@ struct MHD_Daemon | |||
1847 | * @param element element to insert | 1850 | * @param element element to insert |
1848 | */ | 1851 | */ |
1849 | #define EDLL_insert(head,tail,element) do { \ | 1852 | #define EDLL_insert(head,tail,element) do { \ |
1850 | (element)->nextE = (head); \ | 1853 | (element)->nextE = (head); \ |
1851 | (element)->prevE = NULL; \ | 1854 | (element)->prevE = NULL; \ |
1852 | if ((tail) == NULL) \ | 1855 | if ((tail) == NULL) \ |
1853 | (tail) = element; \ | 1856 | (tail) = element; \ |
1854 | else \ | 1857 | else \ |
1855 | (head)->prevE = element; \ | 1858 | (head)->prevE = element; \ |
1856 | (head) = (element); } while (0) | 1859 | (head) = (element); } while (0) |
1857 | 1860 | ||
1858 | 1861 | ||
1859 | /** | 1862 | /** |
@@ -1866,16 +1869,16 @@ struct MHD_Daemon | |||
1866 | * @param element element to remove | 1869 | * @param element element to remove |
1867 | */ | 1870 | */ |
1868 | #define EDLL_remove(head,tail,element) do { \ | 1871 | #define EDLL_remove(head,tail,element) do { \ |
1869 | if ((element)->prevE == NULL) \ | 1872 | if ((element)->prevE == NULL) \ |
1870 | (head) = (element)->nextE; \ | 1873 | (head) = (element)->nextE; \ |
1871 | else \ | 1874 | else \ |
1872 | (element)->prevE->nextE = (element)->nextE; \ | 1875 | (element)->prevE->nextE = (element)->nextE; \ |
1873 | if ((element)->nextE == NULL) \ | 1876 | if ((element)->nextE == NULL) \ |
1874 | (tail) = (element)->prevE; \ | 1877 | (tail) = (element)->prevE; \ |
1875 | else \ | 1878 | else \ |
1876 | (element)->nextE->prevE = (element)->prevE; \ | 1879 | (element)->nextE->prevE = (element)->prevE; \ |
1877 | (element)->nextE = NULL; \ | 1880 | (element)->nextE = NULL; \ |
1878 | (element)->prevE = NULL; } while (0) | 1881 | (element)->prevE = NULL; } while (0) |
1879 | 1882 | ||
1880 | 1883 | ||
1881 | /** | 1884 | /** |
@@ -1902,11 +1905,11 @@ MHD_unescape_plus (char *arg); | |||
1902 | */ | 1905 | */ |
1903 | typedef int | 1906 | typedef int |
1904 | (*MHD_ArgumentIterator_)(struct MHD_Connection *connection, | 1907 | (*MHD_ArgumentIterator_)(struct MHD_Connection *connection, |
1905 | const char *key, | 1908 | const char *key, |
1906 | size_t key_size, | 1909 | size_t key_size, |
1907 | const char *value, | 1910 | const char *value, |
1908 | size_t value_size, | 1911 | size_t value_size, |
1909 | enum MHD_ValueKind kind); | 1912 | enum MHD_ValueKind kind); |
1910 | 1913 | ||
1911 | 1914 | ||
1912 | /** | 1915 | /** |
@@ -1925,10 +1928,10 @@ typedef int | |||
1925 | */ | 1928 | */ |
1926 | int | 1929 | int |
1927 | MHD_parse_arguments_ (struct MHD_Connection *connection, | 1930 | MHD_parse_arguments_ (struct MHD_Connection *connection, |
1928 | enum MHD_ValueKind kind, | 1931 | enum MHD_ValueKind kind, |
1929 | char *args, | 1932 | char *args, |
1930 | MHD_ArgumentIterator_ cb, | 1933 | MHD_ArgumentIterator_ cb, |
1931 | unsigned int *num_headers); | 1934 | unsigned int *num_headers); |
1932 | 1935 | ||
1933 | 1936 | ||
1934 | /** | 1937 | /** |
@@ -1966,8 +1969,8 @@ MHD_check_response_header_token_ci (const struct MHD_Response *response, | |||
1966 | * false otherwise | 1969 | * false otherwise |
1967 | */ | 1970 | */ |
1968 | #define MHD_check_response_header_s_token_ci(r,k,tkn) \ | 1971 | #define MHD_check_response_header_s_token_ci(r,k,tkn) \ |
1969 | MHD_check_response_header_token_ci((r),(k),MHD_STATICSTR_LEN_(k),\ | 1972 | MHD_check_response_header_token_ci ((r),(k),MHD_STATICSTR_LEN_ (k), \ |
1970 | (tkn),MHD_STATICSTR_LEN_(tkn)) | 1973 | (tkn),MHD_STATICSTR_LEN_ (tkn)) |
1971 | 1974 | ||
1972 | 1975 | ||
1973 | /** | 1976 | /** |