Merge branch 'master' of github.com:smealum/ctrulib
This commit is contained in:
commit
6ddf5320e7
@ -7,7 +7,7 @@ all: examples
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
@rm -fr bin
|
@rm -fr bin
|
||||||
@mkdir -p bin
|
@mkdir -p bin
|
||||||
@find . -name "*.3dsx" -exec cp -fv {} bin \;
|
@find . -name "*.3dsx" ! -path "./bin/*" -exec cp -fv {} bin \;
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||||
|
@ -161,7 +161,7 @@ $(OUTPUT).elf : $(OFILES)
|
|||||||
%_vsh.h %.vsh.o : %.vsh
|
%_vsh.h %.vsh.o : %.vsh
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
@python3 $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||||
|
@ -9,8 +9,8 @@ endif
|
|||||||
include $(DEVKITARM)/base_rules
|
include $(DEVKITARM)/base_rules
|
||||||
|
|
||||||
export LIBCTRU_MAJOR := 0
|
export LIBCTRU_MAJOR := 0
|
||||||
export LIBCTRU_MINOR := 4
|
export LIBCTRU_MINOR := 5
|
||||||
export LIBCTRU_PATCH := 1
|
export LIBCTRU_PATCH := 0
|
||||||
|
|
||||||
|
|
||||||
VERSION := $(LIBCTRU_MAJOR).$(LIBCTRU_MINOR).$(LIBCTRU_PATCH)
|
VERSION := $(LIBCTRU_MAJOR).$(LIBCTRU_MINOR).$(LIBCTRU_PATCH)
|
||||||
@ -107,7 +107,7 @@ dist-bin: all
|
|||||||
@tar -cjf libctru-$(VERSION).tar.bz2 include lib default_icon.png
|
@tar -cjf libctru-$(VERSION).tar.bz2 include lib default_icon.png
|
||||||
|
|
||||||
dist-src:
|
dist-src:
|
||||||
@tar -cjf libctru-src-$(VERSION).tar.bz2 include source Makefile Doxyfile Doxyfile.internal default_icon.png
|
@tar -cjf libctru-src-$(VERSION).tar.bz2 include source data Makefile Doxyfile Doxyfile.internal default_icon.png
|
||||||
|
|
||||||
dist: dist-src dist-bin
|
dist: dist-src dist-bin
|
||||||
|
|
||||||
|
@ -32,14 +32,34 @@ void MemPool::CoalesceRight(MemBlock* b)
|
|||||||
|
|
||||||
bool MemPool::Allocate(MemChunk& chunk, u32 size, int align)
|
bool MemPool::Allocate(MemChunk& chunk, u32 size, int align)
|
||||||
{
|
{
|
||||||
int alignM = (1 << align) - 1;
|
// Don't shift out of bounds (CERT INT34-C)
|
||||||
size = (size + alignM) &~ alignM; // Round the size
|
if(align >= 32 || align < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Alignment must not be 0
|
||||||
|
if(align == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
u32 alignMask = (1 << align) - 1;
|
||||||
|
|
||||||
|
// Check if size doesn't fit neatly in alignment
|
||||||
|
if(size & alignMask)
|
||||||
|
{
|
||||||
|
// Make sure addition won't overflow (CERT INT30-C)
|
||||||
|
if(size > UINT32_MAX - alignMask)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Pad size to next alignment
|
||||||
|
size = (size + alignMask) &~ alignMask;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the first suitable block
|
// Find the first suitable block
|
||||||
for (auto b = first; b; b = b->next)
|
for (auto b = first; b; b = b->next)
|
||||||
{
|
{
|
||||||
auto addr = b->base;
|
auto addr = b->base;
|
||||||
u32 begWaste = (u32)addr & alignM;
|
u32 begWaste = (u32)addr & alignMask;
|
||||||
if (begWaste > 0) begWaste = alignM + 1 - begWaste;
|
if (begWaste > 0) begWaste = alignMask + 1 - begWaste;
|
||||||
|
if (begWaste > b->size) continue;
|
||||||
addr += begWaste;
|
addr += begWaste;
|
||||||
u32 bSize = b->size - begWaste;
|
u32 bSize = b->size - begWaste;
|
||||||
if (bSize < size) continue;
|
if (bSize < size) continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user