1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * PROJECT:         ReactOS Tests
3*c2c66affSColin Finck  * LICENSE:         GPL - See COPYING in the top level directory
4*c2c66affSColin Finck  * FILE:            queuetest.c
5*c2c66affSColin Finck  * PURPOSE:         Usermode QueueUserWorkItem() testing
6*c2c66affSColin Finck  * PROGRAMMERS:     Thomas Weidenmueller (w3seek@reactos.org)
7*c2c66affSColin Finck  */
8*c2c66affSColin Finck 
9*c2c66affSColin Finck #include <windows.h>
10*c2c66affSColin Finck #include <stdio.h>
11*c2c66affSColin Finck 
12*c2c66affSColin Finck #define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040
13*c2c66affSColin Finck BOOL WINAPI QueueUserWorkItem(LPTHREAD_START_ROUTINE,PVOID,ULONG);
14*c2c66affSColin Finck 
15*c2c66affSColin Finck #define TestProc(n) \
16*c2c66affSColin Finck DWORD CALLBACK TestProc##n(void *ctx)\
17*c2c66affSColin Finck {\
18*c2c66affSColin Finck     printf("TestProc%d thread 0x%lx context 0x%p\n", n, GetCurrentThreadId(), ctx);\
19*c2c66affSColin Finck     return 0;\
20*c2c66affSColin Finck }
21*c2c66affSColin Finck 
22*c2c66affSColin Finck TestProc(1)
23*c2c66affSColin Finck TestProc(2)
24*c2c66affSColin Finck TestProc(3)
25*c2c66affSColin Finck TestProc(4)
26*c2c66affSColin Finck TestProc(5)
27*c2c66affSColin Finck TestProc(6)
28*c2c66affSColin Finck 
29*c2c66affSColin Finck int __cdecl
main(int argc,char * argv[])30*c2c66affSColin Finck main(int argc, char* argv[])
31*c2c66affSColin Finck {
32*c2c66affSColin Finck     PVOID x = (PVOID)0x12345;
33*c2c66affSColin Finck     QueueUserWorkItem(TestProc1, x, 0);
34*c2c66affSColin Finck     QueueUserWorkItem(TestProc2, x, WT_EXECUTELONGFUNCTION);
35*c2c66affSColin Finck     QueueUserWorkItem(TestProc3, x, WT_EXECUTEINIOTHREAD);
36*c2c66affSColin Finck     QueueUserWorkItem(TestProc4, x, WT_EXECUTEINIOTHREAD | WT_EXECUTELONGFUNCTION);
37*c2c66affSColin Finck     QueueUserWorkItem(TestProc5, x, WT_EXECUTEINPERSISTENTTHREAD);
38*c2c66affSColin Finck     QueueUserWorkItem(TestProc6, x, WT_EXECUTEINPERSISTENTIOTHREAD);
39*c2c66affSColin Finck     Sleep(INFINITE);
40*c2c66affSColin Finck     return 0;
41*c2c66affSColin Finck }
42