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(HANDLE hProcess
, LPCVOID lpBaseAddress
, DWORD dwSize
)
154 if (GetVersion() & 0x80000000) return TRUE
; /* not NT, always TRUE */
155 FIXME_(debug
)("(0x%08lx,%p,0x%08lx): stub\n",(DWORD
)hProcess
, lpBaseAddress
, dwSize
);
159 /***********************************************************************
160 * GetSystemPowerStatus (KERNEL32.@)
162 BOOL WINAPI
GetSystemPowerStatus(LPSYSTEM_POWER_STATUS sps_ptr
)
164 return FALSE
; /* no power management support */
168 /***********************************************************************
169 * SetSystemPowerState (KERNEL32.@)
171 BOOL WINAPI
SetSystemPowerState(BOOL suspend_or_hibernate
,
174 /* suspend_or_hibernate flag: w95 does not support
175 this feature anyway */
190 /******************************************************************************
191 * CreateMailslotA [KERNEL32.@]
193 HANDLE WINAPI
CreateMailslotA( LPCSTR lpName
, DWORD nMaxMessageSize
,
194 DWORD lReadTimeout
, LPSECURITY_ATTRIBUTES sa
)
196 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_a(lpName
),
197 nMaxMessageSize
, lReadTimeout
, sa
);
202 /******************************************************************************
203 * CreateMailslotW [KERNEL32.@] Creates a mailslot with specified name
206 * lpName [I] Pointer to string for mailslot name
207 * nMaxMessageSize [I] Maximum message size
208 * lReadTimeout [I] Milliseconds before read time-out
209 * sa [I] Pointer to security structure
212 * Success: Handle to mailslot
213 * Failure: INVALID_HANDLE_VALUE
215 HANDLE WINAPI
CreateMailslotW( LPCWSTR lpName
, DWORD nMaxMessageSize
,
216 DWORD lReadTimeout
, LPSECURITY_ATTRIBUTES sa
)
218 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName
),
219 nMaxMessageSize
, lReadTimeout
, sa
);
224 /******************************************************************************
225 * GetMailslotInfo [KERNEL32.@] Retrieves info about specified mailslot
228 * hMailslot [I] Mailslot handle
229 * lpMaxMessageSize [O] Address of maximum message size
230 * lpNextSize [O] Address of size of next message
231 * lpMessageCount [O] Address of number of messages
232 * lpReadTimeout [O] Address of read time-out
238 BOOL WINAPI
GetMailslotInfo( HANDLE hMailslot
, LPDWORD lpMaxMessageSize
,
239 LPDWORD lpNextSize
, LPDWORD lpMessageCount
,
240 LPDWORD lpReadTimeout
)
242 FIXME("(%04x): stub\n",hMailslot
);
243 if (lpMaxMessageSize
) *lpMaxMessageSize
= (DWORD
)NULL
;
244 if (lpNextSize
) *lpNextSize
= (DWORD
)NULL
;
245 if (lpMessageCount
) *lpMessageCount
= (DWORD
)NULL
;
246 if (lpReadTimeout
) *lpReadTimeout
= (DWORD
)NULL
;
251 /******************************************************************************
252 * GetCompressedFileSizeA [KERNEL32.@]
255 * This should call the W function below
257 DWORD WINAPI
GetCompressedFileSizeA(
259 LPDWORD lpFileSizeHigh
)
261 FIXME("(...): stub\n");
266 /******************************************************************************
267 * GetCompressedFileSizeW [KERNEL32.@]
270 * Success: Low-order doubleword of number of bytes
271 * Failure: 0xffffffff
273 DWORD WINAPI
GetCompressedFileSizeW(
274 LPCWSTR lpFileName
, /* [in] Pointer to name of file */
275 LPDWORD lpFileSizeHigh
) /* [out] Receives high-order doubleword of size */
277 FIXME("(%s,%p): stub\n",debugstr_w(lpFileName
),lpFileSizeHigh
);
282 /******************************************************************************
283 * SetComputerNameA [KERNEL32.@]
285 BOOL WINAPI
SetComputerNameA( LPCSTR lpComputerName
)
288 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, lpComputerName
, -1, NULL
, 0 );
289 LPWSTR nameW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
291 MultiByteToWideChar( CP_ACP
, 0, lpComputerName
, -1, nameW
, len
);
292 ret
= SetComputerNameW( nameW
);
293 HeapFree( GetProcessHeap(), 0, nameW
);
298 /******************************************************************************
299 * SetComputerNameW [KERNEL32.@]
302 * lpComputerName [I] Address of new computer name
306 BOOL WINAPI
SetComputerNameW( LPCWSTR lpComputerName
)
308 FIXME("(%s): stub\n", debugstr_w(lpComputerName
));
312 /******************************************************************************
313 * CreateIoCompletionPort (KERNEL32.@)
315 HANDLE WINAPI
CreateIoCompletionPort(HANDLE hFileHandle
,
316 HANDLE hExistingCompletionPort
, DWORD dwCompletionKey
,
317 DWORD dwNumberOfConcurrentThreads
)
319 FIXME("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle
, hExistingCompletionPort
, dwCompletionKey
, dwNumberOfConcurrentThreads
);
323 /******************************************************************************
324 * GetQueuedCompletionStatus (KERNEL32.@)
326 BOOL WINAPI
GetQueuedCompletionStatus(
327 HANDLE CompletionPort
, LPDWORD lpNumberOfBytesTransferred
,
328 LPDWORD lpCompletionKey
, LPOVERLAPPED
*lpOverlapped
, DWORD dwMilliseconds
330 FIXME("(%x,%p,%p,%p,%ld), stub!\n",CompletionPort
,lpNumberOfBytesTransferred
,lpCompletionKey
,lpOverlapped
,dwMilliseconds
);
331 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);