1 /*! ========================================================================
2 ** Extended Template and Library
3 ** Win32 Clock Description Implementation
4 ** $Id: _clock_win32hpcount.h,v 1.1.1.1 2005/01/04 01:31:47 darco Exp $
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** General Public License for more details.
18 ** === N O T E S ===========================================================
20 ** This is an internal header file, included by other ETL headers.
21 ** You should not attempt to use it directly.
23 ** ========================================================================= */
25 /* === S T A R T =========================================================== */
27 #ifndef __ETL__CLOCK_WIN32HPCOUNT_H
28 #define __ETL__CLOCK_WIN32HPCOUNT_H
30 /* === H E A D E R S ======================================================= */
32 #define WIN32_LEAN_AND_MEAN
35 /* === M A C R O S ========================================================= */
37 #if defined(__GNUG__) && defined(__int64)
39 #define __int64 long long int
42 /* === T Y P E D E F S ===================================================== */
44 /* === C L A S S E S & S T R U C T S ======================================= */
48 class clock_desc_win32hpcount
51 typedef double value_type;
53 static bool realtime()
56 static bool proctime()
63 static value_type precision()
66 QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
67 return one_second()/(value_type)freq;
70 static const char *description()
71 { return "Win32 QueryPerformanceCounter()"; };
74 typedef __int64 timestamp;
77 get_current_time(timestamp &x)
78 { QueryPerformanceCounter((LARGE_INTEGER*)&x);}
82 { timestamp ret; QueryPerformanceCounter((LARGE_INTEGER*)&ret); return ret; }
85 timestamp_to_seconds(const timestamp &x)
86 { return precision()*x; }
89 seconds_to_timestamp(const value_type &x)
90 { return (timestamp)(x/precision()); }
95 /* === E N D =============================================================== */