diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-01 02:34:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-01 02:34:32 +0100 |
commit | 6cd4ff2ab724583acf3a6e582ad55d0561c7bd28 (patch) | |
tree | 1473e2873b0892d4b210e81a44518c54ea37eadd | |
parent | 085f0f1b1b4e03d5378ca37ae2cb8670a7fa53cd (diff) | |
download | rneovim-6cd4ff2ab724583acf3a6e582ad55d0561c7bd28.tar.gz rneovim-6cd4ff2ab724583acf3a6e582ad55d0561c7bd28.tar.bz2 rneovim-6cd4ff2ab724583acf3a6e582ad55d0561c7bd28.zip |
os: remove uv_translate_sys_error impl #9652
Since libuv minimum version is now v1.12, we can use libuv's impl.
-rw-r--r-- | config/CMakeLists.txt | 1 | ||||
-rw-r--r-- | config/config.h.in | 1 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 124 | ||||
-rw-r--r-- | src/nvim/os/fs_defs.h | 3 |
4 files changed, 3 insertions, 126 deletions
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index 91c1e7c629..4fb44b9a27 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -40,7 +40,6 @@ check_function_exists(fseeko HAVE_FSEEKO) check_function_exists(getpwent HAVE_GETPWENT) check_function_exists(getpwnam HAVE_GETPWNAM) check_function_exists(getpwuid HAVE_GETPWUID) -check_function_exists(uv_translate_sys_error HAVE_UV_TRANSLATE_SYS_ERROR) check_function_exists(readv HAVE_READV) if(Iconv_FOUND) diff --git a/config/config.h.in b/config/config.h.in index ad636632f4..ef2fea4042 100644 --- a/config/config.h.in +++ b/config/config.h.in @@ -29,7 +29,6 @@ #cmakedefine HAVE_NL_MSG_CAT_CNTR #cmakedefine HAVE_PWD_H #cmakedefine HAVE_READLINK -#cmakedefine HAVE_UV_TRANSLATE_SYS_ERROR // TODO: add proper cmake check // #define HAVE_SELINUX 1 #cmakedefine HAVE_SETPGID diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 99ece275b1..109ea6c487 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -1128,127 +1128,3 @@ shortcut_end: } #endif - -int os_translate_sys_error(int sys_errno) -{ -#ifdef HAVE_UV_TRANSLATE_SYS_ERROR - return uv_translate_sys_error(sys_errno); -#elif defined(WIN32) - // TODO(equalsraf): libuv does not yet expose uv_translate_sys_error() - // in its public API, include a version here until it can be used. - // See https://github.com/libuv/libuv/issues/79 -# ifndef ERROR_SYMLINK_NOT_SUPPORTED -# define ERROR_SYMLINK_NOT_SUPPORTED 1464 -# endif - - if (sys_errno <= 0) { - return sys_errno; // If < 0 then it's already a libuv error - } - - switch (sys_errno) { - case ERROR_NOACCESS: return UV_EACCES; - case WSAEACCES: return UV_EACCES; - case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE; - case WSAEADDRINUSE: return UV_EADDRINUSE; - case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL; - case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT; - case WSAEWOULDBLOCK: return UV_EAGAIN; - case WSAEALREADY: return UV_EALREADY; - case ERROR_INVALID_FLAGS: return UV_EBADF; - case ERROR_INVALID_HANDLE: return UV_EBADF; - case ERROR_LOCK_VIOLATION: return UV_EBUSY; - case ERROR_PIPE_BUSY: return UV_EBUSY; - case ERROR_SHARING_VIOLATION: return UV_EBUSY; - case ERROR_OPERATION_ABORTED: return UV_ECANCELED; - case WSAEINTR: return UV_ECANCELED; - case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET; - case ERROR_CONNECTION_ABORTED: return UV_ECONNABORTED; - case WSAECONNABORTED: return UV_ECONNABORTED; - case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED; - case WSAECONNREFUSED: return UV_ECONNREFUSED; - case ERROR_NETNAME_DELETED: return UV_ECONNRESET; - case WSAECONNRESET: return UV_ECONNRESET; - case ERROR_ALREADY_EXISTS: return UV_EEXIST; - case ERROR_FILE_EXISTS: return UV_EEXIST; - case ERROR_BUFFER_OVERFLOW: return UV_EFAULT; - case WSAEFAULT: return UV_EFAULT; - case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH; - case WSAEHOSTUNREACH: return UV_EHOSTUNREACH; - case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL; - case ERROR_INVALID_DATA: return UV_EINVAL; - case ERROR_INVALID_PARAMETER: return UV_EINVAL; - case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL; - case WSAEINVAL: return UV_EINVAL; - case WSAEPFNOSUPPORT: return UV_EINVAL; - case WSAESOCKTNOSUPPORT: return UV_EINVAL; - case ERROR_BEGINNING_OF_MEDIA: return UV_EIO; - case ERROR_BUS_RESET: return UV_EIO; - case ERROR_CRC: return UV_EIO; - case ERROR_DEVICE_DOOR_OPEN: return UV_EIO; - case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO; - case ERROR_DISK_CORRUPT: return UV_EIO; - case ERROR_EOM_OVERFLOW: return UV_EIO; - case ERROR_FILEMARK_DETECTED: return UV_EIO; - case ERROR_GEN_FAILURE: return UV_EIO; - case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO; - case ERROR_IO_DEVICE: return UV_EIO; - case ERROR_NO_DATA_DETECTED: return UV_EIO; - case ERROR_NO_SIGNAL_SENT: return UV_EIO; - case ERROR_OPEN_FAILED: return UV_EIO; - case ERROR_SETMARK_DETECTED: return UV_EIO; - case ERROR_SIGNAL_REFUSED: return UV_EIO; - case WSAEISCONN: return UV_EISCONN; - case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP; - case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE; - case WSAEMFILE: return UV_EMFILE; - case WSAEMSGSIZE: return UV_EMSGSIZE; - case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG; - case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH; - case WSAENETUNREACH: return UV_ENETUNREACH; - case WSAENOBUFS: return UV_ENOBUFS; - case ERROR_BAD_PATHNAME: return UV_ENOENT; - case ERROR_DIRECTORY: return UV_ENOENT; - case ERROR_FILE_NOT_FOUND: return UV_ENOENT; - case ERROR_INVALID_NAME: return UV_ENOENT; - case ERROR_INVALID_DRIVE: return UV_ENOENT; - case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT; - case ERROR_MOD_NOT_FOUND: return UV_ENOENT; - case ERROR_PATH_NOT_FOUND: return UV_ENOENT; - case WSAHOST_NOT_FOUND: return UV_ENOENT; - case WSANO_DATA: return UV_ENOENT; - case ERROR_NOT_ENOUGH_MEMORY: return UV_ENOMEM; - case ERROR_OUTOFMEMORY: return UV_ENOMEM; - case ERROR_CANNOT_MAKE: return UV_ENOSPC; - case ERROR_DISK_FULL: return UV_ENOSPC; - case ERROR_EA_TABLE_FULL: return UV_ENOSPC; - case ERROR_END_OF_MEDIA: return UV_ENOSPC; - case ERROR_HANDLE_DISK_FULL: return UV_ENOSPC; - case ERROR_NOT_CONNECTED: return UV_ENOTCONN; - case WSAENOTCONN: return UV_ENOTCONN; - case ERROR_DIR_NOT_EMPTY: return UV_ENOTEMPTY; - case WSAENOTSOCK: return UV_ENOTSOCK; - case ERROR_NOT_SUPPORTED: return UV_ENOTSUP; - case ERROR_BROKEN_PIPE: return UV_EOF; - case ERROR_ACCESS_DENIED: return UV_EPERM; - case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM; - case ERROR_BAD_PIPE: return UV_EPIPE; - case ERROR_NO_DATA: return UV_EPIPE; - case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE; - case WSAESHUTDOWN: return UV_EPIPE; - case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT; - case ERROR_WRITE_PROTECT: return UV_EROFS; - case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT; - case WSAETIMEDOUT: return UV_ETIMEDOUT; - case ERROR_NOT_SAME_DEVICE: return UV_EXDEV; - case ERROR_INVALID_FUNCTION: return UV_EISDIR; - case ERROR_META_EXPANSION_TOO_LONG: return UV_E2BIG; - default: return UV_UNKNOWN; - } -#else - const int error = -errno; - STATIC_ASSERT(-EINTR == UV_EINTR, "Need to translate error codes"); - STATIC_ASSERT(-EAGAIN == UV_EAGAIN, "Need to translate error codes"); - STATIC_ASSERT(-ENOMEM == UV_ENOMEM, "Need to translate error codes"); - return error; -#endif -} diff --git a/src/nvim/os/fs_defs.h b/src/nvim/os/fs_defs.h index c9b148a5aa..68e5c74ee1 100644 --- a/src/nvim/os/fs_defs.h +++ b/src/nvim/os/fs_defs.h @@ -24,6 +24,9 @@ typedef struct { /// Converts libuv error (negative int) to error description string. #define os_strerror uv_strerror +/// Converts system error code to libuv error code. +#define os_translate_sys_error uv_translate_sys_error + // Values returned by os_nodetype() #define NODE_NORMAL 0 // file or directory, check with os_isdir() #define NODE_WRITABLE 1 // something we can write to (character |