From d5fc8fcb86eb99831626051b3055bea7ca93a074 Mon Sep 17 00:00:00 2001 From: Tim Duesterhus Date: Sat, 11 Sep 2021 17:51:13 +0200 Subject: [PATCH] CLEANUP: Add haproxy/xxhash.h to avoid modifying import/xxhash.h This solves setting XXH_INLINE_ALL in a cleaner way, because the imported header is not modified, easing future updates. see 6f7cc11e6dd0f01b437fba893da2edd2362660a2 --- addons/51degrees/51d.c | 2 +- admin/dyncookie/dyncookie.c | 3 ++- include/haproxy/activity.h | 2 +- include/haproxy/connection-t.h | 2 +- include/haproxy/defaults.h | 7 ------ include/haproxy/xxhash.h | 45 ++++++++++++++++++++++++++++++++++ include/import/xxhash.h | 2 -- src/pattern.c | 2 +- src/sample.c | 2 +- src/server.c | 3 +-- src/server_state.c | 2 +- src/ssl_sock.c | 2 +- 12 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 include/haproxy/xxhash.h diff --git a/addons/51degrees/51d.c b/addons/51degrees/51d.c index 6dfa578e24..5d686953c9 100644 --- a/addons/51degrees/51d.c +++ b/addons/51degrees/51d.c @@ -1,7 +1,6 @@ #include #include -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include <51Degrees.h> struct _51d_property_names { diff --git a/admin/dyncookie/dyncookie.c b/admin/dyncookie/dyncookie.c index 0c778eb7aa..ddb71a7481 100644 --- a/admin/dyncookie/dyncookie.c +++ b/admin/dyncookie/dyncookie.c @@ -14,7 +14,8 @@ #include #include #include -#include + +#include __attribute__((noreturn)) void die(int code, const char *format, ...) { diff --git a/include/haproxy/activity.h b/include/haproxy/activity.h index 42569f203e..66a5f3be7e 100644 --- a/include/haproxy/activity.h +++ b/include/haproxy/activity.h @@ -22,11 +22,11 @@ #ifndef _HAPROXY_ACTIVITY_H #define _HAPROXY_ACTIVITY_H -#include #include #include #include #include +#include extern unsigned int profiling; extern unsigned long task_profiling_mask; diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index ff8927dbad..1afae9624d 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -38,6 +37,7 @@ #include #include #include +#include /* referenced below */ struct connection; diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h index 16058817e6..19a9cb6235 100644 --- a/include/haproxy/defaults.h +++ b/include/haproxy/defaults.h @@ -404,13 +404,6 @@ #define MAX_POLLERS 10 #endif -/* Make all xxhash functions inline, with implementations being directly - * included within xxhash.h. - */ -#ifndef XXH_INLINE_ALL -#define XXH_INLINE_ALL -#endif - /* system sysfs directory */ #define NUMA_DETECT_SYSTEM_SYSFS_PATH "/sys/devices/system" diff --git a/include/haproxy/xxhash.h b/include/haproxy/xxhash.h new file mode 100644 index 0000000000..83a2fb71c5 --- /dev/null +++ b/include/haproxy/xxhash.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2020 Dragan Dosen + * Copyright (C) 2021 Tim Duesterhus + * + * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _HAPROXY_XXHASH_H +#define _HAPROXY_XXHASH_H + +/* Make all xxhash functions inline, with implementations being directly + * included within xxhash.h. + */ +#ifndef XXH_INLINE_ALL +#define XXH_INLINE_ALL +#else +#error "XXH_INLINE_ALL is already defined." +#endif + +#include + +#endif diff --git a/include/import/xxhash.h b/include/import/xxhash.h index 24326bc33f..d0e3e241ef 100644 --- a/include/import/xxhash.h +++ b/include/import/xxhash.h @@ -75,8 +75,6 @@ XXH32 6.8 GB/s 6.0 GB/s extern "C" { #endif -#include - /* **************************** * INLINE mode ******************************/ diff --git a/src/pattern.c b/src/pattern.c index afc0ad0d08..df0f049530 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -26,6 +25,7 @@ #include #include #include +#include const char *const pat_match_names[PAT_MATCH_NUM] = { diff --git a/src/sample.c b/src/sample.c index e4bb3182a6..3126be1056 100644 --- a/src/sample.c +++ b/src/sample.c @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include /* sample type names */ const char *smp_to_type[SMP_TYPES] = { diff --git a/src/server.c b/src/server.c index f0228be810..8f92a25273 100644 --- a/src/server.c +++ b/src/server.c @@ -16,8 +16,6 @@ #include #include -#include - #include #include #include @@ -46,6 +44,7 @@ #include #include #include +#include static void srv_update_status(struct server *s); diff --git a/src/server_state.c b/src/server_state.c index 18d9cd6bfb..b9ae9edac6 100644 --- a/src/server_state.c +++ b/src/server_state.c @@ -13,7 +13,6 @@ #include #include -#include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include /* Update a server state using the parameters available in the params list. diff --git a/src/ssl_sock.c b/src/ssl_sock.c index ae30c2cb47..a87d70b895 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -79,6 +78,7 @@ #include #include #include +#include /* ***** READ THIS before adding code here! *****