Skip to content

Commit 48de264

Browse files
authored
[Build] use timespec_get to get current time (#5252)
Replace clock_gettime with timespec_get which works on Windows as well. For #4661
1 parent 11cf2c8 commit 48de264

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extension/llm/runner/util.h

+6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ ET_EXPERIMENTAL void inline safe_printf(const char* piece) {
6868
ET_EXPERIMENTAL long inline time_in_ms() {
6969
// return time in milliseconds, for benchmarking the model speed
7070
struct timespec time;
71+
// The `timespec_get` function is only available on Android API levels
72+
// 29 or later.
73+
#if defined(__ANDROID_API__) && __ANDROID_API__ < 29
7174
clock_gettime(CLOCK_REALTIME, &time);
75+
#else
76+
timespec_get(&time, TIME_UTC);
77+
#endif
7278
return time.tv_sec * 1000 + time.tv_nsec / 1000000;
7379
}
7480

0 commit comments

Comments
 (0)