Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2007 Pekka Riikonen
+ Copyright (C) 2007 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-#include "silc.h"
+#include "silcruntime.h"
/* Start timer */
return timer->running;
}
-#if 0
-void silc_timer_synchronize(SilcTimer timer)
-{
- SilcUInt32 tdiff, cumu, i;
- SilcUInt64 t1, t2, tcumu;
-
- /* Sync normal timer */
- for (i = 0, cumu = 0; i < 5; i++) {
- silc_timer_start(timer);
- silc_timer_stop(timer);
- silc_timer_value(timer, NULL, &tdiff);
- cumu += tdiff;
- }
+/* Delay execution */
- timer->sync_diff = cumu;
- if (timer->sync_diff > 5)
- timer->sync_diff /= 5;
-
- /* Sync CPU tick count */
- tcumu = 0;
- t1 = silc_timer_tick(timer, FALSE);
- t2 = silc_timer_tick(timer, FALSE);
- tcumu += (t2 - t1);
- t1 = silc_timer_tick(timer, FALSE);
- t2 = silc_timer_tick(timer, FALSE);
- tcumu += (t2 - t1);
- t1 = silc_timer_tick(timer, FALSE);
- t2 = silc_timer_tick(timer, FALSE);
- tcumu += (t2 - t1);
- timer->sync_tdiff = tcumu / 3;
-
- t1 = silc_timer_tick(timer, FALSE);
- t2 = silc_timer_tick(timer, TRUE);
- timer->sync_tdiff += (int)(t2 - t1);
+void silc_usleep(unsigned long microseconds)
+{
+#ifdef SILC_UNIX
+#ifdef HAVE_NANOSLEEP
+ struct timespec tv;
+ tv.tv_sec = 0;
+ tv.tv_nsec = microseconds * 1000;
+#endif /* HAVE_NANOSLEEP */
+#endif /* SILC_UNIX */
+
+#ifdef SILC_UNIX
+#ifdef HAVE_NANOSLEEP
+ nanosleep(&tv, NULL);
+#else
+ usleep(microseconds);
+#endif /* HAVE_NANOSLEEP */
+#endif /* SILC_UNIX */
+#ifdef SILC_WIN32
+ Sleep(microseconds / 1000);
+#endif /* SILC_WIN32 */
+#ifdef SILC_SYMBIAN
+ silc_symbian_usleep(microseconds);
+#endif /* SILC_SYMBIAN */
}
-#endif