Browse code

core: timer - coherent indentation and whitespacing

Daniel-Constantin Mierla authored on 05/05/2016 06:28:19
Showing 7 changed files
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * time related functions
3 3
  *
4 4
  * Copyright (C) 2006 iptelorg GmbH
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 
... ...
@@ -62,8 +62,8 @@ static ticks_t* ticks=0;
62 62
 static ticks_t last_ticks; /* last time we adjusted the time */
63 63
 static ticks_t last_adj_check; /* last time we ran adjust_ticks */
64 64
 static ticks_t prev_ticks; /* last time we ran the timer, also used as
65
-							  "current" ticks when running the timer for
66
-							  "skipped" ticks */
65
+							*  "current" ticks when running the timer for
66
+							*  "skipped" ticks */
67 67
 
68 68
 static struct timeval last_time;
69 69
 static struct timeval start_time; /* for debugging */
... ...
@@ -100,11 +100,11 @@ static int in_timer=0;
100 100
 
101 101
 
102 102
 static gen_lock_t*  slow_timer_lock; /* slow timer lock */
103
-static struct timer_head* slow_timer_lists; 
103
+static struct timer_head* slow_timer_lists;
104 104
 static volatile unsigned short* t_idx; /* "main" timer index in slow_lists[] */
105 105
 static volatile unsigned short* s_idx; /* "slow" timer index in slow_lists[] */
106 106
 static struct timer_ln* volatile* running_timer2=0; /* timer handler running
107
-													     in the "slow" timer */
107
+													 * in the "slow" timer */
108 108
 static sigset_t slow_timer_sset;
109 109
 pid_t slow_timer_pid;
110 110
 static int in_slow_timer=0;
... ...
@@ -137,10 +137,10 @@ void sig_timer(int signo)
137 137
 void destroy_timer()
138 138
 {
139 139
 	struct itimerval it;
140
-	
140
+
141 141
 	/* disable timer */
142 142
 	memset(&it, 0, sizeof(it));
143
-	setitimer(ITIMER_REAL, &it, 0); 
143
+	setitimer(ITIMER_REAL, &it, 0);
144 144
 	set_sig_h(SIGALRM, SIG_IGN);
145 145
 	if (timer_lock){
146 146
 		lock_destroy(timer_lock);
... ...
@@ -199,9 +199,9 @@ int init_timer()
199 199
 {
200 200
 	int r;
201 201
 	int ret;
202
-	
202
+
203 203
 	ret=-1;
204
-	
204
+
205 205
 	/* init the locks */
206 206
 	timer_lock=lock_alloc();
207 207
 	if (timer_lock==0){
... ...
@@ -253,7 +253,7 @@ int init_timer()
253 253
 	}
254 254
 	last_time=start_time;
255 255
 	LM_DBG("starting with *ticks=%u\n", (unsigned) *ticks);
256
-	
256
+
257 257
 	/* init timer structures */
258 258
 	for (r=0; r<H0_ENTRIES; r++)
259 259
 		_timer_init_list(&timer_lst->h0[r]);
... ...
@@ -262,9 +262,9 @@ int init_timer()
262 262
 	for (r=0; r<H2_ENTRIES; r++)
263 263
 		_timer_init_list(&timer_lst->h2[r]);
264 264
 	_timer_init_list(&timer_lst->expired);
265
-	
265
+
266 266
 #ifdef USE_SLOW_TIMER
267
-	
267
+
268 268
 	/* init the locks */
269 269
 	slow_timer_lock=lock_alloc();
270 270
 	if (slow_timer_lock==0){
... ...
@@ -290,9 +290,9 @@ int init_timer()
290 290
 	*running_timer2=0;
291 291
 	for (r=0; r<SLOW_LISTS_NO; r++)
292 292
 		_timer_init_list(&slow_timer_lists[r]);
293
-	
293
+
294 294
 #endif
295
-	
295
+
296 296
 	LM_DBG("timer_list between %p and %p\n",
297 297
 			&timer_lst->h0[0], &timer_lst->h2[H2_ENTRIES]);
298 298
 	return 0;
... ...
@@ -304,7 +304,7 @@ error:
304 304
 
305 305
 
306 306
 #ifdef USE_SLOW_TIMER
307
-/* arm the "slow" timer ( start it) 
307
+/* arm the "slow" timer ( start it)
308 308
  * returns -1 on error
309 309
  * WARNING: use it in the same process as the timer
310 310
  *  (the one using pause(); timer_handler()) or
... ...
@@ -321,7 +321,7 @@ again:
321 321
 	}
322 322
 #ifdef __OS_darwin
323 323
 	/* workaround for darwin sigwait bug, see slow_timer_main() for more
324
-	   info (or grep __OS_darwin) */
324
+	 * info (or grep __OS_darwin) */
325 325
 	/* keep in sync wih main.c: sig_usr() - signals we are interested in */
326 326
 	sigaddset(&slow_timer_sset, SIGINT);
327 327
 	sigaddset(&slow_timer_sset, SIGTERM);
... ...
@@ -342,7 +342,7 @@ error:
342 342
 
343 343
 
344 344
 
345
-/* arm the timer ( start it) 
345
+/* arm the timer ( start it)
346 346
  * returns -1 on error
347 347
  * WARNING: use it in the same process as the timer
348 348
  *  (the one using pause(); timer_handler()) or
... ...
@@ -398,7 +398,7 @@ inline static void adjust_ticks(void)
398 398
 	ticks_t diff_time_ticks;
399 399
 	ticks_t diff_ticks_raw;
400 400
 	s_ticks_t delta;
401
-	
401
+
402 402
 	/* fix ticks if necessary */
403 403
 	if ((*ticks-last_adj_check)>=(ticks_t)TIMER_RESYNC_TICKS){
404 404
 #ifdef DBG_ser_time
... ...
@@ -423,7 +423,7 @@ inline static void adjust_ticks(void)
423 423
 			if (delta<-1){
424 424
 				LM_WARN("our timer runs faster then real-time"
425 425
 						" (%lu ms / %u ticks our time .->"
426
-						 " %lu ms / %u ticks real time)\n", 
426
+						" %lu ms / %u ticks real time)\n",
427 427
 						(unsigned long)(diff_ticks_raw*1000L/TIMER_TICKS_HZ),
428 428
 						diff_ticks_raw,
429 429
 						(unsigned long)(diff_time/1000), diff_time_ticks);
... ...
@@ -463,7 +463,7 @@ time_t ser_time(time_t *t)
463 463
 
464 464
 
465 465
 
466
-/* gettimeofday(2) equivalent, using ser internal timers (faster 
466
+/* gettimeofday(2) equivalent, using ser internal timers (faster
467 467
  * but more imprecise)
468 468
  * WARNING: ignores tz (it's obsolete anyway)*/
469 469
 int ser_gettimeofday(struct timeval* tv, struct timezone* tz)
... ...
@@ -485,22 +485,22 @@ void check_ser_drift()
485 485
 	time_t t1, t2;
486 486
 	struct timeval tv1, tv2;
487 487
 	int r;
488
-	
488
+
489 489
 	t1=time(0);
490 490
 	t2=ser_time(0);
491 491
 	if (t1!=t2)
492 492
 		BUG("time(0)!=ser_time(0) : %d != %d \n", (unsigned)t1, (unsigned)t2);
493
-	
493
+
494 494
 	r=gettimeofday(&tv1, 0);
495 495
 	ser_gettimeofday(&tv2, 0);
496 496
 	if (tv1.tv_sec!=tv2.tv_sec)
497 497
 		BUG("gettimeofday seconds!=ser_gettimeofday seconds : %d != %d \n",
498 498
 				(unsigned)tv1.tv_sec, (unsigned)tv2.tv_sec);
499
-	else if ((tv1.tv_usec > tv2.tv_usec) && 
499
+	else if ((tv1.tv_usec > tv2.tv_usec) &&
500 500
 				(unsigned)(tv1.tv_usec-tv2.tv_usec)>100000)
501 501
 		BUG("gettimeofday usecs > ser_gettimeofday with > 0.1s : %d ms\n",
502 502
 			(unsigned)(tv1.tv_usec-tv2.tv_usec)/1000);
503
-	else if ((tv1.tv_usec < tv2.tv_usec) && 
503
+	else if ((tv1.tv_usec < tv2.tv_usec) &&
504 504
 				(unsigned)(tv2.tv_usec-tv1.tv_usec)>100000)
505 505
 		BUG("gettimeofday usecs < ser_gettimeofday with > 0.1s : %d ms\n",
506 506
 			(unsigned)(tv2.tv_usec-tv1.tv_usec)/1000);
... ...
@@ -555,7 +555,7 @@ int timer_add_safe(struct timer_ln* tl, ticks_t delta)
555 555
 #endif
556 556
 {
557 557
 	int ret;
558
-	
558
+
559 559
 	LOCK_TIMER_LIST();
560 560
 	if (tl->flags & F_TIMER_ACTIVE){
561 561
 #ifdef TIMER_DEBUG
... ...
@@ -600,7 +600,7 @@ error:
600 600
 
601 601
 /* safe timer delete
602 602
  * deletes tl and inits the list pointer to 0
603
- * returns  <0 on error (-1 if timer not active/already deleted and -2 if 
603
+ * returns  <0 on error (-1 if timer not active/already deleted and -2 if
604 604
  *           delete attempted from the timer handler) and 0 on success
605 605
  */
606 606
 #ifdef TIMER_DEBUG
... ...
@@ -611,7 +611,7 @@ int timer_del_safe(struct timer_ln* tl)
611 611
 #endif
612 612
 {
613 613
 	int ret;
614
-	
614
+
615 615
 	ret=-1;
616 616
 again:
617 617
 	/* quick exit if timer inactive */
... ...
@@ -656,7 +656,7 @@ again:
656 656
 						", last from: %s(%s):%d, deleted %d times"
657 657
 						", last from: %s(%s):%d, init %d times, expired %d \n",
658 658
 						tl->add_calls, tl->add_func, tl->add_file,
659
-						tl->add_line, tl->del_calls, tl->del_func, 
659
+						tl->add_line, tl->del_calls, tl->del_func,
660 660
 						tl->del_file, tl->del_line, tl->init, tl->expires_no);
661 661
 #endif
662 662
 					return -2; /* do nothing */
... ...
@@ -680,7 +680,7 @@ again:
680 680
 							"already detached\n",
681 681
 							tl, tl->next, tl->prev, tl->flags);
682 682
 				LOG(timerlog, "WARN: -timer_del-: @%d tl=%p "
683
-					"{ %p, %p, %d, %d, %p, %p, %04x, -}\n", get_ticks_raw(), 
683
+					"{ %p, %p, %d, %d, %p, %p, %04x, -}\n", get_ticks_raw(),
684 684
 					tl,  tl->next, tl->prev, tl->expire, tl->initial_timeout,
685 685
 					tl->data, tl->f, tl->flags);
686 686
 				LOG(timerlog, "WARN: -timer_del-; called from %s(%s):%d\n",
... ...
@@ -726,7 +726,7 @@ again:
726 726
 						", last from: %s(%s):%d, deleted %d times"
727 727
 						", last from: %s(%s):%d, init %d times, expired %d \n",
728 728
 						tl->add_calls, tl->add_func, tl->add_file,
729
-						tl->add_line, tl->del_calls, tl->del_func, 
729
+						tl->add_line, tl->del_calls, tl->del_func,
730 730
 						tl->del_file, tl->del_line, tl->init, tl->expires_no);
731 731
 #endif
732 732
 					return -2; /* do nothing */
... ...
@@ -750,7 +750,7 @@ again:
750 750
 							"already detached\n",
751 751
 							tl, tl->next, tl->prev, tl->flags);
752 752
 				LOG(timerlog, "WARN: -timer_del-: @%d tl=%p "
753
-					"{ %p, %p, %d, %d, %p, %p, %04x, -}\n", get_ticks_raw(), 
753
+					"{ %p, %p, %d, %d, %p, %p, %04x, -}\n", get_ticks_raw(),
754 754
 					tl,  tl->next, tl->prev, tl->expire, tl->initial_timeout,
755 755
 					tl->data, tl->f, tl->flags);
756 756
 				LOG(timerlog, "WARN: -timer_del-; called from %s(%s):%d\n",
... ...
@@ -782,10 +782,10 @@ return ret;
782 782
 
783 783
 
784 784
 /* marks a timer as "to be deleted when the handler ends", usefull when
785
- * the timer handler knows it won't prolong the timer anymore (it will 
785
+ * the timer handler knows it won't prolong the timer anymore (it will
786 786
  * return 0) and will do some time consuming work. Calling this function
787
- * will cause simultaneous timer_dels to return immediately (they won't 
788
- * wait anymore for the timer handle to finish). It will also allow 
787
+ * will cause simultaneous timer_dels to return immediately (they won't
788
+ * wait anymore for the timer handle to finish). It will also allow
789 789
  * self-deleting from the timer handle without bug reports.
790 790
  * WARNING: - if you rely on timer_del to know when the timer handle execution
791 791
  *            finishes (e.g. to free resources used in the timer handle), don't
... ...
@@ -802,7 +802,7 @@ void timer_allow_del(void)
802 802
 #ifdef USE_SLOW_TIMER
803 803
 	if (IS_IN_TIMER_SLOW()){
804 804
 			UNSET_RUNNING_SLOW();
805
-	}else 
805
+	}else
806 806
 #endif
807 807
 		LM_CRIT("timer_allow_del called outside a timer handle\n");
808 808
 }
... ...
@@ -824,10 +824,10 @@ inline static void timer_list_expire(ticks_t t, struct timer_head* h
824 824
 #ifdef TIMER_DEBUG
825 825
 	struct timer_ln* first;
826 826
 	int i=0;
827
-	
827
+
828 828
 	first=h->next;
829 829
 #endif
830
-	
830
+
831 831
 	/*LM_DBG("@ ticks = %lu, list =%p\n",
832 832
 			(unsigned long) *ticks, h);
833 833
 	*/
... ...
@@ -841,9 +841,9 @@ inline static void timer_list_expire(ticks_t t, struct timer_head* h
841 841
 		}else if((tl->next==0) || (tl->prev==0)){
842 842
 			LM_CRIT("timer_list_expire: @%d tl=%p "
843 843
 					"{ %p, %p, %d, %d, %p, %p, %04x, -},"
844
-					" h=%p {%p, %p}\n", t, 
844
+					" h=%p {%p, %p}\n", t,
845 845
 					tl,  tl->next, tl->prev, tl->expire, tl->initial_timeout,
846
-					tl->data, tl->f, tl->flags, 
846
+					tl->data, tl->f, tl->flags,
847 847
 					h, h->next, h->prev);
848 848
 			LM_CRIT("-timer_list_expire-: cycle %d, first %p,"
849 849
 						"running %p\n", i, first, *running_timer);
... ...
@@ -869,7 +869,7 @@ inline static void timer_list_expire(ticks_t t, struct timer_head* h
869 869
 #ifdef TIMER_DEBUG
870 870
 			tl->expires_no++;
871 871
 #endif
872
-			UNLOCK_TIMER_LIST(); /* acts also as write barrier */ 
872
+			UNLOCK_TIMER_LIST(); /* acts also as write barrier */
873 873
 				ret=tl->f(t, tl, tl->data);
874 874
 				/* reset the configuration group handles */
875 875
 				cfg_reset_all();
... ...
@@ -891,7 +891,7 @@ inline static void timer_list_expire(ticks_t t, struct timer_head* h
891 891
 			tl->slow_idx=slow_mark; /* current index */
892 892
 			/* overflow check in timer_handler*/
893 893
 			_timer_add_list(slow_l, tl);
894
-			
894
+
895 895
 		}
896 896
 #endif
897 897
 	}
... ...
@@ -909,11 +909,11 @@ static void timer_handler(void)
909 909
 #ifdef USE_SLOW_TIMER
910 910
 	int run_slow_timer;
911 911
 	int i;
912
-	
912
+
913 913
 	run_slow_timer=0;
914 914
 	i=(slow_idx_t)(*t_idx%SLOW_LISTS_NO);
915 915
 #endif
916
-	
916
+
917 917
 	/*LM_DBG("called, ticks=%lu, prev_ticks=%lu\n",
918 918
 			(unsigned long)*ticks, (unsigned long)prev_ticks);
919 919
 	*/
... ...
@@ -930,7 +930,7 @@ static void timer_handler(void)
930 930
 		}
931 931
 		/* go through all the "missed" ticks, taking a possible overflow
932 932
 		 * into account */
933
-		for (prev_ticks=prev_ticks+1; prev_ticks!=saved_ticks; prev_ticks++) 
933
+		for (prev_ticks=prev_ticks+1; prev_ticks!=saved_ticks; prev_ticks++)
934 934
 			timer_run(prev_ticks);
935 935
 		timer_run(prev_ticks); /* do it for saved_ticks too */
936 936
 	}while(saved_ticks!=*ticks); /* in case *ticks changed */
... ...
@@ -987,7 +987,7 @@ static ticks_t compat_old_handler(ticks_t ti, struct timer_ln* tl,
987 987
 									void * data)
988 988
 {
989 989
 	struct sr_timer* t;
990
-	
990
+
991 991
 #ifdef TIMER_DEBUG
992 992
 	LM_DBG("calling, ticks=%u/%u, tl=%p, t=%p\n",
993 993
 			prev_ticks, (unsigned)*ticks, tl, data);
... ...
@@ -1002,7 +1002,7 @@ static ticks_t compat_old_handler(ticks_t ti, struct timer_ln* tl,
1002 1002
 /* register a periodic timer;
1003 1003
  * compatibility mode.w/ the old timer interface...
1004 1004
  * ret: <0 on error
1005
- * Hint: if you need it in a module, register it from mod_init or it 
1005
+ * Hint: if you need it in a module, register it from mod_init or it
1006 1006
  * won't work otherwise*/
1007 1007
 int register_timer(timer_function f, void* param, unsigned int interval)
1008 1008
 {
... ...
@@ -1016,13 +1016,13 @@ int register_timer(timer_function f, void* param, unsigned int interval)
1016 1016
 	t->id=timer_id++;
1017 1017
 	t->timer_f=f;
1018 1018
 	t->t_param=param;
1019
-	
1019
+
1020 1020
 	timer_init(&t->tl, compat_old_handler, t, 0); /* is slow */
1021 1021
 	if (timer_add(&t->tl, S_TO_TICKS(interval))!=0){
1022 1022
 		LM_ERR("timer_add failed\n");
1023 1023
 		return -1;
1024 1024
 	}
1025
-	
1025
+
1026 1026
 	return t->id;
1027 1027
 
1028 1028
 error:
... ...
@@ -1083,7 +1083,7 @@ void slow_timer_main()
1083 1083
 #ifdef USE_SIGWAIT
1084 1084
 	int sig;
1085 1085
 #endif
1086
-	
1086
+
1087 1087
 	in_slow_timer=1; /* mark this process as the slow timer */
1088 1088
 	while(1){
1089 1089
 #ifdef USE_SIGWAIT
... ...
@@ -1101,11 +1101,11 @@ void slow_timer_main()
1101 1101
 	if (sig!=SLOW_TIMER_SIG){
1102 1102
 #ifdef __OS_darwin
1103 1103
 		/* on darwin sigwait is buggy: it will cause extreme slow down
1104
-		   on signal delivery for the signals it doesn't wait on
1105
-		   (on darwin 8.8.0, g4 1.5Ghz I've measured a 36s delay!).
1106
-		  To work arround this bug, we sigwait() on all the signals we
1107
-		  are interested in ser and manually call the master signal handler 
1108
-		  if the signal!= slow timer signal -- andrei */
1104
+		 *  on signal delivery for the signals it doesn't wait on
1105
+		 *  (on darwin 8.8.0, g4 1.5Ghz I've measured a 36s delay!).
1106
+		 * To work arround this bug, we sigwait() on all the signals we
1107
+		 * are interested in ser and manually call the master signal handler
1108
+		 * if the signal!= slow timer signal -- andrei */
1109 1109
 		sig_usr(sig);
1110 1110
 #endif
1111 1111
 		continue;
... ...
@@ -1113,7 +1113,7 @@ void slow_timer_main()
1113 1113
 #endif
1114 1114
 		/* update the local cfg if needed */
1115 1115
 		cfg_update();
1116
-		
1116
+
1117 1117
 		LOCK_SLOW_TIMER_LIST();
1118 1118
 		while(*s_idx!=*t_idx){
1119 1119
 			i= *s_idx%SLOW_LISTS_NO;
... ...
@@ -1150,7 +1150,7 @@ void slow_timer_main()
1150 1150
 		}
1151 1151
 		UNLOCK_SLOW_TIMER_LIST();
1152 1152
 	}
1153
-	
1153
+
1154 1154
 }
1155 1155
 
1156 1156
 #endif
... ...
@@ -15,8 +15,8 @@
15 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 16
  * GNU General Public License for more details.
17 17
  *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
20 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 21
  */
22 22
 /**
... ...
@@ -41,8 +41,8 @@
41 41
 #ifndef timer_h
42 42
 #define timer_h
43 43
 
44
-#define USE_SLOW_TIMER /* use another process to run the timer handlers 
45
-						  marked "slow" */
44
+#define USE_SLOW_TIMER /* use another process to run the timer handlers
45
+						*  marked "slow" */
46 46
 /*#define TIMER_DEBUG -- compile with -DTIMER_DEBUG*/
47 47
 
48 48
 #include "clist.h"
... ...
@@ -62,7 +62,7 @@ extern pid_t slow_timer_pid;
62 62
 
63 63
 /* deprecated, old, kept for compatibility */
64 64
 typedef void (timer_function)(unsigned int ticks, void* param);
65
-/* deprecated, old, kept for compatibility 
65
+/* deprecated, old, kept for compatibility
66 66
 	get_ticks()*TIMER_TICK used to be the time in s
67 67
 	for new code, use get_ticks_raw() and one of the macros defined in
68 68
 	timer_ticks.h (.e.g TICKS_TO_S(tick) to convert to s or ms )*/
... ...
@@ -72,7 +72,7 @@ typedef void (timer_function)(unsigned int ticks, void* param);
72 72
 typedef void (utimer_function)(unsigned int uticks, void* param);
73 73
 
74 74
 struct timer_ln; /* forward decl */
75
-/* new 
75
+/* new
76 76
  * params:
77 77
  *         - handle pointer to the corresponding struct timer_ln
78 78
  * return: 0 if the timer is one shot, new expire interval if not, -1
... ...
@@ -89,19 +89,19 @@ typedef ticks_t (timer_handler_f)(ticks_t t, struct timer_ln* tl,
89 89
 /* timer flags */
90 90
 #define F_TIMER_FAST	1
91 91
 #define F_TIMER_ON_SLOW_LIST	0x100
92
-#define F_TIMER_ACTIVE	0x200 /* timer is running or has run and expired
93
-								 (one shot) */
92
+#define F_TIMER_ACTIVE	0x200	/* timer is running or has run and expired
93
+								 * (one shot) */
94 94
 #ifdef TIMER_DEBUG
95
-#define F_TIMER_DELETED	0x400 
95
+#define F_TIMER_DELETED	0x400
96 96
 #endif
97 97
 
98 98
 struct timer_ln{ /* timer_link already used in tm */
99 99
 	struct timer_ln* next;
100 100
 	struct timer_ln* prev;
101
-	ticks_t expire; 
101
+	ticks_t expire;
102 102
 	ticks_t initial_timeout;
103 103
 	void* data;
104
-	timer_handler_f* f; 
104
+	timer_handler_f* f;
105 105
 	volatile unsigned short flags;
106 106
 #ifdef USE_SLOW_TIMER
107 107
 	volatile slow_idx_t slow_idx;
... ...
@@ -145,14 +145,14 @@ void timer_free(struct timer_ln* t);
145 145
 #define timer_reinit(tl) \
146 146
 	do{ \
147 147
 		(tl)->flags&=~((unsigned short)(F_TIMER_ON_SLOW_LIST | \
148
-											  F_TIMER_ACTIVE));\
148
+											F_TIMER_ACTIVE));\
149 149
 		(tl)->init++; \
150 150
 	}while(0)
151 151
 #else
152 152
 /* use for a deleted/expired timer that you want to add again */
153 153
 #define timer_reinit(tl) \
154 154
 	(tl)->flags&=~((unsigned short)(F_TIMER_ON_SLOW_LIST | \
155
-										  F_TIMER_ACTIVE))
155
+										F_TIMER_ACTIVE))
156 156
 #endif
157 157
 
158 158
 #define timer_init(tl, fun, param, flgs) \
... ...
@@ -165,7 +165,7 @@ void timer_free(struct timer_ln* t);
165 165
 	}while(0)
166 166
 
167 167
 #ifdef TIMER_DEBUG
168
-int timer_add_safe(struct timer_ln *tl, ticks_t delta, 
168
+int timer_add_safe(struct timer_ln *tl, ticks_t delta,
169 169
 					const char*, const char*, unsigned);
170 170
 int timer_del_safe(struct timer_ln *tl,
171 171
 					const char*, const char*, unsigned);
... ...
@@ -15,8 +15,8 @@
15 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 16
  * GNU General Public License for more details.
17 17
  *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
20 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 21
  */
22 22
 
... ...
@@ -58,7 +58,7 @@ struct timer_head{
58 58
 /*@{ */
59 59
 
60 60
 #define H0_BITS 14
61
-#define H1_BITS  9 
61
+#define H1_BITS  9
62 62
 #define H2_BITS  (32-H1_BITS-H0_BITS)
63 63
 
64 64
 
... ...
@@ -139,7 +139,7 @@ static inline void timer_redist(ticks_t t, struct timer_head *h)
139 139
 {
140 140
 	struct timer_ln* tl;
141 141
 	struct timer_ln* tmp;
142
-	
142
+
143 143
 	timer_foreach_safe(tl, tmp, h){
144 144
 		_timer_dist_tl(tl, tl->expire-t);
145 145
 	}
... ...
@@ -156,7 +156,7 @@ static inline void timer_run(ticks_t t)
156 156
 		if ((t & H1_H0_MASK)==0){        /*r2*/
157 157
 			timer_redist(t, &timer_lst->h2[t>>(H0_BITS+H1_BITS)]);
158 158
 		}
159
-		
159
+
160 160
 		timer_redist(t, &timer_lst->h1[(t & H1_H0_MASK)>>H0_BITS]);/*r2 >> H0*/
161 161
 	}
162 162
 	/*
... ...
@@ -171,7 +171,7 @@ static inline void timer_lst_mv0(ticks_t t, struct timer_head* h)
171 171
 {
172 172
 	struct timer_ln* tl;
173 173
 	struct timer_ln* tmp;
174
-	
174
+
175 175
 	timer_foreach_safe(tl, tmp, h){
176 176
 			_timer_dist_tl(tl, &timer_lst->h0[tl->expire & H0_MASK]);
177 177
 	}
... ...
@@ -183,12 +183,12 @@ static inline void timer_lst_mv1(ticks_t t, struct timer_head* h)
183 183
 {
184 184
 	struct timer_ln* tl;
185 185
 	struct timer_ln* tmp;
186
-	
186
+
187 187
 	timer_foreach_safe(tl, tmp, h){
188 188
 		if ((tl->expire & H0_MASK)==0) /* directly to h0 */
189 189
 			_timer_add_list(tl, &timer_lst->h0[tl->expire & H0_MASK]);
190 190
 		else  /* to h1 */
191
-			_timer_add_list(tl, 
191
+			_timer_add_list(tl,
192 192
 						&timer_lst->h1[(tl->expire & H1_H0_MASK)>>H0_BITS]);
193 193
 	}
194 194
 	/* clear the current list */
... ...
@@ -203,7 +203,7 @@ static inline void timer_run(ticks_t t)
203 203
 	if ((t & H0_MASK)==0){              /*r1*/
204 204
 		if ((t & H1_H0_MASK)==0)        /*r2*/
205 205
 			/* just move the list "down" to hash1 */
206
-			timer_lst_mv1(&timer_lst->h2[t>>(H0_BITS+H1_BITS)]); 
206
+			timer_lst_mv1(&timer_lst->h2[t>>(H0_BITS+H1_BITS)]);
207 207
 		/* move "down" to hash0 */
208 208
 		timer_lst_mv0(&timer_lst->h1[(t & H1_H0_MASK)>>H0_BITS]);
209 209
 	}
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * Copyright (C) 2009 iptelorg GmbH
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -48,8 +48,8 @@ int register_basic_timers(int timers)
48 48
 
49 49
 /**
50 50
  * \brief Forks a separate simple sleep() periodic timer
51
- * 
52
- * Forks a very basic periodic timer process, that just sleep()s for 
51
+ *
52
+ * Forks a very basic periodic timer process, that just sleep()s for
53 53
  * the specified interval and then calls the timer function.
54 54
  * The new "basic timer" process execution start immediately, the sleep()
55 55
  * is called first (so the first call to the timer function will happen
... ...
@@ -67,7 +67,7 @@ int fork_basic_timer(int child_id, char* desc, int make_sock,
67 67
 						timer_function* f, void* param, int interval)
68 68
 {
69 69
 	int pid;
70
-	
70
+
71 71
 	pid=fork_process(child_id, desc, make_sock);
72 72
 	if (pid<0) return -1;
73 73
 	if (pid==0){
... ...
@@ -77,7 +77,7 @@ int fork_basic_timer(int child_id, char* desc, int make_sock,
77 77
 			sleep(interval);
78 78
 			cfg_update();
79 79
 			f(get_ticks(), param); /* ticks in s for compatibility with old
80
-									  timers */
80
+									* timers */
81 81
 		}
82 82
 	}
83 83
 	/* parent */
... ...
@@ -86,8 +86,8 @@ int fork_basic_timer(int child_id, char* desc, int make_sock,
86 86
 
87 87
 /**
88 88
  * \brief Forks a separate simple microsecond-sleep() periodic timer
89
- * 
90
- * Forks a very basic periodic timer process, that just us-sleep()s for 
89
+ *
90
+ * Forks a very basic periodic timer process, that just us-sleep()s for
91 91
  * the specified interval and then calls the timer function.
92 92
  * The new "basic timer" process execution start immediately, the us-sleep()
93 93
  * is called first (so the first call to the timer function will happen
... ...
@@ -106,7 +106,7 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
106 106
 {
107 107
 	int pid;
108 108
 	ticks_t ts;
109
-	
109
+
110 110
 	pid=fork_process(child_id, desc, make_sock);
111 111
 	if (pid<0) return -1;
112 112
 	if (pid==0){
... ...
@@ -126,7 +126,7 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
126 126
 
127 127
 /**
128 128
  * \brief Forks a timer process based on the local timer
129
- * 
129
+ *
130 130
  * Forks a separate timer process running a local_timer.h type of timer
131 131
  * A pointer to the local_timer handle (allocated in shared memory) is
132 132
  * returned in lt_h. It can be used to add/delete more timers at runtime
... ...
@@ -135,10 +135,10 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
135 135
  * used (all the calls to local_timer* must be enclosed by locks if it
136 136
  * cannot be guaranteed that they cannot execute in the same time)
137 137
  * The timer "engine" must be run manually from the child process. For
138
- * example a very simple local timer process that just runs a single 
138
+ * example a very simple local timer process that just runs a single
139 139
  * periodic timer can be started in the following way:
140 140
  * struct local_timer* lt_h;
141
- * 
141
+ *
142 142
  * pid=fork_local_timer_process(...., &lt_h);
143 143
  * if (pid==0){
144 144
  *          timer_init(&my_timer, my_timer_f, 0, 0);
... ...
@@ -157,7 +157,7 @@ int fork_local_timer_process(int child_id, char* desc, int make_sock,
157 157
 {
158 158
 	int pid;
159 159
 	struct local_timer* lt;
160
-	
160
+
161 161
 	lt=shm_malloc(sizeof(*lt));
162 162
 	if (lt==0) goto error;
163 163
 	if (init_local_timer(lt, get_ticks_raw())<0) goto error;
... ...
@@ -186,7 +186,7 @@ int register_sync_timers(int timers)
186 186
 /**
187 187
  * \brief Forks a separate simple sleep() -&- sync periodic timer
188 188
  *
189
- * Forks a very basic periodic timer process, that just sleep()s for 
189
+ * Forks a very basic periodic timer process, that just sleep()s for
190 190
  * the specified interval and then calls the timer function.
191 191
  * The new "sync timer" process execution start immediately, the sleep()
192 192
  * is called first (so the first call to the timer function will happen
... ...
@@ -222,7 +222,7 @@ int fork_sync_timer(int child_id, char* desc, int make_sock,
222 222
 			ts1 = get_ticks_raw();
223 223
 			cfg_update();
224 224
 			f(TICKS_TO_S(ts1), param); /* ticks in sec for compatibility with old
225
-									  timers */
225
+										* timers */
226 226
 			/* adjust the next sleep duration */
227 227
 			ts2 = interval - TICKS_TO_MS(get_ticks_raw()) + TICKS_TO_MS(ts1);
228 228
 		}
... ...
@@ -235,7 +235,7 @@ int fork_sync_timer(int child_id, char* desc, int make_sock,
235 235
 /**
236 236
  * \brief Forks a separate simple microsecond-sleep() -&- sync periodic timer
237 237
  *
238
- * Forks a very basic periodic timer process, that just us-sleep()s for 
238
+ * Forks a very basic periodic timer process, that just us-sleep()s for
239 239
  * the specified interval and then calls the timer function.
240 240
  * The new "sync timer" process execution start immediately, the us-sleep()
241 241
  * is called first (so the first call to the timer function will happen
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * Copyright (C) 2009 iptelorg GmbH
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -41,8 +41,8 @@ int register_basic_timers(int timers);
41 41
 
42 42
 /**
43 43
  * \brief Forks a separate simple sleep() periodic timer
44
- * 
45
- * Forks a very basic periodic timer process, that just sleep()s for 
44
+ *
45
+ * Forks a very basic periodic timer process, that just sleep()s for
46 46
  * the specified interval and then calls the timer function.
47 47
  * The new "basic timer" process execution start immediately, the sleep()
48 48
  * is called first (so the first call to the timer function will happen
... ...
@@ -63,8 +63,8 @@ int fork_basic_timer(int child_id, char* desc, int make_sock,
63 63
 
64 64
 /**
65 65
  * \brief Forks a separate simple milisecond-sleep() periodic timer
66
- * 
67
- * Forks a very basic periodic timer process, that just ms-sleep()s for 
66
+ *
67
+ * Forks a very basic periodic timer process, that just ms-sleep()s for
68 68
  * the specified interval and then calls the timer function.
69 69
  * The new "basic timer" process execution start immediately, the ms-sleep()
70 70
  * is called first (so the first call to the timer function will happen
... ...
@@ -82,7 +82,7 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
82 82
 						timer_function* f, void* param, int uinterval);
83 83
 /**
84 84
  * \brief Forks a timer process based on the local timer
85
- * 
85
+ *
86 86
  * Forks a separate timer process running a local_timer.h type of timer
87 87
  * A pointer to the local_timer handle (allocated in shared memory) is
88 88
  * returned in lt_h. It can be used to add/delete more timers at runtime
... ...
@@ -91,10 +91,10 @@ int fork_basic_utimer(int child_id, char* desc, int make_sock,
91 91
  * used (all the calls to local_timer* must be enclosed by locks if it
92 92
  * cannot be guaranteed that they cannot execute in the same time)
93 93
  * The timer "engine" must be run manually from the child process. For
94
- * example a very simple local timer process that just runs a single 
94
+ * example a very simple local timer process that just runs a single
95 95
  * periodic timer can be started in the following way:
96 96
  * struct local_timer* lt_h;
97
- * 
97
+ *
98 98
  * pid=fork_local_timer_process(...., &lt_h);
99 99
  * if (pid==0){
100 100
  *          timer_init(&my_timer, my_timer_f, 0, 0);
... ...
@@ -15,8 +15,8 @@
15 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 16
  * GNU General Public License for more details.
17 17
  *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
20 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 21
  */
22 22
 /**