Merge branch 'master' of github.com:smealum/ctrulib
This commit is contained in:
commit
6ddf5320e7
@ -7,7 +7,7 @@ all: examples
|
||||
#---------------------------------------------------------------------------------
|
||||
@rm -fr bin
|
||||
@mkdir -p bin
|
||||
@find . -name "*.3dsx" -exec cp -fv {} bin \;
|
||||
@find . -name "*.3dsx" ! -path "./bin/*" -exec cp -fv {} bin \;
|
||||
|
||||
examples:
|
||||
@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
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@python3 $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@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 . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
|
@ -9,8 +9,8 @@ endif
|
||||
include $(DEVKITARM)/base_rules
|
||||
|
||||
export LIBCTRU_MAJOR := 0
|
||||
export LIBCTRU_MINOR := 4
|
||||
export LIBCTRU_PATCH := 1
|
||||
export LIBCTRU_MINOR := 5
|
||||
export LIBCTRU_PATCH := 0
|
||||
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
@ -32,14 +32,34 @@ void MemPool::CoalesceRight(MemBlock* b)
|
||||
|
||||
bool MemPool::Allocate(MemChunk& chunk, u32 size, int align)
|
||||
{
|
||||
int alignM = (1 << align) - 1;
|
||||
size = (size + alignM) &~ alignM; // Round the size
|
||||
// Don't shift out of bounds (CERT INT34-C)
|
||||
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
|
||||
for (auto b = first; b; b = b->next)
|
||||
{
|
||||
auto addr = b->base;
|
||||
u32 begWaste = (u32)addr & alignM;
|
||||
if (begWaste > 0) begWaste = alignM + 1 - begWaste;
|
||||
u32 begWaste = (u32)addr & alignMask;
|
||||
if (begWaste > 0) begWaste = alignMask + 1 - begWaste;
|
||||
if (begWaste > b->size) continue;
|
||||
addr += begWaste;
|
||||
u32 bSize = b->size - begWaste;
|
||||
if (bSize < size) continue;
|
||||
|
Loading…
Reference in New Issue
Block a user