aboutsummaryrefslogtreecommitdiff
path: root/source/nds/dma_adj.c
diff options
context:
space:
mode:
authorNebuleon Fumika2013-02-08 05:50:22 -0500
committerNebuleon Fumika2013-02-08 05:50:22 -0500
commit927d456306672110870eb3386742c1c1ef8eb4f6 (patch)
tree509da9ac1727570b02572068aefb9cdf102ad75b /source/nds/dma_adj.c
parent433749b6ef1e2b070755c3bb7fc0d81b5ecaa7b1 (diff)
parentd4fcf2697c9a45594e3ee0b8bf82e480ddd0b69b (diff)
downloadsnes9x2005-927d456306672110870eb3386742c1c1ef8eb4f6.tar.gz
snes9x2005-927d456306672110870eb3386742c1c1ef8eb4f6.tar.bz2
snes9x2005-927d456306672110870eb3386742c1c1ef8eb4f6.zip
Merge branch 'master' into 8bitsound
Conflicts: source/nds/entry.cpp
Diffstat (limited to 'source/nds/dma_adj.c')
-rw-r--r--source/nds/dma_adj.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/nds/dma_adj.c b/source/nds/dma_adj.c
new file mode 100644
index 0000000..8b6f9ad
--- /dev/null
+++ b/source/nds/dma_adj.c
@@ -0,0 +1,26 @@
+#include "ds2_malloc.h"
+#include "dma_adj.h"
+
+#ifdef DS2_DMA
+
+struct SPointerAdjustments PtrAdj;
+
+void* AlignedMalloc (unsigned int Size, unsigned int Alignment, unsigned int* Adjustment)
+{
+ if (Alignment == 0) Alignment = 1;
+
+ unsigned char* result = (unsigned char*) malloc(Size + Alignment);
+ if (!result) {
+ return result;
+ } else {
+ *Adjustment = Alignment - ((unsigned int) result & (Alignment - 1));
+ return (void*) (result + *Adjustment);
+ }
+}
+
+void AlignedFree (void* Memory, unsigned int Adjustment)
+{
+ free((void*) ((unsigned char*) Memory - Adjustment));
+}
+
+#endif // DS2_DMA