Skip to content

Commit

Permalink
Use libc from newlib (#1752)
Browse files Browse the repository at this point in the history
* Use newlib libc library

This change adds libcmin.a, which is created from newlib libc by selectively removing some of the object files (mostly related to heap management).
The list of files is available in tools/sdk/lib/make_libcmin.sh. Files which are not needed are commented out.
This change adds support for various functions which were missing, like sscanf, strftime, etc.

* Fix some of the time functions

* Redirect stdout to serial

* Implement __putc_r

* Switch to custom newlib build

Built from https://github.com/igrr/newlib-xtensa using:
./configure --with-newlib --enable-multilib --disable-newlib-io-c99-formats --enable-newlib-supplied-syscalls --enable-target-optspace --program-transform-name="s&^&xtensa-lx106-elf-&" --disable-option-checking --with-target-subdir=xtensa-lx106-elf --target=xtensa-lx106-elf --enable-newlib-nano-formatted-io --enable-newlib-reent-small  --prefix=path-to-arduino-core/tools/sdk/libc
CROSS_CFLAGS="-DMALLOC_PROVIDED -DSIGNAL_PROVIDED -DABORT_PROVIDED" make
make install

* Update tests
  • Loading branch information
igrr authored Jun 23, 2016
1 parent d28c551 commit d7d98d0
Show file tree
Hide file tree
Showing 117 changed files with 14,937 additions and 565 deletions.
21 changes: 21 additions & 0 deletions cores/esp8266/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
#include <stdlib.h>
#include "umm_malloc/umm_malloc.h"
#include <c_types.h>
#include <sys/reent.h>

void* _malloc_r(struct _reent* unused, size_t size)
{
return malloc(size);
}

void _free_r(struct _reent* unused, void* ptr)
{
return free(ptr);
}

void* _realloc_r(struct _reent* unused, void* ptr, size_t size)
{
return realloc(ptr, size);
}

void* _calloc_r(struct _reent* unused, size_t count, size_t size)
{
return calloc(count, size);
}

void* ICACHE_RAM_ATTR pvPortMalloc(size_t size, const char* file, int line)
{
Expand Down
Loading

0 comments on commit d7d98d0

Please sign in to comment.