Skip to content

[shims] Fix Windows errno() and _stdlib_open #13235

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
Dec 4, 2017
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
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/LibcShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ typedef long int __swift_ssize_t;
typedef __swift_uint32_t __swift_mode_t;
#elif defined(__APPLE__)
typedef __swift_uint16_t __swift_mode_t;
#elif defined(_WIN32)
typedef __swift_int32_t __swift_mode_t;
#else // just guessing
typedef __swift_uint16_t __swift_mode_t;
#endif
Expand Down Expand Up @@ -128,12 +130,10 @@ char * _Nullable *_stdlib_getEnviron();
#endif

// System error numbers <errno.h>
#if !defined(_WIN32) || defined(__CYGWIN__)
SWIFT_RUNTIME_STDLIB_INTERNAL
int _stdlib_getErrno();
SWIFT_RUNTIME_STDLIB_INTERNAL
void _stdlib_setErrno(int value);
#endif

// Non-standard extensions
SWIFT_READNONE SWIFT_RUNTIME_STDLIB_INTERNAL
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/stubs/LibcShims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ int swift::_stdlib_close(int fd) {
// Windows

SWIFT_RUNTIME_STDLIB_INTERNAL
int swift::_stdlib_open(const char *path, int oflag, int mode) {
return _open(path, oflag, mode);
int swift::_stdlib_open(const char *path, int oflag, __swift_mode_t mode) {
return _open(path, oflag, static_cast<int>(mode));
}

#else
Expand Down Expand Up @@ -183,6 +183,8 @@ char * _Nullable *swift::_stdlib_getEnviron() {
}
#endif

#endif // !(defined(_WIN32) && !defined(__CYGWIN__))

SWIFT_RUNTIME_STDLIB_INTERNAL
int swift::_stdlib_getErrno() {
return errno;
Expand All @@ -193,8 +195,6 @@ void swift::_stdlib_setErrno(int value) {
errno = value;
}

// not Windows
#endif


#if defined(__APPLE__)
Expand Down