├── .gitignore ├── .travis.yml ├── .vscode ├── launch.json └── tasks.json ├── README.md ├── Scheduler ├── Doxygen │ ├── Doxyfile │ ├── doxygen.exe │ └── style.css ├── Include │ ├── MTAppInterop.h │ ├── MTArrayView.h │ ├── MTAtomic.h │ ├── MTColorTable.h │ ├── MTConcurrentRingBuffer.h │ ├── MTConfig.h │ ├── MTDebug.h │ ├── MTFiberContext.h │ ├── MTFiberContext.inl │ ├── MTGroupedTask.h │ ├── MTPlatform.h │ ├── MTProfilerEventListener.h │ ├── MTQueueMPMC.h │ ├── MTScheduler.h │ ├── MTScheduler.inl │ ├── MTStackRequirements.h │ ├── MTStaticVector.h │ ├── MTTaskBucket.h │ ├── MTTaskDesc.h │ ├── MTTaskGroup.h │ ├── MTTaskPool.h │ ├── MTTaskQueue.h │ ├── MTThreadContext.h │ ├── MTTools.h │ ├── MTTypes.h │ ├── Platform │ │ ├── Common │ │ │ ├── MTAtomic.h │ │ │ ├── MTSpinWait.h │ │ │ └── MTThread.h │ │ ├── Posix │ │ │ ├── MTAtomic.h │ │ │ ├── MTCommon.h │ │ │ ├── MTEvent.h │ │ │ ├── MTFiber.h │ │ │ ├── MTMemory.h │ │ │ ├── MTMutex.h │ │ │ ├── MTThread.h │ │ │ └── MTUtils.h │ │ └── Windows │ │ │ ├── MTAtomic.h │ │ │ ├── MTCommon.h │ │ │ ├── MTEvent.h │ │ │ ├── MTEventKernel.h │ │ │ ├── MTEventUser.h │ │ │ ├── MTFiber.h │ │ │ ├── MTFiberDefault.h │ │ │ ├── MTFiberOptimized.h │ │ │ ├── MTMemory.h │ │ │ ├── MTMutex.h │ │ │ ├── MTThread.h │ │ │ ├── MTUtils.h │ │ │ ├── MicroWindows.cpp │ │ │ └── MicroWindows.h │ └── Scopes │ │ └── MTScopes.h └── Source │ ├── MTDefaultAppInterop.cpp │ ├── MTFiberContext.cpp │ ├── MTScheduler.cpp │ └── MTThreadContext.cpp ├── SchedulerTests ├── Profiler │ ├── Profiler.cpp │ └── Profiler.h ├── Tests │ ├── AtomicTests.cpp │ ├── CleanupTests.cpp │ ├── DxtTests.cpp │ ├── FiberTests.cpp │ ├── FireAndForget.cpp │ ├── FoundationTests.cpp │ ├── GroupTests.cpp │ ├── LenaDxt │ │ ├── HeaderDDS.h │ │ └── LenaColor.h │ ├── PlatformTests.cpp │ ├── PriorityTests.cpp │ ├── ScopesTests.cpp │ ├── SimpleTests.cpp │ ├── StackSizeTests.cpp │ ├── SubtasksTests.cpp │ ├── Tests.cpp │ ├── Tests.h │ └── WaitTests.cpp └── main.cpp ├── StripNdaCode.cmd ├── TaskScheduler.code-workspace ├── ThirdParty ├── Boost.Context │ ├── LICENSE_1_0.txt │ ├── asm │ │ ├── jump_arm64_aapcs_elf_gas.S │ │ ├── jump_arm64_aapcs_macho_gas.S │ │ ├── jump_arm_aapcs_elf_gas.S │ │ ├── jump_arm_aapcs_macho_gas.S │ │ ├── jump_arm_aapcs_pe_armasm.asm │ │ ├── jump_combined_sysv_macho_gas.S │ │ ├── jump_i386_ms_pe_gas.asm │ │ ├── jump_i386_ms_pe_masm.asm │ │ ├── jump_i386_sysv_elf_gas.S │ │ ├── jump_i386_sysv_macho_gas.S │ │ ├── jump_i386_x86_64_sysv_macho_gas.S │ │ ├── jump_mips32_o32_elf_gas.S │ │ ├── jump_ppc32_ppc64_sysv_macho_gas.S │ │ ├── jump_ppc32_sysv_elf_gas.S │ │ ├── jump_ppc32_sysv_macho_gas.S │ │ ├── jump_ppc32_sysv_xcoff_gas.S │ │ ├── jump_ppc64_sysv_elf_gas.S │ │ ├── jump_ppc64_sysv_macho_gas.S │ │ ├── jump_ppc64_sysv_xcoff_gas.S │ │ ├── jump_sparc64_sysv_elf_gas.S │ │ ├── jump_sparc_sysv_elf_gas.S │ │ ├── jump_x86_64_ms_pe_gas.asm │ │ ├── jump_x86_64_ms_pe_masm.asm │ │ ├── jump_x86_64_sysv_elf_gas.S │ │ ├── jump_x86_64_sysv_macho_gas.S │ │ ├── make_arm64_aapcs_elf_gas.S │ │ ├── make_arm64_aapcs_macho_gas.S │ │ ├── make_arm_aapcs_elf_gas.S │ │ ├── make_arm_aapcs_macho_gas.S │ │ ├── make_arm_aapcs_pe_armasm.asm │ │ ├── make_combined_sysv_macho_gas.S │ │ ├── make_i386_ms_pe_gas.asm │ │ ├── make_i386_ms_pe_masm.asm │ │ ├── make_i386_sysv_elf_gas.S │ │ ├── make_i386_sysv_macho_gas.S │ │ ├── make_i386_x86_64_sysv_macho_gas.S │ │ ├── make_mips32_o32_elf_gas.S │ │ ├── make_ppc32_ppc64_sysv_macho_gas.S │ │ ├── make_ppc32_sysv_elf_gas.S │ │ ├── make_ppc32_sysv_macho_gas.S │ │ ├── make_ppc32_sysv_xcoff_gas.S │ │ ├── make_ppc64_sysv_elf_gas.S │ │ ├── make_ppc64_sysv_macho_gas.S │ │ ├── make_ppc64_sysv_xcoff_gas.S │ │ ├── make_sparc64_sysv_elf_gas.S │ │ ├── make_sparc_sysv_elf_gas.S │ │ ├── make_x86_64_ms_pe_gas.asm │ │ ├── make_x86_64_ms_pe_masm.asm │ │ ├── make_x86_64_sysv_elf_gas.S │ │ └── make_x86_64_sysv_macho_gas.S │ └── fcontext.h ├── Squish │ ├── ChangeLog │ ├── Doxyfile │ ├── Makefile │ ├── README │ ├── alpha.cpp │ ├── alpha.h │ ├── clusterfit.cpp │ ├── clusterfit.h │ ├── colourblock.cpp │ ├── colourblock.h │ ├── colourfit.cpp │ ├── colourfit.h │ ├── colourset.cpp │ ├── colourset.h │ ├── config │ ├── config.h │ ├── maths.cpp │ ├── maths.h │ ├── rangefit.cpp │ ├── rangefit.h │ ├── simd.h │ ├── simd_float.h │ ├── simd_sse.h │ ├── simd_ve.h │ ├── singlecolourfit.cpp │ ├── singlecolourfit.h │ ├── singlecolourlookup.inl │ ├── squish.cpp │ ├── squish.h │ └── texture_compression_s3tc.txt └── UnitTest++ │ ├── .gitattributes │ ├── .gitignore │ ├── .gitmodules │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── ChangeLog │ ├── INSTALL │ ├── LICENSE │ ├── Makefile.am │ ├── README.md │ ├── UnitTest++ │ ├── AssertException.cpp │ ├── AssertException.h │ ├── CheckMacros.h │ ├── Checks.cpp │ ├── Checks.h │ ├── CompositeTestReporter.cpp │ ├── CompositeTestReporter.h │ ├── Config.h │ ├── CurrentTest.cpp │ ├── CurrentTest.h │ ├── DeferredTestReporter.cpp │ ├── DeferredTestReporter.h │ ├── DeferredTestResult.cpp │ ├── DeferredTestResult.h │ ├── ExceptionMacros.h │ ├── ExecuteTest.h │ ├── HelperMacros.h │ ├── Makefile.am │ ├── MemoryOutStream.cpp │ ├── MemoryOutStream.h │ ├── Posix │ │ ├── SignalTranslator.cpp │ │ ├── SignalTranslator.h │ │ ├── TimeHelpers.cpp │ │ └── TimeHelpers.h │ ├── ReportAssert.cpp │ ├── ReportAssert.h │ ├── ReportAssertImpl.h │ ├── Test.cpp │ ├── Test.h │ ├── TestDetails.cpp │ ├── TestDetails.h │ ├── TestList.cpp │ ├── TestList.h │ ├── TestMacros.h │ ├── TestReporter.cpp │ ├── TestReporter.h │ ├── TestReporterStdout.cpp │ ├── TestReporterStdout.h │ ├── TestResults.cpp │ ├── TestResults.h │ ├── TestRunner.cpp │ ├── TestRunner.h │ ├── TestSuite.h │ ├── TimeConstraint.cpp │ ├── TimeConstraint.h │ ├── TimeHelpers.h │ ├── UnitTest++.h │ ├── UnitTestPP.h │ ├── UnitTestTimer.h │ ├── Win32 │ │ ├── TimeHelpers.cpp │ │ └── TimeHelpers.h │ ├── XmlTestReporter.cpp │ ├── XmlTestReporter.h │ ├── unittestpp_vs2005.vcproj │ ├── unittestpp_vs2008.vcproj │ ├── unittestpp_vs2008.vcxproj │ └── unittestpp_vs2008.vcxproj.filters │ ├── builds │ └── .gitignore │ ├── configure.ac │ └── tests │ ├── Main.cpp │ ├── RecordingReporter.h │ ├── ScopedCurrentTest.h │ ├── TestAssertHandler.cpp │ ├── TestCheckMacros.cpp │ ├── TestChecks.cpp │ ├── TestCompositeTestReporter.cpp │ ├── TestCurrentTest.cpp │ ├── TestDeferredTestReporter.cpp │ ├── TestExceptions.cpp │ ├── TestMemoryOutStream.cpp │ ├── TestTest.cpp │ ├── TestTestList.cpp │ ├── TestTestMacros.cpp │ ├── TestTestResults.cpp │ ├── TestTestRunner.cpp │ ├── TestTestSuite.cpp │ ├── TestTimeConstraint.cpp │ ├── TestTimeConstraintMacro.cpp │ ├── TestUnitTestPP.cpp │ └── TestXmlTestReporter.cpp ├── appveyor.yml ├── license.txt ├── premake4.exe ├── premake4.lua └── sunifdef.exe /.gitignore: -------------------------------------------------------------------------------- 1 | Bin/ 2 | Build/ 3 | Scheduler/Docs 4 | *.user 5 | *.suo 6 | *.rej 7 | *.orig -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | - osx 4 | 5 | osx_image: xcode7.2 6 | 7 | language: 8 | - cpp 9 | 10 | compiler: 11 | - gcc 12 | 13 | before_install: 14 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo bash -c "echo 'deb http://lgp203.free.fr/ubuntu quantal universe' >> /etc/apt/sources.list.d/lgp203.free.fr.source.list"; fi 15 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi 16 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update; fi 17 | 18 | install: 19 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install --force-yes make premake4; fi 20 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install --force-yes -qq gcc-4.9 g++-4.9; fi 21 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90; fi 22 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get --force-yes -y install gcc-4.9-multilib g++-4.9-multilib; fi 23 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install lshw; fi 24 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install valgrind; fi 25 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; fi 26 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install premake; fi 27 | 28 | script: 29 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then clang --version && g++ --version && premake4 gmake && pushd Build/gmake/ && make config=release64 && popd; fi 30 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then clang --version && g++ --version && premake4 gmake && pushd Build/gmake/ && make config=debug64 && popd; fi 31 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo lshw; fi 32 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then sudo system_profiler SPHardwareDataType; fi 33 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then pushd Bin/ && ./TaskSchedulerTests 3 && popd; fi 34 | - if [ "$TRAVIS_OS_NAME" = "osx" ]; then pushd Bin/ && ./TaskSchedulerTests 6 && popd; fi 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(lldb) Launch", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/Bin/TaskSchedulerTests", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}/Bin/", 15 | "environment": [], 16 | "externalConsole": true, 17 | "MIMode": "lldb" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "Premake4 - Generate", 8 | "type": "shell", 9 | "command": "premake4 gmake", 10 | "problemMatcher": [] 11 | }, 12 | { 13 | "label": "Build - Debug64", 14 | "type": "shell", 15 | "command": "pushd Build/gmake && make config=debug64 && popd", 16 | "group": { 17 | "kind": "build", 18 | "isDefault": true 19 | } 20 | }, 21 | { 22 | "label": "Build - Release64", 23 | "type": "shell", 24 | "command": "pushd Build/gmake && make config=release64 && popd", 25 | "problemMatcher": [ 26 | "$gcc" 27 | ] 28 | }, 29 | { 30 | "label": "Run", 31 | "type": "shell", 32 | "command": "pushd Bin/ && ./TaskSchedulerTests && popd", 33 | "problemMatcher": [] 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /Scheduler/Doxygen/doxygen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SergeyMakeev/TaskScheduler/2b9bbb88dfa47e1541368368c320aac6c516a99b/Scheduler/Doxygen/doxygen.exe -------------------------------------------------------------------------------- /Scheduler/Include/MTAppInterop.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | #if MT_MSVC_COMPILER_FAMILY 28 | #include 29 | #elif MT_GCC_COMPILER_FAMILY 30 | #include 31 | #include 32 | #else 33 | #error Compiler is not supported 34 | #endif 35 | 36 | #if MT_MSVC_COMPILER_FAMILY 37 | #define MT_NORETURN 38 | #elif MT_GCC_COMPILER_FAMILY 39 | #define MT_NORETURN // [[ noreturn ]] 40 | #else 41 | #error Can not define MT_NORETURN. Unknown platform. 42 | #endif 43 | 44 | 45 | 46 | #define MT_DEFAULT_ALIGN (16) 47 | 48 | namespace MT 49 | { 50 | // Memory allocator interface. 51 | ////////////////////////////////////////////////////////////////////////// 52 | struct Memory 53 | { 54 | struct StackDesc 55 | { 56 | void* stackBottom; 57 | void* stackTop; 58 | 59 | char* stackMemory; 60 | size_t stackMemoryBytesCount; 61 | 62 | 63 | StackDesc() 64 | : stackBottom(nullptr) 65 | , stackTop(nullptr) 66 | , stackMemory(nullptr) 67 | , stackMemoryBytesCount(0) 68 | { 69 | } 70 | 71 | size_t GetStackSize() 72 | { 73 | return (char*)stackTop - (char*)stackBottom; 74 | } 75 | }; 76 | 77 | 78 | static void* Alloc(size_t size, size_t align = MT_DEFAULT_ALIGN); 79 | static void Free(void* p); 80 | 81 | static StackDesc AllocStack(size_t size); 82 | static void FreeStack(const StackDesc & desc); 83 | }; 84 | 85 | 86 | struct Diagnostic 87 | { 88 | MT_NORETURN static void ReportAssert(const char* condition, const char* description, const char* sourceFile, int sourceLine); 89 | }; 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /Scheduler/Include/MTArrayView.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | 26 | namespace MT 27 | { 28 | 29 | 30 | /// \class ArrayView 31 | /// \brief Simple wrapper to work with raw memory as an array. Includes array bounds checking. 32 | template 33 | class ArrayView 34 | { 35 | T* data; 36 | size_t count; 37 | 38 | public: 39 | 40 | ArrayView() 41 | { 42 | data = nullptr; 43 | count = 0; 44 | } 45 | 46 | ArrayView(void* memoryChunk, size_t instanceCount) 47 | : data((T*)memoryChunk) 48 | , count(instanceCount) 49 | { 50 | MT_ASSERT(count == 0 || data, "Invalid data array"); 51 | } 52 | 53 | ~ArrayView() 54 | { 55 | data = nullptr; 56 | count = 0; 57 | } 58 | 59 | const T &operator[]( size_t i ) const 60 | { 61 | MT_ASSERT( i < Size(), "bad index" ); 62 | return data[i]; 63 | } 64 | 65 | T &operator[]( size_t i ) 66 | { 67 | MT_ASSERT( i < Size(), "bad index" ); 68 | return data[i]; 69 | } 70 | 71 | size_t Size() const 72 | { 73 | return count; 74 | } 75 | 76 | bool IsEmpty() const 77 | { 78 | return count == 0; 79 | } 80 | 81 | T* GetRawData() 82 | { 83 | return data; 84 | } 85 | 86 | const T* GetRawData() const 87 | { 88 | return data; 89 | } 90 | 91 | }; 92 | 93 | 94 | } 95 | -------------------------------------------------------------------------------- /Scheduler/Include/MTAtomic.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #ifndef __MT_ATOMIC_MAIN__ 26 | #define __MT_ATOMIC_MAIN__ 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Scheduler/Include/MTDebug.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | #include 25 | #include 26 | 27 | 28 | #if defined(MT_DEBUG) || defined(MT_INSTRUMENTED_BUILD) 29 | 30 | #define MT_REPORT_ASSERT_IMPL( condition, description, file, line ) MT::Diagnostic::ReportAssert(#condition, description, file, line); 31 | 32 | #ifndef MT_REPORT_ASSERT 33 | #define MT_REPORT_ASSERT( description ) { MT_REPORT_ASSERT_IMPL( "always", description, __FILE__, __LINE__ ) } 34 | #endif 35 | 36 | #ifndef MT_ASSERT 37 | #define MT_ASSERT( condition, description ) { if ( !(condition) ) { MT_REPORT_ASSERT_IMPL( #condition, description, __FILE__, __LINE__ ) } } 38 | #endif 39 | 40 | #ifndef MT_VERIFY 41 | #define MT_VERIFY( condition, description, operation ) { if ( !(condition) ) { { MT_REPORT_ASSERT_IMPL( #condition, description, __FILE__, __LINE__ ) }; operation; } } 42 | #endif 43 | 44 | #else 45 | 46 | #ifndef MT_REPORT_ASSERT 47 | #define MT_REPORT_ASSERT( description ) 48 | #endif 49 | 50 | #ifndef MT_ASSERT 51 | #define MT_ASSERT( condition, description ) 52 | #endif 53 | 54 | #ifndef MT_VERIFY 55 | #define MT_VERIFY( condition, description, operation ) { if ( !(condition) ) { operation; } } 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /Scheduler/Include/MTFiberContext.inl: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | namespace MT 24 | { 25 | 26 | template 27 | void FiberContext::RunSubtasksAndYield(TaskGroup taskGroup, const TTask* taskArray, size_t taskCount) 28 | { 29 | MT_ASSERT(taskCount < (internal::TASK_BUFFER_CAPACITY - 1), "Too many tasks per one Run."); 30 | MT_ASSERT(threadContext, "ThreadContext is nullptr"); 31 | 32 | TaskScheduler& scheduler = *(threadContext->taskScheduler); 33 | 34 | ArrayView buffer(threadContext->descBuffer, taskCount); 35 | 36 | size_t bucketCount = MT::Min((size_t)scheduler.GetWorkersCount(), taskCount); 37 | ArrayView buckets(MT_ALLOCATE_ON_STACK(sizeof(internal::TaskBucket) * bucketCount), bucketCount); 38 | 39 | internal::DistibuteDescriptions(taskGroup, taskArray, buffer, buckets); 40 | RunSubtasksAndYieldImpl(buckets); 41 | } 42 | 43 | template 44 | void FiberContext::RunAsync(TaskGroup taskGroup, const TTask* taskArray, size_t taskCount) 45 | { 46 | MT_ASSERT(taskCount < (internal::TASK_BUFFER_CAPACITY - 1), "Too many tasks per one Run."); 47 | 48 | MT_ASSERT(threadContext, "ThreadContext is nullptr"); 49 | MT_ASSERT(threadContext->taskScheduler->IsWorkerThread(), "Can't use RunAsync outside Task. Use TaskScheduler.RunAsync() instead."); 50 | 51 | TaskScheduler& scheduler = *(threadContext->taskScheduler); 52 | 53 | ArrayView buffer(threadContext->descBuffer, taskCount); 54 | 55 | size_t bucketCount = MT::Min((size_t)scheduler.GetWorkersCount(), taskCount); 56 | ArrayView buckets(MT_ALLOCATE_ON_STACK(sizeof(internal::TaskBucket) * bucketCount), bucketCount); 57 | 58 | internal::DistibuteDescriptions(taskGroup, taskArray, buffer, buckets); 59 | scheduler.RunTasksImpl(buckets, nullptr, false); 60 | } 61 | 62 | 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Scheduler/Include/MTGroupedTask.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace MT 31 | { 32 | class FiberContext; 33 | 34 | namespace internal 35 | { 36 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 37 | struct GroupedTask 38 | { 39 | FiberContext* awaitingFiber; 40 | FiberContext* parentFiber; 41 | TaskGroup group; 42 | TaskDesc desc; 43 | 44 | GroupedTask() 45 | : awaitingFiber(nullptr) 46 | , parentFiber(nullptr) 47 | {} 48 | 49 | GroupedTask(const TaskDesc& _desc, TaskGroup _group) 50 | : awaitingFiber(nullptr) 51 | , parentFiber(nullptr) 52 | , group(_group) 53 | , desc(_desc) 54 | {} 55 | }; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Scheduler/Include/MTPlatform.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | #include 25 | #include 26 | #include 27 | 28 | typedef void (*TThreadEntryPoint)(void* userData); 29 | 30 | #define MT_ARRAY_SIZE( arr ) ( sizeof( arr ) / sizeof( (arr)[0] ) ) 31 | 32 | namespace MT 33 | { 34 | namespace EventReset 35 | { 36 | enum Type 37 | { 38 | AUTOMATIC = 0, 39 | MANUAL = 1, 40 | }; 41 | } 42 | } 43 | 44 | 45 | 46 | #if MT_PLATFORM_WINDOWS 47 | #include 48 | #elif MT_PLATFORM_POSIX || MT_PLATFORM_OSX 49 | #include 50 | #else 51 | #error Platfrom is not supported 52 | #endif 53 | 54 | #include 55 | #include 56 | 57 | namespace MT 58 | { 59 | // 60 | // 61 | // 62 | class ScopedGuard 63 | { 64 | MT::Mutex & mutex; 65 | 66 | ScopedGuard( const ScopedGuard & ); 67 | void operator=( const ScopedGuard &); 68 | 69 | public: 70 | 71 | ScopedGuard(MT::Mutex & _mutex) : mutex(_mutex) 72 | { 73 | mutex.Lock(); 74 | } 75 | 76 | ~ScopedGuard() 77 | { 78 | mutex.Unlock(); 79 | } 80 | }; 81 | 82 | // 83 | // Simple Linear congruential generator 84 | // 85 | class LcgRandom 86 | { 87 | uint32 state; 88 | 89 | public: 90 | 91 | LcgRandom() 92 | : state(2578432553) 93 | { 94 | } 95 | 96 | void SetSeed(uint32 seed) 97 | { 98 | state = seed; 99 | } 100 | 101 | uint16 Get() 102 | { 103 | state = 214013 * state + 2531011; 104 | uint16 rnd = (state >> 16); 105 | return rnd; 106 | } 107 | 108 | 109 | }; 110 | 111 | } 112 | 113 | 114 | #if MT_CPP11_SUPPORTED 115 | #define mt_thread_local _Thread_local 116 | #elif MT_GCC_COMPILER_FAMILY 117 | #define mt_thread_local __thread 118 | #elif MT_MSVC_COMPILER_FAMILY 119 | #define mt_thread_local __declspec(thread) 120 | #else 121 | #error Can not define mt_thread_local. Unknown platform. 122 | #endif 123 | 124 | 125 | -------------------------------------------------------------------------------- /Scheduler/Include/MTProfilerEventListener.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | 26 | #ifdef MT_INSTRUMENTED_BUILD 27 | 28 | 29 | namespace MT 30 | { 31 | 32 | class IProfilerEventListener 33 | { 34 | 35 | public: 36 | 37 | IProfilerEventListener() {}; 38 | virtual ~IProfilerEventListener() {}; 39 | 40 | // Called from main scheduler thread when all fibers has created (notify about fibers count) 41 | virtual void OnFibersCreated(uint32 fibersCount) = 0; 42 | 43 | // Called from main scheduler thread when all threads has created (notify about threads count) 44 | virtual void OnThreadsCreated(uint32 threadsCount) = 0; 45 | 46 | // Called from worker thread context when worker thread created 47 | virtual void OnThreadCreated(uint32 workerIndex) = 0; 48 | 49 | // Called from worker thread context when worker thread started 50 | virtual void OnThreadStarted(uint32 workerIndex) = 0; 51 | 52 | // Called from worker thread context when worker thread stopped 53 | virtual void OnThreadStoped(uint32 workerIndex) = 0; 54 | 55 | // Called from worker thread context when worker thread start to idle 56 | virtual void OnThreadIdleStarted(uint32 workerIndex) = 0; 57 | 58 | // Called from worker thread context when worker thread return to work from idle 59 | virtual void OnThreadIdleFinished(uint32 workerIndex) = 0; 60 | 61 | // Called from thread when thread is waiting for group 62 | virtual void OnThreadWaitStarted() = 0; 63 | 64 | // Called from thread when thread is finished waiting for group 65 | virtual void OnThreadWaitFinished() = 0; 66 | 67 | // Called from thread when waiting thread temporary convert to worker 68 | virtual void OnTemporaryWorkerThreadJoin() = 0; 69 | 70 | // Called from thread when temporary worker leave 71 | virtual void OnTemporaryWorkerThreadLeave() = 0; 72 | 73 | // Called from the worker thread that has change the task execution state 74 | virtual void OnTaskExecuteStateChanged(MT::Color::Type debugColor, const mt_char* debugID, TaskExecuteState::Type type, int32 fiberIndex) = 0; 75 | }; 76 | 77 | } 78 | 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Scheduler/Include/MTStackRequirements.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | 26 | namespace MT 27 | { 28 | namespace StackRequirements 29 | { 30 | enum Type 31 | { 32 | INVALID, 33 | 34 | STANDARD, 35 | EXTENDED 36 | }; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Scheduler/Include/MTTaskBucket.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | namespace MT 31 | { 32 | namespace internal 33 | { 34 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 | struct TaskBucket 36 | { 37 | GroupedTask* tasks; 38 | size_t count; 39 | TaskBucket(GroupedTask* _tasks, size_t _count) 40 | : tasks(_tasks) 41 | , count(_count) 42 | { 43 | } 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Scheduler/Include/MTTaskGroup.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | 26 | namespace MT 27 | { 28 | //Task group ID 29 | class TaskGroup 30 | { 31 | int16 id; 32 | 33 | public: 34 | 35 | static const int16 MT_MAX_GROUPS_COUNT = 256; 36 | 37 | enum PredefinedValues 38 | { 39 | DEFAULT = 0, 40 | INVALID = -1, 41 | ASSIGN_FROM_CONTEXT = -2 42 | }; 43 | 44 | 45 | TaskGroup() 46 | { 47 | id = INVALID; 48 | } 49 | 50 | explicit TaskGroup(PredefinedValues v) 51 | { 52 | id = (int16)v; 53 | } 54 | 55 | explicit TaskGroup(int16 _id) 56 | { 57 | id = _id; 58 | } 59 | 60 | static TaskGroup Default() 61 | { 62 | return TaskGroup(DEFAULT); 63 | } 64 | 65 | TaskGroup & operator= (const PredefinedValues & v) 66 | { 67 | id = (int16)v; 68 | return *this; 69 | } 70 | 71 | bool operator== (const PredefinedValues & v) const 72 | { 73 | return (id == v); 74 | } 75 | 76 | bool operator== (const TaskGroup & other) const 77 | { 78 | return (id == other.id); 79 | } 80 | 81 | bool operator!= (const TaskGroup & other) const 82 | { 83 | return (id != other.id); 84 | } 85 | 86 | int GetValidIndex() const 87 | { 88 | MT_ASSERT(IsValid(), "Try to get invalid index"); 89 | 90 | return id; 91 | } 92 | 93 | bool IsValid() const 94 | { 95 | if (id == INVALID) 96 | return false; 97 | 98 | if (id == ASSIGN_FROM_CONTEXT) 99 | return false; 100 | 101 | return (id >= 0 && id < MT_MAX_GROUPS_COUNT); 102 | } 103 | 104 | 105 | 106 | }; 107 | 108 | 109 | 110 | } 111 | -------------------------------------------------------------------------------- /Scheduler/Include/MTTools.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | #include 25 | #include 26 | 27 | namespace MT 28 | { 29 | template 30 | T Min(T a, T b) 31 | { 32 | return a < b ? a : b; 33 | } 34 | 35 | template 36 | T Max(T a, T b) 37 | { 38 | return a < b ? b : a; 39 | } 40 | 41 | template 42 | T Clamp(T val, T min, T max) 43 | { 44 | return Min(max, Max(min, val)); 45 | } 46 | 47 | 48 | ////////////////////////////////////////////////////////////////////////// 49 | class Timer 50 | { 51 | uint64 startMicroSeconds; 52 | public: 53 | Timer() : startMicroSeconds(MT::GetTimeMicroSeconds()) 54 | { 55 | } 56 | 57 | uint32 GetPastMicroSeconds() const 58 | { 59 | return (uint32)(MT::GetTimeMicroSeconds() - startMicroSeconds); 60 | } 61 | 62 | uint32 GetPastMilliSeconds() const 63 | { 64 | return (uint32)((MT::GetTimeMicroSeconds() - startMicroSeconds) / 1000); 65 | } 66 | }; 67 | 68 | 69 | 70 | //Compile time pow2 check 71 | ////////////////////////////////////////////////////////////////////////// 72 | template< size_t N, size_t C = 1 > 73 | struct IsPow2Recurse 74 | { 75 | enum 76 | { 77 | result = IsPow2Recurse< N / 2, C * 2 >::result 78 | }; 79 | }; 80 | 81 | template< size_t C > 82 | struct IsPow2Recurse< 0, C > 83 | { 84 | enum 85 | { 86 | result = C 87 | }; 88 | }; 89 | 90 | 91 | template< size_t N > 92 | struct StaticIsPow2 93 | { 94 | enum 95 | { 96 | result = IsPow2Recurse< N - 1 >::result == N ? 1 : 0 97 | }; 98 | }; 99 | 100 | 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /Scheduler/Include/MTTypes.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | 28 | #define MT_USED_IN_ASSERT(x) (void)(x) 29 | 30 | #define MT_UNUSED(x) (void)(x) 31 | 32 | #define MT_NOCOPYABLE(TYPE) \ 33 | private: \ 34 | TYPE (const TYPE &); \ 35 | void operator= (const TYPE &); \ 36 | public: \ 37 | 38 | 39 | 40 | #ifdef MT_UNICODE 41 | 42 | typedef wchar_t mt_char; 43 | #define MT_TEXT(quote) L##quote 44 | 45 | #else 46 | 47 | typedef char mt_char; 48 | #define MT_TEXT(quote) quote 49 | 50 | #endif 51 | 52 | 53 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 54 | typedef signed char int8; 55 | typedef unsigned char uint8; 56 | typedef unsigned char byte; 57 | typedef int16_t int16; 58 | typedef uint16_t uint16; 59 | typedef int32_t int32; 60 | typedef uint32_t uint32; 61 | 62 | 63 | #if MT_MSVC_COMPILER_FAMILY 64 | 65 | typedef __int64 int64; 66 | typedef unsigned __int64 uint64; 67 | 68 | #elif MT_GCC_COMPILER_FAMILY 69 | 70 | typedef int64_t int64; 71 | typedef uint64_t uint64; 72 | 73 | #else 74 | 75 | #error Compiler is not supported 76 | 77 | #endif 78 | 79 | 80 | 81 | static_assert( sizeof(int8) == 1, "Invalid type size, int8" ); 82 | static_assert( sizeof(uint8) == 1, "Invalid type size, uint8" ); 83 | static_assert( sizeof(byte) == 1, "Invalid type size, byte" ); 84 | static_assert( sizeof(int16) == 2, "Invalid type size, int16" ); 85 | static_assert( sizeof(uint16) == 2, "Invalid type size, uint16" ); 86 | static_assert( sizeof(int32) == 4, "Invalid type size, int32" ); 87 | static_assert( sizeof(uint32) == 4, "Invalid type size, uint32" ); 88 | static_assert( sizeof(int64) == 8, "Invalid type size, int64" ); 89 | static_assert( sizeof(uint64) == 8, "Invalid type size, uint64" ); 90 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Common/MTAtomic.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | #if MT_MSVC_COMPILER_FAMILY 28 | #include 29 | #elif MT_PLATFORM_POSIX || MT_PLATFORM_OSX 30 | #include 31 | #else 32 | #endif 33 | 34 | 35 | 36 | namespace MT 37 | { 38 | inline bool IsPointerAligned( const volatile void* p, const uint32 align ) 39 | { 40 | return !((uintptr_t)p & (align - 1)); 41 | } 42 | 43 | 44 | // 45 | // Atomic int (type with constructor) 46 | // 47 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 48 | template 49 | class Atomic32 : public Atomic32Base 50 | { 51 | 52 | public: 53 | 54 | Atomic32() 55 | { 56 | static_assert(sizeof(Atomic32) == sizeof(T), "Invalid atomic type size"); 57 | MT_ASSERT(IsPointerAligned(this, __alignof(T)), "Invalid atomic alignment"); 58 | 59 | Atomic32Base::Store(0); 60 | } 61 | 62 | explicit Atomic32(T v) 63 | { 64 | static_assert(sizeof(Atomic32) == sizeof(T), "Invalid atomic type size"); 65 | MT_ASSERT(IsPointerAligned(this, __alignof(T)), "Invalid atomic alignment"); 66 | 67 | Atomic32Base::Store(v); 68 | } 69 | }; 70 | 71 | 72 | // 73 | // Atomic pointer (type with constructor) 74 | // 75 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 76 | template 77 | class AtomicPtr : public AtomicPtrBase 78 | { 79 | public: 80 | AtomicPtr() 81 | { 82 | static_assert(sizeof(AtomicPtr) == sizeof(T*), "Invalid atomic type size"); 83 | MT_ASSERT(IsPointerAligned(this, sizeof(T*)), "Invalid atomic ptr alignment"); 84 | 85 | AtomicPtrBase::Store(nullptr); 86 | } 87 | 88 | explicit AtomicPtr(T* v) 89 | { 90 | static_assert(sizeof(AtomicPtr) == sizeof(T*), "Invalid atomic type size"); 91 | MT_ASSERT(IsPointerAligned(this, sizeof(T*)), "Invalid atomic ptr alignment"); 92 | 93 | AtomicPtrBase::Store(v); 94 | } 95 | 96 | }; 97 | } -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Common/MTThread.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #define MT_CPUCORE_ANY (0xffffffff) 26 | 27 | #include 28 | 29 | namespace MT 30 | { 31 | namespace ThreadPriority 32 | { 33 | enum Type 34 | { 35 | HIGH = 0, 36 | DEFAULT = 1, 37 | LOW = 2 38 | }; 39 | } 40 | 41 | 42 | class ThreadBase 43 | { 44 | protected: 45 | void * funcData; 46 | TThreadEntryPoint func; 47 | public: 48 | 49 | MT_NOCOPYABLE(ThreadBase); 50 | 51 | ThreadBase() 52 | : funcData(nullptr) 53 | , func(nullptr) 54 | { 55 | } 56 | 57 | }; 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Posix/MTCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __MT_COMMON__ 4 | #define __MT_COMMON__ 5 | 6 | #include "MTUtils.h" 7 | #include "MTThread.h" 8 | #include "MTMutex.h" 9 | #include "MTAtomic.h" 10 | #include "MTEvent.h" 11 | #include "MTFiber.h" 12 | #include "MTMemory.h" 13 | 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Posix/MTMemory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __MT_MEMORY__ 4 | #define __MT_MEMORY__ 5 | 6 | 7 | #include 8 | 9 | #define MT_ALLOCATE_ON_STACK(BYTES_COUNT) alloca(BYTES_COUNT) 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Posix/MTMutex.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #ifndef __MT_MUTEX__ 26 | #define __MT_MUTEX__ 27 | 28 | #include 29 | 30 | 31 | namespace MT 32 | { 33 | class ScopedGuard; 34 | 35 | // 36 | // 37 | // 38 | class Mutex 39 | { 40 | pthread_mutexattr_t mutexAttr; 41 | pthread_mutex_t mutex; 42 | 43 | public: 44 | 45 | MT_NOCOPYABLE(Mutex); 46 | 47 | Mutex() 48 | { 49 | int res = pthread_mutexattr_init(&mutexAttr); 50 | MT_USED_IN_ASSERT(res); 51 | MT_ASSERT(res == 0, "pthread_mutexattr_init - failed"); 52 | 53 | res = pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE); 54 | MT_USED_IN_ASSERT(res); 55 | MT_ASSERT(res == 0, "pthread_mutexattr_settype - failed"); 56 | 57 | res = pthread_mutex_init(&mutex, &mutexAttr); 58 | MT_USED_IN_ASSERT(res); 59 | MT_ASSERT(res == 0, "pthread_mutex_init - failed"); 60 | } 61 | 62 | ~Mutex() 63 | { 64 | int res = pthread_mutex_destroy(&mutex); 65 | MT_USED_IN_ASSERT(res); 66 | MT_ASSERT(res == 0, "pthread_mutex_destroy - failed"); 67 | 68 | res = pthread_mutexattr_destroy(&mutexAttr); 69 | MT_USED_IN_ASSERT(res); 70 | MT_ASSERT(res == 0, "pthread_mutexattr_destroy - failed"); 71 | } 72 | 73 | friend class MT::ScopedGuard; 74 | 75 | private: 76 | 77 | void Lock() 78 | { 79 | int res = pthread_mutex_lock(&mutex); 80 | MT_USED_IN_ASSERT(res); 81 | MT_ASSERT(res == 0, "pthread_mutex_lock - failed"); 82 | } 83 | void Unlock() 84 | { 85 | int res = pthread_mutex_unlock(&mutex); 86 | MT_USED_IN_ASSERT(res); 87 | MT_ASSERT(res == 0, "pthread_mutex_unlock - failed"); 88 | } 89 | 90 | }; 91 | 92 | 93 | } 94 | 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Posix/MTUtils.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #ifndef __MT_UTILS__ 26 | #define __MT_UTILS__ 27 | 28 | 29 | #include 30 | 31 | namespace MT 32 | { 33 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | __inline int64 GetTimeMicroSeconds() 35 | { 36 | struct timeval te; 37 | gettimeofday(&te, nullptr); 38 | return te.tv_sec * 1000000LL + te.tv_usec; 39 | } 40 | 41 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 42 | __inline int64 GetTimeMilliSeconds() 43 | { 44 | return GetTimeMicroSeconds() / 1000; 45 | } 46 | 47 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 48 | __inline int64 GetHighFrequencyTime() 49 | { 50 | return GetTimeMicroSeconds(); 51 | } 52 | 53 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 54 | __inline int64 GetFrequency() 55 | { 56 | return 1000000; 57 | } 58 | 59 | } 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __MT_COMMON__ 4 | #define __MT_COMMON__ 5 | 6 | 7 | #include "MTAtomic.h" 8 | 9 | #include "MicroWindows.h" 10 | 11 | #include "MTUtils.h" 12 | #include "MTThread.h" 13 | #include "MTMutex.h" 14 | #include "MTEvent.h" 15 | #include "MTFiber.h" 16 | #include "MTMemory.h" 17 | 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTEvent.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #ifndef __MT_EVENT__ 26 | #define __MT_EVENT__ 27 | 28 | #include 29 | 30 | 31 | 32 | #if MT_ENABLE_LEGACY_WINDOWSXP_SUPPORT 33 | // Windows XP: Conditional variables are not supported. Using kernel mode events. 34 | #include "MTEventKernel.h" 35 | #else 36 | // Conditional variables are supported. Using user mode events. 37 | #include "MTEventUser.h" 38 | #endif 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTEventKernel.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #ifndef __MT_EVENT_KERNEL__ 26 | #define __MT_EVENT_KERNEL__ 27 | 28 | 29 | namespace MT 30 | { 31 | // 32 | // 33 | // 34 | class Event 35 | { 36 | ::MW_HANDLE eventHandle; 37 | 38 | public: 39 | 40 | MT_NOCOPYABLE(Event); 41 | 42 | Event() 43 | { 44 | static_assert(sizeof(Event) == sizeof(::MW_HANDLE), "sizeof(Event) is invalid"); 45 | eventHandle = nullptr; 46 | } 47 | 48 | Event(EventReset::Type resetType, bool initialState) 49 | { 50 | eventHandle = nullptr; 51 | Create(resetType, initialState); 52 | } 53 | 54 | ~Event() 55 | { 56 | CloseHandle(eventHandle); 57 | eventHandle = nullptr; 58 | } 59 | 60 | void Create(EventReset::Type resetType, bool initialState) 61 | { 62 | if (eventHandle != nullptr) 63 | { 64 | CloseHandle(eventHandle); 65 | } 66 | 67 | MW_BOOL bManualReset = (resetType == EventReset::AUTOMATIC) ? 0 : 1; 68 | MW_BOOL bInitialState = initialState ? 1 : 0; 69 | eventHandle = ::CreateEventW(nullptr, bManualReset, bInitialState, nullptr); 70 | } 71 | 72 | void Signal() 73 | { 74 | SetEvent(eventHandle); 75 | } 76 | 77 | void Reset() 78 | { 79 | ResetEvent(eventHandle); 80 | } 81 | 82 | bool Wait(uint32 milliseconds) 83 | { 84 | MW_DWORD res = WaitForSingleObject(eventHandle, milliseconds); 85 | return (res == MW_WAIT_OBJECT_0); 86 | } 87 | 88 | }; 89 | 90 | } 91 | 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTFiber.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | #ifndef __MT_FIBER__ 26 | #define __MT_FIBER__ 27 | 28 | #include 29 | 30 | 31 | #if MT_PTR64 32 | 33 | #define ReadTeb(offset) __readgsqword(offset); 34 | #define WriteTeb(offset, v) __writegsqword(offset, v) 35 | 36 | #else 37 | 38 | #define ReadTeb(offset) __readfsdword(offset); 39 | #define WriteTeb(offset, v) __writefsdword(offset, v) 40 | 41 | #endif 42 | 43 | 44 | #include "MTFiberOptimized.h" 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTMemory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef __MT_MEMORY__ 4 | #define __MT_MEMORY__ 5 | 6 | #define MT_ALLOCATE_ON_STACK(BYTES_COUNT) _alloca(BYTES_COUNT) 7 | 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTMutex.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | #pragma once 23 | 24 | #ifndef __MT_MUTEX__ 25 | #define __MT_MUTEX__ 26 | 27 | 28 | namespace MT 29 | { 30 | class ScopedGuard; 31 | 32 | // 33 | // 34 | // 35 | class Mutex 36 | { 37 | ::MW_CRITICAL_SECTION criticalSection; 38 | 39 | public: 40 | 41 | MT_NOCOPYABLE(Mutex); 42 | 43 | Mutex() 44 | { 45 | ::InitializeCriticalSectionAndSpinCount( &criticalSection, 16 ); 46 | } 47 | 48 | ~Mutex() 49 | { 50 | ::DeleteCriticalSection( &criticalSection ); 51 | } 52 | 53 | friend class MT::ScopedGuard; 54 | 55 | private: 56 | 57 | void Lock() 58 | { 59 | ::EnterCriticalSection( &criticalSection ); 60 | } 61 | void Unlock() 62 | { 63 | ::LeaveCriticalSection( &criticalSection ); 64 | } 65 | 66 | }; 67 | 68 | 69 | } 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /Scheduler/Include/Platform/Windows/MTUtils.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | #pragma once 23 | 24 | #ifndef __MT_UTILS__ 25 | #define __MT_UTILS__ 26 | 27 | namespace MT 28 | { 29 | 30 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 31 | inline int64 GetHighFrequencyTime() 32 | { 33 | MW_LARGE_INTEGER largeInteger; 34 | QueryPerformanceCounter( &largeInteger ); 35 | return largeInteger.QuadPart; 36 | } 37 | 38 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 39 | inline int64 GetFrequency() 40 | { 41 | MW_LARGE_INTEGER frequency; 42 | QueryPerformanceFrequency(&frequency); 43 | return frequency.QuadPart; 44 | } 45 | 46 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 47 | inline int64 GetTimeMilliSeconds() 48 | { 49 | MW_LARGE_INTEGER largeInteger; 50 | QueryPerformanceCounter( &largeInteger ); 51 | return ( largeInteger.QuadPart * int64(1000) ) / GetFrequency(); 52 | } 53 | 54 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 55 | inline int64 GetTimeMicroSeconds() 56 | { 57 | MW_LARGE_INTEGER largeInteger; 58 | QueryPerformanceCounter( &largeInteger ); 59 | return ( largeInteger.QuadPart * int64(1000000) ) / GetFrequency(); 60 | } 61 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 62 | } 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /SchedulerTests/Profiler/Profiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Additional Include Directories and Additional Library Directories must be configured to Brofiler 4 | //#define MT_ENABLE_BROFILER_SUPPORT (1) 5 | 6 | #if defined(MT_INSTRUMENTED_BUILD) && defined(MT_ENABLE_BROFILER_SUPPORT) 7 | #include 8 | 9 | #define BROFILER_NEXT_FRAME() Brofiler::NextFrame(); \ 10 | BROFILER_EVENT("Frame") \ 11 | 12 | 13 | #else 14 | #define PROFILE 15 | #define BROFILER_INLINE_EVENT(NAME, CODE) { CODE; } 16 | #define BROFILER_CATEGORY(NAME, COLOR) 17 | #define BROFILER_FRAME(NAME) 18 | #define BROFILER_THREAD(FRAME_NAME) 19 | #define BROFILER_NEXT_FRAME() 20 | #endif 21 | 22 | 23 | namespace MT 24 | { 25 | class IProfilerEventListener; 26 | } 27 | 28 | 29 | MT::IProfilerEventListener* GetProfiler(); 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /SchedulerTests/Tests/CleanupTests.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #include "Tests.h" 24 | #include 25 | #include 26 | 27 | 28 | SUITE(CleanupTests) 29 | { 30 | 31 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 32 | struct NotFinishedTaskDestroy 33 | { 34 | MT_DECLARE_TASK(NotFinishedTaskDestroy, MT::StackRequirements::STANDARD, MT::TaskPriority::NORMAL, MT::Color::Blue); 35 | 36 | void Do(MT::FiberContext&) 37 | { 38 | MT::SpinSleepMilliSeconds(4); 39 | } 40 | }; 41 | 42 | // Checks one simple task 43 | TEST(NotFinishedTaskDestroy) 44 | { 45 | MT::TaskScheduler scheduler; 46 | 47 | NotFinishedTaskDestroy tasks[1024]; 48 | 49 | scheduler.RunAsync(MT::TaskGroup::Default(), &tasks[0], MT_ARRAY_SIZE(tasks)); 50 | 51 | CHECK(!scheduler.WaitAll(3)); 52 | } 53 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 54 | } 55 | -------------------------------------------------------------------------------- /SchedulerTests/Tests/LenaDxt/HeaderDDS.h: -------------------------------------------------------------------------------- 1 | /* Contents of file dds_header */ 2 | const unsigned char ddsHeader[128] = { 3 | 0x44, 0x44, 0x53, 0x20, 0x7C, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 4 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 8 | 0x04, 0x00, 0x00, 0x00, 0x44, 0x58, 0x54, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /SchedulerTests/Tests/Tests.cpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #include "Tests.h" 24 | #include 25 | 26 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 27 | 28 | int Tests::RunAll() 29 | { 30 | return UnitTest::RunAllTests(); 31 | } 32 | -------------------------------------------------------------------------------- /SchedulerTests/Tests/Tests.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #pragma once 24 | 25 | namespace Tests 26 | { 27 | int RunAll(); 28 | } -------------------------------------------------------------------------------- /StripNdaCode.cmd: -------------------------------------------------------------------------------- 1 | rd /Q /S "./VisualStudio" 2 | rd /Q /S "./Scheduler/Include/Platform/Orbis" 3 | del /S *.cxx 4 | sunifdef.exe --replace --recurse --filter cpp,h,inl --discard drop --undef MT_PLATFORM_DURANGO --undef MT_PLATFORM_ORBIS --undef _XBOX_ONE --undef __ORBIS__ ./Scheduler 5 | sunifdef.exe --replace --recurse --filter cpp,h,inl --discard drop --undef MT_PLATFORM_DURANGO --undef MT_PLATFORM_ORBIS --undef _XBOX_ONE --undef __ORBIS__ ./SchedulerTests -------------------------------------------------------------------------------- /TaskScheduler.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/LICENSE_1_0.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/jump_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 28 | * ------------------------------------------------- * 29 | * | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | | * 33 | * ------------------------------------------------- * 34 | * | 0x60| 0x64| | * 35 | * ------------------------------------------------- * 36 | * | lr | pc | | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl jump_fcontext 43 | .align 2 44 | .type jump_fcontext,%function 45 | jump_fcontext: 46 | @ save LR as PC 47 | push {lr} 48 | @ save V1-V8,LR 49 | push {v1-v8,lr} 50 | 51 | @ prepare stack for FPU 52 | sub sp, sp, #64 53 | 54 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 55 | @ test if fpu env should be preserved 56 | cmp a4, #0 57 | beq 1f 58 | 59 | @ save S16-S31 60 | vstmia sp, {d8-d15} 61 | 62 | 1: 63 | #endif 64 | 65 | @ store RSP (pointing to context-data) in A1 66 | str sp, [a1] 67 | 68 | @ restore RSP (pointing to context-data) from A2 69 | mov sp, a2 70 | 71 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 72 | @ test if fpu env should be preserved 73 | cmp a4, #0 74 | beq 2f 75 | 76 | @ restore S16-S31 77 | vldmia sp, {d8-d15} 78 | 2: 79 | #endif 80 | 81 | @ prepare stack for FPU 82 | add sp, sp, #64 83 | 84 | @ use third arg as return value after jump 85 | @ and as first arg in context function 86 | mov a1, a3 87 | 88 | @ restore v1-V8,LR,PC 89 | pop {v1-v8,lr,pc} 90 | .size jump_fcontext,.-jump_fcontext 91 | 92 | @ Mark that we don't need executable stack. 93 | .section .note.GNU-stack,"",%progbits 94 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/jump_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "jump_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "jump_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "jump_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "jump_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/jump_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | EXIT | * 16 | * ---------------------------------------------------------------------------------- * 17 | * * 18 | ****************************************************************************************/ 19 | 20 | .text 21 | .globl jump_fcontext 22 | .align 2 23 | .type jump_fcontext,@function 24 | jump_fcontext: 25 | /* fourth arg of jump_fcontext() == flag indicating preserving FPU */ 26 | movl 0x10(%esp), %ecx 27 | 28 | pushl %ebp /* save EBP */ 29 | pushl %ebx /* save EBX */ 30 | pushl %esi /* save ESI */ 31 | pushl %edi /* save EDI */ 32 | 33 | /* prepare stack for FPU */ 34 | leal -0x8(%esp), %esp 35 | 36 | /* test for flag preserve_fpu */ 37 | test %ecx, %ecx 38 | je 1f 39 | 40 | /* save MMX control- and status-word */ 41 | stmxcsr (%esp) 42 | /* save x87 control-word */ 43 | fnstcw 0x4(%esp) 44 | 45 | 1: 46 | /* first arg of jump_fcontext() == context jumping from */ 47 | movl 0x1c(%esp), %eax 48 | 49 | /* store ESP (pointing to context-data) in EAX */ 50 | movl %esp, (%eax) 51 | 52 | /* second arg of jump_fcontext() == context jumping to */ 53 | movl 0x20(%esp), %edx 54 | 55 | /* third arg of jump_fcontext() == value to be returned after jump */ 56 | movl 0x24(%esp), %eax 57 | 58 | /* restore ESP (pointing to context-data) from EDX */ 59 | movl %edx, %esp 60 | 61 | /* test for flag preserve_fpu */ 62 | test %ecx, %ecx 63 | je 2f 64 | 65 | /* restore MMX control- and status-word */ 66 | ldmxcsr (%esp) 67 | /* restore x87 control-word */ 68 | fldcw 0x4(%esp) 69 | 2: 70 | /* prepare stack for FPU */ 71 | leal 0x8(%esp), %esp 72 | 73 | popl %edi /* restore EDI */ 74 | popl %esi /* restore ESI */ 75 | popl %ebx /* restore EBX */ 76 | popl %ebp /* restore EBP */ 77 | 78 | /* restore return-address */ 79 | popl %edx 80 | 81 | /* use value in EAX as return-value after jump */ 82 | /* use value in EAX as first arg in context function */ 83 | movl %eax, 0x4(%esp) 84 | 85 | /* indirect jump to context */ 86 | jmp *%edx 87 | .size jump_fcontext,.-jump_fcontext 88 | 89 | /* Mark that we don't need executable stack. */ 90 | .section .note.GNU-stack,"",%progbits 91 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/jump_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | EXIT | * 16 | * ---------------------------------------------------------------------------------- * 17 | * * 18 | ****************************************************************************************/ 19 | 20 | .text 21 | .globl _jump_fcontext 22 | .align 2 23 | _jump_fcontext: 24 | /* fourth arg of jump_fcontext() == flag indicating preserving FPU */ 25 | movl 0x10(%esp), %ecx 26 | 27 | pushl %ebp /* save EBP */ 28 | pushl %ebx /* save EBX */ 29 | pushl %esi /* save ESI */ 30 | pushl %edi /* save EDI */ 31 | 32 | /* prepare stack for FPU */ 33 | leal -0x8(%esp), %esp 34 | 35 | /* test for flag preserve_fpu */ 36 | test %ecx, %ecx 37 | je 1f 38 | 39 | /* save MMX control- and status-word */ 40 | stmxcsr (%esp) 41 | /* save x87 control-word */ 42 | fnstcw 0x4(%esp) 43 | 44 | 1: 45 | /* first arg of jump_fcontext() == context jumping from */ 46 | movl 0x1c(%esp), %eax 47 | 48 | /* store ESP (pointing to context-data) in EAX */ 49 | movl %esp, (%eax) 50 | 51 | /* second arg of jump_fcontext() == context jumping to */ 52 | movl 0x20(%esp), %edx 53 | 54 | /* third arg of jump_fcontext() == value to be returned after jump */ 55 | movl 0x24(%esp), %eax 56 | 57 | /* restore ESP (pointing to context-data) from EDX */ 58 | movl %edx, %esp 59 | 60 | /* test for flag preserve_fpu */ 61 | test %ecx, %ecx 62 | je 2f 63 | 64 | /* restore MMX control- and status-word */ 65 | ldmxcsr (%esp) 66 | /* restore x87 control-word */ 67 | fldcw 0x4(%esp) 68 | 2: 69 | /* prepare stack for FPU */ 70 | leal 0x8(%esp), %esp 71 | 72 | popl %edi /* restore EDI */ 73 | popl %esi /* restore ESI */ 74 | popl %ebx /* restore EBX */ 75 | popl %ebp /* restore EBP */ 76 | 77 | /* restore return-address */ 78 | popl %edx 79 | 80 | /* use value in EAX as return-value after jump */ 81 | /* use value in EAX as first arg in context function */ 82 | movl %eax, 0x4(%esp) 83 | 84 | /* indirect jump to context */ 85 | jmp *%edx 86 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/jump_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "jump_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "jump_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/jump_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "jump_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "jump_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 28 | * ------------------------------------------------- * 29 | * | v1 | v2 | v3 | v4 | v5 | v6 | v7 | v8 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | | * 33 | * ------------------------------------------------- * 34 | * | 0x60| 0x64| | * 35 | * ------------------------------------------------- * 36 | * | lr | pc | | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl make_fcontext 43 | .align 2 44 | .type make_fcontext,%function 45 | make_fcontext: 46 | @ shift address in A1 to lower 16 byte boundary 47 | bic a1, a1, #15 48 | 49 | @ reserve space for context-data on context-stack 50 | sub a1, a1, #104 51 | 52 | @ third arg of make_fcontext() == address of context-function 53 | str a3, [a1,#100] 54 | 55 | @ compute abs address of label finish 56 | adr a2, finish 57 | @ save address of finish as return-address for context-function 58 | @ will be entered after context-function returns 59 | str a2, [a1,#96] 60 | 61 | bx lr @ return pointer to context-data 62 | 63 | finish: 64 | @ exit code is zero 65 | mov a1, #0 66 | @ exit application 67 | bl _exit@PLT 68 | .size make_fcontext,.-make_fcontext 69 | 70 | @ Mark that we don't need executable stack. 71 | .section .note.GNU-stack,"",%progbits 72 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_arm_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 28 | * ------------------------------------------------- * 29 | * | sjlj| v1 | v2 | v3 | v4 | v5 | v6 | v7 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | | * 33 | * ------------------------------------------------- * 34 | * | 0x60| 0x64| 0x68| | * 35 | * ------------------------------------------------- * 36 | * | v8 | lr | pc | | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl _make_fcontext 43 | .align 2 44 | _make_fcontext: 45 | @ shift address in A1 to lower 16 byte boundary 46 | bic a1, a1, #15 47 | 48 | @ reserve space for context-data on context-stack 49 | sub a1, a1, #108 50 | 51 | @ third arg of make_fcontext() == address of context-function 52 | str a3, [a1,#104] 53 | 54 | @ compute abs address of label finish 55 | adr a2, finish 56 | @ save address of finish as return-address for context-function 57 | @ will be entered after context-function returns 58 | str a2, [a1,#100] 59 | 60 | bx lr @ return pointer to context-data 61 | 62 | finish: 63 | @ exit code is zero 64 | mov a1, #0 65 | @ exit application 66 | bl __exit 67 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "make_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "make_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "make_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "make_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | EXIT | * 16 | * ---------------------------------------------------------------------------------- * 17 | * * 18 | ****************************************************************************************/ 19 | 20 | .text 21 | .globl make_fcontext 22 | .align 2 23 | .type make_fcontext,@function 24 | make_fcontext: 25 | /* first arg of make_fcontext() == top of context-stack */ 26 | movl 0x4(%esp), %eax 27 | 28 | /* reserve space for first argument of context-function 29 | rax might already point to a 16byte border */ 30 | leal -0x8(%eax), %eax 31 | 32 | /* shift address in EAX to lower 16 byte boundary */ 33 | andl $-16, %eax 34 | 35 | /* reserve space for context-data on context-stack */ 36 | /* size for fc_mxcsr .. EIP + return-address for context-function */ 37 | /* on context-function entry: (ESP -0x4) % 8 == 0 */ 38 | leal -0x20(%eax), %eax 39 | 40 | /* third arg of make_fcontext() == address of context-function */ 41 | movl 0xc(%esp), %edx 42 | movl %edx, 0x18(%eax) 43 | 44 | /* save MMX control- and status-word */ 45 | stmxcsr (%eax) 46 | /* save x87 control-word */ 47 | fnstcw 0x4(%eax) 48 | 49 | /* compute abs address of label finish */ 50 | call 1f 51 | /* address of label 1 */ 52 | 1: popl %ecx 53 | /* compute abs address of label finish */ 54 | addl $finish-1b, %ecx 55 | /* save address of finish as return-address for context-function */ 56 | /* will be entered after context-function returns */ 57 | movl %ecx, 0x1c(%eax) 58 | 59 | ret /* return pointer to context-data */ 60 | 61 | finish: 62 | call 2f 63 | /* address of label 2 */ 64 | 2: popl %ebx 65 | /* compute address of GOT and store it in EBX */ 66 | addl $_GLOBAL_OFFSET_TABLE_+[.-2b], %ebx 67 | 68 | /* exit code is zero */ 69 | xorl %eax, %eax 70 | movl %eax, (%esp) 71 | /* exit application */ 72 | call _exit@PLT 73 | hlt 74 | .size make_fcontext,.-make_fcontext 75 | 76 | /* Mark that we don't need executable stack. */ 77 | .section .note.GNU-stack,"",%progbits 78 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | EXIT | * 16 | * ---------------------------------------------------------------------------------- * 17 | * * 18 | ****************************************************************************************/ 19 | 20 | .text 21 | .globl _make_fcontext 22 | .align 2 23 | _make_fcontext: 24 | /* first arg of make_fcontext() == top of context-stack */ 25 | movl 0x4(%esp), %eax 26 | 27 | /* reserve space for first argument of context-function 28 | rax might already point to a 16byte border */ 29 | leal -0x8(%eax), %eax 30 | 31 | /* shift address in EAX to lower 16 byte boundary */ 32 | andl $-16, %eax 33 | 34 | /* reserve space for context-data on context-stack */ 35 | /* size for fc_mxcsr .. EIP + return-address for context-function */ 36 | /* on context-function entry: (ESP -0x4) % 8 == 0 */ 37 | leal -0x20(%eax), %eax 38 | 39 | /* thrid arg of make_fcontext() == address of context-function */ 40 | movl 0xc(%esp), %edx 41 | movl %edx, 0x18(%eax) 42 | 43 | /* save MMX control- and status-word */ 44 | stmxcsr (%eax) 45 | /* save x87 control-word */ 46 | fnstcw 0x4(%eax) 47 | 48 | /* compute abs address of label finish */ 49 | call 1f 50 | /* address of label 1 */ 51 | 1: popl %ecx 52 | /* compute abs address of label finish */ 53 | addl $finish-1b, %ecx 54 | /* save address of finish as return-address for context-function */ 55 | /* will be entered after context-function returns */ 56 | movl %ecx, 0x1c(%eax) 57 | 58 | ret /* return pointer to context-data */ 59 | 60 | finish: 61 | /* exit code is zero */ 62 | xorl %eax, %eax 63 | movl %eax, (%esp) 64 | /* exit application */ 65 | call __exit 66 | hlt 67 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "make_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "make_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_mips32_o32_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F20 | F22 | F24 | F26 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F28 | F30 | S0 | S1 | S2 | S3 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | | * 28 | * ------------------------------------------------- * 29 | * | S4 | S5 | S6 | S7 | FP | RA | PC | | * 30 | * ------------------------------------------------- * 31 | * * 32 | * *****************************************************/ 33 | 34 | .text 35 | .globl make_fcontext 36 | .align 2 37 | .type make_fcontext,@function 38 | .ent make_fcontext 39 | make_fcontext: 40 | #ifdef __PIC__ 41 | .set noreorder 42 | .cpload $t9 43 | .set reorder 44 | #endif 45 | # first arg of make_fcontext() == top address of context-stack 46 | move $v0, $a0 47 | 48 | # shift address in A0 to lower 16 byte boundary 49 | move $v1, $v0 50 | li $v0, -16 # 0xfffffffffffffff0 51 | and $v0, $v1, $v0 52 | 53 | # reserve space for context-data on context-stack 54 | # including 48 byte of shadow space (sp % 16 == 0) 55 | addiu $v0, $v0, -140 56 | 57 | # third arg of make_fcontext() == address of context-function 58 | sw $a2, 88($v0) 59 | # save global pointer in context-data 60 | # S0 will contain address of global pointer 61 | sw $gp, 48($v0) 62 | 63 | # compute abs address of label finish 64 | la $t9, finish 65 | # save address of finish as return-address for context-function 66 | # will be entered after context-function returns 67 | sw $t9, 84($v0) 68 | 69 | jr $ra # return pointer to context-data 70 | 71 | finish: 72 | # allocate stack space (contains shadow space for subroutines) 73 | addiu $sp, $sp, -32 74 | # save return address 75 | sw $ra, 28($sp) 76 | 77 | # restore GP (global pointer) 78 | move $gp, $s0 79 | # exit code is zero 80 | move $a0, $zero 81 | # address of exit 82 | lw $t9, %call16(_exit)($gp) 83 | # exit application 84 | jalr $t9 85 | .end make_fcontext 86 | .size make_fcontext, .-make_fcontext 87 | 88 | /* Mark that we don't need executable stack. */ 89 | .section .note.GNU-stack,"",%progbits 90 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "make_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "make_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_ppc32_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl make_fcontext[DS] 2 | .globl .make_fcontext[PR] 3 | .align 2 4 | .csect make_fcontext[DS] 5 | make_fcontext: 6 | .long .make_fcontext[PR] 7 | .csect .make_fcontext[PR], 3 8 | #.make_fcontext: 9 | # save return address into R6 10 | mflr 6 11 | 12 | # first arg of make_fcontext() == top address of context-function 13 | # shift address in R3 to lower 16 byte boundary 14 | clrrwi 3, 3, 4 15 | 16 | # reserve space for context-data on context-stack 17 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 18 | subi 3, 3, 304 19 | 20 | # third arg of make_fcontext() == address of context-function 21 | stw 5, 236(3) 22 | 23 | # load LR 24 | mflr 0 25 | # jump to label 1 26 | bl .Label 27 | .Label: 28 | # load LR into R4 29 | mflr 4 30 | # compute abs address of label .L_finish 31 | addi 4, 4, .L_finish - .Label 32 | # restore LR 33 | mtlr 0 34 | # save address of finish as return-address for context-function 35 | # will be entered after context-function returns 36 | stw 4, 232(3) 37 | 38 | # restore return address from R6 39 | mtlr 6 40 | 41 | blr # return pointer to context-data 42 | 43 | .L_finish: 44 | # save return address into R0 45 | mflr 0 46 | # save return address on stack, set up stack frame 47 | stw 0, 4(1) 48 | # allocate stack space, R1 % 16 == 0 49 | stwu 1, -16(1) 50 | 51 | # exit code is zero 52 | li 3, 0 53 | # exit application 54 | bl ._exit 55 | nop 56 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/asm/make_ppc64_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl make_fcontext[DS] 2 | .globl .make_fcontext[PR] 3 | .align 2 4 | .csect .make_fcontext[PR], 3 5 | .globl _make_fcontext 6 | #._make_fcontext: 7 | # save return address into R6 8 | mflr 6 9 | 10 | # first arg of make_fcontext() == top address of context-function 11 | # shift address in R3 to lower 16 byte boundary 12 | clrrwi 3, 3, 4 13 | 14 | # reserve space for context-data on context-stack 15 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 16 | subi 3, 3, 392 17 | 18 | # third arg of make_fcontext() == address of context-function 19 | stw 5, 320(3) 20 | 21 | # load LR 22 | mflr 0 23 | # jump to label 1 24 | bl .Label 25 | .Label: 26 | # load LR into R4 27 | mflr 4 28 | # compute abs address of label .L_finish 29 | addi 4, 4, .L_finish - .Label 30 | # restore LR 31 | mtlr 0 32 | # save address of finish as return-address for context-function 33 | # will be entered after context-function returns 34 | stw 4, 312(3) 35 | 36 | # restore return address from R6 37 | mtlr 6 38 | 39 | blr # return pointer to context-data 40 | 41 | .L_finish: 42 | # save return address into R0 43 | mflr 0 44 | # save return address on stack, set up stack frame 45 | stw 0, 8(1) 46 | # allocate stack space, R1 % 16 == 0 47 | stwu 1, -32(1) 48 | 49 | # exit code is zero 50 | li 3, 0 51 | # exit application 52 | bl ._exit 53 | nop 54 | -------------------------------------------------------------------------------- /ThirdParty/Boost.Context/fcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Richard Maxwell 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | */ 22 | 23 | #ifndef FCONTEXT_H 24 | #define FCONTEXT_H 25 | 26 | #include 27 | // intptr_t 28 | 29 | #include 30 | // size_t 31 | 32 | // ----------------------------------------------------------------------------- 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | // ----------------------------------------------------------------------------- 37 | 38 | typedef void* fcontext_t; 39 | 40 | intptr_t jump_fcontext 41 | ( 42 | fcontext_t* ofc 43 | , fcontext_t nfc 44 | , intptr_t vp 45 | , int preserve_fpu 46 | ); 47 | 48 | fcontext_t make_fcontext 49 | ( 50 | void* sp 51 | , size_t size 52 | , void (*fn)(intptr_t) 53 | ); 54 | // sp is the pointer to the _top_ of the stack (ie &stack_buffer[size]). 55 | 56 | // ----------------------------------------------------------------------------- 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | // ----------------------------------------------------------------------------- 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /ThirdParty/Squish/ChangeLog: -------------------------------------------------------------------------------- 1 | 1.10 2 | * Iterative cluster fit is now considered to be a new compression mode 3 | * The core cluster fit is now 4x faster using contributions by Ignacio 4 | Castano from NVIDIA 5 | * The single colour lookup table has been halved by exploiting symmetry 6 | 7 | 1.9 8 | * Added contributed SSE1 truncate implementation 9 | * Changed use of SQUISH_USE_SSE to be 1 for SSE and 2 for SSE2 instructions 10 | * Cluster fit is now iterative to further reduce image error 11 | 12 | 1.8 13 | * Switched from using floor to trunc for much better SSE performance (again) 14 | * Xcode build now expects libpng in /usr/local for extra/squishpng 15 | 16 | 1.7 17 | * Fixed floating-point equality issue in clusterfit sort (x86 affected only) 18 | * Implemented proper SSE(2) floor function for 50% speedup on SSE builds 19 | * The range fit implementation now uses the correct colour metric 20 | 21 | 1.6 22 | * Fixed bug in CompressImage where masked pixels were not skipped over 23 | * DXT3 and DXT5 alpha compression now properly use the mask to ignore pixels 24 | * Fixed major DXT1 bug that can generate unexpected transparent pixels 25 | 26 | 1.5 27 | * Added CompressMasked function to handle incomplete DXT blocks more cleanly 28 | * Added kWeightColourByAlpha flag for better quality images when alpha blending 29 | 30 | 1.4 31 | * Fixed stack overflow in rangefit 32 | 33 | 1.3 34 | * Worked around SSE floor implementation bug, proper fix needed! 35 | * This release has visual studio and makefile builds that work 36 | 37 | 1.2 38 | * Added provably optimal single colour compressor 39 | * Added extra/squishgen.cpp that generates single colour lookup tables 40 | 41 | 1.1 42 | * Fixed a DXT1 colour output bug 43 | * Changed argument order for Decompress function to match Compress 44 | * Added GetStorageRequirements function 45 | * Added CompressImage function 46 | * Added DecompressImage function 47 | * Moved squishtool.cpp to extra/squishpng.cpp 48 | * Added extra/squishtest.cpp 49 | 50 | 1.0 51 | * Initial release 52 | 53 | -------------------------------------------------------------------------------- /ThirdParty/Squish/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include config 3 | 4 | SRC = alpha.cpp clusterfit.cpp colourblock.cpp colourfit.cpp colourset.cpp maths.cpp rangefit.cpp singlecolourfit.cpp squish.cpp 5 | 6 | OBJ = $(SRC:%.cpp=%.o) 7 | 8 | LIB = libsquish.a 9 | 10 | all : $(LIB) 11 | 12 | install : $(LIB) 13 | install squish.h $(INSTALL_DIR)/include 14 | install libsquish.a $(INSTALL_DIR)/lib 15 | 16 | uninstall: 17 | $(RM) $(INSTALL_DIR)/include/squish.h 18 | $(RM) $(INSTALL_DIR)/lib/libsquish.a 19 | 20 | $(LIB) : $(OBJ) 21 | $(AR) cr $@ $? 22 | ranlib $@ 23 | 24 | %.o : %.cpp 25 | $(CXX) $(CPPFLAGS) -I. $(CXXFLAGS) -o$@ -c $< 26 | 27 | clean : 28 | $(RM) $(OBJ) $(LIB) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ThirdParty/Squish/README: -------------------------------------------------------------------------------- 1 | LICENSE 2 | ------- 3 | 4 | The squish library is distributed under the terms and conditions of the MIT 5 | license. This license is specified at the top of each source file and must be 6 | preserved in its entirety. 7 | 8 | BUILDING AND INSTALLING THE LIBRARY 9 | ----------------------------------- 10 | 11 | If you are using Visual Studio 2003 or above under Windows then load the Visual 12 | Studio 2003 project in the vs7 folder. By default, the library is built using 13 | SSE2 optimisations. To change this either change or remove the SQUISH_USE_SSE=2 14 | from the preprocessor symbols. 15 | 16 | If you are using a Mac then load the Xcode 2.2 project in the distribution. By 17 | default, the library is built using Altivec optimisations. To change this 18 | either change or remove SQUISH_USE_ALTIVEC=1 from the preprocessor symbols. I 19 | guess I'll have to think about changing this for the new Intel Macs that are 20 | rolling out... 21 | 22 | If you are using unix then first edit the config file in the base directory of 23 | the distribution, enabling Altivec or SSE with the USE_ALTIVEC or USE_SSE 24 | variables, and editing the optimisation flags passed to the C++ compiler if 25 | necessary. Then make can be used to build the library, and make install (from 26 | the superuser account) can be used to install (into /usr/local by default). 27 | 28 | REPORTING BUGS OR FEATURE REQUESTS 29 | ---------------------------------- 30 | 31 | Feedback can be sent to Simon Brown (the developer) at si@sjbrown.co.uk 32 | 33 | New releases are announced on the squish library homepage at 34 | http://sjbrown.co.uk/?code=squish 35 | 36 | -------------------------------------------------------------------------------- /ThirdParty/Squish/alpha.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_ALPHA_H 27 | #define SQUISH_ALPHA_H 28 | 29 | #include 30 | 31 | namespace squish { 32 | 33 | void CompressAlphaDxt3( u8 const* rgba, int mask, void* block ); 34 | void CompressAlphaDxt5( u8 const* rgba, int mask, void* block ); 35 | 36 | void DecompressAlphaDxt3( u8* rgba, void const* block ); 37 | void DecompressAlphaDxt5( u8* rgba, void const* block ); 38 | 39 | } // namespace squish 40 | 41 | #endif // ndef SQUISH_ALPHA_H 42 | -------------------------------------------------------------------------------- /ThirdParty/Squish/clusterfit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | Copyright (c) 2007 Ignacio Castano icastano@nvidia.com 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | -------------------------------------------------------------------------- */ 26 | 27 | #ifndef SQUISH_CLUSTERFIT_H 28 | #define SQUISH_CLUSTERFIT_H 29 | 30 | #include 31 | #include "maths.h" 32 | #include "simd.h" 33 | #include "colourfit.h" 34 | 35 | namespace squish { 36 | 37 | class ClusterFit : public ColourFit 38 | { 39 | public: 40 | ClusterFit( ColourSet const* colours, int flags ); 41 | 42 | private: 43 | bool ConstructOrdering( Vec3 const& axis, int iteration ); 44 | 45 | virtual void Compress3( void* block ); 46 | virtual void Compress4( void* block ); 47 | 48 | enum { kMaxIterations = 8 }; 49 | 50 | int m_iterationCount; 51 | Vec3 m_principle; 52 | u8 m_order[16*kMaxIterations]; 53 | Vec4 m_points_weights[16]; 54 | Vec4 m_xsum_wsum; 55 | Vec4 m_metric; 56 | Vec4 m_besterror; 57 | }; 58 | 59 | } // namespace squish 60 | 61 | #endif // ndef SQUISH_CLUSTERFIT_H 62 | -------------------------------------------------------------------------------- /ThirdParty/Squish/colourblock.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_COLOURBLOCK_H 27 | #define SQUISH_COLOURBLOCK_H 28 | 29 | #include 30 | #include "maths.h" 31 | 32 | namespace squish { 33 | 34 | void WriteColourBlock3( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); 35 | void WriteColourBlock4( Vec3::Arg start, Vec3::Arg end, u8 const* indices, void* block ); 36 | 37 | void DecompressColour( u8* rgba, void const* block, bool isDxt1 ); 38 | 39 | } // namespace squish 40 | 41 | #endif // ndef SQUISH_COLOURBLOCK_H 42 | -------------------------------------------------------------------------------- /ThirdParty/Squish/colourfit.cpp: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #include "colourfit.h" 27 | #include "colourset.h" 28 | 29 | namespace squish { 30 | 31 | ColourFit::ColourFit( ColourSet const* colours, int flags ) 32 | : m_colours( colours ), 33 | m_flags( flags ) 34 | { 35 | } 36 | 37 | void ColourFit::Compress( void* block ) 38 | { 39 | bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 ); 40 | if( isDxt1 ) 41 | { 42 | Compress3( block ); 43 | if( !m_colours->IsTransparent() ) 44 | Compress4( block ); 45 | } 46 | else 47 | Compress4( block ); 48 | } 49 | 50 | } // namespace squish 51 | -------------------------------------------------------------------------------- /ThirdParty/Squish/colourfit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_COLOURFIT_H 27 | #define SQUISH_COLOURFIT_H 28 | 29 | #include 30 | #include "maths.h" 31 | 32 | namespace squish { 33 | 34 | class ColourSet; 35 | 36 | class ColourFit 37 | { 38 | public: 39 | ColourFit( ColourSet const* colours, int flags ); 40 | 41 | void Compress( void* block ); 42 | 43 | protected: 44 | virtual void Compress3( void* block ) = 0; 45 | virtual void Compress4( void* block ) = 0; 46 | 47 | ColourSet const* m_colours; 48 | int m_flags; 49 | }; 50 | 51 | } // namespace squish 52 | 53 | #endif // ndef SQUISH_COLOURFIT_H 54 | -------------------------------------------------------------------------------- /ThirdParty/Squish/colourset.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_COLOURSET_H 27 | #define SQUISH_COLOURSET_H 28 | 29 | #include 30 | #include "maths.h" 31 | 32 | namespace squish { 33 | 34 | /*! @brief Represents a set of block colours 35 | */ 36 | class ColourSet 37 | { 38 | public: 39 | ColourSet( u8 const* rgba, int mask, int flags ); 40 | 41 | int GetCount() const { return m_count; } 42 | Vec3 const* GetPoints() const { return m_points; } 43 | float const* GetWeights() const { return m_weights; } 44 | bool IsTransparent() const { return m_transparent; } 45 | 46 | void RemapIndices( u8 const* source, u8* target ) const; 47 | 48 | private: 49 | int m_count; 50 | Vec3 m_points[16]; 51 | float m_weights[16]; 52 | int m_remap[16]; 53 | bool m_transparent; 54 | }; 55 | 56 | } // namespace sqish 57 | 58 | #endif // ndef SQUISH_COLOURSET_H 59 | -------------------------------------------------------------------------------- /ThirdParty/Squish/config: -------------------------------------------------------------------------------- 1 | # config file used for the Makefile only 2 | 3 | # define to 1 to use Altivec instructions 4 | USE_ALTIVEC ?= 0 5 | 6 | # define to 1 to use SSE2 instructions 7 | USE_SSE ?= 0 8 | 9 | # default flags 10 | CXXFLAGS ?= -O2 11 | ifeq ($(USE_ALTIVEC),1) 12 | CPPFLAGS += -DSQUISH_USE_ALTIVEC=1 13 | CXXFLAGS += -maltivec 14 | endif 15 | ifeq ($(USE_SSE),1) 16 | CPPFLAGS += -DSQUISH_USE_SSE=2 17 | CXXFLAGS += -msse 18 | endif 19 | 20 | # where should we install to 21 | INSTALL_DIR ?= /usr/local 22 | 23 | -------------------------------------------------------------------------------- /ThirdParty/Squish/config.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_CONFIG_H 27 | #define SQUISH_CONFIG_H 28 | 29 | // Set to 1 when building squish to use Altivec instructions. 30 | #ifndef SQUISH_USE_ALTIVEC 31 | #define SQUISH_USE_ALTIVEC 0 32 | #endif 33 | 34 | // Set to 1 or 2 when building squish to use SSE or SSE2 instructions. 35 | #ifndef SQUISH_USE_SSE 36 | #define SQUISH_USE_SSE 0 37 | #endif 38 | 39 | // Internally et SQUISH_USE_SIMD when either Altivec or SSE is available. 40 | #if SQUISH_USE_ALTIVEC && SQUISH_USE_SSE 41 | #error "Cannot enable both Altivec and SSE!" 42 | #endif 43 | #if SQUISH_USE_ALTIVEC || SQUISH_USE_SSE 44 | #define SQUISH_USE_SIMD 1 45 | #else 46 | #define SQUISH_USE_SIMD 0 47 | #endif 48 | 49 | #endif // ndef SQUISH_CONFIG_H 50 | -------------------------------------------------------------------------------- /ThirdParty/Squish/rangefit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_RANGEFIT_H 27 | #define SQUISH_RANGEFIT_H 28 | 29 | #include 30 | #include "colourfit.h" 31 | #include "maths.h" 32 | 33 | namespace squish { 34 | 35 | class ColourSet; 36 | 37 | class RangeFit : public ColourFit 38 | { 39 | public: 40 | RangeFit( ColourSet const* colours, int flags ); 41 | 42 | private: 43 | virtual void Compress3( void* block ); 44 | virtual void Compress4( void* block ); 45 | 46 | Vec3 m_metric; 47 | Vec3 m_start; 48 | Vec3 m_end; 49 | float m_besterror; 50 | }; 51 | 52 | } // squish 53 | 54 | #endif // ndef SQUISH_RANGEFIT_H 55 | -------------------------------------------------------------------------------- /ThirdParty/Squish/simd.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SIMD_H 27 | #define SQUISH_SIMD_H 28 | 29 | #include "maths.h" 30 | 31 | #if SQUISH_USE_ALTIVEC 32 | #include "simd_ve.h" 33 | #elif SQUISH_USE_SSE 34 | #include "simd_sse.h" 35 | #else 36 | #include "simd_float.h" 37 | #endif 38 | 39 | 40 | #endif // ndef SQUISH_SIMD_H 41 | -------------------------------------------------------------------------------- /ThirdParty/Squish/singlecolourfit.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | 3 | Copyright (c) 2006 Simon Brown si@sjbrown.co.uk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------- */ 25 | 26 | #ifndef SQUISH_SINGLECOLOURFIT_H 27 | #define SQUISH_SINGLECOLOURFIT_H 28 | 29 | #include 30 | #include "colourfit.h" 31 | 32 | namespace squish { 33 | 34 | class ColourSet; 35 | struct SingleColourLookup; 36 | 37 | class SingleColourFit : public ColourFit 38 | { 39 | public: 40 | SingleColourFit( ColourSet const* colours, int flags ); 41 | 42 | private: 43 | virtual void Compress3( void* block ); 44 | virtual void Compress4( void* block ); 45 | 46 | void ComputeEndPoints( SingleColourLookup const* const* lookups ); 47 | 48 | u8 m_colour[3]; 49 | Vec3 m_start; 50 | Vec3 m_end; 51 | u8 m_index; 52 | int m_error; 53 | int m_besterror; 54 | }; 55 | 56 | } // namespace squish 57 | 58 | #endif // ndef SQUISH_SINGLECOLOURFIT_H 59 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.h text 4 | *.cpp text 5 | 6 | # VS 20xx files 7 | *.sln text eol=crlf 8 | *.vcproj text eol=crlf 9 | *.vcxproj text eol=crlf 10 | *.vcxproj.filters text eol=crlf 11 | 12 | # VC6 files 13 | *.dsw text eol=crlf 14 | *.dsp text eol=crlf 15 | 16 | # Other 'windows-specific' files 17 | *.bat text eol=crlf -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *.lo 4 | *.la 5 | 6 | # Visual Studio temp/user files 7 | *.user 8 | *.suo 9 | *.sdf 10 | *.opensdf 11 | *.ncb 12 | 13 | # Build output directories 14 | Release 15 | Debug 16 | MinSizeRel 17 | RelWithDebInfo 18 | ipch 19 | 20 | # files generated by autotools 21 | /aclocal.m4 22 | /autom4te.cache 23 | /config.guess 24 | /config.h 25 | /config.h.in 26 | /config.status 27 | /config.sub 28 | /configure 29 | /depcomp 30 | /install-sh 31 | /libtool 32 | /ltmain.sh 33 | /m4 34 | /missing 35 | /stamp-h* 36 | /test-driver 37 | /UnitTest++/TestUnitTest++ 38 | Makefile 39 | Makefile.in 40 | .deps 41 | .libs 42 | *.log 43 | *.trs 44 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs"] 2 | path = docs 3 | url = https://github.com/unittest-cpp/unittest-cpp.wiki.git 4 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/AUTHORS: -------------------------------------------------------------------------------- 1 | See README.md for the historic contributor list. 2 | 3 | The maintainer of UnitTest++ is Patrick Johnmeyer (pjohnmeyer@gmail.com). 4 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.1) 2 | project(UnitTest++) 3 | 4 | option(UTPP_USE_PLUS_SIGN "Set this to OFF is you with to use '-cpp' instead of '++' in lib/include paths" ON) 5 | 6 | # get the main sources 7 | file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h) 8 | file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp) 9 | source_group("" FILES ${headers_} ${sources_}) 10 | 11 | # get platform specific sources 12 | if (WIN32) 13 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 14 | set(platformDir_ Win32) 15 | else() 16 | set(platformDir_ Posix) 17 | endif(WIN32) 18 | 19 | file(GLOB platformHeaders_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.h) 20 | file(GLOB platformSources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.cpp) 21 | source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_}) 22 | 23 | # create the lib 24 | add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_}) 25 | 26 | if(${UTPP_USE_PLUS_SIGN}) 27 | set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++) 28 | endif() 29 | 30 | 31 | # build the test runner 32 | file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h) 33 | source_group( "" FILES ${TEST_SRCS}) 34 | add_executable(TestUnitTest++ ${TEST_SRCS}) 35 | include_directories(.) 36 | 37 | if(${UTPP_USE_PLUS_SIGN}) 38 | set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++) 39 | endif() 40 | 41 | target_link_libraries(TestUnitTest++ UnitTest++) 42 | 43 | # turn on testing 44 | enable_testing() 45 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V) 46 | 47 | # add the test runner as a test 48 | add_test(NAME TestUnitTest++ COMMAND TestUnitTest++ ${CONFIG_PATH} ${CONFIG_TASKS_PATH} ${SOUND_LOG_PATH}) 49 | add_dependencies(check TestUnitTest++) 50 | 51 | 52 | # add install targets 53 | # need a custom install path? 54 | # define CMAKE_INSTALL_PREFIX to change root folder 55 | if(${UTPP_USE_PLUS_SIGN}) 56 | set (UTPP_INSTALL_DESTINATION "include/UnitTest++") 57 | else() 58 | set (UTPP_INSTALL_DESTINATION "include/UnitTestPP") 59 | endif() 60 | 61 | install(TARGETS UnitTest++ DESTINATION lib) 62 | install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION}) 63 | install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_}) -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SergeyMakeev/TaskScheduler/2b9bbb88dfa47e1541368368c320aac6c516a99b/ThirdParty/UnitTest++/ChangeLog -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006 Noel Llopis and Charles Nicholson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | EXTRA_DIST = docs 3 | SUBDIRS = UnitTest++ 4 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/AssertException.cpp: -------------------------------------------------------------------------------- 1 | #include "AssertException.h" 2 | 3 | #ifndef UNITTEST_NO_EXCEPTIONS 4 | 5 | namespace UnitTest { 6 | 7 | AssertException::AssertException() 8 | { 9 | } 10 | 11 | AssertException::~AssertException() throw() 12 | { 13 | } 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/AssertException.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_ASSERTEXCEPTION_H 2 | #define UNITTEST_ASSERTEXCEPTION_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_EXCEPTIONS 6 | 7 | #include "HelperMacros.h" 8 | #include 9 | 10 | namespace UnitTest { 11 | 12 | class UNITTEST_LINKAGE AssertException : public std::exception 13 | { 14 | public: 15 | AssertException(); 16 | virtual ~AssertException() throw(); 17 | }; 18 | 19 | } 20 | 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Checks.cpp: -------------------------------------------------------------------------------- 1 | #include "Checks.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | namespace { 7 | 8 | void CheckStringsEqual(TestResults& results, char const* expected, char const* actual, 9 | TestDetails const& details) 10 | { 11 | using namespace std; 12 | 13 | if ((expected && actual) ? strcmp(expected, actual) : (expected || actual)) 14 | { 15 | UnitTest::MemoryOutStream stream; 16 | stream << "Expected " << (expected ? expected : "") << " but was " << (actual ? actual : ""); 17 | 18 | results.OnTestFailure(details, stream.GetText()); 19 | } 20 | } 21 | 22 | } 23 | 24 | 25 | void CheckEqual(TestResults& results, char const* expected, char const* actual, 26 | TestDetails const& details) 27 | { 28 | CheckStringsEqual(results, expected, actual, details); 29 | } 30 | 31 | void CheckEqual(TestResults& results, char* expected, char* actual, 32 | TestDetails const& details) 33 | { 34 | CheckStringsEqual(results, expected, actual, details); 35 | } 36 | 37 | void CheckEqual(TestResults& results, char* expected, char const* actual, 38 | TestDetails const& details) 39 | { 40 | CheckStringsEqual(results, expected, actual, details); 41 | } 42 | 43 | void CheckEqual(TestResults& results, char const* expected, char* actual, 44 | TestDetails const& details) 45 | { 46 | CheckStringsEqual(results, expected, actual, details); 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/CompositeTestReporter.cpp: -------------------------------------------------------------------------------- 1 | #include "CompositeTestReporter.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | CompositeTestReporter::CompositeTestReporter() 7 | : m_reporterCount(0) 8 | { 9 | } 10 | 11 | int CompositeTestReporter::GetReporterCount() const 12 | { 13 | return m_reporterCount; 14 | } 15 | 16 | bool CompositeTestReporter::AddReporter(TestReporter* reporter) 17 | { 18 | if (m_reporterCount == kMaxReporters) 19 | return false; 20 | 21 | m_reporters[m_reporterCount++] = reporter; 22 | return true; 23 | } 24 | 25 | bool CompositeTestReporter::RemoveReporter(TestReporter* reporter) 26 | { 27 | for (int index = 0; index < m_reporterCount; ++index) 28 | { 29 | if (m_reporters[index] == reporter) 30 | { 31 | m_reporters[index] = m_reporters[m_reporterCount - 1]; 32 | --m_reporterCount; 33 | return true; 34 | } 35 | } 36 | 37 | return false; 38 | } 39 | 40 | void CompositeTestReporter::ReportFailure(TestDetails const& details, char const* failure) 41 | { 42 | for (int index = 0; index < m_reporterCount; ++index) 43 | m_reporters[index]->ReportFailure(details, failure); 44 | } 45 | 46 | void CompositeTestReporter::ReportTestStart(TestDetails const& test) 47 | { 48 | for (int index = 0; index < m_reporterCount; ++index) 49 | m_reporters[index]->ReportTestStart(test); 50 | } 51 | 52 | void CompositeTestReporter::ReportTestFinish(TestDetails const& test, float secondsElapsed) 53 | { 54 | for (int index = 0; index < m_reporterCount; ++index) 55 | m_reporters[index]->ReportTestFinish(test, secondsElapsed); 56 | } 57 | 58 | void CompositeTestReporter::ReportSummary(int totalTestCount, 59 | int failedTestCount, 60 | int failureCount, 61 | float secondsElapsed) 62 | { 63 | for (int index = 0; index < m_reporterCount; ++index) 64 | m_reporters[index]->ReportSummary(totalTestCount, failedTestCount, failureCount, secondsElapsed); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/CompositeTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_COMPOSITETESTREPORTER_H 2 | #define UNITTEST_COMPOSITETESTREPORTER_H 3 | 4 | #include "TestReporter.h" 5 | 6 | namespace UnitTest { 7 | 8 | class UNITTEST_LINKAGE CompositeTestReporter : public TestReporter 9 | { 10 | public: 11 | CompositeTestReporter(); 12 | 13 | int GetReporterCount() const; 14 | bool AddReporter(TestReporter* reporter); 15 | bool RemoveReporter(TestReporter* reporter); 16 | 17 | virtual void ReportTestStart(TestDetails const& test); 18 | virtual void ReportFailure(TestDetails const& test, char const* failure); 19 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); 20 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 21 | 22 | private: 23 | enum { kMaxReporters = 16 }; 24 | TestReporter* m_reporters[kMaxReporters]; 25 | int m_reporterCount; 26 | 27 | // revoked 28 | CompositeTestReporter(const CompositeTestReporter&); 29 | CompositeTestReporter& operator =(const CompositeTestReporter&); 30 | }; 31 | 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Config.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_CONFIG_H 2 | #define UNITTEST_CONFIG_H 3 | 4 | // Standard defines documented here: http://predef.sourceforge.net 5 | 6 | #if defined(_MSC_VER) 7 | #ifndef _CRT_SECURE_NO_WARNINGS 8 | #define _CRT_SECURE_NO_WARNINGS 9 | #endif 10 | #pragma warning(disable:4702) // unreachable code 11 | #pragma warning(disable:4722) // destructor never returns, potential memory leak 12 | 13 | #if (_MSC_VER == 1200) // VC6 14 | #define UNITTEST_COMPILER_IS_MSVC6 15 | #pragma warning(disable:4786) 16 | #pragma warning(disable:4290) 17 | #endif 18 | 19 | #ifdef _USRDLL 20 | #define UNITTEST_WIN32_DLL 21 | #endif 22 | #define UNITTEST_WIN32 23 | #endif 24 | 25 | #if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \ 26 | defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) 27 | #define UNITTEST_POSIX 28 | #endif 29 | 30 | #if defined(__MINGW32__) 31 | #define UNITTEST_MINGW 32 | #endif 33 | 34 | 35 | // By default, MemoryOutStream is implemented in terms of std::ostringstream. 36 | // This is useful if you are using the CHECK macros on objects that have something like this defined: 37 | // std::ostringstream& operator<<(std::ostringstream& s, const YourObject& value) 38 | // 39 | // On the other hand, it can be more expensive. 40 | // Un-comment this line to use the custom MemoryOutStream (no deps on std::ostringstream). 41 | 42 | // #define UNITTEST_USE_CUSTOM_STREAMS 43 | 44 | // Developer note: This dual-macro setup is to preserve compatibility with UnitTest++ 1.4 users 45 | // who may have used or defined UNITTEST_USE_CUSTOM_STREAMS outside of this configuration file, as 46 | // well as Google Code HEAD users that may have used or defined 47 | // UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM outside of this configuration file. 48 | #ifndef UNITTEST_USE_CUSTOM_STREAMS 49 | #define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM 50 | #endif 51 | 52 | // DeferredTestReporter uses the STL to collect test results for subsequent export by reporters like 53 | // XmlTestReporter. If you don't want to use this functionality, uncomment this line and no STL 54 | // headers or code will be compiled into UnitTest++ 55 | 56 | //#define UNITTEST_NO_DEFERRED_REPORTER 57 | 58 | 59 | // By default, asserts that you report via UnitTest::ReportAssert() abort the current test and 60 | // continue to the next one by throwing an exception, which unwinds the stack naturally, destroying 61 | // all auto variables on its way back down. If you don't want to (or can't) use exceptions for your 62 | // platform/compiler, uncomment this line. All exception code will be removed from UnitTest++, 63 | // assert recovery will be done via setjmp/longjmp, and NO correct stack unwinding will happen! 64 | 65 | #define UNITTEST_NO_EXCEPTIONS 66 | 67 | 68 | // std namespace qualification: used for functions like strcpy that 69 | // may live in std:: namespace (cstring header). 70 | #if defined( UNITTEST_COMPILER_IS_MSVC6 ) 71 | #define UNIITEST_NS_QUAL_STD(x) x 72 | #else 73 | #define UNIITEST_NS_QUAL_STD(x) ::std::x 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/CurrentTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CurrentTest.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | UNITTEST_LINKAGE TestResults*& CurrentTest::Results() 7 | { 8 | static TestResults* testResults = NULL; 9 | return testResults; 10 | } 11 | 12 | UNITTEST_LINKAGE const TestDetails*& CurrentTest::Details() 13 | { 14 | static const TestDetails* testDetails = NULL; 15 | return testDetails; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/CurrentTest.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_CURRENTTESTRESULTS_H 2 | #define UNITTEST_CURRENTTESTRESULTS_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestResults; 9 | class TestDetails; 10 | 11 | namespace CurrentTest 12 | { 13 | UNITTEST_LINKAGE TestResults*& Results(); 14 | UNITTEST_LINKAGE const TestDetails*& Details(); 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/DeferredTestReporter.cpp: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 3 | 4 | #include "DeferredTestReporter.h" 5 | #include "TestDetails.h" 6 | 7 | using namespace UnitTest; 8 | 9 | void DeferredTestReporter::ReportTestStart(TestDetails const& details) 10 | { 11 | m_results.push_back(DeferredTestResult(details.suiteName, details.testName)); 12 | } 13 | 14 | void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure) 15 | { 16 | DeferredTestResult& r = m_results.back(); 17 | r.failed = true; 18 | r.failures.push_back(DeferredTestFailure(details.lineNumber, failure)); 19 | r.failureFile = details.filename; 20 | } 21 | 22 | void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed) 23 | { 24 | DeferredTestResult& r = m_results.back(); 25 | r.timeElapsed = secondsElapsed; 26 | } 27 | 28 | DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults() 29 | { 30 | return m_results; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/DeferredTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_DEFERREDTESTREPORTER_H 2 | #define UNITTEST_DEFERREDTESTREPORTER_H 3 | 4 | #include "Config.h" 5 | 6 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 7 | 8 | #include "TestReporter.h" 9 | #include "DeferredTestResult.h" 10 | 11 | #include 12 | 13 | UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestResult); 14 | 15 | namespace UnitTest 16 | { 17 | 18 | class UNITTEST_LINKAGE DeferredTestReporter : public TestReporter 19 | { 20 | public: 21 | virtual void ReportTestStart(TestDetails const& details); 22 | virtual void ReportFailure(TestDetails const& details, char const* failure); 23 | virtual void ReportTestFinish(TestDetails const& details, float secondsElapsed); 24 | 25 | typedef std::vector< DeferredTestResult > DeferredTestResultList; 26 | DeferredTestResultList& GetResults(); 27 | 28 | private: 29 | DeferredTestResultList m_results; 30 | }; 31 | 32 | } 33 | 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/DeferredTestResult.cpp: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 3 | 4 | #include "DeferredTestResult.h" 5 | #include 6 | 7 | namespace UnitTest 8 | { 9 | 10 | DeferredTestFailure::DeferredTestFailure() 11 | : lineNumber(-1) 12 | { 13 | failureStr[0] = '\0'; 14 | } 15 | 16 | DeferredTestFailure::DeferredTestFailure(int lineNumber_, const char* failureStr_) 17 | : lineNumber(lineNumber_) 18 | { 19 | UNIITEST_NS_QUAL_STD(strcpy)(failureStr, failureStr_); 20 | } 21 | 22 | DeferredTestResult::DeferredTestResult() 23 | : suiteName("") 24 | , testName("") 25 | , failureFile("") 26 | , timeElapsed(0.0f) 27 | , failed(false) 28 | { 29 | } 30 | 31 | DeferredTestResult::DeferredTestResult(char const* suite, char const* test) 32 | : suiteName(suite) 33 | , testName(test) 34 | , failureFile("") 35 | , timeElapsed(0.0f) 36 | , failed(false) 37 | { 38 | } 39 | 40 | DeferredTestResult::~DeferredTestResult() 41 | { 42 | } 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/DeferredTestResult.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_DEFERREDTESTRESULT_H 2 | #define UNITTEST_DEFERREDTESTRESULT_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 6 | 7 | #include "HelperMacros.h" 8 | #include 9 | #include 10 | 11 | namespace UnitTest 12 | { 13 | 14 | class UNITTEST_LINKAGE DeferredTestFailure 15 | { 16 | public: 17 | DeferredTestFailure(); 18 | DeferredTestFailure(int lineNumber_, const char* failureStr_); 19 | 20 | int lineNumber; 21 | char failureStr[1024]; 22 | }; 23 | 24 | } 25 | 26 | UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestFailure); 27 | 28 | namespace UnitTest 29 | { 30 | 31 | class UNITTEST_LINKAGE DeferredTestResult 32 | { 33 | public: 34 | DeferredTestResult(); 35 | DeferredTestResult(char const* suite, char const* test); 36 | ~DeferredTestResult(); 37 | 38 | std::string suiteName; 39 | std::string testName; 40 | std::string failureFile; 41 | 42 | typedef std::vector< DeferredTestFailure > FailureVec; 43 | FailureVec failures; 44 | 45 | float timeElapsed; 46 | bool failed; 47 | }; 48 | 49 | } 50 | 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/ExceptionMacros.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_EXCEPTIONMACROS_H 2 | #define UNITTEST_EXCEPTIONMACROS_H 3 | 4 | #include "Config.h" 5 | 6 | #ifndef UNITTEST_NO_EXCEPTIONS 7 | #define UT_TRY(x) try x 8 | #define UT_THROW(x) throw x 9 | #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody 10 | #define UT_CATCH_ALL(CatchBody) catch(...) CatchBody 11 | #else 12 | #define UT_TRY(x) x 13 | #define UT_THROW(x) 14 | #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) 15 | #define UT_CATCH_ALL(CatchBody) 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/ExecuteTest.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_EXECUTE_TEST_H 2 | #define UNITTEST_EXECUTE_TEST_H 3 | 4 | #include 5 | #include "Config.h" 6 | #include "ExceptionMacros.h" 7 | #include "TestDetails.h" 8 | #include "TestResults.h" 9 | #include "MemoryOutStream.h" 10 | #include "AssertException.h" 11 | #include "CurrentTest.h" 12 | #include "TimeHelpers.h" 13 | 14 | #ifdef UNITTEST_NO_EXCEPTIONS 15 | #include "ReportAssertImpl.h" 16 | #endif 17 | 18 | #ifdef UNITTEST_POSIX 19 | #include "Posix/SignalTranslator.h" 20 | #endif 21 | 22 | namespace UnitTest { 23 | 24 | template< typename T > 25 | void ExecuteTest(T& testObject, TestDetails const& details, bool isMockTest) 26 | { 27 | if (isMockTest == false) 28 | CurrentTest::Details() = &details; 29 | 30 | testObject.RunImpl(); 31 | } 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/HelperMacros.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_HELPERMACROS_H 2 | #define UNITTEST_HELPERMACROS_H 3 | 4 | #include "Config.h" 5 | 6 | #define UNITTEST_MULTILINE_MACRO_BEGIN do { 7 | 8 | #if defined(UNITTEST_WIN32) && !defined(UNITTEST_COMPILER_IS_MSVC6) 9 | #define UNITTEST_MULTILINE_MACRO_END \ 10 | } __pragma(warning(push)) __pragma(warning(disable:4127)) while (0) __pragma(warning(pop)) 11 | #else 12 | #define UNITTEST_MULTILINE_MACRO_END } while(0) 13 | #endif 14 | 15 | 16 | #ifdef UNITTEST_WIN32_DLL 17 | #define UNITTEST_IMPORT __declspec(dllimport) 18 | #define UNITTEST_EXPORT __declspec(dllexport) 19 | 20 | #ifdef UNITTEST_DLL_EXPORT 21 | #define UNITTEST_LINKAGE UNITTEST_EXPORT 22 | #define UNITTEST_IMPEXP_TEMPLATE 23 | #else 24 | #define UNITTEST_LINKAGE UNITTEST_IMPORT 25 | #define UNITTEST_IMPEXP_TEMPLATE extern 26 | #endif 27 | 28 | #define UNITTEST_STDVECTOR_LINKAGE(T) \ 29 | __pragma(warning(push)) \ 30 | __pragma(warning(disable:4231)) \ 31 | UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::allocator< T >; \ 32 | UNITTEST_IMPEXP_TEMPLATE template class UNITTEST_LINKAGE std::vector< T >; \ 33 | __pragma(warning(pop)) 34 | #else 35 | #define UNITTEST_IMPORT 36 | #define UNITTEST_EXPORT 37 | #define UNITTEST_LINKAGE 38 | #define UNITTEST_IMPEXP_TEMPLATE 39 | #define UNITTEST_STDVECTOR_LINKAGE(T) 40 | #endif 41 | 42 | #ifdef UNITTEST_WIN32 43 | #define UNITTEST_JMPBUF jmp_buf 44 | #define UNITTEST_SETJMP setjmp 45 | #define UNITTEST_LONGJMP longjmp 46 | #elif defined UNITTEST_POSIX 47 | #define UNITTEST_JMPBUF std::jmp_buf 48 | #define UNITTEST_SETJMP setjmp 49 | #define UNITTEST_LONGJMP std::longjmp 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libUnitTest++.la 2 | pkgincludedir = $(includedir)/UnitTest++ 3 | nobase_pkginclude_HEADERS = UnitTest++.h UnitTestPP.h Config.h HelperMacros.h Test.h TestDetails.h TestList.h TestSuite.h TestResults.h TestMacros.h CheckMacros.h TestRunner.h TimeConstraint.h ExecuteTest.h AssertException.h MemoryOutStream.h CurrentTest.h Posix/SignalTranslator.h Checks.h TimeHelpers.h Posix/TimeHelpers.h ExceptionMacros.h ReportAssert.h ReportAssertImpl.h CompositeTestReporter.h 4 | libUnitTest___la_SOURCES = AssertException.cpp Test.cpp Checks.cpp TestRunner.cpp TestResults.cpp TestReporter.cpp TestReporterStdout.cpp ReportAssert.cpp TestList.cpp TimeConstraint.cpp TestDetails.cpp MemoryOutStream.cpp DeferredTestReporter.cpp DeferredTestResult.cpp XmlTestReporter.cpp CurrentTest.cpp Posix/SignalTranslator.cpp Posix/TimeHelpers.cpp CompositeTestReporter.cpp 5 | libUnitTest___la_LDFLAGS = -version-number @LIBUNITTEST_SO_VERSION@ 6 | check_PROGRAMS = TestUnitTest++ 7 | TestUnitTest___SOURCES = $(top_srcdir)/tests/Main.cpp $(top_srcdir)/tests/TestAssertHandler.cpp $(top_srcdir)/tests/TestCheckMacros.cpp $(top_srcdir)/tests/TestChecks.cpp $(top_srcdir)/tests/TestCompositeTestReporter.cpp $(top_srcdir)/tests/TestCurrentTest.cpp $(top_srcdir)/tests/TestDeferredTestReporter.cpp $(top_srcdir)/tests/TestExceptions.cpp $(top_srcdir)/tests/TestMemoryOutStream.cpp $(top_srcdir)/tests/TestTest.cpp $(top_srcdir)/tests/TestTestList.cpp $(top_srcdir)/tests/TestTestMacros.cpp $(top_srcdir)/tests/TestTestResults.cpp $(top_srcdir)/tests/TestTestRunner.cpp $(top_srcdir)/tests/TestTestSuite.cpp $(top_srcdir)/tests/TestTimeConstraint.cpp $(top_srcdir)/tests/TestTimeConstraintMacro.cpp $(top_srcdir)/tests/TestUnitTestPP.cpp $(top_srcdir)/tests/TestXmlTestReporter.cpp 8 | TestUnitTest___LDADD = libUnitTest++.la 9 | TESTS = TestUnitTest++ 10 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/MemoryOutStream.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_MEMORYOUTSTREAM_H 2 | #define UNITTEST_MEMORYOUTSTREAM_H 3 | 4 | #include "Config.h" 5 | #include "HelperMacros.h" 6 | 7 | #ifdef UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM 8 | 9 | #include 10 | 11 | namespace UnitTest 12 | { 13 | 14 | class UNITTEST_LINKAGE MemoryOutStream : public std::ostringstream 15 | { 16 | public: 17 | MemoryOutStream() {} 18 | ~MemoryOutStream() {} 19 | void Clear(); 20 | char const* GetText() const; 21 | 22 | private: 23 | MemoryOutStream(MemoryOutStream const&); 24 | void operator =(MemoryOutStream const&); 25 | 26 | mutable std::string m_text; 27 | }; 28 | 29 | #ifdef UNITTEST_COMPILER_IS_MSVC6 30 | std::ostream& operator<<(std::ostream& stream, __int64 const n); 31 | std::ostream& operator<<(std::ostream& stream, unsigned __int64 const n); 32 | #endif 33 | 34 | } 35 | 36 | #else 37 | 38 | #include 39 | 40 | #ifdef UNITTEST_COMPILER_IS_MSVC6 41 | namespace std {} 42 | #endif 43 | 44 | namespace UnitTest 45 | { 46 | 47 | class UNITTEST_LINKAGE MemoryOutStream 48 | { 49 | public: 50 | explicit MemoryOutStream(int const size = 256); 51 | ~MemoryOutStream(); 52 | 53 | void Clear(); 54 | char const* GetText() const; 55 | 56 | MemoryOutStream& operator <<(char const* txt); 57 | MemoryOutStream& operator <<(int n); 58 | MemoryOutStream& operator <<(long n); 59 | MemoryOutStream& operator <<(unsigned long n); 60 | #ifdef UNITTEST_COMPILER_IS_MSVC6 61 | MemoryOutStream& operator <<(__int64 n); 62 | MemoryOutStream& operator <<(unsigned __int64 n); 63 | #else 64 | MemoryOutStream& operator <<(long long n); 65 | MemoryOutStream& operator <<(unsigned long long n); 66 | #endif 67 | MemoryOutStream& operator <<(float f); 68 | MemoryOutStream& operator <<(double d); 69 | MemoryOutStream& operator <<(void const* p); 70 | MemoryOutStream& operator <<(unsigned int s); 71 | 72 | enum { GROW_CHUNK_SIZE = 32 }; 73 | int GetCapacity() const; 74 | 75 | private: 76 | void operator= (MemoryOutStream const&); 77 | void GrowBuffer(int capacity); 78 | 79 | int m_capacity; 80 | char* m_buffer; 81 | }; 82 | 83 | } 84 | 85 | #endif 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Posix/SignalTranslator.cpp: -------------------------------------------------------------------------------- 1 | #include "SignalTranslator.h" 2 | 3 | 4 | namespace UnitTest { 5 | 6 | 7 | #if defined(__ORBIS__) 8 | #else 9 | 10 | sigjmp_buf* SignalTranslator::s_jumpTarget = 0; 11 | 12 | namespace { 13 | 14 | void SignalHandler(int sig) 15 | { 16 | siglongjmp(*SignalTranslator::s_jumpTarget, sig ); 17 | } 18 | 19 | } 20 | 21 | 22 | SignalTranslator::SignalTranslator() 23 | { 24 | m_oldJumpTarget = s_jumpTarget; 25 | s_jumpTarget = &m_currentJumpTarget; 26 | 27 | struct sigaction action; 28 | action.sa_flags = 0; 29 | action.sa_handler = SignalHandler; 30 | sigemptyset( &action.sa_mask ); 31 | 32 | sigaction( SIGSEGV, &action, &m_old_SIGSEGV_action ); 33 | sigaction( SIGFPE , &action, &m_old_SIGFPE_action ); 34 | sigaction( SIGTRAP, &action, &m_old_SIGTRAP_action ); 35 | sigaction( SIGBUS , &action, &m_old_SIGBUS_action ); 36 | sigaction( SIGILL , &action, &m_old_SIGBUS_action ); 37 | } 38 | 39 | SignalTranslator::~SignalTranslator() 40 | { 41 | sigaction( SIGILL , &m_old_SIGBUS_action , 0 ); 42 | sigaction( SIGBUS , &m_old_SIGBUS_action , 0 ); 43 | sigaction( SIGTRAP, &m_old_SIGTRAP_action, 0 ); 44 | sigaction( SIGFPE , &m_old_SIGFPE_action , 0 ); 45 | sigaction( SIGSEGV, &m_old_SIGSEGV_action, 0 ); 46 | 47 | s_jumpTarget = m_oldJumpTarget; 48 | } 49 | 50 | #endif 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Posix/SignalTranslator.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_SIGNALTRANSLATOR_H 2 | #define UNITTEST_SIGNALTRANSLATOR_H 3 | 4 | #if defined(__ORBIS__) 5 | 6 | 7 | #else 8 | 9 | #include 10 | #include 11 | 12 | namespace UnitTest { 13 | 14 | class SignalTranslator 15 | { 16 | public: 17 | SignalTranslator(); 18 | ~SignalTranslator(); 19 | 20 | static sigjmp_buf* s_jumpTarget; 21 | 22 | private: 23 | sigjmp_buf m_currentJumpTarget; 24 | sigjmp_buf* m_oldJumpTarget; 25 | 26 | struct sigaction m_old_SIGFPE_action; 27 | struct sigaction m_old_SIGTRAP_action; 28 | struct sigaction m_old_SIGSEGV_action; 29 | struct sigaction m_old_SIGBUS_action; 30 | //struct sigaction m_old_SIGABRT_action; 31 | //struct sigaction m_old_SIGALRM_action; 32 | }; 33 | 34 | #if !defined (__GNUC__) 35 | #define UNITTEST_EXTENSION 36 | #else 37 | #define UNITTEST_EXTENSION __extension__ 38 | #endif 39 | 40 | #define UNITTEST_THROW_SIGNALS_POSIX_ONLY \ 41 | UnitTest::SignalTranslator sig; \ 42 | if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ 43 | throw ("Unhandled system exception"); 44 | 45 | } 46 | 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Posix/TimeHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeHelpers.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | Timer::Timer() 7 | { 8 | m_startTime.tv_sec = 0; 9 | m_startTime.tv_usec = 0; 10 | } 11 | 12 | void Timer::Start() 13 | { 14 | gettimeofday(&m_startTime, 0); 15 | } 16 | 17 | double Timer::GetTimeInMs() const 18 | { 19 | struct timeval currentTime; 20 | gettimeofday(¤tTime, 0); 21 | 22 | double const dsecs = currentTime.tv_sec - m_startTime.tv_sec; 23 | double const dus = currentTime.tv_usec - m_startTime.tv_usec; 24 | 25 | return (dsecs * 1000.0) + (dus / 1000.0); 26 | } 27 | 28 | void TimeHelpers::SleepMs(int ms) 29 | { 30 | usleep(ms * 1000); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Posix/TimeHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TIMEHELPERS_H 2 | #define UNITTEST_TIMEHELPERS_H 3 | 4 | #include 5 | 6 | namespace UnitTest { 7 | 8 | class Timer 9 | { 10 | public: 11 | Timer(); 12 | void Start(); 13 | double GetTimeInMs() const; 14 | 15 | private: 16 | struct timeval m_startTime; 17 | }; 18 | 19 | 20 | namespace TimeHelpers 21 | { 22 | void SleepMs(int ms); 23 | } 24 | 25 | 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/ReportAssert.cpp: -------------------------------------------------------------------------------- 1 | #include "ReportAssert.h" 2 | #include "ReportAssertImpl.h" 3 | #include "AssertException.h" 4 | #include "CurrentTest.h" 5 | #include "TestResults.h" 6 | #include "TestDetails.h" 7 | 8 | #ifdef UNITTEST_NO_EXCEPTIONS 9 | #include "ReportAssertImpl.h" 10 | #endif 11 | 12 | namespace UnitTest { 13 | 14 | namespace 15 | { 16 | bool& AssertExpectedFlag() 17 | { 18 | static bool s_assertExpected = false; 19 | return s_assertExpected; 20 | } 21 | } 22 | 23 | UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber) 24 | { 25 | Detail::ReportAssertEx(CurrentTest::Results(), CurrentTest::Details(), 26 | description, filename, lineNumber); 27 | } 28 | 29 | namespace Detail { 30 | 31 | #ifdef UNITTEST_NO_EXCEPTIONS 32 | UNITTEST_JMPBUF* GetAssertJmpBuf() 33 | { 34 | static UNITTEST_JMPBUF s_jmpBuf; 35 | return &s_jmpBuf; 36 | } 37 | #endif 38 | 39 | UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults, 40 | const TestDetails* testDetails, 41 | char const* description, 42 | char const* filename, 43 | int lineNumber) 44 | { 45 | if (AssertExpectedFlag() == false) 46 | { 47 | TestDetails assertDetails(testDetails->testName, testDetails->suiteName, filename, lineNumber); 48 | testResults->OnTestFailure(assertDetails, description); 49 | } 50 | 51 | ExpectAssert(false); 52 | 53 | #ifndef UNITTEST_NO_EXCEPTIONS 54 | throw AssertException(); 55 | #else 56 | UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET(); 57 | #endif 58 | } 59 | 60 | UNITTEST_LINKAGE void ExpectAssert(bool expected) 61 | { 62 | AssertExpectedFlag() = expected; 63 | } 64 | 65 | UNITTEST_LINKAGE bool AssertExpected() 66 | { 67 | return AssertExpectedFlag(); 68 | } 69 | 70 | }} 71 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/ReportAssert.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_ASSERT_H 2 | #define UNITTEST_ASSERT_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber); 9 | 10 | } 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/ReportAssertImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_REPORTASSERTIMPL_H 2 | #define UNITTEST_REPORTASSERTIMPL_H 3 | 4 | #include "Config.h" 5 | #include "HelperMacros.h" 6 | 7 | #ifdef UNITTEST_NO_EXCEPTIONS 8 | #include 9 | #endif 10 | 11 | namespace UnitTest { 12 | 13 | class TestResults; 14 | class TestDetails; 15 | 16 | namespace Detail { 17 | 18 | UNITTEST_LINKAGE void ExpectAssert(bool expected); 19 | 20 | UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults, 21 | const TestDetails* testDetails, 22 | char const* description, 23 | char const* filename, 24 | int lineNumber); 25 | 26 | UNITTEST_LINKAGE bool AssertExpected(); 27 | 28 | #ifdef UNITTEST_NO_EXCEPTIONS 29 | UNITTEST_LINKAGE UNITTEST_JMPBUF* GetAssertJmpBuf(); 30 | 31 | #ifdef UNITTEST_WIN32 32 | #define UNITTEST_SET_ASSERT_JUMP_TARGET() \ 33 | __pragma(warning(push)) __pragma(warning(disable:4611)) \ 34 | UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) \ 35 | __pragma(warning(pop)) 36 | #else 37 | #define UNITTEST_SET_ASSERT_JUMP_TARGET() UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) 38 | #endif 39 | 40 | #define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), 1) 41 | #endif 42 | 43 | } 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Test.cpp: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #include "Test.h" 3 | #include "TestList.h" 4 | #include "TestResults.h" 5 | #include "AssertException.h" 6 | #include "MemoryOutStream.h" 7 | #include "ExecuteTest.h" 8 | 9 | #ifdef UNITTEST_POSIX 10 | #include "Posix/SignalTranslator.h" 11 | #endif 12 | 13 | namespace UnitTest { 14 | 15 | TestList& Test::GetTestList() 16 | { 17 | static TestList s_list; 18 | return s_list; 19 | } 20 | 21 | Test::Test(char const* testName, char const* suiteName, char const* filename, int lineNumber) 22 | : m_details(testName, suiteName, filename, lineNumber) 23 | , m_nextTest(0) 24 | , m_isMockTest(false) 25 | { 26 | } 27 | 28 | Test::~Test() 29 | { 30 | } 31 | 32 | void Test::Run() 33 | { 34 | ExecuteTest(*this, m_details, m_isMockTest); 35 | } 36 | 37 | void Test::RunImpl() const 38 | { 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Test.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TEST_H 2 | #define UNITTEST_TEST_H 3 | 4 | #include "TestDetails.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestResults; 9 | class TestList; 10 | 11 | class UNITTEST_LINKAGE Test 12 | { 13 | public: 14 | explicit Test(char const* testName, char const* suiteName = "DefaultSuite", char const* filename = "", int lineNumber = 0); 15 | virtual ~Test(); 16 | void Run(); 17 | 18 | TestDetails const m_details; 19 | Test* m_nextTest; 20 | 21 | mutable bool m_isMockTest; 22 | 23 | static TestList& GetTestList(); 24 | 25 | virtual void RunImpl() const; 26 | 27 | private: 28 | Test(Test const&); 29 | Test& operator =(Test const&); 30 | }; 31 | 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestDetails.cpp: -------------------------------------------------------------------------------- 1 | #include "TestDetails.h" 2 | 3 | namespace UnitTest { 4 | 5 | TestDetails::TestDetails(char const* testName_, char const* suiteName_, char const* filename_, int lineNumber_) 6 | : suiteName(suiteName_) 7 | , testName(testName_) 8 | , filename(filename_) 9 | , lineNumber(lineNumber_) 10 | , timeConstraintExempt(false) 11 | { 12 | } 13 | 14 | TestDetails::TestDetails(const TestDetails& details, int lineNumber_) 15 | : suiteName(details.suiteName) 16 | , testName(details.testName) 17 | , filename(details.filename) 18 | , lineNumber(lineNumber_) 19 | , timeConstraintExempt(details.timeConstraintExempt) 20 | { 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestDetails.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTDETAILS_H 2 | #define UNITTEST_TESTDETAILS_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class UNITTEST_LINKAGE TestDetails 9 | { 10 | public: 11 | TestDetails(char const* testName, char const* suiteName, char const* filename, int lineNumber); 12 | TestDetails(const TestDetails& details, int lineNumber); 13 | 14 | char const* const suiteName; 15 | char const* const testName; 16 | char const* const filename; 17 | int const lineNumber; 18 | mutable bool timeConstraintExempt; 19 | 20 | TestDetails(TestDetails const&); // Why is it public? --> http://gcc.gnu.org/bugs.html#cxx_rvalbind 21 | private: 22 | TestDetails& operator=(TestDetails const&); 23 | }; 24 | 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestList.cpp: -------------------------------------------------------------------------------- 1 | #include "TestList.h" 2 | #include "Test.h" 3 | 4 | #include 5 | 6 | namespace UnitTest { 7 | 8 | TestList::TestList() 9 | : m_head(0) 10 | , m_tail(0) 11 | { 12 | } 13 | 14 | void TestList::Add(Test* test) 15 | { 16 | if (m_tail == 0) 17 | { 18 | assert(m_head == 0); 19 | m_head = test; 20 | m_tail = test; 21 | } 22 | else 23 | { 24 | m_tail->m_nextTest = test; 25 | m_tail = test; 26 | } 27 | } 28 | 29 | Test* TestList::GetHead() const 30 | { 31 | return m_head; 32 | } 33 | 34 | ListAdder::ListAdder(TestList& list, Test* test) 35 | { 36 | list.Add(test); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestList.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTLIST_H 2 | #define UNITTEST_TESTLIST_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class Test; 9 | 10 | class UNITTEST_LINKAGE TestList 11 | { 12 | public: 13 | TestList(); 14 | void Add (Test* test); 15 | 16 | Test* GetHead() const; 17 | 18 | private: 19 | Test* m_head; 20 | Test* m_tail; 21 | }; 22 | 23 | 24 | class UNITTEST_LINKAGE ListAdder 25 | { 26 | public: 27 | ListAdder(TestList& list, Test* test); 28 | }; 29 | 30 | } 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestReporter.cpp: -------------------------------------------------------------------------------- 1 | #include "TestReporter.h" 2 | 3 | namespace UnitTest { 4 | 5 | TestReporter::~TestReporter() 6 | { 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTREPORTER_H 2 | #define UNITTEST_TESTREPORTER_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestDetails; 9 | 10 | class UNITTEST_LINKAGE TestReporter 11 | { 12 | public: 13 | virtual ~TestReporter(); 14 | 15 | virtual void ReportTestStart(TestDetails const& test) = 0; 16 | virtual void ReportFailure(TestDetails const& test, char const* failure) = 0; 17 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed) = 0; 18 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) = 0; 19 | }; 20 | 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestReporterStdout.cpp: -------------------------------------------------------------------------------- 1 | #include "TestReporterStdout.h" 2 | #include 3 | 4 | #include "TestDetails.h" 5 | 6 | #ifdef _XBOX_ONE 7 | #include 8 | #include 9 | #endif 10 | 11 | // cstdio doesn't pull in namespace std on VC6, so we do it here. 12 | #if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) 13 | namespace std {} 14 | #endif 15 | 16 | namespace UnitTest { 17 | 18 | void TestReporterStdout::ReportFailure(TestDetails const& details, char const* failure) 19 | { 20 | #ifdef _XBOX_ONE 21 | details; 22 | failure; 23 | OutputDebugStringA("Failed "); 24 | OutputDebugStringA(failure); 25 | OutputDebugStringA("\n"); 26 | //assert(false); 27 | #else 28 | 29 | using namespace std; 30 | #if defined(__APPLE__) || defined(__GNUG__) 31 | char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n"; 32 | fprintf(stderr, errorFormat, details.filename, details.lineNumber, 1, details.testName, failure); 33 | #else 34 | char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n"; 35 | fprintf(stderr, errorFormat, details.filename, details.lineNumber, details.testName, failure); 36 | #endif 37 | #endif 38 | } 39 | 40 | void TestReporterStdout::ReportTestStart(TestDetails const& details/*test*/) 41 | { 42 | #ifdef _XBOX_ONE 43 | OutputDebugStringA("\n=> Test: "); 44 | OutputDebugStringA(details.testName); 45 | OutputDebugStringA("\n"); 46 | #else 47 | printf("\n=> Test: %s\n", details.testName); 48 | #endif 49 | } 50 | 51 | void TestReporterStdout::ReportTestFinish(TestDetails const& /*test*/, float delta) 52 | { 53 | #ifdef _XBOX_ONE 54 | char msg[128]; 55 | sprintf(msg, "=> Finished in %3.2f sec\n", delta); 56 | OutputDebugStringA(msg); 57 | #else 58 | printf("=> Finished in %3.2f sec\n", delta); 59 | #endif 60 | } 61 | 62 | void TestReporterStdout::ReportSummary(int const totalTestCount, int const failedTestCount, 63 | int const failureCount, float const secondsElapsed) 64 | { 65 | using namespace std; 66 | 67 | if (failureCount > 0) 68 | printf("FAILURE: %d out of %d tests failed (%d failures).\n", failedTestCount, totalTestCount, failureCount); 69 | else 70 | printf("Success: %d tests passed.\n", totalTestCount); 71 | 72 | #ifdef _XBOX_ONE 73 | char msg[128]; 74 | sprintf(msg, "Test time: %.2f seconds.\n", secondsElapsed); 75 | OutputDebugStringA(msg); 76 | #else 77 | printf("Test time: %.2f seconds.\n", secondsElapsed); 78 | #endif 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestReporterStdout.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTREPORTERSTDOUT_H 2 | #define UNITTEST_TESTREPORTERSTDOUT_H 3 | 4 | #include "TestReporter.h" 5 | 6 | namespace UnitTest { 7 | 8 | class UNITTEST_LINKAGE TestReporterStdout : public TestReporter 9 | { 10 | private: 11 | virtual void ReportTestStart(TestDetails const& test); 12 | virtual void ReportFailure(TestDetails const& test, char const* failure); 13 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); 14 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 15 | }; 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestResults.cpp: -------------------------------------------------------------------------------- 1 | #include "TestResults.h" 2 | #include "TestReporter.h" 3 | 4 | #include "TestDetails.h" 5 | 6 | namespace UnitTest { 7 | 8 | TestResults::TestResults(TestReporter* testReporter) 9 | : m_testReporter(testReporter) 10 | , m_totalTestCount(0) 11 | , m_failedTestCount(0) 12 | , m_failureCount(0) 13 | , m_currentTestFailed(false) 14 | { 15 | } 16 | 17 | void TestResults::OnTestStart(TestDetails const& test) 18 | { 19 | ++m_totalTestCount; 20 | m_currentTestFailed = false; 21 | if (m_testReporter) 22 | m_testReporter->ReportTestStart(test); 23 | } 24 | 25 | void TestResults::OnTestFailure(TestDetails const& test, char const* failure) 26 | { 27 | ++m_failureCount; 28 | if (!m_currentTestFailed) 29 | { 30 | ++m_failedTestCount; 31 | m_currentTestFailed = true; 32 | } 33 | 34 | if (m_testReporter) 35 | m_testReporter->ReportFailure(test, failure); 36 | } 37 | 38 | void TestResults::OnTestFinish(TestDetails const& test, float secondsElapsed) 39 | { 40 | if (m_testReporter) 41 | m_testReporter->ReportTestFinish(test, secondsElapsed); 42 | } 43 | 44 | int TestResults::GetTotalTestCount() const 45 | { 46 | return m_totalTestCount; 47 | } 48 | 49 | int TestResults::GetFailedTestCount() const 50 | { 51 | return m_failedTestCount; 52 | } 53 | 54 | int TestResults::GetFailureCount() const 55 | { 56 | return m_failureCount; 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestResults.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTRESULTS_H 2 | #define UNITTEST_TESTRESULTS_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestReporter; 9 | class TestDetails; 10 | 11 | class UNITTEST_LINKAGE TestResults 12 | { 13 | public: 14 | explicit TestResults(TestReporter* reporter = 0); 15 | 16 | void OnTestStart(TestDetails const& test); 17 | void OnTestFailure(TestDetails const& test, char const* failure); 18 | void OnTestFinish(TestDetails const& test, float secondsElapsed); 19 | 20 | int GetTotalTestCount() const; 21 | int GetFailedTestCount() const; 22 | int GetFailureCount() const; 23 | 24 | private: 25 | TestReporter* m_testReporter; 26 | int m_totalTestCount; 27 | int m_failedTestCount; 28 | int m_failureCount; 29 | 30 | bool m_currentTestFailed; 31 | 32 | TestResults(TestResults const&); 33 | TestResults& operator =(TestResults const&); 34 | }; 35 | 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestRunner.cpp: -------------------------------------------------------------------------------- 1 | #include "TestRunner.h" 2 | #include "TestResults.h" 3 | #include "TestReporter.h" 4 | #include "TestReporterStdout.h" 5 | #include "TimeHelpers.h" 6 | #include "MemoryOutStream.h" 7 | 8 | #include 9 | 10 | 11 | namespace UnitTest { 12 | 13 | int RunAllTests() 14 | { 15 | TestReporterStdout reporter; 16 | TestRunner runner(reporter); 17 | return runner.RunTestsIf(Test::GetTestList(), NULL, True(), 0); 18 | } 19 | 20 | 21 | TestRunner::TestRunner(TestReporter& reporter) 22 | : m_reporter(&reporter) 23 | , m_result(new TestResults(&reporter)) 24 | , m_timer(new Timer) 25 | { 26 | m_timer->Start(); 27 | } 28 | 29 | TestRunner::~TestRunner() 30 | { 31 | delete m_result; 32 | delete m_timer; 33 | } 34 | 35 | TestResults* TestRunner::GetTestResults() 36 | { 37 | return m_result; 38 | } 39 | 40 | int TestRunner::Finish() const 41 | { 42 | float const secondsElapsed = static_cast(m_timer->GetTimeInMs() / 1000.0); 43 | m_reporter->ReportSummary(m_result->GetTotalTestCount(), 44 | m_result->GetFailedTestCount(), 45 | m_result->GetFailureCount(), 46 | secondsElapsed); 47 | 48 | return m_result->GetFailureCount(); 49 | } 50 | 51 | bool TestRunner::IsTestInSuite(const Test* const curTest, char const* suiteName) const 52 | { 53 | using namespace std; 54 | return (suiteName == NULL) || !strcmp(curTest->m_details.suiteName, suiteName); 55 | } 56 | 57 | void TestRunner::RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const 58 | { 59 | if (curTest->m_isMockTest == false) 60 | CurrentTest::Results() = result; 61 | 62 | Timer testTimer; 63 | testTimer.Start(); 64 | 65 | result->OnTestStart(curTest->m_details); 66 | 67 | curTest->Run(); 68 | 69 | double const testTimeInMs = testTimer.GetTimeInMs(); 70 | if (maxTestTimeInMs > 0 && testTimeInMs > maxTestTimeInMs && !curTest->m_details.timeConstraintExempt) 71 | { 72 | MemoryOutStream stream; 73 | stream << "Global time constraint failed. Expected under " << maxTestTimeInMs << 74 | "ms but took " << testTimeInMs << "ms."; 75 | 76 | result->OnTestFailure(curTest->m_details, stream.GetText()); 77 | } 78 | 79 | result->OnTestFinish(curTest->m_details, static_cast< float >(testTimeInMs / 1000.0)); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestRunner.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTRUNNER_H 2 | #define UNITTEST_TESTRUNNER_H 3 | 4 | #include "Test.h" 5 | #include "TestList.h" 6 | #include "CurrentTest.h" 7 | 8 | namespace UnitTest { 9 | 10 | class TestReporter; 11 | class TestResults; 12 | class Timer; 13 | 14 | UNITTEST_LINKAGE int RunAllTests(); 15 | 16 | struct True 17 | { 18 | bool operator()(const Test* const) const 19 | { 20 | return true; 21 | } 22 | }; 23 | 24 | class UNITTEST_LINKAGE TestRunner 25 | { 26 | public: 27 | explicit TestRunner(TestReporter& reporter); 28 | ~TestRunner(); 29 | 30 | template< class Predicate > 31 | int RunTestsIf(TestList const& list, char const* suiteName, 32 | const Predicate& predicate, int maxTestTimeInMs) const 33 | { 34 | Test* curTest = list.GetHead(); 35 | 36 | while (curTest != 0) 37 | { 38 | if (IsTestInSuite(curTest, suiteName) && predicate(curTest)) 39 | RunTest(m_result, curTest, maxTestTimeInMs); 40 | 41 | curTest = curTest->m_nextTest; 42 | } 43 | 44 | return Finish(); 45 | } 46 | 47 | TestResults* GetTestResults(); 48 | 49 | private: 50 | TestReporter* m_reporter; 51 | TestResults* m_result; 52 | Timer* m_timer; 53 | 54 | int Finish() const; 55 | bool IsTestInSuite(const Test* const curTest, char const* suiteName) const; 56 | void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const; 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TestSuite.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTSUITE_H 2 | #define UNITTEST_TESTSUITE_H 3 | 4 | namespace UnitTestSuite 5 | { 6 | inline char const* GetSuiteName () 7 | { 8 | return "DefaultSuite"; 9 | } 10 | } 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TimeConstraint.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeConstraint.h" 2 | #include "TestResults.h" 3 | #include "MemoryOutStream.h" 4 | #include "CurrentTest.h" 5 | 6 | namespace UnitTest { 7 | 8 | 9 | TimeConstraint::TimeConstraint(int ms, TestDetails const& details) 10 | : m_details(details) 11 | , m_maxMs(ms) 12 | { 13 | m_timer.Start(); 14 | } 15 | 16 | TimeConstraint::~TimeConstraint() 17 | { 18 | double const totalTimeInMs = m_timer.GetTimeInMs(); 19 | if (totalTimeInMs > m_maxMs) 20 | { 21 | MemoryOutStream stream; 22 | stream << "Time constraint failed. Expected to run test under " << m_maxMs << 23 | "ms but took " << totalTimeInMs << "ms."; 24 | 25 | CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TimeConstraint.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TIMECONSTRAINT_H 2 | #define UNITTEST_TIMECONSTRAINT_H 3 | 4 | #include "TimeHelpers.h" 5 | #include "HelperMacros.h" 6 | 7 | namespace UnitTest { 8 | 9 | class TestResults; 10 | class TestDetails; 11 | 12 | class UNITTEST_LINKAGE TimeConstraint 13 | { 14 | public: 15 | TimeConstraint(int ms, TestDetails const& details); 16 | ~TimeConstraint(); 17 | 18 | private: 19 | void operator=(TimeConstraint const&); 20 | TimeConstraint(TimeConstraint const&); 21 | 22 | Timer m_timer; 23 | TestDetails const& m_details; 24 | int const m_maxMs; 25 | }; 26 | 27 | #define UNITTEST_TIME_CONSTRAINT(ms) \ 28 | UnitTest::TimeConstraint unitTest__timeConstraint__(ms, UnitTest::TestDetails(m_details, __LINE__)) 29 | 30 | #define UNITTEST_TIME_CONSTRAINT_EXEMPT() \ 31 | UNITTEST_MULTILINE_MACRO_BEGIN \ 32 | m_details.timeConstraintExempt = true; \ 33 | UNITTEST_MULTILINE_MACRO_END 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/TimeHelpers.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | 3 | #if defined UNITTEST_POSIX 4 | #include "Posix/TimeHelpers.h" 5 | #else 6 | #include "Win32/TimeHelpers.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/UnitTest++.h: -------------------------------------------------------------------------------- 1 | #include "UnitTestPP.h" -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/UnitTestPP.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTESTPP_H 2 | #define UNITTESTPP_H 3 | 4 | #include "Config.h" 5 | #include "TestMacros.h" 6 | #include "CheckMacros.h" 7 | #include "TestRunner.h" 8 | #include "TimeConstraint.h" 9 | #include "ReportAssert.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/UnitTestTimer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | 6 | 7 | namespace Time 8 | { 9 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 10 | inline __int64 GetTime() 11 | { 12 | LARGE_INTEGER largeInteger; 13 | QueryPerformanceCounter( &largeInteger ); 14 | return largeInteger.QuadPart; 15 | } 16 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 17 | inline __int64 GetFrequency() 18 | { 19 | LARGE_INTEGER frequency; 20 | QueryPerformanceFrequency(&frequency); 21 | return frequency.QuadPart; 22 | } 23 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 24 | inline __int64 GetTimeMilliSeconds() 25 | { 26 | LARGE_INTEGER largeInteger; 27 | QueryPerformanceCounter( &largeInteger ); 28 | return ( largeInteger.QuadPart * __int64(1000) ) / GetFrequency(); 29 | } 30 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 31 | inline __int64 GetTimeMicroSeconds() 32 | { 33 | LARGE_INTEGER largeInteger; 34 | QueryPerformanceCounter( &largeInteger ); 35 | return ( largeInteger.QuadPart * __int64(1000000) ) / GetFrequency(); 36 | } 37 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 38 | inline void SpinSleep(size_t microSeconds) 39 | { 40 | __int64 time = GetTimeMicroSeconds() + microSeconds; 41 | while(GetTimeMicroSeconds() < time) 42 | { 43 | Sleep(0); 44 | } 45 | } 46 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 47 | } 48 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Win32/TimeHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeHelpers.h" 2 | 3 | #ifndef WIN32_LEAN_AND_MEAN 4 | #define WIN32_LEAN_AND_MEAN 5 | #endif 6 | #include 7 | 8 | namespace UnitTest { 9 | 10 | Timer::Timer() 11 | : m_threadHandle(::GetCurrentThread()) 12 | , m_startTime(0) 13 | { 14 | #if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR 15 | typedef unsigned long DWORD_PTR; 16 | #endif 17 | 18 | DWORD_PTR systemMask; 19 | ::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask); 20 | ::SetThreadAffinityMask(m_threadHandle, 1); 21 | ::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency)); 22 | ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask); 23 | } 24 | 25 | void Timer::Start() 26 | { 27 | m_startTime = GetTime(); 28 | } 29 | 30 | double Timer::GetTimeInMs() const 31 | { 32 | __int64 const elapsedTime = GetTime() - m_startTime; 33 | double const seconds = double(elapsedTime) / double(m_frequency); 34 | return seconds * 1000.0; 35 | } 36 | 37 | __int64 Timer::GetTime() const 38 | { 39 | LARGE_INTEGER curTime; 40 | ::SetThreadAffinityMask(m_threadHandle, 1); 41 | ::QueryPerformanceCounter(&curTime); 42 | ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask); 43 | return curTime.QuadPart; 44 | } 45 | 46 | void TimeHelpers::SleepMs(int ms) 47 | { 48 | ::Sleep(ms); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/Win32/TimeHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TIMEHELPERS_H 2 | #define UNITTEST_TIMEHELPERS_H 3 | 4 | #include "../Config.h" 5 | #include "../HelperMacros.h" 6 | 7 | #ifdef UNITTEST_MINGW 8 | #ifndef __int64 9 | #define __int64 long long 10 | #endif 11 | #endif 12 | 13 | namespace UnitTest { 14 | 15 | class UNITTEST_LINKAGE Timer 16 | { 17 | public: 18 | Timer(); 19 | void Start(); 20 | double GetTimeInMs() const; 21 | 22 | private: 23 | __int64 GetTime() const; 24 | 25 | void* m_threadHandle; 26 | 27 | #if defined(_WIN64) 28 | unsigned __int64 m_processAffinityMask; 29 | #else 30 | unsigned long m_processAffinityMask; 31 | #endif 32 | 33 | __int64 m_startTime; 34 | __int64 m_frequency; 35 | }; 36 | 37 | 38 | namespace TimeHelpers 39 | { 40 | UNITTEST_LINKAGE void SleepMs(int ms); 41 | } 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/XmlTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_XMLTESTREPORTER_H 2 | #define UNITTEST_XMLTESTREPORTER_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 6 | 7 | #include "DeferredTestReporter.h" 8 | 9 | #include 10 | 11 | namespace UnitTest 12 | { 13 | 14 | class UNITTEST_LINKAGE XmlTestReporter : public DeferredTestReporter 15 | { 16 | public: 17 | explicit XmlTestReporter(std::ostream& ostream); 18 | 19 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 20 | 21 | private: 22 | XmlTestReporter(XmlTestReporter const&); 23 | XmlTestReporter& operator=(XmlTestReporter const&); 24 | 25 | void AddXmlElement(std::ostream& os, char const* encoding); 26 | void BeginResults(std::ostream& os, int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 27 | void EndResults(std::ostream& os); 28 | void BeginTest(std::ostream& os, DeferredTestResult const& result); 29 | void AddFailure(std::ostream& os, DeferredTestResult const& result); 30 | void EndTest(std::ostream& os, DeferredTestResult const& result); 31 | 32 | std::ostream& m_ostream; 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/UnitTest++/unittestpp_vs2008.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {8532d556-7b68-49d6-8fca-85f1fc6c4864} 6 | 7 | 8 | 9 | 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Win32 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/builds/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.69]) 5 | AC_INIT([UnitTest++], [1.4.1], [pjohnmeyer@gmail.com]) 6 | AC_CONFIG_SRCDIR([UnitTest++/TestDetails.cpp]) 7 | AC_CONFIG_MACRO_DIR([m4]) 8 | AC_CONFIG_HEADERS([config.h]) 9 | 10 | AM_INIT_AUTOMAKE([foreign]) 11 | LT_INIT() 12 | 13 | AC_SUBST([LIBUNITTEST_SO_VERSION], [1:4:1]) 14 | 15 | # Checks for programs. 16 | AC_PROG_CXX 17 | AC_PROG_CC 18 | 19 | # Checks for libraries. 20 | 21 | # Checks for header files. 22 | AC_CHECK_HEADERS([sys/time.h unistd.h setjmp.h signal.h cassert cstddef cstdio cstring exception iosfwd iostream sstream string vector]) 23 | 24 | # Checks for typedefs, structures, and compiler characteristics. 25 | AC_CHECK_HEADER_STDBOOL 26 | AC_C_INLINE 27 | AC_TYPE_SIZE_T 28 | 29 | # Checks for library functions. 30 | AC_CHECK_FUNCS([gettimeofday strstr]) 31 | 32 | AC_CONFIG_FILES([Makefile 33 | UnitTest++/Makefile]) 34 | AC_OUTPUT 35 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | 3 | int main(int, char const *[]) 4 | { 5 | return UnitTest::RunAllTests(); 6 | } 7 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/RecordingReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_RECORDINGREPORTER_H 2 | #define UNITTEST_RECORDINGREPORTER_H 3 | 4 | #include "UnitTest++/TestReporter.h" 5 | #include 6 | 7 | #include "UnitTest++/TestDetails.h" 8 | 9 | struct RecordingReporter : public UnitTest::TestReporter 10 | { 11 | private: 12 | enum { kMaxStringLength = 256 }; 13 | 14 | public: 15 | RecordingReporter() 16 | : testRunCount(0) 17 | , testFailedCount(0) 18 | , lastFailedLine(0) 19 | , testFinishedCount(0) 20 | , lastFinishedTestTime(0) 21 | , summaryTotalTestCount(0) 22 | , summaryFailedTestCount(0) 23 | , summaryFailureCount(0) 24 | , summarySecondsElapsed(0) 25 | { 26 | lastStartedSuite[0] = '\0'; 27 | lastStartedTest[0] = '\0'; 28 | lastFailedFile[0] = '\0'; 29 | lastFailedSuite[0] = '\0'; 30 | lastFailedTest[0] = '\0'; 31 | lastFailedMessage[0] = '\0'; 32 | lastFinishedSuite[0] = '\0'; 33 | lastFinishedTest[0] = '\0'; 34 | } 35 | 36 | virtual void ReportTestStart(UnitTest::TestDetails const& test) 37 | { 38 | using namespace std; 39 | 40 | ++testRunCount; 41 | strcpy(lastStartedSuite, test.suiteName); 42 | strcpy(lastStartedTest, test.testName); 43 | } 44 | 45 | virtual void ReportFailure(UnitTest::TestDetails const& test, char const* failure) 46 | { 47 | using namespace std; 48 | 49 | ++testFailedCount; 50 | strcpy(lastFailedFile, test.filename); 51 | lastFailedLine = test.lineNumber; 52 | strcpy(lastFailedSuite, test.suiteName); 53 | strcpy(lastFailedTest, test.testName); 54 | strcpy(lastFailedMessage, failure); 55 | } 56 | 57 | virtual void ReportTestFinish(UnitTest::TestDetails const& test, float testDuration) 58 | { 59 | using namespace std; 60 | 61 | ++testFinishedCount; 62 | strcpy(lastFinishedSuite, test.suiteName); 63 | strcpy(lastFinishedTest, test.testName); 64 | lastFinishedTestTime = testDuration; 65 | } 66 | 67 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) 68 | { 69 | summaryTotalTestCount = totalTestCount; 70 | summaryFailedTestCount = failedTestCount; 71 | summaryFailureCount = failureCount; 72 | summarySecondsElapsed = secondsElapsed; 73 | } 74 | 75 | int testRunCount; 76 | char lastStartedSuite[kMaxStringLength]; 77 | char lastStartedTest[kMaxStringLength]; 78 | 79 | int testFailedCount; 80 | char lastFailedFile[kMaxStringLength]; 81 | int lastFailedLine; 82 | char lastFailedSuite[kMaxStringLength]; 83 | char lastFailedTest[kMaxStringLength]; 84 | char lastFailedMessage[kMaxStringLength]; 85 | 86 | int testFinishedCount; 87 | char lastFinishedSuite[kMaxStringLength]; 88 | char lastFinishedTest[kMaxStringLength]; 89 | float lastFinishedTestTime; 90 | 91 | int summaryTotalTestCount; 92 | int summaryFailedTestCount; 93 | int summaryFailureCount; 94 | float summarySecondsElapsed; 95 | }; 96 | 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/ScopedCurrentTest.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_SCOPEDCURRENTTEST_H 2 | #define UNITTEST_SCOPEDCURRENTTEST_H 3 | 4 | #include "UnitTest++/CurrentTest.h" 5 | #include 6 | 7 | class ScopedCurrentTest 8 | { 9 | public: 10 | ScopedCurrentTest() 11 | : m_oldTestResults(UnitTest::CurrentTest::Results()) 12 | , m_oldTestDetails(UnitTest::CurrentTest::Details()) 13 | { 14 | } 15 | 16 | explicit ScopedCurrentTest(UnitTest::TestResults& newResults, const UnitTest::TestDetails* newDetails = NULL) 17 | : m_oldTestResults(UnitTest::CurrentTest::Results()) 18 | , m_oldTestDetails(UnitTest::CurrentTest::Details()) 19 | { 20 | UnitTest::CurrentTest::Results() = &newResults; 21 | 22 | if (newDetails != NULL) 23 | UnitTest::CurrentTest::Details() = newDetails; 24 | } 25 | 26 | ~ScopedCurrentTest() 27 | { 28 | UnitTest::CurrentTest::Results() = m_oldTestResults; 29 | UnitTest::CurrentTest::Details() = m_oldTestDetails; 30 | } 31 | 32 | private: 33 | UnitTest::TestResults* m_oldTestResults; 34 | const UnitTest::TestDetails* m_oldTestDetails; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestAssertHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/Config.h" 2 | #include "UnitTest++/UnitTestPP.h" 3 | 4 | #include "UnitTest++/ReportAssert.h" 5 | #include "UnitTest++/ReportAssertImpl.h" 6 | #include "UnitTest++/AssertException.h" 7 | 8 | #include "RecordingReporter.h" 9 | #include 10 | 11 | using namespace UnitTest; 12 | 13 | namespace { 14 | 15 | TEST(CanSetAssertExpected) 16 | { 17 | Detail::ExpectAssert(true); 18 | CHECK(Detail::AssertExpected()); 19 | 20 | Detail::ExpectAssert(false); 21 | CHECK(!Detail::AssertExpected()); 22 | } 23 | 24 | #ifndef UNITTEST_NO_EXCEPTIONS 25 | 26 | TEST(ReportAssertThrowsAssertException) 27 | { 28 | bool caught = false; 29 | 30 | try 31 | { 32 | TestResults testResults; 33 | TestDetails testDetails("", "", "", 0); 34 | Detail::ReportAssertEx(&testResults, &testDetails, "", "", 0); 35 | } 36 | catch(AssertException const&) 37 | { 38 | caught = true; 39 | } 40 | 41 | CHECK(true == caught); 42 | } 43 | 44 | TEST(ReportAssertClearsExpectAssertFlag) 45 | { 46 | RecordingReporter reporter; 47 | TestResults testResults(&reporter); 48 | TestDetails testDetails("", "", "", 0); 49 | 50 | try 51 | { 52 | Detail::ExpectAssert(true); 53 | Detail::ReportAssertEx(&testResults, &testDetails, "", "", 0); 54 | } 55 | catch(AssertException const&) 56 | { 57 | } 58 | 59 | CHECK(Detail::AssertExpected() == false); 60 | CHECK_EQUAL(0, reporter.testFailedCount); 61 | } 62 | 63 | TEST(ReportAssertWritesFailureToResultsAndDetailsWhenAssertIsNotExpected) 64 | { 65 | const int lineNumber = 12345; 66 | const char* description = "description"; 67 | const char* filename = "filename"; 68 | 69 | RecordingReporter reporter; 70 | TestResults testResults(&reporter); 71 | TestDetails testDetails("", "", "", 0); 72 | 73 | try 74 | { 75 | Detail::ReportAssertEx(&testResults, &testDetails, description, filename, lineNumber); 76 | } 77 | catch(AssertException const&) 78 | { 79 | } 80 | 81 | CHECK_EQUAL(description, reporter.lastFailedMessage); 82 | CHECK_EQUAL(filename, reporter.lastFailedFile); 83 | CHECK_EQUAL(lineNumber, reporter.lastFailedLine); 84 | } 85 | 86 | TEST(ReportAssertReportsNoErrorsWhenAssertIsExpected) 87 | { 88 | Detail::ExpectAssert(true); 89 | 90 | RecordingReporter reporter; 91 | TestResults testResults(&reporter); 92 | TestDetails testDetails("", "", "", 0); 93 | 94 | try 95 | { 96 | Detail::ReportAssertEx(&testResults, &testDetails, "", "", 0); 97 | } 98 | catch(AssertException const&) 99 | { 100 | } 101 | 102 | CHECK_EQUAL(0, reporter.testFailedCount); 103 | } 104 | 105 | TEST(CheckAssertMacroSetsAssertExpectationToFalseAfterRunning) 106 | { 107 | Detail::ExpectAssert(true); 108 | CHECK_ASSERT(ReportAssert("", "", 0)); 109 | CHECK(!Detail::AssertExpected()); 110 | Detail::ExpectAssert(false); 111 | } 112 | 113 | #else 114 | 115 | TEST(SetAssertJumpTargetReturnsFalseWhenSettingJumpTarget) 116 | { 117 | CHECK(UNITTEST_SET_ASSERT_JUMP_TARGET() == false); 118 | } 119 | 120 | TEST(JumpToAssertJumpTarget_JumpsToSetPoint_ReturnsTrue) 121 | { 122 | const volatile bool taken = !!UNITTEST_SET_ASSERT_JUMP_TARGET(); 123 | 124 | volatile bool set = false; 125 | if (taken == false) 126 | { 127 | UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET(); 128 | set = true; 129 | } 130 | 131 | CHECK(set == false); 132 | } 133 | 134 | #endif 135 | 136 | } 137 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestCurrentTest.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | #include "UnitTest++/CurrentTest.h" 3 | #include "ScopedCurrentTest.h" 4 | 5 | namespace 6 | { 7 | 8 | TEST(CanSetandGetDetails) 9 | { 10 | bool ok = false; 11 | { 12 | ScopedCurrentTest scopedTest; 13 | 14 | const UnitTest::TestDetails* details = reinterpret_cast< const UnitTest::TestDetails* >(12345); 15 | UnitTest::CurrentTest::Details() = details; 16 | 17 | ok = (UnitTest::CurrentTest::Details() == details); 18 | } 19 | 20 | CHECK(ok); 21 | } 22 | 23 | TEST(CanSetAndGetResults) 24 | { 25 | bool ok = false; 26 | { 27 | ScopedCurrentTest scopedTest; 28 | 29 | UnitTest::TestResults results; 30 | UnitTest::CurrentTest::Results() = &results; 31 | 32 | ok = (UnitTest::CurrentTest::Results() == &results); 33 | } 34 | 35 | CHECK(ok); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestTest.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | #include "UnitTest++/TestReporter.h" 3 | #include "UnitTest++/TimeHelpers.h" 4 | #include "ScopedCurrentTest.h" 5 | 6 | using namespace UnitTest; 7 | 8 | namespace { 9 | 10 | TEST(PassingTestHasNoFailures) 11 | { 12 | class PassingTest : public Test 13 | { 14 | public: 15 | PassingTest() : Test("passing") {} 16 | virtual void RunImpl() const 17 | { 18 | CHECK(true); 19 | } 20 | }; 21 | 22 | TestResults results; 23 | { 24 | ScopedCurrentTest scopedResults(results); 25 | PassingTest().Run(); 26 | } 27 | 28 | CHECK_EQUAL(0, results.GetFailureCount()); 29 | } 30 | 31 | 32 | TEST(FailingTestHasFailures) 33 | { 34 | class FailingTest : public Test 35 | { 36 | public: 37 | FailingTest() : Test("failing") {} 38 | virtual void RunImpl() const 39 | { 40 | CHECK(false); 41 | } 42 | }; 43 | 44 | TestResults results; 45 | { 46 | ScopedCurrentTest scopedResults(results); 47 | FailingTest().Run(); 48 | } 49 | 50 | CHECK_EQUAL(1, results.GetFailureCount()); 51 | } 52 | 53 | #ifndef UNITTEST_NO_EXCEPTIONS 54 | TEST(ThrowingTestsAreReportedAsFailures) 55 | { 56 | class CrashingTest : public Test 57 | { 58 | public: 59 | CrashingTest() : Test("throwing") {} 60 | virtual void RunImpl() const 61 | { 62 | throw "Blah"; 63 | } 64 | }; 65 | 66 | TestResults results; 67 | { 68 | ScopedCurrentTest scopedResult(results); 69 | CrashingTest().Run(); 70 | } 71 | 72 | CHECK_EQUAL(1, results.GetFailureCount()); 73 | } 74 | 75 | #if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) 76 | TEST(CrashingTestsAreReportedAsFailures) 77 | { 78 | class CrashingTest : public Test 79 | { 80 | public: 81 | CrashingTest() : Test("crashing") {} 82 | virtual void RunImpl() const 83 | { 84 | 85 | reinterpret_cast< void (*)() >(0)(); 86 | } 87 | }; 88 | 89 | TestResults results; 90 | { 91 | ScopedCurrentTest scopedResult(results); 92 | CrashingTest().Run(); 93 | } 94 | 95 | CHECK_EQUAL(1, results.GetFailureCount()); 96 | } 97 | #endif 98 | #endif 99 | 100 | TEST(TestWithUnspecifiedSuiteGetsDefaultSuite) 101 | { 102 | Test test("test"); 103 | CHECK(test.m_details.suiteName != NULL); 104 | CHECK_EQUAL("DefaultSuite", test.m_details.suiteName); 105 | } 106 | 107 | TEST(TestReflectsSpecifiedSuiteName) 108 | { 109 | Test test("test", "testSuite"); 110 | CHECK(test.m_details.suiteName != NULL); 111 | CHECK_EQUAL("testSuite", test.m_details.suiteName); 112 | } 113 | 114 | void Fail() 115 | { 116 | CHECK(false); 117 | } 118 | 119 | TEST(OutOfCoreCHECKMacrosCanFailTests) 120 | { 121 | TestResults results; 122 | { 123 | ScopedCurrentTest scopedResult(results); 124 | Fail(); 125 | } 126 | 127 | CHECK_EQUAL(1, results.GetFailureCount()); 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestTestList.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | #include "UnitTest++/TestList.h" 3 | 4 | using namespace UnitTest; 5 | 6 | namespace { 7 | 8 | 9 | TEST(TestListIsEmptyByDefault) 10 | { 11 | TestList list; 12 | CHECK(list.GetHead() == 0); 13 | } 14 | 15 | TEST(AddingTestSetsHeadToTest) 16 | { 17 | Test test("test"); 18 | TestList list; 19 | list.Add(&test); 20 | 21 | CHECK(list.GetHead() == &test); 22 | CHECK(test.m_nextTest == 0); 23 | } 24 | 25 | TEST(AddingSecondTestAddsItToEndOfList) 26 | { 27 | Test test1("test1"); 28 | Test test2("test2"); 29 | 30 | TestList list; 31 | list.Add(&test1); 32 | list.Add(&test2); 33 | 34 | CHECK(list.GetHead() == &test1); 35 | CHECK(test1.m_nextTest == &test2); 36 | CHECK(test2.m_nextTest == 0); 37 | } 38 | 39 | TEST(ListAdderAddsTestToList) 40 | { 41 | TestList list; 42 | 43 | Test test(""); 44 | ListAdder adder(list, &test); 45 | 46 | CHECK(list.GetHead() == &test); 47 | CHECK(test.m_nextTest == 0); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestTestSuite.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | 3 | // We're really testing if it's possible to use the same suite in two files 4 | // to compile and link successfuly (TestTestSuite.cpp has suite with the same name) 5 | // Note: we are outside of the anonymous namespace 6 | SUITE(SameTestSuite) 7 | { 8 | TEST(DummyTest2) 9 | { 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestTimeConstraint.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | #include "UnitTest++/TestResults.h" 3 | #include "UnitTest++/TimeHelpers.h" 4 | #include "RecordingReporter.h" 5 | #include "ScopedCurrentTest.h" 6 | 7 | using namespace UnitTest; 8 | 9 | namespace 10 | { 11 | 12 | TEST(TimeConstraintSucceedsWithFastTest) 13 | { 14 | TestResults result; 15 | { 16 | ScopedCurrentTest scopedResult(result); 17 | TimeConstraint t(200, TestDetails("", "", "", 0)); 18 | TimeHelpers::SleepMs(5); 19 | } 20 | CHECK_EQUAL(0, result.GetFailureCount()); 21 | } 22 | 23 | TEST(TimeConstraintFailsWithSlowTest) 24 | { 25 | TestResults result; 26 | { 27 | ScopedCurrentTest scopedResult(result); 28 | TimeConstraint t(10, TestDetails("", "", "", 0)); 29 | TimeHelpers::SleepMs(20); 30 | } 31 | CHECK_EQUAL(1, result.GetFailureCount()); 32 | } 33 | 34 | TEST(TimeConstraintFailureIncludesCorrectData) 35 | { 36 | RecordingReporter reporter; 37 | TestResults result(&reporter); 38 | { 39 | ScopedCurrentTest scopedResult(result); 40 | 41 | TestDetails const details("testname", "suitename", "filename", 10); 42 | TimeConstraint t(10, details); 43 | TimeHelpers::SleepMs(20); 44 | } 45 | 46 | using namespace std; 47 | 48 | CHECK(strstr(reporter.lastFailedFile, "filename")); 49 | CHECK_EQUAL(10, reporter.lastFailedLine); 50 | CHECK(strstr(reporter.lastFailedTest, "testname")); 51 | } 52 | 53 | TEST(TimeConstraintFailureIncludesTimeoutInformation) 54 | { 55 | RecordingReporter reporter; 56 | TestResults result(&reporter); 57 | { 58 | ScopedCurrentTest scopedResult(result); 59 | TimeConstraint t(10, TestDetails("", "", "", 0)); 60 | TimeHelpers::SleepMs(20); 61 | } 62 | 63 | using namespace std; 64 | 65 | CHECK(strstr(reporter.lastFailedMessage, "ime constraint")); 66 | CHECK(strstr(reporter.lastFailedMessage, "under 10ms")); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestTimeConstraintMacro.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | #include "UnitTest++/TimeHelpers.h" 3 | 4 | #include "RecordingReporter.h" 5 | #include "ScopedCurrentTest.h" 6 | 7 | namespace { 8 | 9 | TEST(TimeConstraintMacroQualifiesNamespace) 10 | { 11 | // If this compiles without a "using namespace UnitTest;", all is well. 12 | UNITTEST_TIME_CONSTRAINT(1); 13 | } 14 | 15 | TEST(TimeConstraintMacroUsesCorrectInfo) 16 | { 17 | int testLine = 0; 18 | RecordingReporter reporter; 19 | 20 | { 21 | UnitTest::TestResults testResults(&reporter); 22 | ScopedCurrentTest scopedResults(testResults); 23 | 24 | UNITTEST_TIME_CONSTRAINT(10); testLine = __LINE__; 25 | UnitTest::TimeHelpers::SleepMs(20); 26 | } 27 | 28 | using namespace std; 29 | 30 | CHECK_EQUAL(1, reporter.testFailedCount); 31 | CHECK(strstr(reporter.lastFailedFile, __FILE__)); 32 | CHECK_EQUAL(testLine, reporter.lastFailedLine); 33 | CHECK(strstr(reporter.lastFailedTest, "TimeConstraintMacroUsesCorrectInfo")); 34 | } 35 | 36 | TEST(TimeConstraintMacroComparesAgainstPreciseActual) 37 | { 38 | int testLine = 0; 39 | RecordingReporter reporter; 40 | 41 | { 42 | UnitTest::TestResults testResults(&reporter); 43 | ScopedCurrentTest scopedResults(testResults); 44 | 45 | UNITTEST_TIME_CONSTRAINT(1); testLine = __LINE__; 46 | 47 | // start a new timer and run until we're as little over the 1 msec 48 | // threshold as we can achieve; this should guarantee that the "test" 49 | // runs in some very small amount of time > 1 msec 50 | UnitTest::Timer myTimer; 51 | myTimer.Start(); 52 | 53 | while (myTimer.GetTimeInMs() < 1.001) 54 | UnitTest::TimeHelpers::SleepMs(0); 55 | } 56 | 57 | using namespace std; 58 | 59 | CHECK_EQUAL(1, reporter.testFailedCount); 60 | CHECK(strstr(reporter.lastFailedFile, __FILE__)); 61 | CHECK_EQUAL(testLine, reporter.lastFailedLine); 62 | CHECK(strstr(reporter.lastFailedTest, "TimeConstraintMacroComparesAgainstPreciseActual")); 63 | } 64 | 65 | struct EmptyFixture {}; 66 | 67 | TEST_FIXTURE(EmptyFixture, TimeConstraintMacroWorksInFixtures) 68 | { 69 | int testLine = 0; 70 | RecordingReporter reporter; 71 | 72 | { 73 | UnitTest::TestResults testResults(&reporter); 74 | ScopedCurrentTest scopedResults(testResults); 75 | 76 | UNITTEST_TIME_CONSTRAINT(10); testLine = __LINE__; 77 | UnitTest::TimeHelpers::SleepMs(20); 78 | } 79 | 80 | using namespace std; 81 | 82 | CHECK_EQUAL(1, reporter.testFailedCount); 83 | CHECK(strstr(reporter.lastFailedFile, __FILE__)); 84 | CHECK_EQUAL(testLine, reporter.lastFailedLine); 85 | CHECK(strstr(reporter.lastFailedTest, "TimeConstraintMacroWorksInFixtures")); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /ThirdParty/UnitTest++/tests/TestUnitTestPP.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/UnitTestPP.h" 2 | #include "ScopedCurrentTest.h" 3 | 4 | // These are sample tests that show the different features of the framework 5 | 6 | namespace { 7 | 8 | TEST(ValidCheckSucceeds) 9 | { 10 | bool const b = true; 11 | CHECK(b); 12 | } 13 | 14 | TEST(CheckWorksWithPointers) 15 | { 16 | void* p = (void *)0x100; 17 | CHECK(p); 18 | CHECK(p != 0); 19 | } 20 | 21 | TEST(ValidCheckEqualSucceeds) 22 | { 23 | int const x = 3; 24 | int const y = 3; 25 | CHECK_EQUAL(x, y); 26 | } 27 | 28 | TEST(CheckEqualWorksWithPointers) 29 | { 30 | void* p = (void *)0; 31 | CHECK_EQUAL((void*)0, p); 32 | } 33 | 34 | TEST(ValidCheckCloseSucceeds) 35 | { 36 | CHECK_CLOSE(2.0f, 2.001f, 0.01f); 37 | CHECK_CLOSE(2.001f, 2.0f, 0.01f); 38 | } 39 | 40 | TEST(ArrayCloseSucceeds) 41 | { 42 | float const a1[] = {1, 2, 3}; 43 | float const a2[] = {1, 2.01f, 3}; 44 | CHECK_ARRAY_CLOSE(a1, a2, 3, 0.1f); 45 | } 46 | 47 | #ifndef UNITTEST_NO_EXCEPTIONS 48 | 49 | TEST(CheckThrowMacroSucceedsOnCorrectException) 50 | { 51 | struct TestException {}; 52 | CHECK_THROW(throw TestException(), TestException); 53 | } 54 | 55 | TEST(CheckAssertSucceeds) 56 | { 57 | CHECK_ASSERT(UnitTest::ReportAssert("desc", "file", 0)); 58 | } 59 | 60 | TEST(CheckThrowMacroFailsOnMissingException) 61 | { 62 | class NoThrowTest : public UnitTest::Test 63 | { 64 | public: 65 | NoThrowTest() : Test("nothrow") {} 66 | void DontThrow() const 67 | { 68 | } 69 | 70 | virtual void RunImpl() const 71 | { 72 | CHECK_THROW(DontThrow(), int); 73 | } 74 | }; 75 | 76 | UnitTest::TestResults results; 77 | { 78 | ScopedCurrentTest scopedResults(results); 79 | 80 | NoThrowTest test; 81 | test.Run(); 82 | } 83 | 84 | CHECK_EQUAL(1, results.GetFailureCount()); 85 | } 86 | 87 | TEST(CheckThrowMacroFailsOnWrongException) 88 | { 89 | class WrongThrowTest : public UnitTest::Test 90 | { 91 | public: 92 | WrongThrowTest() : Test("wrongthrow") {} 93 | virtual void RunImpl() const 94 | { 95 | CHECK_THROW(throw "oops", int); 96 | } 97 | }; 98 | 99 | UnitTest::TestResults results; 100 | { 101 | ScopedCurrentTest scopedResults(results); 102 | 103 | WrongThrowTest test; 104 | test.Run(); 105 | } 106 | 107 | CHECK_EQUAL(1, results.GetFailureCount()); 108 | } 109 | 110 | #endif 111 | 112 | struct SimpleFixture 113 | { 114 | SimpleFixture() 115 | { 116 | ++instanceCount; 117 | } 118 | ~SimpleFixture() 119 | { 120 | --instanceCount; 121 | } 122 | 123 | static int instanceCount; 124 | }; 125 | 126 | int SimpleFixture::instanceCount = 0; 127 | 128 | TEST_FIXTURE(SimpleFixture, DefaultFixtureCtorIsCalled) 129 | { 130 | CHECK(SimpleFixture::instanceCount > 0); 131 | } 132 | 133 | TEST_FIXTURE(SimpleFixture, OnlyOneFixtureAliveAtATime) 134 | { 135 | CHECK_EQUAL(1, SimpleFixture::instanceCount); 136 | } 137 | 138 | void CheckBool(const bool b) 139 | { 140 | CHECK(b); 141 | } 142 | 143 | TEST(CanCallCHECKOutsideOfTestFunction) 144 | { 145 | CheckBool(true); 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | build_script: 4 | - premake4 vs2010 5 | - cd Build/vs2010 6 | - MsBuild TaskScheduler.sln /t:Rebuild /p:Configuration=Release 7 | 8 | test_script: 9 | - cd ..\..\Bin 10 | - TaskSchedulerTests.exe 3 -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /premake4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SergeyMakeev/TaskScheduler/2b9bbb88dfa47e1541368368c320aac6c516a99b/premake4.exe -------------------------------------------------------------------------------- /sunifdef.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SergeyMakeev/TaskScheduler/2b9bbb88dfa47e1541368368c320aac6c516a99b/sunifdef.exe --------------------------------------------------------------------------------