ReactOS 0.4.15-dev-7931-gfd331f1
QueueUserAPC.c File Reference
#include "precomp.h"
Include dependency graph for QueueUserAPC.c:

Go to the source code of this file.

Macros

#define MAX_RECORD   30
 

Functions

static void AddValueToRecord (DWORD dwValue)
 
static VOID CheckRecord (void)
 
static DWORD WINAPI ThreadFunc1 (LPVOID arg)
 
static DWORD WINAPI ThreadFunc2 (LPVOID arg)
 
static VOID NTAPI DoUserAPC1 (ULONG_PTR Parameter)
 
static VOID NTAPI DoUserAPC2 (ULONG_PTR Parameter)
 
static VOID NTAPI DoUserAPC3 (ULONG_PTR Parameter)
 
static void JustDoIt (LPTHREAD_START_ROUTINE fn)
 
static void TestForSleepEx (void)
 
static void TestForWaitForSingleObjectEx (void)
 
static DWORD WINAPI ThreadFunc3 (LPVOID arg)
 
static void TestMultipleUserAPCs (void)
 
 START_TEST (QueueUserAPC)
 

Variables

static LONG s_record_count = 0
 
static DWORD s_record [MAX_RECORD+1] = { 0 }
 
static BOOL s_terminate_all = FALSE
 
static const DWORD s_expected []
 
static const SIZE_T s_expected_count = _countof(s_expected)
 

Macro Definition Documentation

◆ MAX_RECORD

#define MAX_RECORD   30

Definition at line 9 of file QueueUserAPC.c.

Function Documentation

◆ AddValueToRecord()

static void AddValueToRecord ( DWORD  dwValue)
static

Definition at line 25 of file QueueUserAPC.c.

26{
28 if (next < MAX_RECORD)
29 s_record[next] = dwValue;
30}
#define MAX_RECORD
Definition: QueueUserAPC.c:9
static DWORD s_record[MAX_RECORD+1]
Definition: QueueUserAPC.c:12
static LONG s_record_count
Definition: QueueUserAPC.c:11
#define InterlockedIncrement
Definition: armddk.h:53
long LONG
Definition: pedump.c:60
static unsigned __int64 next
Definition: rand_nt.c:6

Referenced by DoUserAPC1(), DoUserAPC2(), DoUserAPC3(), JustDoIt(), ThreadFunc1(), and ThreadFunc2().

◆ CheckRecord()

static VOID CheckRecord ( void  )
static

Definition at line 32 of file QueueUserAPC.c.

33{
35
36 for (i = 0; i < count; ++i)
37 {
38 ok(s_record[i] == s_expected[i], "s_record[%u]: got %lu vs expected %lu\n",
39 (INT)i, s_record[i], s_expected[i]);
40 }
41
43 for (i = 0; i < count; ++i)
44 {
46 "s_record_count: got %u vs expected %u\n",
48 }
49}
static const DWORD s_expected[]
Definition: QueueUserAPC.c:15
static const SIZE_T s_expected_count
Definition: QueueUserAPC.c:23
#define ok(value,...)
Definition: atltest.h:57
#define abs(i)
Definition: fconv.c:206
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define min(a, b)
Definition: monoChain.cc:55
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58

Referenced by JustDoIt().

◆ DoUserAPC1()

static VOID NTAPI DoUserAPC1 ( ULONG_PTR  Parameter)
static

Definition at line 77 of file QueueUserAPC.c.

78{
79 ok_int((int)Parameter, 1);
81}
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
#define ok_int(expression, result)
Definition: atltest.h:134
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:323

Referenced by JustDoIt(), and TestMultipleUserAPCs().

◆ DoUserAPC2()

static VOID NTAPI DoUserAPC2 ( ULONG_PTR  Parameter)
static

Definition at line 83 of file QueueUserAPC.c.

84{
85 ok_int((int)Parameter, 2);
87}

Referenced by JustDoIt(), and TestMultipleUserAPCs().

◆ DoUserAPC3()

static VOID NTAPI DoUserAPC3 ( ULONG_PTR  Parameter)
static

Definition at line 89 of file QueueUserAPC.c.

90{
91 ok_int((int)Parameter, 3);
94}
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13
#define TRUE
Definition: types.h:120

Referenced by JustDoIt(), and TestMultipleUserAPCs().

◆ JustDoIt()

static void JustDoIt ( LPTHREAD_START_ROUTINE  fn)
static

Definition at line 96 of file QueueUserAPC.c.

97{
100
102 s_record_count = 0;
103 ZeroMemory(s_record, sizeof(s_record));
104
106 ok(hThread != NULL, "hThread was NULL\n");
107
108 Sleep(100);
109
113
114 Sleep(100);
115
119
120 Sleep(100);
121
125
129
132 hThread = NULL;
134
135 CheckRecord();
136}
static VOID NTAPI DoUserAPC2(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:83
static VOID CheckRecord(void)
Definition: QueueUserAPC.c:32
static VOID NTAPI DoUserAPC3(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:89
static VOID NTAPI DoUserAPC1(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:77
#define ok_long(expression, result)
Definition: atltest.h:133
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:959
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
DWORD dwThreadId
Definition: fdebug.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE hThread
Definition: wizard.c:28
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define ZeroMemory
Definition: winbase.h:1712
#define WAIT_OBJECT_0
Definition: winbase.h:406

◆ START_TEST()

START_TEST ( QueueUserAPC  )

Definition at line 180 of file QueueUserAPC.c.

181{
185}
static void TestForWaitForSingleObjectEx(void)
Definition: QueueUserAPC.c:143
static void TestForSleepEx(void)
Definition: QueueUserAPC.c:138
static void TestMultipleUserAPCs(void)
Definition: QueueUserAPC.c:153

◆ TestForSleepEx()

static void TestForSleepEx ( void  )
static

Definition at line 138 of file QueueUserAPC.c.

139{
141}
static void JustDoIt(void)
static DWORD WINAPI ThreadFunc1(LPVOID arg)
Definition: QueueUserAPC.c:51

Referenced by START_TEST().

◆ TestForWaitForSingleObjectEx()

static void TestForWaitForSingleObjectEx ( void  )
static

Definition at line 143 of file QueueUserAPC.c.

144{
146}
static DWORD WINAPI ThreadFunc2(LPVOID arg)
Definition: QueueUserAPC.c:64

Referenced by START_TEST().

◆ TestMultipleUserAPCs()

static void TestMultipleUserAPCs ( void  )
static

Definition at line 153 of file QueueUserAPC.c.

154{
157
158 s_record_count = 0;
159
161 ok(hThread != NULL, "hThread was NULL\n");
162
166
168
170
173
175 ok_long(s_record[0], 4);
176 ok_long(s_record[1], 5);
177 ok_long(s_record[2], 6);
178}
static DWORD WINAPI ThreadFunc3(LPVOID arg)
Definition: QueueUserAPC.c:148
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
#define CREATE_SUSPENDED
Definition: winbase.h:178

Referenced by START_TEST().

◆ ThreadFunc1()

static DWORD WINAPI ThreadFunc1 ( LPVOID  arg)
static

Definition at line 51 of file QueueUserAPC.c.

52{
54 while (!s_terminate_all)
55 {
59 }
61 return 0;
62}
#define INFINITE
Definition: serial.h:102
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
#define WAIT_IO_COMPLETION
Definition: winbase.h:411

Referenced by TestForSleepEx().

◆ ThreadFunc2()

static DWORD WINAPI ThreadFunc2 ( LPVOID  arg)
static

Definition at line 64 of file QueueUserAPC.c.

65{
67 while (!s_terminate_all)
68 {
72 }
74 return 0;
75}
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148

Referenced by TestForWaitForSingleObjectEx().

◆ ThreadFunc3()

static DWORD WINAPI ThreadFunc3 ( LPVOID  arg)
static

Definition at line 148 of file QueueUserAPC.c.

149{
150 return 0;
151}

Referenced by TestMultipleUserAPCs().

Variable Documentation

◆ s_expected

const DWORD s_expected[]
static
Initial value:
=
{
0, 1, 7, 8, 4,
2, 1, 9, 10, 5,
2, 1, 11, 12, 13,
6, 2, 3, 14, 15,
16
}

Definition at line 15 of file QueueUserAPC.c.

Referenced by CheckRecord().

◆ s_expected_count

const SIZE_T s_expected_count = _countof(s_expected)
static

Definition at line 23 of file QueueUserAPC.c.

Referenced by CheckRecord().

◆ s_record

DWORD s_record[MAX_RECORD+1] = { 0 }
static

Definition at line 12 of file QueueUserAPC.c.

Referenced by AddValueToRecord(), CheckRecord(), JustDoIt(), and TestMultipleUserAPCs().

◆ s_record_count

LONG s_record_count = 0
static

Definition at line 11 of file QueueUserAPC.c.

Referenced by AddValueToRecord(), CheckRecord(), JustDoIt(), and TestMultipleUserAPCs().

◆ s_terminate_all

BOOL s_terminate_all = FALSE
static

Definition at line 13 of file QueueUserAPC.c.

Referenced by DoUserAPC3(), JustDoIt(), ThreadFunc1(), and ThreadFunc2().