diff --git a/include/common/buf.h b/include/common/buf.h index 0bdc5beb9..6ae9a4e67 100644 --- a/include/common/buf.h +++ b/include/common/buf.h @@ -28,11 +28,9 @@ #ifndef _COMMON_BUF_H #define _COMMON_BUF_H -#include #include #include - -#include +#include /* Structure defining a buffer's head */ struct buffer { diff --git a/include/common/debug.h b/include/common/debug.h index c234bdc70..c1b7e42ce 100644 --- a/include/common/debug.h +++ b/include/common/debug.h @@ -25,49 +25,6 @@ #include #include -#ifdef DEBUG_FULL -#define DPRINTF(x...) fprintf(x) -#else -#define DPRINTF(x...) -#endif - -#ifdef DEBUG_FSM -#define FSM_PRINTF(x...) fprintf(x) -#else -#define FSM_PRINTF(x...) -#endif - -/* This abort is more efficient than abort() because it does not mangle the - * stack and stops at the exact location we need. - */ -#define ABORT_NOW() (*(volatile int*)1=0) - -/* BUG_ON: complains if is true when DEBUG_STRICT or DEBUG_STRICT_NOCRASH - * are set, does nothing otherwise. With DEBUG_STRICT in addition it immediately - * crashes using ABORT_NOW() above. - */ -#if defined(DEBUG_STRICT) || defined(DEBUG_STRICT_NOCRASH) -#if defined(DEBUG_STRICT) -#define CRASH_NOW() ABORT_NOW() -#else -#define CRASH_NOW() -#endif - -#define BUG_ON(cond) _BUG_ON(cond, __FILE__, __LINE__) -#define _BUG_ON(cond, file, line) __BUG_ON(cond, file, line) -#define __BUG_ON(cond, file, line) \ - do { \ - if (unlikely(cond)) { \ - const char msg[] = "\nFATAL: bug condition \"" #cond "\" matched at " file ":" #line "\n"; \ - DISGUISE(write(2, msg, strlen(msg))); \ - CRASH_NOW(); \ - } \ - } while (0) -#else -#undef CRASH_NOW -#define BUG_ON(cond) -#endif - struct task; struct buffer; extern volatile unsigned long threads_to_dump; diff --git a/include/haproxy/api.h b/include/haproxy/api.h index 5a916ba44..f32050d71 100644 --- a/include/haproxy/api.h +++ b/include/haproxy/api.h @@ -30,6 +30,7 @@ #ifndef _HAPROXY_BASE_H #define _HAPROXY_BASE_H +#include #include #include diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h new file mode 100644 index 000000000..d164c4c12 --- /dev/null +++ b/include/haproxy/bug.h @@ -0,0 +1,78 @@ +/* + * include/haproxy/bug.h + * Assertions and instant crash macros needed everywhere. + * + * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _HAPROXY_BUG_H +#define _HAPROXY_BUG_H + +#include + +/* quick debugging hack, should really be removed ASAP */ +#ifdef DEBUG_FULL +#define DPRINTF(x...) fprintf(x) +#else +#define DPRINTF(x...) +#endif + +/* This abort is more efficient than abort() because it does not mangle the + * stack and stops at the exact location we need. + */ +#define ABORT_NOW() (*(volatile int*)1=0) + +/* BUG_ON: complains if is true when DEBUG_STRICT or DEBUG_STRICT_NOCRASH + * are set, does nothing otherwise. With DEBUG_STRICT in addition it immediately + * crashes using ABORT_NOW() above. + */ +#if defined(DEBUG_STRICT) || defined(DEBUG_STRICT_NOCRASH) +#if defined(DEBUG_STRICT) +#define CRASH_NOW() ABORT_NOW() +#else +#define CRASH_NOW() +#endif + +#define BUG_ON(cond) _BUG_ON(cond, __FILE__, __LINE__) +#define _BUG_ON(cond, file, line) __BUG_ON(cond, file, line) +#define __BUG_ON(cond, file, line) \ + do { \ + if (unlikely(cond)) { \ + const char msg[] = "\nFATAL: bug condition \"" #cond "\" matched at " file ":" #line "\n"; \ + DISGUISE(write(2, msg, __builtin_strlen(msg))); \ + CRASH_NOW(); \ + } \ + } while (0) +#else +#undef CRASH_NOW +#define BUG_ON(cond) +#endif + +#endif /* _HAPROXY_BUG_H */ + +/* + * Local variables: + * c-indent-level: 8 + * c-basic-offset: 8 + * End: + */ diff --git a/include/proto/session.h b/include/proto/session.h index 61a7b0020..522e43fe5 100644 --- a/include/proto/session.h +++ b/include/proto/session.h @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/src/backend.c b/src/backend.c index ece412c7c..c876003f9 100644 --- a/src/backend.c +++ b/src/backend.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/src/cli.c b/src/cli.c index 13fc2049c..a0118dc2b 100644 --- a/src/cli.c +++ b/src/cli.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include diff --git a/src/connection.c b/src/connection.c index a30a2dd97..adca5c14e 100644 --- a/src/connection.c +++ b/src/connection.c @@ -26,7 +26,6 @@ #include #include -#include DECLARE_POOL(pool_head_connection, "connection", sizeof(struct connection)); DECLARE_POOL(pool_head_connstream, "conn_stream", sizeof(struct conn_stream)); diff --git a/src/ev_epoll.c b/src/ev_epoll.c index 97a0b28c6..91670afd3 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/src/filters.c b/src/filters.c index 3d7bb4562..f8cb52669 100644 --- a/src/filters.c +++ b/src/filters.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 5b8daa144..9bd6ab10a 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/src/frontend.c b/src/frontend.c index 6274e8a40..ce5c3d762 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -24,7 +24,6 @@ #include #include -#include #include #include diff --git a/src/h1_htx.c b/src/h1_htx.c index e9d79f6f8..6e582e389 100644 --- a/src/h1_htx.c +++ b/src/h1_htx.c @@ -11,7 +11,6 @@ */ #include -#include #include #include #include diff --git a/src/http_acl.c b/src/http_acl.c index 06c5d71f2..fe71658da 100644 --- a/src/http_acl.c +++ b/src/http_acl.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/src/http_act.c b/src/http_act.c index 1918aa583..da57d8fe0 100644 --- a/src/http_act.c +++ b/src/http_act.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/http_ana.c b/src/http_ana.c index 4635c38e1..41f119de0 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/src/http_conv.c b/src/http_conv.c index 83c6bb33b..109952145 100644 --- a/src/http_conv.c +++ b/src/http_conv.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/src/http_fetch.c b/src/http_fetch.c index 5d7ae8828..96d44ab60 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/http_htx.c b/src/http_htx.c index f4a600424..38a91cc41 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/src/http_rules.c b/src/http_rules.c index 2661062ee..6a5a5f33b 100644 --- a/src/http_rules.c +++ b/src/http_rules.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/lb_chash.c b/src/lb_chash.c index b21654123..0899ee76e 100644 --- a/src/lb_chash.c +++ b/src/lb_chash.c @@ -17,7 +17,6 @@ */ #include -#include #include #include diff --git a/src/lb_fas.c b/src/lb_fas.c index ef507b7cb..72e9c9c03 100644 --- a/src/lb_fas.c +++ b/src/lb_fas.c @@ -17,7 +17,6 @@ */ #include -#include #include #include diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index 89634bfe4..b9cc9878b 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -11,7 +11,6 @@ */ #include -#include #include #include diff --git a/src/lb_fwrr.c b/src/lb_fwrr.c index 31e8bb2d1..6f8769741 100644 --- a/src/lb_fwrr.c +++ b/src/lb_fwrr.c @@ -11,7 +11,6 @@ */ #include -#include #include #include diff --git a/src/lb_map.c b/src/lb_map.c index 660475b96..8d2461fcf 100644 --- a/src/lb_map.c +++ b/src/lb_map.c @@ -11,7 +11,6 @@ */ #include -#include #include #include diff --git a/src/memory.c b/src/memory.c index 437ce10da..961a292c2 100644 --- a/src/memory.c +++ b/src/memory.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index ff642f26d..c95d5d46f 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 063f4b363..9233288fd 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 5fc976a63..648f3a32f 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/src/raw_sock.c b/src/raw_sock.c index af8cc65af..3612442c1 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/src/session.c b/src/session.c index fd842a404..3f26cd477 100644 --- a/src/session.c +++ b/src/session.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/src/ssl_sock.c b/src/ssl_sock.c index d11eaaf19..c2bea22a0 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -46,7 +46,6 @@ #include #include -#include #include #include #include diff --git a/src/stream.c b/src/stream.c index 903060381..0c030379c 100644 --- a/src/stream.c +++ b/src/stream.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/stream_interface.c b/src/stream_interface.c index fc75c39fc..91f844b97 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 58e67ca76..0be4ecdf2 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -11,7 +11,6 @@ */ #include #include -#include #include #include #include