Skip to content

Commit aa3335d

Browse files
committed
_SwiftSyntaxCShims: rename Swift getter
`_errno` is a C reserved identifier. Windows uses this reserved namespace and results in a collision. Rename the getter to namespace it and avoid the collision.
1 parent 5c57421 commit aa3335d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Sources/SwiftCompilerPluginMessageHandling/StandardIOMessageConnection.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,27 @@ public struct StandardIOMessageConnection: MessageConnection {
6262
// receiving messages from the plugin host.
6363
let inputFD = dup(fileno(_stdin))
6464
guard inputFD >= 0 else {
65-
throw IOError.systemError(function: "dup(fileno(stdin))", errno: _errno)
65+
throw IOError.systemError(function: "dup(fileno(stdin))", errno: _swift_syntax_errno)
6666
}
6767

6868
// Having duplicated the original standard-input descriptor, we close
6969
// `stdin` so that attempts by the plugin to read console input (which
7070
// are usually a mistake) return errors instead of blocking.
7171
guard close(fileno(_stdin)) >= 0 else {
72-
throw IOError.systemError(function: "close(fileno(stdin))", errno: _errno)
72+
throw IOError.systemError(function: "close(fileno(stdin))", errno: _swift_syntax_errno)
7373
}
7474

7575
// Duplicate the `stdout` file descriptor, which we will then use for
7676
// sending messages to the plugin host.
7777
let outputFD = dup(fileno(_stdout))
7878
guard outputFD >= 0 else {
79-
throw IOError.systemError(function: "dup(fileno(stdout))", errno: _errno)
79+
throw IOError.systemError(function: "dup(fileno(stdout))", errno: _swift_syntax_errno)
8080
}
8181

8282
// Having duplicated the original standard-output descriptor, redirect
8383
// `stdout` to `stderr` so that all free-form text output goes there.
8484
guard dup2(fileno(_stderr), fileno(_stdout)) >= 0 else {
85-
throw IOError.systemError(function: "dup2(fileno(stderr), fileno(stdout))", errno: _errno)
85+
throw IOError.systemError(function: "dup2(fileno(stderr), fileno(stdout))", errno: _swift_syntax_errno)
8686
}
8787

8888
#if canImport(ucrt)
@@ -101,7 +101,7 @@ public struct StandardIOMessageConnection: MessageConnection {
101101
let endPtr = ptr.advanced(by: buffer.count)
102102
while ptr != endPtr {
103103
switch write(outputFileDescriptor, ptr, numericCast(endPtr - ptr)) {
104-
case -1: throw IOError.systemError(function: "write(_:_:_:)", errno: _errno)
104+
case -1: throw IOError.systemError(function: "write(_:_:_:)", errno: _swift_syntax_errno)
105105
case 0: throw IOError.systemError(function: "write", errno: 0) /* unreachable */
106106
case let n: ptr += Int(n)
107107
}
@@ -116,7 +116,7 @@ public struct StandardIOMessageConnection: MessageConnection {
116116
let endPtr = ptr.advanced(by: buffer.count)
117117
while ptr != endPtr {
118118
switch read(inputFileDescriptor, ptr, numericCast(endPtr - ptr)) {
119-
case -1: throw IOError.systemError(function: "read(_:_:_:)", errno: _errno)
119+
case -1: throw IOError.systemError(function: "read(_:_:_:)", errno: _swift_syntax_errno)
120120
case 0: throw IOError.readReachedEndOfInput
121121
case let n: ptr += Int(n)
122122
}

Sources/_SwiftSyntaxCShims/include/swiftsyntax_errno.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <errno.h>
1919

20-
SWIFT_NAME_S("getter:_errno()")
20+
SWIFT_NAME_S("getter:_swift_syntax_errno()")
2121
static inline int swiftsyntax_errno(void) {
2222
return errno;
2323
}

0 commit comments

Comments
 (0)