Skip to content

Commit

Permalink
Merge pull request #2032 from ghaerr/tinyprintf
Browse files Browse the repository at this point in the history
[libc] Add flush destructor function to tiny_printf.c
  • Loading branch information
ghaerr authored Sep 20, 2024
2 parents 797924d + e675aed commit d0ff130
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions elkscmd/lib/tiny_vfprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/rtinit.h>

static unsigned char bufout[80];
static unsigned char buferr[80];
Expand Down Expand Up @@ -49,6 +50,15 @@ FILE stderr[1] =
}
};

/* name clash with stdio/init.c if __stdio_fini name used */
#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
DESTRUCTOR(__exit_flush, _INIT_PRI_STDIO);
void __exit_flush(void)
{
fflush(stdout);
fflush(stderr);
}

int fflush(FILE *fp)
{
int len;
Expand Down

0 comments on commit d0ff130

Please sign in to comment.