Commit cd1eb0c4 authored by Noah Hilverling's avatar Noah Hilverling

Initial commit

parents
Pipeline #7300 failed with stages
in 31 minutes and 27 seconds
stages:
- build
- test
- upload
variables:
DOCKER_IMAGE_BASE: registry.icinga.com/build-docker
.build: &build
stage: build
tags:
- docker
image: ${DOCKER_IMAGE_BASE}/${DOCKER_IMAGE}
script:
- icinga-build-package
cache:
key: "${CI_JOB_NAME}"
paths:
- ccache/
artifacts:
paths:
- build/*
expire_in: 1 week
.test: &test
stage: test
tags:
- docker
image: ${DOCKER_IMAGE_BASE}/${DOCKER_IMAGE}
script:
- find build/
- icinga-build-test
.upload: &upload
stage: upload
tags:
- docker
image: ${DOCKER_IMAGE_BASE}/upload
script:
- find build/
- icinga-build-upload-aptly
only:
- tags
###################################
# Debian
###################################
build/debian/buster:
<<: *build
variables:
DOCKER_IMAGE: debian/buster
test/debian/buster:
<<: *test
variables:
DOCKER_IMAGE: debian/buster
dependencies:
- build/debian/buster
upload/debian/buster:
<<: *upload
dependencies:
- build/debian/buster
###################################
# Ubuntu
###################################
build/ubuntu/bionic:
<<: *build
variables:
DOCKER_IMAGE: ubuntu/bionic
test/ubuntu/bionic:
<<: *test
variables:
DOCKER_IMAGE: ubuntu/bionic
dependencies:
- build/ubuntu/bionic
upload/ubuntu/bionic:
<<: *upload
dependencies:
- build/ubuntu/bionic
*.c
*.service
redis (4:4.0.2-3) unstable; urgency=medium
This version drops the Debian-specific support for the
/etc/redis/redis-{server,sentinel}.{pre,post}-{up,down}.d directories in
favour of using systemd's ExecStartPre, ExecStartPost, ExecStopPre,
ExecStopPost commands.
-- Chris Lamb <lamby@debian.org> Wed, 11 Oct 2017 22:55:00 -0400
# -*- sh -*-
#
# Bash completion function for the 'redis-cli' command.
#
# Steve
# --
# http://www.steve.org.uk
#
_redis-cli()
{
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
#
# All known commands accepted. Sorted.
#
opts='bgrewriteaof bgsave dbsize debug decr decrby del echo exists expire expireat flushall flushdb get getset incr incrby info keys lastsave lindex llen lpop lpush lrange lrem lset ltrim mget move mset msetnx ping randomkey rename renamenx rewriteaof rpop rpoplpush rpush sadd save scard sdiff sdiffstore select set setnx shutdown sinter sinterstore sismember slaveof smembers smove sort spop srandmember srem sunion sunionstore ttl type zadd zcard zincrby zrange zrangebyscore zrem zremrangebyscore zrevrange zscore'
#
# Only complete on the first term.
#
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _redis-cli redis-cli
#!/bin/sh
for BINARY in redis-server redis-sentinel
do
for MODE in default templated
do
case "${BINARY}" in
redis-server)
NAME="redis"
;;
redis-sentinel)
NAME="sentinel"
;;
esac
case "${MODE}" in
default)
EXTRA="Alias=${NAME}.service"
TARGET="debian/${BINARY}.service"
NAMESPACED="${NAME}"
DESCRIPTION="Advanced key-value store"
;;
templated)
EXTRA=""
TARGET="debian/${BINARY}@.service"
NAMESPACED="${NAME}-%i"
DESCRIPTION="Advanced key-value store (%I)"
;;
esac
: >${TARGET}
if [ "${MODE}" = "templated" ]
then
cat >> ${TARGET} <<EOF
# Templated service file for ${BINARY}(1)
#
# Each instance of ${BINARY} requires its own configuration file:
#
# $ cp /etc/redis/${NAME}.conf /etc/redis/${NAME}-myname.conf
# $ chown redis:redis /etc/redis/${NAME}-myname.conf
#
# Ensure each instance is using their own database:
#
# $ sed -i -e 's@^dbfilename .*@dbfilename dump-myname.rdb@' /etc/redis/${NAME}-myname.conf
#
# We then listen exlusively on UNIX sockets to avoid TCP port collisions:
#
# $ sed -i -e 's@^port .*@port 0@' /etc/redis/${NAME}-myname.conf
# $ sed -i -e 's@^\\(# \\)\\{0,1\\}unixsocket .*@unixsocket /var/run/${NAME}-myname/${BINARY}.sock@' /etc/redis/${NAME}-myname.conf
#
# ... and ensure we are logging, etc. in a unique location:
#
# $ sed -i -e 's@^logfile .*@logfile /var/log/redis/${BINARY}-myname.log@' /etc/redis/${NAME}-myname.conf
# $ sed -i -e 's@^pidfile .*@pidfile /run/redis-myname/${BINARY}.pid@' /etc/redis/${NAME}-myname.conf
#
# We can then start the service as follows, validating we are using our own
# configuration:
#
# $ systemctl start ${BINARY}@myname.service
# $ redis-cli -s /var/run/${NAME}-myname/${BINARY}.sock info | grep config_file
#
# -- Chris Lamb <lamby@debian.org> Mon, 09 Oct 2017 22:17:24 +0100
EOF
fi
cat >> ${TARGET} <<EOF
[Unit]
Description=${DESCRIPTION}
After=network.target
Documentation=http://redis.io/documentation, man:${BINARY}(1)
[Service]
Type=forking
ExecStart=/usr/bin/${BINARY} /etc/redis/${NAMESPACED}.conf
ExecStop=/bin/kill -s TERM \$MAINPID
PIDFile=/run/${NAMESPACED}/${BINARY}.pid
TimeoutStopSec=0
Restart=always
User=redis
Group=redis
RuntimeDirectory=${NAMESPACED}
RuntimeDirectoryMode=2755
UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/var/lib/redis
ReadWriteDirectories=-/var/log/redis
ReadWriteDirectories=-/var/run/${NAMESPACED}
NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
MemoryDenyWriteExecute=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictNamespaces=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
# ${BINARY} can write to its own config file when in cluster mode so we
# permit writing there by default. If you are not using this feature, it is
# recommended that you replace the following lines with "ProtectSystem=full".
ProtectSystem=true
ReadWriteDirectories=-/etc/redis
[Install]
WantedBy=multi-user.target
EOF
if [ "${EXTRA}" != "" ]
then
echo "${EXTRA}" >> "${TARGET}"
fi
done
done
This diff is collapsed.
Source: redis
Section: database
Priority: optional
Maintainer: Chris Lamb <lamby@debian.org>
Build-Depends:
debhelper-compat (= 12),
dpkg-dev (>= 1.17.14),
libhiredis-dev (>= 0.14.0),
libjemalloc-dev [linux-any],
liblua5.1-dev,
lua-bitop-dev,
lua-cjson-dev,
procps <!nocheck>,
tcl <!nocheck>,
Standards-Version: 4.4.0
Homepage: https://redis.io/
Vcs-Git: https://salsa.debian.org/lamby/pkg-redis.git
Vcs-Browser: https://salsa.debian.org/lamby/pkg-redis
Rules-Requires-Root: no
Package: redis
Architecture: all
Depends:
redis-server (<< ${binary:Version}.1~),
redis-server (>= ${binary:Version}),
${misc:Depends},
Description: Persistent key-value database with network interface (metapackage)
Redis is a key-value database in a similar vein to memcache but the dataset
is non-volatile. Redis additionally provides native support for atomically
manipulating and querying data structures such as lists and sets.
.
The dataset is stored entirely in memory and periodically flushed to disk.
.
This package depends on the redis-server package.
Package: redis-sentinel
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends:
lsb-base (>= 3.2-14),
redis-tools (= ${binary:Version}),
${misc:Depends},
Description: Persistent key-value database with network interface (monitoring)
Redis is a key-value database in a similar vein to memcache but the dataset
is non-volatile. Redis additionally provides native support for atomically
manipulating and querying data structures such as lists and sets.
.
This package contains the Redis Sentinel monitoring software.
Package: redis-server
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends:
lsb-base (>= 3.2-14),
redis-tools (= ${binary:Version}),
${misc:Depends},
Description: Persistent key-value database with network interface
Redis is a key-value database in a similar vein to memcache but the dataset
is non-volatile. Redis additionally provides native support for atomically
manipulating and querying data structures such as lists and sets.
.
The dataset is stored entirely in memory and periodically flushed to disk.
Package: redis-tools
Architecture: any
Depends:
adduser,
${misc:Depends},
${shlibs:Depends},
Suggests:
ruby-redis,
Replaces:
redis-server (<< 2:2.6.16-1),
Breaks:
redis-server (<< 2:2.6.16-1),
Description: Persistent key-value database with network interface (client)
Redis is a key-value database in a similar vein to memcache but the dataset
is non-volatile. Redis additionally provides native support for atomically
manipulating and querying data structures such as lists and sets.
.
This package contains the command line client and other tools.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Contact: Salvatore Sanfilippo <antirez@gmail.com>
Upstream-Name: redis
Source: https://github.com/antirez/redis
Files: *
Copyright: © 2006-2014 Salvatore Sanfilippo <antirez@gmail.com>
License: BSD-3-clause
Files:
src/rio.*
src/t_zset.c
src/ziplist.h
src/intset.*
src/redis-check-aof.c
deps/hiredis/*
deps/linenoise/*
Copyright:
© 2009-2012 Pieter Noordhuis <pcnoordhuis@gmail.com>
© 2009-2012 Salvatore Sanfilippo <antirez@gmail.com>
License: BSD-3-clause
Files:
src/lzf.h
src/lzfP.h
src/lzf_d.c
src/lzf_c.c
Copyright:
© 2000-2007 Marc Alexander Lehmann <schmorp@schmorp.de>
© 2009-2012 Salvatore Sanfilippo <antirez@gmail.com>
License: BSD-2-clause
Files: src/setproctitle.c
Copyright:
© 2010 William Ahern
© 2013 Salvatore Sanfilippo
© 2013 Stam He
License: BSD-3-clause
Files: src/ae_evport.c
Copyright: © 2012 Joyent, Inc.
License: BSD-3-clause
Files: src/ae_kqueue.c
Copyright: © 2009 Harish Mallipeddi <harish.mallipeddi@gmail.com>
License: BSD-3-clause
Files: utils/install_server.sh
Copyright: © 2011 Dvir Volk <dvirsk@gmail.com>
License: BSD-3-clause
Files: deps/jemalloc/*
Copyright:
© 2002-2012 Jason Evans <jasone@canonware.com>
© 2007-2012 Mozilla Foundation
© 2009-2012 Facebook, Inc.
License: BSD-3-clause
Files: src/pqsort.*
Copyright: © 1992-1993 The Regents of the University of California
License: BSD-3-clause
Files: deps/lua/*
Copyright: © 1994-2012 Lua.org, PUC-Ri
License: MIT
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.
Files: debian/*
Copyright: © 2009 Chris Lamb <lamby@debian.org>
License: BSD-3-clause
License: BSD-2-clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
.
2. 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 HOLDER 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.
License: BSD-3-clause
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.
* Neither the name of Redis nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
.
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.
[DEFAULT]
debian-branch=debian/sid
upstream-branch=upstream/sid
image: registry.salsa.debian.org/salsa-ci-team/ci-image-git-buildpackage:latest
pages:
stage: deploy
except:
- tags
artifacts:
paths:
- public
script:
- gitlab-ci-git-buildpackage-all
- gitlab-ci-aptly
From: Chris Lamb <lamby@debian.org>
Date: Fri, 30 Oct 2015 10:53:42 +0000
Subject: fix-ftbfs-on-kfreebsd
---
src/fmacros.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/fmacros.h b/src/fmacros.h
index 6e56c75..d490aec 100644
--- a/src/fmacros.h
+++ b/src/fmacros.h
@@ -41,7 +41,7 @@
#define _ALL_SOURCE
#endif
-#if defined(__linux__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__OpenBSD__) || defined(__GLIBC__)
#define _XOPEN_SOURCE 700
/*
* On NetBSD, _XOPEN_SOURCE undefines _NETBSD_SOURCE and
From: Chris Lamb <lamby@debian.org>
Date: Wed, 3 Oct 2018 19:24:16 +0100
Subject: Add support for a USE_SYSTEM_HIREDIS flag.
---
deps/Makefile | 2 ++
src/Makefile | 19 ++++++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/deps/Makefile b/deps/Makefile
index 2ed7736..d6b8e3e 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -33,7 +33,9 @@ ifneq ($(shell sh -c '[ -f .make-ldflags ] && cat .make-ldflags || echo none'),
endif
distclean:
+ifneq ($(USE_SYSTEM_HIREDIS),yes)
-(cd hiredis && $(MAKE) clean) > /dev/null || true
+endif
-(cd linenoise && $(MAKE) clean) > /dev/null || true
ifneq ($(USE_SYSTEM_LUA),yes)
-(cd lua && $(MAKE) clean) > /dev/null || true
diff --git a/src/Makefile b/src/Makefile
index dfbb74e..70d8abc 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -16,7 +16,7 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh')
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
OPTIMIZATION?=-O2
-DEPENDENCY_TARGETS=hiredis linenoise
+DEPENDENCY_TARGETS=linenoise
NODEPS:=clean distclean
# Default settings
@@ -127,7 +127,7 @@ endif
endif
endif
# Include paths to dependencies
-FINAL_CFLAGS+= -I../deps/hiredis -I../deps/linenoise
+FINAL_CFLAGS+= -I../deps/linenoise
ifeq ($(MALLOC),tcmalloc)
FINAL_CFLAGS+= -DUSE_TCMALLOC
@@ -159,6 +159,15 @@ else
FINAL_LIBS := ../deps/lua/src/liblua.a $(FINAL_LIBS)
endif
+ifeq ($(USE_SYSTEM_HIREDIS),yes)
+ FINAL_LIBS+= -lhiredis
+ FINAL_CFLAGS+= -I/usr/include/hiredis
+else
+ DEPENDENCY_TARGETS += hiredis
+ FINAL_LIBS+= ../deps/hiredis/libhiredis.a
+ FINAL_CFLAGS+= -I../deps/hiredis
+endif
+
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) $(CPPFLAGS)
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
REDIS_INSTALL=$(QUIET_INSTALL)$(INSTALL)
@@ -230,7 +239,7 @@ endif
# redis-server
$(REDIS_SERVER_NAME): $(REDIS_SERVER_OBJ)
- $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS)
+ $(REDIS_LD) -o $@ $^ $(FINAL_LIBS)
# redis-sentinel
$(REDIS_SENTINEL_NAME): $(REDIS_SERVER_NAME)
@@ -246,11 +255,11 @@ $(REDIS_CHECK_AOF_NAME): $(REDIS_SERVER_NAME)
# redis-cli
$(REDIS_CLI_NAME): $(REDIS_CLI_OBJ)
- $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a ../deps/linenoise/linenoise.o $(FINAL_LIBS)
+ $(REDIS_LD) -o $@ $^ ../deps/linenoise/linenoise.o $(FINAL_LIBS)
# redis-benchmark
$(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ)
- $(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS)
+ $(REDIS_LD) -o $@ $^ $(FINAL_LIBS)
dict-benchmark: dict.c zmalloc.c sds.c siphash.c
$(REDIS_CC) $(FINAL_CFLAGS) $^ -D DICT_BENCHMARK_MAIN -o $@ $(FINAL_LIBS)
From: Chris Lamb <lamby@debian.org>
Date: Sat, 25 Aug 2018 17:52:13 +0200
Subject: Add support for USE_SYSTEM_JEMALLOC flag.
https://github.com/antirez/redis/pull/5279
---
deps/Makefile | 2 ++
src/Makefile | 5 +++++
src/object.c | 5 +++++
src/zmalloc.c | 10 ++++++++++
src/zmalloc.h | 4 ++++
5 files changed, 26 insertions(+)
diff --git a/deps/Makefile b/deps/Makefile
index eb35c1e..1342fac 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -36,7 +36,9 @@ distclean:
-(cd hiredis && $(MAKE) clean) > /dev/null || true
-(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
-(rm -f .make-*)
.PHONY: distclean
diff --git a/src/Makefile b/src/Makefile
index e12602a..26651d5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -140,10 +140,15 @@ ifeq ($(MALLOC),tcmalloc_minimal)
endif
ifeq ($(MALLOC),jemalloc)
+ifeq ($(USE_SYSTEM_JEMALLOC),yes)
+ FINAL_CFLAGS+= -DUSE_JEMALLOC -I/usr/include/jemalloc/include
+ FINAL_LIBS := -ljemalloc $(FINAL_LIBS)
+else
DEPENDENCY_TARGETS+= jemalloc
FINAL_CFLAGS+= -DUSE_JEMALLOC -I../deps/jemalloc/include
FINAL_LIBS := ../deps/jemalloc/lib/libjemalloc.a $(FINAL_LIBS)
endif
+endif
REDIS_CC=$(QUIET_CC)$(CC) $(FINAL_CFLAGS) $(CPPFLAGS)
REDIS_LD=$(QUIET_LINK)$(CC) $(FINAL_LDFLAGS)
diff --git a/src/object.c b/src/object.c
index d5a22e6..b0cf607 100644
--- a/src/object.c
+++ b/src/object.c
@@ -36,6 +36,11 @@
#define strtold(a,b) ((long double)strtod((a),(b)))
#endif
+#if defined(USE_JEMALLOC) && (USE_SYSTEM_JEMALLOC == yes)
+#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/zmalloc.c b/src/zmalloc.c
index 2482f51..80e6571 100644
--- a/src/zmalloc.c
+++ b/src/zmalloc.c
@@ -63,6 +63,15 @@ void zlibc_free(void *ptr) {
#define realloc(ptr,size) tc_realloc(ptr,size)
#define free(ptr) tc_free(ptr)
#elif defined(USE_JEMALLOC)
+#if USE_SYSTEM_JEMALLOC == yes
+#define malloc(size) malloc(size)
+#define calloc(count,size) calloc(count,size)
+#define realloc(ptr,size) realloc(ptr,size)
+#define free(ptr) free(ptr)
+#define mallocx(size,flags) mallocx(size,flags)
+#define dallocx(ptr,flags) dallocx(ptr,flags)
+#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)
@@ -70,6 +79,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) do { \
size_t _n = (__n); \