* 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>
*
*****************************************************************************/
#include <stdio.h> /* sprintf() */
-#include <videolan/vlc.h>
+#include <vlc/vlc.h>
#if defined( PTH_INIT_IN_PTH_H ) /* GNU Pth */
# include <pth.h>
# include <kernel/OS.h>
#endif
-#if defined( WIN32 )
+#if defined( WIN32 ) || defined( UNDER_CE )
# include <windows.h>
#else
# include <sys/time.h>
*****************************************************************************/
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).
#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 */
}
/*****************************************************************************
- * 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
}
snooze( delay );
-#elif defined( WIN32 )
+#elif defined( WIN32 ) || defined( UNDER_CE )
mtime_t usec_time, delay;
usec_time = mdate();
}
/*****************************************************************************
- * msleep: more precise sleep() (inline function) (ok ?)
+ * msleep: more precise sleep()
*****************************************************************************
* Portable usleep() function.
*****************************************************************************/
#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 )