]> git.sesse.net Git - vlc/blobdiff - src/misc/mtime.c
Remove redumdant parameter to vlc_global
[vlc] / src / misc / mtime.c
index 7d9ab55375dc4aff3bc0cdf9646605d2772efd70..dd525e74bb70d083f9a72574b38125b8c60c38b7 100644 (file)
@@ -35,6 +35,7 @@
 #include <time.h>                      /* clock_gettime(), clock_nanosleep() */
 #include <stdlib.h>                                               /* lldiv() */
 #include <assert.h>
+#include <errno.h>
 
 
 #if defined( PTH_INIT_IN_PTH_H )                                  /* GNU Pth */
@@ -128,8 +129,10 @@ static inline unsigned mprec( void )
 
 static unsigned prec = 0;
 static volatile mtime_t cached_time = 0;
-#if (_POSIX_MONOTONIC_CLOCK - 0 < 0)
-# define CLOCK_MONOTONIC CLOCK_REALTIME
+#if defined( HAVE_CLOCK_NANOSLEEP ) 
+#  if (_POSIX_MONOTONIC_CLOCK - 0 < 0)
+#    define CLOCK_MONOTONIC CLOCK_REALTIME
+#  endif
 #endif
 
 /**
@@ -159,7 +162,6 @@ mtime_t mdate( void )
 #elif defined( WIN32 ) || defined( UNDER_CE )
     /* We don't need the real date, just the value of a high precision timer */
     static mtime_t freq = I64C(-1);
-    mtime_t usec_time;
 
     if( freq == I64C(-1) )
     {
@@ -225,9 +227,9 @@ mtime_t mdate( void )
         {
             /* Counter wrapped */
             i_wrap_counts++;
-            usec_time += I64C(0x100000000) * 1000;
+            res += I64C(0x100000000) * 1000;
         }
-        i_previous_time = usec_time;
+        i_previous_time = res;
         LeaveCriticalSection( &date_lock );
     }
 #else
@@ -430,7 +432,10 @@ mtime_t date_Increment( date_t *p_date, uint32_t i_nb_samples )
     return p_date->date;
 }
 
+#ifndef HAVE_GETTIMEOFDAY
+
 #ifdef WIN32
+
 /*
  * Number of micro-seconds between the beginning of the Windows epoch
  * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
@@ -467,9 +472,10 @@ static int gettimeofday (struct timeval *tv, void *tz )
     tv->tv_usec = (long) (tim % 1000000L);
     return (0);
 }
-#endif
 
+#endif
 
+#endif
 
 /**
  * @return NTP 64-bits timestamp in host byte order.