summaryrefslogtreecommitdiffstatshomepage
path: root/teensy/malloc0.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-06 14:32:56 -0800
committerDamien George <damien.p.george@gmail.com>2014-01-06 14:32:56 -0800
commit880ce2d7fabc127b4bca7b6f2ea8b82d0977045f (patch)
treefeb4fc084bbba429cd4dd52a690577d80c6b4de6 /teensy/malloc0.c
parentff07bb3adb50481d6b7be94755e07df893f374dc (diff)
parent297446e7af472f8869ecca67f37ed159d02b1024 (diff)
downloadmicropython-880ce2d7fabc127b4bca7b6f2ea8b82d0977045f.tar.gz
micropython-880ce2d7fabc127b4bca7b6f2ea8b82d0977045f.zip
Merge pull request #97 from dhylands/teensy-3.1
Initial support for Teensy 3.1
Diffstat (limited to 'teensy/malloc0.c')
-rw-r--r--teensy/malloc0.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/teensy/malloc0.c b/teensy/malloc0.c
new file mode 100644
index 0000000000..1a6cb708e8
--- /dev/null
+++ b/teensy/malloc0.c
@@ -0,0 +1,57 @@
+#include <stdint.h>
+#include "std.h"
+#include "mpconfig.h"
+#include "gc.h"
+
+#if 0
+static uint32_t mem = 0;
+
+void *malloc(size_t n) {
+ if (mem == 0) {
+ extern uint32_t _heap_start;
+ mem = (uint32_t)&_heap_start; // need to use big ram block so we can execute code from it (is it true that we can't execute from CCM?)
+ }
+ void *ptr = (void*)mem;
+ mem = (mem + n + 3) & (~3);
+ if (mem > 0x20000000 + 0x18000) {
+ void __fatal_error(const char*);
+ __fatal_error("out of memory");
+ }
+ return ptr;
+}
+
+void free(void *ptr) {
+}
+
+void *realloc(void *ptr, size_t n) {
+ return malloc(n);
+}
+
+#endif
+
+void *calloc(size_t sz, size_t n) {
+ char *ptr = malloc(sz * n);
+ for (int i = 0; i < sz * n; i++) {
+ ptr[i] = 0;
+ }
+ return ptr;
+}
+
+void *malloc(size_t n) {
+ void *m = gc_alloc(n);
+ return m;
+}
+
+void free(void *ptr) {
+ gc_free(ptr);
+}
+
+void *realloc(void *ptr, size_t n) {
+ return gc_realloc(ptr, n);
+}
+
+void __assert_func(void) {
+ printf("\nASSERT FAIL!");
+ for (;;) {
+ }
+}