Skip to content

[test][stdlib] Define stdio stubs for OpenBSD. #32330

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 1 commit into from
Jun 12, 2020
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: 4 additions & 0 deletions stdlib/public/Platform/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public func snprintf(ptr: UnsafeMutablePointer<Int8>, _ len: Int, _ format: Unsa
return vsnprintf(ptr, len, format, va_args)
}
}
#elseif os(OpenBSD)
public var stdin: UnsafeMutablePointer<FILE> { return _swift_stdlib_stdin() }
public var stdout: UnsafeMutablePointer<FILE> { return _swift_stdlib_stdout() }
public var stderr: UnsafeMutablePointer<FILE> { return _swift_stdlib_stderr() }
#elseif os(Windows)
public var stdin: UnsafeMutablePointer<FILE> { return __acrt_iob_func(0) }
public var stdout: UnsafeMutablePointer<FILE> { return __acrt_iob_func(1) }
Expand Down
17 changes: 17 additions & 0 deletions stdlib/public/SwiftShims/LibcOverlayShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include "Visibility.h"

#if defined(__OpenBSD__)
#include <stdio.h>
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <errno.h>
#include <io.h>
Expand Down Expand Up @@ -112,6 +115,20 @@ int static inline _swift_stdlib_openat(int fd, const char *path, int oflag,
}
#endif

#if defined(__OpenBSD__)
static inline FILE *_swift_stdlib_stdin(void) {
return stdin;
}

static inline FILE *_swift_stdlib_stdout(void) {
return stdout;
}

static inline FILE *_swift_stdlib_stderr(void) {
return stderr;
}
#endif

#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
Expand Down