Skip to content

Commit 9683569

Browse files
authored
OpenBSD 7.8 will require OpaquePointer for FILE. (#84478)
OpenBSD 7.8 snapshots hide the type information for FILE. Therefore, the types for the standard stdio streams should (regrettably) be OpaquePointer, due to the well-discussed issue of losing type information for forward-declared C types. We explicitly drop to void * in the LibcOverlayShims for backwards compatibility, since OpenBSD 7.8 is not yet released.
1 parent 3535225 commit 9683569

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

stdlib/private/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ if(SWIFT_BUILD_SDK_OVERLAY
3030
endif()
3131
# Currently SwiftReflectionTest cannot be built on Windows, due to
3232
# dependencies on POSIX symbols
33-
if (SWIFT_INCLUDE_TESTS AND (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"))
33+
if (SWIFT_INCLUDE_TESTS
34+
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
35+
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD"
36+
AND CMAKE_SYSTEM_VERSION VERSION_LESS "7.8"))
3437
add_subdirectory(SwiftReflectionTest)
3538
endif()
3639
endif()

stdlib/public/Platform/Platform.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public func snprintf(ptr: UnsafeMutablePointer<Int8>, _ len: Int, _ format: Unsa
7474
#endif
7575

7676
#elseif os(OpenBSD)
77-
public var stdin: UnsafeMutablePointer<FILE> { return _swift_stdlib_stdin() }
78-
public var stdout: UnsafeMutablePointer<FILE> { return _swift_stdlib_stdout() }
79-
public var stderr: UnsafeMutablePointer<FILE> { return _swift_stdlib_stderr() }
77+
public var stdin: OpaquePointer { return OpaquePointer(_swift_stdlib_stdin()) }
78+
public var stdout: OpaquePointer { return OpaquePointer(_swift_stdlib_stdout()) }
79+
public var stderr: OpaquePointer { return OpaquePointer(_swift_stdlib_stderr()) }
8080
#elseif os(Windows)
8181
public var stdin: UnsafeMutablePointer<FILE> {
8282
return unsafe __acrt_iob_func(0)

stdlib/public/SwiftShims/swift/shims/LibcOverlayShims.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ int static inline _swift_stdlib_openat(int fd, const char *path, int oflag,
121121
#endif
122122

123123
#if defined(__OpenBSD__)
124-
static inline FILE *_swift_stdlib_stdin(void) {
124+
static inline void *_swift_stdlib_stdin(void) {
125125
return stdin;
126126
}
127127

128-
static inline FILE *_swift_stdlib_stdout(void) {
128+
static inline void *_swift_stdlib_stdout(void) {
129129
return stdout;
130130
}
131131

132-
static inline FILE *_swift_stdlib_stderr(void) {
132+
static inline void *_swift_stdlib_stderr(void) {
133133
return stderr;
134134
}
135135
#endif

0 commit comments

Comments
 (0)