1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: test_New.cpp 4 5 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 24216 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include <nn/svc.h> 17 #include <nn/Result.h> 18 #include <nn/init.h> 19 #include <nn/config.h> 20 #include <nn/assert.h> 21 #include <nn/util/util_Result.h> 22 #include <nn/fnd/fnd_ExpHeap.h> 23 #include <nn/os/os_MemoryMapSelect.h> 24 #include <nn/os/os_MemoryBlock.h> 25 #include <stdlib.h> 26 27 #include <new> 28 29 namespace nn{ namespace test{ 30 InitializeAllocator(size_t size)31 void InitializeAllocator(size_t size) 32 { 33 #if NN_PLATFORM_HAS_MMU 34 nn::os::SetupHeapForMemoryBlock( size ); 35 nn::init::InitializeAllocator( size/2 ); 36 #else 37 NN_UNUSED_VAR(size); 38 #endif 39 } 40 }} 41 42 43 namespace nn { namespace drivers { namespace fnd { AllocateBuffer(size_t requiredSize,size_t idealSize)44 extern nn::fnd::MemoryRange AllocateBuffer(size_t requiredSize, size_t idealSize) 45 { 46 NN_UNUSED_VAR(idealSize); 47 void* p = malloc(requiredSize); 48 NN_TASSERT_(p); 49 uptr begin = reinterpret_cast<uptr>(p); 50 return nn::fnd::MemoryRange(begin, begin + requiredSize); 51 } 52 DeallocateBuffer(const nn::fnd::MemoryRange & memoryRange)53 extern void DeallocateBuffer(const nn::fnd::MemoryRange& memoryRange) 54 { 55 free(reinterpret_cast<void*>(memoryRange.GetAddress())); 56 } 57 58 // 比較的小さいオブジェクトをアロケートする AllocateSmall(size_t size)59 extern void* AllocateSmall(size_t size) 60 { 61 return malloc(size); 62 } DeallocateSmall(void * p,size_t)63 extern void DeallocateSmall(void* p, size_t) 64 { 65 free(p); 66 } 67 }}} 68