Skip to content

Commit 6cf9ed8

Browse files
authored
Merge pull request #13235 from troughton/windows-errno-stdlibopen
2 parents fde0d92 + b4391f3 commit 6cf9ed8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

stdlib/public/SwiftShims/LibcShims.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ typedef long int __swift_ssize_t;
5353
typedef __swift_uint32_t __swift_mode_t;
5454
#elif defined(__APPLE__)
5555
typedef __swift_uint16_t __swift_mode_t;
56+
#elif defined(_WIN32)
57+
typedef __swift_int32_t __swift_mode_t;
5658
#else // just guessing
5759
typedef __swift_uint16_t __swift_mode_t;
5860
#endif
@@ -128,12 +130,10 @@ char * _Nullable *_stdlib_getEnviron();
128130
#endif
129131

130132
// System error numbers <errno.h>
131-
#if !defined(_WIN32) || defined(__CYGWIN__)
132133
SWIFT_RUNTIME_STDLIB_INTERNAL
133134
int _stdlib_getErrno();
134135
SWIFT_RUNTIME_STDLIB_INTERNAL
135136
void _stdlib_setErrno(int value);
136-
#endif
137137

138138
// Non-standard extensions
139139
SWIFT_READNONE SWIFT_RUNTIME_STDLIB_INTERNAL

stdlib/public/stubs/LibcShims.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ int swift::_stdlib_close(int fd) {
120120
// Windows
121121

122122
SWIFT_RUNTIME_STDLIB_INTERNAL
123-
int swift::_stdlib_open(const char *path, int oflag, int mode) {
124-
return _open(path, oflag, mode);
123+
int swift::_stdlib_open(const char *path, int oflag, __swift_mode_t mode) {
124+
return _open(path, oflag, static_cast<int>(mode));
125125
}
126126

127127
#else
@@ -183,6 +183,8 @@ char * _Nullable *swift::_stdlib_getEnviron() {
183183
}
184184
#endif
185185

186+
#endif // !(defined(_WIN32) && !defined(__CYGWIN__))
187+
186188
SWIFT_RUNTIME_STDLIB_INTERNAL
187189
int swift::_stdlib_getErrno() {
188190
return errno;
@@ -193,8 +195,6 @@ void swift::_stdlib_setErrno(int value) {
193195
errno = value;
194196
}
195197

196-
// not Windows
197-
#endif
198198

199199

200200
#if defined(__APPLE__)

0 commit comments

Comments
 (0)