mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'fix/console_linux_target_mac' into 'master'
fix(linux): prevent build error on MacOS and optimize buffer usage on Linux See merge request espressif/esp-idf!29176
This commit is contained in:
commit
32ecb0411c
@ -107,7 +107,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdio_ext.h>
|
||||
#if !CONFIG_IDF_TARGET_LINUX
|
||||
// On Linux, we don't need __fbufsize (see comments below), and
|
||||
// __fbufsize not available on MacOS (which is also considered "Linux" target)
|
||||
#include <stdio_ext.h> // for __fbufsize
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -216,9 +220,14 @@ bool linenoiseIsDumbMode(void) {
|
||||
}
|
||||
|
||||
static void flushWrite(void) {
|
||||
// On Linux, we set stdout to unbuffered mode to facilitate interaction with tools.
|
||||
// Performance on Linux is not considered as critical as on chip targets. Additionally,
|
||||
// MacOS does not have __fbufsize.
|
||||
#if !CONFIG_IDF_TARGET_LINUX
|
||||
if (__fbufsize(stdout) > 0) {
|
||||
fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
fsync(fileno(stdout));
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,9 @@ static void main_task(void* args)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
// This makes sure that stdio is flushed after each '\n' so that idf.py monitor
|
||||
// reads the program output on time.
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
// This makes sure that stdio is always syncronized so that idf.py monitor
|
||||
// and other tools read text output on time.
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
|
||||
usleep(1000);
|
||||
BaseType_t res = xTaskCreatePinnedToCore(&main_task, "main",
|
||||
|
Loading…
Reference in New Issue
Block a user