ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
August 2011
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
498 discussions
Start a n
N
ew thread
[tfaber] 53091: [KMTESTS] - KeEvent: a little concurrent testing (part 2/x) - ExFastMutex: concurrent testing (part 2/2) - Fix copypasta
by tfaber@svn.reactos.org
Author: tfaber Date: Fri Aug 5 21:12:11 2011 New Revision: 53091 URL:
http://svn.reactos.org/svn/reactos?rev=53091&view=rev
Log: [KMTESTS] - KeEvent: a little concurrent testing (part 2/x) - ExFastMutex: concurrent testing (part 2/2) - Fix copypasta Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/i…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h [iso-8859-1] Fri Aug 5 21:12:11 2011 @@ -41,7 +41,7 @@ #define ExAllocatePoolWithTag(type, size, tag) HeapAlloc(GetProcessHeap(), 0, size) #define ExFreePool(p) HeapFree(GetProcessHeap(), 0, p) #define ExFreePoolWithTag(p, tag) HeapFree(GetProcessHeap(), 0, p) -#define RtlCopyMemoryNonTemporal(d, s, l) +#define RtlCopyMemoryNonTemporal RtlCopyMemory #define RtlPrefetchMemoryNonTemporal(s, l) #endif /* defined KMT_EMULATE_KERNEL */ Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c [iso-8859-1] Fri Aug 5 21:12:11 2011 @@ -104,6 +104,180 @@ KmtSetIrql(OriginalIrql); } +typedef VOID (FASTCALL *PMUTEX_FUNCTION)(PFAST_MUTEX); +typedef BOOLEAN (FASTCALL *PMUTEX_TRY_FUNCTION)(PFAST_MUTEX); + +typedef struct +{ + HANDLE Handle; + PKTHREAD Thread; + KIRQL Irql; + PFAST_MUTEX Mutex; + PMUTEX_FUNCTION Acquire; + PMUTEX_TRY_FUNCTION TryAcquire; + PMUTEX_FUNCTION Release; + BOOLEAN Try; + BOOLEAN RetExpected; + KEVENT InEvent; + KEVENT OutEvent; +} THREAD_DATA, *PTHREAD_DATA; + +static +VOID +NTAPI +AcquireMutexThread( + PVOID Parameter) +{ + PTHREAD_DATA ThreadData = Parameter; + KIRQL Irql; + BOOLEAN Ret = FALSE; + NTSTATUS Status; + + KeRaiseIrql(ThreadData->Irql, &Irql); + + if (ThreadData->Try) + { + Ret = ThreadData->TryAcquire(ThreadData->Mutex); + ok_eq_bool(Ret, ThreadData->RetExpected); + } + else + ThreadData->Acquire(ThreadData->Mutex); + + ok_bool_false(KeSetEvent(&ThreadData->OutEvent, 0, TRUE), "KeSetEvent returned"); + Status = KeWaitForSingleObject(&ThreadData->InEvent, Executive, KernelMode, FALSE, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + + if (!ThreadData->Try || Ret) + ThreadData->Release(ThreadData->Mutex); + + KeLowerIrql(Irql); +} + +static +VOID +InitThreadData( + PTHREAD_DATA ThreadData, + PFAST_MUTEX Mutex, + PMUTEX_FUNCTION Acquire, + PMUTEX_TRY_FUNCTION TryAcquire, + PMUTEX_FUNCTION Release) +{ + ThreadData->Mutex = Mutex; + KeInitializeEvent(&ThreadData->InEvent, NotificationEvent, FALSE); + KeInitializeEvent(&ThreadData->OutEvent, NotificationEvent, FALSE); + ThreadData->Acquire = Acquire; + ThreadData->TryAcquire = TryAcquire; + ThreadData->Release = Release; +} + +static +NTSTATUS +StartThread( + PTHREAD_DATA ThreadData, + PLARGE_INTEGER Timeout, + KIRQL Irql, + BOOLEAN Try, + BOOLEAN RetExpected) +{ + NTSTATUS Status = STATUS_SUCCESS; + OBJECT_ATTRIBUTES Attributes; + + ThreadData->Try = Try; + ThreadData->Irql = Irql; + ThreadData->RetExpected = RetExpected; + InitializeObjectAttributes(&Attributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL); + Status = PsCreateSystemThread(&ThreadData->Handle, GENERIC_ALL, &Attributes, NULL, NULL, AcquireMutexThread, ThreadData); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = ObReferenceObjectByHandle(ThreadData->Handle, SYNCHRONIZE, PsThreadType, KernelMode, (PVOID *)&ThreadData->Thread, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + + return KeWaitForSingleObject(&ThreadData->OutEvent, Executive, KernelMode, FALSE, Timeout); +} + +static +VOID +FinishThread( + PTHREAD_DATA ThreadData) +{ + NTSTATUS Status = STATUS_SUCCESS; + + KeSetEvent(&ThreadData->InEvent, 0, TRUE); + Status = KeWaitForSingleObject(ThreadData->Thread, Executive, KernelMode, FALSE, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + + ObDereferenceObject(ThreadData->Thread); + Status = ZwClose(ThreadData->Handle); + ok_eq_hex(Status, STATUS_SUCCESS); + KeClearEvent(&ThreadData->InEvent); + KeClearEvent(&ThreadData->OutEvent); +} + +static +VOID +TestFastMutexConcurrent( + PFAST_MUTEX Mutex) +{ + NTSTATUS Status; + THREAD_DATA ThreadData; + THREAD_DATA ThreadData2; + THREAD_DATA ThreadDataUnsafe; + THREAD_DATA ThreadDataTry; + LARGE_INTEGER Timeout; + Timeout.QuadPart = -10 * 1000 * 10; /* 10 ms */ + + InitThreadData(&ThreadData, Mutex, ExAcquireFastMutex, NULL, ExReleaseFastMutex); + InitThreadData(&ThreadData2, Mutex, ExAcquireFastMutex, NULL, ExReleaseFastMutex); + InitThreadData(&ThreadDataUnsafe, Mutex, ExAcquireFastMutexUnsafe, NULL, ExReleaseFastMutexUnsafe); + InitThreadData(&ThreadDataTry, Mutex, NULL, ExTryToAcquireFastMutex, ExReleaseFastMutex); + + /* have a thread acquire the mutex */ + Status = StartThread(&ThreadData, NULL, PASSIVE_LEVEL, FALSE, FALSE); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckMutex(Mutex, 0L, ThreadData.Thread, 0LU, PASSIVE_LEVEL, PASSIVE_LEVEL); + /* have a second thread try to acquire it -- should fail */ + Status = StartThread(&ThreadDataTry, NULL, PASSIVE_LEVEL, TRUE, FALSE); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckMutex(Mutex, 0L, ThreadData.Thread, 0LU, PASSIVE_LEVEL, PASSIVE_LEVEL); + FinishThread(&ThreadDataTry); + + /* have another thread acquire it -- should block */ + Status = StartThread(&ThreadData2, &Timeout, APC_LEVEL, FALSE, FALSE); + ok_eq_hex(Status, STATUS_TIMEOUT); + CheckMutex(Mutex, -1L, ThreadData.Thread, 1LU, PASSIVE_LEVEL, PASSIVE_LEVEL); + + /* finish the first thread -- now the second should become available */ + FinishThread(&ThreadData); + Status = KeWaitForSingleObject(&ThreadData2.OutEvent, Executive, KernelMode, FALSE, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckMutex(Mutex, 0L, ThreadData2.Thread, 1LU, APC_LEVEL, PASSIVE_LEVEL); + + /* block two more threads */ + Status = StartThread(&ThreadDataUnsafe, &Timeout, APC_LEVEL, FALSE, FALSE); + ok_eq_hex(Status, STATUS_TIMEOUT); + CheckMutex(Mutex, -1L, ThreadData2.Thread, 2LU, APC_LEVEL, PASSIVE_LEVEL); + + Status = StartThread(&ThreadData, &Timeout, PASSIVE_LEVEL, FALSE, FALSE); + ok_eq_hex(Status, STATUS_TIMEOUT); + CheckMutex(Mutex, -2L, ThreadData2.Thread, 3LU, APC_LEVEL, PASSIVE_LEVEL); + + /* finish 1 */ + FinishThread(&ThreadData2); + Status = KeWaitForSingleObject(&ThreadDataUnsafe.OutEvent, Executive, KernelMode, FALSE, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckMutex(Mutex, -1L, ThreadDataUnsafe.Thread, 3LU, APC_LEVEL, PASSIVE_LEVEL); + + /* finish 2 */ + FinishThread(&ThreadDataUnsafe); + Status = KeWaitForSingleObject(&ThreadData.OutEvent, Executive, KernelMode, FALSE, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + CheckMutex(Mutex, 0L, ThreadData.Thread, 3LU, PASSIVE_LEVEL, PASSIVE_LEVEL); + + /* finish 3 */ + FinishThread(&ThreadData); + + CheckMutex(Mutex, 1L, NULL, 3LU, PASSIVE_LEVEL, PASSIVE_LEVEL); +} + START_TEST(ExFastMutex) { FAST_MUTEX Mutex; @@ -124,4 +298,6 @@ TestFastMutex(&Mutex, HIGH_LEVEL); } KeLowerIrql(PASSIVE_LEVEL); -} + + TestFastMutexConcurrent(&Mutex); +} Modified: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c [iso-8859-1] Fri Aug 5 21:12:11 2011 @@ -7,7 +7,7 @@ #include <kmt_test.h> -/* TODO: thread testing, exports vs macros */ +/* TODO: more thread testing, exports vs macros */ #define CheckEvent(Event, ExpectedType, State, ExpectedWaitNext, Irql) do \ { \ @@ -96,6 +96,95 @@ KmtSetIrql(OriginalIrql); } +typedef struct +{ + HANDLE Handle; + PKTHREAD Thread; + PKEVENT Event1; + PKEVENT Event2; + volatile BOOLEAN Signal; +} THREAD_DATA, *PTHREAD_DATA; + +static +VOID +NTAPI +WaitForEventThread( + IN OUT PVOID Context) +{ + NTSTATUS Status; + PTHREAD_DATA ThreadData = Context; + + ok_irql(PASSIVE_LEVEL); + ThreadData->Signal = TRUE; + Status = KeWaitForSingleObject(ThreadData->Event1, Executive, KernelMode, FALSE, NULL); + ok_irql(PASSIVE_LEVEL); + ok_eq_hex(Status, STATUS_SUCCESS); + ThreadData->Signal = TRUE; + Status = KeWaitForSingleObject(ThreadData->Event2, Executive, KernelMode, FALSE, NULL); + ok_irql(PASSIVE_LEVEL); + ok_eq_hex(Status, STATUS_SUCCESS); + ok_irql(PASSIVE_LEVEL); +} + +static +VOID +TestEventThreads( + IN PKEVENT Event, + IN EVENT_TYPE Type, + IN KIRQL OriginalIrql) +{ + NTSTATUS Status; + THREAD_DATA Threads[5]; + LARGE_INTEGER Timeout; + KPRIORITY Priority; + KEVENT WaitEvent; + KEVENT TerminateEvent; + int i; + Timeout.QuadPart = -1000 * 10; + + KeInitializeEvent(Event, Type, FALSE); + KeInitializeEvent(&WaitEvent, NotificationEvent, FALSE); + KeInitializeEvent(&TerminateEvent, SynchronizationEvent, FALSE); + + for (i = 0; i < sizeof Threads / sizeof Threads[0]; ++i) + { + Threads[i].Event1 = Event; + Threads[i].Event2 = &TerminateEvent; + Threads[i].Signal = FALSE; + Status = PsCreateSystemThread(&Threads[i].Handle, GENERIC_ALL, NULL, NULL, NULL, WaitForEventThread, &Threads[i]); + ok_eq_hex(Status, STATUS_SUCCESS); + Status = ObReferenceObjectByHandle(Threads[i].Handle, SYNCHRONIZE, PsThreadType, KernelMode, (PVOID *)&Threads[i].Thread, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + Priority = KeQueryPriorityThread(Threads[i].Thread); + ok_eq_long(Priority, 8L); + while (!Threads[i].Signal) + { + Status = KeWaitForSingleObject(&WaitEvent, Executive, KernelMode, FALSE, &Timeout); + ok_eq_hex(Status, STATUS_TIMEOUT); + } + Threads[i].Signal = FALSE; + } + + for (i = 0; i < sizeof Threads / sizeof Threads[0]; ++i) + { + KeSetEvent(Event, 1, FALSE); + while (!Threads[i].Signal) + { + Status = KeWaitForSingleObject(&WaitEvent, Executive, KernelMode, FALSE, &Timeout); + ok_eq_hex(Status, STATUS_TIMEOUT); + } + Priority = KeQueryPriorityThread(Threads[i].Thread); + ok_eq_long(Priority, 9L); + KeSetEvent(&TerminateEvent, 0, FALSE); + Status = KeWaitForSingleObject(Threads[i].Thread, Executive, KernelMode, FALSE, NULL); + ok_eq_hex(Status, STATUS_SUCCESS); + + ObDereferenceObject(Threads[i].Thread); + Status = ZwClose(Threads[i].Handle); + ok_eq_hex(Status, STATUS_SUCCESS); + } +} + START_TEST(KeEvent) { KEVENT Event; @@ -111,6 +200,8 @@ KeLowerIrql(Irql); } + TestEventThreads(&Event, NotificationEvent, PASSIVE_LEVEL); + ok_irql(PASSIVE_LEVEL); KmtSetIrql(PASSIVE_LEVEL); }
13 years, 3 months
1
0
0
0
[tfaber] 53090: [KMTESTS] - add KeEvent test (part 1/x) - add ExFastMutex test (part 1/2)
by tfaber@svn.reactos.org
Author: tfaber Date: Fri Aug 5 21:07:52 2011 New Revision: 53090 URL:
http://svn.reactos.org/svn/reactos?rev=53090&view=rev
Log: [KMTESTS] - add KeEvent test (part 1/x) - add ExFastMutex test (part 1/2) Added: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c (with props) branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c (with props) Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/C…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] Fri Aug 5 21:07:52 2011 @@ -17,6 +17,7 @@ example/Example.c example/KernelType.c ntos_ex/ExDoubleList.c + ntos_ex/ExFastMutex.c ntos_ex/ExHardError.c ntos_ex/ExInterlocked.c ntos_ex/ExPools.c @@ -29,6 +30,7 @@ ntos_io/IoMdl.c ntos_ke/KeApc.c ntos_ke/KeDpc.c + ntos_ke/KeEvent.c ntos_ke/KeIrql.c ntos_ke/KeProcessor.c ntos_ke/KeSpinLock.c Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv.rbuild [iso-8859-1] Fri Aug 5 21:07:52 2011 @@ -16,6 +16,7 @@ </directory> <directory name="ntos_ex"> <file>ExDoubleList.c</file> + <file>ExFastMutex.c</file> <file>ExHardError.c</file> <file>ExInterlocked.c</file> <file>ExPools.c</file> @@ -34,6 +35,7 @@ <directory name="ntos_ke"> <file>KeApc.c</file> <file>KeDpc.c</file> + <file>KeEvent.c</file> <file>KeIrql.c</file> <file>KeProcessor.c</file> <file>KeSpinLock.c</file> Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest_drv/testlist.c [iso-8859-1] Fri Aug 5 21:07:52 2011 @@ -9,6 +9,7 @@ KMT_TESTFUNC Test_Example; KMT_TESTFUNC Test_ExDoubleList; +KMT_TESTFUNC Test_ExFastMutex; KMT_TESTFUNC Test_ExHardError; KMT_TESTFUNC Test_ExHardErrorInteractive; KMT_TESTFUNC Test_ExInterlocked; @@ -22,6 +23,7 @@ KMT_TESTFUNC Test_IoMdl; KMT_TESTFUNC Test_KeApc; KMT_TESTFUNC Test_KeDpc; +KMT_TESTFUNC Test_KeEvent; KMT_TESTFUNC Test_KeIrql; KMT_TESTFUNC Test_KeProcessor; KMT_TESTFUNC Test_KernelType; @@ -33,6 +35,7 @@ const KMT_TEST TestList[] = { { "ExDoubleList", Test_ExDoubleList }, + { "ExFastMutex", Test_ExFastMutex }, { "ExHardError", Test_ExHardError }, { "-ExHardErrorInteractive", Test_ExHardErrorInteractive }, { "ExInterlocked", Test_ExInterlocked }, @@ -47,6 +50,7 @@ { "IoMdl", Test_IoMdl }, { "KeApc", Test_KeApc }, { "KeDpc", Test_KeDpc }, + { "KeEvent", Test_KeEvent }, { "KeIrql", Test_KeIrql }, { "KeProcessor", Test_KeProcessor }, { "-KernelType", Test_KernelType }, Added: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c (added) +++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c [iso-8859-1] Fri Aug 5 21:07:52 2011 @@ -1,0 +1,127 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Kernel-Mode Test Suite Fast Mutex test + * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de> + */ + +#include <kmt_test.h> + +//#define NDEBUG +#include <debug.h> + +NTKERNELAPI VOID FASTCALL ExiAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex); +NTKERNELAPI VOID FASTCALL ExiReleaseFastMutex(IN OUT PFAST_MUTEX FastMutex); +NTKERNELAPI BOOLEAN FASTCALL ExiTryToAcquireFastMutex(IN OUT PFAST_MUTEX FastMutex); + +#define CheckMutex(Mutex, ExpectedCount, ExpectedOwner, \ + ExpectedContention, ExpectedOldIrql, \ + ExpectedIrql) do \ +{ \ + ok_eq_long((Mutex)->Count, ExpectedCount); \ + ok_eq_pointer((Mutex)->Owner, ExpectedOwner); \ + ok_eq_ulong((Mutex)->Contention, ExpectedContention); \ + ok_eq_ulong((Mutex)->OldIrql, (ULONG)ExpectedOldIrql); \ + ok_bool_false(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); \ + ok_irql(ExpectedIrql); \ +} while (0) + +static +VOID +TestFastMutex( + PFAST_MUTEX Mutex, + KIRQL OriginalIrql) +{ + PKTHREAD Thread = KeGetCurrentThread(); + + ok_irql(OriginalIrql); + + /* acquire/release normally */ + ExAcquireFastMutex(Mutex); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); + ok_bool_false(ExTryToAcquireFastMutex(Mutex), "ExTryToAcquireFastMutex returned"); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); + ExReleaseFastMutex(Mutex); + CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); + + /* ntoskrnl's fastcall version */ + ExiAcquireFastMutex(Mutex); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); + ok_bool_false(ExiTryToAcquireFastMutex(Mutex), "ExiTryToAcquireFastMutex returned"); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); + ExiReleaseFastMutex(Mutex); + CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); + + /* acquire/release unsafe */ + ExAcquireFastMutexUnsafe(Mutex); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, OriginalIrql); + ExReleaseFastMutexUnsafe(Mutex); + CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); + + /* try to acquire */ + ok_bool_true(ExTryToAcquireFastMutex(Mutex), "ExTryToAcquireFastMutex returned"); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); + ExReleaseFastMutex(Mutex); + CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); + + /* shortcut functions with critical region */ + ExEnterCriticalRegionAndAcquireFastMutexUnsafe(Mutex); + ok_bool_true(KeAreApcsDisabled(), "KeAreApcsDisabled returned"); + ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(Mutex); + + /* mismatched acquire/release */ + ExAcquireFastMutex(Mutex); + CheckMutex(Mutex, 0L, Thread, 0LU, OriginalIrql, APC_LEVEL); + ExReleaseFastMutexUnsafe(Mutex); + CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, APC_LEVEL); + KmtSetIrql(OriginalIrql); + CheckMutex(Mutex, 1L, NULL, 0LU, OriginalIrql, OriginalIrql); + + Mutex->OldIrql = 0x55555555LU; + ExAcquireFastMutexUnsafe(Mutex); + CheckMutex(Mutex, 0L, Thread, 0LU, 0x55555555LU, OriginalIrql); + Mutex->OldIrql = PASSIVE_LEVEL; + ExReleaseFastMutex(Mutex); + CheckMutex(Mutex, 1L, NULL, 0LU, PASSIVE_LEVEL, PASSIVE_LEVEL); + KmtSetIrql(OriginalIrql); + CheckMutex(Mutex, 1L, NULL, 0LU, PASSIVE_LEVEL, OriginalIrql); + + /* release without acquire */ + ExReleaseFastMutexUnsafe(Mutex); + CheckMutex(Mutex, 2L, NULL, 0LU, PASSIVE_LEVEL, OriginalIrql); + --Mutex->Count; + Mutex->OldIrql = OriginalIrql; + ExReleaseFastMutex(Mutex); + CheckMutex(Mutex, 2L, NULL, 0LU, OriginalIrql, OriginalIrql); + ExReleaseFastMutex(Mutex); + CheckMutex(Mutex, 3L, NULL, 0LU, OriginalIrql, OriginalIrql); + Mutex->Count -= 2; + + /* make sure we survive this in case of error */ + ok_eq_long(Mutex->Count, 1L); + Mutex->Count = 1; + ok_irql(OriginalIrql); + KmtSetIrql(OriginalIrql); +} + +START_TEST(ExFastMutex) +{ + FAST_MUTEX Mutex; + KIRQL Irql; + + memset(&Mutex, 0x55, sizeof Mutex); + ExInitializeFastMutex(&Mutex); + CheckMutex(&Mutex, 1L, NULL, 0LU, 0x55555555LU, PASSIVE_LEVEL); + + TestFastMutex(&Mutex, PASSIVE_LEVEL); + KeRaiseIrql(APC_LEVEL, &Irql); + TestFastMutex(&Mutex, APC_LEVEL); + if (!KmtIsCheckedBuild) + { + KeRaiseIrql(DISPATCH_LEVEL, &Irql); + TestFastMutex(&Mutex, DISPATCH_LEVEL); + KeRaiseIrql(HIGH_LEVEL, &Irql); + TestFastMutex(&Mutex, HIGH_LEVEL); + } + KeLowerIrql(PASSIVE_LEVEL); +} Propchange: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ex/ExFastMutex.c ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/n…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c (added) +++ branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c [iso-8859-1] Fri Aug 5 21:07:52 2011 @@ -1,0 +1,116 @@ +/* + * PROJECT: ReactOS kernel-mode tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Kernel-Mode Test Suite Event test + * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de> + */ + +#include <kmt_test.h> + +/* TODO: thread testing, exports vs macros */ + +#define CheckEvent(Event, ExpectedType, State, ExpectedWaitNext, Irql) do \ +{ \ + ok_eq_uint((Event)->Header.Type, ExpectedType); \ + ok_eq_uint((Event)->Header.Hand, sizeof *(Event) / sizeof(ULONG)); \ + ok_eq_long((Event)->Header.Lock & 0xFF00FF00L, 0x55005500L); \ + ok_eq_long((Event)->Header.SignalState, State); \ + ok_eq_pointer((Event)->Header.WaitListHead.Flink, \ + &(Event)->Header.WaitListHead); \ + ok_eq_pointer((Event)->Header.WaitListHead.Blink, \ + &(Event)->Header.WaitListHead); \ + ok_eq_long(KeReadStateEvent(Event), State); \ + ok_eq_bool(Thread->WaitNext, ExpectedWaitNext); \ + ok_irql(Irql); \ +} while (0) + +static +VOID +TestEventFunctional( + IN PKEVENT Event, + IN EVENT_TYPE Type, + IN KIRQL OriginalIrql) +{ + LONG State; + PKTHREAD Thread = KeGetCurrentThread(); + + memset(Event, 0x55, sizeof *Event); + KeInitializeEvent(Event, Type, FALSE); + CheckEvent(Event, Type, 0L, FALSE, OriginalIrql); + + memset(Event, 0x55, sizeof *Event); + KeInitializeEvent(Event, Type, TRUE); + CheckEvent(Event, Type, 1L, FALSE, OriginalIrql); + + Event->Header.SignalState = 0x12345678L; + CheckEvent(Event, Type, 0x12345678L, FALSE, OriginalIrql); + + State = KePulseEvent(Event, 0, FALSE); + CheckEvent(Event, Type, 0L, FALSE, OriginalIrql); + ok_eq_long(State, 0x12345678L); + + Event->Header.SignalState = 0x12345678L; + KeClearEvent(Event); + CheckEvent(Event, Type, 0L, FALSE, OriginalIrql); + + State = KeSetEvent(Event, 0, FALSE); + CheckEvent(Event, Type, 1L, FALSE, OriginalIrql); + ok_eq_long(State, 0L); + + State = KeResetEvent(Event); + CheckEvent(Event, Type, 0L, FALSE, OriginalIrql); + ok_eq_long(State, 1L); + + Event->Header.SignalState = 0x23456789L; + State = KeSetEvent(Event, 0, FALSE); + CheckEvent(Event, Type, 1L, FALSE, OriginalIrql); + ok_eq_long(State, 0x23456789L); + + Event->Header.SignalState = 0x3456789AL; + State = KeResetEvent(Event); + CheckEvent(Event, Type, 0L, FALSE, OriginalIrql); + ok_eq_long(State, 0x3456789AL); + + if (OriginalIrql <= DISPATCH_LEVEL || !KmtIsCheckedBuild) + { + Event->Header.SignalState = 0x456789ABL; + State = KeSetEvent(Event, 0, TRUE); + CheckEvent(Event, Type, 1L, TRUE, DISPATCH_LEVEL); + ok_eq_long(State, 0x456789ABL); + ok_eq_uint(Thread->WaitIrql, OriginalIrql); + /* repair the "damage" */ + Thread->WaitNext = FALSE; + KmtSetIrql(OriginalIrql); + + Event->Header.SignalState = 0x56789ABCL; + State = KePulseEvent(Event, 0, TRUE); + CheckEvent(Event, Type, 0L, TRUE, DISPATCH_LEVEL); + ok_eq_long(State, 0x56789ABCL); + ok_eq_uint(Thread->WaitIrql, OriginalIrql); + /* repair the "damage" */ + Thread->WaitNext = FALSE; + KmtSetIrql(OriginalIrql); + } + + ok_irql(OriginalIrql); + KmtSetIrql(OriginalIrql); +} + +START_TEST(KeEvent) +{ + KEVENT Event; + KIRQL Irql; + KIRQL Irqls[] = { PASSIVE_LEVEL, APC_LEVEL, DISPATCH_LEVEL, HIGH_LEVEL }; + int i; + + for (i = 0; i < sizeof Irqls / sizeof Irqls[0]; ++i) + { + KeRaiseIrql(Irqls[i], &Irql); + TestEventFunctional(&Event, NotificationEvent, Irqls[i]); + TestEventFunctional(&Event, SynchronizationEvent, Irqls[i]); + KeLowerIrql(Irql); + } + + ok_irql(PASSIVE_LEVEL); + KmtSetIrql(PASSIVE_LEVEL); +} Propchange: branches/GSoC_2011/KMTestSuite/kmtests/ntos_ke/KeEvent.c ------------------------------------------------------------------------------ svn:eol-style = native
13 years, 3 months
1
0
0
0
[cgutman] 53089: [LWIP] - Use lookaside lists for allocating lwIP callback messages and packet queue entries for a small speed boost
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Aug 5 20:55:57 2011 New Revision: 53089 URL:
http://svn.reactos.org/svn/reactos?rev=53089&view=rev
Log: [LWIP] - Use lookaside lists for allocating lwIP callback messages and packet queue entries for a small speed boost Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h [iso-8859-1] Fri Aug 5 20:55:57 2011 @@ -17,6 +17,72 @@ struct pbuf *p; LIST_ENTRY ListEntry; } QUEUE_ENTRY, *PQUEUE_ENTRY; + +struct lwip_callback_msg +{ + /* Synchronization */ + KEVENT Event; + + /* Input */ + union { + struct { + PVOID Arg; + } Socket; + struct { + PCONNECTION_ENDPOINT Connection; + struct ip_addr *IpAddress; + u16_t Port; + } Bind; + struct { + PCONNECTION_ENDPOINT Connection; + u8_t Backlog; + } Listen; + struct { + PCONNECTION_ENDPOINT Connection; + void *Data; + u16_t DataLength; + } Send; + struct { + PCONNECTION_ENDPOINT Connection; + struct ip_addr *IpAddress; + u16_t Port; + } Connect; + struct { + PCONNECTION_ENDPOINT Connection; + int shut_rx; + int shut_tx; + } Shutdown; + struct { + PCONNECTION_ENDPOINT Connection; + int Callback; + } Close; + } Input; + + /* Output */ + union { + struct { + struct tcp_pcb *NewPcb; + } Socket; + struct { + err_t Error; + } Bind; + struct { + struct tcp_pcb *NewPcb; + } Listen; + struct { + err_t Error; + } Send; + struct { + err_t Error; + } Connect; + struct { + err_t Error; + } Shutdown; + struct { + err_t Error; + } Close; + } Output; +}; NTSTATUS LibTCPGetDataFromConnectionQueue(PCONNECTION_ENDPOINT Connection, PUCHAR RecvBuffer, UINT RecvLen, UINT *Received); Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Fri Aug 5 20:55:57 2011 @@ -28,6 +28,8 @@ * to going messing around in lwIP because I have no desire to create another mess like oskittcp */ extern KEVENT TerminationEvent; +extern NPAGED_LOOKASIDE_LIST MessageLookasideList; +extern NPAGED_LOOKASIDE_LIST QueueEntryLookasideList; static void @@ -37,7 +39,6 @@ PQUEUE_ENTRY qp = NULL; ReferenceObject(Connection); - while (!IsListEmpty(&Connection->PacketQueue)) { @@ -47,7 +48,7 @@ /* We're in the tcpip thread here so this is safe */ pbuf_free(qp->p); - ExFreePoolWithTag(qp, LWIP_TAG); + ExFreeToNPagedLookasideList(&QueueEntryLookasideList, qp); } DereferenceObject(Connection); @@ -57,7 +58,7 @@ { PQUEUE_ENTRY qp; - qp = (PQUEUE_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(QUEUE_ENTRY), LWIP_TAG); + qp = (PQUEUE_ENTRY)ExAllocateFromNPagedLookasideList(&QueueEntryLookasideList); qp->p = p; ExInterlockedInsertTailList(&Connection->PacketQueue, &qp->ListEntry, &Connection->Lock); @@ -96,7 +97,7 @@ /* Use this special pbuf free callback function because we're outside tcpip thread */ pbuf_free_callback(qp->p); - ExFreePoolWithTag(qp, LWIP_TAG); + ExFreeToNPagedLookasideList(&QueueEntryLookasideList, qp); Status = STATUS_SUCCESS; } @@ -198,7 +199,7 @@ */ TCPFinEventHandler(arg, ERR_OK); } - + return ERR_OK; } @@ -209,9 +210,9 @@ /* Make sure the socket didn't get closed */ if (!arg) return ERR_ABRT; - + TCPAcceptEventHandler(arg, newpcb); - + /* Set in LibTCPAccept (called from TCPAcceptEventHandler) */ if (newpcb->callback_arg) return ERR_OK; @@ -226,9 +227,9 @@ /* Make sure the socket didn't get closed */ if (!arg) return ERR_OK; - + TCPConnectEventHandler(arg, err); - + return ERR_OK; } @@ -238,60 +239,48 @@ { /* Make sure the socket didn't get closed */ if (!arg) return; - + TCPFinEventHandler(arg, err); } -struct socket_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PVOID Arg; - - /* Output */ - struct tcp_pcb *NewPcb; -}; - static void LibTCPSocketCallback(void *arg) { - struct socket_callback_msg *msg = arg; - + struct lwip_callback_msg *msg = arg; + ASSERT(msg); - - msg->NewPcb = tcp_new(); - - if (msg->NewPcb) - { - tcp_arg(msg->NewPcb, msg->Arg); - tcp_err(msg->NewPcb, InternalErrorEventHandler); - } - + + msg->Output.Socket.NewPcb = tcp_new(); + + if (msg->Output.Socket.NewPcb) + { + tcp_arg(msg->Output.Socket.NewPcb, msg->Input.Socket.Arg); + tcp_err(msg->Output.Socket.NewPcb, InternalErrorEventHandler); + } + KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE); } struct tcp_pcb * LibTCPSocket(void *arg) { - struct socket_callback_msg *msg = ExAllocatePool(NonPagedPool, sizeof(struct socket_callback_msg)); + struct lwip_callback_msg *msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); struct tcp_pcb *ret; if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Arg = arg; - + msg->Input.Socket.Arg = arg; + tcpip_callback_with_block(LibTCPSocketCallback, msg, 1); - + if (WaitForEventSafely(&msg->Event)) - ret = msg->NewPcb; + ret = msg->Output.Socket.NewPcb; else ret = NULL; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } @@ -299,37 +288,23 @@ return NULL; } -struct bind_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PCONNECTION_ENDPOINT Connection; - struct ip_addr *IpAddress; - u16_t Port; - - /* Output */ - err_t Error; -}; - static void LibTCPBindCallback(void *arg) { - struct bind_callback_msg *msg = arg; - + struct lwip_callback_msg *msg = arg; + ASSERT(msg); - - if (!msg->Connection->SocketContext) - { - msg->Error = ERR_CLSD; + + if (!msg->Input.Bind.Connection->SocketContext) + { + msg->Output.Bind.Error = ERR_CLSD; goto done; } - - msg->Error = tcp_bind((PTCP_PCB)msg->Connection->SocketContext, - msg->IpAddress, - ntohs(msg->Port)); + + msg->Output.Bind.Error = tcp_bind((PTCP_PCB)msg->Input.Bind.Connection->SocketContext, + msg->Input.Bind.IpAddress, + ntohs(msg->Input.Bind.Port)); done: KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE); @@ -338,25 +313,25 @@ err_t LibTCPBind(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port) { - struct bind_callback_msg *msg; + struct lwip_callback_msg *msg; err_t ret; - msg = ExAllocatePool(NonPagedPool, sizeof(struct bind_callback_msg)); + msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Connection = Connection; - msg->IpAddress = ipaddr; - msg->Port = port; + msg->Input.Bind.Connection = Connection; + msg->Input.Bind.IpAddress = ipaddr; + msg->Input.Bind.Port = port; tcpip_callback_with_block(LibTCPBindCallback, msg, 1); if (WaitForEventSafely(&msg->Event)) - ret = msg->Error; + ret = msg->Output.Bind.Error; else ret = ERR_CLSD; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } @@ -364,38 +339,25 @@ return ERR_MEM; } -struct listen_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PCONNECTION_ENDPOINT Connection; - u8_t Backlog; - - /* Output */ - PTCP_PCB NewPcb; -}; - static void LibTCPListenCallback(void *arg) { - struct listen_callback_msg *msg = arg; + struct lwip_callback_msg *msg = arg; ASSERT(msg); - if (!msg->Connection->SocketContext) - { - msg->NewPcb = NULL; + if (!msg->Input.Listen.Connection->SocketContext) + { + msg->Output.Listen.NewPcb = NULL; goto done; } - msg->NewPcb = tcp_listen_with_backlog((PTCP_PCB)msg->Connection->SocketContext, msg->Backlog); - - if (msg->NewPcb) - { - tcp_accept(msg->NewPcb, InternalAcceptEventHandler); + msg->Output.Listen.NewPcb = tcp_listen_with_backlog((PTCP_PCB)msg->Input.Listen.Connection->SocketContext, msg->Input.Listen.Backlog); + + if (msg->Output.Listen.NewPcb) + { + tcp_accept(msg->Output.Listen.NewPcb, InternalAcceptEventHandler); } done: @@ -405,24 +367,24 @@ PTCP_PCB LibTCPListen(PCONNECTION_ENDPOINT Connection, const u8_t backlog) { - struct listen_callback_msg *msg; + struct lwip_callback_msg *msg; PTCP_PCB ret; - msg = ExAllocatePool(NonPagedPool, sizeof(struct listen_callback_msg)); + msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Connection = Connection; - msg->Backlog = backlog; + msg->Input.Listen.Connection = Connection; + msg->Input.Listen.Backlog = backlog; tcpip_callback_with_block(LibTCPListenCallback, msg, 1); if (WaitForEventSafely(&msg->Event)) - ret = msg->NewPcb; + ret = msg->Output.Listen.NewPcb; else ret = NULL; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } @@ -430,46 +392,32 @@ return NULL; } -struct send_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PCONNECTION_ENDPOINT Connection; - void *Data; - u16_t DataLength; - - /* Output */ - err_t Error; -}; - static void LibTCPSendCallback(void *arg) { - struct send_callback_msg *msg = arg; + struct lwip_callback_msg *msg = arg; ASSERT(msg); - if (!msg->Connection->SocketContext) - { - msg->Error = ERR_CLSD; + if (!msg->Input.Send.Connection->SocketContext) + { + msg->Output.Send.Error = ERR_CLSD; goto done; } - if (tcp_sndbuf((PTCP_PCB)msg->Connection->SocketContext) < msg->DataLength) - { - msg->Error = ERR_INPROGRESS; + if (tcp_sndbuf((PTCP_PCB)msg->Input.Send.Connection->SocketContext) < msg->Input.Send.DataLength) + { + msg->Output.Send.Error = ERR_INPROGRESS; } else { - msg->Error = tcp_write((PTCP_PCB)msg->Connection->SocketContext, - msg->Data, - msg->DataLength, - TCP_WRITE_FLAG_COPY); - - tcp_output((PTCP_PCB)msg->Connection->SocketContext); + msg->Output.Send.Error = tcp_write((PTCP_PCB)msg->Input.Send.Connection->SocketContext, + msg->Input.Send.Data, + msg->Input.Send.DataLength, + TCP_WRITE_FLAG_COPY); + + tcp_output((PTCP_PCB)msg->Input.Send.Connection->SocketContext); } done: @@ -480,15 +428,15 @@ LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, const int safe) { err_t ret; - struct send_callback_msg *msg; - - msg = ExAllocatePool(NonPagedPool, sizeof(struct send_callback_msg)); + struct lwip_callback_msg *msg; + + msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Connection = Connection; - msg->Data = dataptr; - msg->DataLength = len; + msg->Input.Send.Connection = Connection; + msg->Input.Send.Data = dataptr; + msg->Input.Send.DataLength = len; if (safe) LibTCPSendCallback(msg); @@ -496,11 +444,11 @@ tcpip_callback_with_block(LibTCPSendCallback, msg, 1); if (WaitForEventSafely(&msg->Event)) - ret = msg->Error; + ret = msg->Output.Send.Error; else ret = ERR_CLSD; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } @@ -508,42 +456,28 @@ return ERR_MEM; } -struct connect_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PCONNECTION_ENDPOINT Connection; - struct ip_addr *IpAddress; - u16_t Port; - - /* Output */ - err_t Error; -}; - static void LibTCPConnectCallback(void *arg) { - struct connect_callback_msg *msg = arg; + struct lwip_callback_msg *msg = arg; ASSERT(arg); - if (!msg->Connection->SocketContext) - { - msg->Error = ERR_CLSD; + if (!msg->Input.Connect.Connection->SocketContext) + { + msg->Output.Connect.Error = ERR_CLSD; goto done; } - tcp_recv((PTCP_PCB)msg->Connection->SocketContext, InternalRecvEventHandler); - tcp_sent((PTCP_PCB)msg->Connection->SocketContext, InternalSendEventHandler); - - err_t Error = tcp_connect((PTCP_PCB)msg->Connection->SocketContext, - msg->IpAddress, ntohs(msg->Port), + tcp_recv((PTCP_PCB)msg->Input.Connect.Connection->SocketContext, InternalRecvEventHandler); + tcp_sent((PTCP_PCB)msg->Input.Connect.Connection->SocketContext, InternalSendEventHandler); + + err_t Error = tcp_connect((PTCP_PCB)msg->Input.Connect.Connection->SocketContext, + msg->Input.Connect.IpAddress, ntohs(msg->Input.Connect.Port), InternalConnectEventHandler); - msg->Error = Error == ERR_OK ? ERR_INPROGRESS : Error; + msg->Output.Connect.Error = Error == ERR_OK ? ERR_INPROGRESS : Error; done: KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE); @@ -552,27 +486,27 @@ err_t LibTCPConnect(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port) { - struct connect_callback_msg *msg; + struct lwip_callback_msg *msg; err_t ret; - msg = ExAllocatePool(NonPagedPool, sizeof(struct connect_callback_msg)); + msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Connection = Connection; - msg->IpAddress = ipaddr; - msg->Port = port; + msg->Input.Connect.Connection = Connection; + msg->Input.Connect.IpAddress = ipaddr; + msg->Input.Connect.Port = port; tcpip_callback_with_block(LibTCPConnectCallback, msg, 1); if (WaitForEventSafely(&msg->Event)) { - ret = msg->Error; + ret = msg->Output.Connect.Error; } else ret = ERR_CLSD; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } @@ -580,43 +514,29 @@ return ERR_MEM; } -struct shutdown_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PCONNECTION_ENDPOINT Connection; - int shut_rx; - int shut_tx; - - /* Output */ - err_t Error; -}; - static void LibTCPShutdownCallback(void *arg) { - struct shutdown_callback_msg *msg = arg; - PTCP_PCB pcb = msg->Connection->SocketContext; - - if (!msg->Connection->SocketContext) - { - msg->Error = ERR_CLSD; + struct lwip_callback_msg *msg = arg; + PTCP_PCB pcb = msg->Input.Shutdown.Connection->SocketContext; + + if (!msg->Input.Shutdown.Connection->SocketContext) + { + msg->Output.Shutdown.Error = ERR_CLSD; goto done; } if (pcb->state == CLOSE_WAIT) { /* This case actually results in a socket closure later (lwIP bug?) */ - msg->Connection->SocketContext = NULL; - } - - msg->Error = tcp_shutdown(pcb, msg->shut_rx, msg->shut_tx); - if (msg->Error) - { - msg->Connection->SocketContext = pcb; + msg->Input.Shutdown.Connection->SocketContext = NULL; + } + + msg->Output.Shutdown.Error = tcp_shutdown(pcb, msg->Input.Shutdown.shut_rx, msg->Input.Shutdown.shut_tx); + if (msg->Output.Shutdown.Error) + { + msg->Input.Shutdown.Connection->SocketContext = pcb; } done: @@ -626,26 +546,26 @@ err_t LibTCPShutdown(PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx) { - struct shutdown_callback_msg *msg; + struct lwip_callback_msg *msg; err_t ret; - msg = ExAllocatePool(NonPagedPool, sizeof(struct shutdown_callback_msg)); + msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Connection = Connection; - msg->shut_rx = shut_rx; - msg->shut_tx = shut_tx; + msg->Input.Shutdown.Connection = Connection; + msg->Input.Shutdown.shut_rx = shut_rx; + msg->Input.Shutdown.shut_tx = shut_tx; tcpip_callback_with_block(LibTCPShutdownCallback, msg, 1); if (WaitForEventSafely(&msg->Event)) - ret = msg->Error; + ret = msg->Output.Shutdown.Error; else ret = ERR_CLSD; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } @@ -653,45 +573,32 @@ return ERR_MEM; } -struct close_callback_msg -{ - /* Synchronization */ - KEVENT Event; - - /* Input */ - PCONNECTION_ENDPOINT Connection; - int Callback; - - /* Output */ - err_t Error; -}; - static void LibTCPCloseCallback(void *arg) { - struct close_callback_msg *msg = arg; - PTCP_PCB pcb = msg->Connection->SocketContext; + struct lwip_callback_msg *msg = arg; + PTCP_PCB pcb = msg->Input.Close.Connection->SocketContext; int state; - if (!msg->Connection->SocketContext) - { - msg->Error = ERR_OK; + if (!msg->Input.Close.Connection->SocketContext) + { + msg->Output.Close.Error = ERR_OK; goto done; } - LibTCPEmptyQueue(msg->Connection); + LibTCPEmptyQueue(msg->Input.Close.Connection); /* Clear the PCB pointer */ - msg->Connection->SocketContext = NULL; + msg->Input.Close.Connection->SocketContext = NULL; /* Save the old PCB state */ state = pcb->state; - msg->Error = tcp_close(pcb); - if (!msg->Error) - { - if (msg->Callback) + msg->Output.Close.Error = tcp_close(pcb); + if (!msg->Output.Close.Error) + { + if (msg->Input.Close.Callback) { /* Call the FIN handler in the cases where it will not be called by lwIP */ switch (state) @@ -699,7 +606,7 @@ case CLOSED: case LISTEN: case SYN_SENT: - TCPFinEventHandler(msg->Connection, ERR_OK); + TCPFinEventHandler(msg->Input.Close.Connection, ERR_OK); break; default: @@ -710,7 +617,7 @@ else { /* Restore the PCB pointer */ - msg->Connection->SocketContext = pcb; + msg->Input.Close.Connection->SocketContext = pcb; } done: @@ -721,15 +628,15 @@ LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback) { err_t ret; - struct close_callback_msg *msg; - - msg = ExAllocatePool(NonPagedPool, sizeof(struct close_callback_msg)); + struct lwip_callback_msg *msg; + + msg = ExAllocateFromNPagedLookasideList(&MessageLookasideList); if (msg) { KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); - msg->Connection = Connection; - msg->Callback = callback; + msg->Input.Close.Connection = Connection; + msg->Input.Close.Callback = callback; if (safe) LibTCPCloseCallback(msg); @@ -737,11 +644,11 @@ tcpip_callback_with_block(LibTCPCloseCallback, msg, 1); if (WaitForEventSafely(&msg->Event)) - ret = msg->Error; + ret = msg->Output.Close.Error; else ret = ERR_CLSD; - ExFreePool(msg); + ExFreeToNPagedLookasideList(&MessageLookasideList, msg); return ret; } Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] Fri Aug 5 20:55:57 2011 @@ -10,6 +10,8 @@ static KSPIN_LOCK ThreadListLock; KEVENT TerminationEvent; +NPAGED_LOOKASIDE_LIST MessageLookasideList; +NPAGED_LOOKASIDE_LIST QueueEntryLookasideList; static LARGE_INTEGER StartTime; @@ -311,6 +313,22 @@ KeQuerySystemTime(&StartTime); KeInitializeEvent(&TerminationEvent, NotificationEvent, FALSE); + + ExInitializeNPagedLookasideList(&MessageLookasideList, + NULL, + NULL, + 0, + sizeof(struct lwip_callback_msg), + LWIP_TAG, + 0); + + ExInitializeNPagedLookasideList(&QueueEntryLookasideList, + NULL, + NULL, + 0, + sizeof(QUEUE_ENTRY), + LWIP_TAG, + 0); } void @@ -338,4 +356,7 @@ ZwClose(Container->Handle); } } -} + + ExDeleteNPagedLookasideList(&MessageLookasideList); + ExDeleteNPagedLookasideList(&QueueEntryLookasideList); +}
13 years, 3 months
1
0
0
0
[jgardou] 53088: [CMAKE] - make generated files depend on their generator It seems stupid, but I removed this quite some time ago, don't ask me why. Now, you just have to build the tools and do an ...
by jgardou@svn.reactos.org
Author: jgardou Date: Fri Aug 5 20:40:40 2011 New Revision: 53088 URL:
http://svn.reactos.org/svn/reactos?rev=53088&view=rev
Log: [CMAKE] - make generated files depend on their generator It seems stupid, but I removed this quite some time ago, don't ask me why. Now, you just have to build the tools and do an incremental build each time a tool is updated. Modified: trunk/reactos/boot/CMakeLists.txt trunk/reactos/cmake/gcc.cmake trunk/reactos/cmake/idl-support.cmake trunk/reactos/cmake/msvc.cmake trunk/reactos/include/asm/CMakeLists.txt trunk/reactos/media/vgafonts/CMakeLists.txt trunk/reactos/subsystems/win32/win32k/CMakeLists.txt Modified: trunk/reactos/boot/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/CMakeLists.txt?rev=53…
============================================================================== --- trunk/reactos/boot/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/boot/CMakeLists.txt [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -7,6 +7,7 @@ ${CMAKE_COMMAND} -D CD_DIR=${CMAKE_CURRENT_BINARY_DIR}/bootcd -P ${CMAKE_CURRENT_BINARY_DIR}/bootcd.cmake COMMAND native-cdmake -v -j -m -b ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin ${CMAKE_CURRENT_BINARY_DIR}/bootcd REACTOS ${REACTOS_BINARY_DIR}/bootcd.iso + DEPENDS native-cdmake VERBATIM) ##bootcdregtest @@ -18,6 +19,7 @@ ${CMAKE_COMMAND} -D CD_DIR=${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest -P ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest.cmake COMMAND native-cdmake -v -j -m -b ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isobtrt.bin ${CMAKE_CURRENT_BINARY_DIR}/bootcdregtest REACTOS ${REACTOS_BINARY_DIR}/bootcdregtest.iso + DEPENDS native-cdmake VERBATIM) @@ -43,6 +45,7 @@ ${CMAKE_COMMAND} -D CD_DIR=${CMAKE_CURRENT_BINARY_DIR}/livecd -P ${CMAKE_CURRENT_BINARY_DIR}/livecd.cmake COMMAND native-cdmake -v -j -m -b ${CMAKE_CURRENT_BINARY_DIR}/freeldr/bootsect/isoboot.bin ${CMAKE_CURRENT_BINARY_DIR}/livecd REACTOS ${REACTOS_BINARY_DIR}/livecd.iso + DEPENDS native-cdmake VERBATIM) add_subdirectory(freeldr) Modified: trunk/reactos/cmake/gcc.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/gcc.cmake?rev=53088&…
============================================================================== --- trunk/reactos/cmake/gcc.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/gcc.cmake [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -233,14 +233,14 @@ OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a COMMAND native-spec2def -n=${_name}${_suffix} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def) # Delayed importlib creation add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a COMMAND native-spec2def -n=${_name}${_suffix} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def --kill-at --output-delaylib ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_delayed.a - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def) elseif(${_extension} STREQUAL ".def") message("Use of def files for import libs is deprecated: ${_exports_file}") @@ -272,7 +272,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c COMMAND native-spec2def -n=${_dllname} --kill-at -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c PROPERTIES GENERATED TRUE) @@ -385,7 +385,7 @@ OUTPUT ${_binary_file} COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address} # COMMAND objcopy --output-target binary --image-base 0x${_base_address} ${_object_file} ${_binary_file} - DEPENDS ${_object_file}) + DEPENDS ${_object_file} native-obj2bin) set_source_files_properties(${_object_file} ${_binary_file} PROPERTIES GENERATED TRUE) Modified: trunk/reactos/cmake/idl-support.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/idl-support.cmake?re…
============================================================================== --- trunk/reactos/cmake/idl-support.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/idl-support.cmake [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -16,6 +16,7 @@ else() set(IDL_FLAGS "") endif() + set(IDL_DEPENDS "") else() set(IDL_COMPILER native-widl) set(IDL_HEADER_ARG -h -o) #.h @@ -32,6 +33,7 @@ else() set(IDL_FLAGS "") endif() + set(IDL_DEPENDS native-widl) endif() @@ -59,7 +61,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_TYPELIB_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS}) list(APPEND OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.tlb) endforeach() add_custom_target(${TARGET} ALL DEPENDS ${OBJECTS}) @@ -74,7 +76,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS}) list(APPEND HEADERS ${HEADER}) endforeach() add_custom_target(${TARGET} ALL DEPENDS ${HEADERS}) @@ -98,7 +100,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.h COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_PROXY_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_p.c ${IDL_HEADER_ARG2} ${NAME}_p.h ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${DLLDATA_ARG} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS}) endforeach() # Extra pass to generate dlldata @@ -113,7 +115,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} --dlldata-only -o ${CMAKE_CURRENT_BINARY_DIR}/proxy.dlldata.c ${IDLS} - DEPENDS ${IDLS}) + DEPENDS ${IDLS} ${IDL_DEPENDS}) endif() endmacro() @@ -125,13 +127,13 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.h COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG2} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.h ${IDL_SERVER_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS}) list(APPEND server_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_s.c) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.c ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_HEADER_ARG2} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.h ${IDL_CLIENT_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.c ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${IDL_DEPENDS}) list(APPEND client_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_c.c) endforeach() add_library(${TARGET} ${client_SOURCES} ${server_SOURCES}) @@ -151,7 +153,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c COMMAND ${IDL_COMPILER} ${INCLUDES} ${DEFINES} ${IDL_FLAGS} ${IDL_INTERFACE_ARG} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c ${IDL_FILE_FULL} - DEPENDS ${IDL_FILE_FULL}) + DEPENDS ${IDL_FILE_FULL} ${IDL_DEPENDS}) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${NAME}_i.c PROPERTIES GENERATED TRUE) endmacro() Modified: trunk/reactos/cmake/msvc.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/msvc.cmake?rev=53088…
============================================================================== --- trunk/reactos/cmake/msvc.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/msvc.cmake [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -146,7 +146,7 @@ add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm ${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def COMMAND native-spec2def --ms --kill-at -a=${SPEC2DEF_ARCH} --implib -n=${_name}${_suffix} -d=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_exp.def -l=${CMAKE_BINARY_DIR}/importlibs/lib${_name}_stubs.asm ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} native-spec2def) # Assemble the stub file add_custom_command( @@ -185,7 +185,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c COMMAND native-spec2def --ms --kill-at -a=${SPEC2DEF_ARCH} -n=${_dllname} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c PROPERTIES GENERATED TRUE) endmacro() @@ -217,7 +217,7 @@ add_custom_command( OUTPUT ${_binary_file} COMMAND native-obj2bin ${_object_file} ${_binary_file} ${_base_address} - DEPENDS ${_object_file}) + DEPENDS ${_object_file} native-obj2bin) set_source_files_properties(${_object_file} ${_temp_file} ${_binary_file} PROPERTIES GENERATED TRUE) Modified: trunk/reactos/include/asm/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/asm/CMakeLists.txt…
============================================================================== --- trunk/reactos/include/asm/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/include/asm/CMakeLists.txt [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -21,7 +21,7 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.inc COMMAND native-geninc ${genincdata_dll} ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.inc ${OPT_MS} - DEPENDS genincdata) + DEPENDS genincdata native-geninc) add_custom_target(asm DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_filename}.inc) Modified: trunk/reactos/media/vgafonts/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/vgafonts/CMakeLists.…
============================================================================== --- trunk/reactos/media/vgafonts/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/media/vgafonts/CMakeLists.txt [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -12,7 +12,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/vgafonts.cab COMMAND native-cabman -M raw -S ${CMAKE_CURRENT_BINARY_DIR}/vgafonts.cab ${SOURCE} - DEPENDS ${SOURCE}) + DEPENDS ${SOURCE} native-cabman) add_custom_target(vgafonts DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vgafonts.cab) Modified: trunk/reactos/subsystems/win32/win32k/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/CM…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/CMakeLists.txt [iso-8859-1] Fri Aug 5 20:40:40 2011 @@ -22,7 +22,8 @@ add_custom_command( OUTPUT ${GENDIB_FILES} - COMMAND native-gendib ${CMAKE_CURRENT_BINARY_DIR}/dib) + COMMAND native-gendib ${CMAKE_CURRENT_BINARY_DIR}/dib + DEPENDS native-gendib) list(APPEND SOURCE dib/alphablend.c
13 years, 3 months
1
0
0
0
[jgardou] 53087: [PSDK] - do not redefine UNICODE_STRING and NTSTATUS if wintrnl.h has already been included - define PNTSTATUS in wintrnl.h - add RPC_PROTSEC_VECTOR and RPC_MGMT_AUTHORIZATION_FN d...
by jgardou@svn.reactos.org
Author: jgardou Date: Fri Aug 5 19:35:54 2011 New Revision: 53087 URL:
http://svn.reactos.org/svn/reactos?rev=53087&view=rev
Log: [PSDK] - do not redefine UNICODE_STRING and NTSTATUS if wintrnl.h has already been included - define PNTSTATUS in wintrnl.h - add RPC_PROTSEC_VECTOR and RPC_MGMT_AUTHORIZATION_FN definitions Modified: trunk/reactos/include/psdk/ntsecapi.h trunk/reactos/include/psdk/rpcdce.h trunk/reactos/include/psdk/winternl.h Modified: trunk/reactos/include/psdk/ntsecapi.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntsecapi.h?re…
============================================================================== --- trunk/reactos/include/psdk/ntsecapi.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/ntsecapi.h [iso-8859-1] Fri Aug 5 19:35:54 2011 @@ -141,11 +141,11 @@ #define SCESTATUS_NO_MAPPING 18L #define SCESTATUS_TRUST_FAIL 19L -#if !defined(_NTDEF_) +#if !defined(_NTDEF_) && !defined(__WINE_WINTERNL_H) typedef LONG NTSTATUS, *PNTSTATUS; #endif -#if defined (_NTDEF_) +#if defined (_NTDEF_) || defined(__WINE_WINTERNL_H) typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; typedef STRING LSA_STRING, *PLSA_STRING; typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES; Modified: trunk/reactos/include/psdk/rpcdce.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/rpcdce.h?rev=…
============================================================================== --- trunk/reactos/include/psdk/rpcdce.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/rpcdce.h [iso-8859-1] Fri Aug 5 19:35:54 2011 @@ -279,6 +279,18 @@ } u; } RPC_SECURITY_QOS_V2_A, *PRPC_SECURITY_QOS_V2_A; +typedef struct _RPC_PROTSEQ_VECTORA +{ + unsigned int Count; + unsigned char __RPC_FAR * Protseq[1]; +} RPC_PROTSEQ_VECTORA; + +typedef struct _RPC_PROTSEQ_VECTORW +{ + unsigned int Count; + unsigned short __RPC_FAR * Protseq[1]; +} RPC_PROTSEQ_VECTORW; + #define _SEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(_SEC_WINNT_AUTH_IDENTITY_) #define SEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(SEC_WINNT_AUTH_IDENTITY_) #define PSEC_WINNT_AUTH_IDENTITY WINELIB_NAME_AW(PSEC_WINNT_AUTH_IDENTITY_) @@ -290,6 +302,16 @@ #define RPC_SECURITY_QOS_V2 WINELIB_NAME_AW(RPC_SECURITY_QOS_V2_) #define PRPC_SECURITY_QOS_V2 WINELIB_NAME_AW(PRPC_SECURITY_QOS_V2_) #define _RPC_SECURITY_QOS_V2 WINELIB_NAME_AW(_RPC_SECURITY_QOS_V2_) + +#define RPC_PROTSEQ_VECTOR WINELIB_NAME_AW(RPC_PROTSEQ_VECTOR) +#define _RPC_PROTSEQ_VECTOR WINELIB_NAME_AW(_RPC_PROTSEQ_VECTOR) + +typedef int +(__RPC_API * RPC_MGMT_AUTHORIZATION_FN) ( + IN RPC_BINDING_HANDLE ClientBinding, + IN unsigned long RequestedMgmtOperation, + OUT RPC_STATUS __RPC_FAR * Status + ); /* SEC_WINNT_AUTH Flags */ #define SEC_WINNT_AUTH_IDENTITY_ANSI 0x1 Modified: trunk/reactos/include/psdk/winternl.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winternl.h?re…
============================================================================== --- trunk/reactos/include/psdk/winternl.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winternl.h [iso-8859-1] Fri Aug 5 19:35:54 2011 @@ -32,7 +32,7 @@ * Fundamental types and data structures */ -typedef LONG NTSTATUS; +typedef LONG NTSTATUS, *PNTSTATUS; typedef CONST char *PCSZ;
13 years, 3 months
1
0
0
0
[jgardou] 53086: [FORMATTING] - damn you notepad++
by jgardou@svn.reactos.org
Author: jgardou Date: Fri Aug 5 17:58:27 2011 New Revision: 53086 URL:
http://svn.reactos.org/svn/reactos?rev=53086&view=rev
Log: [FORMATTING] - damn you notepad++ Modified: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c Modified: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arcem…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] Fri Aug 5 17:58:27 2011 @@ -30,7 +30,7 @@ { { MemoryFirmwareTemporary, 0x80, 0x10 }, 4, }, // File system read buffer. FILESYSBUFFER { { MemoryFirmwareTemporary, 0x90, 0x10 }, 5, }, // Disk read buffer for int 13h. DISKREADBUFFER { { MemoryFirmwarePermanent, 0xA0, 0x60 }, 6, }, // ROM / Video - { { MemorySpecialMemory, 0xFFF, 1 }, 7, }, // unusable memory + { { MemorySpecialMemory, 0xFFF, 1 }, 7, }, // unusable memory #elif __arm__ // This needs to be done per-platform specific way #endif
13 years, 3 months
1
0
0
0
[jgardou] 53085: [FREELDR] - Add back apparently lost line of r52098. Patch by Alex Ionescu, tested by Igor Paliychuk. See issue #6292 for more details.
by jgardou@svn.reactos.org
Author: jgardou Date: Fri Aug 5 17:54:06 2011 New Revision: 53085 URL:
http://svn.reactos.org/svn/reactos?rev=53085&view=rev
Log: [FREELDR] - Add back apparently lost line of r52098. Patch by Alex Ionescu, tested by Igor Paliychuk. See issue #6292 for more details. Modified: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c Modified: trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arcem…
============================================================================== --- trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] (original) +++ trunk/reactos/boot/freeldr/freeldr/arcemul/mm.c [iso-8859-1] Fri Aug 5 17:54:06 2011 @@ -30,6 +30,7 @@ { { MemoryFirmwareTemporary, 0x80, 0x10 }, 4, }, // File system read buffer. FILESYSBUFFER { { MemoryFirmwareTemporary, 0x90, 0x10 }, 5, }, // Disk read buffer for int 13h. DISKREADBUFFER { { MemoryFirmwarePermanent, 0xA0, 0x60 }, 6, }, // ROM / Video + { { MemorySpecialMemory, 0xFFF, 1 }, 7, }, // unusable memory #elif __arm__ // This needs to be done per-platform specific way #endif
13 years, 3 months
1
0
0
0
[akhaldi] 53084: [CMAKE] * Force cl as the C/C++ Compiler when we detect the WDK environment. * Buildbot can now have PCH support back.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Fri Aug 5 14:48:47 2011 New Revision: 53084 URL:
http://svn.reactos.org/svn/reactos?rev=53084&view=rev
Log: [CMAKE] * Force cl as the C/C++ Compiler when we detect the WDK environment. * Buildbot can now have PCH support back. Modified: trunk/reactos/cmake/Platform/Windows-cl.cmake Modified: trunk/reactos/cmake/Platform/Windows-cl.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/cmake/Platform/Windows-cl.…
============================================================================== --- trunk/reactos/cmake/Platform/Windows-cl.cmake [iso-8859-1] (original) +++ trunk/reactos/cmake/Platform/Windows-cl.cmake [iso-8859-1] Fri Aug 5 14:48:47 2011 @@ -30,6 +30,11 @@ set(ARCH i386) endif() endif() + + # Force C/C++ Compilers + include(CMakeForceCompiler) + CMAKE_FORCE_C_COMPILER(cl MSVC) + CMAKE_FORCE_CXX_COMPILER(cl MSVC) # Add library directories STRING(REPLACE * ${ARCH} ATL_LIB_PATH $ENV{ATL_LIB_PATH})
13 years, 3 months
1
0
0
0
[cgutman] 53083: [TCPIP] - Fix socket closure from a hacked mess that just aborts every socket into something that works properly [LWIP] - Add code to indicate when a socket is closed from LAST_ACK...
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Aug 5 10:28:11 2011 New Revision: 53083 URL:
http://svn.reactos.org/svn/reactos?rev=53083&view=rev
Log: [TCPIP] - Fix socket closure from a hacked mess that just aborts every socket into something that works properly [LWIP] - Add code to indicate when a socket is closed from LAST_ACK state - The problem was that after we call tcp_close from a CLOSE_WAIT state, we never get any indication when the connection is actually closed which causes problems because we're stuck guessing when we can release the port - I will bring this issue up on the lwIP mailing lists to see if this is a patch they want to integrate or if they have any other ideas Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp_in.c branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -444,11 +444,9 @@ * Status of operation */ { - PCONNECTION_ENDPOINT Connection, LastConnection; + PCONNECTION_ENDPOINT Connection; PTRANSPORT_CONTEXT TranContext; PIO_STACK_LOCATION IrpSp; - KIRQL OldIrql; - NTSTATUS Status; TI_DbgPrint(DEBUG_IRP, ("Called.\n")); @@ -468,52 +466,9 @@ return STATUS_INVALID_PARAMETER; } - LockObject(Connection, &OldIrql); - - if (!Connection->AddressFile) { - UnlockObject(Connection, OldIrql); - TI_DbgPrint(MID_TRACE, ("No address file is asscociated.\n")); - return STATUS_INVALID_PARAMETER; - } - - LockObjectAtDpcLevel(Connection->AddressFile); - - /* Unlink this connection from the address file */ - if (Connection->AddressFile->Connection == Connection) - { - Connection->AddressFile->Connection = Connection->Next; - DereferenceObject(Connection); - Status = STATUS_SUCCESS; - } - else - { - LastConnection = Connection->AddressFile->Connection; - while (LastConnection->Next != Connection && LastConnection->Next != NULL) - LastConnection = LastConnection->Next; - if (LastConnection->Next == Connection) - { - LastConnection->Next = Connection->Next; - DereferenceObject(Connection); - Status = STATUS_SUCCESS; - } - else - { - Status = STATUS_INVALID_PARAMETER; - } - } - - UnlockObjectFromDpcLevel(Connection->AddressFile); - - if (Status == STATUS_SUCCESS) - { - /* Remove the address file from this connection */ - DereferenceObject(Connection->AddressFile); - Connection->AddressFile = NULL; - } - - UnlockObject(Connection, OldIrql); - - return Status; + /* NO-OP because we need the address to deallocate the port when the connection closes */ + + return STATUS_SUCCESS; } @@ -653,6 +608,7 @@ Status = STATUS_NO_MEMORY; if( NT_SUCCESS(Status) ) { + ReferenceObject(Connection->AddressFile); Connection->AddressFile->Listener->AddressFile = Connection->AddressFile; Modified: branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/drivers/n…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/drivers/network/tcpip/tcpip/fileobjs.c [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -409,7 +409,6 @@ /* We have to close this listener because we started it */ if( AddrFile->Listener ) { - AddrFile->Listener->AddressFile = NULL; TCPClose( AddrFile->Listener ); } Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/event.c [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -63,7 +63,7 @@ } VOID -FlushAllQueues(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status) +FlushReceiveQueue(PCONNECTION_ENDPOINT Connection, const NTSTATUS Status) { PTDI_BUCKET Bucket; PLIST_ENTRY Entry; @@ -84,13 +84,35 @@ CompleteBucket(Connection, Bucket, FALSE); } - // Calling with Status == STATUS_SUCCESS means that we got a graceful closure - // so we don't want to kill everything else since send is still valid in this state - // + DereferenceObject(Connection); +} + +VOID +FlushAllQueues(PCONNECTION_ENDPOINT Connection, NTSTATUS Status) +{ + PTDI_BUCKET Bucket; + PLIST_ENTRY Entry; + + ReferenceObject(Connection); + + while ((Entry = ExInterlockedRemoveHeadList(&Connection->ReceiveRequest, &Connection->Lock))) + { + Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); + + TI_DbgPrint(DEBUG_TCP, + ("Completing Receive request: %x %x\n", + Bucket->Request, Status)); + + Bucket->Status = Status; + Bucket->Information = 0; + + CompleteBucket(Connection, Bucket, FALSE); + } + + /* We completed the reads successfully but we need to return failure now */ if (Status == STATUS_SUCCESS) { - DereferenceObject(Connection); - return; + Status = STATUS_FILE_CLOSED; } while ((Entry = ExInterlockedRemoveHeadList(&Connection->ListenRequest, &Connection->Lock))) @@ -134,17 +156,61 @@ VOID TCPFinEventHandler(void *arg, const err_t err) { - PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)arg; - const NTSTATUS status = TCPTranslateError(err); - - /* Only clear the pointer if the shutdown was caused by an error */ - if (err != ERR_OK) - { - /* We're got closed by the error so remove the PCB pointer */ + PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)arg, LastConnection; + const NTSTATUS Status = TCPTranslateError(err); + KIRQL OldIrql; + + ASSERT(Connection->AddressFile); + + /* Check if this was a partial socket closure */ + if (err == ERR_OK && Connection->SocketContext) + { + /* Just flush the receive queue and get out of here */ + FlushReceiveQueue(Connection, STATUS_SUCCESS); + } + else + { + /* First off all, remove the PCB pointer */ Connection->SocketContext = NULL; - } - - FlushAllQueues(Connection, status); + + /* Complete all outstanding requests now */ + FlushAllQueues(Connection, Status); + + LockObject(Connection, &OldIrql); + + LockObjectAtDpcLevel(Connection->AddressFile); + + /* Unlink this connection from the address file */ + if (Connection->AddressFile->Connection == Connection) + { + Connection->AddressFile->Connection = Connection->Next; + DereferenceObject(Connection); + } + else if (Connection->AddressFile->Listener == Connection) + { + Connection->AddressFile->Listener = NULL; + DereferenceObject(Connection); + } + else + { + LastConnection = Connection->AddressFile->Connection; + while (LastConnection->Next != Connection && LastConnection->Next != NULL) + LastConnection = LastConnection->Next; + if (LastConnection->Next == Connection) + { + LastConnection->Next = Connection->Next; + DereferenceObject(Connection); + } + } + + UnlockObjectFromDpcLevel(Connection->AddressFile); + + /* Remove the address file from this connection */ + DereferenceObject(Connection->AddressFile); + Connection->AddressFile = NULL; + + UnlockObject(Connection, OldIrql); + } } VOID @@ -186,7 +252,7 @@ ASSERT( ((PTCP_PCB)Bucket->AssociatedEndpoint->SocketContext)->state == CLOSED ); /* free socket context created in FileOpenConnection, as we're using a new one */ - LibTCPClose(Bucket->AssociatedEndpoint, TRUE); + LibTCPClose(Bucket->AssociatedEndpoint, TRUE, FALSE); /* free previously created socket context (we don't use it, we use newpcb) */ Bucket->AssociatedEndpoint->SocketContext = newpcb; Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -106,15 +106,12 @@ Socket = Connection->SocketContext; - /* We should not be associated to an address file at this point */ - ASSERT(!Connection->AddressFile); - /* Don't try to close again if the other side closed us already */ if (Connection->SocketContext) { FlushAllQueues(Connection, STATUS_CANCELLED); - LibTCPClose(Connection, FALSE); + LibTCPClose(Connection, FALSE, TRUE); } UnlockObject(Connection, OldIrql); Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp_in.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp_in.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/core/tcp_in.c [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -345,6 +345,10 @@ } else if (recv_flags & TF_CLOSED) { /* The connection has been closed and we will deallocate the PCB. */ + TCP_EVENT_CLOSED(pcb, err); + if (err == ERR_ABRT) { + goto aborted; + } tcp_pcb_remove(&tcp_active_pcbs, pcb); memp_free(MEMP_TCP_PCB, pcb); } else { Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/include/rosip.h [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -34,7 +34,7 @@ err_t LibTCPSend(PCONNECTION_ENDPOINT Connection, void *const dataptr, const u16_t len, const int safe); err_t LibTCPConnect(PCONNECTION_ENDPOINT Connection, struct ip_addr *const ipaddr, const u16_t port); err_t LibTCPShutdown(PCONNECTION_ENDPOINT Connection, const int shut_rx, const int shut_tx); -err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe); +err_t LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback); err_t LibTCPGetPeerName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port); err_t LibTCPGetHostName(PTCP_PCB pcb, struct ip_addr *const ipaddr, u16_t *const port); Modified: branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/TcpIpDriver/lib/drive…
============================================================================== --- branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] (original) +++ branches/GSoC_2011/TcpIpDriver/lib/drivers/lwip/src/rostcp.c [iso-8859-1] Fri Aug 5 10:28:11 2011 @@ -599,27 +599,25 @@ LibTCPShutdownCallback(void *arg) { struct shutdown_callback_msg *msg = arg; - + PTCP_PCB pcb = msg->Connection->SocketContext; + if (!msg->Connection->SocketContext) { msg->Error = ERR_CLSD; goto done; } - /* - We check here if the pcb is in state ESTABLISHED or SYN_RECV because otherwise - it means lwIP will take care of it anyway and if it does so before us it will - cause memory corruption. - */ - if ((((PTCP_PCB)msg->Connection->SocketContext)->state == ESTABLISHED) || - (((PTCP_PCB)msg->Connection->SocketContext)->state == SYN_RCVD)) - { - msg->Error = - tcp_shutdown((PTCP_PCB)msg->Connection->SocketContext, - msg->shut_rx, msg->shut_tx); - } - else - msg->Error = ERR_OK; + if (pcb->state == CLOSE_WAIT) + { + /* This case actually results in a socket closure later (lwIP bug?) */ + msg->Connection->SocketContext = NULL; + } + + msg->Error = tcp_shutdown(pcb, msg->shut_rx, msg->shut_tx); + if (msg->Error) + { + msg->Connection->SocketContext = pcb; + } done: KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE); @@ -662,6 +660,7 @@ /* Input */ PCONNECTION_ENDPOINT Connection; + int Callback; /* Output */ err_t Error; @@ -672,6 +671,8 @@ LibTCPCloseCallback(void *arg) { struct close_callback_msg *msg = arg; + PTCP_PCB pcb = msg->Connection->SocketContext; + int state; if (!msg->Connection->SocketContext) { @@ -681,22 +682,43 @@ LibTCPEmptyQueue(msg->Connection); - if (((PTCP_PCB)msg->Connection->SocketContext)->state == LISTEN) - { - msg->Error = tcp_close((PTCP_PCB)msg->Connection->SocketContext); + /* Clear the PCB pointer */ + msg->Connection->SocketContext = NULL; + + /* Save the old PCB state */ + state = pcb->state; + + msg->Error = tcp_close(pcb); + if (!msg->Error) + { + if (msg->Callback) + { + /* Call the FIN handler in the cases where it will not be called by lwIP */ + switch (state) + { + case CLOSED: + case LISTEN: + case SYN_SENT: + TCPFinEventHandler(msg->Connection, ERR_OK); + break; + + default: + break; + } + } } else { - tcp_abort((PTCP_PCB)msg->Connection->SocketContext); - msg->Error = ERR_OK; - } - + /* Restore the PCB pointer */ + msg->Connection->SocketContext = pcb; + } + done: KeSetEvent(&msg->Event, IO_NO_INCREMENT, FALSE); } err_t -LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe) +LibTCPClose(PCONNECTION_ENDPOINT Connection, const int safe, const int callback) { err_t ret; struct close_callback_msg *msg; @@ -707,6 +729,7 @@ KeInitializeEvent(&msg->Event, NotificationEvent, FALSE); msg->Connection = Connection; + msg->Callback = callback; if (safe) LibTCPCloseCallback(msg);
13 years, 3 months
1
0
0
0
[tfaber] 53082: [KMTESTS/RTL] - Remove hacks from RtlSplayTree/RtlAvlTree tests - Extend RtlMemory test
by tfaber@svn.reactos.org
Author: tfaber Date: Fri Aug 5 09:44:20 2011 New Revision: 53082 URL:
http://svn.reactos.org/svn/reactos?rev=53082&view=rev
Log: [KMTESTS/RTL] - Remove hacks from RtlSplayTree/RtlAvlTree tests - Extend RtlMemory test Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlAvlTree.c branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlSplayTree.c Modified: branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/C…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/CMakeLists.txt [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -75,6 +75,7 @@ add_executable(kmtest ${KMTEST_SOURCE}) set_module_type(kmtest win32cui) +target_link_libraries(kmtest ${PSEH_LIB}) add_importlibs(kmtest advapi32 msvcrt kernel32 ntdll) set_property(TARGET kmtest PROPERTY COMPILE_DEFINITIONS KMT_USER_MODE) Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/i…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_platform.h [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -30,6 +30,8 @@ #elif !defined __GNUC__ #define KIRQL int #endif /* !defined __GNUC__ */ +typedef const UCHAR CUCHAR, *PCUCHAR; +typedef ULONG LOGICAL, *PLOGICAL; #undef KeRaiseIrql #define KeRaiseIrql(new, old) @@ -39,10 +41,13 @@ #define ExAllocatePoolWithTag(type, size, tag) HeapAlloc(GetProcessHeap(), 0, size) #define ExFreePool(p) HeapFree(GetProcessHeap(), 0, p) #define ExFreePoolWithTag(p, tag) HeapFree(GetProcessHeap(), 0, p) +#define RtlCopyMemoryNonTemporal(d, s, l) +#define RtlPrefetchMemoryNonTemporal(s, l) #endif /* defined KMT_EMULATE_KERNEL */ #endif /* defined KMT_USER_MODE */ #include <pseh/pseh2.h> +#include <limits.h> #endif /* !defined _KMTEST_PLATFORM_H_ */ Modified: branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/i…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/include/kmt_test.h [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -139,6 +139,7 @@ #define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu") #define ok_eq_longlong(value, expected) ok_eq_print(value, expected, "%I64d") #define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected, "%I64u") +#define ok_eq_size(value, expected) ok_eq_ulonglong((ULONGLONG)(value), (ULONGLONG)(expected)) #define ok_eq_hex(value, expected) ok_eq_print(value, expected, "0x%08lx") #define ok_bool_true(value, desc) ok((value) == TRUE, desc " FALSE, expected TRUE\n") #define ok_bool_false(value, desc) ok((value) == FALSE, desc " TRUE, expected FALSE\n") Modified: branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/k…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/kmtest.rbuild [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -2,6 +2,7 @@ <include base="kmtest">include</include> <library>advapi32</library> <library>ntdll</library> + <library>pseh</library> <define name="KMT_USER_MODE" /> <directory name="kmtest"> <file>kmtest.c</file> Modified: branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlAvlTree.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/r…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlAvlTree.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlAvlTree.c [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -1,34 +1,4 @@ -/* HACK: broken ntddk.h */ -#ifdef KMT_KERNEL_MODE -typedef struct _RTL_SPLAY_LINKS { - struct _RTL_SPLAY_LINKS *Parent; - struct _RTL_SPLAY_LINKS *LeftChild; - struct _RTL_SPLAY_LINKS *RightChild; -} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; -#endif - +/* this is a little hacky, but better than duplicating the code (for now) */ #define RTL_USE_AVL_TABLES -#define KMT_EMULATE_KERNEL -#include <kmt_test.h> - -#if defined KMT_USER_MODE -/* HACK: missing in rtltypes.h */ -#undef RTL_GENERIC_TABLE -#undef PRTL_GENERIC_TABLE - -#define RTL_GENERIC_TABLE RTL_AVL_TABLE -#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE - -/* HACK: missing in rtlfuncs.h */ -#define RtlInitializeGenericTable RtlInitializeGenericTableAvl -#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl -#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl -#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl -#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl -#define RtlGetElementGenericTable RtlGetElementGenericTableAvl -#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl -#endif - -/* this is a little hacky, but better than duplicating the code (for now) */ #define Test_RtlSplayTree Test_RtlAvlTree #include "RtlSplayTree.c" Modified: branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/r…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlMemory.c [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -5,23 +5,494 @@ * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de> */ +#include <stddef.h> +__declspec(dllimport) void __stdcall RtlMoveMemory(void *, const void *, size_t); +__declspec(dllimport) void __stdcall RtlFillMemory(void *, size_t, unsigned char); + #define KMT_EMULATE_KERNEL #include <kmt_test.h> +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wnonnull" +#endif /* defined __GNUC__ */ + +static +VOID +MakeBuffer( + OUT PVOID Buffer, + ...) +{ + PUCHAR OutBuffer = Buffer; + INT Count; + INT Value; + va_list Arguments; + + va_start(Arguments, Buffer); + + while (1) + { + Count = va_arg(Arguments, INT); + if (!Count) + break; + ASSERT(Count > 0); + + Value = va_arg(Arguments, INT); + while (Count--) + *OutBuffer++ = Value; + } + + va_end(Arguments); +} + +static +BOOLEAN +CheckBuffer( + IN const VOID *Buffer, + ...) +{ + PCUCHAR OutBuffer = Buffer; + INT Count; + INT Value; + va_list Arguments; + + va_start(Arguments, Buffer); + + while (1) + { + Count = va_arg(Arguments, INT); + if (!Count) + break; + ASSERT(Count > 0); + + Value = va_arg(Arguments, INT); + while (Count--) + if (*OutBuffer++ != Value) + { + --OutBuffer; + trace("CheckBuffer failed at offset %d, value %x, expected %x\n", OutBuffer - (PCUCHAR)Buffer, *OutBuffer, Value); + return FALSE; + } + } + + va_end(Arguments); + return TRUE; +} + +static +VOID +MakePattern( + OUT PVOID Buffer, + ...) +{ + PUCHAR OutBuffer = Buffer; + INT Count, Repeat, i; + INT Values[16]; + va_list Arguments; + + va_start(Arguments, Buffer); + + while (1) + { + Count = va_arg(Arguments, INT); + if (!Count) + break; + ASSERT(Count > 0 && Count < sizeof Values / sizeof Values[0]); + + Repeat = va_arg(Arguments, INT); + ASSERT(Repeat > 0); + + for (i = 0; i < Count; ++i) + Values[i] = va_arg(Arguments, INT); + + while (Repeat--) + for (i = 0; i < Count; ++i) + *OutBuffer++ = Values[i]; + } + + va_end(Arguments); +} + +static +BOOLEAN +CheckPattern( + IN const VOID *Buffer, + ...) +{ + PCUCHAR OutBuffer = Buffer; + INT Count, Repeat, i; + INT Values[16]; + va_list Arguments; + + va_start(Arguments, Buffer); + + while (1) + { + Count = va_arg(Arguments, INT); + if (!Count) + break; + ASSERT(Count > 0 && Count < sizeof Values / sizeof Values[0]); + + Repeat = va_arg(Arguments, INT); + ASSERT(Repeat > 0); + + for (i = 0; i < Count; ++i) + Values[i] = va_arg(Arguments, INT); + + while (Repeat--) + for (i = 0; i < Count; ++i) + if (*OutBuffer++ != Values[i]) + { + --OutBuffer; + trace("CheckPattern failed at offset %d, value %x, expected %x\n", OutBuffer - (PCUCHAR)Buffer, *OutBuffer, Values[i]); + return FALSE; + } + } + + va_end(Arguments); + return TRUE; +} + START_TEST(RtlMemory) { - UCHAR Buffer[512]; + NTSTATUS Status; + UCHAR Buffer[513]; + const INT Size = 512; + const INT HalfSize = Size / 2; + SIZE_T RetSize; KIRQL Irql; - int i; - - KeRaiseIrql(HIGH_LEVEL, &Irql); - - RtlFillMemory(Buffer, sizeof Buffer / 2, 0x55); - RtlFillMemory(Buffer + sizeof Buffer / 2, sizeof Buffer / 2, 0xAA); - for (i = 0; i < sizeof Buffer / 2; ++i) + INT i; + + KeRaiseIrql(HIGH_LEVEL, &Irql); + /* zero everything behind 'Size'. Tests will check that this wasn't changed. + * TODO: use guarded memory for this! */ + MakeBuffer(Buffer + Size, sizeof Buffer - Size, 0, 0); + + /* test our helper functions first */ + MakeBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 0); + for (i = 0; i < HalfSize; ++i) ok_eq_uint(Buffer[i], 0x55); - for (i = sizeof Buffer / 2; i < sizeof Buffer; ++i) + for (i = HalfSize; i < Size; ++i) ok_eq_uint(Buffer[i], 0xAA); + ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + + MakePattern(Buffer, 3, 20, 0x11, 0x22, 0x33, 1, 4, 0x44, 0); + for (i = 0; i < 60; i += 3) + { + ok_eq_uint(Buffer[i+0], 0x11); + ok_eq_uint(Buffer[i+1], 0x22); + ok_eq_uint(Buffer[i+2], 0x33); + } + for (i = 60; i < 64; ++i) + ok_eq_uint(Buffer[i], 0x44); + for (i = 64; i < HalfSize; ++i) + ok_eq_uint(Buffer[i], 0x55); + for (i = HalfSize; i < Size; ++i) + ok_eq_uint(Buffer[i], 0xAA); + ok_bool_true(CheckPattern(Buffer, 3, 20, 0x11, 0x22, 0x33, 1, 4, 0x44, 0), "CheckPattern"); + + /* RtlMoveMemory */ + MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0); + RtlMoveMemory(Buffer + 13, Buffer + 62, 95); + ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern"); + + MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0); + RtlMoveMemory(Buffer + 78, Buffer + 43, 107); + ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlMoveMemory(NULL, NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + +#undef RtlMoveMemory + /* RtlMoveMemory export */ + MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0); + RtlMoveMemory(Buffer + 13, Buffer + 62, 95); + ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern"); + + MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0); + RtlMoveMemory(Buffer + 78, Buffer + 43, 107); + ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlMoveMemory(NULL, NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlCopyMemory */ + MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0); + RtlCopyMemory(Buffer + 13, Buffer + 62, 95); + ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern"); + + MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0); + RtlCopyMemory(Buffer + 78, Buffer + 43, 107); + ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlCopyMemory(NULL, NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlCopyMemoryNonTemporal */ + MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0); + RtlCopyMemoryNonTemporal(Buffer + 13, Buffer + 62, 95); + ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern"); + + MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0); + RtlCopyMemoryNonTemporal(Buffer + 78, Buffer + 43, 107); + ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlCopyMemoryNonTemporal(NULL, NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlCopyBytes */ + MakePattern(Buffer, 2, 64, 0x12, 0x34, 2, 192, 0x56, 0x78, 0); + RtlCopyBytes(Buffer + 13, Buffer + 62, 95); + ok_bool_true(CheckPattern(Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0), "CheckPattern"); + + MakePattern(Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0); + RtlCopyBytes(Buffer + 78, Buffer + 43, 107); + ok_bool_true(CheckPattern(Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0), "CheckPattern"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlCopyBytes(NULL, NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlEqualMemory */ + /* TODO: where is memcmp? */ + + /* RtlCompareMemory */ + MakePattern(Buffer, 8, HalfSize / 8 - 1, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, + 1, 1, 0x12, + 8, HalfSize / 8, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, + 1, 7, 0x12, 0); + + RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, HalfSize - 8); + ok_eq_size(RetSize, HalfSize - 8); + RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, HalfSize - 8 + 1); + ok_eq_size(RetSize, HalfSize - 8 + 1); + RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, HalfSize - 8 + 2); + ok_eq_size(RetSize, HalfSize - 8 + 1); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RetSize = RtlCompareMemory(Buffer, Buffer + HalfSize - 7, SIZE_MAX); + ok_eq_size(RetSize, HalfSize - 8 + 1); + RetSize = RtlCompareMemory(NULL, NULL, 0); + ok_eq_size(RetSize, 0LU); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlCompareMemoryUlong */ + MakeBuffer(Buffer, 8, 0x55, Size - 4, 0, 0); + RetSize = RtlCompareMemoryUlong(Buffer, sizeof(ULONG), 0x55555555LU); + ok_eq_size(RetSize, 4LU); + RetSize = RtlCompareMemoryUlong(Buffer + 1, sizeof(ULONG), 0x55555555LU); + ok_eq_size(RetSize, 4LU); + RetSize = RtlCompareMemoryUlong(Buffer + 2, sizeof(ULONG), 0x55555555LU); + ok_eq_size(RetSize, 4LU); + RetSize = RtlCompareMemoryUlong(Buffer + 3, sizeof(ULONG), 0x55555555LU); + ok_eq_size(RetSize, 4LU); + RetSize = RtlCompareMemoryUlong(Buffer + 5, sizeof(ULONG), 0x55555555LU); + ok_eq_size(RetSize, 0LU); + RetSize = RtlCompareMemoryUlong(Buffer + 5, sizeof(ULONG), 0x00555555LU); + ok_eq_size(RetSize, 4LU); + RetSize = RtlCompareMemoryUlong(Buffer, 1, 0x55555555LU); + ok_eq_size(RetSize, 0LU); + RetSize = RtlCompareMemoryUlong(Buffer, 2, 0x55555555LU); + ok_eq_size(RetSize, 0LU); + RetSize = RtlCompareMemoryUlong(Buffer, 3, 0x55555555LU); + ok_eq_size(RetSize, 0LU); + RetSize = RtlCompareMemoryUlong(Buffer, 5, 0x55555555LU); + ok_eq_size(RetSize, 4LU); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RetSize = RtlCompareMemoryUlong(NULL, 0, 0x55555555LU); + ok_eq_size(RetSize, 0LU); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlZeroMemory */ + MakeBuffer(Buffer, Size, 0x11, 0); + RtlZeroMemory(Buffer, 1); + ok_bool_true(CheckBuffer(Buffer, 1, 0, Size - 1, 0x11, 1, 0, 0), "CheckBuffer"); + Buffer[0] = 0x11; + RtlZeroMemory(Buffer, Size - 1); + ok_bool_true(CheckBuffer(Buffer, Size - 1, 0, 1, 0x11, 1, 0, 0), "CheckBuffer"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlZeroMemory(NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlSecureZeroMemory */ + MakeBuffer(Buffer, Size, 0x11, 0); + RtlSecureZeroMemory(Buffer, 1); + ok_bool_true(CheckBuffer(Buffer, 1, 0, Size - 1, 0x11, 1, 0, 0), "CheckBuffer"); + Buffer[0] = 0x11; + RtlSecureZeroMemory(Buffer, Size - 1); + ok_bool_true(CheckBuffer(Buffer, Size - 1, 0, 1, 0x11, 1, 0, 0), "CheckBuffer"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlSecureZeroMemory(NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlZeroBytes */ + MakeBuffer(Buffer, Size, 0x11, 0); + RtlZeroBytes(Buffer, 1); + ok_bool_true(CheckBuffer(Buffer, 1, 0, Size - 1, 0x11, 1, 0, 0), "CheckBuffer"); + Buffer[0] = 0x11; + RtlZeroBytes(Buffer, Size - 1); + ok_bool_true(CheckBuffer(Buffer, Size - 1, 0, 1, 0x11, 1, 0, 0), "CheckBuffer"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlZeroBytes(NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlFillMemory */ + MakeBuffer(Buffer, Size, 0, 0); + RtlFillMemory(Buffer, HalfSize, 0x55); + RtlFillMemory(Buffer + HalfSize, HalfSize, 0xAA); + ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + RtlFillMemory(Buffer + 3, 7, 0x88); + ok_bool_true(CheckBuffer(Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlFillMemory(NULL, 0, 0x55); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + +#undef RtlFillMemory + /* RtlFillMemory export */ + MakeBuffer(Buffer, Size, 0, 0); + RtlFillMemory(Buffer, HalfSize, 0x55); + RtlFillMemory(Buffer + HalfSize, HalfSize, 0xAA); + ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + RtlFillMemory(Buffer + 3, 7, 0x88); + ok_bool_true(CheckBuffer(Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlFillMemory(NULL, 0, 0x55); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlFillMemoryUlong */ + MakeBuffer(Buffer, Size, 0, 0); + RtlFillMemoryUlong(Buffer, HalfSize, 0x01234567LU); + RtlFillMemoryUlong(Buffer + HalfSize, HalfSize, 0x89ABCDEFLU); + ok_bool_true(CheckPattern(Buffer, 4, HalfSize / 4, 0x67, 0x45, 0x23, 0x01, 4, HalfSize / 4, 0xEF, 0xCD, 0xAB, 0x89, 1, 1, 0, 0), "CheckPattern"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + MakeBuffer(Buffer, Size, 0, 0); + RtlFillMemoryUlong(Buffer + 1, sizeof(ULONG), 0xAAAAAAAALU); + ok_bool_true(CheckBuffer(Buffer, 1, 0, sizeof(ULONG), 0xAA, Size - sizeof(ULONG) - 1, 0, 1, 0, 0), "CheckBuffer"); + + RtlFillMemoryUlong(NULL, 0, 0x55555555LU); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlFillMemoryUlonglong */ + /* TODO: this function doesn't exist in 2k3/x86? wdm.h error? */ + + /* RtlFillBytes */ + MakeBuffer(Buffer, Size, 0, 0); + RtlFillBytes(Buffer, HalfSize, 0x55); + RtlFillBytes(Buffer + HalfSize, HalfSize, 0xAA); + ok_bool_true(CheckBuffer(Buffer, HalfSize, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + RtlFillBytes(Buffer + 3, 7, 0x88); + ok_bool_true(CheckBuffer(Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0), "CheckBuffer"); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlFillBytes(NULL, 0, 0x55); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); + + /* RtlPrefetchMemoryNonTemporal */ + RtlPrefetchMemoryNonTemporal(Buffer, Size); + + KeLowerIrql(Irql); + Status = STATUS_SUCCESS; + _SEH2_TRY { + RtlPrefetchMemoryNonTemporal(NULL, 0); + } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { + Status = _SEH2_GetExceptionCode(); + } _SEH2_END; + ok_eq_hex(Status, STATUS_SUCCESS); + KeRaiseIrql(HIGH_LEVEL, &Irql); KeLowerIrql(Irql); } Modified: branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlSplayTree.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/KMTestSuite/kmtests/r…
============================================================================== --- branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlSplayTree.c [iso-8859-1] (original) +++ branches/GSoC_2011/KMTestSuite/kmtests/rtl/RtlSplayTree.c [iso-8859-1] Fri Aug 5 09:44:20 2011 @@ -10,17 +10,6 @@ #define NDEBUG #include <debug.h> - -/* HACK: missing in rtlfuncs.h */ -#if defined KMT_USER_MODE && !defined RTL_USE_AVL_TABLES -NTSYSAPI VOID NTAPI RtlInitializeGenericTable(OUT PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext OPTIONAL); -NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer, IN CLONG BufferSize, OUT PBOOLEAN NewElement OPTIONAL); -NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer); -NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer); -NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable(IN PRTL_GENERIC_TABLE Table, IN BOOLEAN Restart); -NTSYSAPI PVOID NTAPI RtlGetElementGenericTable(IN PRTL_GENERIC_TABLE Table, IN ULONG I); -NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(IN PRTL_GENERIC_TABLE Table); -#endif static LIST_ENTRY Allocations;
13 years, 3 months
1
0
0
0
← Newer
1
...
40
41
42
43
44
45
46
...
50
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Results per page:
10
25
50
100
200