Skip to content

[stdlib] Include POSIXError as part of MSVCRT #24056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O
add_swift_target_library(swiftMSVCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
msvcrt.swift
${swift_platform_sources}
POSIXError.swift

GYB_SOURCES
${swift_platform_gyb_sources}
Expand Down
128 changes: 126 additions & 2 deletions stdlib/public/Platform/POSIXError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
//
//===----------------------------------------------------------------------===//

// FIXME: Only defining POSIXErrorCode for Darwin and Linux at the moment.

#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)

/// Enumeration describing POSIX error codes.
Expand Down Expand Up @@ -554,4 +552,130 @@ public enum POSIXErrorCode : Int32 {
case ENOTRECOVERABLE = 131
}

#elseif os(Windows)

/// Enumeration describing POSIX error codes.
public enum POSIXErrorCode : Int32 {

/// Operation not permitted
case EPERM = 1

/// No such file or directory
case ENOENT = 2

/// No such process
case ESRCH = 3

/// Interrupted function
case EINTR = 4

/// I/O error
case EIO = 5

/// No such device or address
case ENXIO = 6

/// Argument list too long
case E2BIG = 7

/// Exec format error
case ENOEXEC = 8

/// Bad file number
case EBADF = 9

/// No spawned processes
case ECHILD = 10

/// No more processes or not enough memory or maximum nesting level reached
case EAGAIN = 11

/// Not enough memory
case ENOMEM = 12

/// Permission denied
case EACCES = 13

/// Bad address
case EFAULT = 14

/// Device or resource busy
case EBUSY = 16

/// File exists
case EEXIST = 17

/// Cross-device link
case EXDEV = 18

/// No such device
case ENODEV = 19

/// Not a directory
case ENOTDIR = 20

/// Is a directory
case EISDIR = 21

/// Invalid argument
case EINVAL = 22

/// Too many files open in system
case ENFILE = 23

/// Too many open files
case EMFILE = 24

/// Inappropriate I/O control operation
case ENOTTY = 25

/// File too large
case EFBIG = 27

/// No space left on device
case ENOSPC = 28

/// Invalid seek
case ESPIPE = 29

/// Read-only file system
case EROFS = 30

/// Too many links
case EMLINK = 31

/// Broken pipe
case EPIPE = 32

/// Math argument
case EDOM = 33

/// Result too large
case ERANGE = 34

/// Resource deadlock would occur
case EDEADLK = 36

/// Same as EDEADLK for compatibility with older Microsoft C versions
public static var EDEADLOCK: POSIXErrorCode { return .EDEADLK }

/// Filename too long
case ENAMETOOLONG = 38

/// No locks available
case ENOLCK = 39

/// Function not supported
case ENOSYS = 40

/// Directory not empty
case ENOTEMPTY = 41

/// Illegal byte sequence
case EILSEQ = 42

/// String was truncated
case STRUNCATE = 80
}

#endif