X-Git-Url: http://git.silc.fi/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilctimer.c;h=ce1c2bf11ad75832788783ec2e2b38d0e917c386;hb=0e5c6a2c995a3e33a7e5ce1120db16474783c1c4;hp=049341b77d8df6c9df51306f81969ee54dc6e26e;hpb=4d96aec5a0942c3b9bf66dcbec47c593f267c5ec;p=runtime.git diff --git a/lib/silcutil/silctimer.c b/lib/silcutil/silctimer.c index 049341b7..ce1c2bf1 100644 --- a/lib/silcutil/silctimer.c +++ b/lib/silcutil/silctimer.c @@ -128,3 +128,30 @@ SilcBool silc_timer_is_running(SilcTimer timer) { return timer->running; } + +/* Delay execution */ + +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 */ +}