From 45cb4fb640178e680135fe0bcca1e9ee94114567 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 26 Oct 2009 21:10:04 +0100 Subject: [PATCH] [MEDIUM] build: switch ebtree users to use new ebtree version All files referencing the previous ebtree code were changed to point to the new one in the ebtree directory. A makefile variable (EBTREE_DIR) is also available to use files from another directory. The ability to build the libebtree library temporarily remains disabled because it can have an impact on some existing toolchains and does not appear worth it in the medium term if we add support for multi-criteria stickiness for instance. --- Makefile | 24 ++++++++++++++++++------ Makefile.bsd | 21 ++++++++++++++------- Makefile.osx | 23 +++++++++++++++-------- contrib/halog/Makefile | 9 +++++---- contrib/halog/halog.c | 2 +- include/common/standard.h | 2 +- include/proto/task.h | 2 +- include/types/lb_chash.h | 4 ++-- include/types/lb_fwlc.h | 2 +- include/types/lb_fwrr.h | 2 +- include/types/protocols.h | 2 +- include/types/proxy.h | 2 +- include/types/server.h | 2 +- include/types/task.h | 2 +- src/lb_chash.c | 2 +- src/lb_fwlc.c | 2 +- src/lb_fwrr.c | 2 +- src/lb_map.c | 2 +- src/standard.c | 2 +- src/task.c | 2 +- 20 files changed, 69 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index 46b762c29..824e8e19b 100644 --- a/Makefile +++ b/Makefile @@ -410,10 +410,12 @@ OPTIONS_LDFLAGS += -L$(PCREDIR)/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynami BUILD_OPTIONS += $(call ignore_implicit,USE_STATIC_PCRE) endif +# This one can be changed to look for ebtree files in an external directory +EBTREE_DIR := ebtree #### Global compile options VERBOSE_CFLAGS = $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) -COPTS = -Iinclude -Wall +COPTS = -Iinclude -I$(EBTREE_DIR) -Wall COPTS += $(CFLAGS) $(TARGET_CFLAGS) $(SMALL_OPTS) $(DEFINE) $(SILENT_DEFINE) COPTS += $(DEBUG) $(OPTIONS_CFLAGS) $(ADDINC) @@ -462,12 +464,22 @@ OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \ src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o \ src/stream_interface.o src/dumpstats.o src/proto_tcp.o \ src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \ - src/acl.o src/memory.o src/freq_ctr.o \ - src/ebtree.o src/eb32tree.o + src/acl.o src/memory.o src/freq_ctr.o -haproxy: $(OBJS) $(OPTIONS_OBJS) +EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \ + $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \ + $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \ + $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o + +# Not used right now +LIB_EBTREE = $(EBTREE_DIR)/libebtree.a + +haproxy: $(OBJS) $(OPTIONS_OBJS) $(EBTREE_OBJS) $(LD) $(LDFLAGS) -o $@ $^ $(LDOPTS) +$(LIB_EBTREE): $(EBTREE_OBJS) + $(AR) rv $@ $^ + objsize: haproxy @objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort @@ -504,8 +516,8 @@ install-bin: haproxy install: install-bin install-man install-doc clean: - rm -f *.[oas] src/*.[oas] core haproxy test - for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done + rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test + for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz rm -f haproxy-$(VERSION) nohup.out gmon.out diff --git a/Makefile.bsd b/Makefile.bsd index 7957f9427..015a3651b 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -92,8 +92,11 @@ VERDATE != cat VERDATE 2>/dev/null || touch VERDATE VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \ -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\" -COPTS = -Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) \ - $(SMALL_OPTS) $(VER_OPTS) $(DEFINE) +# This one can be changed to look for ebtree files in an external directory +EBTREE_DIR := ebtree + +COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \ + $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE) LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB) CFLAGS = -Wall $(COPTS) $(DEBUG) LDFLAGS = -g @@ -107,12 +110,16 @@ OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \ src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \ src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o \ src/ev_poll.o src/ev_kqueue.o \ - src/acl.o src/memory.o src/freq_ctr.o \ - src/ebtree.o src/eb32tree.o + src/acl.o src/memory.o src/freq_ctr.o + +EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \ + $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \ + $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \ + $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o all: haproxy -haproxy: $(OBJS) $(OPT_OBJS) +haproxy: $(OBJS) $(OPT_OBJS) $(EBTREE_OBJS) $(LD) $(LDFLAGS) -o $@ $> $(LIBS) .SUFFIXES: .c.o @@ -129,8 +136,8 @@ 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 + rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test + for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out version: diff --git a/Makefile.osx b/Makefile.osx index 19fb72060..5fa0da025 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -31,6 +31,9 @@ LD = gcc PCREDIR!= pcre-config --prefix 2>/dev/null || : #PCREDIR=/usr/local +# This one can be changed to look for ebtree files in an external directory +EBTREE_DIR = ebtree + # This is for darwin 3.0 and above COPTS.darwin = -DENABLE_POLL -DENABLE_KQUEUE LIBS.darwin = @@ -89,8 +92,8 @@ VERDATE != cat VERDATE 2>/dev/null || touch VERDATE VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \ -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\" -COPTS = -Iinclude $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) $(REGEX_OPTS) \ - $(SMALL_OPTS) $(VER_OPTS) $(DEFINE) +COPTS = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \ + $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE) LIBS = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB) CFLAGS = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4 LDFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4 @@ -104,13 +107,17 @@ OBJS = src/haproxy.o src/sessionhash.o src/base64.o src/protocols.o \ src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \ src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o \ src/ev_poll.o \ - src/acl.o src/memory.o src/freq_ctr.o \ - src/ebtree.o src/eb32tree.o + src/acl.o src/memory.o src/freq_ctr.o + +EBTREE_OBJS = $(EBTREE_DIR)/ebtree.o \ + $(EBTREE_DIR)/eb32tree.o $(EBTREE_DIR)/eb64tree.o \ + $(EBTREE_DIR)/ebmbtree.o $(EBTREE_DIR)/ebsttree.o \ + $(EBTREE_DIR)/ebimtree.o $(EBTREE_DIR)/ebistree.o all: haproxy -haproxy: $(OBJS) - $(LD) $(LDFLAGS) $(OBJS) -o $@ +haproxy: $(OBJS) $(EBTREE_OBJS) + $(LD) $(LDFLAGS) $(OBJS) $(EBTREE_OBJS) -o $@ .SUFFIXES: .c.o @@ -126,8 +133,8 @@ 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 + rm -f *.[oas] src/*.[oas] ebtree/*.[oas] haproxy test + for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION) nohup.out gmon.out version: diff --git a/contrib/halog/Makefile b/contrib/halog/Makefile index 2215e03a9..f85acc7c1 100644 --- a/contrib/halog/Makefile +++ b/contrib/halog/Makefile @@ -1,13 +1,14 @@ -INCLUDE = -I../../include -OPTIMIZE = -O3 -mtune=pentium-m +EBTREE_DIR = ../../ebtree +INCLUDE = -I$(EBTREE_DIR) +OPTIMIZE = -O3 #-mtune=pentium-m OBJS = halog halog64 halog: halog.c fgets2.c - $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) ../../src/ebtree.c ../../src/eb32tree.c $^ + $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) $(EBTREE_DIR)/ebtree.c $(EBTREE_DIR)/eb32tree.c $^ halog64: halog.c fgets2-64.c - $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) ../../src/ebtree.c ../../src/eb32tree.c $^ + $(CC) $(OPTIMIZE) -o $@ $(INCLUDE) $(EBTREE_DIR)/ebtree.c $(EBTREE_DIR)/eb32tree.c $^ clean: rm -vf $(OBJS) diff --git a/contrib/halog/halog.c b/contrib/halog/halog.c index 27e09617d..fcf99c49d 100644 --- a/contrib/halog/halog.c +++ b/contrib/halog/halog.c @@ -27,7 +27,7 @@ #include #include -#include +#include #define ACCEPT_FIELD 6 #define TIME_FIELD 9 diff --git a/include/common/standard.h b/include/common/standard.h index ce70f2e5f..0a6b68bf9 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include /****** string-specific macros and functions ******/ diff --git a/include/proto/task.h b/include/proto/task.h index 62f83e3f5..0cfe28f20 100644 --- a/include/proto/task.h +++ b/include/proto/task.h @@ -26,11 +26,11 @@ #include #include -#include #include #include #include #include +#include #include diff --git a/include/types/lb_chash.h b/include/types/lb_chash.h index 3eee12c40..5991ce961 100644 --- a/include/types/lb_chash.h +++ b/include/types/lb_chash.h @@ -23,8 +23,8 @@ #define _TYPES_LB_CHASH_H #include -#include -#include +#include +#include struct lb_chash { struct eb_root act; /* weighted chash entries of active servers */ diff --git a/include/types/lb_fwlc.h b/include/types/lb_fwlc.h index cad4d134b..170eb241c 100644 --- a/include/types/lb_fwlc.h +++ b/include/types/lb_fwlc.h @@ -23,7 +23,7 @@ #define _TYPES_LB_FWLC_H #include -#include +#include struct lb_fwlc { struct eb_root act; /* weighted least conns on the active servers */ diff --git a/include/types/lb_fwrr.h b/include/types/lb_fwrr.h index 600a511a1..731f055f9 100644 --- a/include/types/lb_fwrr.h +++ b/include/types/lb_fwrr.h @@ -23,7 +23,7 @@ #define _TYPES_LB_FWRR_H #include -#include +#include /* This structure is used to apply fast weighted round robin on a server group */ struct fwrr_group { diff --git a/include/types/protocols.h b/include/types/protocols.h index 66c742b09..c13c73d36 100644 --- a/include/types/protocols.h +++ b/include/types/protocols.h @@ -28,8 +28,8 @@ #include #include -#include #include +#include #include #include diff --git a/include/types/proxy.h b/include/types/proxy.h index ec00d741e..8348f92ed 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -29,11 +29,11 @@ #include #include -#include #include #include #include #include +#include #include #include diff --git a/include/types/server.h b/include/types/server.h index b3fe83dc7..935992d40 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -26,8 +26,8 @@ #include #include -#include #include +#include #include #include diff --git a/include/types/task.h b/include/types/task.h index 641cb17cd..41f889c88 100644 --- a/include/types/task.h +++ b/include/types/task.h @@ -25,8 +25,8 @@ #include #include -#include #include +#include /* values for task->state */ #define TASK_SLEEPING 0x00 /* task sleeping */ diff --git a/src/lb_chash.c b/src/lb_chash.c index bfd4cd047..58c029a4a 100644 --- a/src/lb_chash.c +++ b/src/lb_chash.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c index 5d1a31be2..c2fcb4efe 100644 --- a/src/lb_fwlc.c +++ b/src/lb_fwlc.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/lb_fwrr.c b/src/lb_fwrr.c index 84d179da3..d92b6eb82 100644 --- a/src/lb_fwrr.c +++ b/src/lb_fwrr.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/lb_map.c b/src/lb_map.c index 2918c26be..d3264bb6b 100644 --- a/src/lb_map.c +++ b/src/lb_map.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/standard.c b/src/standard.c index 6b0be2d0a..6a8724a86 100644 --- a/src/standard.c +++ b/src/standard.c @@ -20,8 +20,8 @@ #include #include -#include #include +#include #include /* enough to store 10 integers of : diff --git a/src/task.c b/src/task.c index cc455f58f..9b21fd9df 100644 --- a/src/task.c +++ b/src/task.c @@ -13,11 +13,11 @@ #include #include -#include #include #include #include #include +#include #include #include