[Freeswitch-svn] [commit] r6238 - in freeswitch/trunk: . src

Freeswitch SVN anthm at freeswitch.org
Tue Nov 13 13:47:09 EST 2007


Author: anthm
Date: Tue Nov 13 13:47:08 2007
New Revision: 6238

Added:
   freeswitch/trunk/src/switch_time.c
      - copied, changed from r6237, /freeswitch/trunk/src/softtimer.c
Removed:
   freeswitch/trunk/src/softtimer.c
Modified:
   freeswitch/trunk/Makefile.am
   freeswitch/trunk/configure.in
   freeswitch/trunk/src/switch_apr.c

Log:
some time changes

Modified: freeswitch/trunk/Makefile.am
==============================================================================
--- freeswitch/trunk/Makefile.am	(original)
+++ freeswitch/trunk/Makefile.am	Tue Nov 13 13:47:08 2007
@@ -56,7 +56,7 @@
 src/switch_log.c\
 src/switch_xml.c\
 src/switch_config.c\
-src/softtimer.c\
+src/switch_time.c\
 libs/stfu/stfu.c\
 src/switch_cpp.cpp\
 libs/libteletone/src/libteletone_detect.c\

Modified: freeswitch/trunk/configure.in
==============================================================================
--- freeswitch/trunk/configure.in	(original)
+++ freeswitch/trunk/configure.in	Tue Nov 13 13:47:08 2007
@@ -188,6 +188,9 @@
 AC_CHECK_FUNCS([gethostname vasprintf mmap mlock mlockall usleep])
 AC_CHECK_FUNCS([sched_setscheduler setpriority setrlimit setgroups initgroups])
 
+AC_CHECK_LIB(rt, clock_gettime, [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])])
+AC_CHECK_LIB(rt, clock_nanosleep, [AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define if you have clock_nanosleep()])])
+
 AC_CHECK_DECL([RLIMIT_MEMLOCK],
 	[AC_DEFINE([HAVE_RLIMIT_MEMLOCK],[1],[RLIMIT_MEMLOCK constant for setrlimit])],,
 	[#ifdef HAVE_SYS_RESOURCE_H

Modified: freeswitch/trunk/src/switch_apr.c
==============================================================================
--- freeswitch/trunk/src/switch_apr.c	(original)
+++ freeswitch/trunk/src/switch_apr.c	Tue Nov 13 13:47:08 2007
@@ -233,7 +233,13 @@
 
 SWITCH_DECLARE(switch_time_t) switch_time_now(void)
 {
+#ifdef HAVE_CLOCK_GETTIME
+	struct timespec ts;
+	clock_gettime(CLOCK_REALTIME,&ts);
+	return ts.tv_sec * APR_USEC_PER_SEC + (ts.tv_nsec/1000);
+#else
 	return (switch_time_t) apr_time_now();
+#endif
 }
 
 SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t * result, switch_time_exp_t * input)
@@ -256,17 +262,6 @@
 	return apr_time_exp_gmt((apr_time_exp_t *) result, input);
 }
 
-SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
-{
-#if defined(HAVE_USLEEP)
-	usleep(t);
-#elif defined(WIN32)
-	Sleep((DWORD) ((t) / 1000));
-#else
-	apr_sleep(t);
-#endif
-}
-
 
 SWITCH_DECLARE(switch_status_t) switch_rfc822_date(char *date_str, switch_time_t t)
 {

Copied: freeswitch/trunk/src/switch_time.c (from r6237, /freeswitch/trunk/src/softtimer.c)
==============================================================================
--- /freeswitch/trunk/src/softtimer.c	(original)
+++ freeswitch/trunk/src/switch_time.c	Tue Nov 13 13:47:08 2007
@@ -80,6 +80,29 @@
 #define IDLE_SPEED 100
 
 
+SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t)
+{
+	
+#if defined(HAVE_CLOCK_NANOSLEEP)
+	struct timespec ts;
+	ts.tv_sec = t / APR_USEC_PER_SEC;
+	ts.tv_nsec = (t % APR_USEC_PER_SEC) * 1000;
+	
+	clock_nanosleep(CLOCK_REALTIME, 0, &ts, NULL);
+	
+#elif defined(HAVE_USLEEP)
+	usleep(t);
+#elif defined(WIN32)
+	Sleep((DWORD) ((t) / 1000));
+#else
+	apr_sleep(t);
+#endif
+
+
+}
+
+
+
 static switch_status_t timer_init(switch_timer_t *timer)
 {
 	timer_private_t *private_info;



More information about the Freeswitch-svn mailing list