... | ... |
@@ -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 | 48 |
# -DVQ_MALLOC |
48 | 49 |
# additional option to PKG_MALLOC which utilizes a fater then |
49 | 50 |
# qm version |
51 |
+# (not true anymore, q_malloc performs approx. the same) |
|
52 |
+# -DF_MALLOC |
|
53 |
+# an even faster malloc, not recommended for debugging |
|
50 | 54 |
# -DDBG_MALLOC |
51 | 55 |
# issues additional debugging information if lock/unlock is called |
56 |
+# -DFAST_LOCK |
|
57 |
+# uses fast arhitecture specific locking (see the arh. specific section) |
|
52 | 58 |
# |
53 | 59 |
|
54 | 60 |
DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ |
61 |
+ -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\ |
|
55 | 62 |
-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 |
|
63 |
+ -DUSE_SYNONIM \ |
|
64 |
+ -DF_MALLOC |
|
65 |
+ # -DVQ_MALLOC |
|
66 |
+ #-DBRUT_HACK #-DEXTRA_DEBUG |
|
59 | 67 |
#-DEXTRA_DEBUG -DBRUT_HACK \ |
60 | 68 |
#-DVQ_MALLOC -DDBG_LOCK #-DSTATS |
61 | 69 |
#-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG |
... | ... |
@@ -67,31 +75,43 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ |
67 | 75 |
#-DNO_DEBUG#-DSTATS -DNO_DEBUG |
68 | 76 |
#-DNO_LOG |
69 | 77 |
|
70 |
-PROFILE= -pg #set this if you want profiling |
|
71 |
-mode = debug |
|
72 |
-#mode = release |
|
78 |
+# arh. specific definitions |
|
79 |
+ifeq ($(ARCH), i386) |
|
80 |
+ DEFS+= -DFAST_LOCK |
|
81 |
+endif |
|
82 |
+ |
|
83 |
+ |
|
84 |
+#PROFILE= -pg #set this if you want profiling |
|
85 |
+#mode = debug |
|
86 |
+mode = release |
|
73 | 87 |
|
74 | 88 |
# platform dependent settings |
75 | 89 |
|
76 | 90 |
|
77 | 91 |
#common |
78 | 92 |
CC=gcc |
79 |
-LD=gcc |
|
93 |
+LD= $(CC) |
|
94 |
+CC_VER= $(CC) $(shell $(CC) --version) |
|
80 | 95 |
MKDEP=gcc -MM $(DEFS) |
81 | 96 |
MKTAGS=ctags -R . |
82 | 97 |
|
83 | 98 |
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) |
|
99 |
+ CFLAGS+=-O9 -funroll-loops -Wcast-align $(PROFILE) -Winline\ |
|
100 |
+ -malign-double -malign-loops=4 |
|
101 |
+ #-Wmissing-prototypes \ |
|
102 |
+ |
|
103 |
+ifneq (,$(findstring 3.0, $(CC_VER))) |
|
104 |
+ CFLAGS+=-minline-all-stringops \ |
|
105 |
+ -march=athlon \ |
|
106 |
+ #-mcpu=athlon |
|
107 |
+endif |
|
108 |
+ LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) |
|
89 | 109 |
# we need -fPIC -DPIC only for shared objects, we don't need them for |
90 | 110 |
# the executable file, because it's always loaded at a fixed address |
91 | 111 |
# -andrei |
92 | 112 |
else |
93 |
- CFLAGS=-g -Wcast-align -Winline $(PROFILE) |
|
94 |
- LDFLAGS=-g -Wl,-E $(PROFILE) |
|
113 |
+ CFLAGS+=-g -Wcast-align -Winline $(PROFILE) |
|
114 |
+ LDFLAGS+=-g -Wl,-E $(PROFILE) |
|
95 | 115 |
endif |
96 | 116 |
|
97 | 117 |
#*FLAGS used for compiling the modules |
... | ... |
@@ -107,10 +127,10 @@ LIBS=-lfl -ldl |
107 | 127 |
|
108 | 128 |
|
109 | 129 |
#arch specific stuff |
110 |
-ifeq ($(ARCH), Linux) |
|
130 |
+ifeq ($(OS), Linux) |
|
111 | 131 |
|
112 | 132 |
endif |
113 |
-ifeq ($(ARCH), SunOS) |
|
133 |
+ifeq ($(OS), SunOS) |
|
114 | 134 |
ifeq ($(mode), release) |
115 | 135 |
LDFLAGS=-O2 $(PROFILE) |
116 | 136 |
MOD_LDFLAGS=-O2 -G |
... | ... |
@@ -118,18 +138,18 @@ ifeq ($(ARCH), SunOS) |
118 | 138 |
LDFLAGS=-g $(PROFILE) |
119 | 139 |
MOD_LDFLAGS=-g -G |
120 | 140 |
endif |
121 |
- |
|
141 |
+ |
|
122 | 142 |
YACC=yacc |
123 | 143 |
LIBS+=-L/usr/local/lib -lxnet # or -lnsl -lsocket or -lglibc ? |
124 | 144 |
|
125 | 145 |
endif |
126 |
-ifeq ($(ARCH), FreeBSD) |
|
146 |
+ifeq ($(OS), FreeBSD) |
|
127 | 147 |
|
128 | 148 |
YACC=yacc |
129 | 149 |
LIBS= -lfl #dlopen is in libc |
130 | 150 |
|
131 | 151 |
endif |
132 |
-ifneq (,$(findstring CYGWIN, $(ARCH))) |
|
152 |
+ifneq (,$(findstring CYGWIN, $(OS))) |
|
133 | 153 |
|
134 | 154 |
#cygwin is the same as common |
135 | 155 |
|
... | ... |
@@ -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 | 39 |
|
39 | 40 |
.PHONY: clean |
40 | 41 |
clean: |
41 |
- -@rm $(objs) $(NAME) 2>/dev/null |
|
42 |
- -@for r in $(modules); do $(MAKE) -C $$r clean ; done |
|
42 |
+ -@rm -f $(objs) $(NAME) 2>/dev/null |
|
43 |
+ -@for r in $(modules) $(static_modules_path); do \ |
|
44 |
+ $(MAKE) -C $$r clean ; \ |
|
45 |
+ done |
|
43 | 46 |
|
44 | 47 |
|
45 | 48 |
|
... | ... |
@@ -47,12 +50,12 @@ clean: |
47 | 50 |
.PHONY: distclean |
48 | 51 |
.PHONY: realclean |
49 | 52 |
proper realclean distclean: clean |
50 |
- -@rm $(depends) 2>/dev/null |
|
53 |
+ -@rm -f $(depends) 2>/dev/null |
|
51 | 54 |
-@for r in $(modules); do $(MAKE) -C $$r proper ; done |
52 | 55 |
|
53 | 56 |
.PHONY: mantainer-cleaan |
54 | 57 |
mantainer-clean: distclean |
55 |
- -rm $(auto_gen) TAGS tags *.dbg .*.swp |
|
58 |
+ -rm -f $(auto_gen) TAGS tags *.dbg .*.swp |
|
56 | 59 |
-@for r in $(modules); do $(MAKE) -C $$r mantainer-clean ; done |
57 | 60 |
|
58 | 61 |
.PHONY: TAGS |
... | ... |
@@ -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 | 86 |
#ifdef DEBUG_DMALLOC |
84 | 87 |
", DEBUG_DMALLOC" |
85 | 88 |
#endif |
89 |
+#ifdef FAST_LOCK |
|
90 |
+", FAST_LOCK" |
|
91 |
+#endif |
|
86 | 92 |
; |
87 | 93 |
|
88 | 94 |
static char help_msg[]= "\ |
... | ... |
@@ -537,7 +543,9 @@ int main(int argc, char** argv) |
537 | 543 |
printf("flags: %s\n", flags ); |
538 | 544 |
print_ct_constants(); |
539 | 545 |
printf("%s\n",id); |
540 |
- printf("%s compiled on %s at %s\n", __FILE__, __DATE__, __TIME__ ); |
|
546 |
+ printf("%s compiled on %s at %s with %s\n", __FILE__, |
|
547 |
+ __DATE__, __TIME__, COMPILER ); |
|
548 |
+ |
|
541 | 549 |
exit(0); |
542 | 550 |
break; |
543 | 551 |
case 'h': |
... | ... |
@@ -647,15 +655,15 @@ int main(int argc, char** argv) |
647 | 655 |
if (working_dir==0) working_dir="/"; |
648 | 656 |
/*alloc pids*/ |
649 | 657 |
#ifdef SHM_MEM |
650 |
- pids=shm_malloc(sizeof(int)*children_no); |
|
658 |
+ pids=shm_malloc(sizeof(int)*(children_no+1)); |
|
651 | 659 |
#else |
652 |
- pids=malloc(sizeof(int)*children_no); |
|
660 |
+ pids=malloc(sizeof(int)*(children_no+1)); |
|
653 | 661 |
#endif |
654 | 662 |
if (pids==0){ |
655 | 663 |
fprintf(stderr, "ERROR: out of memory\n"); |
656 | 664 |
goto error; |
657 | 665 |
} |
658 |
- memset(pids, 0, sizeof(int)*children_no); |
|
666 |
+ memset(pids, 0, sizeof(int)*(children_no+1)); |
|
659 | 667 |
|
660 | 668 |
if (addresses_no==0) { |
661 | 669 |
/* 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 | 31 |
/*init mem*/ |
30 | 32 |
#ifdef VQ_MALLOC |
31 | 33 |
mem_block=vqm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE); |
34 |
+ #elif F_MALLOC |
|
35 |
+ mem_block=fm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE); |
|
32 | 36 |
#else |
33 | 37 |
mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE); |
34 | 38 |
#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 | 31 |
__FUNCTION__, __LINE__); |
29 | 32 |
# define pkg_free(p) vqm_free(mem_block, (p), __FILE__, \ |
30 | 33 |
__FUNCTION__, __LINE__); |
34 |
+# elif defined F_MALLOC |
|
35 |
+# define pkg_malloc(s) fm_malloc(mem_block, (s),__FILE__, \ |
|
36 |
+ __FUNCTION__, __LINE__); |
|
37 |
+# define pkg_free(p) fm_free(mem_block, (p), __FILE__, \ |
|
38 |
+ __FUNCTION__, __LINE__); |
|
31 | 39 |
# else |
32 | 40 |
# define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, \ |
33 | 41 |
__FUNCTION__, __LINE__); |
... | ... |
@@ -38,6 +46,9 @@ |
38 | 46 |
# ifdef VQ_MALLOC |
39 | 47 |
# define pkg_malloc(s) vqm_malloc(mem_block, (s)) |
40 | 48 |
# define pkg_free(p) vqm_free(mem_block, (p)) |
49 |
+# elif defined F_MALLOC |
|
50 |
+# define pkg_malloc(s) fm_malloc(mem_block, (s)) |
|
51 |
+# define pkg_free(p) fm_free(mem_block, (p)) |
|
41 | 52 |
# else |
42 | 53 |
# define pkg_malloc(s) qm_malloc(mem_block, (s)) |
43 | 54 |
# define pkg_free(p) qm_free(mem_block, (p)) |
... | ... |
@@ -45,6 +56,8 @@ |
45 | 56 |
# endif |
46 | 57 |
# ifdef VQ_MALLOC |
47 | 58 |
# define pkg_status() vqm_status(mem_block) |
59 |
+# elif defined F_MALLOC |
|
60 |
+# define pkg_status() fm_status(mem_block) |
|
48 | 61 |
# else |
49 | 62 |
# define pkg_status() qm_status(mem_block) |
50 | 63 |
# 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 | 338 |
DBG("qm_free: freeing block alloc'ed from %s: %s(%d)\n", f->file, f->func, |
340 | 339 |
f->line); |
341 | 340 |
#endif |
342 |
- next=FRAG_NEXT(f); |
|
343 | 341 |
size=f->size; |
344 | 342 |
qm->used-=size; |
345 | 343 |
qm->real_used-=size; |
... | ... |
@@ -349,7 +347,7 @@ void qm_free(struct qm_block* qm, void* p) |
349 | 347 |
|
350 | 348 |
#ifdef QM_JOIN_FREE |
351 | 349 |
/* join packets if possible*/ |
352 |
- |
|
350 |
+ next=FRAG_NEXT(f); |
|
353 | 351 |
if (((char*)next < (char*)qm->last_frag_end) &&( next->u.is_free)){ |
354 | 352 |
/* join */ |
355 | 353 |
qm_detach_free(qm, next); |
... | ... |
@@ -399,32 +397,27 @@ void qm_status(struct qm_block* qm) |
399 | 397 |
qm->used, qm->real_used, qm->size-qm->real_used); |
400 | 398 |
LOG(L_INFO, " max used (+overhead)= %d\n", qm->max_real_used); |
401 | 399 |
|
402 |
- LOG(L_INFO, "dumping all fragments:\n"); |
|
400 |
+ LOG(L_INFO, "dumping all allocked. fragments:\n"); |
|
403 | 401 |
for (f=qm->first_frag, i=0;(char*)f<(char*)qm->last_frag_end;f=FRAG_NEXT(f) |
404 | 402 |
,i++){ |
405 |
- LOG(L_INFO, " %3d. %c address=%x size=%d\n", i, |
|
403 |
+ if (! f->u.is_free){ |
|
404 |
+ LOG(L_INFO, " %3d. %c address=%x size=%d\n", i, |
|
406 | 405 |
(f->u.is_free)?'a':'N', |
407 | 406 |
(char*)f+sizeof(struct qm_frag), f->size); |
408 | 407 |
#ifdef DBG_QM_MALLOC |
409 |
- LOG(L_INFO, " %s from %s: %s(%d)\n", |
|
408 |
+ LOG(L_INFO, " %s from %s: %s(%d)\n", |
|
410 | 409 |
(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", |
|
410 |
+ LOG(L_INFO, " start check=%x, end check= %x, %x\n", |
|
412 | 411 |
f->check, FRAG_END(f)->check1, FRAG_END(f)->check2); |
413 | 412 |
#endif |
413 |
+ } |
|
414 | 414 |
} |
415 |
- LOG(L_INFO, "dumping free list:\n"); |
|
415 |
+ LOG(L_INFO, "dumping free list stats :\n"); |
|
416 | 416 |
for(h=0,i=0;h<QM_HASH_SIZE;h++){ |
417 | 417 |
|
418 | 418 |
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 |
- } |
|
419 |
+ f!=&(qm->free_hash[h].head); f=f->u.nxt_free, i++, j++); |
|
420 |
+ if (j) LOG(L_INFO, "hash= %3d. fragments no.: %5d\n", h, j); |
|
428 | 421 |
} |
429 | 422 |
LOG(L_INFO, "-----------------------------\n"); |
430 | 423 |
} |
... | ... |
@@ -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 | 50 |
#ifdef DBG_QM_MALLOC |
48 | 51 |
unsigned int check1; |
49 | 52 |
unsigned int check2; |
53 |
+ unsigned int reserved1; |
|
54 |
+ unsigned int reserved2; |
|
50 | 55 |
#endif |
51 | 56 |
unsigned int size; |
52 | 57 |
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 | 186 |
/* init it for malloc*/ |
185 | 187 |
# ifdef VQ_MALLOC |
186 | 188 |
shm_block=vqm_malloc_init(shm_mempool, SHM_MEM_SIZE); |
189 |
+ #elif defined F_MALLOC |
|
190 |
+ shm_block=fm_malloc_init(shm_mempool, SHM_MEM_SIZE); |
|
187 | 191 |
# else |
188 | 192 |
shm_block=qm_malloc_init(shm_mempool, SHM_MEM_SIZE); |
189 | 193 |
# 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; |
... | ... |
@@ -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 | 104 |
//hash_code+=crc_32_tab[(cseq_nr.s[i]+hash_code)%243]; |
65 | 105 |
hash_code+=ccitt_tab[*(cs+i)+123]; |
66 | 106 |
|
67 |
- hash_code %= (TABLE_ENTRIES-1); |
|
107 |
+ hash_code &= (TABLE_ENTRIES-1); /* TABLE_ENTRIES = 2^k */ |
|
68 | 108 |
return hash_code; |
69 | 109 |
} |
70 | 110 |
|
... | ... |
@@ -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 | 858 |
pkg_free(msg->orig); |
858 | 859 |
/* don't free anymore -- now a pointer to a static buffer */ |
859 | 860 |
# ifdef DYN_BUF |
860 |
- pkg_free(msg->buf); */ |
|
861 |
+ pkg_free(msg->buf); |
|
861 | 862 |
# endif |
862 | 863 |
} |
863 | 864 |
|
... | ... |
@@ -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 |
|