mshtml: Check for null pointers in IHTMLLocation_get*.
[wine/hramrach.git] / dlls / kernel32 / cpu.c
blobd08e429438ef0458e418ab3c6436c387d3155aff
1 /*
2 * What processor?
4 * Copyright 1995,1997 Morten Welinder
5 * Copyright 1997-1998 Marcus Meissner
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #ifdef HAVE_SYS_TIME_H
29 # include <sys/time.h>
30 #endif
33 #define NONAMELESSUNION
34 #define NONAMELESSSTRUCT
35 #include "ntstatus.h"
36 #define WIN32_NO_STATUS
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winnt.h"
40 #include "winternl.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
43 #include "ddk/wdm.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(reg);
47 #define SHARED_DATA ((KSHARED_USER_DATA*)0x7ffe0000)
49 /****************************************************************************
50 * QueryPerformanceCounter (KERNEL32.@)
52 * Get the current value of the performance counter.
54 * PARAMS
55 * counter [O] Destination for the current counter reading
57 * RETURNS
58 * Success: TRUE. counter contains the current reading
59 * Failure: FALSE.
61 * SEE ALSO
62 * See QueryPerformanceFrequency.
64 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
66 NtQueryPerformanceCounter( counter, NULL );
67 return TRUE;
71 /****************************************************************************
72 * QueryPerformanceFrequency (KERNEL32.@)
74 * Get the resolution of the performance counter.
76 * PARAMS
77 * frequency [O] Destination for the counter resolution
79 * RETURNS
80 * Success. TRUE. Frequency contains the resolution of the counter.
81 * Failure: FALSE.
83 * SEE ALSO
84 * See QueryPerformanceCounter.
86 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
88 LARGE_INTEGER counter;
89 NtQueryPerformanceCounter( &counter, frequency );
90 return TRUE;
94 /***********************************************************************
95 * GetSystemInfo [KERNEL32.@]
97 * Get information about the system.
99 * RETURNS
100 * Nothing.
102 * NOTES
103 * On the first call it creates cached values, so it doesn't have to determine
104 * them repeatedly. On Linux, the "/proc/cpuinfo" special file is used.
106 * It also creates a cached flag array for IsProcessorFeaturePresent().
108 VOID WINAPI GetSystemInfo(
109 LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */)
111 NTSTATUS nts;
112 SYSTEM_BASIC_INFORMATION sbi;
113 SYSTEM_CPU_INFORMATION sci;
115 TRACE("si=0x%p\n", si);
117 if ((nts = NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL )) != STATUS_SUCCESS ||
118 (nts = NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL )) != STATUS_SUCCESS)
120 SetLastError(RtlNtStatusToDosError(nts));
121 return;
124 si->u.s.wProcessorArchitecture = sci.Architecture;
125 si->u.s.wReserved = 0;
126 si->dwPageSize = sbi.PageSize;
127 si->lpMinimumApplicationAddress = sbi.LowestUserAddress;
128 si->lpMaximumApplicationAddress = sbi.HighestUserAddress;
129 si->dwActiveProcessorMask = sbi.ActiveProcessorsAffinityMask;
130 si->dwNumberOfProcessors = sbi.NumberOfProcessors;
132 switch (sci.Architecture)
134 case PROCESSOR_ARCHITECTURE_INTEL:
135 switch (sci.Level)
137 case 3: si->dwProcessorType = PROCESSOR_INTEL_386; break;
138 case 4: si->dwProcessorType = PROCESSOR_INTEL_486; break;
139 case 5:
140 case 6: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
141 default: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; break;
143 break;
144 case PROCESSOR_ARCHITECTURE_PPC:
145 switch (sci.Level)
147 case 1: si->dwProcessorType = PROCESSOR_PPC_601; break;
148 case 3:
149 case 6: si->dwProcessorType = PROCESSOR_PPC_603; break;
150 case 4: si->dwProcessorType = PROCESSOR_PPC_604; break;
151 case 9: si->dwProcessorType = PROCESSOR_PPC_604; break;
152 case 20: si->dwProcessorType = PROCESSOR_PPC_620; break;
153 default: si->dwProcessorType = 0;
155 break;
156 default: FIXME("Unknown processor architecture %x\n", sci.Architecture);
158 si->dwAllocationGranularity = sbi.AllocationGranularity;
159 si->wProcessorLevel = sci.Level;
160 si->wProcessorRevision = sci.Revision;
164 /***********************************************************************
165 * GetNativeSystemInfo [KERNEL32.@]
167 VOID WINAPI GetNativeSystemInfo(
168 LPSYSTEM_INFO si /* [out] Destination for system information, may not be NULL */)
170 static BOOL reported = FALSE;
171 if (!reported) {
172 FIXME("(%p) using GetSystemInfo()\n", si);
173 reported = TRUE;
174 } else
175 TRACE("(%p) using GetSystemInfo()\n", si);
176 GetSystemInfo(si);
179 /***********************************************************************
180 * IsProcessorFeaturePresent [KERNEL32.@]
182 * Determine if the cpu supports a given feature.
184 * RETURNS
185 * TRUE, If the processor supports feature,
186 * FALSE otherwise.
188 BOOL WINAPI IsProcessorFeaturePresent (
189 DWORD feature /* [in] Feature number, (PF_ constants from "winnt.h") */)
191 if (feature < 64)
192 return SHARED_DATA->ProcessorFeatures[feature];
193 else
194 return FALSE;