diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2023-12-01 08:06:37 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-01 08:06:37 +0800 |
| commit | 09e93d7c4d33451ffe2dd2edeb7e2124b83c8078 (patch) | |
| tree | c0d1d3de8f4dbd578e6c4d53bb91a55896b169c2 /src/nvim/os | |
| parent | b32b5b2711ed338f4944c983a247f80c3163f87c (diff) | |
| download | rneovim-09e93d7c4d33451ffe2dd2edeb7e2124b83c8078.tar.gz rneovim-09e93d7c4d33451ffe2dd2edeb7e2124b83c8078.tar.bz2 rneovim-09e93d7c4d33451ffe2dd2edeb7e2124b83c8078.zip | |
refactor(IWYU): create {ex_getln,rbuffer,os/fileio}_defs.h (#26338)
Diffstat (limited to 'src/nvim/os')
| -rw-r--r-- | src/nvim/os/fileio.h | 43 | ||||
| -rw-r--r-- | src/nvim/os/fileio_defs.h | 43 |
2 files changed, 45 insertions, 41 deletions
diff --git a/src/nvim/os/fileio.h b/src/nvim/os/fileio.h index 72e7984c8a..55f213f377 100644 --- a/src/nvim/os/fileio.h +++ b/src/nvim/os/fileio.h @@ -1,20 +1,8 @@ #pragma once -#include <stdbool.h> -#include <stddef.h> +#include <stddef.h> // IWYU pragma: keep -#include "nvim/func_attr.h" -#include "nvim/rbuffer.h" - -/// Structure used to read from/write to file -typedef struct { - int fd; ///< File descriptor. - int _error; ///< Error code for use with RBuffer callbacks or zero. - RBuffer *rv; ///< Read or write buffer. - bool wr; ///< True if file is in write mode. - bool eof; ///< True if end of file was encountered. - bool non_blocking; ///< True if EAGAIN should not restart syscalls. -} FileDescriptor; +#include "nvim/os/fileio_defs.h" // IWYU pragma: export /// file_open() flags typedef enum { @@ -37,33 +25,6 @@ typedef enum { kFileMkDir = 256, } FileOpenFlags; -static inline bool file_eof(const FileDescriptor *fp) - REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; - -/// Check whether end of file was encountered -/// -/// @param[in] fp File to check. -/// -/// @return true if it was, false if it was not or read operation was never -/// performed. -static inline bool file_eof(const FileDescriptor *const fp) -{ - return fp->eof && rbuffer_size(fp->rv) == 0; -} - -static inline int file_fd(const FileDescriptor *fp) - REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; - -/// Return the file descriptor associated with the FileDescriptor structure -/// -/// @param[in] fp File to check. -/// -/// @return File descriptor. -static inline int file_fd(const FileDescriptor *const fp) -{ - return fp->fd; -} - enum { /// Read or write buffer size /// diff --git a/src/nvim/os/fileio_defs.h b/src/nvim/os/fileio_defs.h new file mode 100644 index 0000000000..3dc8c7b22a --- /dev/null +++ b/src/nvim/os/fileio_defs.h @@ -0,0 +1,43 @@ +#pragma once + +#include <stdbool.h> + +#include "nvim/func_attr.h" +#include "nvim/rbuffer_defs.h" + +/// Structure used to read from/write to file +typedef struct { + int fd; ///< File descriptor. + int _error; ///< Error code for use with RBuffer callbacks or zero. + RBuffer *rv; ///< Read or write buffer. + bool wr; ///< True if file is in write mode. + bool eof; ///< True if end of file was encountered. + bool non_blocking; ///< True if EAGAIN should not restart syscalls. +} FileDescriptor; + +static inline bool file_eof(const FileDescriptor *fp) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; + +/// Check whether end of file was encountered +/// +/// @param[in] fp File to check. +/// +/// @return true if it was, false if it was not or read operation was never +/// performed. +static inline bool file_eof(const FileDescriptor *const fp) +{ + return fp->eof && rbuffer_size(fp->rv) == 0; +} + +static inline int file_fd(const FileDescriptor *fp) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; + +/// Return the file descriptor associated with the FileDescriptor structure +/// +/// @param[in] fp File to check. +/// +/// @return File descriptor. +static inline int file_fd(const FileDescriptor *const fp) +{ + return fp->fd; +} |