update for HEAD-2003091401
[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 /*
38  * @implemented
39  */
40 WINBOOL STDCALL
41 QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
42 {
43   LARGE_INTEGER Frequency;
44   NTSTATUS Status;
45
46   Status = NtQueryPerformanceCounter(lpPerformanceCount,
47                                      &Frequency);
48   if (!NT_SUCCESS(Status))
49   {
50     SetLastErrorByStatus(Status);
51     return(FALSE);
52   }
53
54   if (Frequency.QuadPart == 0ULL)
55   {
56     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
57     return(FALSE);
58   }
59
60   return(TRUE);
61 }
62
63
64 /*
65  * @implemented
66  */
67 WINBOOL STDCALL
68 QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)
69 {
70   LARGE_INTEGER Count;
71   NTSTATUS Status;
72
73   Status = NtQueryPerformanceCounter(&Count,
74                                      lpFrequency);
75   if (!NT_SUCCESS(Status))
76   {
77     SetLastErrorByStatus(Status);
78     return(FALSE);
79   }
80
81   if (lpFrequency->QuadPart == 0ULL)
82   {
83     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
84     return(FALSE);
85   }
86
87   return(TRUE);
88 }
89
90 /* EOF */