Skip to content

Commit 9692f35

Browse files
committed
build with 64-bit time_t on 32-bit platforms
It is good practice to build with 64-bit time_t/timeval on 32-bit platforms to avoid the Y2038 issue. This is the default when building on Yocto for armv7, for example. Unfortunately suseconds_t is not an alias to a type of the correct width (unlike time_t), so for Glibc make it a private alias of time_t to fix the build.
1 parent c748c8b commit 9692f35

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/FoundationEssentials/FileManager/FileManager+Files.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,12 @@ extension _FileManagerImpl {
967967
#endif
968968
}
969969

970+
#if canImport(Glibc)
971+
// support for 64-bit timestamps on 32-bit platforms; unfortunately
972+
// suseconds_t is not an alias of the appropriate type, but time_t is
973+
typealias suseconds_t = time_t
974+
#endif
975+
970976
if let date = attributes[.modificationDate] as? Date {
971977
let (isecs, fsecs) = modf(date.timeIntervalSince1970)
972978
if let tv_sec = time_t(exactly: isecs),

0 commit comments

Comments
 (0)