mirror of
https://github.com/apple/swift-system
synced 2026-11-23 04:34:26 +00:00
Compare commits
7
Commits
1.8.0
...
release/1.8.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f325ebf78f | ||
|
|
4179b2cce5 | ||
|
|
f5fe750a57 | ||
|
|
b0d4217c8c | ||
|
|
869129b7bf | ||
|
|
5c2854d7bd | ||
|
|
d0ef8d091d |
No files matched your search
@@ -10,7 +10,7 @@ on:
|
||||
jobs:
|
||||
tests:
|
||||
name: Test
|
||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.12
|
||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.15
|
||||
with:
|
||||
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
|
||||
enable_linux_checks: true
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
|
||||
build-abi-stable:
|
||||
name: Build ABI Stable
|
||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.12
|
||||
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.15
|
||||
with:
|
||||
enable_linux_checks: false
|
||||
enable_macos_checks: true
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
|
||||
soundness:
|
||||
name: Soundness
|
||||
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.12
|
||||
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.15
|
||||
with:
|
||||
license_header_check_project_name: "Swift.org"
|
||||
# https://github.com/apple/swift-system/issues/224
|
||||
|
||||
@@ -32,7 +32,7 @@ To use the `SystemPackage` library in a SwiftPM project,
|
||||
add the following line to the dependencies in your `Package.swift` file:
|
||||
|
||||
```swift
|
||||
.package(url: "https://github.com/apple/swift-system", from: "1.7.1"),
|
||||
.package(url: "https://github.com/apple/swift-system", from: "1.8.0"),
|
||||
```
|
||||
|
||||
Finally, include `"SystemPackage"` as a dependency for your executable target:
|
||||
@@ -41,7 +41,7 @@ Finally, include `"SystemPackage"` as a dependency for your executable target:
|
||||
let package = Package(
|
||||
// name, platforms, products, etc.
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-system", from: "1.7.1"),
|
||||
.package(url: "https://github.com/apple/swift-system", from: "1.8.0"),
|
||||
// other dependencies
|
||||
],
|
||||
targets: [
|
||||
@@ -87,8 +87,8 @@ The following table maps existing package releases to their minimum required Swi
|
||||
| Package version | Swift version | Xcode release |
|
||||
| ----------------------- | --------------- | ------------- |
|
||||
| swift-system 1.3.x | >= Swift 5.8 | >= Xcode 14.3 |
|
||||
| swift-system 1.4.x through 1.6.x | >= Swift 5.9 | >= Xcode 15.0 |
|
||||
| swift-system 1.7.x | >= Swift 6.1 | >= Xcode 16.3 |
|
||||
| swift-system 1.4.0 through 1.6.x | >= Swift 5.9 | >= Xcode 15.0 |
|
||||
| swift-system 1.7.0 through 1.8.x | >= Swift 6.1 | >= Xcode 16.3 |
|
||||
|
||||
We'd like this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate. Accordingly, from time to time, new versions of this package require clients to upgrade to a more recent Swift toolchain release. (This allows the package to make use of new language/stdlib features, build on compiler bug fixes, and adopt new package manager functionality as soon as they are available.) Patch (i.e., bugfix) releases will not increase the required toolchain version, but any minor (i.e., new feature) release may do so.
|
||||
|
||||
@@ -113,13 +113,14 @@ We maintain separate branches for each active minor version of the package:
|
||||
| swift-system 1.5.x | release/1.5.0 |
|
||||
| swift-system 1.6.x | release/1.6.0 |
|
||||
| swift-system 1.7.x | release/1.7.0 |
|
||||
| swift-system 1.8.x (unreleased) | main |
|
||||
| swift-system 1.8.x | release/1.8.x |
|
||||
| swift-system 1.9.x (unreleased) | |
|
||||
|
||||
Changes must land on the branch corresponding to the earliest release that they will need to ship on. They are periodically propagated to subsequent branches, in the following direction:
|
||||
|
||||
`release/1.6.0` → `release/1.7.0` → `main`
|
||||
`release/1.7.0` → `release/1.8.x` → `main`
|
||||
|
||||
For example, anything landing on `release/1.3` will eventually appear on `release/1.4` and then `main` too; there is no need to file standalone PRs for each release line. (Change propagation currently requires manual work -- it is performed by project maintainers.)
|
||||
For example, anything landing on `release/1.6.0` will eventually appear on `release/1.7.0`, then `release/1.8.x` and finally `main` as well. There is no need to file standalone PRs for each release line. (Change propagation currently requires manual work -- it is performed by project maintainers.)
|
||||
|
||||
### Code of Conduct
|
||||
|
||||
|
||||
@@ -13,12 +13,9 @@ target_include_directories(CSystem PUBLIC
|
||||
$<INSTALL_INTERFACE:include/CSystem>)
|
||||
|
||||
install(FILES
|
||||
include/CSystemDarwin.h
|
||||
include/CSystemLinux.h
|
||||
include/CSystemShared.h
|
||||
include/CSystemWASI.h
|
||||
include/CSystemWindows.h
|
||||
include/CSystemFreeBSD.h
|
||||
include/io_uring.h
|
||||
include/module.modulemap
|
||||
DESTINATION include/CSystem)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2026 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef O_CLOFORK
|
||||
#define COMPATIBILITY_O_CLOFORK O_CLOFORK
|
||||
#else
|
||||
#define COMPATIBILITY_O_CLOFORK 0
|
||||
#endif
|
||||
|
||||
#endif // defined(__APPLE__)
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2026 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef O_CLOFORK
|
||||
#define COMPATIBILITY_O_CLOFORK O_CLOFORK
|
||||
#else
|
||||
#define COMPATIBILITY_O_CLOFORK 0
|
||||
#endif
|
||||
|
||||
#endif // defined(__FreeBSD__)
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2020 Apple Inc. and the Swift System project authors
|
||||
Copyright (c) 2020 - 2026 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
@@ -9,16 +9,24 @@
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <sys/epoll.h>
|
||||
// Glibc doesn't export eventfd, which the tests use.
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include "io_uring.h"
|
||||
#endif
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
#include <stddef.h>
|
||||
#include "io_uring.h"
|
||||
|
||||
// Defined in shims.c, which can include the libc headers they need.
|
||||
extern int csystem_io_uring_setup(unsigned int entries,
|
||||
struct io_uring_params *p);
|
||||
extern int csystem_io_uring_enter(int fd, unsigned int to_submit,
|
||||
unsigned int min_complete,
|
||||
unsigned int flags, void *sig);
|
||||
extern int csystem_io_uring_enter2(int fd, unsigned int to_submit,
|
||||
unsigned int min_complete,
|
||||
unsigned int flags, void *args, size_t sz);
|
||||
extern int csystem_io_uring_register(int fd, unsigned int opcode, void *arg,
|
||||
unsigned int nr_args);
|
||||
#endif // !defined(__ANDROID__)
|
||||
|
||||
#endif // __linux__
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2020 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRA_LEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/uio.h>
|
||||
#include <signal.h>
|
||||
#pragma once
|
||||
|
||||
// Types only: the syscall wrappers need libc headers, so they're in shims.c.
|
||||
|
||||
#define __SWIFT_IORING_SQE_FALLBACK_STRUCT { \
|
||||
__u8 opcode; \
|
||||
@@ -193,19 +192,6 @@ struct io_uring_params {
|
||||
};
|
||||
#endif // __has_include(<linux/io_uring.h>)
|
||||
|
||||
#ifndef SWIFT_IORING_C_WRAPPER
|
||||
#define SWIFT_IORING_C_WRAPPER
|
||||
|
||||
# ifndef __NR_io_uring_setup
|
||||
# define __NR_io_uring_setup 425
|
||||
# endif
|
||||
# ifndef __NR_io_uring_enter
|
||||
# define __NR_io_uring_enter 426
|
||||
# endif
|
||||
# ifndef __NR_io_uring_register
|
||||
# define __NR_io_uring_register 427
|
||||
# endif
|
||||
|
||||
/*
|
||||
struct io_uring_getevents_arg {
|
||||
__u64 sigmask;
|
||||
@@ -220,29 +206,3 @@ struct swift_io_uring_getevents_arg {
|
||||
__u32 min_wait_usec;
|
||||
__u64 ts;
|
||||
};
|
||||
|
||||
static inline int io_uring_register(int fd, unsigned int opcode, void *arg,
|
||||
unsigned int nr_args)
|
||||
{
|
||||
return syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
|
||||
}
|
||||
|
||||
static inline int io_uring_setup(unsigned int entries, struct io_uring_params *p)
|
||||
{
|
||||
return syscall(__NR_io_uring_setup, entries, p);
|
||||
}
|
||||
|
||||
static inline int io_uring_enter2(int fd, unsigned int to_submit, unsigned int min_complete,
|
||||
unsigned int flags, void *args, size_t sz)
|
||||
{
|
||||
return syscall(__NR_io_uring_enter, fd, to_submit, min_complete,
|
||||
flags, args, sz);
|
||||
}
|
||||
|
||||
static inline int io_uring_enter(int fd, unsigned int to_submit, unsigned int min_complete,
|
||||
unsigned int flags, sigset_t *sig)
|
||||
{
|
||||
return io_uring_enter2(fd, to_submit, min_complete, flags, sig, _NSIG / 8);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,17 @@
|
||||
// System imports CSystem with `internal import`. Don't include a header that
|
||||
// the platform's C module also includes: CSystem would then co-own its
|
||||
// declarations, so Swift would limit them to CSystem's import access level and
|
||||
// could credit their members to CSystem under MemberImportVisibility.
|
||||
// (CSystemWASI.h still does; see Constants.swift.)
|
||||
module CSystem {
|
||||
header "CSystemShared.h"
|
||||
header "CSystemDarwin.h"
|
||||
header "CSystemLinux.h"
|
||||
header "CSystemWASI.h"
|
||||
header "CSystemWindows.h"
|
||||
header "CSystemFreeBSD.h"
|
||||
export *
|
||||
}
|
||||
|
||||
// IORing's inlinable code stores these types, so System imports this module
|
||||
// with `public import`. Keep libc headers out of it too.
|
||||
module CSystemIOUring {
|
||||
header "io_uring.h"
|
||||
}
|
||||
+39
-8
@@ -14,19 +14,14 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <CSystemFreeBSD.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#define _GNU_SOURCE
|
||||
#include <signal.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <CSystemLinux.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <CSystemWindows.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined(_WIN32) && !defined(__wasi__) && !defined(__APPLE__)
|
||||
@@ -70,3 +65,39 @@ extern int csystem_posix_dup3(int fildes, int fildes2, int flag) {
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__linux__) && !defined(__ANDROID__)
|
||||
# ifndef __NR_io_uring_setup
|
||||
# define __NR_io_uring_setup 425
|
||||
# endif
|
||||
# ifndef __NR_io_uring_enter
|
||||
# define __NR_io_uring_enter 426
|
||||
# endif
|
||||
# ifndef __NR_io_uring_register
|
||||
# define __NR_io_uring_register 427
|
||||
# endif
|
||||
|
||||
extern int csystem_io_uring_setup(unsigned int entries,
|
||||
struct io_uring_params *p) {
|
||||
return syscall(__NR_io_uring_setup, entries, p);
|
||||
}
|
||||
|
||||
extern int csystem_io_uring_enter2(int fd, unsigned int to_submit,
|
||||
unsigned int min_complete,
|
||||
unsigned int flags, void *args, size_t sz) {
|
||||
return syscall(__NR_io_uring_enter, fd, to_submit, min_complete, flags,
|
||||
args, sz);
|
||||
}
|
||||
|
||||
extern int csystem_io_uring_enter(int fd, unsigned int to_submit,
|
||||
unsigned int min_complete,
|
||||
unsigned int flags, void *sig) {
|
||||
return csystem_io_uring_enter2(fd, to_submit, min_complete, flags, sig,
|
||||
_NSIG / 8);
|
||||
}
|
||||
|
||||
extern int csystem_io_uring_register(int fd, unsigned int opcode, void *arg,
|
||||
unsigned int nr_args) {
|
||||
return syscall(__NR_io_uring_register, fd, opcode, arg, nr_args);
|
||||
}
|
||||
#endif // defined(__linux__) && !defined(__ANDROID__)
|
||||
@@ -12,15 +12,13 @@
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
import Darwin
|
||||
#elseif canImport(Glibc)
|
||||
import CSystem
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
import CSystem
|
||||
import Musl
|
||||
#elseif canImport(WASILibc)
|
||||
internal import CSystem // For the members of system_dirent
|
||||
import WASILibc
|
||||
#elseif canImport(Android)
|
||||
import CSystem
|
||||
import Android
|
||||
#else
|
||||
#error("Unsupported Platform")
|
||||
|
||||
@@ -15,15 +15,12 @@
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
import Darwin
|
||||
#elseif canImport(Glibc)
|
||||
import CSystem
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
import CSystem
|
||||
import Musl
|
||||
#elseif canImport(WASILibc)
|
||||
import WASILibc
|
||||
#elseif canImport(Android)
|
||||
import CSystem
|
||||
import Android
|
||||
#else
|
||||
#error("Unsupported Platform")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#if compiler(>=6.2) && $Lifetimes
|
||||
#if os(Linux)
|
||||
|
||||
import CSystem
|
||||
public import CSystemIOUring
|
||||
|
||||
public extension IORing {
|
||||
struct Completion: ~Copyable {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#if compiler(>=6.2) && $Lifetimes
|
||||
#if os(Linux)
|
||||
|
||||
import CSystem
|
||||
public import CSystemIOUring
|
||||
|
||||
@usableFromInline
|
||||
internal enum IORequestCore {
|
||||
|
||||
@@ -10,14 +10,15 @@
|
||||
#if compiler(>=6.2) && $Lifetimes
|
||||
#if os(Linux)
|
||||
|
||||
import CSystem
|
||||
internal import CSystem
|
||||
public import CSystemIOUring
|
||||
#if canImport(Glibc)
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
import Musl
|
||||
#endif
|
||||
|
||||
/// Throwing wrapper around the `io_uring_enter2` shim.
|
||||
/// Throwing wrapper around the `csystem_io_uring_enter2` shim.
|
||||
///
|
||||
/// On success returns the syscall's non-negative result (the number of SQEs
|
||||
/// consumed by the kernel). On failure, reads `errno` and throws the matching
|
||||
@@ -32,14 +33,14 @@ internal func _ioUringEnter2(
|
||||
argsSize: Int
|
||||
) throws(Errno) -> Int32 {
|
||||
let result = valueOrErrno(retryOnInterrupt: true) {
|
||||
io_uring_enter2(
|
||||
csystem_io_uring_enter2(
|
||||
ringDescriptor, toSubmit, minComplete, flags, args, argsSize
|
||||
)
|
||||
}
|
||||
return try result.get()
|
||||
}
|
||||
|
||||
/// Throwing wrapper around the `io_uring_enter` shim.
|
||||
/// Throwing wrapper around the `csystem_io_uring_enter` shim.
|
||||
///
|
||||
/// On success returns the syscall's non-negative result (the number of SQEs
|
||||
/// consumed by the kernel). On failure, reads `errno` and throws the matching
|
||||
@@ -53,12 +54,12 @@ internal func _ioUringEnter(
|
||||
sig: UnsafeMutablePointer<sigset_t>?
|
||||
) throws(Errno) -> Int32 {
|
||||
let result = valueOrErrno(retryOnInterrupt: true) {
|
||||
io_uring_enter(ringDescriptor, toSubmit, minComplete, flags, sig)
|
||||
csystem_io_uring_enter(ringDescriptor, toSubmit, minComplete, flags, sig)
|
||||
}
|
||||
return try result.get()
|
||||
}
|
||||
|
||||
/// Throwing wrapper around the `io_uring_register` shim.
|
||||
/// Throwing wrapper around the `csystem_io_uring_register` shim.
|
||||
///
|
||||
/// On success returns the syscall's non-negative result. On failure, reads
|
||||
/// `errno` and throws the matching `Errno`. `EINTR` is retried automatically.
|
||||
@@ -70,7 +71,7 @@ internal func _ioUringRegister(
|
||||
nrArgs: UInt32
|
||||
) throws(Errno) -> Int32 {
|
||||
let result = valueOrErrno(retryOnInterrupt: true) {
|
||||
io_uring_register(ringDescriptor, opcode, arg, nrArgs)
|
||||
csystem_io_uring_register(ringDescriptor, opcode, arg, nrArgs)
|
||||
}
|
||||
return try result.get()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#if compiler(>=6.2) && $Lifetimes
|
||||
#if os(Linux)
|
||||
|
||||
import CSystem
|
||||
internal import CSystem
|
||||
public import CSystemIOUring
|
||||
// needed for mmap
|
||||
#if canImport(Glibc)
|
||||
import Glibc
|
||||
@@ -223,7 +224,7 @@ private func setUpRing(
|
||||
|
||||
var err: Errno? = nil
|
||||
let ringDescriptor = withUnsafeMutablePointer(to: ¶ms) {
|
||||
let result = io_uring_setup(queueDepth, $0)
|
||||
let result = csystem_io_uring_setup(queueDepth, $0)
|
||||
if result < 0 {
|
||||
err = Errno.current
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#if compiler(>=6.2) && $Lifetimes
|
||||
#if os(Linux)
|
||||
|
||||
import CSystem
|
||||
public import CSystemIOUring
|
||||
#if canImport(Glibc)
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
|
||||
@@ -10,19 +10,15 @@
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
import Darwin
|
||||
#elseif os(Windows)
|
||||
import CSystem
|
||||
import ucrt
|
||||
#elseif canImport(Glibc)
|
||||
import CSystem
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
import CSystem
|
||||
import Musl
|
||||
#elseif canImport(WASILibc)
|
||||
import WASILibc
|
||||
#elseif canImport(Bionic)
|
||||
import CSystem
|
||||
import Bionic
|
||||
#elseif canImport(Android)
|
||||
import Android
|
||||
#else
|
||||
#error("Unsupported Platform")
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import Darwin
|
||||
#elseif os(Windows)
|
||||
import ucrt
|
||||
import WinSDK
|
||||
#elseif canImport(Glibc)
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
@@ -27,7 +28,10 @@ import Android
|
||||
#error("Unsupported Platform")
|
||||
#endif
|
||||
|
||||
import CSystem
|
||||
// Some WASI constants come from CSystem and are inlined into clients.
|
||||
#if os(WASI)
|
||||
public import CSystem
|
||||
#endif
|
||||
|
||||
// MARK: errno
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
@@ -630,7 +634,7 @@ internal var _O_CLOEXEC: CInt {
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _O_CLOFORK: CInt {
|
||||
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
|
||||
COMPATIBILITY_O_CLOFORK
|
||||
0x0800_0000 // O_CLOFORK, which SDKs before macOS 27 and older FreeBSD lack
|
||||
#elseif !os(WASI) && !os(Linux) && !os(Android)
|
||||
O_CLOFORK
|
||||
#else
|
||||
|
||||
@@ -10,23 +10,18 @@
|
||||
// Internal wrappers and typedefs which help reduce #if littering in System's
|
||||
// code base.
|
||||
|
||||
// TODO: Should CSystem just include all the header files we need?
|
||||
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
import Darwin
|
||||
#elseif os(Windows)
|
||||
import CSystem
|
||||
import ucrt
|
||||
import WinSDK
|
||||
#elseif canImport(Glibc)
|
||||
import CSystem
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
import CSystem
|
||||
import Musl
|
||||
#elseif canImport(WASILibc)
|
||||
import WASILibc
|
||||
#elseif canImport(Android)
|
||||
import CSystem
|
||||
import Android
|
||||
#else
|
||||
#error("Unsupported Platform")
|
||||
@@ -184,7 +179,7 @@ extension String {
|
||||
// TLS
|
||||
#if os(Windows)
|
||||
internal typealias _PlatformTLSKey = DWORD
|
||||
#elseif os(WASI) && (swift(<6.1) || !_runtime(_multithreaded))
|
||||
#elseif os(WASI) && !_runtime(_multithreaded)
|
||||
// Mock TLS storage for single-threaded WASI.
|
||||
// Carries no state of its own, and only used to index `sharedTLSStorage`.
|
||||
internal final class _PlatformTLSKey: @unchecked Sendable {
|
||||
@@ -214,7 +209,7 @@ internal func makeTLSKey() -> _PlatformTLSKey {
|
||||
fatalError("Unable to create key")
|
||||
}
|
||||
return raw
|
||||
#elseif os(WASI) && (swift(<6.1) || !_runtime(_multithreaded))
|
||||
#elseif os(WASI) && !_runtime(_multithreaded)
|
||||
return _PlatformTLSKey()
|
||||
#else
|
||||
var raw = pthread_key_t()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
import CSystem
|
||||
internal import CSystem
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
import Darwin
|
||||
#elseif canImport(Glibc)
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
|
||||
#if canImport(Darwin, _version: 310)
|
||||
import Darwin.Mach
|
||||
#else
|
||||
@preconcurrency import Darwin.Mach
|
||||
#endif
|
||||
|
||||
@available(System 1.4.0, *)
|
||||
public protocol MachPortRight {}
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
// - Access raw C members of vended types (e.g. CInterop.Stat) as a downstream
|
||||
// consumer would. Don't go through the Swift (e.g. Stat) wrapper since its
|
||||
// accesses happen inside System, where importing CSystem is fine.
|
||||
// - Touch every direct member the public API exposes. One field is not always
|
||||
// a safe proxy for the rest.
|
||||
// - Touch every direct member the public API exposes, and the members of C
|
||||
// types it exposes through them (e.g. timespec). One field is not always a
|
||||
// safe proxy for the rest.
|
||||
|
||||
#if canImport(Glibc) || canImport(Musl) || canImport(Android)
|
||||
#if canImport(Glibc)
|
||||
@@ -43,5 +44,7 @@ func _mivProbe(_ s: CInterop.Stat) {
|
||||
_ = s.st_atim
|
||||
_ = s.st_mtim
|
||||
_ = s.st_ctim
|
||||
_ = s.st_atim.tv_sec
|
||||
_ = s.st_atim.tv_nsec
|
||||
}
|
||||
#endif
|
||||
@@ -201,6 +201,22 @@ final class FileOperationsTest: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if canImport(Darwin, _version: 428) // The macOS 27 SDK defines O_CLOFORK.
|
||||
func testAdHocPipeCloseOnFork() throws {
|
||||
guard #available(macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0, *) else {
|
||||
throw XCTSkip("pipe2 and PipeOptions require anyAppleOS 27 or newer")
|
||||
}
|
||||
// System spells O_CLOFORK as a literal on Darwin.
|
||||
XCTAssertEqual(FileDescriptor.PipeOptions.closeOnFork.rawValue, O_CLOFORK)
|
||||
let pipe = try FileDescriptor.pipe(options: .closeOnFork)
|
||||
try pipe.readEnd.closeAfter {
|
||||
try pipe.writeEnd.closeAfter {
|
||||
XCTAssertEqual(fcntl(pipe.readEnd.rawValue, F_GETFD) & FD_CLOFORK, FD_CLOFORK)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // !os(WASI)
|
||||
|
||||
#if !os(Windows)
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#if os(Linux)
|
||||
|
||||
import XCTest
|
||||
import CSystem //for eventfd
|
||||
import CSystem // for eventfd and csystem_io_uring_setup
|
||||
import CSystemIOUring
|
||||
#if canImport(Glibc)
|
||||
import Glibc // for errno
|
||||
#elseif canImport(Musl)
|
||||
@@ -28,7 +29,7 @@ let uringEnabled: Bool = {
|
||||
func isUringEnabled() throws -> Bool {
|
||||
// Even if the kernel supports io_uring, the SystemPackage build may have
|
||||
// been compiled against older kernel headers that lack features it needs
|
||||
// (gated on IORING_TIMEOUT_BOOTTIME in CSystem); in that configuration
|
||||
// (gated on IORING_TIMEOUT_BOOTTIME in io_uring.h); in that configuration
|
||||
// IORing.init throws ENOTSUP. Treat that as disabled so tests skip cleanly
|
||||
// instead of failing.
|
||||
do throws(Errno) {
|
||||
@@ -59,7 +60,7 @@ func isUringEnabled() throws -> Bool {
|
||||
// - EPERM or EACCES -> treat as disabled
|
||||
// - propagate any other error.
|
||||
var params = io_uring_params()
|
||||
let raw = io_uring_setup(1, ¶ms)
|
||||
let raw = csystem_io_uring_setup(1, ¶ms)
|
||||
if raw < 0 {
|
||||
let err = Errno(rawValue: errno)
|
||||
switch err {
|
||||
|
||||
@@ -16,10 +16,8 @@ import Testing
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
import Darwin
|
||||
#elseif canImport(Glibc)
|
||||
import CSystem
|
||||
import Glibc
|
||||
#elseif canImport(Musl)
|
||||
import CSystem
|
||||
import Musl
|
||||
#elseif canImport(WASILibc)
|
||||
import CSystem
|
||||
|
||||
Reference in new issue
Block a user