From 0e5c6a2c995a3e33a7e5ce1120db16474783c1c4 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Mon, 4 Feb 2008 23:01:29 +0200 Subject: [PATCH] Moved silc_usleep from inline function to source file. --- lib/silcutil/silctime.h | 14 ++++++++++++++ lib/silcutil/silctimer.c | 27 ++++++++++++++++++++++++++ lib/silcutil/silctimer.h | 41 ++++++++++++++++------------------------ 3 files changed, 57 insertions(+), 25 deletions(-) diff --git a/lib/silcutil/silctime.h b/lib/silcutil/silctime.h index a049cca4..32d4d927 100644 --- a/lib/silcutil/silctime.h +++ b/lib/silcutil/silctime.h @@ -44,6 +44,20 @@ * SOURCE * */ +/****s* silcutil/SilcTimeStruct + * + * NAME + * + * typedef struct { ... } *SilcTime, SilcTimeStruct; + * + * DESCRIPTION + * + * This context represents time value. It includes date and time + * down to millisecond precision. The structure size is 64 bits. + * + * SOURCE + * + */ typedef struct SilcTimeObject { unsigned int year : 15; /* Year, 0 - 32768 */ unsigned int month : 4; /* Month, 1 - 12 */ 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 */ +} diff --git a/lib/silcutil/silctimer.h b/lib/silcutil/silctimer.h index bc908ee7..f6348694 100644 --- a/lib/silcutil/silctimer.h +++ b/lib/silcutil/silctimer.h @@ -53,6 +53,18 @@ * silc_timer_* functions. * ***/ +/****s* silcutil/SilcTimerStruct + * + * NAME + * + * typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct; + * + * DESCRIPTION + * + * The timer context. The context is given as argument to all + * silc_timer_* functions. + * + ***/ typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct; /****f* silcutil/silc_timer_start @@ -219,6 +231,9 @@ SilcUInt64 silc_timer_tick(SilcTimer timer, SilcBool adjust) : "=r" (hi), "=r" (lo), "=r" (tmp)); x = ((SilcUInt64)lo | ((SilcUInt64)hi << 32)); return adjust ? x - timer->sync_tdiff : x; + +#else + return 0; #endif /* SILC_I486 */ #elif defined(SILC_WIN32) @@ -306,30 +321,6 @@ void silc_timer_synchronize(SilcTimer timer) * in fact milliseconds. * ***/ -static inline -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 */ -} +void silc_usleep(unsigned long microseconds); #endif /* SILCTIMER_H */ -- 2.24.0