Skip to content

Commit e256339

Browse files
kotlarmilosjkotas
andauthored
Fix time retrieval for Apple mobile in LogAssert (#120358)
* Fix time retrieval for Apple mobile in LogAssert * Update src/coreclr/utilcode/debug.cpp Co-authored-by: Jan Kotas <[email protected]> * Update src/coreclr/utilcode/debug.cpp Co-authored-by: Jan Kotas <[email protected]> --------- Co-authored-by: Jan Kotas <[email protected]>
1 parent 1e1451e commit e256339

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/coreclr/utilcode/debug.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "ex.h"
1313
#include "corexcep.h"
1414
#include <time.h>
15+
#if defined(HOST_IOS) || defined(HOST_TVOS) || defined(HOST_MACCATALYST)
16+
#include <sys/time.h>
17+
#endif
1518

1619
#include <minipal/debugger.h>
1720

@@ -160,7 +163,15 @@ VOID LogAssert(
160163
STRESS_LOG2(LF_ASSERT, LL_ALWAYS, "ASSERT:%s:%d\n", szFile, iLine);
161164

162165
struct timespec ts;
166+
#if defined(HOST_IOS) || defined(HOST_TVOS) || defined(HOST_MACCATALYST)
167+
// timespec_get is only available on iOS 13.0+, use gettimeofday instead
168+
struct timeval tv;
169+
gettimeofday(&tv, nullptr);
170+
ts.tv_sec = tv.tv_sec;
171+
ts.tv_nsec = tv.tv_usec * 1000;
172+
#else
163173
int ret = timespec_get(&ts, TIME_UTC);
174+
#endif
164175

165176
struct tm local;
166177
#ifdef HOST_WINDOWS

0 commit comments

Comments
 (0)