mirror of
https://github.com/apple/swift-system
synced 2026-11-24 04:38:14 +00:00
73 lines
1.9 KiB
Swift
73 lines
1.9 KiB
Swift
/*
|
|
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
|
|
*/
|
|
|
|
// Compile-only canary for MemberImportVisibility regressions: this file fails
|
|
// to build if a C member of a type SystemPackage vends is attributed to the
|
|
// private CSystem module.
|
|
//
|
|
// For new type wrappers introduced to System, access their C members here:
|
|
// - Import the platform overlay (Glibc/Musl/Android), as consumers do.
|
|
// - 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, 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)
|
|
import Glibc
|
|
#elseif canImport(Musl)
|
|
import Musl
|
|
#elseif canImport(Android)
|
|
import Android
|
|
#endif
|
|
import SystemPackage
|
|
|
|
func _mivProbe(_ s: CInterop.Stat) {
|
|
_ = s.st_dev
|
|
_ = s.st_ino
|
|
_ = s.st_mode
|
|
_ = s.st_nlink
|
|
_ = s.st_uid
|
|
_ = s.st_gid
|
|
_ = s.st_rdev
|
|
_ = s.st_size
|
|
_ = s.st_blksize
|
|
_ = s.st_blocks
|
|
_ = s.st_atim
|
|
_ = s.st_mtim
|
|
_ = s.st_ctim
|
|
_ = s.st_atim.tv_sec
|
|
_ = s.st_atim.tv_nsec
|
|
}
|
|
|
|
// These are the Linux and Android field names. FreeBSD's libc module is also
|
|
// named Glibc, but its `statfs` and `fsid_t` use the BSD names.
|
|
#if os(Linux) || os(Android)
|
|
func _mivProbe(_ s: CInterop.StatFS) {
|
|
_ = s.f_type
|
|
_ = s.f_bsize
|
|
_ = s.f_blocks
|
|
_ = s.f_bfree
|
|
_ = s.f_bavail
|
|
_ = s.f_files
|
|
_ = s.f_ffree
|
|
_ = s.f_fsid
|
|
_ = s.f_namelen
|
|
_ = s.f_frsize
|
|
_ = s.f_flags
|
|
}
|
|
|
|
func _mivProbe(_ id: CInterop.FileSystemID) {
|
|
_ = id.__val
|
|
}
|
|
#endif
|
|
#endif
|