common.cpp: Add the convenience function malloc_alignedPage(), which returns a 4KB page-aligned (for most systems) block of memory.

This commit is contained in:
rogerman 2017-01-25 20:03:22 -08:00
parent 53c4a27aef
commit 62f230ef44
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2008-2015 DeSmuME team
Copyright (C) 2008-2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -114,6 +114,15 @@ void* malloc_alignedCacheLine(size_t length)
#endif
}
void* malloc_alignedPage(size_t length)
{
// WARNING!
//
// This may fail for SPARC users, which have a page size
// of 8KB instead of the more typical 4KB.
return malloc_aligned(length, 4096);
}
void free_aligned(void *ptr)
{
if (ptr == NULL)

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2008-2016 DeSmuME team
Copyright (C) 2008-2017 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -49,6 +49,7 @@ void* malloc_aligned16(size_t length);
void* malloc_aligned32(size_t length);
void* malloc_aligned64(size_t length);
void* malloc_alignedCacheLine(size_t length);
void* malloc_alignedPage(size_t length);
void free_aligned(void *ptr);
#endif