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
diff --git a/addons/51degrees/51d.c b/addons/51degrees/51d.c
index 6dfa578..5d68695 100644
--- a/addons/51degrees/51d.c
+++ b/addons/51degrees/51d.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <import/lru.h>
-#include <import/xxhash.h>
#include <haproxy/api.h>
#include <haproxy/arg.h>
#include <haproxy/buf-t.h>
@@ -15,6 +14,7 @@
#include <haproxy/sample.h>
#include <haproxy/thread.h>
#include <haproxy/tools.h>
+#include <haproxy/xxhash.h>
#include <51Degrees.h>
struct _51d_property_names {
diff --git a/admin/dyncookie/dyncookie.c b/admin/dyncookie/dyncookie.c
index 0c778eb..ddb71a7 100644
--- a/admin/dyncookie/dyncookie.c
+++ b/admin/dyncookie/dyncookie.c
@@ -14,7 +14,8 @@
#include <stdlib.h>
#include <stdarg.h>
#include <arpa/inet.h>
-#include <import/xxhash.h>
+
+#include <haproxy/xxhash.h>
__attribute__((noreturn)) void die(int code, const char *format, ...)
{
diff --git a/include/haproxy/activity.h b/include/haproxy/activity.h
index 42569f2..66a5f3b 100644
--- a/include/haproxy/activity.h
+++ b/include/haproxy/activity.h
@@ -22,11 +22,11 @@
#ifndef _HAPROXY_ACTIVITY_H
#define _HAPROXY_ACTIVITY_H
-#include <import/xxhash.h>
#include <haproxy/activity-t.h>
#include <haproxy/api.h>
#include <haproxy/freq_ctr.h>
#include <haproxy/time.h>
+#include <haproxy/xxhash.h>
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 ff8927d..1afae96 100644
--- a/include/haproxy/connection-t.h
+++ b/include/haproxy/connection-t.h
@@ -30,7 +30,6 @@
#include <import/ebmbtree.h>
#include <import/ist.h>
-#include <import/xxhash.h>
#include <haproxy/api-t.h>
#include <haproxy/buf-t.h>
@@ -38,6 +37,7 @@
#include <haproxy/port_range-t.h>
#include <haproxy/protocol-t.h>
#include <haproxy/thread-t.h>
+#include <haproxy/xxhash.h>
/* referenced below */
struct connection;
diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h
index 1605881..19a9cb6 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 0000000..83a2fb7
--- /dev/null
+++ b/include/haproxy/xxhash.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 Dragan Dosen <ddosen@haproxy.com>
+ * Copyright (C) 2021 Tim Duesterhus <tim@bastelstu.be>
+ *
+ * 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 <import/xxhash.h>
+
+#endif
diff --git a/include/import/xxhash.h b/include/import/xxhash.h
index 24326bc..d0e3e24 100644
--- a/include/import/xxhash.h
+++ b/include/import/xxhash.h
@@ -75,8 +75,6 @@
extern "C" {
#endif
-#include <haproxy/defaults.h>
-
/* ****************************
* INLINE mode
******************************/
diff --git a/src/pattern.c b/src/pattern.c
index afc0ad0..df0f049 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -16,7 +16,6 @@
#include <import/ebsttree.h>
#include <import/lru.h>
-#include <import/xxhash.h>
#include <haproxy/api.h>
#include <haproxy/global.h>
@@ -26,6 +25,7 @@
#include <haproxy/regex.h>
#include <haproxy/sample.h>
#include <haproxy/tools.h>
+#include <haproxy/xxhash.h>
const char *const pat_match_names[PAT_MATCH_NUM] = {
diff --git a/src/sample.c b/src/sample.c
index e4bb318..3126be1 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -18,7 +18,6 @@
#include <import/mjson.h>
#include <import/sha1.h>
-#include <import/xxhash.h>
#include <haproxy/api.h>
#include <haproxy/arg.h>
@@ -43,6 +42,7 @@
#include <haproxy/tools.h>
#include <haproxy/uri_auth-t.h>
#include <haproxy/vars.h>
+#include <haproxy/xxhash.h>
/* sample type names */
const char *smp_to_type[SMP_TYPES] = {
diff --git a/src/server.c b/src/server.c
index f0228be..8f92a25 100644
--- a/src/server.c
+++ b/src/server.c
@@ -16,8 +16,6 @@
#include <ctype.h>
#include <errno.h>
-#include <import/xxhash.h>
-
#include <haproxy/api.h>
#include <haproxy/applet-t.h>
#include <haproxy/backend.h>
@@ -46,6 +44,7 @@
#include <haproxy/tcpcheck.h>
#include <haproxy/time.h>
#include <haproxy/tools.h>
+#include <haproxy/xxhash.h>
static void srv_update_status(struct server *s);
diff --git a/src/server_state.c b/src/server_state.c
index 18d9cd6..b9ae9ed 100644
--- a/src/server_state.c
+++ b/src/server_state.c
@@ -13,7 +13,6 @@
#include <errno.h>
#include <import/eb64tree.h>
-#include <import/xxhash.h>
#include <import/ebistree.h>
#include <haproxy/api.h>
@@ -29,6 +28,7 @@
#include <haproxy/server.h>
#include <haproxy/ssl_sock.h>
#include <haproxy/tools.h>
+#include <haproxy/xxhash.h>
/* 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 ae30c2c..a87d70b 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -43,7 +43,6 @@
#include <import/ebpttree.h>
#include <import/ebsttree.h>
#include <import/lru.h>
-#include <import/xxhash.h>
#include <haproxy/api.h>
#include <haproxy/arg.h>
@@ -79,6 +78,7 @@
#include <haproxy/tools.h>
#include <haproxy/vars.h>
#include <haproxy/xprt_quic.h>
+#include <haproxy/xxhash.h>
/* ***** READ THIS before adding code here! *****