diff options
author | Tim Schumacher <timschumi@gmx.de> | 2021-05-26 10:06:36 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-30 14:56:50 +0100 |
commit | ccef5fe23464a8048e5bb66a4bbbad34aa7c38bd (patch) | |
tree | 4825f8a26a0ec56a7b2bd0cd84b4456fb67f9053 /Userland | |
parent | cd970928a0779219655d5bdaf46cf32f8c865b23 (diff) | |
download | serenity-ccef5fe23464a8048e5bb66a4bbbad34aa7c38bd.zip |
LibC: Implement __fpurge
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibC/stdio.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibC/stdio_ext.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp index 6eca1a2bb0..b33e308141 100644 --- a/Userland/Libraries/LibC/stdio.cpp +++ b/Userland/Libraries/LibC/stdio.cpp @@ -40,6 +40,7 @@ public: void setbuf(u8* data, int mode, size_t size) { m_buffer.setbuf(data, mode, size); } bool flush(); + void purge(); bool close(); int fileno() const { return m_fd; } @@ -192,6 +193,11 @@ bool FILE::flush() return true; } +void FILE::purge() +{ + m_buffer.drop(); +} + ssize_t FILE::do_read(u8* data, size_t size) { int nread = ::read(m_fd, data, size); @@ -1323,4 +1329,10 @@ int __fwriting(FILE* stream) return (stream->flags() & FILE::Flags::LastWrite); } + +void __fpurge(FILE* stream) +{ + ScopedFileLock lock(stream); + stream->purge(); +} } diff --git a/Userland/Libraries/LibC/stdio_ext.h b/Userland/Libraries/LibC/stdio_ext.h index f9f8b5a18b..5b22fb4358 100644 --- a/Userland/Libraries/LibC/stdio_ext.h +++ b/Userland/Libraries/LibC/stdio_ext.h @@ -12,5 +12,6 @@ __BEGIN_DECLS int __freading(FILE*); int __fwriting(FILE*); +void __fpurge(FILE*); __END_DECLS |