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
25 #include "wine/port.h"
29 #ifdef HAVE_SYS_TIME_H
30 # include <sys/time.h>
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(win32
);
42 WINE_DECLARE_DEBUG_CHANNEL(debug
);
45 static BOOL QUERYPERF_Initialized
= 0;
46 #if defined(__i386__) && defined(__GNUC__)
47 static BOOL QUERYPERF_RDTSC_Use
= 0;
48 static LONGLONG QUERYPERF_RDTSC_Frequency
= 0;
51 static void QUERYPERF_Init(void)
53 #if defined(__i386__) && defined(__GNUC__)
54 /* We are running on i386 and compiling on GCC.
55 * Do a runtime check to see if we have the rdtsc instruction available
58 char line
[256], *s
, *value
;
63 if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE
))
65 /* rdtsc is available. However, in order to use it
66 * we also need to be able to get the processor's
67 * speed. Currently we do this by reading /proc/cpuinfo
68 * which makes it Linux-specific.
71 TRACE("rdtsc available\n");
73 fp
= fopen( "/proc/cpuinfo", "r" );
76 while(fgets( line
, sizeof(line
), fp
))
78 /* NOTE: the ':' is the only character we can rely on */
79 if (!(value
= strchr( line
, ':' )))
82 /* terminate the valuename */
84 /* skip any leading spaces */
85 while (*value
== ' ') value
++;
86 if ((s
= strchr( value
, '\n' )))
89 if (!strncasecmp( line
, "cpu MHz", strlen( "cpu MHz" ) ))
91 if (sscanf( value
, "%lf", &cpuMHz
) == 1)
93 QUERYPERF_RDTSC_Frequency
= (LONGLONG
)(cpuMHz
* 1000000.0);
94 QUERYPERF_RDTSC_Use
= TRUE
;
95 TRACE("using frequency: %lldHz\n", QUERYPERF_RDTSC_Frequency
);
104 QUERYPERF_Initialized
= TRUE
;
108 /****************************************************************************
109 * QueryPerformanceCounter (KERNEL32.@)
111 BOOL WINAPI
QueryPerformanceCounter(PLARGE_INTEGER counter
)
115 if (!QUERYPERF_Initialized
)
118 #if defined(__i386__) && defined(__GNUC__)
119 if (QUERYPERF_RDTSC_Use
)
121 /* i586 optimized version */
122 __asm__
__volatile__ ( "rdtsc"
123 : "=a" (counter
->s
.LowPart
), "=d" (counter
->s
.HighPart
) );
126 /* fall back to generic routine (ie, for i386, i486) */
129 /* generic routine */
130 gettimeofday( &tv
, NULL
);
131 counter
->QuadPart
= (LONGLONG
)tv
.tv_usec
+ (LONGLONG
)tv
.tv_sec
* 1000000;
135 /****************************************************************************
136 * QueryPerformanceFrequency (KERNEL32.@)
138 BOOL WINAPI
QueryPerformanceFrequency(PLARGE_INTEGER frequency
)
140 if (!QUERYPERF_Initialized
)
143 #if defined(__i386__) && defined(__GNUC__)
144 if (QUERYPERF_RDTSC_Use
)
146 frequency
->QuadPart
= QUERYPERF_RDTSC_Frequency
;
151 frequency
->s
.LowPart
= 1000000;
152 frequency
->s
.HighPart
= 0;
156 /****************************************************************************
157 * FlushInstructionCache (KERNEL32.@)
159 BOOL WINAPI
FlushInstructionCache(HANDLE hProcess
, LPCVOID lpBaseAddress
, SIZE_T dwSize
)
161 if (GetVersion() & 0x80000000) return TRUE
; /* not NT, always TRUE */
162 FIXME_(debug
)("(0x%08lx,%p,0x%08lx): stub\n",(DWORD
)hProcess
, lpBaseAddress
, dwSize
);
166 /***********************************************************************
167 * GetSystemPowerStatus (KERNEL32.@)
169 BOOL WINAPI
GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr
)
171 return FALSE
; /* no power management support */
175 /***********************************************************************
176 * SetSystemPowerState (KERNEL32.@)
178 BOOL WINAPI
SetSystemPowerState(BOOL suspend_or_hibernate
,
181 /* suspend_or_hibernate flag: w95 does not support
182 this feature anyway */
197 /******************************************************************************
198 * CreateMailslotA [KERNEL32.@]
200 HANDLE WINAPI
CreateMailslotA( LPCSTR lpName
, DWORD nMaxMessageSize
,
201 DWORD lReadTimeout
, LPSECURITY_ATTRIBUTES sa
)
203 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName
),
204 nMaxMessageSize
, lReadTimeout
, sa
);
209 /******************************************************************************
210 * CreateMailslotW [KERNEL32.@] Creates a mailslot with specified name
213 * lpName [I] Pointer to string for mailslot name
214 * nMaxMessageSize [I] Maximum message size
215 * lReadTimeout [I] Milliseconds before read time-out
216 * sa [I] Pointer to security structure
219 * Success: Handle to mailslot
220 * Failure: INVALID_HANDLE_VALUE
222 HANDLE WINAPI
CreateMailslotW( LPCWSTR lpName
, DWORD nMaxMessageSize
,
223 DWORD lReadTimeout
, LPSECURITY_ATTRIBUTES sa
)
225 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName
),
226 nMaxMessageSize
, lReadTimeout
, sa
);
231 /******************************************************************************
232 * GetMailslotInfo [KERNEL32.@] Retrieves info about specified mailslot
235 * hMailslot [I] Mailslot handle
236 * lpMaxMessageSize [O] Address of maximum message size
237 * lpNextSize [O] Address of size of next message
238 * lpMessageCount [O] Address of number of messages
239 * lpReadTimeout [O] Address of read time-out
245 BOOL WINAPI
GetMailslotInfo( HANDLE hMailslot
, LPDWORD lpMaxMessageSize
,
246 LPDWORD lpNextSize
, LPDWORD lpMessageCount
,
247 LPDWORD lpReadTimeout
)
249 FIXME("(%p): stub\n",hMailslot
);
250 if (lpMaxMessageSize
) *lpMaxMessageSize
= (DWORD
)NULL
;
251 if (lpNextSize
) *lpNextSize
= (DWORD
)NULL
;
252 if (lpMessageCount
) *lpMessageCount
= (DWORD
)NULL
;
253 if (lpReadTimeout
) *lpReadTimeout
= (DWORD
)NULL
;
258 /******************************************************************************
259 * GetCompressedFileSizeA [KERNEL32.@]
262 * This should call the W function below
264 DWORD WINAPI
GetCompressedFileSizeA(
266 LPDWORD lpFileSizeHigh
)
268 FIXME("(...): stub\n");
273 /******************************************************************************
274 * GetCompressedFileSizeW [KERNEL32.@]
277 * Success: Low-order doubleword of number of bytes
278 * Failure: 0xffffffff
280 DWORD WINAPI
GetCompressedFileSizeW(
281 LPCWSTR lpFileName
, /* [in] Pointer to name of file */
282 LPDWORD lpFileSizeHigh
) /* [out] Receives high-order doubleword of size */
284 FIXME("(%s,%p): stub\n",debugstr_w(lpFileName
),lpFileSizeHigh
);
289 /******************************************************************************
290 * CreateIoCompletionPort (KERNEL32.@)
292 HANDLE WINAPI
CreateIoCompletionPort(HANDLE hFileHandle
,
293 HANDLE hExistingCompletionPort
, DWORD dwCompletionKey
,
294 DWORD dwNumberOfConcurrentThreads
)
296 FIXME("(%p, %p, %08lx, %08lx): stub.\n", hFileHandle
, hExistingCompletionPort
, dwCompletionKey
, dwNumberOfConcurrentThreads
);
300 /******************************************************************************
301 * GetQueuedCompletionStatus (KERNEL32.@)
303 BOOL WINAPI
GetQueuedCompletionStatus(
304 HANDLE CompletionPort
, LPDWORD lpNumberOfBytesTransferred
,
305 LPDWORD lpCompletionKey
, LPOVERLAPPED
*lpOverlapped
, DWORD dwMilliseconds
307 FIXME("(%p,%p,%p,%p,%ld), stub!\n",CompletionPort
,lpNumberOfBytesTransferred
,lpCompletionKey
,lpOverlapped
,dwMilliseconds
);
308 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);