本文整理汇总了C++中BlockAllocator类的典型用法代码示例。如果您正苦于以下问题:C++ BlockAllocator类的具体用法?C++ BlockAllocator怎么用?C++ BlockAllocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlockAllocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
Fixture* Body::CreateFixture(const FixtureDef* def)
{
assert(m_world->IsLocked() == false);
if (m_world->IsLocked() == true)
{
return NULL;
}
BlockAllocator* allocator = &m_world->m_blockAllocator;
void* memory = allocator->Allocate(sizeof(Fixture));
Fixture* fixture = new (memory) Fixture;
fixture->Create(allocator, this, def);
if (m_flags & activeFlag)
{
BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
fixture->CreateProxies(broadPhase, m_xf);
}
fixture->m_next = m_fixtureList;
m_fixtureList = fixture;
++m_fixtureCount;
fixture->m_body = this;
// Adjust mass properties if needed.
if (fixture->m_density > 0.0f)
{
ResetMassData();
}
// Let the world know we have a new fixture. This will cause new contacts
// to be created at the beginning of the next time step.
m_world->m_flags |= World::newFixture;
return fixture;
}
示例2: __KernelMemoryDoState
void __KernelMemoryDoState(PointerWrap &p)
{
kernelMemory.DoState(p);
userMemory.DoState(p);
p.Do(vplWaitTimer);
CoreTiming::RestoreRegisterEvent(vplWaitTimer, "VplTimeout", __KernelVplTimeout);
p.DoMarker("sceKernelMemory");
}
示例3: __KernelMemoryInit
void __KernelMemoryInit()
{
kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd()-PSP_GetKernelMemoryBase());
userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd()-PSP_GetUserMemoryBase());
INFO_LOG(HLE, "Kernel and user memory pools initialized");
vplWaitTimer = CoreTiming::RegisterEvent("VplTimeout", __KernelVplTimeout);
}
示例4: FreeMemoryBlock
u32 FreeMemoryBlock(u32 uid) {
INFO_LOG(HLE, "FreeMemoryBlock(%08x)", uid);
u32 blockPtr = userMemory.GetBlockStartFromAddress(uid);
if (!blockPtr) {
return SCE_KERNEL_ERROR_UNKNOWN_UID;
}
userMemory.Free(blockPtr);
return 0;
}
示例5: __KernelMemoryShutdown
void __KernelMemoryShutdown()
{
INFO_LOG(HLE,"Shutting down user memory pool: ");
userMemory.ListBlocks();
userMemory.Shutdown();
INFO_LOG(HLE,"Shutting down \"kernel\" memory pool: ");
kernelMemory.ListBlocks();
kernelMemory.Shutdown();
}
示例6: __KernelMemoryInit
void __KernelMemoryInit()
{
kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd()-PSP_GetKernelMemoryBase());
userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd()-PSP_GetUserMemoryBase());
INFO_LOG(HLE, "Kernel and user memory pools initialized");
vplWaitTimer = CoreTiming::RegisterEvent("VplTimeout", __KernelVplTimeout);
flags_ = 0;
sdkVersion_ = 0;
compilerVersion_ = 0;
memset(tlsUsedIndexes, 0, sizeof(tlsUsedIndexes));
}
示例7: __KernelMemoryDoState
void __KernelMemoryDoState(PointerWrap &p)
{
kernelMemory.DoState(p);
userMemory.DoState(p);
p.Do(vplWaitTimer);
CoreTiming::RestoreRegisterEvent(vplWaitTimer, "VplTimeout", __KernelVplTimeout);
p.Do(flags_);
p.Do(sdkVersion_);
p.Do(compilerVersion_);
p.DoArray(tlsUsedIndexes, ARRAY_SIZE(tlsUsedIndexes));
p.DoMarker("sceKernelMemory");
}
示例8: sceKernelMaxFreeMemSize
void sceKernelMaxFreeMemSize()
{
// TODO: Fudge factor improvement
u32 retVal = userMemory.GetLargestFreeBlockSize()-0x40000;
DEBUG_LOG(HLE,"%08x (dec %i)=sceKernelMaxFreeMemSize",retVal,retVal);
RETURN(retVal);
}
示例9: GetMemoryBlockPtr
u32 GetMemoryBlockPtr(u32 uid, u32 addr) {
INFO_LOG(HLE, "GetMemoryBlockPtr(%08x, %08x)", uid, addr);
u32 blockPtr = userMemory.GetBlockStartFromAddress(uid);
if (!blockPtr) {
return SCE_KERNEL_ERROR_UNKNOWN_UID;
}
Memory::Write_U32(blockPtr, addr);
return 0;
}
示例10: AllocMemoryBlock
u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAddr) {
// Just support allocating a block in the user region.
u32 blockPtr = userMemory.Alloc(size, type == 1, pname);
INFO_LOG(HLE,"%08x=AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %08x, %08x)", blockPtr, pname, type, size, paramsAddr);
// Create a UID object??? Nah, let's just us the UID itself (hack!)
return blockPtr;
}
示例11: sceKernelDeleteTls
// Parameters are an educated guess.
int sceKernelDeleteTls(SceUID uid)
{
WARN_LOG(HLE, "sceKernelDeleteTls(%08x)", uid);
u32 error;
TLS *tls = kernelObjects.Get<TLS>(uid, error);
if (tls)
{
// TODO: Wake waiting threads, probably?
userMemory.Free(tls->address);
tlsUsedIndexes[tls->ntls.index] = false;
kernelObjects.Destroy<TLS>(uid);
}
return error;
}
示例12: sceKernelDeleteFpl
void sceKernelDeleteFpl()
{
SceUID id = PARAM(0);
u32 error;
FPL *fpl = kernelObjects.Get<FPL>(id, error);
if (fpl)
{
userMemory.Free(fpl->address);
DEBUG_LOG(HLE,"sceKernelDeleteFpl(%i)", id);
RETURN(kernelObjects.Destroy<FPL>(id));
}
else
{
RETURN(error);
}
}
示例13: sceKernelDeleteVpl
int sceKernelDeleteVpl(SceUID uid)
{
DEBUG_LOG(HLE, "sceKernelDeleteVpl(%i)", uid);
u32 error;
VPL *vpl = kernelObjects.Get<VPL>(uid, error);
if (vpl)
{
bool wokeThreads = __KernelClearVplThreads(vpl, SCE_KERNEL_ERROR_WAIT_DELETE);
if (wokeThreads)
hleReSchedule("vpl deleted");
userMemory.Free(vpl->address);
kernelObjects.Destroy<VPL>(uid);
return 0;
}
else
return error;
}
示例14: sceKernelCreateFpl
//sceKernelCreateFpl(const char *name, SceUID mpid, SceUint attr, SceSize blocksize, int numBlocks, optparam)
void sceKernelCreateFpl()
{
const char *name = Memory::GetCharPointer(PARAM(0));
u32 mpid = PARAM(1);
u32 attr = PARAM(2);
u32 blockSize = PARAM(3);
u32 numBlocks = PARAM(4);
u32 totalSize = blockSize * numBlocks;
bool atEnd = false; // attr can change this I think
u32 address = userMemory.Alloc(totalSize, atEnd, "FPL");
if (address == (u32)-1)
{
DEBUG_LOG(HLE,"sceKernelCreateFpl(\"%s\", partition=%i, attr=%i, bsize=%i, nb=%i) FAILED - out of ram",
name, mpid, attr, blockSize, numBlocks);
RETURN(SCE_KERNEL_ERROR_NO_MEMORY);
return;
}
FPL *fpl = new FPL;
SceUID id = kernelObjects.Create(fpl);
strncpy(fpl->nf.name, name, 32);
fpl->nf.size = sizeof(fpl->nf);
fpl->nf.mpid = mpid; // partition
fpl->nf.attr = attr;
fpl->nf.blocksize = blockSize;
fpl->nf.numBlocks = numBlocks;
fpl->nf.numWaitThreads = 0;
fpl->blocks = new bool[fpl->nf.numBlocks];
memset(fpl->blocks, 0, fpl->nf.numBlocks * sizeof(bool));
fpl->address = address;
DEBUG_LOG(HLE,"%i=sceKernelCreateFpl(\"%s\", partition=%i, attr=%i, bsize=%i, nb=%i)",
id, name, mpid, attr, blockSize, numBlocks);
RETURN(id);
}
示例15: AllocMemoryBlock
u32 AllocMemoryBlock(const char *pname, u32 type, u32 size, u32 paramsAddr) {
// Just support allocating a block in the user region.
if (paramsAddr) {
u32 length = Memory::Read_U32(paramsAddr);
if (length != 4) {
WARN_LOG(HLE, "AllockMemoryBlock(SysMemUserForUser_FE707FDF) : unknown parameters with length %d", length);
}
}
if (type < 0 || type > 1) {
return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE;
}
u32 blockPtr = userMemory.Alloc(size, type == 1, pname);
if (!blockPtr) {
return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED;
}
INFO_LOG(HLE,"%08x=AllocMemoryBlock(SysMemUserForUser_FE707FDF)(%s, %i, %08x, %08x)", blockPtr, pname, type, size, paramsAddr);
// Create a UID object??? Nah, let's just us the UID itself (hack!)
return blockPtr;
}