Compile the imagehlp dll with STRICT defined.
[wine/multimedia.git] / win32 / newfns.c
blobf2ef642e11773348fb6ef0fce254b67db2aa2d3a
1 /*
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
22 at a later date. */
24 #include "config.h"
25 #include "wine/port.h"
27 #include <stdio.h>
28 #include <string.h>
29 #ifdef HAVE_SYS_TIME_H
30 # include <sys/time.h>
31 #endif
32 #ifdef HAVE_UNISTD_H
33 # include <unistd.h>
34 #endif
35 #include "windef.h"
36 #include "winbase.h"
37 #include "winnls.h"
38 #include "winerror.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;
49 #endif
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
57 FILE *fp;
58 char line[256], *s, *value;
59 double cpuMHz;
61 TRACE("()\n");
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" );
74 if (fp)
76 while(fgets( line, sizeof(line), fp ))
78 /* NOTE: the ':' is the only character we can rely on */
79 if (!(value = strchr( line, ':' )))
80 continue;
82 /* terminate the valuename */
83 *value++ = '\0';
84 /* skip any leading spaces */
85 while (*value == ' ') value++;
86 if ((s = strchr( value, '\n' )))
87 *s = '\0';
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);
96 break;
100 fclose(fp);
103 #endif
104 QUERYPERF_Initialized = TRUE;
108 /****************************************************************************
109 * QueryPerformanceCounter (KERNEL32.@)
111 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
113 struct timeval tv;
115 if (!QUERYPERF_Initialized)
116 QUERYPERF_Init();
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) );
124 return TRUE;
126 /* fall back to generic routine (ie, for i386, i486) */
127 #endif
129 /* generic routine */
130 gettimeofday( &tv, NULL );
131 counter->QuadPart = (LONGLONG)tv.tv_usec + (LONGLONG)tv.tv_sec * 1000000;
132 return TRUE;
135 /****************************************************************************
136 * QueryPerformanceFrequency (KERNEL32.@)
138 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
140 if (!QUERYPERF_Initialized)
141 QUERYPERF_Init();
143 #if defined(__i386__) && defined(__GNUC__)
144 if (QUERYPERF_RDTSC_Use)
146 frequency->QuadPart = QUERYPERF_RDTSC_Frequency;
147 return TRUE;
149 #endif
151 frequency->s.LowPart = 1000000;
152 frequency->s.HighPart = 0;
153 return TRUE;
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);
163 return TRUE;
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,
179 BOOL force_flag)
181 /* suspend_or_hibernate flag: w95 does not support
182 this feature anyway */
184 for ( ;0; )
186 if ( force_flag )
189 else
193 return TRUE;
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);
205 return (HANDLE)1;
209 /******************************************************************************
210 * CreateMailslotW [KERNEL32.@] Creates a mailslot with specified name
212 * PARAMS
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
218 * RETURNS
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);
227 return (HANDLE)1;
231 /******************************************************************************
232 * GetMailslotInfo [KERNEL32.@] Retrieves info about specified mailslot
234 * PARAMS
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
241 * RETURNS
242 * Success: TRUE
243 * Failure: FALSE
245 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
246 LPDWORD lpNextSize, LPDWORD lpMessageCount,
247 LPDWORD lpReadTimeout )
249 FIXME("(%04x): 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;
254 return TRUE;
258 /******************************************************************************
259 * GetCompressedFileSizeA [KERNEL32.@]
261 * NOTES
262 * This should call the W function below
264 DWORD WINAPI GetCompressedFileSizeA(
265 LPCSTR lpFileName,
266 LPDWORD lpFileSizeHigh)
268 FIXME("(...): stub\n");
269 return 0xffffffff;
273 /******************************************************************************
274 * GetCompressedFileSizeW [KERNEL32.@]
276 * RETURNS
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);
285 return 0xffffffff;
289 /******************************************************************************
290 * SetComputerNameA [KERNEL32.@]
292 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
294 BOOL ret;
295 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
296 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
298 MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
299 ret = SetComputerNameW( nameW );
300 HeapFree( GetProcessHeap(), 0, nameW );
301 return ret;
305 /******************************************************************************
306 * SetComputerNameW [KERNEL32.@]
308 * PARAMS
309 * lpComputerName [I] Address of new computer name
311 * RETURNS STD
313 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
315 FIXME("(%s): stub\n", debugstr_w(lpComputerName));
316 return TRUE;
319 /******************************************************************************
320 * CreateIoCompletionPort (KERNEL32.@)
322 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle,
323 HANDLE hExistingCompletionPort, DWORD dwCompletionKey,
324 DWORD dwNumberOfConcurrentThreads)
326 FIXME("(%04x, %04x, %08lx, %08lx): stub.\n", hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
327 return (HANDLE)NULL;
330 /******************************************************************************
331 * GetQueuedCompletionStatus (KERNEL32.@)
333 BOOL WINAPI GetQueuedCompletionStatus(
334 HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred,
335 LPDWORD lpCompletionKey, LPOVERLAPPED *lpOverlapped, DWORD dwMilliseconds
337 FIXME("(%x,%p,%p,%p,%ld), stub!\n",CompletionPort,lpNumberOfBytesTransferred,lpCompletionKey,lpOverlapped,dwMilliseconds);
338 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
339 return FALSE;