/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #include #include #include void __gh_set_errno(int err); /******************************************************************************/ /* void *sbrk (size_t size); */ /* Return a pointer to at least size bytes of contiguous read/write memory. */ /* The memory returned by sbrk on different calls need not be contiguous */ /* with each other (although they should be for compatibility with unix). */ /* */ /* Return -1 on an error and set errno = ENOMEM. */ /* */ /* sbrk is normally only called by malloc. */ /* */ /* WARNING: __ghs_alloc() relies on our contiguous algorithm and our */ /* behavior for size==0, which returns the next-available pointer. */ /******************************************************************************/ void *sbrk (size_t size) { /* don't need a lock as MEMAllocFromDefaultHeapEx() has it's own lock */ void *ret = NULL; if (size != 0) { ret = MEMAllocFromDefaultHeapEx(size,PPC_IO_BUFFER_ALIGN); } if (ret == NULL) { ret = (void *)-1; __gh_set_errno(ENOMEM); } return ret; } void *__ghs_alloc (int size, int align) { /* MEMAllocFromDefaultHeapEx() has it's own lock __ghsLock() not needed here */ return MEMAllocFromDefaultHeapEx(size, align); }