diff --git a/libc/src/__support/File/file.h b/libc/src/__support/File/file.h --- a/libc/src/__support/File/file.h +++ b/libc/src/__support/File/file.h @@ -56,7 +56,6 @@ // file position indicator. using SeekFunc = ErrorOr(File *, long, int); using CloseFunc = int(File *); - using FlushFunc = int(File *); // CleanupFunc is a function which does the equivalent of this: // // void my_file_cleanup(File *f) { @@ -103,7 +102,6 @@ ReadFunc *platform_read; SeekFunc *platform_seek; CloseFunc *platform_close; - FlushFunc *platform_flush; CleanupFunc *platform_cleanup; Mutex mutex; @@ -202,15 +200,13 @@ // is zero. This way, we will not have to employ the semantics of // the set_buffer method and allocate a buffer. constexpr File(WriteFunc *wf, ReadFunc *rf, SeekFunc *sf, CloseFunc *cf, - FlushFunc *ff, CleanupFunc *clf, uint8_t *buffer, - size_t buffer_size, int buffer_mode, bool owned, - ModeFlags modeflags) + CleanupFunc *clf, uint8_t *buffer, size_t buffer_size, + int buffer_mode, bool owned, ModeFlags modeflags) : platform_write(wf), platform_read(rf), platform_seek(sf), - platform_close(cf), platform_flush(ff), platform_cleanup(clf), - mutex(false, false, false), ungetc_buf(0), buf(buffer), - bufsize(buffer_size), bufmode(buffer_mode), own_buf(owned), - mode(modeflags), pos(0), prev_op(FileOp::NONE), read_limit(0), - eof(false), err(false) { + platform_close(cf), platform_cleanup(clf), mutex(false, false, false), + ungetc_buf(0), buf(buffer), bufsize(buffer_size), bufmode(buffer_mode), + own_buf(owned), mode(modeflags), pos(0), prev_op(FileOp::NONE), + read_limit(0), eof(false), err(false) { if constexpr (ENABLE_BUFFER) adjust_buf(); } diff --git a/libc/src/__support/File/file.cpp b/libc/src/__support/File/file.cpp --- a/libc/src/__support/File/file.cpp +++ b/libc/src/__support/File/file.cpp @@ -335,7 +335,6 @@ return buf_result.error; } pos = 0; - return platform_flush(this); } // TODO: Add POSIX behavior for input streams. return 0; diff --git a/libc/src/__support/File/gpu/file.cpp b/libc/src/__support/File/gpu/file.cpp --- a/libc/src/__support/File/gpu/file.cpp +++ b/libc/src/__support/File/gpu/file.cpp @@ -26,8 +26,8 @@ public: constexpr GPUFile(uintptr_t file, File::ModeFlags modeflags) - : File(&write_func, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - 0, _IONBF, false, modeflags), + : File(&write_func, nullptr, nullptr, nullptr, nullptr, nullptr, 0, + _IONBF, false, modeflags), file(file) {} uintptr_t get_file() const { return file; } diff --git a/libc/src/__support/File/linux/file.cpp b/libc/src/__support/File/linux/file.cpp --- a/libc/src/__support/File/linux/file.cpp +++ b/libc/src/__support/File/linux/file.cpp @@ -24,7 +24,6 @@ FileIOResult read_func(File *, void *, size_t); ErrorOr seek_func(File *, long, int); int close_func(File *); -int flush_func(File *); } // anonymous namespace @@ -34,7 +33,7 @@ public: constexpr LinuxFile(int file_descriptor, uint8_t *buffer, size_t buffer_size, int buffer_mode, bool owned, File::ModeFlags modeflags) - : File(&write_func, &read_func, &seek_func, &close_func, flush_func, + : File(&write_func, &read_func, &seek_func, &close_func, &cleanup_file, buffer, buffer_size, buffer_mode, owned, modeflags), fd(file_descriptor) {} @@ -91,15 +90,6 @@ return 0; } -int flush_func(File *f) { - auto *lf = reinterpret_cast(f); - int ret = __llvm_libc::syscall_impl(SYS_fsync, lf->get_fd()); - if (ret < 0) { - return -ret; - } - return 0; -} - } // anonymous namespace ErrorOr openfile(const char *path, const char *mode) { diff --git a/libc/src/stdio/fopencookie.cpp b/libc/src/stdio/fopencookie.cpp --- a/libc/src/stdio/fopencookie.cpp +++ b/libc/src/stdio/fopencookie.cpp @@ -26,15 +26,13 @@ static FileIOResult cookie_read(File *f, void *data, size_t size); static ErrorOr cookie_seek(File *f, long offset, int whence); static int cookie_close(File *f); - static int cookie_flush(File *); public: CookieFile(void *c, cookie_io_functions_t cops, uint8_t *buffer, size_t bufsize, File::ModeFlags mode) : File(&cookie_write, &cookie_read, &CookieFile::cookie_seek, - &cookie_close, &cookie_flush, &cleanup_file, buffer, - bufsize, 0 /* default buffering mode */, - true /* File owns buffer */, mode), + &cookie_close, &cleanup_file, buffer, bufsize, + 0 /* default buffering mode */, true /* File owns buffer */, mode), cookie(c), ops(cops) {} }; @@ -74,8 +72,6 @@ return cookie_file->ops.close(cookie_file->cookie); } -int CookieFile::cookie_flush(File *) { return 0; } - } // anonymous namespace LLVM_LIBC_FUNCTION(::FILE *, fopencookie, diff --git a/libc/test/src/__support/File/file_test.cpp b/libc/test/src/__support/File/file_test.cpp --- a/libc/test/src/__support/File/file_test.cpp +++ b/libc/test/src/__support/File/file_test.cpp @@ -33,13 +33,12 @@ size_t len); static ErrorOr str_seek(__llvm_libc::File *f, long offset, int whence); static int str_close(__llvm_libc::File *f) { return 0; } - static int str_flush(__llvm_libc::File *f) { return 0; } public: explicit StringFile(char *buffer, size_t buflen, int bufmode, bool owned, ModeFlags modeflags) : __llvm_libc::File(&str_write, &str_read, &str_seek, &str_close, - &str_flush, &__llvm_libc::cleanup_file, + &__llvm_libc::cleanup_file, reinterpret_cast(buffer), buflen, bufmode, owned, modeflags), pos(0), eof_marker(0), write_append(false) { diff --git a/libc/test/src/stdio/ftell_test.cpp b/libc/test/src/stdio/ftell_test.cpp --- a/libc/test/src/stdio/ftell_test.cpp +++ b/libc/test/src/stdio/ftell_test.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "src/stdio/fclose.h" -#include "src/stdio/fflush.h" #include "src/stdio/fopen.h" #include "src/stdio/fread.h" #include "src/stdio/fseek.h"