From 62f230ef44fea41314965fbb1169cf1977efa0f8 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 25 Jan 2017 20:03:22 -0800 Subject: [PATCH] common.cpp: Add the convenience function malloc_alignedPage(), which returns a 4KB page-aligned (for most systems) block of memory. --- desmume/src/common.cpp | 11 ++++++++++- desmume/src/common.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/desmume/src/common.cpp b/desmume/src/common.cpp index d8e2cde1c..413effdc5 100644 --- a/desmume/src/common.cpp +++ b/desmume/src/common.cpp @@ -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) diff --git a/desmume/src/common.h b/desmume/src/common.h index 4f7bd974c..cf3683f13 100644 --- a/desmume/src/common.h +++ b/desmume/src/common.h @@ -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