102d170cfSs.makeev_local // The MIT License (MIT)
202d170cfSs.makeev_local //
302d170cfSs.makeev_local // 	Copyright (c) 2015 Sergey Makeev, Vadim Slyusarev
402d170cfSs.makeev_local //
502d170cfSs.makeev_local // 	Permission is hereby granted, free of charge, to any person obtaining a copy
602d170cfSs.makeev_local // 	of this software and associated documentation files (the "Software"), to deal
702d170cfSs.makeev_local // 	in the Software without restriction, including without limitation the rights
802d170cfSs.makeev_local // 	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
902d170cfSs.makeev_local // 	copies of the Software, and to permit persons to whom the Software is
1002d170cfSs.makeev_local // 	furnished to do so, subject to the following conditions:
1102d170cfSs.makeev_local //
1202d170cfSs.makeev_local //  The above copyright notice and this permission notice shall be included in
1302d170cfSs.makeev_local // 	all copies or substantial portions of the Software.
1402d170cfSs.makeev_local //
1502d170cfSs.makeev_local // 	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1602d170cfSs.makeev_local // 	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1702d170cfSs.makeev_local // 	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1802d170cfSs.makeev_local // 	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1902d170cfSs.makeev_local // 	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2002d170cfSs.makeev_local // 	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2102d170cfSs.makeev_local // 	THE SOFTWARE.
2202d170cfSs.makeev_local 
2302d170cfSs.makeev_local #pragma once
2402d170cfSs.makeev_local 
2502d170cfSs.makeev_local #include <MTConfig.h>
2602d170cfSs.makeev_local 
2702d170cfSs.makeev_local #if MT_MSVC_COMPILER_FAMILY
2802d170cfSs.makeev_local #include <crtdefs.h>
2902d170cfSs.makeev_local #elif MT_GCC_COMPILER_FAMILY
3002d170cfSs.makeev_local #include <sys/types.h>
3102d170cfSs.makeev_local #include <stddef.h>
3202d170cfSs.makeev_local #else
3302d170cfSs.makeev_local #error Compiler is not supported
3402d170cfSs.makeev_local #endif
3502d170cfSs.makeev_local 
36721f8c0bSs.makeev_local #if MT_MSVC_COMPILER_FAMILY
37*2f083884Ss.makeev_local #define MT_NORETURN
38721f8c0bSs.makeev_local #elif MT_GCC_COMPILER_FAMILY
39*2f083884Ss.makeev_local #define MT_NORETURN // [[ noreturn ]]
40721f8c0bSs.makeev_local #else
41721f8c0bSs.makeev_local #error Can not define MT_NORETURN. Unknown platform.
42721f8c0bSs.makeev_local #endif
43721f8c0bSs.makeev_local 
44721f8c0bSs.makeev_local 
4502d170cfSs.makeev_local 
4602d170cfSs.makeev_local #define MT_DEFAULT_ALIGN (16)
4702d170cfSs.makeev_local 
4802d170cfSs.makeev_local namespace MT
4902d170cfSs.makeev_local {
5002d170cfSs.makeev_local 	// Memory allocator interface.
5102d170cfSs.makeev_local 	//////////////////////////////////////////////////////////////////////////
5202d170cfSs.makeev_local 	struct Memory
5302d170cfSs.makeev_local 	{
5402d170cfSs.makeev_local 		struct StackDesc
5502d170cfSs.makeev_local 		{
5602d170cfSs.makeev_local 			void* stackBottom;
5702d170cfSs.makeev_local 			void* stackTop;
5802d170cfSs.makeev_local 
5902d170cfSs.makeev_local 			char* stackMemory;
6002d170cfSs.makeev_local 			size_t stackMemoryBytesCount;
6102d170cfSs.makeev_local 
6202d170cfSs.makeev_local 
StackDescMemory::StackDesc6302d170cfSs.makeev_local 			StackDesc()
6402d170cfSs.makeev_local 				: stackBottom(nullptr)
6502d170cfSs.makeev_local 				, stackTop(nullptr)
6602d170cfSs.makeev_local 				, stackMemory(nullptr)
6702d170cfSs.makeev_local 				, stackMemoryBytesCount(0)
6802d170cfSs.makeev_local 			{
6902d170cfSs.makeev_local 			}
7002d170cfSs.makeev_local 
GetStackSizeMemory::StackDesc7102d170cfSs.makeev_local 			size_t GetStackSize()
7202d170cfSs.makeev_local 			{
7302d170cfSs.makeev_local 				return (char*)stackTop - (char*)stackBottom;
7402d170cfSs.makeev_local 			}
7502d170cfSs.makeev_local 		};
7602d170cfSs.makeev_local 
7702d170cfSs.makeev_local 
7802d170cfSs.makeev_local 		static void* Alloc(size_t size, size_t align = MT_DEFAULT_ALIGN);
7902d170cfSs.makeev_local 		static void Free(void* p);
8002d170cfSs.makeev_local 
8102d170cfSs.makeev_local 		static StackDesc AllocStack(size_t size);
8202d170cfSs.makeev_local 		static void FreeStack(const StackDesc & desc);
8302d170cfSs.makeev_local 	};
8402d170cfSs.makeev_local 
8502d170cfSs.makeev_local 
8602d170cfSs.makeev_local 	struct Diagnostic
8702d170cfSs.makeev_local 	{
88721f8c0bSs.makeev_local 		MT_NORETURN static void ReportAssert(const char* condition, const char* description, const char* sourceFile, int sourceLine);
8902d170cfSs.makeev_local 	};
9002d170cfSs.makeev_local 
9102d170cfSs.makeev_local 
9202d170cfSs.makeev_local }
93