]> git.sesse.net Git - vlc/blobdiff - include/vlc_mtime.h
Warn about ticks at compile-time
[vlc] / include / vlc_mtime.h
index add6941638eeec9dc0965dc22088f63198d2b353..c2ad1bea802d8d244e6f34854f2765417d095b9f 100644 (file)
@@ -29,9 +29,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#if !defined( __LIBVLC__ )
-  #error You are not libvlc or one of its plugins. You cannot include this file
-#endif
+#ifndef __VLC_MTIME_H
+# define __VLC_MTIME_H 1
 
 /*****************************************************************************
  * LAST_MDATE: date which will never happen
@@ -69,6 +68,19 @@ VLC_EXPORT( void,    mwait,    ( mtime_t date ) );
 VLC_EXPORT( void,    msleep,   ( mtime_t delay ) );
 VLC_EXPORT( char *,  secstotimestr, ( char *psz_buffer, int secs ) );
 
+#ifdef __GNUC__
+static
+__attribute__((unused))
+__attribute__((noinline))
+__attribute__((warning("use proper event handling instead")))
+void bad_msleep( mtime_t delay )
+{
+    msleep( delay );
+}
+# define msleep( d ) \
+   ((__builtin_constant_p(d) && (d < 29000000)) ? bad_msleep(d) : msleep(d))
+#endif
+
 /*****************************************************************************
  * date_t: date incrementation without long-term rounding errors
  *****************************************************************************/
@@ -87,3 +99,4 @@ VLC_EXPORT( mtime_t, date_Get,       ( const date_t * ) );
 VLC_EXPORT( void,    date_Move,      ( date_t *, mtime_t ) );
 VLC_EXPORT( mtime_t, date_Increment, ( date_t *, uint32_t ) );
 VLC_EXPORT( uint64_t, NTPtime64,     ( void ) );
+#endif /* !__VLC_MTIME_ */