Browse code

- fixed macros ("(",")", do{}while(0)). - small Makefile changes

Andrei Pelinescu-Onciul authored on 08/12/2001 14:20:09
Showing 4 changed files
... ...
@@ -3,10 +3,10 @@
3 3
 # sip_router makefile
4 4
 #
5 5
 # WARNING: requires gmake (GNU Make)
6
-#  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 6), WinNT
6
+#  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 6), WinNT (cygwin)
7 7
 
8 8
 auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
9
-exclude_modules=CVS
9
+exclude_modules=CVS usrloc
10 10
 sources=$(filter-out $(auto_gen), $(wildcard *.c)) $(auto_gen)
11 11
 objs=$(sources:.c=.o)
12 12
 depends=$(sources:.c=.d)
... ...
@@ -99,7 +99,7 @@ ifneq (,$(findstring CYGWIN, $(ARCH)))
99 99
 endif
100 100
 
101 101
 
102
-MKDEP=gcc -M $(DEFS)
102
+MKDEP=gcc -MM $(DEFS)
103 103
 
104 104
 ALLDEP=Makefile
105 105
 
... ...
@@ -110,8 +110,10 @@ export #export all variables for the sub-makes
110 110
 %.o:%.c $(ALLDEP)
111 111
 	$(CC) $(CFLAGS) $(DEFS) -c $< -o $@
112 112
 
113
-%.d: %.c
114
-	$(MKDEP) $< >$@
113
+%.d: %.c $(ALLDEP)
114
+	set -e; $(MKDEP) $< \
115
+	|  sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
116
+	[ -s $@ ] || rm -f $@
115 117
 
116 118
 
117 119
 # normal rules
... ...
@@ -134,19 +136,21 @@ dep: $(depends)
134 136
 
135 137
 .PHONY: clean
136 138
 clean:
137
-	-rm $(objs) $(NAME)
139
+	-rm $(objs) $(NAME) 2>/dev/null
138 140
 	-for r in $(modules); do $(MAKE) -C $$r clean ; done
139 141
 
140 142
 .PHONY: modules
141 143
 modules:
142 144
 	-for r in $(modules); do \
145
+		echo  "" ; \
146
+		echo  "" ; \
143 147
 		$(MAKE) -C $$r ; \
144 148
 	done
145 149
 
146 150
 
147 151
 .PHONY: proper
148 152
 proper: clean 
149
-	-rm $(depends)
153
+	-rm $(depends) 2>/dev/null
150 154
 	-for r in $(modules); do $(MAKE) -C $$r proper ; done
151 155
 
152 156
 include $(depends)
... ...
@@ -6,34 +6,54 @@
6 6
 #include "../../timer.h"
7 7
 
8 8
 #define stop_RETR_and_FR_timers(h_table,p_cell)    \
9
-           { int ijk; \
10
-           if ( p_cell->outbound_response )  {  \
11
-               remove_from_timer_list( h_table , (&(p_cell->outbound_response->tl[RETRASMISSIONS_LIST])) , RETRASMISSIONS_LIST ); \
12
-               remove_from_timer_list( h_table , (&(p_cell->outbound_response->tl[FR_TIMER_LIST])) , FR_TIMER_LIST ); } \
13
-           for( ijk=0 ; ijk<p_cell->nr_of_outgoings ; ijk++ )  { \
14
-               remove_from_timer_list( h_table , (&(p_cell->outbound_request[ijk]->tl[RETRASMISSIONS_LIST])) , RETRASMISSIONS_LIST ); \
15
-               remove_from_timer_list( h_table , (&(p_cell->outbound_request[ijk]->tl[FR_TIMER_LIST])) , FR_TIMER_LIST ); } \
16
-           }
9
+	do{ int ijk; \
10
+		if ( (p_cell)->outbound_response )  {  \
11
+			remove_from_timer_list( \
12
+				(h_table) , \
13
+				(&((p_cell)->outbound_response->tl[RETRASMISSIONS_LIST])), \
14
+				RETRASMISSIONS_LIST\
15
+			); \
16
+			remove_from_timer_list( (h_table), \
17
+					(&((p_cell)->outbound_response->tl[FR_TIMER_LIST])), \
18
+					FR_TIMER_LIST );\
19
+		} \
20
+		for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  { \
21
+			remove_from_timer_list( \
22
+				(h_table) , \
23
+				(&((p_cell)->outbound_request[ijk]->tl[RETRASMISSIONS_LIST])),\
24
+				RETRASMISSIONS_LIST \
25
+			); \
26
+			remove_from_timer_list( (h_table) , \
27
+				(&((p_cell)->outbound_request[ijk]->tl[FR_TIMER_LIST])), \
28
+				FR_TIMER_LIST ); \
29
+		} \
30
+	}while(0)
31
+
17 32
 
18 33
 #define insert_into_timer(hash_table,new_tl,list_id,time_out) \
19
-             {\
20
-                if ( is_in_timer_list(new_tl,list_id)  )\
21
-                   remove_from_timer_list( hash_table , new_tl , list_id);\
22
-                insert_into_timer_list(hash_table,new_tl,list_id,get_ticks()+time_out);\
23
-             }
34
+	do{\
35
+		if ( is_in_timer_list((new_tl),(list_id))  )\
36
+			remove_from_timer_list( (hash_table) , (new_tl) ,\
37
+								(list_id));\
38
+			insert_into_timer_list((hash_table), (new_tl), (list_id),\
39
+								get_ticks()+(time_out));\
40
+	}while(0)
41
+
24 42
 
25 43
 #define add_to_tail_of_timer(hash_table,new_tl,list_id,time_out) \
26
-             {\
27
-                if ( is_in_timer_list(new_tl,list_id)  )\
28
-                   remove_from_timer_list( hash_table , new_tl , list_id);\
29
-                add_to_tail_of_timer_list(hash_table,new_tl,list_id,get_ticks()+time_out);\
30
-             }
44
+	 do{\
45
+		if ( is_in_timer_list((new_tl), (list_id))  )\
46
+			remove_from_timer_list((hash_table), (new_tl), (list_id));\
47
+			add_to_tail_of_timer_list((hash_table), (new_tl), \
48
+								(list_id), get_ticks()+(time_out));\
49
+	}while(0)
50
+
31 51
 
32 52
 #define remove_from_timer(hash_table,tl,list_id) \
33
-             {\
34
-                if ( !is_in_timer_list(tl,list_id)  )\
35
-                   remove_from_timer_list( hash_table , tl , list_id);\
36
-             }
53
+	 do{\
54
+		if ( !is_in_timer_list((tl), (list_id))  )\
55
+			remove_from_timer_list( (hash_table), (tl), (list_id));\
56
+	}while(0)
37 57
 
38 58
 
39 59
 
... ...
@@ -41,7 +41,7 @@ enum{
41 41
 };
42 42
 
43 43
 /* casting macro for accessing CSEQ body */
44
-#define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
44
+#define get_cseq( p_msg)    ((struct cseq_body*)(p_msg)->cseq->parsed)
45 45
 
46 46
 
47 47
 
... ...
@@ -11,15 +11,16 @@
11 11
 
12 12
 /*usefull macros*/
13 13
 #define FRAG_END(f)  \
14
-			((struct qm_frag_end*)((char*)f+sizeof(struct qm_frag)+f->size))
14
+			((struct qm_frag_end*)((char*)(f)+sizeof(struct qm_frag)+ \
15
+								   (f)->size))
15 16
 
16 17
 #define FRAG_NEXT(f) \
17
-			((struct qm_frag*)((char*)f+sizeof(struct qm_frag)+f->size+ \
18
+			((struct qm_frag*)((char*)(f)+sizeof(struct qm_frag)+(f)->size+ \
18 19
 							   sizeof(struct qm_frag_end)))
19 20
 			
20 21
 #define FRAG_PREV(f) \
21
-		( (struct qm_frag*) ( ((char*)f-sizeof(struct qm_frag_end))- \
22
-		((struct qm_frag_end*)((char*)f-sizeof(struct qm_frag_end)))->size- \
22
+		( (struct qm_frag*) ( ((char*)(f)-sizeof(struct qm_frag_end))- \
23
+		((struct qm_frag_end*)((char*)(f)-sizeof(struct qm_frag_end)))->size- \
23 24
 			sizeof(struct qm_frag) ) )
24 25
 
25 26