forked from espressif/esp-idf
Merge branch 'feature/newlib_fsync_without_vfs' into 'master'
newlib: implement fsync for the case of CONFIG_VFS_SUPPORT_IO=0 See merge request espressif/esp-idf!21390
This commit is contained in:
@@ -73,6 +73,22 @@ static ssize_t _fstat_r_console(struct _reent *r, int fd, struct stat * st)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _fsync_console(int fd)
|
||||||
|
{
|
||||||
|
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||||
|
#ifdef CONFIG_ESP_CONSOLE_UART
|
||||||
|
esp_rom_uart_flush_tx(CONFIG_ESP_CONSOLE_UART_NUM);
|
||||||
|
#elif defined(CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG)
|
||||||
|
esp_rom_uart_flush_tx(CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM);
|
||||||
|
#elif defined(CONFIG_ESP_CONSOLE_USB_CDC)
|
||||||
|
esp_rom_uart_flush_tx(CONFIG_ESP_ROM_USB_OTG_NUM);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The following weak definitions of syscalls will be used unless
|
/* The following weak definitions of syscalls will be used unless
|
||||||
* another definition is provided. That definition may come from
|
* another definition is provided. That definition may come from
|
||||||
@@ -84,6 +100,8 @@ ssize_t _write_r(struct _reent *r, int fd, const void * data, size_t size)
|
|||||||
__attribute__((weak,alias("_write_r_console")));
|
__attribute__((weak,alias("_write_r_console")));
|
||||||
int _fstat_r (struct _reent *r, int fd, struct stat *st)
|
int _fstat_r (struct _reent *r, int fd, struct stat *st)
|
||||||
__attribute__((weak,alias("_fstat_r_console")));
|
__attribute__((weak,alias("_fstat_r_console")));
|
||||||
|
int fsync(int fd)
|
||||||
|
__attribute__((weak,alias("_fsync_console")));
|
||||||
|
|
||||||
|
|
||||||
/* The aliases below are to "syscall_not_implemented", which
|
/* The aliases below are to "syscall_not_implemented", which
|
||||||
|
@@ -27,6 +27,7 @@ void die(const char* msg)
|
|||||||
{
|
{
|
||||||
printf("Test error: %s\n\n", msg);
|
printf("Test error: %s\n\n", msg);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
fsync(fileno(stdout));
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
/* Don't use abort here as it would enter the panic handler */
|
/* Don't use abort here as it would enter the panic handler */
|
||||||
esp_restart_noos();
|
esp_restart_noos();
|
||||||
|
Reference in New Issue
Block a user