ReactOS  0.4.15-dev-1177-g6cb3b62
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)
 
 START_TEST (QueueUserAPC)
 

Variables

static DWORD 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 {
27  s_record[s_record_count] = dwValue;
30 }
static DWORD s_record_count
Definition: QueueUserAPC.c:11
#define MAX_RECORD
Definition: QueueUserAPC.c:9
static DWORD s_record[MAX_RECORD+1]
Definition: QueueUserAPC.c:12

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",
47  (int)s_record_count, (int)s_expected_count);
48  }
49 }
#define abs(i)
Definition: fconv.c:206
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:58
static const DWORD s_expected[]
Definition: QueueUserAPC.c:15
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
static DWORD s_record_count
Definition: QueueUserAPC.c:11
static const SIZE_T s_expected_count
Definition: QueueUserAPC.c:23
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
static DWORD s_record[MAX_RECORD+1]
Definition: QueueUserAPC.c:12

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
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define ok_int(expression, result)
Definition: atltest.h:134

Referenced by JustDoIt().

◆ 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 }
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define ok_int(expression, result)
Definition: atltest.h:134

Referenced by JustDoIt().

◆ 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 void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
#define TRUE
Definition: types.h:120
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define ok_int(expression, result)
Definition: atltest.h:134
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13

Referenced by JustDoIt().

◆ 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 
105  hThread = CreateThread(NULL, 0, fn, NULL, 0, &dwThreadId);
106  ok(hThread != NULL, "hThread was NULL\n");
107 
108  Sleep(100);
109 
110  AddValueToRecord(7);
112  AddValueToRecord(8);
113 
114  Sleep(100);
115 
116  AddValueToRecord(9);
118  AddValueToRecord(10);
119 
120  Sleep(100);
121 
122  AddValueToRecord(11);
124  AddValueToRecord(12);
125 
126  AddValueToRecord(13);
128  AddValueToRecord(14);
129 
130  AddValueToRecord(15);
132  hThread = NULL;
133  AddValueToRecord(16);
134 
135  CheckRecord();
136 }
#define CloseHandle
Definition: compat.h:487
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1648
static VOID CheckRecord(void)
Definition: QueueUserAPC.c:32
#define ok_long(expression, result)
Definition: atltest.h:133
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:947
#define FALSE
Definition: types.h:117
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:136
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
static VOID NTAPI DoUserAPC2(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:83
static DWORD s_record_count
Definition: QueueUserAPC.c:11
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
static VOID NTAPI DoUserAPC1(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:77
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13
#define ok(value,...)
Definition: atltest.h:57
static VOID NTAPI DoUserAPC3(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:89
HANDLE hThread
Definition: wizard.c:27
static DWORD s_record[MAX_RECORD+1]
Definition: QueueUserAPC.c:12

Referenced by TestForSleepEx(), and TestForWaitForSingleObjectEx().

◆ START_TEST()

START_TEST ( QueueUserAPC  )

Definition at line 148 of file QueueUserAPC.c.

149 {
150  TestForSleepEx();
152 }
static void TestForWaitForSingleObjectEx(void)
Definition: QueueUserAPC.c:143
static void TestForSleepEx(void)
Definition: QueueUserAPC.c:138

◆ TestForSleepEx()

static void TestForSleepEx ( void  )
static

Definition at line 138 of file QueueUserAPC.c.

139 {
141 }
static void JustDoIt(LPTHREAD_START_ROUTINE fn)
Definition: QueueUserAPC.c:96
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 void JustDoIt(LPTHREAD_START_ROUTINE fn)
Definition: QueueUserAPC.c:96
static DWORD WINAPI ThreadFunc2(LPVOID arg)
Definition: QueueUserAPC.c:64

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 }
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
#define TRUE
Definition: types.h:120
#define ok_long(expression, result)
Definition: atltest.h:133
#define WAIT_IO_COMPLETION
Definition: winbase.h:392
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13
#define INFINITE
Definition: serial.h:102

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
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
#define TRUE
Definition: types.h:120
#define ok_long(expression, result)
Definition: atltest.h:133
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
#define WAIT_IO_COMPLETION
Definition: winbase.h:392
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13
#define INFINITE
Definition: serial.h:102

Referenced by TestForWaitForSingleObjectEx().

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(), and JustDoIt().

◆ s_record_count

DWORD s_record_count = 0
static

Definition at line 11 of file QueueUserAPC.c.

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

◆ s_terminate_all

BOOL s_terminate_all = FALSE
static

Definition at line 13 of file QueueUserAPC.c.

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