[COMPLIB] Add support for retrieveing high resolution counter tick
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Sep 2005 07:32:51 +0000 (07:32 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 19 Sep 2005 07:32:51 +0000 (07:32 +0000)
count and frequency.

Signed-off-by: Fab Tillier (ftillier@silverstorm.com)
Signed-off-by: Yossi Leybovich (sleybo@mellanox.co.il)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@75 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/complib/user/cl_timer.c
inc/complib/cl_timer.h
inc/kernel/complib/cl_timer_osd.h

index 9df169f..81c5b92 100644 (file)
@@ -169,3 +169,27 @@ cl_get_time_stamp_sec( void )
 {\r
        return( (uint32_t)(cl_get_time_stamp() / SEC_TO_MICRO) );\r
 }\r
+\r
+\r
+uint64_t\r
+cl_get_tick_count( void )\r
+{\r
+       LARGE_INTEGER   tick_count;\r
+\r
+       if( !QueryPerformanceCounter( &tick_count ) )\r
+               return( 0 );\r
+\r
+       return tick_count.QuadPart;\r
+}\r
+\r
+\r
+uint64_t\r
+cl_get_frequency( void )\r
+{\r
+       LARGE_INTEGER   frequency;\r
+\r
+       if( !QueryPerformanceFrequency( &frequency ) )\r
+               return( 0 );\r
+\r
+       return frequency.QuadPart;\r
+}\r
index a7f3624..7ea2641 100644 (file)
@@ -348,7 +348,31 @@ cl_get_time_stamp( void );
 *      Time elapsed, in microseconds, since the system was booted.\r
 *\r
 * SEE ALSO\r
-*      Timer, cl_get_time_stamp_sec\r
+*      Timer, cl_get_time_stamp_usec, cl_get_time_stamp_sec\r
+*********/\r
+\r
+\r
+/****f* Component Library: Time Stamp/cl_get_time_stamp_usec\r
+* NAME\r
+*      cl_get_time_stamp_usec\r
+*\r
+* DESCRIPTION\r
+*      The cl_get_time_stamp_usec function returns the current time stamp in\r
+*      microseconds since the system was booted.\r
+*\r
+* SYNOPSIS\r
+*/\r
+CL_INLINE uint64_t CL_API\r
+cl_get_time_stamp_usec( void )\r
+{\r
+       return cl_get_time_stamp();\r
+}\r
+/*\r
+* RETURN VALUE\r
+*      Time elapsed, in microseconds, since the system was booted.\r
+*\r
+* SEE ALSO\r
+*      Timer, cl_get_time_stamp, cl_get_time_stamp_sec\r
 *********/\r
 \r
 \r
@@ -373,6 +397,48 @@ cl_get_time_stamp_sec( void );
 *********/\r
 \r
 \r
+/****f* Component Library: Time Stamp/cl_get_tick_count\r
+* NAME\r
+*      cl_get_tick_count\r
+*\r
+* DESCRIPTION\r
+*      The cl_get_tick_count function returns the raw high-resolution\r
+*      performance counter value.\r
+*\r
+* SYNOPSIS\r
+*/\r
+CL_EXPORT uint64_t CL_API\r
+cl_get_tick_count( void );\r
+/*\r
+* RETURN VALUE\r
+*      Value of the high-resolution performance counter.\r
+*\r
+* SEE ALSO\r
+*      Timer, cl_get_time_stamp, cl_get_frequency\r
+*********/\r
+\r
+\r
+/****f* Component Library: Time Stamp/cl_get_frequency\r
+* NAME\r
+*      cl_get_frequency\r
+*\r
+* DESCRIPTION\r
+*      The cl_get_frequency function returns the frequency of the\r
+*      high-resolution performance counter.\r
+*\r
+* SYNOPSIS\r
+*/\r
+CL_EXPORT uint64_t CL_API\r
+cl_get_frequency( void );\r
+/*\r
+* RETURN VALUE\r
+*      The frequency of the high-resolution performance counter.\r
+*\r
+* SEE ALSO\r
+*      Timer, cl_get_time_stamp, cl_get_tick_count\r
+*********/\r
+\r
+\r
 #ifdef __cplusplus\r
 }      /* extern "C" */\r
 #endif\r
index c7c5115..e09813b 100644 (file)
@@ -77,6 +77,24 @@ cl_get_time_stamp_sec( void )
        return( (uint32_t)(KeQueryInterruptTime() / HUNDREDNS_TO_SEC) );\r
 }\r
 \r
+CL_INLINE uint64_t CL_API\r
+cl_get_tick_count( void )\r
+{\r
+       LARGE_INTEGER   tick_count;\r
+\r
+       tick_count = KeQueryPerformanceCounter( NULL );\r
+       return tick_count.QuadPart;\r
+}\r
+\r
+CL_INLINE uint64_t CL_API\r
+cl_get_frequency( void )\r
+{\r
+       LARGE_INTEGER   frequency;\r
+\r
+       KeQueryPerformanceCounter( &frequency );\r
+       return frequency.QuadPart;\r
+}\r
+\r
 #ifdef __cplusplus\r
 }      /* extern "C" */\r
 #endif\r