From: Alex Henrie alexhenrie24@gmail.com
These functions were moved from winmm.dll to kernel32.dll in Windows 8.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58839 --- dlls/kernel32/Makefile.in | 1 + dlls/kernel32/kernel32.spec | 5 ++ dlls/kernel32/time.c | 99 +++++++++++++++++++++++++++++++++++++ dlls/winmm/time.c | 80 ------------------------------ dlls/winmm/winmm.spec | 10 ++-- 5 files changed, 110 insertions(+), 85 deletions(-) create mode 100644 dlls/kernel32/time.c
diff --git a/dlls/kernel32/Makefile.in b/dlls/kernel32/Makefile.in index 66cd9916673..70cb7022926 100644 --- a/dlls/kernel32/Makefile.in +++ b/dlls/kernel32/Makefile.in @@ -27,6 +27,7 @@ SOURCES = \ sync.c \ tape.c \ thread.c \ + time.c \ toolhelp.c \ version.c \ version.rc \ diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 3bb49206c6b..e332ede7733 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -1714,6 +1714,11 @@ @ stdcall -import lstrlen(str) @ stdcall -import lstrlenA(str) @ stdcall -import lstrlenW(wstr) +@ stdcall timeBeginPeriod(long) +@ stdcall timeEndPeriod(long) +@ stdcall timeGetDevCaps(ptr long) +@ stdcall timeGetSystemTime(ptr long) +@ stdcall timeGetTime()
################################################################ # Wine internal extensions diff --git a/dlls/kernel32/time.c b/dlls/kernel32/time.c new file mode 100644 index 00000000000..003ed271c46 --- /dev/null +++ b/dlls/kernel32/time.c @@ -0,0 +1,99 @@ +/* + * MMSYSTEM time functions + * + * Copyright 1993 Martin Ayotte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" + +#define _WINMM_ +#include "mmsystem.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mmtime); + +#define MMSYSTIME_MININTERVAL (1) +#define MMSYSTIME_MAXINTERVAL (65535) + +DWORD WINAPI timeGetTime(void) +{ + LARGE_INTEGER now, freq; + + QueryPerformanceCounter(&now); + QueryPerformanceFrequency(&freq); + + return (now.QuadPart * 1000) / freq.QuadPart; +} + +MMRESULT WINAPI timeGetSystemTime(MMTIME *time, UINT size) +{ + if (size >= sizeof(*time)) + { + time->wType = TIME_MS; + time->u.ms = timeGetTime(); + } + + return 0; +} + +MMRESULT WINAPI timeGetDevCaps(TIMECAPS *caps, UINT size) +{ + TRACE("(%p, %u)\n", caps, size); + + if (!caps) + { + WARN("invalid caps\n"); + return TIMERR_NOCANDO; + } + + if (size < sizeof(TIMECAPS)) + { + WARN("invalid size\n"); + return TIMERR_NOCANDO; + } + + caps->wPeriodMin = MMSYSTIME_MININTERVAL; + caps->wPeriodMax = MMSYSTIME_MAXINTERVAL; + + return 0; +} + +MMRESULT WINAPI timeBeginPeriod(UINT period) +{ + if (period < MMSYSTIME_MININTERVAL || period > MMSYSTIME_MAXINTERVAL) + return TIMERR_NOCANDO; + + if (period > MMSYSTIME_MININTERVAL) + WARN("Stub; we set our timer resolution at minimum\n"); + + return 0; +} + +MMRESULT WINAPI timeEndPeriod(UINT period) +{ + if (period < MMSYSTIME_MININTERVAL || period > MMSYSTIME_MAXINTERVAL) + return TIMERR_NOCANDO; + + if (period > MMSYSTIME_MININTERVAL) + WARN("Stub; we set our timer resolution at minimum\n"); + + return 0; +} diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c index e00b5ca7b54..e03bbac34c6 100644 --- a/dlls/winmm/time.c +++ b/dlls/winmm/time.c @@ -22,7 +22,6 @@
#include <stdarg.h> #include <errno.h> -#include <time.h>
#include "windef.h" #include "winbase.h" @@ -236,32 +235,6 @@ void TIME_MMTimeStop(void) } }
-/************************************************************************** - * timeGetSystemTime [WINMM.@] - */ -MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize) -{ - if (wSize >= sizeof(*lpTime)) { - lpTime->wType = TIME_MS; - lpTime->u.ms = timeGetTime(); - } - - return 0; -} - -/************************************************************************** - * timeGetTime [WINMM.@] - */ -DWORD WINAPI timeGetTime(void) -{ - LARGE_INTEGER now, freq; - - QueryPerformanceCounter(&now); - QueryPerformanceFrequency(&freq); - - return (now.QuadPart * 1000) / freq.QuadPart; -} - /************************************************************************** * timeSetEvent [WINMM.@] */ @@ -343,56 +316,3 @@ MMRESULT WINAPI timeKillEvent(UINT wID) WakeConditionVariable(&TIME_cv); return TIMERR_NOERROR; } - -/************************************************************************** - * timeGetDevCaps [WINMM.@] - */ -MMRESULT WINAPI timeGetDevCaps(LPTIMECAPS lpCaps, UINT wSize) -{ - TRACE("(%p, %u)\n", lpCaps, wSize); - - if (lpCaps == 0) { - WARN("invalid lpCaps\n"); - return TIMERR_NOCANDO; - } - - if (wSize < sizeof(TIMECAPS)) { - WARN("invalid wSize\n"); - return TIMERR_NOCANDO; - } - - lpCaps->wPeriodMin = MMSYSTIME_MININTERVAL; - lpCaps->wPeriodMax = MMSYSTIME_MAXINTERVAL; - return TIMERR_NOERROR; -} - -/************************************************************************** - * timeBeginPeriod [WINMM.@] - */ -MMRESULT WINAPI timeBeginPeriod(UINT wPeriod) -{ - if (wPeriod < MMSYSTIME_MININTERVAL || wPeriod > MMSYSTIME_MAXINTERVAL) - return TIMERR_NOCANDO; - - if (wPeriod > MMSYSTIME_MININTERVAL) - { - WARN("Stub; we set our timer resolution at minimum\n"); - } - - return 0; -} - -/************************************************************************** - * timeEndPeriod [WINMM.@] - */ -MMRESULT WINAPI timeEndPeriod(UINT wPeriod) -{ - if (wPeriod < MMSYSTIME_MININTERVAL || wPeriod > MMSYSTIME_MAXINTERVAL) - return TIMERR_NOCANDO; - - if (wPeriod > MMSYSTIME_MININTERVAL) - { - WARN("Stub; we set our timer resolution at minimum\n"); - } - return 0; -} diff --git a/dlls/winmm/winmm.spec b/dlls/winmm/winmm.spec index d7c7379d77c..ff4c64683ac 100644 --- a/dlls/winmm/winmm.spec +++ b/dlls/winmm/winmm.spec @@ -143,11 +143,11 @@ @ stdcall mmsystemGetVersion() @ stdcall sndPlaySoundA(ptr long) @ stdcall sndPlaySoundW(ptr long) -@ stdcall timeBeginPeriod(long) -@ stdcall timeEndPeriod(long) -@ stdcall timeGetDevCaps(ptr long) -@ stdcall timeGetSystemTime(ptr long) -@ stdcall timeGetTime() +@ stdcall -import timeBeginPeriod(long) +@ stdcall -import timeEndPeriod(long) +@ stdcall -import timeGetDevCaps(ptr long) +@ stdcall -import timeGetSystemTime(ptr long) +@ stdcall -import timeGetTime() @ stdcall timeKillEvent(long) @ stdcall timeSetEvent(long long ptr long long) @ stdcall waveInAddBuffer(long ptr long)