Skip to content

Commit af76f14

Browse files
phauslertshortli
authored andcommitted
Convert DispatchGlobalExecutor deadline casts to a decltype based cast (which should hold on all platforms)
1 parent f3d12ed commit af76f14

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

stdlib/public/Concurrency/DispatchGlobalExecutor.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,22 +314,10 @@ clock_and_value_to_time(int clock, long long sec, long long nsec) {
314314
case swift_clock_id_continuous:
315315
return value | DISPATCH_UP_OR_MONOTONIC_TIME_MASK;
316316
case swift_clock_id_wall: {
317-
#if defined(_WIN32)
318-
struct timespec ts = {
319-
.tv_sec = sec,
320-
.tv_nsec = static_cast<long>(nsec)
321-
};
322-
#elif defined(__APPLE__)
323-
struct timespec ts = {
324-
.tv_sec = static_cast<__darwin_time_t>(sec),
325-
.tv_nsec = nsec
317+
struct timespec ts = {
318+
.tv_sec = static_cast<decltype(ts.tv_sec)>(sec),
319+
.tv_nsec = static_cast<decltype(ts.tv_nsec)>(nsec)
326320
};
327-
#else
328-
struct timespec ts = {
329-
.tv_sec = static_cast<long>(sec),
330-
.tv_nsec = nsec
331-
};
332-
#endif
333321
return dispatch_walltime(&ts, 0);
334322
}
335323
}

0 commit comments

Comments
 (0)