]> git.sesse.net Git - vlc/blobdiff - src/misc/mtime.c
* ./include/*, ./src/*: separated WIN32 #tests and UNDER_CE #tests, because
[vlc] / src / misc / mtime.c
index 0ac77f40e101af2248c72e89e81b08cff8c1e589..6dfa582c1ed2e0a15398e80f2f2db1c81975d61f 100644 (file)
@@ -3,7 +3,7 @@
  * Functions are prototyped in mtime.h.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: mtime.c,v 1.31 2002/05/18 13:33:44 massiot Exp $
+ * $Id: mtime.c,v 1.35 2002/11/11 14:39:12 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
@@ -32,7 +32,7 @@
  *****************************************************************************/
 #include <stdio.h>                                              /* sprintf() */
 
-#include <videolan/vlc.h>
+#include <vlc/vlc.h>
 
 #if defined( PTH_INIT_IN_PTH_H )                                  /* GNU Pth */
 #   include <pth.h>
@@ -46,7 +46,7 @@
 #   include <kernel/OS.h>
 #endif
 
-#if defined( WIN32 )
+#if defined( WIN32 ) || defined( UNDER_CE )
 #   include <windows.h>
 #else
 #   include <sys/time.h>
@@ -73,17 +73,19 @@ int nanosleep(struct timespec *, struct timespec *);
  *****************************************************************************/
 char *mstrtime( char *psz_buffer, mtime_t date )
 {
+    static mtime_t ll1000 = 1000, ll60 = 60, ll24 = 24;
+
     sprintf( psz_buffer, "%02d:%02d:%02d-%03d.%03d",
-             (int) (date / (I64C(1000) * I64C(1000) * I64C(60) * I64C(60)) % I64C(24)),
-             (int) (date / (I64C(1000) * I64C(1000) * I64C(60)) % I64C(60)),
-             (int) (date / (I64C(1000) * I64C(1000)) % I64C(60)),
-             (int) (date / I64C(1000) % I64C(1000)),
-             (int) (date % I64C(1000)) );
+             (int) (date / (ll1000 * ll1000 * ll60 * ll60) % ll24),
+             (int) (date / (ll1000 * ll1000 * ll60) % ll60),
+             (int) (date / (ll1000 * ll1000) % ll60),
+             (int) (date / ll1000 % ll1000),
+             (int) (date % ll1000) );
     return( psz_buffer );
 }
 
 /*****************************************************************************
- * mdate: return high precision date (inline function)
+ * mdate: return high precision date
  *****************************************************************************
  * Uses the gettimeofday() function when possible (1 MHz resolution) or the
  * ftime() function (1 kHz resolution).
@@ -93,7 +95,7 @@ mtime_t mdate( void )
 #if defined( HAVE_KERNEL_OS_H )
     return( real_time_clock_usecs() );
 
-#elif defined( WIN32 )
+#elif defined( WIN32 ) || defined( UNDER_CE )
     /* We don't get the real date, just the value of a high precision timer.
      * this is because the usual time functions have at best only a milisecond
      * resolution */
@@ -122,7 +124,7 @@ mtime_t mdate( void )
 }
 
 /*****************************************************************************
- * mwait: wait for a date (inline function)
+ * mwait: wait for a date
  *****************************************************************************
  * This function uses select() and an system date function to wake up at a
  * precise date. It should be used for process synchronization. If current date
@@ -140,7 +142,7 @@ void mwait( mtime_t date )
     }
     snooze( delay );
 
-#elif defined( WIN32 )
+#elif defined( WIN32 ) || defined( UNDER_CE )
     mtime_t usec_time, delay;
 
     usec_time = mdate();
@@ -201,7 +203,7 @@ void mwait( mtime_t date )
 }
 
 /*****************************************************************************
- * msleep: more precise sleep() (inline function)                        (ok ?)
+ * msleep: more precise sleep()
  *****************************************************************************
  * Portable usleep() function.
  *****************************************************************************/
@@ -216,7 +218,7 @@ void msleep( mtime_t delay )
 #elif defined( ST_INIT_IN_ST_H )
     st_usleep( delay );
 
-#elif defined( WIN32 )
+#elif defined( WIN32 ) || defined( UNDER_CE )
     Sleep( (int) (delay / 1000) );
 
 #elif defined( HAVE_NANOSLEEP )