summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-12-13 14:24:13 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-12-13 14:24:13 +0100
commitebd3e2890cad3fbc9b0293b91173995d191ee804 (patch)
tree1403948c291306274baa38f11b7a9f77a56fb809
parent6d8a58ae50c46531512ac6930d95f7ec2d6679c3 (diff)
mpmalloc
-rw-r--r--src/arch/msp430fr5994lp/Makefile.inc2
-rw-r--r--src/lib/mpmalloc.cc28
2 files changed, 29 insertions, 1 deletions
diff --git a/src/arch/msp430fr5994lp/Makefile.inc b/src/arch/msp430fr5994lp/Makefile.inc
index d82abc4..2dd0ff4 100644
--- a/src/arch/msp430fr5994lp/Makefile.inc
+++ b/src/arch/msp430fr5994lp/Makefile.inc
@@ -10,7 +10,7 @@ COMMON_FLAGS += -mcpu=${CPU} -mmcu=${MCU} -DMULTIPASS_ARCH_msp430fr5994lp
COMMON_FLAGS += -DMULTIPASS_ARCH_HAS_I2C
ifneq (${msp430_large}, )
- COMMON_FLAGS += -mcode-region=either -mlarge
+ COMMON_FLAGS += -mcode-region=either -mlarge -DADDR_20BIT
endif
# LTO seems to be broken.
diff --git a/src/lib/mpmalloc.cc b/src/lib/mpmalloc.cc
new file mode 100644
index 0000000..db4a87a
--- /dev/null
+++ b/src/lib/mpmalloc.cc
@@ -0,0 +1,28 @@
+#include <stdlib.h>
+#include "driver/stdout.h"
+#include "lib/mpmalloc.h"
+
+void* mpcalloc(size_t nmemb, size_t size) {
+ void* ret = calloc(nmemb, size);
+#ifdef ADDR_20BIT
+ kout << "calloc:" << dec << (uint32_t)nmemb << "x" << (uint32_t)size << "@" << ret << endl;
+#else
+ kout << "calloc:" << dec << nmemb << "x" << size << "@" << ret << endl;
+#endif
+ return ret;
+}
+
+void* mpmalloc(size_t size) {
+ void* ret = malloc(size);
+#ifdef ADDR_20BIT
+ kout << "malloc:" << dec << (uint32_t)size << "@" << ret << endl;
+#else
+ kout << "malloc:" << dec << size << "@" << ret << endl;
+#endif
+ return ret;
+}
+
+void mpfree(void* addr) {
+ kout << "free:" << addr << endl;
+ free(addr);
+}