Skip to content

Commit 98712f6

Browse files
committed
Remove _GNU_SOURCE define and AT_EMPTY_PATH for now
1 parent 2f5b12b commit 98712f6

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ let swiftSettings = swiftSettingsAvailability + swiftSettingsCI + [
8787

8888
let cSettings: [CSetting] = [
8989
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
90-
.define("_GNU_SOURCE", .when(platforms: [.linux])),
9190
]
9291

9392
#if SYSTEM_ABI_STABLE

Sources/System/FileSystem/Stat.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,16 @@ public struct Stat: RawRepresentable, Sendable {
8686
public static var resolveBeneath: Flags { Flags(rawValue: _AT_RESOLVE_BENEATH) }
8787
#endif
8888

89-
#if os(FreeBSD) || os(Linux) || os(Android)
90-
/// If the path is an empty string (or `NULL` since Linux 6.11),
91-
/// return information about the given file descriptor.
92-
///
93-
/// The corresponding C constant is `AT_EMPTY_PATH`.
94-
/// - Note: Only available on FreeBSD, Linux, and Android.
95-
@_alwaysEmitIntoClient
96-
public static var emptyPath: Flags { Flags(rawValue: _AT_EMPTY_PATH) }
97-
#endif
89+
// TODO: Re-enable when _GNU_SOURCE can be defined.
90+
// #if os(FreeBSD) || os(Linux) || os(Android)
91+
// /// If the path is an empty string (or `NULL` since Linux 6.11),
92+
// /// return information about the given file descriptor.
93+
// ///
94+
// /// The corresponding C constant is `AT_EMPTY_PATH`.
95+
// /// - Note: Only available on FreeBSD, Linux, and Android.
96+
// @_alwaysEmitIntoClient
97+
// public static var emptyPath: Flags { Flags(rawValue: _AT_EMPTY_PATH) }
98+
// #endif
9899
}
99100

100101
// MARK: Initializers

Sources/System/Internals/Constants.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,11 @@ internal var _AT_SYMLINK_NOFOLLOW_ANY: CInt { AT_SYMLINK_NOFOLLOW_ANY }
663663
internal var _AT_RESOLVE_BENEATH: CInt { AT_RESOLVE_BENEATH }
664664
#endif
665665

666-
#if os(FreeBSD) || os(Linux) || os(Android)
667-
@_alwaysEmitIntoClient
668-
internal var _AT_EMPTY_PATH: CInt { AT_EMPTY_PATH }
669-
#endif
666+
// TODO: Re-enable when _GNU_SOURCE can be defined.
667+
//#if os(FreeBSD) || os(Linux) || os(Android)
668+
//@_alwaysEmitIntoClient
669+
//internal var _AT_EMPTY_PATH: CInt { AT_EMPTY_PATH }
670+
//#endif
670671

671672
// MARK: - File Mode / File Type
672673

Tests/SystemTests/StatTests.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ private struct StatTests {
8181
}
8282

8383
@Test
84-
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
8584
func followSymlinkInits() async throws {
8685
try withTemporaryFilePath(basename: "Stat_followSymlinkInits") { tempDir in
8786
let targetFilePath = tempDir.appending("target.txt")
@@ -98,17 +97,15 @@ private struct StatTests {
9897
}
9998
}
10099

101-
#if !os(WASI) // Can't open an fd to a symlink on WASI (no O_PATH)
100+
// Can't open an fd to a symlink on WASI (no O_PATH)
101+
// On non-Darwin, we need O_PATH | O_NOFOLLOW to open the symlink
102+
// directly, but O_PATH requires _GNU_SOURCE be defined (TODO).
102103
#if SYSTEM_PACKAGE_DARWIN
103104
let symlinkFD = try FileDescriptor.open(symlinkPath, .readOnly, options: .symlink)
104-
#else
105-
// Need O_PATH | O_NOFOLLOW to open the symlink directly
106-
let symlinkFD = try FileDescriptor.open(symlinkPath, .readOnly, options: [.path, .noFollow])
107-
#endif
108105
defer {
109106
try? symlinkFD.close()
110107
}
111-
#endif // !os(WASI)
108+
#endif
112109

113110
let targetStat = try targetFilePath.stat()
114111
let originalTargetAccessTime = targetStat.st_atim
@@ -130,7 +127,7 @@ private struct StatTests {
130127
stat.st_atim = originalTargetAccessTime
131128
#expect(stat == targetStat)
132129

133-
#if !os(WASI)
130+
#if SYSTEM_PACKAGE_DARWIN
134131
stat = try symlinkFD.stat()
135132
stat.st_atim = originalSymlinkAccessTime
136133
#expect(stat == symlinkStat)
@@ -142,7 +139,7 @@ private struct StatTests {
142139
stat.st_atim = originalTargetAccessTime
143140
#expect(stat == targetStat)
144141

145-
#if !os(WASI)
142+
#if SYSTEM_PACKAGE_DARWIN
146143
stat = try Stat(symlinkFD)
147144
stat.st_atim = originalSymlinkAccessTime
148145
#expect(stat == symlinkStat)
@@ -400,11 +397,12 @@ private struct StatTests {
400397

401398
}
402399

403-
#if !SYSTEM_PACKAGE_DARWIN && !os(WASI)
404-
private extension FileDescriptor.OpenOptions {
405-
static var path: Self { Self(rawValue: O_PATH) }
406-
}
407-
#endif
400+
// TODO: Re-enable for testing when _GNU_SOURCE can be defined.
401+
//#if !SYSTEM_PACKAGE_DARWIN && !os(WASI)
402+
//private extension FileDescriptor.OpenOptions {
403+
// static var path: Self { Self(rawValue: O_PATH) }
404+
//}
405+
//#endif
408406

409407
// Comparison operators for timespec until UTCClock.Instant properties are available
410408
private func >= (lhs: timespec, rhs: timespec) -> Bool {

0 commit comments

Comments
 (0)