Skip to content

Commit cb5e497

Browse files
authored
Merge pull request #2983 from compnerd/errno
_SwiftSyntaxCShims: rename Swift getter
2 parents 5f5371d + 8d5a067 commit cb5e497

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Sources/SwiftCompilerPluginMessageHandling/CompilerPluginMessageHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class CompilerPluginMessageListener<Connection: MessageConnection, Handle
121121
} catch {
122122
// Emit a diagnostic and indicate failure to the plugin host,
123123
// and exit with an error code.
124-
fputs("Internal Error: \(error)\n", _stderr)
124+
fputs("Internal Error: \(error)\n", swift_syntax_stderr)
125125
exit(1)
126126
}
127127
}

Sources/SwiftCompilerPluginMessageHandling/StandardIOMessageConnection.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public struct StandardIOMessageConnection: MessageConnection {
4545
/// directly to `stdin` and `stdout` as WASI doesn't support
4646
/// `dup{,2}`.
4747
public init() throws {
48-
let inputFD = fileno(_stdin)
49-
let outputFD = fileno(_stdout)
48+
let inputFD = fileno(swift_syntax_stdin)
49+
let outputFD = fileno(swift_syntax_stdout)
5050
self.init(inputFileDescriptor: inputFD, outputFileDescriptor: outputFD)
5151
}
5252
#else
@@ -60,29 +60,29 @@ public struct StandardIOMessageConnection: MessageConnection {
6060
public init() throws {
6161
// Duplicate the `stdin` file descriptor, which we will then use for
6262
// receiving messages from the plugin host.
63-
let inputFD = dup(fileno(_stdin))
63+
let inputFD = dup(fileno(swift_syntax_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.
71-
guard close(fileno(_stdin)) >= 0 else {
72-
throw IOError.systemError(function: "close(fileno(stdin))", errno: _errno)
71+
guard close(fileno(swift_syntax_stdin)) >= 0 else {
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.
77-
let outputFD = dup(fileno(_stdout))
77+
let outputFD = dup(fileno(swift_syntax_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.
84-
guard dup2(fileno(_stderr), fileno(_stdout)) >= 0 else {
85-
throw IOError.systemError(function: "dup2(fileno(stderr), fileno(stdout))", errno: _errno)
84+
guard dup2(fileno(swift_syntax_stderr), fileno(swift_syntax_stdout)) >= 0 else {
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
}

Sources/_SwiftSyntaxCShims/include/swiftsyntax_stdio.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
#include <stdio.h>
1919

20-
SWIFT_NAME_S("getter:_stdout()")
20+
SWIFT_NAME_S("getter:swift_syntax_stdout()")
2121
static inline FILE *swiftsyntax_stdout(void) {
2222
return stdout;
2323
}
2424

25-
SWIFT_NAME_S("getter:_stdin()")
25+
SWIFT_NAME_S("getter:swift_syntax_stdin()")
2626
static inline FILE *swiftsyntax_stdin(void) {
2727
return stdin;
2828
}
2929

30-
SWIFT_NAME_S("getter:_stderr()")
30+
SWIFT_NAME_S("getter:swift_syntax_stderr()")
3131
static inline FILE *swiftsyntax_stderr(void) {
3232
return stderr;
3333
}

0 commit comments

Comments
 (0)