aboutsummaryrefslogtreecommitdiff
path: root/stm
diff options
context:
space:
mode:
authorDamien George2014-02-11 21:42:09 +0000
committerDamien George2014-02-11 21:42:09 +0000
commit323f39a2b383ba1f4b65f5cd786a2531589d1677 (patch)
treeb1c589947293ee36e00a1fe6813b5feb710126a9 /stm
parent0d14d1301667132ea12ae37ff8fe8b04842a69f1 (diff)
parent723a6ed37175fcade87802c8ab44325971446020 (diff)
Merge pull request #278 from pfalcon/unix-gc
Enable GC for Unix port
Diffstat (limited to 'stm')
-rw-r--r--stm/malloc0.c12
-rw-r--r--stm/mpconfigport.h8
-rw-r--r--stm/std.h4
3 files changed, 8 insertions, 16 deletions
diff --git a/stm/malloc0.c b/stm/malloc0.c
index eaa436f4f..85a643f72 100644
--- a/stm/malloc0.c
+++ b/stm/malloc0.c
@@ -29,18 +29,6 @@ void *realloc(void *ptr, size_t n) {
#endif
-void *malloc(size_t n) {
- return gc_alloc(n);
-}
-
-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 (;;) {
diff --git a/stm/mpconfigport.h b/stm/mpconfigport.h
index fd7af29d2..1d79243f9 100644
--- a/stm/mpconfigport.h
+++ b/stm/mpconfigport.h
@@ -21,6 +21,14 @@ typedef float machine_float_t;
machine_float_t machine_sqrt(machine_float_t x);
+// There is no classical C heap in bare-metal ports, only Python
+// garbage-collected heap. For completeness, emulate C heap via
+// GC heap. Note that MicroPython core never uses malloc() and friends,
+// so these defines are mostly to help extension module writers.
+#define malloc gc_alloc
+#define free gc_free
+#define realloc gc_realloc
+
// board specific definitions
// choose 1 of these boards
diff --git a/stm/std.h b/stm/std.h
index a2bf70617..843ddd827 100644
--- a/stm/std.h
+++ b/stm/std.h
@@ -2,10 +2,6 @@ typedef unsigned int size_t;
void __assert_func(void);
-void *malloc(size_t n);
-void free(void *ptr);
-void *realloc(void *ptr, size_t n);
-
void *memcpy(void *dest, const void *src, size_t n);
void *memmove(void *dest, const void *src, size_t n);
void *memset(void *s, int c, size_t n);