cpu/esp32: use always newlib_syscalls_default
Modules newlib and newlib_syscalls_default are now used by default. Conditional compilations for MODULE_NEWLIB_SYSCALLS_DEFAULT as well as alternative code are removed completely.
This commit is contained in:
parent
f483988ae9
commit
87cd181f56
@ -68,7 +68,7 @@ USEMODULE += esp_idf_driver
|
||||
USEMODULE += esp_idf_esp32
|
||||
USEMODULE += esp_idf_soc
|
||||
USEMODULE += log
|
||||
USEMODULE += newlib_syscalls_default
|
||||
USEMODULE += newlib
|
||||
USEMODULE += periph
|
||||
USEMODULE += periph_adc_ctrl
|
||||
USEMODULE += periph_hwrng
|
||||
|
||||
@ -294,16 +294,12 @@ static NORETURN void IRAM system_init (void)
|
||||
/* init random number generator */
|
||||
srand(hwrand());
|
||||
|
||||
#if defined(MODULE_NEWLIB_SYSCALLS_DEFAULT)
|
||||
/*
|
||||
* initialization as it should be called from newlibc (includes the
|
||||
* execution of stdio_init)
|
||||
*/
|
||||
extern void _init(void);
|
||||
_init();
|
||||
#elif defined(MODULE_STDIO_UART)
|
||||
stdio_init();
|
||||
#endif
|
||||
|
||||
/* add SPI RAM to heap if enabled */
|
||||
#if CONFIG_SPIRAM_SUPPORT && CONFIG_SPIRAM_BOOT_INIT
|
||||
|
||||
@ -273,15 +273,6 @@ void* IRAM_ATTR __wrap__calloc_r(struct _reent *r, size_t count, size_t size)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef MODULE_NEWLIB_SYSCALLS_DEFAULT
|
||||
/* this should not happen when MODULE_ESP_IDF_HEAP is activated since heap_caps
|
||||
doesn't use _sbrk_r to allocate memory blocks */
|
||||
void* _sbrk_r (struct _reent *r, ptrdiff_t sz)
|
||||
{
|
||||
_exit(ENOSYS);
|
||||
}
|
||||
#endif /* MODULE_NEWLIB_SYSCALLS_DEFAULT */
|
||||
|
||||
#else /* MODULE_ESP_IDF_HEAP */
|
||||
|
||||
/* for compatibiliy with ESP-IDF heap functions */
|
||||
@ -304,48 +295,8 @@ void* IRAM heap_caps_realloc( void *ptr, size_t size )
|
||||
|
||||
extern uint8_t _eheap; /* end of heap (defined in esp32.common.ld) */
|
||||
extern uint8_t _sheap; /* start of heap (defined in esp32.common.ld) */
|
||||
extern uint8_t *heap_top; /* current top of heap as defined in newlib_syscalls_default */
|
||||
|
||||
#ifdef MODULE_NEWLIB_SYSCALLS_DEFAULT
|
||||
|
||||
extern uint8_t *heap_top;
|
||||
#define _cheap heap_top
|
||||
|
||||
#else /* MODULE_NEWLIB_SYSCALLS_DEFAULT */
|
||||
|
||||
static uint8_t* _cheap = 0; /* last allocated chunk of heap */
|
||||
|
||||
void* IRAM _sbrk_r (struct _reent *r, ptrdiff_t incr)
|
||||
{
|
||||
uint8_t* _cheap_old;
|
||||
|
||||
/* initial _cheap */
|
||||
if (_cheap == NULL) {
|
||||
_cheap = &_sheap;
|
||||
}
|
||||
|
||||
/* save old _cheap */
|
||||
_cheap_old = _cheap;
|
||||
|
||||
/* check whether _cheap + incr overflows the heap */
|
||||
if (_cheap + incr >= &_eheap) {
|
||||
r->_errno = ENOMEM;
|
||||
return (caddr_t)-1;
|
||||
}
|
||||
|
||||
/* set new _cheap */
|
||||
_cheap += incr;
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
uint32_t remaining = &_eheap - _cheap;
|
||||
printf ("%s %i byte allocated in %p .. %p, remaining %u\n",
|
||||
__func__, incr, _cheap_old, _cheap, remaining);
|
||||
#endif
|
||||
|
||||
/* return allocated memory */
|
||||
return (caddr_t) _cheap_old;
|
||||
}
|
||||
|
||||
#endif /* MODULE_NEWLIB_SYSCALLS_DEFAULT */
|
||||
#endif /* MODULE_ESP_IDF_HEAP */
|
||||
|
||||
unsigned int IRAM get_free_heap_size (void)
|
||||
@ -353,7 +304,7 @@ unsigned int IRAM get_free_heap_size (void)
|
||||
#if MODULE_ESP_IDF_HEAP
|
||||
return heap_caps_get_free_size( MALLOC_CAP_DEFAULT );
|
||||
#else
|
||||
return &_eheap - ((_cheap) ? _cheap : &_sheap);
|
||||
return &_eheap - ((heap_top) ? heap_top : &_sheap);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -365,39 +316,6 @@ uint32_t esp_get_free_heap_size( void ) __attribute__((alias("get_free_heap_size
|
||||
* @name Other system functions
|
||||
*/
|
||||
|
||||
#ifndef MODULE_NEWLIB_SYSCALLS_DEFAULT
|
||||
|
||||
int _getpid_r(struct _reent *r)
|
||||
{
|
||||
return sched_active_pid;
|
||||
}
|
||||
|
||||
int _kill_r(struct _reent *r, int pid, int sig)
|
||||
{
|
||||
DEBUG("%s: system function not yet implemented\n", __func__);
|
||||
r->_errno = ESRCH; /* no such process */
|
||||
return -1;
|
||||
}
|
||||
|
||||
void _exit(int __status)
|
||||
{
|
||||
ets_printf("#! exit %d: powering off\n", __status);
|
||||
pm_off();
|
||||
while(1);
|
||||
}
|
||||
|
||||
clock_t IRAM_ATTR _times_r(struct _reent *r, struct tms *ptms)
|
||||
{
|
||||
ptms->tms_cstime = 0;
|
||||
ptms->tms_cutime = 0;
|
||||
ptms->tms_stime = system_get_time() / (US_PER_SEC / CLK_TCK);
|
||||
ptms->tms_utime = 0;
|
||||
|
||||
return ptms->tms_stime / MHZ;
|
||||
}
|
||||
|
||||
#endif /* MODULE_NEWLIB_SYSCALLS_DEFAULT */
|
||||
|
||||
void _abort(void)
|
||||
{
|
||||
ets_printf("#! abort called: powering off\n");
|
||||
@ -441,8 +359,8 @@ static struct syscall_stub_table s_stub_table =
|
||||
._kill_r = &_kill_r,
|
||||
|
||||
._times_r = &_times_r,
|
||||
#ifdef MODULE_NEWLIB_SYSCALLS_DEFAULT
|
||||
._gettimeofday_r = _gettimeofday_r,
|
||||
|
||||
._open_r = &_open_r,
|
||||
._close_r = &_close_r,
|
||||
._lseek_r = (int (*)(struct _reent *r, int, int, int))&_lseek_r,
|
||||
@ -451,17 +369,6 @@ static struct syscall_stub_table s_stub_table =
|
||||
._write_r = (int (*)(struct _reent *r, int, const void *, int))&_write_r,
|
||||
._read_r = (int (*)(struct _reent *r, int, void *, int))&_read_r,
|
||||
._unlink_r = &_unlink_r,
|
||||
#else /* MODULE_NEWLIB_SYSCALLS_DEFAULT */
|
||||
._gettimeofday_r = (int (*)(struct _reent *r, struct timeval *, void *))&_no_sys_func,
|
||||
._open_r = (int (*)(struct _reent *r, const char *, int, int))&_no_sys_func,
|
||||
._close_r = (int (*)(struct _reent *r, int))&_no_sys_func,
|
||||
._lseek_r = (int (*)(struct _reent *r, int, int, int))&_no_sys_func,
|
||||
._fstat_r = (int (*)(struct _reent *r, int, struct stat *))&_no_sys_func,
|
||||
._stat_r = (int (*)(struct _reent *r, const char*, struct stat *))&_no_sys_func,
|
||||
._write_r = (int (*)(struct _reent *r, int, const void *, int))&_no_sys_func,
|
||||
._read_r = (int (*)(struct _reent *r, int, void *, int))&_no_sys_func,
|
||||
._unlink_r = (int (*)(struct _reent *r, const char*))&_no_sys_func,
|
||||
#endif /* MODULE_NEWLIB_SYSCALLS_DEFAULT */
|
||||
._link_r = (int (*)(struct _reent *r, const char*, const char*))&_no_sys_func,
|
||||
._rename_r = (int (*)(struct _reent *r, const char*, const char*))&_no_sys_func,
|
||||
|
||||
@ -475,6 +382,7 @@ static struct syscall_stub_table s_stub_table =
|
||||
._lock_try_acquire_recursive = &_lock_try_acquire_recursive,
|
||||
._lock_release = &_lock_release,
|
||||
._lock_release_recursive = &_lock_release_recursive,
|
||||
|
||||
#if CONFIG_NEWLIB_NANO_FORMAT
|
||||
._printf_float = &_printf_float,
|
||||
._scanf_float = &_scanf_float,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user