diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index cf18370bc11..d9c45139a26 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -329,12 +329,12 @@ @ stdcall CreateSymbolicLinkW(wstr wstr long) @ stdcall CreateTapePartition(long long long long) @ stdcall -import CreateThread(ptr long ptr long long ptr) -@ stdcall CreateThreadpool(ptr) -@ stdcall CreateThreadpoolCleanupGroup() -@ stdcall CreateThreadpoolIo(ptr ptr ptr ptr) -@ stdcall CreateThreadpoolTimer(ptr ptr ptr) -@ stdcall CreateThreadpoolWait(ptr ptr ptr) -@ stdcall CreateThreadpoolWork(ptr ptr ptr) +@ stdcall -import CreateThreadpool(ptr) +@ stdcall -import CreateThreadpoolCleanupGroup() +@ stdcall -import CreateThreadpoolIo(ptr ptr ptr ptr) +@ stdcall -import CreateThreadpoolTimer(ptr ptr ptr) +@ stdcall -import CreateThreadpoolWait(ptr ptr ptr) +@ stdcall -import CreateThreadpoolWork(ptr ptr ptr) @ stdcall -import CreateTimerQueue() @ stdcall -import CreateTimerQueueTimer(ptr long ptr ptr long long long) @ stdcall CreateToolhelp32Snapshot(long long) @@ -1462,8 +1462,8 @@ # @ stub SetThreadpoolStackInformation @ stdcall SetThreadpoolThreadMaximum(ptr long) ntdll.TpSetPoolMaxThreads @ stdcall SetThreadpoolThreadMinimum(ptr long) ntdll.TpSetPoolMinThreads -@ stdcall SetThreadpoolTimer(ptr ptr long long) -@ stdcall SetThreadpoolWait(ptr long ptr) +@ stdcall SetThreadpoolTimer(ptr ptr long long) ntdll.TpSetTimer +@ stdcall SetThreadpoolWait(ptr long ptr) ntdll.TpSetWait @ stdcall SetTimeZoneInformation(ptr) @ stub SetTimerQueueTimer @ stdcall -arch=x86_64 SetUmsThreadInformation(ptr long ptr long) @@ -1515,7 +1515,7 @@ @ stdcall TryAcquireSRWLockExclusive(ptr) ntdll.RtlTryAcquireSRWLockExclusive @ stdcall TryAcquireSRWLockShared(ptr) ntdll.RtlTryAcquireSRWLockShared @ stdcall TryEnterCriticalSection(ptr) ntdll.RtlTryEnterCriticalSection -@ stdcall TrySubmitThreadpoolCallback(ptr ptr ptr) +@ stdcall -import TrySubmitThreadpoolCallback(ptr ptr ptr) @ stdcall TzSpecificLocalTimeToSystemTime(ptr ptr ptr) # @ stub TzSpecificLocalTimeToSystemTimeEx # @ stub -arch=x86_64 uaw_lstrcmpW diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c index 02d2868111e..af9e2ce7033 100644 --- a/dlls/kernel32/thread.c +++ b/dlls/kernel32/thread.c @@ -242,177 +242,3 @@ BOOL WINAPI CallbackMayRunLong( TP_CALLBACK_INSTANCE *instance ) return TRUE; } - -/*********************************************************************** - * CreateThreadpool (KERNEL32.@) - */ -PTP_POOL WINAPI CreateThreadpool( PVOID reserved ) -{ - TP_POOL *pool; - NTSTATUS status; - - TRACE( "%p\n", reserved ); - - status = TpAllocPool( &pool, reserved ); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return NULL; - } - - return pool; -} - -/*********************************************************************** - * CreateThreadpoolCleanupGroup (KERNEL32.@) - */ -PTP_CLEANUP_GROUP WINAPI CreateThreadpoolCleanupGroup( void ) -{ - TP_CLEANUP_GROUP *group; - NTSTATUS status; - - TRACE( "\n" ); - - status = TpAllocCleanupGroup( &group ); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return NULL; - } - - return group; -} - -/*********************************************************************** - * CreateThreadpoolIo (KERNEL32.@) - */ -PTP_IO WINAPI CreateThreadpoolIo( HANDLE handle, PTP_WIN32_IO_CALLBACK callback, - PVOID userdata, TP_CALLBACK_ENVIRON *environment ) -{ - FIXME("(%p, %p, %p, %p): stub\n", handle, callback, userdata, environment); - return FALSE; -} - -/*********************************************************************** - * CreateThreadpoolTimer (KERNEL32.@) - */ -PTP_TIMER WINAPI CreateThreadpoolTimer( PTP_TIMER_CALLBACK callback, PVOID userdata, - TP_CALLBACK_ENVIRON *environment ) -{ - TP_TIMER *timer; - NTSTATUS status; - - TRACE( "%p, %p, %p\n", callback, userdata, environment ); - - status = TpAllocTimer( &timer, callback, userdata, environment ); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return NULL; - } - - return timer; -} - -/*********************************************************************** - * CreateThreadpoolWait (KERNEL32.@) - */ -PTP_WAIT WINAPI CreateThreadpoolWait( PTP_WAIT_CALLBACK callback, PVOID userdata, - TP_CALLBACK_ENVIRON *environment ) -{ - TP_WAIT *wait; - NTSTATUS status; - - TRACE( "%p, %p, %p\n", callback, userdata, environment ); - - status = TpAllocWait( &wait, callback, userdata, environment ); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return NULL; - } - - return wait; -} - -/*********************************************************************** - * CreateThreadpoolWork (KERNEL32.@) - */ -PTP_WORK WINAPI CreateThreadpoolWork( PTP_WORK_CALLBACK callback, PVOID userdata, - TP_CALLBACK_ENVIRON *environment ) -{ - TP_WORK *work; - NTSTATUS status; - - TRACE( "%p, %p, %p\n", callback, userdata, environment ); - - status = TpAllocWork( &work, callback, userdata, environment ); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return NULL; - } - - return work; -} - -/*********************************************************************** - * SetThreadpoolTimer (KERNEL32.@) - */ -VOID WINAPI SetThreadpoolTimer( TP_TIMER *timer, FILETIME *due_time, - DWORD period, DWORD window_length ) -{ - LARGE_INTEGER timeout; - - TRACE( "%p, %p, %u, %u\n", timer, due_time, period, window_length ); - - if (due_time) - { - timeout.u.LowPart = due_time->dwLowDateTime; - timeout.u.HighPart = due_time->dwHighDateTime; - } - - TpSetTimer( timer, due_time ? &timeout : NULL, period, window_length ); -} - -/*********************************************************************** - * SetThreadpoolWait (KERNEL32.@) - */ -VOID WINAPI SetThreadpoolWait( TP_WAIT *wait, HANDLE handle, FILETIME *due_time ) -{ - LARGE_INTEGER timeout; - - TRACE( "%p, %p, %p\n", wait, handle, due_time ); - - if (!handle) - { - due_time = NULL; - } - else if (due_time) - { - timeout.u.LowPart = due_time->dwLowDateTime; - timeout.u.HighPart = due_time->dwHighDateTime; - } - - TpSetWait( wait, handle, due_time ? &timeout : NULL ); -} - -/*********************************************************************** - * TrySubmitThreadpoolCallback (KERNEL32.@) - */ -BOOL WINAPI TrySubmitThreadpoolCallback( PTP_SIMPLE_CALLBACK callback, PVOID userdata, - TP_CALLBACK_ENVIRON *environment ) -{ - NTSTATUS status; - - TRACE( "%p, %p, %p\n", callback, userdata, environment ); - - status = TpSimpleTryPost( callback, userdata, environment ); - if (status) - { - SetLastError( RtlNtStatusToDosError(status) ); - return FALSE; - } - - return TRUE; -} diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index f88b6e7690f..2192ae54cad 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -223,12 +223,12 @@ # @ stub CreateStateSubcontainer @ stdcall CreateSymbolicLinkW(wstr wstr long) kernel32.CreateSymbolicLinkW @ stdcall CreateThread(ptr long ptr long long ptr) -@ stdcall CreateThreadpool(ptr) kernel32.CreateThreadpool -@ stdcall CreateThreadpoolCleanupGroup() kernel32.CreateThreadpoolCleanupGroup -@ stdcall CreateThreadpoolIo(ptr ptr ptr ptr) kernel32.CreateThreadpoolIo -@ stdcall CreateThreadpoolTimer(ptr ptr ptr) kernel32.CreateThreadpoolTimer -@ stdcall CreateThreadpoolWait(ptr ptr ptr) kernel32.CreateThreadpoolWait -@ stdcall CreateThreadpoolWork(ptr ptr ptr) kernel32.CreateThreadpoolWork +@ stdcall CreateThreadpool(ptr) +@ stdcall CreateThreadpoolCleanupGroup() +@ stdcall CreateThreadpoolIo(ptr ptr ptr ptr) +@ stdcall CreateThreadpoolTimer(ptr ptr ptr) +@ stdcall CreateThreadpoolWait(ptr ptr ptr) +@ stdcall CreateThreadpoolWork(ptr ptr ptr) @ stdcall CreateTimerQueue() @ stdcall CreateTimerQueueTimer(ptr long ptr ptr long long long) @ stdcall CreateWaitableTimerExW(ptr wstr long long) @@ -1609,7 +1609,7 @@ @ stdcall TryAcquireSRWLockExclusive(ptr) ntdll.RtlTryAcquireSRWLockExclusive @ stdcall TryAcquireSRWLockShared(ptr) ntdll.RtlTryAcquireSRWLockShared @ stdcall TryEnterCriticalSection(ptr) ntdll.RtlTryEnterCriticalSection -@ stdcall TrySubmitThreadpoolCallback(ptr ptr ptr) kernel32.TrySubmitThreadpoolCallback +@ stdcall TrySubmitThreadpoolCallback(ptr ptr ptr) @ stdcall TzSpecificLocalTimeToSystemTime(ptr ptr ptr) kernel32.TzSpecificLocalTimeToSystemTime @ stub TzSpecificLocalTimeToSystemTimeEx @ stdcall UnhandledExceptionFilter(ptr) kernel32.UnhandledExceptionFilter diff --git a/dlls/kernelbase/thread.c b/dlls/kernelbase/thread.c index bae4d209637..5f6c7ed6f34 100644 --- a/dlls/kernelbase/thread.c +++ b/dlls/kernelbase/thread.c @@ -493,3 +493,92 @@ BOOL WINAPI DECLSPEC_HOTPATCH TerminateThread( HANDLE handle, DWORD exit_code ) { return set_ntstatus( NtTerminateThread( handle, exit_code )); } + + +/*********************************************************************** + * Thread pool + ***********************************************************************/ + + +/*********************************************************************** + * CreateThreadpool (kernelbase.@) + */ +PTP_POOL WINAPI DECLSPEC_HOTPATCH CreateThreadpool( void *reserved ) +{ + TP_POOL *pool; + + if (!set_ntstatus( TpAllocPool( &pool, reserved ))) pool = NULL; + return pool; +} + + +/*********************************************************************** + * CreateThreadpoolCleanupGroup (kernelbase.@) + */ +PTP_CLEANUP_GROUP WINAPI DECLSPEC_HOTPATCH CreateThreadpoolCleanupGroup(void) +{ + TP_CLEANUP_GROUP *group; + + if (!set_ntstatus( TpAllocCleanupGroup( &group ))) return NULL; + return group; +} + + +/*********************************************************************** + * CreateThreadpoolIo (kernelbase.@) + */ +PTP_IO WINAPI DECLSPEC_HOTPATCH CreateThreadpoolIo( HANDLE handle, PTP_WIN32_IO_CALLBACK callback, + PVOID userdata, TP_CALLBACK_ENVIRON *environment ) +{ + FIXME( "(%p, %p, %p, %p): stub\n", handle, callback, userdata, environment ); + return FALSE; +} + + +/*********************************************************************** + * CreateThreadpoolTimer (kernelbase.@) + */ +PTP_TIMER WINAPI DECLSPEC_HOTPATCH CreateThreadpoolTimer( PTP_TIMER_CALLBACK callback, PVOID userdata, + TP_CALLBACK_ENVIRON *environment ) +{ + TP_TIMER *timer; + + if (!set_ntstatus( TpAllocTimer( &timer, callback, userdata, environment ))) return NULL; + return timer; +} + + +/*********************************************************************** + * CreateThreadpoolWait (kernelbase.@) + */ +PTP_WAIT WINAPI DECLSPEC_HOTPATCH CreateThreadpoolWait( PTP_WAIT_CALLBACK callback, PVOID userdata, + TP_CALLBACK_ENVIRON *environment ) +{ + TP_WAIT *wait; + + if (!set_ntstatus( TpAllocWait( &wait, callback, userdata, environment ))) return NULL; + return wait; +} + + +/*********************************************************************** + * CreateThreadpoolWork (kernelbase.@) + */ +PTP_WORK WINAPI DECLSPEC_HOTPATCH CreateThreadpoolWork( PTP_WORK_CALLBACK callback, PVOID userdata, + TP_CALLBACK_ENVIRON *environment ) +{ + TP_WORK *work; + + if (!set_ntstatus( TpAllocWork( &work, callback, userdata, environment ))) return NULL; + return work; +} + + +/*********************************************************************** + * TrySubmitThreadpoolCallback (kernelbase.@) + */ +BOOL WINAPI DECLSPEC_HOTPATCH TrySubmitThreadpoolCallback( PTP_SIMPLE_CALLBACK callback, PVOID userdata, + TP_CALLBACK_ENVIRON *environment ) +{ + return set_ntstatus( TpSimpleTryPost( callback, userdata, environment )); +}