int nanosleep(struct timespec *, struct timespec *);
#endif
+#if !defined (_POSIX_CLOCK_SELECTION)
+# define _POSIX_CLOCK_SELECTION (-1)
+#endif
+
+# if (_POSIX_CLOCK_SELECTION < 0)
+/*
+ * We cannot use the monotonic clock is clock selection is not available,
+ * as it would screw vlc_cond_timedwait() completely. Instead, we have to
+ * stick to the realtime clock. Nevermind it screws everything when ntpdate
+ * warps the wall clock.
+ */
+# undef CLOCK_MONOTONIC
+# define CLOCK_MONOTONIC CLOCK_REALTIME
+#elif !defined (HAVE_CLOCK_NANOSLEEP)
+/* Clock selection without clock in the first place, I don't think so. */
+# error We have quite a situation here! Fix me if it ever happens.
+#endif
+
/**
* Return a date in a readable format
*
*/
char *secstotimestr( char *psz_buffer, int i_seconds )
{
- snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
- (int) (i_seconds / (60 *60)),
- (int) ((i_seconds / 60) % 60),
- (int) (i_seconds % 60) );
+ int i_hours, i_mins;
+ i_mins = i_seconds / 60;
+ i_hours = i_mins / 60 ;
+ if( i_hours )
+ {
+ snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
+ (int) i_hours,
+ (int) (i_mins % 60),
+ (int) (i_seconds % 60) );
+ }
+ else
+ {
+ snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%2.2d:%2.2d",
+ (int) i_mins ,
+ (int) (i_seconds % 60) );
+ }
return( psz_buffer );
}
static unsigned prec = 0;
static volatile mtime_t cached_time = 0;
-#if defined( HAVE_CLOCK_NANOSLEEP )
-# if (_POSIX_MONOTONIC_CLOCK - 0 < 0)
-# define CLOCK_MONOTONIC CLOCK_REALTIME
-# endif
-#endif
/**
* Return high precision date
{
mtime_t earlier = cached_time;
-#if defined( HAVE_CLOCK_NANOSLEEP )
+#if defined( HAVE_CLOCK_NANOSLEEP )
lldiv_t d = lldiv( delay, 1000000 );
struct timespec ts = { d.quot, d.rem * 1000 };