aboutsummaryrefslogtreecommitdiff
path: root/src/lib/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/internal.h')
-rw-r--r--src/lib/internal.h161
1 files changed, 82 insertions, 79 deletions
diff --git a/src/lib/internal.h b/src/lib/internal.h
index bd3bd1c6..b5ec3039 100644
--- a/src/lib/internal.h
+++ b/src/lib/internal.h
@@ -58,14 +58,16 @@
58 * 58 *
59 * @param msg error message (const char *) 59 * @param msg error message (const char *)
60 */ 60 */
61#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); BUILTIN_NOT_REACHED; } while (0) 61#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg); \
62 BUILTIN_NOT_REACHED; } while (0)
62#else 63#else
63/** 64/**
64 * Trigger 'panic' action based on fatal errors. 65 * Trigger 'panic' action based on fatal errors.
65 * 66 *
66 * @param msg error message (const char *) 67 * @param msg error message (const char *)
67 */ 68 */
68#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); BUILTIN_NOT_REACHED; } while (0) 69#define MHD_PANIC(msg) do { mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL); \
70 BUILTIN_NOT_REACHED; } while (0)
69#endif 71#endif
70 72
71#include "mhd_threads.h" 73#include "mhd_threads.h"
@@ -82,8 +84,8 @@
82 */ 84 */
83void 85void
84MHD_DLOG (const struct MHD_Daemon *daemon, 86MHD_DLOG (const struct MHD_Daemon *daemon,
85 enum MHD_StatusCode sc, 87 enum MHD_StatusCode sc,
86 const char *format, 88 const char *format,
87 ...); 89 ...);
88#endif 90#endif
89 91
@@ -93,9 +95,9 @@ MHD_DLOG (const struct MHD_Daemon *daemon,
93 * @param fd the FD to close 95 * @param fd the FD to close
94 */ 96 */
95#define MHD_fd_close_chk_(fd) do { \ 97#define MHD_fd_close_chk_(fd) do { \
96 if ( (0 != close ((fd)) && (EBADF == errno)) ) \ 98 if ( (0 != close ((fd)) && (EBADF == errno)) ) \
97 MHD_PANIC(_("Failed to close FD.\n")); \ 99 MHD_PANIC (_ ("Failed to close FD.\n")); \
98 } while(0) 100} while (0)
99 101
100/** 102/**
101 * Should we perform additional sanity checks at runtime (on our internal 103 * Should we perform additional sanity checks at runtime (on our internal
@@ -128,10 +130,11 @@ extern MHD_PanicCallback mhd_panic;
128extern void *mhd_panic_cls; 130extern void *mhd_panic_cls;
129 131
130/* If we have Clang or gcc >= 4.5, use __buildin_unreachable() */ 132/* If we have Clang or gcc >= 4.5, use __buildin_unreachable() */
131#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) 133#if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= \
132#define BUILTIN_NOT_REACHED __builtin_unreachable() 134 5)
135#define BUILTIN_NOT_REACHED __builtin_unreachable ()
133#elif defined(_MSC_FULL_VER) 136#elif defined(_MSC_FULL_VER)
134#define BUILTIN_NOT_REACHED __assume(0) 137#define BUILTIN_NOT_REACHED __assume (0)
135#else 138#else
136#define BUILTIN_NOT_REACHED 139#define BUILTIN_NOT_REACHED
137#endif 140#endif
@@ -140,7 +143,7 @@ extern void *mhd_panic_cls;
140/** 143/**
141 * Determine length of static string / macro strings at compile time. 144 * Determine length of static string / macro strings at compile time.
142 */ 145 */
143#define MHD_STATICSTR_LEN_(macro) (sizeof(macro)/sizeof(char) - 1) 146#define MHD_STATICSTR_LEN_(macro) (sizeof(macro) / sizeof(char) - 1)
144#endif /* ! MHD_STATICSTR_LEN_ */ 147#endif /* ! MHD_STATICSTR_LEN_ */
145 148
146 149
@@ -1534,8 +1537,8 @@ struct MHD_Daemon
1534 * @return #MHD_SC_OK on success, otherwise an error code 1537 * @return #MHD_SC_OK on success, otherwise an error code
1535 */ 1538 */
1536typedef enum MHD_StatusCode 1539typedef enum MHD_StatusCode
1537(*ActionCallback) (void *cls, 1540(*ActionCallback)(void *cls,
1538 struct MHD_Request *request); 1541 struct MHD_Request *request);
1539 1542
1540 1543
1541/** 1544/**
@@ -1703,9 +1706,9 @@ struct MHD_Response
1703 */ 1706 */
1704typedef bool 1707typedef bool
1705(*MHD_ArgumentIterator_)(struct MHD_Request *request, 1708(*MHD_ArgumentIterator_)(struct MHD_Request *request,
1706 const char *key, 1709 const char *key,
1707 const char *value, 1710 const char *value,
1708 enum MHD_ValueKind kind); 1711 enum MHD_ValueKind kind);
1709 1712
1710 1713
1711/** 1714/**
@@ -1724,10 +1727,10 @@ typedef bool
1724 */ 1727 */
1725bool 1728bool
1726MHD_parse_arguments_ (struct MHD_Request *request, 1729MHD_parse_arguments_ (struct MHD_Request *request,
1727 enum MHD_ValueKind kind, 1730 enum MHD_ValueKind kind,
1728 char *args, 1731 char *args,
1729 MHD_ArgumentIterator_ cb, 1732 MHD_ArgumentIterator_ cb,
1730 unsigned int *num_headers); 1733 unsigned int *num_headers);
1731 1734
1732 1735
1733 1736
@@ -1740,15 +1743,15 @@ MHD_parse_arguments_ (struct MHD_Request *request,
1740 * @param element element to insert 1743 * @param element element to insert
1741 */ 1744 */
1742#define DLL_insert(head,tail,element) do { \ 1745#define DLL_insert(head,tail,element) do { \
1743 mhd_assert (NULL == (element)->next); \ 1746 mhd_assert (NULL == (element)->next); \
1744 mhd_assert (NULL == (element)->prev); \ 1747 mhd_assert (NULL == (element)->prev); \
1745 (element)->next = (head); \ 1748 (element)->next = (head); \
1746 (element)->prev = NULL; \ 1749 (element)->prev = NULL; \
1747 if ((tail) == NULL) \ 1750 if ((tail) == NULL) \
1748 (tail) = element; \ 1751 (tail) = element; \
1749 else \ 1752 else \
1750 (head)->prev = element; \ 1753 (head)->prev = element; \
1751 (head) = (element); } while (0) 1754 (head) = (element); } while (0)
1752 1755
1753 1756
1754/** 1757/**
@@ -1760,18 +1763,18 @@ MHD_parse_arguments_ (struct MHD_Request *request,
1760 * @param element element to remove 1763 * @param element element to remove
1761 */ 1764 */
1762#define DLL_remove(head,tail,element) do { \ 1765#define DLL_remove(head,tail,element) do { \
1763 mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ 1766 mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \
1764 mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ 1767 mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \
1765 if ((element)->prev == NULL) \ 1768 if ((element)->prev == NULL) \
1766 (head) = (element)->next; \ 1769 (head) = (element)->next; \
1767 else \ 1770 else \
1768 (element)->prev->next = (element)->next; \ 1771 (element)->prev->next = (element)->next; \
1769 if ((element)->next == NULL) \ 1772 if ((element)->next == NULL) \
1770 (tail) = (element)->prev; \ 1773 (tail) = (element)->prev; \
1771 else \ 1774 else \
1772 (element)->next->prev = (element)->prev; \ 1775 (element)->next->prev = (element)->prev; \
1773 (element)->next = NULL; \ 1776 (element)->next = NULL; \
1774 (element)->prev = NULL; } while (0) 1777 (element)->prev = NULL; } while (0)
1775 1778
1776 1779
1777 1780
@@ -1784,15 +1787,15 @@ MHD_parse_arguments_ (struct MHD_Request *request,
1784 * @param element element to insert 1787 * @param element element to insert
1785 */ 1788 */
1786#define XDLL_insert(head,tail,element) do { \ 1789#define XDLL_insert(head,tail,element) do { \
1787 mhd_assert (NULL == (element)->nextX); \ 1790 mhd_assert (NULL == (element)->nextX); \
1788 mhd_assert (NULL == (element)->prevX); \ 1791 mhd_assert (NULL == (element)->prevX); \
1789 (element)->nextX = (head); \ 1792 (element)->nextX = (head); \
1790 (element)->prevX = NULL; \ 1793 (element)->prevX = NULL; \
1791 if (NULL == (tail)) \ 1794 if (NULL == (tail)) \
1792 (tail) = element; \ 1795 (tail) = element; \
1793 else \ 1796 else \
1794 (head)->prevX = element; \ 1797 (head)->prevX = element; \
1795 (head) = (element); } while (0) 1798 (head) = (element); } while (0)
1796 1799
1797 1800
1798/** 1801/**
@@ -1804,18 +1807,18 @@ MHD_parse_arguments_ (struct MHD_Request *request,
1804 * @param element element to remove 1807 * @param element element to remove
1805 */ 1808 */
1806#define XDLL_remove(head,tail,element) do { \ 1809#define XDLL_remove(head,tail,element) do { \
1807 mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ 1810 mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \
1808 mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ 1811 mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \
1809 if (NULL == (element)->prevX) \ 1812 if (NULL == (element)->prevX) \
1810 (head) = (element)->nextX; \ 1813 (head) = (element)->nextX; \
1811 else \ 1814 else \
1812 (element)->prevX->nextX = (element)->nextX; \ 1815 (element)->prevX->nextX = (element)->nextX; \
1813 if (NULL == (element)->nextX) \ 1816 if (NULL == (element)->nextX) \
1814 (tail) = (element)->prevX; \ 1817 (tail) = (element)->prevX; \
1815 else \ 1818 else \
1816 (element)->nextX->prevX = (element)->prevX; \ 1819 (element)->nextX->prevX = (element)->prevX; \
1817 (element)->nextX = NULL; \ 1820 (element)->nextX = NULL; \
1818 (element)->prevX = NULL; } while (0) 1821 (element)->prevX = NULL; } while (0)
1819 1822
1820 1823
1821/** 1824/**
@@ -1827,13 +1830,13 @@ MHD_parse_arguments_ (struct MHD_Request *request,
1827 * @param element element to insert 1830 * @param element element to insert
1828 */ 1831 */
1829#define EDLL_insert(head,tail,element) do { \ 1832#define EDLL_insert(head,tail,element) do { \
1830 (element)->nextE = (head); \ 1833 (element)->nextE = (head); \
1831 (element)->prevE = NULL; \ 1834 (element)->prevE = NULL; \
1832 if ((tail) == NULL) \ 1835 if ((tail) == NULL) \
1833 (tail) = element; \ 1836 (tail) = element; \
1834 else \ 1837 else \
1835 (head)->prevE = element; \ 1838 (head)->prevE = element; \
1836 (head) = (element); } while (0) 1839 (head) = (element); } while (0)
1837 1840
1838 1841
1839/** 1842/**
@@ -1845,16 +1848,16 @@ MHD_parse_arguments_ (struct MHD_Request *request,
1845 * @param element element to remove 1848 * @param element element to remove
1846 */ 1849 */
1847#define EDLL_remove(head,tail,element) do { \ 1850#define EDLL_remove(head,tail,element) do { \
1848 if ((element)->prevE == NULL) \ 1851 if ((element)->prevE == NULL) \
1849 (head) = (element)->nextE; \ 1852 (head) = (element)->nextE; \
1850 else \ 1853 else \
1851 (element)->prevE->nextE = (element)->nextE; \ 1854 (element)->prevE->nextE = (element)->nextE; \
1852 if ((element)->nextE == NULL) \ 1855 if ((element)->nextE == NULL) \
1853 (tail) = (element)->prevE; \ 1856 (tail) = (element)->prevE; \
1854 else \ 1857 else \
1855 (element)->nextE->prevE = (element)->prevE; \ 1858 (element)->nextE->prevE = (element)->prevE; \
1856 (element)->nextE = NULL; \ 1859 (element)->nextE = NULL; \
1857 (element)->prevE = NULL; } while (0) 1860 (element)->prevE = NULL; } while (0)
1858 1861
1859 1862
1860 1863