2 * Win32 miscellaneous functions
4 * Copyright 1995 Thomas Sandford (tdgsandf@prds-grn.demon.co.uk)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /* Misc. new functions - they should be moved into appropriate files
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(win32);
35 WINE_DECLARE_DEBUG_CHANNEL(debug);
38 static BOOL QUERYPERF_Initialized = 0;
39 #if defined(__i386__) && defined(__GNUC__)
40 static BOOL QUERYPERF_RDTSC_Use = 0;
41 static LONGLONG QUERYPERF_RDTSC_Frequency = 0;
44 static void QUERYPERF_Init(void)
46 #if defined(__i386__) && defined(__GNUC__)
47 /* We are running on i386 and compiling on GCC.
48 * Do a runtime check to see if we have the rdtsc instruction available
51 char line[256], *s, *value;
56 if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE ))
58 /* rdtsc is available. However, in order to use it
59 * we also need to be able to get the processor's
60 * speed. Currently we do this by reading /proc/cpuinfo
61 * which makes it Linux-specific.
64 TRACE("rdtsc available\n");
66 fp = fopen( "/proc/cpuinfo", "r" );
69 while(fgets( line, sizeof(line), fp ))
71 /* NOTE: the ':' is the only character we can rely on */
72 if (!(value = strchr( line, ':' )))
75 /* terminate the valuename */
77 /* skip any leading spaces */
78 while (*value == ' ') value++;
79 if ((s = strchr( value, '\n' )))
82 if (!strncasecmp( line, "cpu MHz", strlen( "cpu MHz" ) ))
84 if (sscanf( value, "%lf", &cpuMHz ) == 1)
86 QUERYPERF_RDTSC_Frequency = (LONGLONG)(cpuMHz * 1000000.0);
87 QUERYPERF_RDTSC_Use = TRUE;
88 TRACE("using frequency: %lldHz\n", QUERYPERF_RDTSC_Frequency);
97 QUERYPERF_Initialized = TRUE;
101 /****************************************************************************
102 * QueryPerformanceCounter (KERNEL32.@)
104 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
108 if (!QUERYPERF_Initialized)
111 #if defined(__i386__) && defined(__GNUC__)
112 if (QUERYPERF_RDTSC_Use)
114 /* i586 optimized version */
115 __asm__ __volatile__ ( "rdtsc"
116 : "=a" (counter->s.LowPart), "=d" (counter->s.HighPart) );
119 /* fall back to generic routine (ie, for i386, i486) */
122 /* generic routine */
123 gettimeofday( &tv, NULL );
124 counter->QuadPart = (LONGLONG)tv.tv_usec + (LONGLONG)tv.tv_sec * 1000000LL;
128 /****************************************************************************
129 * QueryPerformanceFrequency (KERNEL32.@)
131 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
133 if (!QUERYPERF_Initialized)
136 #if defined(__i386__) && defined(__GNUC__)
137 if (QUERYPERF_RDTSC_Use)
139 frequency->QuadPart = QUERYPERF_RDTSC_Frequency;
144 frequency->s.LowPart = 1000000;
145 frequency->s.HighPart = 0;
149 /****************************************************************************
150 * FlushInstructionCache (KERNEL32.@)
152 BOOL WINAPI FlushInstructionCache(DWORD x,DWORD y,DWORD z) {
153 if (GetVersion() & 0x80000000) return TRUE; /* not NT, always TRUE */
154 FIXME_(debug)("(0x%08lx,0x%08lx,0x%08lx): stub\n",x,y,z);
158 /***********************************************************************
159 * GetSystemPowerStatus (KERNEL32.@)
161 BOOL WINAPI GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr)
163 return FALSE; /* no power management support */
167 /***********************************************************************
168 * SetSystemPowerState (KERNEL32.@)
170 BOOL WINAPI SetSystemPowerState(BOOL suspend_or_hibernate,
173 /* suspend_or_hibernate flag: w95 does not support
174 this feature anyway */
189 /******************************************************************************
190 * CreateMailslotA [KERNEL32.@]
192 HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
193 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa)
195 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName),
196 nMaxMessageSize, lReadTimeout, sa);
201 /******************************************************************************
202 * CreateMailslotW [KERNEL32.@] Creates a mailslot with specified name
205 * lpName [I] Pointer to string for mailslot name
206 * nMaxMessageSize [I] Maximum message size
207 * lReadTimeout [I] Milliseconds before read time-out
208 * sa [I] Pointer to security structure
211 * Success: Handle to mailslot
212 * Failure: INVALID_HANDLE_VALUE
214 HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
215 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
217 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName),
218 nMaxMessageSize, lReadTimeout, sa);
223 /******************************************************************************
224 * GetMailslotInfo [KERNEL32.@] Retrieves info about specified mailslot
227 * hMailslot [I] Mailslot handle
228 * lpMaxMessageSize [O] Address of maximum message size
229 * lpNextSize [O] Address of size of next message
230 * lpMessageCount [O] Address of number of messages
231 * lpReadTimeout [O] Address of read time-out
237 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
238 LPDWORD lpNextSize, LPDWORD lpMessageCount,
239 LPDWORD lpReadTimeout )
241 FIXME("(%04x): stub\n",hMailslot);
242 if (lpMaxMessageSize) *lpMaxMessageSize = (DWORD)NULL;
243 if (lpNextSize) *lpNextSize = (DWORD)NULL;
244 if (lpMessageCount) *lpMessageCount = (DWORD)NULL;
245 if (lpReadTimeout) *lpReadTimeout = (DWORD)NULL;
250 /******************************************************************************
251 * GetCompressedFileSizeA [KERNEL32.@]
254 * This should call the W function below
256 DWORD WINAPI GetCompressedFileSizeA(
258 LPDWORD lpFileSizeHigh)
260 FIXME("(...): stub\n");
265 /******************************************************************************
266 * GetCompressedFileSizeW [KERNEL32.@]
269 * Success: Low-order doubleword of number of bytes
270 * Failure: 0xffffffff
272 DWORD WINAPI GetCompressedFileSizeW(
273 LPCWSTR lpFileName, /* [in] Pointer to name of file */
274 LPDWORD lpFileSizeHigh) /* [out] Receives high-order doubleword of size */
276 FIXME("(%s,%p): stub\n",debugstr_w(lpFileName),lpFileSizeHigh);
281 /******************************************************************************
282 * SetComputerNameA [KERNEL32.@]
284 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
287 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
288 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
290 MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
291 ret = SetComputerNameW( nameW );
292 HeapFree( GetProcessHeap(), 0, nameW );
297 /******************************************************************************
298 * SetComputerNameW [KERNEL32.@]
301 * lpComputerName [I] Address of new computer name
305 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
307 FIXME("(%s): stub\n", debugstr_w(lpComputerName));
311 /******************************************************************************
312 * CreateIoCompletionPort (KERNEL32.@)
314 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
315 HANDLE hExistingCompletionPort, DWORD dwCompletionKey,
316 DWORD dwNumberOfConcurrentThreads)
318 FIXME("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
322 /******************************************************************************
323 * GetQueuedCompletionStatus (KERNEL32.@)
325 BOOL WINAPI GetQueuedCompletionStatus(
326 HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred,
327 LPDWORD lpCompletionKey, LPOVERLAPPED *lpOverlapped, DWORD dwMilliseconds
329 FIXME("(%x,%p,%p,%p,%ld), stub!\n",CompletionPort,lpNumberOfBytesTransferred,lpCompletionKey,lpOverlapped,dwMilliseconds);
330 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);