Skip to content

Commit d48882b

Browse files
authored
Not using timespec_get on android api level < 29
1 parent 176f197 commit d48882b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

extension/llm/runner/util.h

Lines changed: 6 additions & 0 deletions
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+
// above 29.
73+
#if defined(__ANDROID_API__) && __ANDROID_API__ < 29
74+
clock_gettime(CLOCK_REALTIME, &time);
75+
#else
7176
timespec_get(&time, TIME_UTC);
77+
#endif
7278
return time.tv_sec * 1000 + time.tv_nsec / 1000000;
7379
}
7480

0 commit comments

Comments
 (0)