From 84eaaa168f6beb0cbcda4da269527c68d3e15f83 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Wed, 3 Nov 2004 22:18:44 +0000 Subject: [PATCH] Fix broken thread start routines. --- dlls/kernel/task.c | 5 +++-- dlls/kernel/tests/change.c | 2 +- dlls/kernel/tests/thread.c | 35 +++++++++++++++++++---------------- dlls/winmm/mmsystem.c | 12 +++++++----- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/dlls/kernel/task.c b/dlls/kernel/task.c index 394c652934..5af1482f14 100644 --- a/dlls/kernel/task.c +++ b/dlls/kernel/task.c @@ -453,8 +453,9 @@ static WIN16_SUBSYSTEM_TIB *allocate_win16_tib( TDB *pTask ) } /* startup routine for a new 16-bit thread */ -static DWORD CALLBACK task_start( TDB *pTask ) +static DWORD CALLBACK task_start( LPVOID p ) { + TDB *pTask = (TDB *)p; DWORD ret; NtCurrentTeb()->htask16 = pTask->hSelf; @@ -480,7 +481,7 @@ HTASK16 TASK_SpawnTask( NE_MODULE *pModule, WORD cmdShow, TDB *pTask; if (!(pTask = TASK_Create( pModule, cmdShow, cmdline, len ))) return 0; - if (!(*hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)task_start, pTask, 0, NULL ))) + if (!(*hThread = CreateThread( NULL, 0, task_start, pTask, 0, NULL ))) { TASK_DeleteTask( pTask->hSelf ); return 0; diff --git a/dlls/kernel/tests/change.c b/dlls/kernel/tests/change.c index 88353f5538..565ff11845 100644 --- a/dlls/kernel/tests/change.c +++ b/dlls/kernel/tests/change.c @@ -58,7 +58,7 @@ static HANDLE StartNotificationThread(LPCSTR path, BOOL subtree, DWORD flags) change = FindFirstChangeNotificationA(path, subtree, flags); ok(change != INVALID_HANDLE_VALUE, "FindFirstChangeNotification error: %ld\n", GetLastError()); - thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NotificationThread, (LPVOID)change, + thread = CreateThread(NULL, 0, NotificationThread, (LPVOID)change, 0, &threadId); ok(thread != INVALID_HANDLE_VALUE, "CreateThread error: %ld\n", GetLastError()); diff --git a/dlls/kernel/tests/thread.c b/dlls/kernel/tests/thread.c index e9b8b2d42a..aa578fff9e 100644 --- a/dlls/kernel/tests/thread.c +++ b/dlls/kernel/tests/thread.c @@ -86,8 +86,9 @@ typedef struct { that the thread local storage routines work correctly, and that threads actually run concurrently */ -VOID WINAPI threadFunc1(t1Struct *tstruct) +DWORD WINAPI threadFunc1(LPVOID p) { + t1Struct *tstruct = (t1Struct *)p; int i; /* write our thread # into shared memory */ tstruct->threadmem[tstruct->threadnum]=GetCurrentThreadId(); @@ -107,34 +108,36 @@ VOID WINAPI threadFunc1(t1Struct *tstruct) /* Check that noone cahnged our tls memory */ ok((int)TlsGetValue(tlsIndex)-1==tstruct->threadnum, "TlsGetValue failed\n"); - ExitThread(NUM_THREADS+tstruct->threadnum); + return NUM_THREADS+tstruct->threadnum; } -VOID WINAPI threadFunc2() +DWORD WINAPI threadFunc2(LPVOID p) { - ExitThread(99); + return 99; } -VOID WINAPI threadFunc3() +DWORD WINAPI threadFunc3(LPVOID p) { HANDLE thread; thread=GetCurrentThread(); SuspendThread(thread); - ExitThread(99); + return 99; } -VOID WINAPI threadFunc4(HANDLE event) +DWORD WINAPI threadFunc4(LPVOID p) { + HANDLE event = (HANDLE)p; if(event != NULL) { SetEvent(event); } Sleep(99000); - ExitThread(0); + return 0; } #if CHECK_STACK -VOID WINAPI threadFunc5(DWORD *exitCode) +DWORD WINAPI threadFunc5(LPVOID p) { + DWORD *exitCode = (DWORD *)p; SYSTEM_INFO sysInfo; sysInfo.dwPageSize=0; GetSystemInfo(&sysInfo); @@ -147,7 +150,7 @@ VOID WINAPI threadFunc5(DWORD *exitCode) *exitCode=1; } __ENDTRY - ExitThread(0); + return 0; } #endif @@ -179,7 +182,7 @@ VOID test_CreateThread_basic() /* Test that passing arguments to threads works okay */ for(i=0;i0,"GetSystemInfo should return a valid page size\n"); thread = CreateThread(NULL,sysInfo.dwPageSize, - (LPTHREAD_START_ROUTINE)threadFunc5,&exitCode, + threadFunc5,&exitCode, 0,&threadId); ok(WaitForSingleObject(thread,5000)==WAIT_OBJECT_0, "TerminateThread didn't work\n"); @@ -461,7 +464,7 @@ VOID test_GetThreadTimes() DWORD threadId; int error; - thread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadFunc2,NULL, + thread = CreateThread(NULL,0,threadFunc2,NULL, CREATE_SUSPENDED,&threadId); ok(thread!=NULL,"Create Thread failed\n"); diff --git a/dlls/winmm/mmsystem.c b/dlls/winmm/mmsystem.c index 563c79ee11..7ee73c8ecf 100644 --- a/dlls/winmm/mmsystem.c +++ b/dlls/winmm/mmsystem.c @@ -1893,7 +1893,7 @@ static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16 h) return (WINE_MMTHREAD*)MapSL( MAKESEGPTR(h, 0) ); } -void WINAPI WINE_mmThreadEntryPoint(DWORD); +DWORD WINAPI WINE_mmThreadEntryPoint(LPVOID); /************************************************************************** * mmThreadCreate [MMSYSTEM.1120] @@ -1951,8 +1951,8 @@ LRESULT WINAPI mmThreadCreate16(FARPROC16 fpThreadAddr, LPHANDLE16 lpHndl, DWORD /* lpMMThd->hVxD = OpenVxDHandle(lpMMThd->hEvent); */ } - lpMMThd->hThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)WINE_mmThreadEntryPoint, - (LPVOID)(DWORD)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID); + lpMMThd->hThread = CreateThread(0, 0, WINE_mmThreadEntryPoint, + (LPVOID)(DWORD_PTR)hndl, CREATE_SUSPENDED, &lpMMThd->dwThreadID); if (lpMMThd->hThread == 0) { WARN("Couldn't create thread\n"); /* clean-up(VxDhandle...); devicedirectio... */ @@ -2143,9 +2143,9 @@ HANDLE16 WINAPI mmThreadGetTask16(HANDLE16 hndl) /************************************************************************** * __wine_mmThreadEntryPoint (MMSYSTEM.2047) */ -void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt) +DWORD WINAPI WINE_mmThreadEntryPoint(LPVOID p) { - HANDLE16 hndl = (HANDLE16)_pmt; + HANDLE16 hndl = (HANDLE16)(DWORD_PTR)p; WINE_MMTHREAD* lpMMThd = WINMM_GetmmThread(hndl); TRACE("(%04x %p)\n", hndl, lpMMThd); @@ -2173,6 +2173,8 @@ void WINAPI WINE_mmThreadEntryPoint(DWORD _pmt) CloseHandle(lpMMThd->hEvent); GlobalFree16(hndl); TRACE("done\n"); + + return 0; } typedef BOOL16 (WINAPI *MMCPLCALLBACK)(HWND, LPCSTR, LPCSTR, LPCSTR);