File redict-backport-fixes.patch of Package redict

diff --git a/.forgejo/workflows/run-tests.yaml b/.forgejo/workflows/run-tests.yaml
new file mode 100644
index 000000000..71b870150
--- /dev/null
+++ b/.forgejo/workflows/run-tests.yaml
@@ -0,0 +1,29 @@
+on:
+  push:
+    branches:
+      - main
+jobs:
+  test:
+    runs-on:  podman
+    container:
+        image: alpine:3.20
+    steps:
+      - name: Install build dependencies
+        run: apk add --no-cache git linux-headers openssl-dev tcl procps tar make gcc musl-dev
+      - name: Checkout
+        run: git clone ${{github.server_url}}/${{ github.repository }}
+      - name: Build
+        run: make BUILD_TLS=yes
+        working-directory: redict
+      - name: Test redict
+        run: ./runtest
+        working-directory: redict
+      - name: Test redict-cluster
+        run: ./runtest-cluster
+        working-directory: redict
+      - name: Test redict-moduleapi
+        run: ./runtest-moduleapi
+        working-directory: redict
+      - name: Test redict-sentinel
+        run: ./runtest-sentinel
+        working-directory: redict
diff --git a/.reuse/dep5 b/.reuse/dep5
index c5f0b263d..2db2e9883 100644
--- a/.reuse/dep5
+++ b/.reuse/dep5
@@ -8,7 +8,7 @@ Files: .gitignore src/.gitignore tests/tmp/.gitignore .gitattributes
 Copyright: 2024 Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: .editorconfig
+Files: .editorconfig .forgejo/workflows/run-tests.yaml
 Copyright: 2024 Redict Contributors
 License: BSD-3-Clause
 
@@ -111,18 +111,18 @@ Files: deps/hiredict/.gitignore deps/hiredict/.travis.yml deps/hiredict/appveyor
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: deps/hiredict/hiredict.pc.in deps/hiredict/hiredict.targets deps/hiredict/hiredict_ssl.pc.in
+Files: deps/hiredict/util/hiredict.pc.in deps/hiredict/util/hiredict.targets deps/hiredict/util/hiredict_ssl.pc.in
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: deps/hiredict/shim/hiredis.pc.in deps/hiredict/shim/hiredis_ssl.pc.in
+Files: deps/hiredict/util/hiredis.pc.in deps/hiredict/util/hiredis_ssl.pc.in
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: deps/hiredict/hiredict-config.cmake.in deps/hiredict/hiredict_ssl-config.cmake.in
+Files: deps/hiredict/util/hiredict-config.cmake.in deps/hiredict/util/hiredict_ssl-config.cmake.in
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: deps/hiredict/hiredict.targets
+Files: deps/hiredict/util/hiredict.targets
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
diff --git a/README.md b/README.md
index 14caf183d..cf4944e6f 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,10 @@ toolchain, and GNU make. To build Redict, simply run "make".
 You can pass the following variables to Redict to customize the build:
 
 * `USE_JEMALLOC=no MALLOC=libc`: use the libc allocator rather than jemalloc
+* `USE_SYSTEM_JEMALLOC=yes`: use the system's installed jemalloc libraries
+   rather than the vendored copy.
+* `USE_SYSTEM_HIREDICT=yes`: use the system's installed hiredict libraries
+  rather than the vendored copy.
 * `BUILD_TLS=yes`: build with TLS support. Requires OpenSSL.
 * `USE_SYSTEMD=yes`: build with systemd support. Requires libsystemd.
 * `PROG_SUFFIX="-suffix"`: Append "-suffix" to executable names
diff --git a/deps/Makefile b/deps/Makefile
index 9a273aefc..e071cfa03 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -36,10 +36,14 @@ ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'),
 endif
 
 distclean:
+ifneq ($(USE_SYSTEM_HIREDICT),yes)
 	-(cd hiredict && $(MAKE) clean) > /dev/null || true
+endif
 	-(cd linenoise && $(MAKE) clean) > /dev/null || true
 	-(cd lua && $(MAKE) clean) > /dev/null || true
+ifneq ($(USE_SYSTEM_JEMALLOC),yes)
 	-(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true
+endif
 	-(cd hdr_histogram && $(MAKE) clean) > /dev/null || true
 	-(cd fpconv && $(MAKE) clean) > /dev/null || true
 	-(rm -f .make-*)
diff --git a/deps/hiredict/.gitignore b/deps/hiredict/.gitignore
index 1fe9080f9..327b0e946 100644
--- a/deps/hiredict/.gitignore
+++ b/deps/hiredict/.gitignore
@@ -1,6 +1,7 @@
 /hiredict-test
 /examples/hiredict-example*
-/*.o
+src/*.o
+src/*.d
 /*.so
 /*.dylib
 /*.a
diff --git a/deps/hiredict/.reuse/dep5 b/deps/hiredict/.reuse/dep5
index c68298a8f..b7b64df48 100644
--- a/deps/hiredict/.reuse/dep5
+++ b/deps/hiredict/.reuse/dep5
@@ -7,18 +7,18 @@ Files: .gitignore .travis.yml appveyor.yml
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: hiredict.pc.in hiredict.targets hiredict_ssl.pc.in
+Files: util/hiredict.pc.in util/hiredict.targets util/hiredict_ssl.pc.in
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: shim/hiredis.pc.in shim/hiredis_ssl.pc.in
+Files: util/hiredis.pc.in util/hiredis_ssl.pc.in
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: hiredict-config.cmake.in hiredict_ssl-config.cmake.in
+Files: util/hiredict-config.cmake.in util/hiredict_ssl-config.cmake.in
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
 
-Files: hiredict.targets
+Files: util/hiredict.targets
 Copyright: Salvatore Sanfilippo <antirez at gmail dot com>
 License: BSD-3-Clause
diff --git a/deps/hiredict/CMakeLists.txt b/deps/hiredict/CMakeLists.txt
index 872de4527..84eeb0338 100644
--- a/deps/hiredict/CMakeLists.txt
+++ b/deps/hiredict/CMakeLists.txt
@@ -8,7 +8,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
 
 MACRO(getVersionBit name)
   SET(VERSION_REGEX "^#define ${name} (.+)$")
-  FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/hiredict.h"
+  FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/hiredict/hiredict.h"
     VERSION_BIT REGEX ${VERSION_REGEX})
   STRING(REGEX REPLACE ${VERSION_REGEX} "\\1" ${name} "${VERSION_BIT}")
 ENDMACRO(getVersionBit)
@@ -38,13 +38,13 @@ SET(CMAKE_C_STANDARD 99)
 SET(CMAKE_DEBUG_POSTFIX d)
 
 SET(hiredict_sources
-    alloc.c
-    async.c
-    hiredict.c
-    net.c
-    read.c
-    sds.c
-    sockcompat.c)
+    src/alloc.c
+    src/async.c
+    src/hiredict.c
+    src/net.c
+    src/read.c
+    src/sds.c
+    src/sockcompat.c)
 
 SET(hiredict_sources ${hiredict_sources})
 
@@ -52,6 +52,7 @@ IF(WIN32)
     ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN)
 ENDIF()
 
+INCLUDE_DIRECTORIES(include)
 ADD_LIBRARY(hiredict ${hiredict_sources})
 ADD_LIBRARY(hiredict::hiredict ALIAS hiredict)
 set(hiredict_export_name hiredict CACHE STRING "Name of the exported target")
@@ -76,8 +77,8 @@ ENDIF()
 
 TARGET_INCLUDE_DIRECTORIES(hiredict PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
 
-CONFIGURE_FILE(hiredict.pc.in hiredict.pc @ONLY)
-CONFIGURE_FILE(shim/hiredis.pc.in hiredis.pc @ONLY)
+CONFIGURE_FILE(util/hiredict.pc.in hiredict.pc @ONLY)
+CONFIGURE_FILE(util/hiredis.pc.in hiredis.pc @ONLY)
 
 set(CPACK_PACKAGE_VENDOR "Redict")
 set(CPACK_PACKAGE_DESCRIPTION "\
@@ -118,18 +119,24 @@ endif()
 
 if (ENABLE_NUGET)
     # For NuGet packages
-    INSTALL(FILES hiredict.targets
+    INSTALL(FILES util/hiredict.targets
         DESTINATION build/native)
 endif()
 
-INSTALL(FILES hiredict.h read.h sds.h async.h alloc.h sockcompat.h
+INSTALL(FILES
+    include/hiredict/hiredict.h
+    include/hiredict/read.h
+    include/hiredict/sds.h
+    include/hiredict/async.h
+    include/hiredict/alloc.h
+    include/hiredict/sockcompat.h
     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredict)
 
 INSTALL(FILES shim/hiredis.h shim/read.h shim/sds.h
 	shim/async.h shim/alloc.h shim/sockcompat.h
     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
 
-INSTALL(DIRECTORY adapters
+INSTALL(DIRECTORY include/hiredict/adapters
     DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredict)
 
 INSTALL(DIRECTORY shim/adapters
@@ -154,7 +161,7 @@ SET(INCLUDE_INSTALL_DIR include)
 include(CMakePackageConfigHelpers)
 write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/hiredict-config-version.cmake"
                                  COMPATIBILITY SameMajorVersion)
-configure_package_config_file(hiredict-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/hiredict-config.cmake
+configure_package_config_file(util/hiredict-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/hiredict-config.cmake
                               INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR}
                               PATH_VARS INCLUDE_INSTALL_DIR)
 
@@ -176,7 +183,7 @@ IF(ENABLE_SSL)
     ENDIF()
     FIND_PACKAGE(OpenSSL REQUIRED)
     SET(hiredict_ssl_sources
-        ssl.c)
+        src/ssl.c)
     ADD_LIBRARY(hiredict_ssl ${hiredict_ssl_sources})
     ADD_LIBRARY(hiredict::hiredict_ssl ALIAS hiredict_ssl)
 
@@ -196,8 +203,8 @@ IF(ENABLE_SSL)
     IF(WIN32)
         TARGET_LINK_LIBRARIES(hiredict_ssl PRIVATE hiredict)
     ENDIF()
-    CONFIGURE_FILE(hiredict_ssl.pc.in hiredict_ssl.pc @ONLY)
-    CONFIGURE_FILE(shim/hiredis_ssl.pc.in hiredis_ssl.pc @ONLY)
+    CONFIGURE_FILE(util/hiredict_ssl.pc.in hiredict_ssl.pc @ONLY)
+    CONFIGURE_FILE(util/hiredis_ssl.pc.in hiredis_ssl.pc @ONLY)
 
     INSTALL(TARGETS hiredict_ssl
         EXPORT hiredict_ssl-targets
@@ -211,7 +218,7 @@ IF(ENABLE_SSL)
             CONFIGURATIONS Debug RelWithDebInfo)
     endif()
 
-    INSTALL(FILES hiredict_ssl.h
+    INSTALL(FILES include/hiredict/hiredict_ssl.h
         DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredict)
 
     INSTALL(FILES shim/hiredis_ssl.h
@@ -232,7 +239,7 @@ IF(ENABLE_SSL)
     else()
         SET(CMAKE_CONF_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/hiredict_ssl)
     endif()
-    configure_package_config_file(hiredict_ssl-config.cmake.in
+    configure_package_config_file(util/hiredict_ssl-config.cmake.in
                                   ${CMAKE_CURRENT_BINARY_DIR}/hiredict_ssl-config.cmake
                                   INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR}
                                   PATH_VARS INCLUDE_INSTALL_DIR)
@@ -248,7 +255,7 @@ ENDIF()
 
 IF(NOT DISABLE_TESTS)
     ENABLE_TESTING()
-    ADD_EXECUTABLE(hiredict-test test.c)
+    ADD_EXECUTABLE(hiredict-test src/test.c)
     TARGET_LINK_LIBRARIES(hiredict-test hiredict)
     IF(ENABLE_SSL_TESTS)
 		ADD_DEFINITIONS(-DHIREDICT_TEST_SSL=1)
@@ -259,7 +266,7 @@ IF(NOT DISABLE_TESTS)
         TARGET_LINK_LIBRARIES(hiredict-test event)
     ENDIF()
     ADD_TEST(NAME hiredict-test
-        COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh)
+        COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/util/test.sh)
 ENDIF()
 
 # Add examples
diff --git a/deps/hiredict/Makefile b/deps/hiredict/Makefile
index b62a840a3..c54ede3a4 100644
--- a/deps/hiredict/Makefile
+++ b/deps/hiredict/Makefile
@@ -9,20 +9,38 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # SPDX-License-Identifier: LGPL-3.0-or-later
 
-OBJ=alloc.o net.o hiredict.o sds.o async.o read.o sockcompat.o
+OBJ=src/alloc.o src/net.o src/hiredict.o src/sds.o src/async.o src/read.o src/sockcompat.o src/test.o
 EXAMPLES=hiredict-example hiredict-example-libevent hiredict-example-libev hiredict-example-glib hiredict-example-push hiredict-example-poll
 TESTS=hiredict-test
 LIBNAME=libhiredict
 PKGCONFNAME=hiredict.pc
-SHIM_PKGCONFNAME=shim/hiredis.pc
+SHIM_PKGCONFNAME=hiredis.pc
 
-HIREDICT_MAJOR=$(shell grep HIREDICT_MAJOR hiredict.h | awk '{print $$3}')
-HIREDICT_MINOR=$(shell grep HIREDICT_MINOR hiredict.h | awk '{print $$3}')
-HIREDICT_PATCH=$(shell grep HIREDICT_PATCH hiredict.h | awk '{print $$3}')
-HIREDICT_SONAME=$(shell grep HIREDICT_SONAME hiredict.h | awk '{print $$3}')
+HIREDICT_HEADER=include/hiredict/hiredict.h
+
+HIREDICT_MAJOR=$(shell grep HIREDICT_MAJOR $(HIREDICT_HEADER) | awk '{print $$3}')
+HIREDICT_MINOR=$(shell grep HIREDICT_MINOR $(HIREDICT_HEADER) | awk '{print $$3}')
+HIREDICT_PATCH=$(shell grep HIREDICT_PATCH $(HIREDICT_HEADER) | awk '{print $$3}')
+HIREDICT_SONAME=$(shell grep HIREDICT_SONAME $(HIREDICT_HEADER) | awk '{print $$3}')
 
 HIREDICT_VERSION=$(HIREDICT_MAJOR).$(HIREDICT_MINOR).$(HIREDICT_PATCH)
 
+INSTALL_HEADERS=$(HIREDICT_HEADER) \
+	include/hiredict/adapters \
+	include/hiredict/alloc.h \
+	include/hiredict/async.h \
+	include/hiredict/read.h \
+	include/hiredict/sds.h \
+	include/hiredict/sockcompat.h
+
+INSTALL_SHIM_HEADERS=shim/hiredis.h \
+	shim/adapters \
+	shim/alloc.h \
+	shim/async.h \
+	shim/read.h \
+	shim/sds.h \
+	shim/sockcompat.h
+
 # Installation related variables and target
 PREFIX?=/usr/local
 INCLUDE_PATH?=include/hiredict
@@ -56,6 +74,7 @@ ifeq ($(USE_WERROR),1)
   WARNINGS+=-Werror
 endif
 DEBUG_FLAGS?= -g -ggdb
+CFLAGS+=-Iinclude -MMD
 REAL_CFLAGS=$(OPTIMIZATION) -fPIC $(CPPFLAGS) $(CFLAGS) $(WARNINGS) $(DEBUG_FLAGS) $(PLATFORM_FLAGS)
 REAL_LDFLAGS=$(LDFLAGS)
 
@@ -70,10 +89,10 @@ STLIBNAME=$(LIBNAME).$(STLIBSUFFIX)
 STLIB_MAKE_CMD=$(AR) rcs
 
 #################### SSL variables start ####################
-SSL_OBJ=ssl.o
+SSL_OBJ=src/ssl.o
 SSL_LIBNAME=libhiredict_ssl
 SSL_PKGCONFNAME=hiredict_ssl.pc
-SSL_SHIM_PKGCONFNAME=shim/hiredis_ssl.pc
+SSL_SHIM_PKGCONFNAME=hiredis_ssl.pc
 SSL_INSTALLNAME=install-ssl
 SSL_DYLIB_MINOR_NAME=$(SSL_LIBNAME).$(DYLIBSUFFIX).$(HIREDICT_SONAME)
 SSL_DYLIB_MAJOR_NAME=$(SSL_LIBNAME).$(DYLIBSUFFIX).$(HIREDICT_MAJOR)
@@ -155,7 +174,10 @@ endif
 ifeq ($(uname_S),Darwin)
   DYLIBSUFFIX=dylib
   DYLIB_MINOR_NAME=$(LIBNAME).$(HIREDICT_SONAME).$(DYLIBSUFFIX)
+  DYLIB_MAJOR_NAME=$(LIBNAME).$(HIREDICT_MAJOR).$(DYLIBSUFFIX)
   DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(DYLIB_MINOR_NAME) -o $(DYLIBNAME) $(LDFLAGS)
+  SSL_DYLIB_MINOR_NAME=$(SSL_LIBNAME).$(HIREDICT_SONAME).$(DYLIBSUFFIX)
+  SSL_DYLIB_MAJOR_NAME=$(SSL_LIBNAME).$(HIREDICT_MAJOR).$(DYLIBSUFFIX)
   SSL_DYLIB_MAKE_CMD=$(CC) -dynamiclib -Wl,-install_name,$(PREFIX)/$(LIBRARY_PATH)/$(SSL_DYLIB_MINOR_NAME) -o $(SSL_DYLIBNAME) $(LDFLAGS) $(SSL_LDFLAGS)
   DYLIB_PLUGIN=-Wl,-undefined -Wl,dynamic_lookup
 endif
@@ -168,16 +190,8 @@ static: $(STLIBNAME) $(SSL_STLIB)
 
 pkgconfig: $(PKGCONFNAME) $(SHIM_PKGCONFNAME) $(SSL_PKGCONF) $(SSL_SHIM_PKGCONF)
 
-# Deps (use make dep to generate this)
-alloc.o: alloc.c fmacros.h alloc.h
-async.o: async.c fmacros.h alloc.h async.h hiredict.h read.h sds.h net.h dict.c dict.h win32.h async_private.h
-dict.o: dict.c fmacros.h alloc.h dict.h
-hiredict.o: hiredict.c fmacros.h hiredict.h read.h sds.h alloc.h net.h async.h win32.h
-net.o: net.c fmacros.h net.h hiredict.h read.h sds.h alloc.h sockcompat.h win32.h
-read.o: read.c fmacros.h alloc.h read.h sds.h win32.h
-sds.o: sds.c sds.h sdsalloc.h alloc.h
-sockcompat.o: sockcompat.c sockcompat.h
-test.o: test.c fmacros.h hiredict.h read.h sds.h alloc.h net.h sockcompat.h win32.h
+# include header dependencies generated by -MMD.
+-include $(OBJ:%.o=%.d)
 
 $(DYLIBNAME): $(OBJ)
 	$(DYLIB_MAKE_CMD) -o $(DYLIBNAME) $(OBJ) $(REAL_LDFLAGS)
@@ -191,8 +205,6 @@ $(SSL_DYLIBNAME): $(SSL_OBJ)
 
 $(SSL_STLIBNAME): $(SSL_OBJ)
 	$(STLIB_MAKE_CMD) $(SSL_STLIBNAME) $(SSL_OBJ)
-
-$(SSL_OBJ): ssl.c hiredict.h read.h sds.h alloc.h async.h win32.h async_private.h
 #################### SSL building rules end ####################
 
 # Binaries:
@@ -272,7 +284,7 @@ ifeq ($(TEST_ASYNC),1)
     TEST_LDFLAGS += -levent
 endif
 
-hiredict-test: test.o $(TEST_LIBS)
+hiredict-test: src/test.o $(TEST_LIBS)
 	$(CC) -o $@ $(REAL_CFLAGS) -I. $^ $(REAL_LDFLAGS) $(TEST_LDFLAGS)
 
 hiredict-%: %.o $(STLIBNAME)
@@ -282,22 +294,22 @@ test: hiredict-test
 	./hiredict-test
 
 check: hiredict-test
-	TEST_SSL=$(USE_SSL) ./test.sh
+	TEST_SSL=$(USE_SSL) ./util/test.sh
 
 .c.o:
-	$(CC) -std=c99 -c $(REAL_CFLAGS) $<
+	$(CC) -std=c99 -c $(REAL_CFLAGS) $< -o $@
 
 clean:
 	rm -rf $(DYLIBNAME) $(STLIBNAME) $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(TESTS) \
 		$(PKGCONFNAME) $(SHIM_PKGCONFNAME) $(SSL_PKGCONFNAME) $(SSL_SHIM_PKGCONFNAME) \
-		examples/hiredict-example* *.o *.gcda *.gcno *.gcov
+		examples/hiredict-example* src/*.o src/*.d *.gcda *.gcno *.gcov
 
 dep:
-	$(CC) $(CPPFLAGS) $(CFLAGS) -MM *.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) -MM src/*.c
 
 INSTALL?= cp -pPR
 
-%.pc: %.pc.in
+%.pc: util/%.pc.in
 	@echo "Generating $@ for pkgconfig..."
 	@sed -e 's#@PREFIX@#$(PREFIX)#' \
 		-e 's#@LIBDIR@#$(LIBRARY_PATH)#' \
@@ -305,11 +317,12 @@ INSTALL?= cp -pPR
 		"$<" > "$@"
 
 install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME) $(SHIM_PKGCONFNAME) $(SSL_INSTALL)
-	mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_INCLUDE_PATH)/adapters $(INSTALL_LIBRARY_PATH) $(SHIM_INSTALL_INCLUDE_PATH) $(SHIM_INSTALL_INCLUDE_PATH)/adapters
-	$(INSTALL) hiredict.h async.h read.h sds.h alloc.h sockcompat.h $(INSTALL_INCLUDE_PATH)
-	$(INSTALL) shim/hiredis.h shim/async.h shim/read.h shim/sds.h shim/alloc.h shim/sockcompat.h $(SHIM_INSTALL_INCLUDE_PATH)
-	$(INSTALL) adapters/*.h $(INSTALL_INCLUDE_PATH)/adapters
-	$(INSTALL) shim/adapters/*.h $(SHIM_INSTALL_INCLUDE_PATH)/adapters
+	mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_INCLUDE_PATH)/adapters $(INSTALL_LIBRARY_PATH) \
+		$(SHIM_INSTALL_INCLUDE_PATH) $(SHIM_INSTALL_INCLUDE_PATH)/adapters
+
+	$(INSTALL) $(INSTALL_HEADERS) $(INSTALL_INCLUDE_PATH)
+	$(INSTALL) $(INSTALL_SHIM_HEADERS) $(SHIM_INSTALL_INCLUDE_PATH)
+
 	$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(DYLIB_MINOR_NAME)
 	cd $(INSTALL_LIBRARY_PATH) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIBNAME) && ln -sf $(DYLIB_MINOR_NAME) $(DYLIB_MAJOR_NAME)
 	$(INSTALL) $(STLIBNAME) $(INSTALL_LIBRARY_PATH)
@@ -318,7 +331,7 @@ install: $(DYLIBNAME) $(STLIBNAME) $(PKGCONFNAME) $(SHIM_PKGCONFNAME) $(SSL_INST
 
 install-ssl: $(SSL_DYLIBNAME) $(SSL_STLIBNAME) $(SSL_PKGCONFNAME) $(SSL_SHIM_PKGCONFNAME)
 	mkdir -p $(INSTALL_INCLUDE_PATH) $(INSTALL_LIBRARY_PATH) $(SHIM_INSTALL_INCLUDE_PATH)
-	$(INSTALL) hiredict_ssl.h $(INSTALL_INCLUDE_PATH)
+	$(INSTALL) include/hiredict/hiredict_ssl.h $(INSTALL_INCLUDE_PATH)
 	$(INSTALL) shim/hiredis_ssl.h $(SHIM_INSTALL_INCLUDE_PATH)
 	$(INSTALL) $(SSL_DYLIBNAME) $(INSTALL_LIBRARY_PATH)/$(SSL_DYLIB_MINOR_NAME)
 	cd $(INSTALL_LIBRARY_PATH) && ln -sf $(SSL_DYLIB_MINOR_NAME) $(SSL_DYLIBNAME) && ln -sf $(SSL_DYLIB_MINOR_NAME) $(SSL_DYLIB_MAJOR_NAME)
diff --git a/deps/hiredict/appveyor.yml b/deps/hiredict/appveyor.yml
deleted file mode 100644
index 6791923c6..000000000
--- a/deps/hiredict/appveyor.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-# Appveyor configuration file for CI build of hiredict on Windows (under Cygwin)
-
-environment:
-    matrix:
-        - CYG_BASH: C:\cygwin64\bin\bash
-          CC: gcc
-        - CYG_BASH: C:\cygwin\bin\bash
-          CC: gcc
-          CFLAGS: -m32
-          CXXFLAGS: -m32
-          LDFLAGS: -m32
-
-clone_depth: 1
-
-# Attempt to ensure we don't try to convert line endings to Win32 CRLF as this will cause build to fail
-init:
-    - git config --global core.autocrlf input
-
-# Install needed build dependencies
-install:
-    - '%CYG_BASH% -lc "cygcheck -dc cygwin"'
-
-build_script:
-    - 'echo building...'
-    - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0</dev/null; mkdir build && cd build && cmake .. -G \"Unix Makefiles\" && make VERBOSE=1"'
diff --git a/deps/hiredict/examples/example-ae.c b/deps/hiredict/examples/example-ae.c
index 170d7b288..d2706f7e1 100644
--- a/deps/hiredict/examples/example-ae.c
+++ b/deps/hiredict/examples/example-ae.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/ae.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/ae.h>
 
 /* Put event loop in the global scope, so it can be explicitly stopped */
 static aeEventLoop *loop;
diff --git a/deps/hiredict/examples/example-glib.c b/deps/hiredict/examples/example-glib.c
index 97cf279b2..ec36eba1f 100644
--- a/deps/hiredict/examples/example-glib.c
+++ b/deps/hiredict/examples/example-glib.c
@@ -6,9 +6,9 @@
 
 #include <stdlib.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/glib.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/glib.h>
 
 static GMainLoop *mainloop;
 
diff --git a/deps/hiredict/examples/example-ivykis.c b/deps/hiredict/examples/example-ivykis.c
index 8aa257078..a2047db05 100644
--- a/deps/hiredict/examples/example-ivykis.c
+++ b/deps/hiredict/examples/example-ivykis.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/ivykis.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/ivykis.h>
 
 void getCallback(redictAsyncContext *c, void *r, void *privdata) {
     redictReply *reply = r;
diff --git a/deps/hiredict/examples/example-libev.c b/deps/hiredict/examples/example-libev.c
index b1806745a..511983749 100644
--- a/deps/hiredict/examples/example-libev.c
+++ b/deps/hiredict/examples/example-libev.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/libev.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/libev.h>
 
 void getCallback(redictAsyncContext *c, void *r, void *privdata) {
     redictReply *reply = r;
diff --git a/deps/hiredict/examples/example-libevent-ssl.c b/deps/hiredict/examples/example-libevent-ssl.c
index b15e7e2d9..336b439c7 100644
--- a/deps/hiredict/examples/example-libevent-ssl.c
+++ b/deps/hiredict/examples/example-libevent-ssl.c
@@ -9,10 +9,10 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <hiredict_ssl.h>
-#include <async.h>
-#include <adapters/libevent.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/hiredict_ssl.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/libevent.h>
 
 void getCallback(redictAsyncContext *c, void *r, void *privdata) {
     redictReply *reply = r;
diff --git a/deps/hiredict/examples/example-libevent.c b/deps/hiredict/examples/example-libevent.c
index efc21d6bc..c093230de 100644
--- a/deps/hiredict/examples/example-libevent.c
+++ b/deps/hiredict/examples/example-libevent.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/libevent.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/libevent.h>
 
 void getCallback(redictAsyncContext *c, void *r, void *privdata) {
     redictReply *reply = r;
diff --git a/deps/hiredict/examples/example-libhv.c b/deps/hiredict/examples/example-libhv.c
index ca053c0c3..bf7e20b92 100644
--- a/deps/hiredict/examples/example-libhv.c
+++ b/deps/hiredict/examples/example-libhv.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/libhv.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/libhv.h>
 
 void getCallback(redictAsyncContext *c, void *r, void *privdata) {
     redictReply *reply = r;
diff --git a/deps/hiredict/examples/example-libsdevent.c b/deps/hiredict/examples/example-libsdevent.c
index 6e544fc34..0bdb9f6e8 100644
--- a/deps/hiredict/examples/example-libsdevent.c
+++ b/deps/hiredict/examples/example-libsdevent.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/libsdevent.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/libsdevent.h>
 
 void debugCallback(redictAsyncContext *c, void *r, void *privdata) {
     (void)privdata;
diff --git a/deps/hiredict/examples/example-libuv.c b/deps/hiredict/examples/example-libuv.c
index c8992bc9f..81f3a4b9e 100644
--- a/deps/hiredict/examples/example-libuv.c
+++ b/deps/hiredict/examples/example-libuv.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/libuv.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/libuv.h>
 
 void debugCallback(redictAsyncContext *c, void *r, void *privdata) {
     (void)privdata; //unused
diff --git a/deps/hiredict/examples/example-macosx.c b/deps/hiredict/examples/example-macosx.c
index 265afe477..1d17c1fee 100644
--- a/deps/hiredict/examples/example-macosx.c
+++ b/deps/hiredict/examples/example-macosx.c
@@ -8,9 +8,9 @@
 
 #include <stdio.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/macosx.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/macosx.h>
 
 void getCallback(redictAsyncContext *c, void *r, void *privdata) {
     redictReply *reply = r;
diff --git a/deps/hiredict/examples/example-poll.c b/deps/hiredict/examples/example-poll.c
index 75d4fd54e..e9a35f559 100644
--- a/deps/hiredict/examples/example-poll.c
+++ b/deps/hiredict/examples/example-poll.c
@@ -10,8 +10,8 @@
 #include <signal.h>
 #include <unistd.h>
 
-#include <async.h>
-#include <adapters/poll.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/poll.h>
 
 /* Put in the global scope, so that loop can be explicitly stopped */
 static int exit_loop = 0;
diff --git a/deps/hiredict/examples/example-push.c b/deps/hiredict/examples/example-push.c
index 1d6d0b54e..e587fc2c8 100644
--- a/deps/hiredict/examples/example-push.c
+++ b/deps/hiredict/examples/example-push.c
@@ -9,7 +9,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <hiredict.h>
+#include <hiredict/hiredict.h>
 
 #define KEY_COUNT 5
 
diff --git a/deps/hiredict/examples/example-qt.h b/deps/hiredict/examples/example-qt.h
index f48df1712..a1646a192 100644
--- a/deps/hiredict/examples/example-qt.h
+++ b/deps/hiredict/examples/example-qt.h
@@ -7,7 +7,7 @@
 #ifndef __HIREDICT_EXAMPLE_QT_H
 #define __HIREDICT_EXAMPLE_QT_H
 
-#include <adapters/qt.h>
+#include <hiredict/adapters/qt.h>
 
 class ExampleQt : public QObject {
 
diff --git a/deps/hiredict/examples/example-redictmoduleapi.c b/deps/hiredict/examples/example-redictmoduleapi.c
index 84dea0dfd..5b7b5297f 100644
--- a/deps/hiredict/examples/example-redictmoduleapi.c
+++ b/deps/hiredict/examples/example-redictmoduleapi.c
@@ -9,9 +9,9 @@
 #include <string.h>
 #include <signal.h>
 
-#include <hiredict.h>
-#include <async.h>
-#include <adapters/redictmoduleapi.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/redictmoduleapi.h>
 
 void debugCallback(redictAsyncContext *c, void *r, void *privdata) {
     (void)privdata; //unused
diff --git a/deps/hiredict/examples/example-ssl.c b/deps/hiredict/examples/example-ssl.c
index c9b8818b6..8fd660eea 100644
--- a/deps/hiredict/examples/example-ssl.c
+++ b/deps/hiredict/examples/example-ssl.c
@@ -8,8 +8,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <hiredict.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/hiredict_ssl.h>
 
 #ifdef _MSC_VER
 #include <winsock2.h> /* For struct timeval */
diff --git a/deps/hiredict/examples/example.c b/deps/hiredict/examples/example.c
index 28e77e44b..5d3d01e48 100644
--- a/deps/hiredict/examples/example.c
+++ b/deps/hiredict/examples/example.c
@@ -7,7 +7,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <hiredict.h>
+#include <hiredict/hiredict.h>
 
 #ifdef _MSC_VER
 #include <winsock2.h> /* For struct timeval */
diff --git a/deps/hiredict/fuzzing/format_command_fuzzer.c b/deps/hiredict/fuzzing/format_command_fuzzer.c
index cbca8b0ef..0250414f7 100644
--- a/deps/hiredict/fuzzing/format_command_fuzzer.c
+++ b/deps/hiredict/fuzzing/format_command_fuzzer.c
@@ -17,7 +17,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include "hiredict.h"
+#include <hiredict/hiredict.h>
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
     char *new_str, *cmd;
diff --git a/deps/hiredict/async_private.h b/deps/hiredict/include/async_private.h
similarity index 100%
rename from deps/hiredict/async_private.h
rename to deps/hiredict/include/async_private.h
diff --git a/deps/hiredict/dict.h b/deps/hiredict/include/dict.h
similarity index 100%
rename from deps/hiredict/dict.h
rename to deps/hiredict/include/dict.h
diff --git a/deps/hiredict/fmacros.h b/deps/hiredict/include/fmacros.h
similarity index 100%
rename from deps/hiredict/fmacros.h
rename to deps/hiredict/include/fmacros.h
diff --git a/deps/hiredict/adapters/ae.h b/deps/hiredict/include/hiredict/adapters/ae.h
similarity index 98%
rename from deps/hiredict/adapters/ae.h
rename to deps/hiredict/include/hiredict/adapters/ae.h
index 1edcd0e9c..22a1cedd1 100644
--- a/deps/hiredict/adapters/ae.h
+++ b/deps/hiredict/include/hiredict/adapters/ae.h
@@ -13,8 +13,8 @@
 #define __HIREDICT_AE_H__
 #include <sys/types.h>
 #include <ae.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 typedef struct redictAeEvents {
     redictAsyncContext *context;
diff --git a/deps/hiredict/adapters/glib.h b/deps/hiredict/include/hiredict/adapters/glib.h
similarity index 98%
rename from deps/hiredict/adapters/glib.h
rename to deps/hiredict/include/hiredict/adapters/glib.h
index 84490c8a3..76568208d 100644
--- a/deps/hiredict/adapters/glib.h
+++ b/deps/hiredict/include/hiredict/adapters/glib.h
@@ -14,8 +14,8 @@
 
 #include <glib.h>
 
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 typedef struct
 {
diff --git a/deps/hiredict/adapters/ivykis.h b/deps/hiredict/include/hiredict/adapters/ivykis.h
similarity index 97%
rename from deps/hiredict/adapters/ivykis.h
rename to deps/hiredict/include/hiredict/adapters/ivykis.h
index a8468d87d..805c8aa6b 100644
--- a/deps/hiredict/adapters/ivykis.h
+++ b/deps/hiredict/include/hiredict/adapters/ivykis.h
@@ -12,8 +12,8 @@
 #ifndef __HIREDICT_IVYKIS_H__
 #define __HIREDICT_IVYKIS_H__
 #include <iv.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 typedef struct redictIvykisEvents {
     redictAsyncContext *context;
diff --git a/deps/hiredict/adapters/libev.h b/deps/hiredict/include/hiredict/adapters/libev.h
similarity index 98%
rename from deps/hiredict/adapters/libev.h
rename to deps/hiredict/include/hiredict/adapters/libev.h
index 9aa841e15..0734bc333 100644
--- a/deps/hiredict/adapters/libev.h
+++ b/deps/hiredict/include/hiredict/adapters/libev.h
@@ -16,8 +16,8 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <ev.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 typedef struct redictLibevEvents {
     redictAsyncContext *context;
diff --git a/deps/hiredict/adapters/libevent.h b/deps/hiredict/include/hiredict/adapters/libevent.h
similarity index 98%
rename from deps/hiredict/adapters/libevent.h
rename to deps/hiredict/include/hiredict/adapters/libevent.h
index 66ce6b631..c4e97b493 100644
--- a/deps/hiredict/adapters/libevent.h
+++ b/deps/hiredict/include/hiredict/adapters/libevent.h
@@ -12,8 +12,8 @@
 #ifndef __HIREDICT_LIBEVENT_H__
 #define __HIREDICT_LIBEVENT_H__
 #include <event2/event.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 #define REDICT_LIBEVENT_DELETED 0x01
 #define REDICT_LIBEVENT_ENTERED 0x02
diff --git a/deps/hiredict/adapters/libhv.h b/deps/hiredict/include/hiredict/adapters/libhv.h
similarity index 98%
rename from deps/hiredict/adapters/libhv.h
rename to deps/hiredict/include/hiredict/adapters/libhv.h
index 2d6fd772d..ddccacadc 100644
--- a/deps/hiredict/adapters/libhv.h
+++ b/deps/hiredict/include/hiredict/adapters/libhv.h
@@ -13,8 +13,8 @@
 #define __HIREDICT_LIBHV_H__
 
 #include <hv/hloop.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 typedef struct redictLibhvEvents {
     hio_t *io;
diff --git a/deps/hiredict/adapters/libsdevent.h b/deps/hiredict/include/hiredict/adapters/libsdevent.h
similarity index 98%
rename from deps/hiredict/adapters/libsdevent.h
rename to deps/hiredict/include/hiredict/adapters/libsdevent.h
index 103d69ee1..3086646df 100644
--- a/deps/hiredict/adapters/libsdevent.h
+++ b/deps/hiredict/include/hiredict/adapters/libsdevent.h
@@ -12,8 +12,8 @@
 #ifndef HIREDICT_LIBSDEVENT_H
 #define HIREDICT_LIBSDEVENT_H
 #include <systemd/sd-event.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 #define REDICT_LIBSDEVENT_DELETED 0x01
 #define REDICT_LIBSDEVENT_ENTERED 0x02
diff --git a/deps/hiredict/adapters/libuv.h b/deps/hiredict/include/hiredict/adapters/libuv.h
similarity index 98%
rename from deps/hiredict/adapters/libuv.h
rename to deps/hiredict/include/hiredict/adapters/libuv.h
index e91b8722b..b7da4f676 100644
--- a/deps/hiredict/adapters/libuv.h
+++ b/deps/hiredict/include/hiredict/adapters/libuv.h
@@ -13,8 +13,8 @@
 #define __HIREDICT_LIBUV_H__
 #include <stdlib.h>
 #include <uv.h>
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 #include <string.h>
 
 typedef struct redictLibuvEvents {
diff --git a/deps/hiredict/adapters/macosx.h b/deps/hiredict/include/hiredict/adapters/macosx.h
similarity index 98%
rename from deps/hiredict/adapters/macosx.h
rename to deps/hiredict/include/hiredict/adapters/macosx.h
index 670ca62e6..cb4b4e4ef 100644
--- a/deps/hiredict/adapters/macosx.h
+++ b/deps/hiredict/include/hiredict/adapters/macosx.h
@@ -14,8 +14,8 @@
 
 #include <CoreFoundation/CoreFoundation.h>
 
-#include "../hiredict.h"
-#include "../async.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 
 typedef struct {
     redictAsyncContext *context;
diff --git a/deps/hiredict/adapters/poll.h b/deps/hiredict/include/hiredict/adapters/poll.h
similarity index 98%
rename from deps/hiredict/adapters/poll.h
rename to deps/hiredict/include/hiredict/adapters/poll.h
index adc0aabe9..62a2b56f5 100644
--- a/deps/hiredict/adapters/poll.h
+++ b/deps/hiredict/include/hiredict/adapters/poll.h
@@ -12,8 +12,8 @@
 #ifndef HIREDICT_POLL_H
 #define HIREDICT_POLL_H
 
-#include "../async.h"
-#include "../sockcompat.h"
+#include <hiredict/async.h>
+#include <hiredict/sockcompat.h>
 #include <string.h> // for memset
 #include <errno.h>
 
diff --git a/deps/hiredict/adapters/qt.h b/deps/hiredict/include/hiredict/adapters/qt.h
similarity index 99%
rename from deps/hiredict/adapters/qt.h
rename to deps/hiredict/include/hiredict/adapters/qt.h
index de8d191bf..dce0d3b8f 100644
--- a/deps/hiredict/adapters/qt.h
+++ b/deps/hiredict/include/hiredict/adapters/qt.h
@@ -12,7 +12,7 @@
 #ifndef __HIREDICT_QT_H__
 #define __HIREDICT_QT_H__
 #include <QSocketNotifier>
-#include "../async.h"
+#include <hiredict/async.h>
 
 static void RedictQtAddRead(void *);
 static void RedictQtDelRead(void *);
diff --git a/deps/hiredict/adapters/redictmoduleapi.h b/deps/hiredict/include/hiredict/adapters/redictmoduleapi.h
similarity index 98%
rename from deps/hiredict/adapters/redictmoduleapi.h
rename to deps/hiredict/include/hiredict/adapters/redictmoduleapi.h
index 0238ba103..7d41208c6 100644
--- a/deps/hiredict/adapters/redictmoduleapi.h
+++ b/deps/hiredict/include/hiredict/adapters/redictmoduleapi.h
@@ -14,8 +14,8 @@
 
 #include "redictmodule.h"
 
-#include "../async.h"
-#include "../hiredict.h"
+#include <hiredict/async.h>
+#include <hiredict/hiredict.h>
 
 #include <sys/types.h>
 
diff --git a/deps/hiredict/alloc.h b/deps/hiredict/include/hiredict/alloc.h
similarity index 100%
rename from deps/hiredict/alloc.h
rename to deps/hiredict/include/hiredict/alloc.h
diff --git a/deps/hiredict/async.h b/deps/hiredict/include/hiredict/async.h
similarity index 99%
rename from deps/hiredict/async.h
rename to deps/hiredict/include/hiredict/async.h
index 527efa6e2..0e95f3c64 100644
--- a/deps/hiredict/async.h
+++ b/deps/hiredict/include/hiredict/async.h
@@ -13,7 +13,7 @@
 
 #ifndef __HIREDICT_ASYNC_H
 #define __HIREDICT_ASYNC_H
-#include "hiredict.h"
+#include <hiredict/hiredict.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/deps/hiredict/hiredict.h b/deps/hiredict/include/hiredict/hiredict.h
similarity index 98%
rename from deps/hiredict/hiredict.h
rename to deps/hiredict/include/hiredict/hiredict.h
index c186bb7be..6ef4ac335 100644
--- a/deps/hiredict/hiredict.h
+++ b/deps/hiredict/include/hiredict/hiredict.h
@@ -17,7 +17,7 @@
 
 #ifndef __HIREDICT_H
 #define __HIREDICT_H
-#include "read.h"
+#include <hiredict/read.h>
 #include <stdarg.h> /* for va_list */
 #ifndef _MSC_VER
 #include <sys/time.h> /* for struct timeval */
@@ -26,13 +26,13 @@ struct timeval; /* forward declaration */
 typedef long long ssize_t;
 #endif
 #include <stdint.h> /* uintXX_t, etc */
-#include "sds.h" /* for sds */
-#include "alloc.h" /* for allocation wrappers */
+#include <hiredict/sds.h> /* for sds */
+#include <hiredict/alloc.h> /* for allocation wrappers */
 
 #define HIREDICT_MAJOR 1
-#define HIREDICT_MINOR 2
-#define HIREDICT_PATCH 0
-#define HIREDICT_SONAME 1.2.1-dev
+#define HIREDICT_MINOR 3
+#define HIREDICT_PATCH 1
+#define HIREDICT_SONAME 1.3.1
 
 /* Connection type can be blocking or non-blocking and is set in the
  * least significant bit of the flags field in redictContext. */
diff --git a/deps/hiredict/hiredict_ssl.h b/deps/hiredict/include/hiredict/hiredict_ssl.h
similarity index 100%
rename from deps/hiredict/hiredict_ssl.h
rename to deps/hiredict/include/hiredict/hiredict_ssl.h
diff --git a/deps/hiredict/read.h b/deps/hiredict/include/hiredict/read.h
similarity index 100%
rename from deps/hiredict/read.h
rename to deps/hiredict/include/hiredict/read.h
diff --git a/deps/hiredict/sds.h b/deps/hiredict/include/hiredict/sds.h
similarity index 100%
rename from deps/hiredict/sds.h
rename to deps/hiredict/include/hiredict/sds.h
diff --git a/deps/hiredict/sockcompat.h b/deps/hiredict/include/hiredict/sockcompat.h
similarity index 100%
rename from deps/hiredict/sockcompat.h
rename to deps/hiredict/include/hiredict/sockcompat.h
diff --git a/deps/hiredict/net.h b/deps/hiredict/include/net.h
similarity index 98%
rename from deps/hiredict/net.h
rename to deps/hiredict/include/net.h
index be66e19dc..e2767b827 100644
--- a/deps/hiredict/net.h
+++ b/deps/hiredict/include/net.h
@@ -19,7 +19,7 @@
 #ifndef __NET_H
 #define __NET_H
 
-#include "hiredict.h"
+#include <hiredict/hiredict.h>
 
 void redictNetClose(redictContext *c);
 ssize_t redictNetRead(redictContext *c, char *buf, size_t bufcap);
diff --git a/deps/hiredict/sdsalloc.h b/deps/hiredict/include/sdsalloc.h
similarity index 96%
rename from deps/hiredict/sdsalloc.h
rename to deps/hiredict/include/sdsalloc.h
index 37e213049..f594a2c6e 100644
--- a/deps/hiredict/sdsalloc.h
+++ b/deps/hiredict/include/sdsalloc.h
@@ -21,7 +21,7 @@
  * the include of your alternate allocator if needed (not needed in order
  * to use the default libc allocator). */
 
-#include "alloc.h"
+#include <hiredict/alloc.h>
 
 #define s_malloc hi_malloc
 #define s_realloc hi_realloc
diff --git a/deps/hiredict/win32.h b/deps/hiredict/include/win32.h
similarity index 100%
rename from deps/hiredict/win32.h
rename to deps/hiredict/include/win32.h
diff --git a/deps/hiredict/alloc.c b/deps/hiredict/src/alloc.c
similarity index 98%
rename from deps/hiredict/alloc.c
rename to deps/hiredict/src/alloc.c
index 342192bf5..755a2070f 100644
--- a/deps/hiredict/alloc.c
+++ b/deps/hiredict/src/alloc.c
@@ -10,7 +10,7 @@
  */
 
 #include "fmacros.h"
-#include "alloc.h"
+#include <hiredict/alloc.h>
 #include <string.h>
 #include <stdlib.h>
 
diff --git a/deps/hiredict/async.c b/deps/hiredict/src/async.c
similarity index 99%
rename from deps/hiredict/async.c
rename to deps/hiredict/src/async.c
index 2363092c0..ffea870e0 100644
--- a/deps/hiredict/async.c
+++ b/deps/hiredict/src/async.c
@@ -10,9 +10,8 @@
  * SPDX-License-Identifier: LGPL-3.0-or-later
  *
  */
-
 #include "fmacros.h"
-#include "alloc.h"
+
 #include <stdlib.h>
 #include <string.h>
 #ifndef _MSC_VER
@@ -21,12 +20,13 @@
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
-#include "async.h"
+
+#include <hiredict/alloc.h>
+#include <hiredict/async.h>
+#include <hiredict/sds.h>
 #include "net.h"
 #include "dict.c"
-#include "sds.h"
 #include "win32.h"
-
 #include "async_private.h"
 
 #ifdef NDEBUG
diff --git a/deps/hiredict/dict.c b/deps/hiredict/src/dict.c
similarity index 99%
rename from deps/hiredict/dict.c
rename to deps/hiredict/src/dict.c
index 322b35e33..948534499 100644
--- a/deps/hiredict/dict.c
+++ b/deps/hiredict/src/dict.c
@@ -16,7 +16,7 @@
  */
 
 #include "fmacros.h"
-#include "alloc.h"
+#include <hiredict/alloc.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <limits.h>
diff --git a/deps/hiredict/hiredict.c b/deps/hiredict/src/hiredict.c
similarity index 99%
rename from deps/hiredict/hiredict.c
rename to deps/hiredict/src/hiredict.c
index 080e38d41..612052e52 100644
--- a/deps/hiredict/hiredict.c
+++ b/deps/hiredict/src/hiredict.c
@@ -14,18 +14,18 @@
  * SPDX-License-Identifier: LGPL-3.0-or-later
  *
  */
-
 #include "fmacros.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <errno.h>
 #include <ctype.h>
 
-#include "hiredict.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/sds.h>
+#include <hiredict/async.h>
 #include "net.h"
-#include "sds.h"
-#include "async.h"
 #include "win32.h"
 
 extern int redictContextUpdateConnectTimeout(redictContext *c, const struct timeval *timeout);
diff --git a/deps/hiredict/net.c b/deps/hiredict/src/net.c
similarity index 99%
rename from deps/hiredict/net.c
rename to deps/hiredict/src/net.c
index 96cfa0e51..09daab70c 100644
--- a/deps/hiredict/net.c
+++ b/deps/hiredict/src/net.c
@@ -15,8 +15,8 @@
  * SPDX-License-Identifier: LGPL-3.0-or-later
  *
  */
-
 #include "fmacros.h"
+
 #include <sys/types.h>
 #include <fcntl.h>
 #include <string.h>
@@ -26,10 +26,11 @@
 #include <limits.h>
 #include <stdlib.h>
 #include <time.h>
+#include <netdb.h>
 
+#include <hiredict/sds.h>
+#include <hiredict/sockcompat.h>
 #include "net.h"
-#include "sds.h"
-#include "sockcompat.h"
 #include "win32.h"
 
 /* Defined in hiredict.c */
diff --git a/deps/hiredict/read.c b/deps/hiredict/src/read.c
similarity index 99%
rename from deps/hiredict/read.c
rename to deps/hiredict/src/read.c
index 7b50ff2d0..f1530daf9 100644
--- a/deps/hiredict/read.c
+++ b/deps/hiredict/src/read.c
@@ -24,9 +24,9 @@
 #include <limits.h>
 #include <math.h>
 
-#include "alloc.h"
-#include "read.h"
-#include "sds.h"
+#include <hiredict/alloc.h>
+#include <hiredict/read.h>
+#include <hiredict/sds.h>
 #include "win32.h"
 
 /* Initial size of our nested reply stack and how much we grow it when needd */
diff --git a/deps/hiredict/sds.c b/deps/hiredict/src/sds.c
similarity index 99%
rename from deps/hiredict/sds.c
rename to deps/hiredict/src/sds.c
index 0dbd9fb46..26694fa36 100644
--- a/deps/hiredict/sds.c
+++ b/deps/hiredict/src/sds.c
@@ -13,15 +13,16 @@
  * SPDX-License-Identifier: LGPL-3.0-or-later
  *
  */
-
 #include "fmacros.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <assert.h>
 #include <limits.h>
-#include "sds.h"
+
+#include <hiredict/sds.h>
 #include "sdsalloc.h"
 
 static inline int sdsHdrSize(char type) {
diff --git a/deps/hiredict/sockcompat.c b/deps/hiredict/src/sockcompat.c
similarity index 99%
rename from deps/hiredict/sockcompat.c
rename to deps/hiredict/src/sockcompat.c
index 6c82cceea..af75aacf5 100644
--- a/deps/hiredict/sockcompat.c
+++ b/deps/hiredict/src/sockcompat.c
@@ -10,7 +10,7 @@
  */
 
 #define REDICT_SOCKCOMPAT_IMPLEMENTATION
-#include "sockcompat.h"
+#include <hiredict/sockcompat.h>
 
 #ifdef _WIN32
 static int _wsaErrorToErrno(int err) {
diff --git a/deps/hiredict/ssl.c b/deps/hiredict/src/ssl.c
similarity index 99%
rename from deps/hiredict/ssl.c
rename to deps/hiredict/src/ssl.c
index 19c49a2bd..ad4964fcd 100644
--- a/deps/hiredict/ssl.c
+++ b/deps/hiredict/src/ssl.c
@@ -13,10 +13,6 @@
  *
  */
 
-#include "hiredict.h"
-#include "async.h"
-#include "net.h"
-
 #include <assert.h>
 #include <errno.h>
 #include <string.h>
@@ -38,9 +34,13 @@
 #include <openssl/ssl.h>
 #include <openssl/err.h>
 
-#include "win32.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/hiredict_ssl.h>
+#include <hiredict/async.h>
+#include "net.h"
 #include "async_private.h"
-#include "hiredict_ssl.h"
+#include "win32.h"
+
 
 #define OPENSSL_1_1_0 0x10100000L
 
diff --git a/deps/hiredict/test.c b/deps/hiredict/src/test.c
similarity index 99%
rename from deps/hiredict/test.c
rename to deps/hiredict/src/test.c
index 48d53e91c..b9aeb004b 100644
--- a/deps/hiredict/test.c
+++ b/deps/hiredict/src/test.c
@@ -8,9 +8,8 @@
  * SPDX-License-Identifier: LGPL-3.0-or-later
  *
  */
-
 #include "fmacros.h"
-#include "sockcompat.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -24,14 +23,15 @@
 #include <limits.h>
 #include <math.h>
 
-#include "hiredict.h"
-#include "async.h"
-#include "adapters/poll.h"
+#include <hiredict/sockcompat.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
+#include <hiredict/adapters/poll.h>
 #ifdef HIREDICT_TEST_SSL
-#include "hiredict_ssl.h"
+#include <hiredict/hiredict_ssl.h>
 #endif
 #ifdef HIREDICT_TEST_ASYNC
-#include "adapters/libevent.h"
+#include <hiredict/adapters/libevent.h>
 #include <event2/event.h>
 #endif
 #include "net.h"
diff --git a/deps/hiredict/hiredict-config.cmake.in b/deps/hiredict/util/hiredict-config.cmake.in
similarity index 100%
rename from deps/hiredict/hiredict-config.cmake.in
rename to deps/hiredict/util/hiredict-config.cmake.in
diff --git a/deps/hiredict/hiredict.pc.in b/deps/hiredict/util/hiredict.pc.in
similarity index 71%
rename from deps/hiredict/hiredict.pc.in
rename to deps/hiredict/util/hiredict.pc.in
index e24d643b1..50bb3d1a8 100644
--- a/deps/hiredict/hiredict.pc.in
+++ b/deps/hiredict/util/hiredict.pc.in
@@ -3,10 +3,9 @@ install_libdir=@LIBDIR@
 exec_prefix=${prefix}
 libdir=${exec_prefix}/${install_libdir}
 includedir=${prefix}/include
-pkgincludedir=${includedir}/hiredict
 
 Name: hiredict
 Description: Minimalistic C client library for Redict.
 Version: @PROJECT_VERSION@
 Libs: -L${libdir} -lhiredict
-Cflags: -I${pkgincludedir} -I${includedir} -D_FILE_OFFSET_BITS=64
+Cflags: -I${includedir} -D_FILE_OFFSET_BITS=64
diff --git a/deps/hiredict/hiredict.targets b/deps/hiredict/util/hiredict.targets
similarity index 100%
rename from deps/hiredict/hiredict.targets
rename to deps/hiredict/util/hiredict.targets
diff --git a/deps/hiredict/hiredict_ssl-config.cmake.in b/deps/hiredict/util/hiredict_ssl-config.cmake.in
similarity index 100%
rename from deps/hiredict/hiredict_ssl-config.cmake.in
rename to deps/hiredict/util/hiredict_ssl-config.cmake.in
diff --git a/deps/hiredict/hiredict_ssl.pc.in b/deps/hiredict/util/hiredict_ssl.pc.in
similarity index 88%
rename from deps/hiredict/hiredict_ssl.pc.in
rename to deps/hiredict/util/hiredict_ssl.pc.in
index 111e2f6a4..99af3686c 100644
--- a/deps/hiredict/hiredict_ssl.pc.in
+++ b/deps/hiredict/util/hiredict_ssl.pc.in
@@ -3,7 +3,6 @@ install_libdir=@LIBDIR@
 exec_prefix=${prefix}
 libdir=${exec_prefix}/${install_libdir}
 includedir=${prefix}/include
-pkgincludedir=${includedir}/hiredict
 
 Name: hiredict_ssl
 Description: SSL Support for hiredict.
diff --git a/deps/hiredict/shim/hiredis.pc.in b/deps/hiredict/util/hiredis.pc.in
similarity index 100%
rename from deps/hiredict/shim/hiredis.pc.in
rename to deps/hiredict/util/hiredis.pc.in
diff --git a/deps/hiredict/shim/hiredis_ssl.pc.in b/deps/hiredict/util/hiredis_ssl.pc.in
similarity index 100%
rename from deps/hiredict/shim/hiredis_ssl.pc.in
rename to deps/hiredict/util/hiredis_ssl.pc.in
diff --git a/deps/hiredict/util/lint.sh b/deps/hiredict/util/lint.sh
new file mode 100755
index 000000000..7882de4a9
--- /dev/null
+++ b/deps/hiredict/util/lint.sh
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+# SPDX-FileCopyrightText: 2024 Hiredict Contributors
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+signoff() {
+    if ! git log --format='%b' HEAD^.. | grep 'Signed-off-by' >/dev/null
+    then
+        echo "Missing sign-off!" >&2
+        echo "Run 'git commit --amend -s' to fix" >&2
+        echo "See CONTRIBUTING.md" >&2
+        return 1
+    fi
+}
+
+licenses() {
+    if ! chronic sh -c "reuse lint 2>/dev/null"
+    then
+        return 1
+    fi
+}
+
+exitcode=0
+for step in signoff licenses
+do
+    if ! $step
+    then
+        exitcode=1
+    fi
+done
+
+if [ $exitcode -eq 0 ]
+then
+    echo "Everything looks good!"
+fi
+exit $exitcode
diff --git a/deps/hiredict/test.sh b/deps/hiredict/util/test.sh
similarity index 100%
rename from deps/hiredict/test.sh
rename to deps/hiredict/util/test.sh
diff --git a/redict.conf b/redict.conf
index 905681a21..466fd0815 100644
--- a/redict.conf
+++ b/redict.conf
@@ -338,8 +338,12 @@ daemonize no
 # nothing bad happens, the server will start and run normally.
 #
 # Note that on modern Linux systems "/run/redict.pid" is more conforming
-# and should be used instead.
-pidfile /var/run/redict_6379.pid
+# than "/var/run/redict.pid" and should be used instead. If you are running
+# as a non-root user, you'll need to make sure that the the user running
+# redict is able to create files there. This is the case for the redict
+# containers. A simple workaround in that case is to create the pidfile in the
+# /data or /tmp directory.
+pidfile /run/redict_6379.pid
 
 # Specify the server verbosity level.
 # This can be one of:
diff --git a/src/Makefile b/src/Makefile
index 0739466b6..b68de15e5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -24,7 +24,7 @@ endif
 ifneq ($(OPTIMIZATION),-O0)
 	OPTIMIZATION+=-fno-omit-frame-pointer
 endif
-DEPENDENCY_TARGETS=hiredict linenoise lua hdr_histogram fpconv
+DEPENDENCY_TARGETS=linenoise lua hdr_histogram fpconv
 NODEPS:=clean distclean
 
 # Default settings
@@ -226,7 +226,7 @@ ifdef OPENSSL_PREFIX
 endif
 
 # Include paths to dependencies
-FINAL_CFLAGS+= -I../deps/hiredict -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv
+FINAL_CFLAGS+= -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -I../deps/fpconv
 
 # Determine systemd support and/or build preference (defaulting to auto-detection)
 BUILD_WITH_SYSTEMD=no
@@ -266,10 +266,25 @@ ifeq ($(MALLOC),tcmalloc_minimal)
 endif
 
 ifeq ($(MALLOC),jemalloc)
+	FINAL_CFLAGS+= -DUSE_JEMALLOC
+ifeq ($(USE_SYSTEM_JEMALLOC),yes)
+	FINAL_CFLAGS+= -DUSE_SYSTEM_JEMALLOC $(shell $(PKG_CONFIG) --cflags jemalloc)
+	FINAL_LIBS := $(shell $(PKG_CONFIG) --libs jemalloc) $(FINAL_LIBS)
+else
 	DEPENDENCY_TARGETS+= jemalloc
-	FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
+	FINAL_CFLAGS+= -I../deps/jemalloc/include
 	FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
 endif
+endif
+
+ifeq ($(USE_SYSTEM_HIREDICT),yes)
+    FINAL_LIBS+= $(shell $(PKG_CONFIG) --libs hiredict)
+    FINAL_CFLAGS+= $(shell $(PKG_CONFIG) --cflags hiredict)
+else
+    DEPENDENCY_TARGETS += hiredict
+    FINAL_LIBS+= ../deps/hiredict/libhiredict.a
+    FINAL_CFLAGS+= -I../deps/hiredict/include
+endif
 
 # LIBSSL & LIBCRYPTO
 LIBSSL_LIBS=
@@ -293,15 +308,23 @@ BUILD_MODULE:=2
 ifeq ($(BUILD_TLS),yes)
 	FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_YES) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_NO)
 	FINAL_LDFLAGS+=$(OPENSSL_LDFLAGS)
+ifeq ($(USE_SYSTEM_HIREDICT),yes)
+	FINAL_LIBS += $(shell $(PKG_CONFIG) --libs hiredict_ssl) $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
+else
 	FINAL_LIBS += ../deps/hiredict/libhiredict_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
 endif
+endif
 
 TLS_MODULE=
 TLS_MODULE_NAME:=redict-tls$(PROG_SUFFIX).so
 TLS_MODULE_CFLAGS:=$(FINAL_CFLAGS)
 ifeq ($(BUILD_TLS),module)
 	FINAL_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS)
+ifeq ($(USE_SYSTEM_HIREDICT),yes)
+	TLS_CLIENT_LIBS = $(shell $(PKG_CONFIG) --libs hiredict_ssl) $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
+else
 	TLS_CLIENT_LIBS = ../deps/hiredict/libhiredict_ssl.a $(LIBSSL_LIBS) $(LIBCRYPTO_LIBS)
+endif
 	TLS_MODULE=$(TLS_MODULE_NAME)
 	TLS_MODULE_CFLAGS+=-DUSE_OPENSSL=$(BUILD_MODULE) $(OPENSSL_CFLAGS) -DBUILD_TLS_MODULE=$(BUILD_MODULE)
 endif
@@ -400,7 +423,7 @@ endif
 
 # redict-server
 $(REDICT_SERVER_NAME): $(REDICT_SERVER_OBJ)
-	$(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS)
+	$(REDICT_LD) -o $@ $^ ../deps/lua/src/liblua.a ../deps/hdr_histogram/libhdrhistogram.a ../deps/fpconv/libfpconv.a $(FINAL_LIBS)
 
 # redict-sentinel
 $(REDICT_SENTINEL_NAME): $(REDICT_SERVER_NAME)
@@ -420,11 +443,11 @@ $(TLS_MODULE_NAME): $(REDICT_SERVER_NAME)
 
 # redict-cli
 $(REDICT_CLI_NAME): $(REDICT_CLI_OBJ)
-	$(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
+	$(REDICT_LD) -o $@ $^ ../deps/linenoise/linenoise.o $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
 
 # redict-benchmark
 $(REDICT_BENCHMARK_NAME): $(REDICT_BENCHMARK_OBJ)
-	$(REDICT_LD) -o $@ $^ ../deps/hiredict/libhiredict.a ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
+	$(REDICT_LD) -o $@ $^ ../deps/hdr_histogram/libhdrhistogram.a $(FINAL_LIBS) $(TLS_CLIENT_LIBS)
 
 DEP = $(REDICT_SERVER_OBJ:%.o=%.d) $(REDICT_CLI_OBJ:%.o=%.d) $(REDICT_BENCHMARK_OBJ:%.o=%.d)
 -include $(DEP)
diff --git a/src/cli_common.c b/src/cli_common.c
index c8cf6030b..81ed4ea3e 100644
--- a/src/cli_common.c
+++ b/src/cli_common.c
@@ -13,15 +13,15 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <hiredict.h>
-#include <sds.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/sds.h>
 #include <unistd.h>
 #include <string.h>
 #include <ctype.h>
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
 
 #define UNUSED(V) ((void) V)
diff --git a/src/cli_common.h b/src/cli_common.h
index 4a45f50c0..66ce4983c 100644
--- a/src/cli_common.h
+++ b/src/cli_common.h
@@ -7,8 +7,8 @@
 #ifndef __CLICOMMON_H
 #define __CLICOMMON_H
 
-#include <hiredict.h>
-#include <sds.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/sds.h>
 
 typedef struct cliSSLconfig {
     /* Requested SNI, or NULL */
diff --git a/src/config.c b/src/config.c
index 5fd5930c5..fc47b7d12 100644
--- a/src/config.c
+++ b/src/config.c
@@ -10,6 +10,7 @@
 #include "connection.h"
 #include "bio.h"
 
+#include <stdbool.h>
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <glob.h>
diff --git a/src/debug.c b/src/debug.c
index 89d33bfd7..2257d655e 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -56,6 +56,9 @@ void bugReportEnd(int killViaSignal, int sig);
 void logStackTrace(void *eip, int uplevel, int current_thread);
 void sigalrmSignalHandler(int sig, siginfo_t *info, void *secret);
 
+#if defined(USE_JEMALLOC) && defined(USE_SYSTEM_JEMALLOC)
+#define je_mallctl mallctl
+#endif
 /* ================================= Debugging ============================== */
 
 /* Compute the sha1 of string at 's' with 'len' bytes long.
diff --git a/src/object.c b/src/object.c
index cf7811e81..5da8fbcc9 100644
--- a/src/object.c
+++ b/src/object.c
@@ -15,6 +15,11 @@
 #define strtold(a,b) ((long double)strtod((a),(b)))
 #endif
 
+#if defined(USE_JEMALLOC) && defined(USE_SYSTEM_JEMALLOC)
+#define je_mallctl mallctl
+#define je_malloc_stats_print malloc_stats_print
+#endif
+
 /* ===================== Creation and parsing of objects ==================== */
 
 robj *createObject(int type, void *ptr) {
diff --git a/src/redict-benchmark.c b/src/redict-benchmark.c
index 9b4bafeca..16ee5b45b 100644
--- a/src/redict-benchmark.c
+++ b/src/redict-benchmark.c
@@ -19,13 +19,13 @@
 #include <math.h>
 #include <pthread.h>
 
-#include <sds.h>
 #include "ae.h"
-#include <hiredict.h>
+#include <hiredict/hiredict.h>
+#include <hiredict/sds.h>
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
 #include "adlist.h"
 #include "dict.h"
diff --git a/src/redict-check-aof.c b/src/redict-check-aof.c
index 0266cc70e..377168cdc 100644
--- a/src/redict-check-aof.c
+++ b/src/redict-check-aof.c
@@ -534,6 +534,12 @@ int redict_check_aof_main(int argc, char **argv) {
         goto invalid_args;
     }
 
+    /* Check if filepath is longer than PATH_MAX */
+    if (strlen(filepath) > PATH_MAX) {
+        printf("Error: filepath is too long (exceeds PATH_MAX)\n");
+        goto invalid_args;
+    }
+
     /* In the glibc implementation dirname may modify their argument. */
     memcpy(temp_filepath, filepath, strlen(filepath) + 1);
     dirpath = dirname(temp_filepath);
diff --git a/src/redict-cli.c b/src/redict-cli.c
index ee82e820b..6c01a4c04 100644
--- a/src/redict-cli.c
+++ b/src/redict-cli.c
@@ -23,13 +23,13 @@
 #include <math.h>
 #include <termios.h>
 
-#include <hiredict.h>
+#include <hiredict/hiredict.h>
 #ifdef USE_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#include <hiredict_ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
-#include <sds.h>
+#include <hiredict/sds.h>
 #include "dict.h"
 #include "adlist.h"
 #include "zmalloc.h"
diff --git a/src/sds.c b/src/sds.c
index 0a295132c..a1ac73d5a 100644
--- a/src/sds.c
+++ b/src/sds.c
@@ -24,6 +24,10 @@
 #include "sds.h"
 #include "sdsalloc.h"
 
+#if defined(USE_JEMALLOC) && defined(USE_SYSTEM_JEMALLOC)
+#define je_nallocx nallocx
+#endif
+
 const char *SDS_NOINIT = "SDS_NOINIT";
 
 static inline int sdsHdrSize(char type) {
diff --git a/src/sentinel.c b/src/sentinel.c
index 995fe0c3e..6f2888626 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -6,12 +6,12 @@
 // SPDX-License-Identifier: LGPL-3.0-only
 
 #include "server.h"
-#include "hiredict.h"
+#include <hiredict/hiredict.h>
+#include <hiredict/async.h>
 #if USE_OPENSSL == 1 /* BUILD_YES */
-#include "openssl/ssl.h"
-#include "hiredict_ssl.h"
+#include <openssl/ssl.h>
+#include <hiredict/hiredict_ssl.h>
 #endif
-#include "async.h"
 
 #include <ctype.h>
 #include <arpa/inet.h>
diff --git a/src/version.h b/src/version.h
index 84efa7d93..56b8494de 100644
--- a/src/version.h
+++ b/src/version.h
@@ -4,5 +4,5 @@
 // SPDX-License-Identifier: BSD-3-Clause
 // SPDX-License-Identifier: LGPL-3.0-only
 
-#define REDICT_VERSION "7.3.6"
-#define REDICT_VERSION_NUM 0x00070306
+#define REDICT_VERSION "255.255.255"
+#define REDICT_VERSION_NUM 0x00ffffff
diff --git a/src/zmalloc.c b/src/zmalloc.c
index d737e2b14..7187599aa 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -56,6 +56,9 @@ void zlibc_free(void *ptr) {
 #define free(ptr) tc_free(ptr)
 /* Explicitly override malloc/free etc when using jemalloc. */
 #elif defined(USE_JEMALLOC)
+#if defined(USE_SYSTEM_JEMALLOC)
+#define je_mallctl mallctl
+#else
 #define malloc(size) je_malloc(size)
 #define calloc(count,size) je_calloc(count,size)
 #define realloc(ptr,size) je_realloc(ptr,size)
@@ -63,6 +66,7 @@ void zlibc_free(void *ptr) {
 #define mallocx(size,flags) je_mallocx(size,flags)
 #define dallocx(ptr,flags) je_dallocx(ptr,flags)
 #endif
+#endif
 
 #define update_zmalloc_stat_alloc(__n) atomicIncr(used_memory,(__n))
 #define update_zmalloc_stat_free(__n) atomicDecr(used_memory,(__n))
diff --git a/src/zmalloc.h b/src/zmalloc.h
index df7d290da..c10858439 100644
--- a/src/zmalloc.h
+++ b/src/zmalloc.h
@@ -27,7 +27,11 @@
 #include <jemalloc/jemalloc.h>
 #if (JEMALLOC_VERSION_MAJOR == 2 && JEMALLOC_VERSION_MINOR >= 1) || (JEMALLOC_VERSION_MAJOR > 2)
 #define HAVE_MALLOC_SIZE 1
+#if defined(USE_SYSTEM_JEMALLOC)
+#define zmalloc_size(p) malloc_usable_size(p)
+#else
 #define zmalloc_size(p) je_malloc_usable_size(p)
+#endif
 #else
 #error "Newer version of jemalloc required"
 #endif
openSUSE Build Service is sponsored by