Moved silc_usleep from inline function to source file.
[runtime.git] / lib / silcutil / silctimer.h
index 30debf07d67a93f1995d583ea3123838eee3965e..f63486941e4e59d4d2a47b9058bbab62a88666d8 100644 (file)
@@ -4,7 +4,7 @@
 
   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
 
 */
 
-/****h* silcutil/SILC Timer Interface
+/****h* silcutil/Timer Interface
  *
  * DESCRIPTION
  *
  * SILC Timer interface provides a simple way to measure time intervals.
  * The SILC Timer works with microsecond resolution, depending on platform.
  *
+ * The interface also provides utility functions to get currenet CPU tick
+ * count and to delay process/thread execution.
+ *
  * EXAMPLE
  *
  * SilcTimerStruct timer;
 #ifndef SILCTIMER_H
 #define SILCTIMER_H
 
-/****s* silcutil/SilcTimerAPI/SilcTimer
+/****s* silcutil/SilcTimer
+ *
+ * NAME
+ *
+ *    typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct;
+ *
+ * DESCRIPTION
+ *
+ *    The timer context.  The context is given as argument to all
+ *    silc_timer_* functions.
+ *
+ ***/
+/****s* silcutil/SilcTimerStruct
  *
  * NAME
  *
@@ -52,7 +67,7 @@
  ***/
 typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct;
 
-/****f* silcutil/SilcTimerAPI/silc_timer_start
+/****f* silcutil/silc_timer_start
  *
  * SYNOPSIS
  *
@@ -75,7 +90,7 @@ typedef struct SilcTimerObject *SilcTimer, SilcTimerStruct;
  ***/
 void silc_timer_start(SilcTimer timer);
 
-/****f* silcutil/SilcTimerAPI/silc_timer_stop
+/****f* silcutil/silc_timer_stop
  *
  * SYNOPSIS
  *
@@ -89,7 +104,7 @@ void silc_timer_start(SilcTimer timer);
  ***/
 void silc_timer_stop(SilcTimer timer);
 
-/****f* silcutil/SilcTimerAPI/silc_timer_continue
+/****f* silcutil/silc_timer_continue
  *
  * SYNOPSIS
  *
@@ -102,7 +117,7 @@ void silc_timer_stop(SilcTimer timer);
  ***/
 void silc_timer_continue(SilcTimer timer);
 
-/****f* silcutil/SilcTimerAPI/silc_timer_value
+/****f* silcutil/silc_timer_value
  *
  * SYNOPSIS
  *
@@ -121,7 +136,7 @@ void silc_timer_value(SilcTimer timer,
                      SilcUInt64 *elapsed_time_seconds,
                      SilcUInt32 *elapsed_time_microseconds);
 
-/****f* silcutil/SilcTimerAPI/silc_timer_value_time
+/****f* silcutil/silc_timer_value_time
  *
  * SYNOPSIS
  *
@@ -137,7 +152,7 @@ void silc_timer_value(SilcTimer timer,
  ***/
 void silc_timer_value_time(SilcTimer timer, SilcTime ret_time);
 
-/****f* silcutil/SilcTimerAPI/silc_timer_start_time
+/****f* silcutil/silc_timer_start_time
  *
  * SYNOPSIS
  *
@@ -150,7 +165,7 @@ void silc_timer_value_time(SilcTimer timer, SilcTime ret_time);
  ***/
 void silc_timer_start_time(SilcTimer timer, SilcTime ret_start_time);
 
-/****f* silcutil/SilcTimerAPI/silc_timer_is_running
+/****f* silcutil/silc_timer_is_running
  *
  * SYNOPSIS
  *
@@ -165,7 +180,7 @@ SilcBool silc_timer_is_running(SilcTimer timer);
 
 #include "silctimer_i.h"
 
-/****f* silcutil/SilcTimerAPI/silc_timer_tick
+/****f* silcutil/silc_timer_tick
  *
  * SYNOPSIS
  *
@@ -179,7 +194,7 @@ SilcBool silc_timer_is_running(SilcTimer timer);
  *    tick count.  If the `adjust' is TRUE and the silc_timer_synchronize
  *    has been called the returned value is adjusted to be more accurate.
  *
- * EXAMPLES
+ * EXAMPLE
  *
  *    // Synchronize timer for more accurate CPU tick counts
  *    silc_timer_synchronize(&timer);
@@ -216,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)
@@ -226,7 +244,7 @@ SilcUInt64 silc_timer_tick(SilcTimer timer, SilcBool adjust)
 #endif /* __GNUC__ || __ICC */
 }
 
-/****f* silcutil/SilcTimerAPI/silc_timer_synchronize
+/****f* silcutil/silc_timer_synchronize
  *
  * SYNOPSIS
  *
@@ -286,4 +304,23 @@ void silc_timer_synchronize(SilcTimer timer)
   timer->sync_tdiff += (int)(t2 - t1);
 }
 
+/****f* silcutil/silc_usleep
+ *
+ * SYNOPSIS
+ *
+ *    void silc_usleep(unsigned long microseconds);
+ *
+ * DESCRIPTION
+ *
+ *    Delays the execution of process/thread for the specified amount of
+ *    time, which is in microseconds.
+ *
+ * NOTES
+ *
+ *    The delay is only approximate and on some platforms the resolution is
+ *    in fact milliseconds.
+ *
+ ***/
+void silc_usleep(unsigned long microseconds);
+
 #endif /* SILCTIMER_H */