c8bdaa43dc3581f33b3655aef2dac1107a66786e
[reactos.git] / lib / kernel32 / misc / perfcnt.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2003 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$ */
20 /*
21  * PROJECT:         ReactOS system libraries
22  * FILE:            lib/kernel32/misc/perfcnt.c
23  * PURPOSE:         Performance counter
24  * PROGRAMMER:      Eric Kohl
25  */
26
27 /* INCLUDES *****************************************************************/
28
29 #include <k32.h>
30
31 #define NDEBUG
32 #include <kernel32/kernel32.h>
33
34
35 /* FUNCTIONS ****************************************************************/
36
37 WINBOOL STDCALL
38 QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
39 {
40   LARGE_INTEGER Frequency;
41   NTSTATUS Status;
42
43   Status = NtQueryPerformanceCounter(lpPerformanceCount,
44                                      &Frequency);
45   if (!NT_SUCCESS(Status))
46   {
47     SetLastErrorByStatus(Status);
48     return(FALSE);
49   }
50
51   if (Frequency.QuadPart == 0ULL)
52   {
53     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
54     return(FALSE);
55   }
56
57   return(TRUE);
58 }
59
60
61 WINBOOL STDCALL
62 QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)
63 {
64   LARGE_INTEGER Count;
65   NTSTATUS Status;
66
67   Status = NtQueryPerformanceCounter(&Count,
68                                      lpFrequency);
69   if (!NT_SUCCESS(Status))
70   {
71     SetLastErrorByStatus(Status);
72     return(FALSE);
73   }
74
75   if (lpFrequency->QuadPart == 0ULL)
76   {
77     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
78     return(FALSE);
79   }
80
81   return(TRUE);
82 }
83
84 /* EOF */