Compare commits

...
76 Commits
Author SHA1 Message Date
Guillaume Lessard a34201439c Merge pull request #220 from glessard/1.4.2
[1.4.x] Support for FreeBSD and OpenBSD
2025-02-18 15:35:23 -08:00
Guillaume Lessard 12573bfb88 Merge branch 'main' into 1.4.2 2025-02-17 17:03:43 -08:00
Guillaume Lessard 3a1b4a8e05 Merge pull request #219 from glessard/1.4.1
[1.4.x] Use GetTempPathW for better compatibility
2025-02-17 14:04:33 -08:00
Guillaume Lessard d9b03016dc Merge pull request #218 from glessard/1.4.1
[1.4.x] Use GetTempPathW for better compatibility
2025-02-17 11:52:53 -08:00
xuty f18ed75481 Use GetTempPathW for better compatibility 2025-02-17 11:43:11 -08:00
Guillaume Lessard b1b7b60a55 Merge pull request #215 from 3405691582/openbsd
OpenBSD support.
2025-02-10 14:41:18 -08:00
Guillaume Lessard 2228d64644 Merge pull request #213 from Steelskin/fabrice/cmake-install-paths
[cmake] Install libraries in standard directories
2025-02-07 11:00:22 -08:00
3405691582 3b053e055b ManagedBuffer.capacity is unavailable on OpenBSD.
`.capacity` is backed by malloc introspection (`malloc_size`), which is
not available on all platforms. The workaround is straightforward here,
thankfully: instead, use the minimum capacity already specified.
2025-02-04 19:44:35 -05:00
3405691582 90702d6d15 Typealias system_DIRPtr for OpenBSD. 2025-02-04 19:44:32 -05:00
Guillaume Lessard 849d005b2b Merge pull request #211 from ShaftUI/temp-path-w
[Windows] Use GetTempPathW in _getTemporaryDirectory for better compatibility
2025-01-30 15:00:27 -08:00
Guillaume Lessard 8790e47013 Merge pull request #214 from michael-yuji/freebsd-wip
Add FreeBSD errno and open options
2025-01-29 15:50:13 -08:00
Guillaume Lessard f27874d762 Merge pull request #209 from ADKaster/install-interface
CSystem: Set build and install interfaces on included headers
2025-01-28 13:49:12 -08:00
Michael Chiu df7341ee2b fix cmake x86_64 build 2025-01-26 21:29:19 -08:00
Michael Chiu 4d735a6631 Add FreeBSD errnos and open options 2025-01-26 21:29:13 -08:00
Fabrice de Gans bebd7c146e [cmake] Install libraries in standard directories
Previously, libs were installed under `lib/swift/${os}`. They should be
installed in the default library directory for the relevant target
system.
In addition, swiftmodules were installed in the older layout format.
This changes to use the standard modern layout format for swiftmodules.
2025-01-23 11:45:17 -08:00
michael-yuji 4fa2a719c5 Merge pull request #212 from michael-yuji/freebsd-wip
Guard errnos not available on FreeBSD
2025-01-17 21:52:07 -08:00
Michael Chiu 0d824eee86 refactor ifdef in test 2025-01-17 15:06:28 -08:00
Michael Chiu eb566de2d3 Fix tests on FreeBSD 2025-01-17 14:43:40 -08:00
Michael Chiu a4fb6cb206 Keep order consistent 2025-01-17 14:43:34 -08:00
Michael Chiu 7e73a336fb Guard errnos not available on FreeBSD 2025-01-17 14:30:51 -08:00
xuty 85b83fddb1 Use GetTempPathW for better compatibility 2024-12-17 15:13:15 +08:00
Guillaume Lessard 61a2af5e8b Merge pull request #210 from ADKaster/remove-nbsp
Internals: Remove non-breaking spaces from Windows syscall adapter
2024-11-22 19:38:54 -05:00
Andrew Kaster eb3b1fa54b Internals: Remove non-breaking spaces from Windows syscall adapter
This was causing a warning with Swift 6.0.2
2024-11-21 15:03:28 -07:00
Andrew Kaster f1393b76f3 CSystem: Set build and install interfaces on included headers 2024-11-21 14:48:57 -07:00
Guillaume Lessard fbd61a676d Merge pull request #207 from glessard/merge-1.4.0-into-main
Merge 1.4.0 into main
2024-10-18 22:39:45 -07:00
Guillaume Lessard f21f6a8866 Merge branch 'release/1.4.0' into merge-1.4.0-into-main
# Conflicts:
#	.gitignore
#	.swiftci/5_10_ubuntu2204
#	.swiftci/5_8_ubuntu2204
#	.swiftci/5_9_ubuntu2204
#	.swiftci/nightly_6_0_macos
#	.swiftci/nightly_6_0_ubuntu2204
#	.swiftci/nightly_main_macos
#	.swiftci/nightly_main_ubuntu2204
#	.swiftci/nightly_main_windows
#	Package.swift
#	Sources/System/FileOperations.swift
#	Sources/System/FilePath/FilePath.swift
#	Sources/System/Internals/WindowsSyscallAdapters.swift
2024-10-17 17:24:38 -07:00
Guillaume Lessard 7a18b4bf34 Merge pull request #193 from glbrntt/mac-catalyst
Add support for macCatalyst
2024-10-16 13:57:03 -07:00
George Barnett 2662793bd6 Add support for macCatalyst
Building swift-system for macCatalyst fails as there is no import of the
Darwin module.
2024-08-19 10:20:12 +01:00
Guillaume Lessard d581098eeb Merge pull request #191 from glessard/private-aeic-init-removal
Remove private-and-@_aEIC initializers
2024-07-31 16:56:38 -07:00
Guillaume Lessard edbc9e4fdc Remove private-and-@_aEIC initializers
These were just passthroughs.
2024-07-31 16:30:25 -07:00
Stephen Canon 9c42c54644 Merge pull request #189 from stephentyrone/enforce-file-path-invariants-in-decode
Ensure that FilePath and SystemString's invariants are enforced when …
2024-07-17 14:49:19 -04:00
Stephen Canon 3841a7531f Add some notes explaining what invariants are violated. 2024-07-17 13:49:15 -04:00
Stephen Canon 3b43b391b5 Add some comments and remove leftover WIP noise. 2024-07-17 12:49:37 -04:00
Stephen Canon c64775ef71 Another invariant to check 2024-07-17 12:25:34 -04:00
Stephen Canon 4c96faa6d8 Insure that FilePath and SystemString's invariants are enforced when decoding. 2024-07-17 12:14:43 -04:00
Guillaume Lessard 19e7f0fdd4 Merge pull request #187 from finagolfin/droid
Import new Android overlay
2024-07-08 17:20:28 -07:00
Finagolfin 02811ea6b4 Import new Android overlay
Use Bionic module instead where possible
2024-07-08 17:53:39 +05:30
Guillaume Lessard 2ce971a831 Merge pull request #155 from glessard/system-string-api-consistency
SystemString api consistency improvements
2024-07-05 14:26:21 -07:00
Guillaume Lessard 80788529b5 Merge pull request #170 from glessard/platform-flags
Make a platform-specific flag explicitly platform-specific
2024-07-05 14:24:12 -07:00
Guillaume Lessard 05fb1f1142 Merge pull request #178 from apple/dev/merge-1.3.0-back-to-main
[gardening] Merge the release/1.3.0 branch back into main
2024-07-03 16:22:44 -07:00
Guillaume Lessard 8d2dda76fa Merge pull request #186 from futurejones/add-riscv64-support
add support for riscv64
2024-06-18 16:21:38 -07:00
Neil Jones c1789e0525 add support for riscv64 2024-06-18 10:45:08 +09:00
Yuta Saito 318d2159d1 Merge pull request #182 from kateinoigakukun/katei/suppress-cmakelists-warning
Suppress unhandled CMakeLists.txt warning by SwiftPM
2024-06-06 03:08:41 +09:00
Yuta Saito 9c17c8562d Suppress unhandled CMakeLists.txt warning by SwiftPM 2024-06-03 02:15:29 +00:00
Guillaume Lessard 0d6be7ac22 Merge branch 'release/1.3.0'
# Conflicts:
#	.gitignore
#	.swiftci/5_10_ubuntu2204
#	.swiftci/5_8_ubuntu2204
#	.swiftci/5_9_ubuntu2204
#	.swiftci/nightly_6_0_macos
#	.swiftci/nightly_6_0_ubuntu2204
#	.swiftci/nightly_main_macos
#	.swiftci/nightly_main_ubuntu2204
#	.swiftci/nightly_main_windows
#	Package.swift
#	Sources/System/Internals/CInterop.swift
#	Sources/System/Internals/Constants.swift
#	Sources/System/Internals/Exports.swift
#	Sources/System/Internals/Syscalls.swift
#	Tests/SystemTests/FileOperationsTest.swift
2024-05-16 11:51:10 -07:00
Guillaume Lessard b642f54526 Merge pull request #175 from glessard/32-are-too-few-bits
fix a 32-bit overflow issue
2024-05-14 11:32:44 -07:00
Alastair Houghton 36987d6d37 Merge pull request #176 from al45tair/remove-unintended-public
Remove unintentional public functions and fix a couple of Windows issues.
2024-05-14 14:52:12 +01:00
Alastair Houghton 082adfe732 [Windows] Add a comment to explain the O_RDONLY/O_WRONLY/O_RDWR logic.
The values of these flags on Windows do not overlap, and more
particularly, `O_RDONLY` is actually zero on Windows, which means we
cannot test for it by AND-ing.
2024-05-14 14:42:57 +01:00
Alastair Houghton abc0a6d26f [Windows] Fix tests.
We need to use `@testable` when importing `SystemPackage` in order to
let us test the `internal` functions.

Also, use `NUL` instead of `/dev/null`, and generate random bytes in a
file instead of reading from `/dev/random`.
2024-05-13 15:13:31 +01:00
Alastair Houghton c3559ecd61 [Windows] Fix a problem with opening files read only.
`_O_RDONLY` is zero, so we can't test for it by AND-ing.
2024-05-13 14:18:17 +01:00
Alastair Houghton 8e09ede76d Remove accidentally public functions.
These can't be new API as they haven't been reviewed.
2024-05-13 11:19:43 +01:00
Guillaume Lessard 25c4b1ad75 fix a 32-bit overflow issue
- ensures compatibility with watchOS
2024-05-12 14:07:11 -07:00
Karoy Lorentey aac7f54e89 Merge pull request #174 from lorentey/codeowners
Add CODEOWNERS
2024-05-10 17:17:48 -07:00
Karoy Lorentey a6fd8ba9ba Add CODEOWNERS 2024-05-10 17:06:59 -07:00
Mishal Shah 3433699e6e [CI] Remove support for Swift 5.7 2024-05-10 16:32:21 -07:00
Guillaume Lessard d8c0e24651 Merge pull request #169 from glessard/manifest-fix
Improved compatibility for visionOS support
2024-05-10 15:42:15 -07:00
Guillaume Lessard 63b05e24e8 Improved compatibility for visionOS support 2024-05-10 15:37:04 -07:00
Guillaume Lessard b0e2a510ed Make a platform-specific flag explicitly platform-specific 2024-05-10 15:28:43 -07:00
Guillaume Lessard cf5e688e70 Merge pull request #162 from finagolfin/droid
Android: DIR* is an OpaquePointer in Bionic too
2024-05-09 09:31:47 -07:00
Guillaume Lessard 93d600b5c9 Merge pull request #161 from jmschonfeld/string-init-ambiguity
Disfavor String.init(platformString: UnsafePointer<CChar>)
2024-05-09 09:26:56 -07:00
Finagolfin 7fe8e6cfc2 Android: DIR* is an OpaquePointer in Bionic too 2024-05-09 19:29:36 +05:30
Mishal Shah 84077b3b4b Add Swift CI Support 2024-05-08 15:21:09 -07:00
Alastair Houghton 027c936a26 Merge pull request #158 from al45tair/eng/PR-125087707
Fix swift-system to work on Windows.
2024-05-08 16:13:21 +01:00
Alastair Houghton f5ad5e57fb [Linux] Glibc's DIR doesn't get imported into Swift.
Swift ends up with OpaquePointer instead of a typed pointer.

rdar://125087707
2024-05-08 16:09:56 +01:00
Alastair Houghton 2357d6932c Refactor FilePathTemp, add tests for permission code.
Broke `FilePathTemp.swift` into separate files for POSIX and
Windows.

Added tests for permissions code on Windows.

Added leading underscores to some function names.

Made some other functions `fileprivate`.

rdar://125087707
2024-05-08 16:09:56 +01:00
Alastair HoughtonandKaroy Lorentey 33773a8eb9 Update Sources/System/FilePath/FilePathTemp.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2024-05-08 16:09:56 +01:00
Alastair Houghton 21638a06b1 Map mode bits to Windows ACLs.
This adds support for mapping POSIX-style mode bits to Windows ACLs when
calling `open()` or `mkdir()`.

rdar://125087707
2024-05-08 16:09:56 +01:00
Alastair Houghton ec7d406cd4 Changes after comments from Saleem.
Use idiomatic Swift notation, not `Optional<Bool>`.

Prefer Win32 APIs to UCRT APIs.

rdar://125087707
2024-05-08 16:09:56 +01:00
Alastair Houghton c6456a9c03 Use the proper temporary directory on Darwin.
It seems we can get the temporary directory from confstr().

rdar://125087707
2024-05-08 16:09:56 +01:00
Alastair Houghton cfd3f9da90 Fix swift-system to work on Windows.
The swift-system tests were not passing, for various reasons, mostly
to do with path related confusion.

As part of this, add a function to create a temporary directory, as that
was one of the problems.

Also add Windows support for pipe() and ftruncate(), which was missing.

rdar://125087707
2024-05-08 16:09:54 +01:00
Max DesiatovandGuillaume Lessard 40b6b0ef8c Add support for WASILibc module (#159)
Quoting the [wasi.dev landing page](https://wasi.dev):
> The WebAssembly System Interface (WASI) is a group of standard API specifications for software compiled to the W3C WebAssembly (Wasm) standard. WASI is designed to provide a secure standard interface for applications that can be compiled to Wasm from any language, and that may run anywhere—from browsers to clouds to embedded devices.

Currently support for WASI in Swift is based on [`wasi-libc`](https://github.com/WebAssembly/wasi-libc).

Adding support for `wasi-libc` mostly amounted to excluding unsupported errnos, adding TLS dictionary storage shim for single-threaded environment, and adding constants in C headers for macros that Clang importer currently doesn't support.

Co-authored-by: Guillaume Lessard <guillaume.lessard@apple.com>
2024-04-30 17:11:39 +01:00
Guillaume Lessard 6609a401b9 Update copyright notices 2024-03-08 12:16:44 -08:00
Guillaume Lessard 17e9790792 Rename withSystemChars
- `withNullTerminatedSystemChars` makes it clear that the null-termination is included. Operations where the null-termination is included should be obvious.
2024-03-08 12:16:43 -08:00
Guillaume Lessard def7b1a70c Fix behaviour of withCodeUnits()
- The original implementation includes a trailing zero with the full collection, but the implementation for a slice does not. As a result, given a `let s: SystemString`, `s.string` was not equal to `s[…].string`
2024-03-08 12:13:04 -08:00
Guillaume Lessard c86758849a Test SystemString.string property consistency 2024-03-08 12:13:04 -08:00
Guillaume Lessard afb7fa4eef Generate SystemString.string consistently
- SystemString.string and Slice<SystemString>.string should be generated in the same manner. Now they are.
2024-03-08 12:13:04 -08:00
13 changed files with 172 additions and 37 deletions

No files matched your search

+2 -1
View File
@@ -2,7 +2,8 @@
/.swiftpm
/.build
/Packages
swift-system.xcodeproj
/*.xcodeproj
xcuserdata/
.*.sw?
/.swiftpm
.docc-build
+2
View File
@@ -11,6 +11,8 @@ cmake_minimum_required(VERSION 3.16.0)
project(SwiftSystem
LANGUAGES C Swift)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+2 -2
View File
@@ -9,8 +9,8 @@ See https://swift.org/LICENSE.txt for license information
add_library(CSystem INTERFACE)
target_include_directories(CSystem INTERFACE
include)
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
$<INSTALL_INTERFACE:include/CSystem>)
install(FILES
include/CSystemLinux.h
+40 -6
View File
@@ -1067,7 +1067,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
public static var ENOSYS: Errno { noFunction }
// BSD
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
/// Inappropriate file type or format.
///
/// The file was the wrong type for the operation,
@@ -1082,7 +1082,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
public static var EFTYPE: Errno { badFileTypeOrFormat }
#endif
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
/// Authentication error.
///
/// The authentication ticket used to mount an NFS file system was invalid.
@@ -1253,7 +1253,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
@available(*, unavailable, renamed: "illegalByteSequence")
public static var EILSEQ: Errno { illegalByteSequence }
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
/// Attribute not found.
///
/// The specified extended attribute doesn't exist.
@@ -1294,7 +1294,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
@available(*, unavailable, renamed: "multiHop")
public static var EMULTIHOP: Errno { multiHop }
#if !os(WASI)
#if !os(WASI) && !os(FreeBSD)
/// No message available.
///
/// No message was available to be received by the requested operation.
@@ -1320,7 +1320,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
@available(*, unavailable, renamed: "noLink")
public static var ENOLINK: Errno { noLink }
#if !os(WASI)
#if !os(WASI) && !os(FreeBSD)
/// Reserved.
///
/// This error is reserved for future use.
@@ -1361,7 +1361,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
@available(*, unavailable, renamed: "protocolError")
public static var EPROTO: Errno { protocolError }
#if !os(OpenBSD) && !os(WASI)
#if !os(OpenBSD) && !os(WASI) && !os(FreeBSD)
/// Reserved.
///
/// This error is reserved for future use.
@@ -1459,6 +1459,38 @@ extension Errno {
public static var EOWNERDEAD: Errno { previousOwnerDied }
#endif
#if os(FreeBSD)
/// Capabilities insufficient.
///
/// The corresponding C error is `ENOTCAPABLE`.
@_alwaysEmitIntoClient
public static var notCapable: Errno { .init(rawValue: _ENOTCAPABLE) }
@_alwaysEmitIntoClient
@available(*, unavailable, renamed: "notCapable")
public static var ENOTCAPABLE: Errno { notCapable }
/// Not permitted in capability mode.
///
/// The corresponding C error is `ECAPMODE`.
@_alwaysEmitIntoClient
public static var capabilityMode: Errno { .init(rawValue: _ECAPMODE) }
@_alwaysEmitIntoClient
@available(*, unavailable, renamed: "capabilityMode")
public static var ECAPMODE: Errno { capabilityMode }
/// Integrity check failed.
///
/// The corresponding C error is `EINTEGRITY`.
@_alwaysEmitIntoClient
public static var integrityCheckFailed: Errno { .init(rawValue: _EINTEGRITY) }
@_alwaysEmitIntoClient
@available(*, unavailable, renamed: "integrityCheckFailed")
public static var EINTEGRITY: Errno { integrityCheckFailed }
#endif
#if SYSTEM_PACKAGE_DARWIN
/// Interface output queue is full.
///
@@ -1469,7 +1501,9 @@ extension Errno {
@_alwaysEmitIntoClient
@available(*, unavailable, renamed: "outputQueueFull")
public static var EQFULL: Errno { outputQueueFull }
#endif
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
/// The largest valid error.
///
/// This value is the largest valid value
+31 -2
View File
@@ -182,7 +182,7 @@ extension FileDescriptor {
@available(*, unavailable, renamed: "exclusiveCreate")
public static var O_EXCL: OpenOptions { exclusiveCreate }
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
/// Indicates that opening the file
/// atomically obtains a shared lock on the file.
///
@@ -250,6 +250,22 @@ extension FileDescriptor {
public static var O_DIRECTORY: OpenOptions { directory }
#endif
#if os(FreeBSD)
/// Indicates that each write operation is synchronous.
///
/// If this option is specified,
/// each time you write to the file,
/// the new data is written immediately and synchronously to the disk.
///
/// The corresponding C constant is `O_SYNC`.
@_alwaysEmitIntoClient
public static var sync: OpenOptions { .init(rawValue: _O_SYNC) }
@_alwaysEmitIntoClient
@available(*, unavailable, renamed: "sync")
public static var O_SYNC: OpenOptions { sync }
#endif
#if SYSTEM_PACKAGE_DARWIN
/// Indicates that opening the file
/// opens symbolic links instead of following them.
@@ -354,7 +370,7 @@ extension FileDescriptor {
// TODO: These are available on some versions of Linux with appropriate
// macro defines.
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
/// Indicates that the offset should be set
/// to the next hole after the specified number of bytes.
///
@@ -456,6 +472,19 @@ extension FileDescriptor.OpenOptions
(.truncate, ".truncate"),
(.exclusiveCreate, ".exclusiveCreate"),
]
#elseif os(FreeBSD)
let descriptions: [(Element, StaticString)] = [
(.nonBlocking, ".nonBlocking"),
(.append, ".append"),
(.create, ".create"),
(.truncate, ".truncate"),
(.exclusiveCreate, ".exclusiveCreate"),
(.sharedLock, ".sharedLock"),
(.exclusiveLock, ".exclusiveLock"),
(.sync, ".sync"),
(.noFollow, ".noFollow"),
(.closeOnExec, ".closeOnExec")
]
#else
let descriptions: [(Element, StaticString)] = [
(.nonBlocking, ".nonBlocking"),
@@ -17,7 +17,7 @@ internal func _getTemporaryDirectory() throws -> FilePath {
capacity: Int(MAX_PATH) + 1) {
buffer in
guard GetTempPath2W(DWORD(buffer.count), buffer.baseAddress) != 0 else {
guard GetTempPathW(DWORD(buffer.count), buffer.baseAddress) != 0 else {
throw Errno(windowsError: GetLastError())
}
+30 -7
View File
@@ -359,7 +359,7 @@ internal var _ENOLCK: CInt { ENOLCK }
@_alwaysEmitIntoClient
internal var _ENOSYS: CInt { ENOSYS }
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
@_alwaysEmitIntoClient
internal var _EFTYPE: CInt { EFTYPE }
@@ -368,7 +368,9 @@ internal var _EAUTH: CInt { EAUTH }
@_alwaysEmitIntoClient
internal var _ENEEDAUTH: CInt { ENEEDAUTH }
#endif
#if SYSTEM_PACKAGE_DARWIN
@_alwaysEmitIntoClient
internal var _EPWROFF: CInt { EPWROFF }
@@ -409,7 +411,7 @@ internal var _ENOMSG: CInt { ENOMSG }
@_alwaysEmitIntoClient
internal var _EILSEQ: CInt { EILSEQ }
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
@_alwaysEmitIntoClient
internal var _ENOATTR: CInt { ENOATTR }
#endif
@@ -422,7 +424,7 @@ internal var _EBADMSG: CInt { EBADMSG }
@_alwaysEmitIntoClient
internal var _EMULTIHOP: CInt { EMULTIHOP }
#if !os(WASI)
#if !os(WASI) && !os(FreeBSD)
@_alwaysEmitIntoClient
internal var _ENODATA: CInt { ENODATA }
#endif
@@ -430,7 +432,7 @@ internal var _ENODATA: CInt { ENODATA }
@_alwaysEmitIntoClient
internal var _ENOLINK: CInt { ENOLINK }
#if !os(WASI)
#if !os(WASI) && !os(FreeBSD)
@_alwaysEmitIntoClient
internal var _ENOSR: CInt { ENOSR }
@@ -442,7 +444,7 @@ internal var _ENOSTR: CInt { ENOSTR }
@_alwaysEmitIntoClient
internal var _EPROTO: CInt { EPROTO }
#if !os(OpenBSD) && !os(WASI)
#if !os(OpenBSD) && !os(WASI) && !os(FreeBSD)
@_alwaysEmitIntoClient
internal var _ETIME: CInt { ETIME }
#endif
@@ -471,10 +473,23 @@ internal var _ENOTRECOVERABLE: CInt { ENOTRECOVERABLE }
internal var _EOWNERDEAD: CInt { EOWNERDEAD }
#endif
#if os(FreeBSD)
@_alwaysEmitIntoClient
internal var _ENOTCAPABLE: CInt { ENOTCAPABLE }
@_alwaysEmitIntoClient
internal var _ECAPMODE: CInt { ECAPMODE }
@_alwaysEmitIntoClient
internal var _EINTEGRITY: CInt { EINTEGRITY }
#endif
#if SYSTEM_PACKAGE_DARWIN
@_alwaysEmitIntoClient
internal var _EQFULL: CInt { EQFULL }
#endif
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
@_alwaysEmitIntoClient
internal var _ELAST: CInt { ELAST }
#endif
@@ -524,7 +539,7 @@ internal var _O_APPEND: CInt {
#endif
}
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
@_alwaysEmitIntoClient
internal var _O_SHLOCK: CInt { O_SHLOCK }
@@ -543,6 +558,14 @@ internal var _O_ASYNC: CInt { O_ASYNC }
internal var _O_NOFOLLOW: CInt { O_NOFOLLOW }
#endif
#if os(FreeBSD)
@_alwaysEmitIntoClient
internal var _O_FSYNC: CInt { O_FSYNC }
@_alwaysEmitIntoClient
internal var _O_SYNC: CInt { O_SYNC }
#endif
@_alwaysEmitIntoClient
internal var _O_CREAT: CInt {
#if os(WASI)
@@ -609,7 +632,7 @@ internal var _SEEK_CUR: CInt { SEEK_CUR }
@_alwaysEmitIntoClient
internal var _SEEK_END: CInt { SEEK_END }
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
@_alwaysEmitIntoClient
internal var _SEEK_HOLE: CInt { SEEK_HOLE }
+7 -1
View File
@@ -80,7 +80,13 @@ extension _RawBuffer {
internal static func create(minimumCapacity: Int) -> Storage {
Storage.create(
minimumCapacity: minimumCapacity,
makingHeaderWith: { $0.capacity }
makingHeaderWith: {
#if os(OpenBSD)
minimumCapacity
#else
$0.capacity
#endif
}
) as! Storage
}
}
+1 -1
View File
@@ -191,7 +191,7 @@ internal func system_confstr(
internal let SYSTEM_AT_REMOVE_DIR = AT_REMOVEDIR
internal let SYSTEM_DT_DIR = DT_DIR
internal typealias system_dirent = dirent
#if os(Linux) || os(Android)
#if os(Linux) || os(Android) || os(FreeBSD) || os(OpenBSD)
internal typealias system_DIRPtr = OpaquePointer
#else
internal typealias system_DIRPtr = UnsafeMutablePointer<DIR>
@@ -187,7 +187,7 @@ internal func pwrite(
internal func pipe(
_ fds: UnsafeMutablePointer<Int32>, bytesReserved: UInt32 = 4096
) -> CInt {
  return _pipe(fds, bytesReserved, _O_BINARY | _O_NOINHERIT);
return _pipe(fds, bytesReserved, _O_BINARY | _O_NOINHERIT);
}
@inline(__always)
+16 -3
View File
@@ -131,10 +131,13 @@ final class ErrnoTest: XCTestCase {
XCTAssert(ENOLCK == Errno.noLocks.rawValue)
XCTAssert(ENOSYS == Errno.noFunction.rawValue)
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
XCTAssert(EFTYPE == Errno.badFileTypeOrFormat.rawValue)
XCTAssert(EAUTH == Errno.authenticationError.rawValue)
XCTAssert(ENEEDAUTH == Errno.needAuthenticator.rawValue)
#endif
#if SYSTEM_PACKAGE_DARWIN
XCTAssert(EPWROFF == Errno.devicePowerIsOff.rawValue)
XCTAssert(EDEVERR == Errno.deviceError.rawValue)
#endif
@@ -164,13 +167,17 @@ final class ErrnoTest: XCTestCase {
#if !os(Windows)
XCTAssert(EBADMSG == Errno.badMessage.rawValue)
XCTAssert(EMULTIHOP == Errno.multiHop.rawValue)
XCTAssert(ENODATA == Errno.noData.rawValue)
XCTAssert(ENOLINK == Errno.noLink.rawValue)
XCTAssert(EPROTO == Errno.protocolError.rawValue)
#endif
#if !os(Windows) && !os(FreeBSD)
XCTAssert(ENODATA == Errno.noData.rawValue)
XCTAssert(ENOSR == Errno.noStreamResources.rawValue)
XCTAssert(ENOSTR == Errno.notStream.rawValue)
XCTAssert(EPROTO == Errno.protocolError.rawValue)
XCTAssert(ETIME == Errno.timeout.rawValue)
#endif
XCTAssert(EOPNOTSUPP == Errno.notSupportedOnSocket.rawValue)
// From headers but not man page
@@ -192,6 +199,12 @@ final class ErrnoTest: XCTestCase {
XCTAssert(EOWNERDEAD == Errno.previousOwnerDied.rawValue)
#endif
#if os(FreeBSD)
XCTAssert(ENOTCAPABLE == Errno.notCapable.rawValue)
XCTAssert(ECAPMODE == Errno.capabilityMode.rawValue)
XCTAssert(EINTEGRITY == Errno.integrityCheckFailed.rawValue)
#endif
#if SYSTEM_PACKAGE_DARWIN
XCTAssert(EQFULL == Errno.outputQueueFull.rawValue)
XCTAssert(ELAST == Errno.lastErrnoValue.rawValue)
+9 -2
View File
@@ -42,18 +42,25 @@ final class FileDescriptorTest: XCTestCase {
#endif
// BSD only
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
XCTAssertEqual(O_SHLOCK, FileDescriptor.OpenOptions.sharedLock.rawValue)
XCTAssertEqual(O_EXLOCK, FileDescriptor.OpenOptions.exclusiveLock.rawValue)
#endif
#if SYSTEM_PACKAGE_DARWIN
XCTAssertEqual(O_SYMLINK, FileDescriptor.OpenOptions.symlink.rawValue)
XCTAssertEqual(O_EVTONLY, FileDescriptor.OpenOptions.eventOnly.rawValue)
#endif
#if os(FreeBSD)
XCTAssertEqual(O_SYNC, FileDescriptor.OpenOptions.sync.rawValue)
#endif
XCTAssertEqual(SEEK_SET, FileDescriptor.SeekOrigin.start.rawValue)
XCTAssertEqual(SEEK_CUR, FileDescriptor.SeekOrigin.current.rawValue)
XCTAssertEqual(SEEK_END, FileDescriptor.SeekOrigin.end.rawValue)
#if SYSTEM_PACKAGE_DARWIN
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
XCTAssertEqual(SEEK_HOLE, FileDescriptor.SeekOrigin.nextHole.rawValue)
XCTAssertEqual(SEEK_DATA, FileDescriptor.SeekOrigin.nextData.rawValue)
#endif
+30 -10
View File
@@ -36,7 +36,7 @@ function(get_swift_host_arch result_var_name)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a")
set("${result_var_name}" "armv7" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64")
set("${result_var_name}" "amd64" PARENT_SCOPE)
set("${result_var_name}" "x86_64" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
set("${result_var_name}" "x86_64" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64")
@@ -45,6 +45,8 @@ function(get_swift_host_arch result_var_name)
set("${result_var_name}" "i686" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
set("${result_var_name}" "i686" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "riscv64")
set("${result_var_name}" "riscv64" PARENT_SCOPE)
else()
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
@@ -67,6 +69,28 @@ function(get_swift_host_os result_var_name)
endif()
endfunction()
if(NOT Swift_MODULE_TRIPLE)
# Attempt to get the module triple from the Swift compiler.
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
if(CMAKE_Swift_COMPILER_TARGET)
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
endif()
execute_process(COMMAND ${module_triple_command}
OUTPUT_VARIABLE target_info_json)
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
# Exit now if we failed to infer the triple.
if(NOT module_triple)
message(FATAL_ERROR
"Failed to get module triple from Swift compiler. "
"Compiler output: ${target_info_json}")
endif()
# Cache the module triple for future use.
set(Swift_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files")
mark_as_advanced(Swift_MODULE_TRIPLE)
endif()
function(_install_target module)
get_swift_host_os(swift_os)
get_target_property(type ${module} TYPE)
@@ -77,24 +101,20 @@ function(_install_target module)
set(swift swift)
endif()
install(TARGETS ${module}
ARCHIVE DESTINATION lib/${swift}/${swift_os}
LIBRARY DESTINATION lib/${swift}/${swift_os}
RUNTIME DESTINATION bin)
install(TARGETS ${module})
if(type STREQUAL EXECUTABLE)
return()
endif()
get_swift_host_arch(swift_arch)
get_target_property(module_name ${module} Swift_MODULE_NAME)
if(NOT module_name)
set(module_name ${module})
endif()
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${swift_arch}.swiftdoc)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${Swift_MODULE_TRIPLE}.swiftdoc)
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${swift_arch}.swiftmodule)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${Swift_MODULE_TRIPLE}.swiftmodule)
endfunction()