]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] Added easier support for Doug Lea's malloc (dlmalloc)
authorWilly Tarreau <w@1wt.eu>
Wed, 11 Jul 2007 07:19:31 +0000 (09:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Jul 2007 07:19:31 +0000 (09:19 +0200)
It's now as easy as passing "DLMALLOC_SRC=<path_to_dlmalloc.c>" to
build with support for dlmalloc. The dlmalloc source is not provided
with haproxy in order to ensure that people will use either the most
recent, or the most suited version for their platform. The minimal
mmap size is specified in DLMALLOC_THRES, which defaults to 4096. It
should be increased on platforms with larger pages (eg: 8 kB on some
64 bit systems).

Makefile
Makefile.bsd
Makefile.osx

index 39fa4d55dbc28dab70ba926d83f2865a0fb1dd63..c5c262e5d696fd8488a2099054f5529dcb98099f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,10 @@
 # This makefile supports different OS and CPU setups.
 # You should use it this way :
 #   make TARGET=os CPU=cpu REGEX=lib
-
+#
+# Some external components may be build with it, such dlmalloc :
+#
+#   make DLMALLOC_SRC=/usr/local/src/dlmalloc.c
 
 # Select target OS. TARGET must match a system for which COPTS and LIBS are
 # correctly defined below.
@@ -180,6 +183,12 @@ ifneq ($(USE_REGPARM),)
 OPTIONS += -DCONFIG_HAP_USE_REGPARM
 endif
 
+ifneq ($(DLMALLOC_SRC),)
+# May be changed to patch PAGE_SIZE on every platform
+DLMALLOC_THRES=4096
+OPT_OBJS += src/dlmalloc.o
+endif
+
 ifneq ($(VERSION),)
 OPTIONS += -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\"
 endif
@@ -228,6 +237,9 @@ objsize: haproxy
 %.o:   %.c
        $(CC) $(CFLAGS) -c -o $@ $<
 
+src/dlmalloc.o: $(DLMALLOC_SRC)
+       $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
+
 clean:
        rm -f *.[oas] src/*.[oas] core haproxy test
        for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
index 14e70f463753c36cf97795798edd1b33c1898be3..025bc4593feddec1a5afa42d2a67ac02642f034a 100644 (file)
@@ -1,6 +1,11 @@
 # This makefile is dedicated to OpenBSD (and possibly other BSDs)
 # You should use it this way :
 #   make TARGET=os CPU=cpu
+#
+# Some optional components may be added, such as DLMALLOC :
+#
+#   make TARGET=freebsd CPU=i686 DLMALLOC_SRC=/usr/local/src/dlmalloc.c \
+#        OPT_OBJS=src/dlmalloc.o
 
 VERSION := 1.3.12
 
@@ -66,11 +71,17 @@ SMALL_OPTS = -DBUFSIZE=8030 -DMAXREWRITE=1030 -DSYSTEM_MAXCONN=1024
 ADDINC =
 ADDLIB =
 
+# redefine this if you want to add some special .o files
+OPT_OBJS =
+
 # set some defines when needed.
 # Known ones are -DENABLE_POLL
 # - use -DTPROXY to compile with transparent proxy support.
 DEFINE = -DTPROXY
 
+# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
+DLMALLOC_THRES=4096
+
 # global options
 TARGET_OPTS=$(COPTS.$(TARGET))
 REGEX_OPTS=$(COPTS.$(REGEX))
@@ -92,7 +103,7 @@ OBJS = src/haproxy.o src/list.o src/chtbl.o src/hashpjw.o src/base64.o \
 
 all: haproxy
 
-haproxy: $(OBJS)
+haproxy: $(OBJS) $(OPT_OBJS)
        $(LD) $(LDFLAGS) -o $@ $> $(LIBS)
 
 .SUFFIXES: .c.o
@@ -100,6 +111,9 @@ haproxy: $(OBJS)
 .c.o:
        $(CC) $(CFLAGS) -c -o $@ $>
 
+src/dlmalloc.o: $(DLMALLOC_SRC)
+       $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $>
+
 clean:
        rm -f *.[oas] src/*.[oas] core haproxy test
        for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done
index 0a2aa74363b0cdb1762299277fc6b683d8ba7b1e..f588478545741b2ece218f1af3553f212689d375 100644 (file)
@@ -1,6 +1,11 @@
 # This makefile is dedicated to darwin (and possibly other BSDs)
 # You should use it this way :
 #   make TARGET=os CPU=cpu
+#
+# Some optional components may be added, such as DLMALLOC :
+#
+#   make DLMALLOC_SRC=/usr/local/src/dlmalloc.c \
+#        OPT_OBJS=src/dlmalloc.o
 
 VERSION := 1.3.12
 
@@ -71,6 +76,9 @@ ADDLIB =
 # - use -DTPROXY to compile with transparent proxy support.
 DEFINE = -DTPROXY 
 
+# May be changed to patch PAGE_SIZE on every platform when using dlmalloc
+DLMALLOC_THRES=4096
+
 # global options
 TARGET_OPTS=$(COPTS.$(TARGET))
 REGEX_OPTS=$(COPTS.$(REGEX))
@@ -100,6 +108,9 @@ haproxy: $(OBJS)
 .c.o:
        $(CC) $(CFLAGS) -c -o $@ $<
 
+src/dlmalloc.o: $(DLMALLOC_SRC)
+       $(CC) $(CFLAGS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
+
 clean:
        rm -f *.[oas] src/*.[oas] core haproxy test
        for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done