Browse code

- updated Makefiles ( gcc-3.0 specific options, arch. specific defines section, a.s.o) - fixed gcc-3.0 warnings - added f_malloc, an even faster malloc

Andrei Pelinescu-Onciul authored on 11/02/2002 17:56:22
Showing 20 changed files
... ...
@@ -15,7 +15,7 @@ Requirements:
15 15
 - flex
16 16
 - gmake (on Linux this is the standard "make")
17 17
 
18
-Arhitecture Notes:
18
+OS Notes:
19 19
 
20 20
 - FreeBSD: make sure gmake, bison & flex are installed
21 21
 - Solaris: as above; you can use Solaris's yacc instead of bison
... ...
@@ -56,6 +56,14 @@ make modules=modules/print modules
56 56
 
57 57
 make exclude_modules="CVS textops" modules
58 58
 
59
+-compile with the "tm" module statically linked and with profiling
60
+
61
+make static_modules=tm PROFILE=-pg all
62
+
63
+-compile with gcc-3.0 instead of gcc
64
+
65
+make CC=gcc-3.0 all
66
+
59 67
 
60 68
 
61 69
 Make targets:
... ...
@@ -8,11 +8,12 @@
8 8
 #version number
9 9
 VERSION = 0
10 10
 PATCHLEVEL = 8
11
-SUBLEVEL = 5
11
+SUBLEVEL = 6
12 12
 EXTRAVERSION =
13 13
 
14 14
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
15
-ARCH = $(shell uname -s)
15
+OS = $(shell uname -s)
16
+ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
16 17
 
17 18
 # compile-time options
18 19
 #
... ...
@@ -47,15 +48,22 @@ ARCH = $(shell uname -s)
47 47
 # -DVQ_MALLOC
48 48
 #		additional option to PKG_MALLOC which utilizes a fater then
49 49
 #		qm version
50
+#		(not true anymore, q_malloc performs approx. the same)
51
+# -DF_MALLOC
52
+#		an even faster malloc, not recommended for debugging
50 53
 # -DDBG_MALLOC
51 54
 #		issues additional debugging information if lock/unlock is called
55
+# -DFAST_LOCK
56
+#		uses fast arhitecture specific locking (see the arh. specific section)
52 57
 #
53 58
 
54 59
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
60
+	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
55 61
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
56
-	 -DUSE_SYNONIM -DVQ_MALLOC\
57
-	 #-DFAST_LOCK -Di386
58
-	 #-DBRUT_HACK #-DEXTRA_DEBUG #-DSTATIC_TM
62
+	 -DUSE_SYNONIM \
63
+	 -DF_MALLOC
64
+	# -DVQ_MALLOC
65
+	 #-DBRUT_HACK #-DEXTRA_DEBUG 
59 66
 	#-DEXTRA_DEBUG -DBRUT_HACK \
60 67
 	#-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
61 68
 	  #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG
... ...
@@ -67,31 +75,43 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
67 67
 #-DNO_DEBUG#-DSTATS -DNO_DEBUG
68 68
 #-DNO_LOG
69 69
 
70
-PROFILE=  -pg #set this if you want profiling
71
-mode = debug
72
-#mode = release
70
+# arh. specific definitions
71
+ifeq ($(ARCH), i386)
72
+	DEFS+= -DFAST_LOCK
73
+endif
74
+
75
+
76
+#PROFILE=  -pg #set this if you want profiling
77
+#mode = debug
78
+mode = release
73 79
 
74 80
 # platform dependent settings
75 81
 
76 82
 
77 83
 #common
78 84
 CC=gcc
79
-LD=gcc
85
+LD= $(CC)
86
+CC_VER= $(CC) $(shell $(CC) --version)
80 87
 MKDEP=gcc -MM $(DEFS)
81 88
 MKTAGS=ctags -R .
82 89
 
83 90
 ifeq ($(mode), release)
84
-	CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
85
-#			-malign-double -malign-loops=4 -minline-all-stringops \
86
-#			-march=athlon -mcpu=athlon
87
-	#-Wmissing-prototypes
88
-	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
91
+	CFLAGS+=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
92
+			-malign-double -malign-loops=4
93
+			#-Wmissing-prototypes \
94
+	
95
+ifneq (,$(findstring 3.0, $(CC_VER)))
96
+	CFLAGS+=-minline-all-stringops \
97
+				-march=athlon \
98
+				#-mcpu=athlon
99
+endif
100
+	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
89 101
 	# we need -fPIC -DPIC only for shared objects, we don't need them for
90 102
 	# the executable file, because it's always loaded at a fixed address
91 103
 	# -andrei
92 104
 else
93
-	CFLAGS=-g -Wcast-align -Winline $(PROFILE)
94
-	LDFLAGS=-g -Wl,-E $(PROFILE)
105
+	CFLAGS+=-g -Wcast-align -Winline $(PROFILE)
106
+	LDFLAGS+=-g -Wl,-E $(PROFILE)
95 107
 endif
96 108
 
97 109
 #*FLAGS used for compiling the modules
... ...
@@ -107,10 +127,10 @@ LIBS=-lfl -ldl
107 107
 
108 108
 
109 109
 #arch specific stuff
110
-ifeq ($(ARCH), Linux)
110
+ifeq ($(OS), Linux)
111 111
 
112 112
 endif
113
-ifeq  ($(ARCH), SunOS)
113
+ifeq  ($(OS), SunOS)
114 114
 	ifeq ($(mode), release)
115 115
 		LDFLAGS=-O2 $(PROFILE)
116 116
 		MOD_LDFLAGS=-O2 -G
... ...
@@ -118,18 +138,18 @@ ifeq  ($(ARCH), SunOS)
118 118
 		LDFLAGS=-g $(PROFILE)
119 119
 		MOD_LDFLAGS=-g -G
120 120
 	endif
121
-	
121
+
122 122
 YACC=yacc
123 123
 LIBS+=-L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ?
124 124
 
125 125
 endif
126
-ifeq ($(ARCH), FreeBSD)
126
+ifeq ($(OS), FreeBSD)
127 127
 
128 128
 YACC=yacc
129 129
 LIBS= -lfl  #dlopen is in libc
130 130
 
131 131
 endif
132
-ifneq (,$(findstring CYGWIN, $(ARCH)))
132
+ifneq (,$(findstring CYGWIN, $(OS)))
133 133
 
134 134
 #cygwin is the same as common
135 135
 
... ...
@@ -6,7 +6,8 @@
6 6
 #
7 7
 
8 8
 #
9
-# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, LIBS, MKDEP, auto_gen, depends, objs
9
+# Uses: NAME, ALLDEP, CC, CFLAGS, DEFS, LIBS, MKDEP, auto_gen, depends, objs,
10
+# extra_objs, static_modules, static_modules_path
10 11
 # (all this must  be defined previously!,  see Makefile.defs & Makefile)
11 12
 #
12 13
 
... ...
@@ -38,8 +39,10 @@ static: $(objs)
38 38
 
39 39
 .PHONY: clean
40 40
 clean:
41
-	-@rm $(objs) $(NAME) 2>/dev/null
42
-	-@for r in $(modules); do $(MAKE) -C $$r clean ; done
41
+	-@rm -f $(objs) $(NAME) 2>/dev/null
42
+	-@for r in $(modules) $(static_modules_path); do \
43
+		$(MAKE) -C $$r clean ; \
44
+	done
43 45
 
44 46
 
45 47
 
... ...
@@ -47,12 +50,12 @@ clean:
47 47
 .PHONY: distclean
48 48
 .PHONY: realclean
49 49
 proper realclean distclean: clean 
50
-	-@rm $(depends) 2>/dev/null
50
+	-@rm -f $(depends) 2>/dev/null
51 51
 	-@for r in $(modules); do $(MAKE) -C $$r proper ; done
52 52
 
53 53
 .PHONY: mantainer-cleaan
54 54
 mantainer-clean: distclean
55
-	-rm $(auto_gen) TAGS tags *.dbg .*.swp
55
+	-rm -f $(auto_gen) TAGS tags *.dbg .*.swp
56 56
 	-@for r in $(modules); do $(MAKE) -C $$r mantainer-clean ; done
57 57
 
58 58
 .PHONY: TAGS
... ...
@@ -16,3 +16,5 @@ objs=$(sources:.c=.o)
16 16
 extra_objs=
17 17
 depends=$(sources:.c=.d)
18 18
 modules=
19
+static_modules=
20
+static_modules_path=
... ...
@@ -15,7 +15,7 @@
15 15
 #include <sched.h>
16 16
 
17 17
 
18
-#ifdef i386
18
+#ifdef __i386
19 19
 
20 20
 
21 21
 typedef  volatile int lock_t;
... ...
@@ -41,7 +41,7 @@
41 41
 #endif
42 42
 
43 43
 static char id[]="@(#) $Id$";
44
-static char version[]=  NAME " " VERSION " (" ARCH ")" ;
44
+static char version[]=  NAME " " VERSION " (" ARCH "/" OS ")" ;
45 45
 static char compiled[]= __TIME__ __DATE__ ;
46 46
 static char flags[]=
47 47
 "STATS:"
... ...
@@ -74,6 +74,9 @@ static char flags[]=
74 74
 #ifdef VQ_MALLOC
75 75
 ", VQ_MALLOC"
76 76
 #endif
77
+#ifdef F_MALLOC
78
+", F_MALLOC"
79
+#endif
77 80
 #ifdef USE_SHM_MEM
78 81
 ", USE_SHM_MEM"
79 82
 #endif
... ...
@@ -83,6 +86,9 @@ static char flags[]=
83 83
 #ifdef DEBUG_DMALLOC
84 84
 ", DEBUG_DMALLOC"
85 85
 #endif
86
+#ifdef FAST_LOCK
87
+", FAST_LOCK"
88
+#endif
86 89
 ;
87 90
 
88 91
 static char help_msg[]= "\
... ...
@@ -537,7 +543,9 @@ int main(int argc, char** argv)
537 537
 					printf("flags: %s\n", flags );
538 538
 					print_ct_constants();
539 539
 					printf("%s\n",id);
540
-					printf("%s compiled on %s at %s\n", __FILE__, __DATE__, __TIME__ );
540
+					printf("%s compiled on %s at %s with %s\n", __FILE__,
541
+							__DATE__, __TIME__, COMPILER );
542
+					
541 543
 					exit(0);
542 544
 					break;
543 545
 			case 'h':
... ...
@@ -647,15 +655,15 @@ int main(int argc, char** argv)
647 647
 	if (working_dir==0) working_dir="/";
648 648
 	/*alloc pids*/
649 649
 #ifdef SHM_MEM
650
-	pids=shm_malloc(sizeof(int)*children_no);
650
+	pids=shm_malloc(sizeof(int)*(children_no+1));
651 651
 #else
652
-	pids=malloc(sizeof(int)*children_no);
652
+	pids=malloc(sizeof(int)*(children_no+1));
653 653
 #endif
654 654
 	if (pids==0){
655 655
 		fprintf(stderr, "ERROR: out  of memory\n");
656 656
 		goto error;
657 657
 	}
658
-	memset(pids, 0, sizeof(int)*children_no);
658
+	memset(pids, 0, sizeof(int)*(children_no+1));
659 659
 
660 660
 	if (addresses_no==0) {
661 661
 		/* get our address, only the first one */
... ...
@@ -18,6 +18,8 @@
18 18
 	char mem_pool[PKG_MEM_POOL_SIZE];
19 19
 	#ifdef VQ_MALLOC
20 20
 		struct vqm_block* mem_block;
21
+	#elif defined F_MALLOC
22
+		struct fm_block* mem_block;
21 23
 	#else
22 24
 		struct qm_block* mem_block;
23 25
 	#endif
... ...
@@ -29,6 +31,8 @@ int init_mallocs()
29 29
         /*init mem*/
30 30
 	#ifdef VQ_MALLOC
31 31
         	mem_block=vqm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
32
+	#elif F_MALLOC
33
+		mem_block=fm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
32 34
 	#else
33 35
         	mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
34 36
 	#endif
... ...
@@ -14,7 +14,10 @@
14 14
 #	ifdef VQ_MALLOC
15 15
 #		include "vq_malloc.h"
16 16
 		extern struct vqm_block* mem_block;
17
-#	else
17
+#	elif defined F_MALLOC
18
+#		include "f_malloc.h"
19
+		extern struct fm_block* mem_block;
20
+#   else
18 21
 #		include "q_malloc.h"
19 22
 		extern struct qm_block* mem_block;
20 23
 #	endif
... ...
@@ -28,6 +31,11 @@
28 28
 				__FUNCTION__, __LINE__);
29 29
 #			define pkg_free(p)   vqm_free(mem_block, (p), __FILE__,  \
30 30
 				__FUNCTION__, __LINE__);
31
+#		elif defined F_MALLOC
32
+#			define pkg_malloc(s) fm_malloc(mem_block, (s),__FILE__, \
33
+				__FUNCTION__, __LINE__);
34
+#			define pkg_free(p)   fm_free(mem_block, (p), __FILE__,  \
35
+				__FUNCTION__, __LINE__);
31 36
 #		else
32 37
 #			define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, \
33 38
 				__FUNCTION__, __LINE__);
... ...
@@ -38,6 +46,9 @@
38 38
 #		ifdef VQ_MALLOC
39 39
 #			define pkg_malloc(s) vqm_malloc(mem_block, (s))
40 40
 #			define pkg_free(p)   vqm_free(mem_block, (p))
41
+#		elif defined F_MALLOC
42
+#			define pkg_malloc(s) fm_malloc(mem_block, (s))
43
+#			define pkg_free(p)   fm_free(mem_block, (p))
41 44
 #		else
42 45
 #			define pkg_malloc(s) qm_malloc(mem_block, (s))
43 46
 #			define pkg_free(p)   qm_free(mem_block, (p))
... ...
@@ -45,6 +56,8 @@
45 45
 #	endif
46 46
 #	ifdef VQ_MALLOC
47 47
 #		define pkg_status()  vqm_status(mem_block)
48
+#	elif defined F_MALLOC
49
+#		define pkg_status()  fm_status(mem_block)
48 50
 #	else
49 51
 #		define pkg_status()  qm_status(mem_block)
50 52
 #	endif
... ...
@@ -2,7 +2,7 @@
2 2
  *
3 3
  */
4 4
 
5
-#if !defined(q_malloc) && !(defined VQ_MALLOC)
5
+#if !defined(q_malloc) && !(defined VQ_MALLOC) && !(defined F_MALLOC)
6 6
 #define q_malloc
7 7
 
8 8
 #include "q_malloc.h"
... ...
@@ -130,7 +130,7 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
130 130
 	if (size <(MIN_FRAG_SIZE+FRAG_OVERHEAD)) return 0;
131 131
 	size=ROUNDDOWN(size);
132 132
 	
133
-	init_overhead=sizeof(struct qm_block)+sizeof(struct qm_frag)+
133
+	init_overhead=ROUNDUP(sizeof(struct qm_block))+sizeof(struct qm_frag)+
134 134
 		sizeof(struct qm_frag_end);
135 135
 	printf("qm_malloc_init: size= %d, init_overhead=%d\n", size, init_overhead);
136 136
 	
... ...
@@ -147,7 +147,7 @@ struct qm_block* qm_malloc_init(char* address, unsigned int size)
147 147
 	qm->real_used=init_overhead;
148 148
 	qm->max_real_used=qm->real_used;
149 149
 	
150
-	qm->first_frag=(struct qm_frag*)(start+sizeof(struct qm_block));
150
+	qm->first_frag=(struct qm_frag*)(start+ROUNDUP(sizeof(struct qm_block)));
151 151
 	qm->last_frag_end=(struct qm_frag_end*)(end-sizeof(struct qm_frag_end));
152 152
 	/* init initial fragment*/
153 153
 	qm->first_frag->size=size;
... ...
@@ -240,9 +240,8 @@ void* qm_malloc(struct qm_block* qm, unsigned int size)
240 240
 	/*size must be a multiple of 8*/
241 241
 	size=ROUNDUP(size);
242 242
 	if (size>(qm->size-qm->real_used)) return 0;
243
-	/*search for a suitable free frag*/
244
-	f=qm_find_free(qm, size);
245 243
 
244
+	/*search for a suitable free frag*/
246 245
 	if ((f=qm_find_free(qm, size))!=0){
247 246
 		/* we found it!*/
248 247
 		/*detach it from the free list*/
... ...
@@ -339,7 +338,6 @@ void qm_free(struct qm_block* qm, void* p)
339 339
 	DBG("qm_free: freeing block alloc'ed from %s: %s(%d)\n", f->file, f->func,
340 340
 			f->line);
341 341
 #endif
342
-	next=FRAG_NEXT(f);
343 342
 	size=f->size;
344 343
 	qm->used-=size;
345 344
 	qm->real_used-=size;
... ...
@@ -349,7 +347,7 @@ void qm_free(struct qm_block* qm, void* p)
349 349
 
350 350
 #ifdef QM_JOIN_FREE
351 351
 	/* join packets if possible*/
352
-
352
+	next=FRAG_NEXT(f);
353 353
 	if (((char*)next < (char*)qm->last_frag_end) &&( next->u.is_free)){
354 354
 		/* join */
355 355
 		qm_detach_free(qm, next);
... ...
@@ -399,32 +397,27 @@ void qm_status(struct qm_block* qm)
399 399
 			qm->used, qm->real_used, qm->size-qm->real_used);
400 400
 	LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used);
401 401
 	
402
-	LOG(L_INFO, "dumping all fragments:\n");
402
+	LOG(L_INFO, "dumping all allocked. fragments:\n");
403 403
 	for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f)
404 404
 			,i++){
405
-		LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
405
+		if (! f->u.is_free){
406
+			LOG(L_INFO, "    %3d. %c  address=%x  size=%d\n", i, 
406 407
 				(f->u.is_free)?'a':'N',
407 408
 				(char*)f+sizeof(struct qm_frag), f->size);
408 409
 #ifdef DBG_QM_MALLOC
409
-		LOG(L_INFO, "            %s from %s: %s(%d)\n",
410
+			LOG(L_INFO, "            %s from %s: %s(%d)\n",
410 411
 				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
411
-		LOG(L_INFO, "        start check=%x, end check= %x, %x\n",
412
+			LOG(L_INFO, "        start check=%x, end check= %x, %x\n",
412 413
 				f->check, FRAG_END(f)->check1, FRAG_END(f)->check2);
413 414
 #endif
415
+		}
414 416
 	}
415
-	LOG(L_INFO, "dumping free list:\n");
417
+	LOG(L_INFO, "dumping free list stats :\n");
416 418
 	for(h=0,i=0;h<QM_HASH_SIZE;h++){
417 419
 		
418 420
 		for (f=qm->free_hash[h].head.u.nxt_free,j=0; 
419
-				f!=&(qm->free_hash[h].head); f=f->u.nxt_free, i++, j++){
420
-			LOG(L_INFO, "   %5d.[%3d:%3d] %c  address=%x  size=%d\n", i, h, j,
421
-					(f->u.is_free)?'a':'N',
422
-					(char*)f+sizeof(struct qm_frag), f->size);
423
-#ifdef DBG_QM_MALLOC
424
-			DBG("            %s from %s: %s(%d)\n", 
425
-				(f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
426
-#endif
427
-		}
421
+				f!=&(qm->free_hash[h].head); f=f->u.nxt_free, i++, j++);
422
+		if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j);
428 423
 	}
429 424
 	LOG(L_INFO, "-----------------------------\n");
430 425
 }
... ...
@@ -3,14 +3,17 @@
3 3
  * simple & fast malloc library
4 4
  */
5 5
 
6
-#if !defined(q_malloc_h) && !defined(VQ_MALLOC)
6
+#if !defined(q_malloc_h) && !defined(VQ_MALLOC) && !defined(F_MALLOC)
7 7
 #define q_malloc_h
8 8
 
9 9
 
10 10
 
11 11
 /* defs*/
12 12
 
13
-#define ROUNDTO		16 /* size we round to, must be = 2^n */
13
+#define ROUNDTO		16 /* size we round to, must be = 2^n  and also
14
+						 sizeof(qm_frag)+sizeof(qm_frag_end)
15
+						 must be mutliple of ROUNDTO!
16
+					   */
14 17
 #define MIN_FRAG_SIZE	ROUNDTO
15 18
 
16 19
 
... ...
@@ -47,6 +50,8 @@ struct qm_frag_end{
47 47
 #ifdef DBG_QM_MALLOC
48 48
 	unsigned int check1;
49 49
 	unsigned int check2;
50
+	unsigned int reserved1;
51
+	unsigned int reserved2;
50 52
 #endif
51 53
 	unsigned int size;
52 54
 	struct qm_frag* prev_free;
... ...
@@ -51,6 +51,8 @@ int shm_semid=-1; /*semaphore id*/
51 51
 static void* shm_mempool=(void*)-1;
52 52
 #ifdef VQ_MALLOC
53 53
 	struct vqm_block* shm_block;
54
+#elif F_MALLOC
55
+	struct fm_block* shm_block;
54 56
 #else
55 57
 	struct qm_block* shm_block;
56 58
 #endif
... ...
@@ -184,6 +186,8 @@ int shm_mem_init()
184 184
 	/* init it for malloc*/
185 185
 #	ifdef VQ_MALLOC
186 186
 		shm_block=vqm_malloc_init(shm_mempool, SHM_MEM_SIZE);
187
+	#elif defined F_MALLOC
188
+		shm_block=fm_malloc_init(shm_mempool, SHM_MEM_SIZE);
187 189
 #	else
188 190
 		shm_block=qm_malloc_init(shm_mempool, SHM_MEM_SIZE);
189 191
 #	endif
... ...
@@ -33,6 +33,12 @@
33 33
 #	define MY_MALLOC vqm_malloc
34 34
 #	define MY_FREE vqm_free
35 35
 #	define MY_STATUS vqm_status
36
+#elif defined F_MALLOC
37
+#	include "f_malloc.h"
38
+	extern struct fm_block* shm_block;
39
+#	define MY_MALLOC fm_malloc
40
+#	define MY_FREE fm_free
41
+#	define MY_STATUS fm_status
36 42
 #else
37 43
 #	include "q_malloc.h"
38 44
 	extern struct qm_block* shm_block;
... ...
@@ -8,7 +8,7 @@
8 8
 
9 9
 /* always use a power of 2 for hash table size */
10 10
 #define T_TABLE_POWER		12
11
-#define TABLE_ENTRIES  		(2 << (T_TABLE_POWER-1))
11
+#define TABLE_ENTRIES  		(1 << (T_TABLE_POWER))
12 12
 
13 13
 /* maximum number of forks per transaction */
14 14
 #define MAX_FORK		2
... ...
@@ -22,12 +22,52 @@ int old_hash( str  call_id, str cseq_nr )
22 22
 {
23 23
    int  hash_code = 0;
24 24
    int  i;
25
+	
26
+#ifdef i386
27
+   int ci_len, cs_len;
28
+   char *ci, *cs;
29
+   
30
+	trim_len( ci_len, ci, call_id );
31
+	trim_len( cs_len, cs, cseq_nr );
32
+
33
+		int dummy1;
34
+		if (call_id.len>=4){
35
+			asm(
36
+				"1: \n\r"
37
+				"addl (%1), %0 \n\r"
38
+				"add $4, %1 \n\r"
39
+				"cmp %2, %1 \n\r"
40
+				"jl 1b  \n\r"
41
+				: "=r"(hash_code), "=r"(dummy1)
42
+				:  "0" (hash_code), "1"(ci),
43
+				"r"( (ci_len & (~3)) +ci)
44
+			);
45
+		}
46
+#else
25 47
     if ( call_id.len>0 )
26 48
       for( i=0 ; i<call_id.len ; hash_code+=call_id.s[i++]  );
49
+#endif
50
+
51
+#ifdef i386
52
+
53
+		int dummy2;
54
+		if (cseq_nr.len>=4){
55
+			asm(
56
+				"1: \n\r"
57
+				"addl (%1), %0 \n\r"
58
+				"add $4, %1 \n\r"
59
+				"cmp %2, %1 \n\r"
60
+				"jl 1b  \n\r"
61
+				: "=r"(hash_code), "=r"(dummy2)
62
+				:  "0" (hash_code), "1"(cs),
63
+				"r"((cs_len & (~3) )+ cs)
64
+			);
65
+		}
66
+#else
27 67
     if ( cseq_nr.len>0 )
28 68
       for( i=0 ; i<cseq_nr.len ; hash_code+=cseq_nr.s[i++] );
29
-
30
-   return hash_code %= TABLE_ENTRIES;
69
+#endif
70
+   return hash_code &= (TABLE_ENTRIES-1); /* TABLE_ENTRIES = 2^k */
31 71
 }
32 72
 
33 73
 int new_hash( str call_id, str cseq_nr )
... ...
@@ -64,7 +104,7 @@ int new_hash( str call_id, str cseq_nr )
64 64
 		//hash_code+=crc_32_tab[(cseq_nr.s[i]+hash_code)%243];
65 65
 		hash_code+=ccitt_tab[*(cs+i)+123];
66 66
 
67
-	hash_code %= (TABLE_ENTRIES-1);
67
+	hash_code &= (TABLE_ENTRIES-1); /* TABLE_ENTRIES = 2^k */
68 68
    	return hash_code;
69 69
 }
70 70
 
... ...
@@ -69,7 +69,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
69 69
 	} else IFISMETHOD( INVITE, 'I' )
70 70
 	else IFISMETHOD( CANCEL, 'C')
71 71
 	else IFISMETHOD( ACK, 'A' )
72
-	else IFISMETHOD( BYE, 'B' )
72
+	else IFISMETHOD( BYE, 'B' ) 
73 73
 	/* if you want to add another method XXX, include METHOD_XXX in
74 74
            H-file (this is the value which you will take later in
75 75
            processing and define XXX_LEN as length of method name;
... ...
@@ -379,6 +379,7 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
379 379
 		}
380 380
 		t++;
381 381
 check_continue:
382
+		;
382 383
 	}while( (t<end) && ((*t==' ')||(*t=='\t')) );
383 384
 
384 385
 	cb->error=PARSE_OK;
... ...
@@ -857,7 +858,7 @@ void free_sip_msg(struct sip_msg* msg)
857 857
 	pkg_free(msg->orig);
858 858
 	/* don't free anymore -- now a pointer to a static buffer */
859 859
 #	ifdef DYN_BUF
860
-	pkg_free(msg->buf); */
860
+	pkg_free(msg->buf); 
861 861
 #	endif
862 862
 }
863 863
 
... ...
@@ -991,8 +991,8 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
991 991
 						state=F_CR;
992 992
 						break;
993 993
 					default:
994
-						LOG(L_ERR, "ERROR: parse_first_line: invalid
995
-								message\n");
994
+						LOG(L_ERR, "ERROR: parse_first_line: invalid" 
995
+								"message\n");
996 996
 						goto error;
997 997
 				}
998 998
 				break;
... ...
@@ -1015,8 +1015,8 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
1015 1015
 						state=F_LF;
1016 1016
 						goto skip;
1017 1017
 					default:
1018
-						LOG(L_ERR, "ERROR: parse_first_line: invalid
1019
-								message\n");
1018
+						LOG(L_ERR, "ERROR: parse_first_line: invalid"
1019
+								" message\n");
1020 1020
 						goto error;
1021 1021
 				}
1022 1022
 				break;
... ...
@@ -68,7 +68,7 @@ enum{	L_VALUE=200,   F_VALUE, P_VALUE, P_STRING,
68 68
  * state=F_{LF,CR,CRLF}!
69 69
  * output state = L_PARAM or F_PARAM or END_OF_HEADER
70 70
  * (and saved_state= last state); everything else => error */
71
-__inline char* parse_via_param(	char* p, char* end, int* pstate,
71
+char* parse_via_param(	char* p, char* end, int* pstate, 
72 72
 								int* psaved_state, struct via_param* param)
73 73
 {
74 74
 	char* tmp;
... ...
@@ -7,17 +7,19 @@
7 7
 
8 8
 debug=3          # debug level (cmd line: -dddddddddd)
9 9
 #fork=yes          # (cmd. line: -D)
10
-fork=no
10
+fork=yes
11
+#fork=no
11 12
 log_stderror=yes # (cmd line: -E)
12 13
 #log_stderror=no	# (cmd line: -E)
13 14
 
14 15
 
15
-children=8
16
+children=4
16 17
 check_via=no     # (cmd. line: -v)
17
-dns=on           # (cmd. line: -r)
18
-rev_dns=yes      # (cmd. line: -R)
18
+dns=off           # (cmd. line: -r)
19
+rev_dns=off      # (cmd. line: -R)
19 20
 #port=5070
20
-listen=127.0.0.1
21
+listen=10.0.0.179
22
+#listen=127.0.0.1
21 23
 #listen=192.168.57.33
22 24
 loop_checks=0
23 25
 # for more info: sip_router -h
... ...
@@ -5,19 +5,19 @@
5 5
 #
6 6
 
7 7
 
8
-debug=9          # debug level (cmd line: -dddddddddd)
9
-#fork=yes          # (cmd. line: -D)
10
-fork=no
8
+debug=3          # debug level (cmd line: -dddddddddd)
9
+fork=yes          # (cmd. line: -D)
10
+#fork=no
11 11
 log_stderror=yes # (cmd line: -E)
12 12
 #log_stderror=no	# (cmd line: -E)
13 13
 
14 14
 
15
-children=8
15
+children=4
16 16
 check_via=no     # (cmd. line: -v)
17
-dns=on           # (cmd. line: -r)
18
-rev_dns=yes      # (cmd. line: -R)
17
+dns=off           # (cmd. line: -r)
18
+rev_dns=off      # (cmd. line: -R)
19 19
 #port=5070
20
-#listen=127.0.0.1
20
+listen=10.0.0.179
21 21
 #listen=192.168.57.33
22 22
 loop_checks=0
23 23
 # for more info: sip_router -h
... ...
@@ -25,7 +25,7 @@ loop_checks=0
25 25
 #modules
26 26
 #loadmodule "modules/print/print.so"
27 27
 loadmodule "modules/tm/tm.so"
28
-loadmodule "modules/rr/rr.so"
28
+#loadmodule "modules/rr/rr.so"
29 29
 loadmodule "modules/maxfwd/maxfwd.so"
30 30
 
31 31
 
... ...
@@ -154,7 +154,7 @@ int udp_rcv_loop()
154 154
 #ifdef DYN_BUF
155 155
 	char* buf;
156 156
 #else
157
-	char buf [BUF_SIZE+1];
157
+	static char buf [BUF_SIZE+1];
158 158
 #endif
159 159
 
160 160
 	struct sockaddr* from;
... ...
@@ -181,7 +181,7 @@ int udp_rcv_loop()
181 181
 		if (len==-1){
182 182
 			LOG(L_ERR, "ERROR: udp_rcv_loop:recvfrom: %s\n",
183 183
 						strerror(errno));
184
-			if (errno==EINTR)	goto skip;
184
+			if (errno==EINTR)	continue; /* goto skip;*/
185 185
 			else goto error;
186 186
 		}
187 187
 		/*debugging, make print* msg work */
... ...
@@ -190,7 +190,7 @@ int udp_rcv_loop()
190 190
 		/* receive_msg must free buf too!*/
191 191
 		receive_msg(buf, len, ((struct sockaddr_in*)from)->sin_addr.s_addr);
192 192
 		
193
-	skip: /* do other stuff */
193
+	/* skip: do other stuff */
194 194
 		
195 195
 	}
196 196