xref: /third_party/musl/src/time/clock.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/time/
1570af302Sopenharmony_ci#include <time.h>
2570af302Sopenharmony_ci#include <limits.h>
3570af302Sopenharmony_ci#include <unsupported_api.h>
4570af302Sopenharmony_ci
5570af302Sopenharmony_ciclock_t clock()
6570af302Sopenharmony_ci{
7570af302Sopenharmony_ci	struct timespec ts;
8570af302Sopenharmony_ci
9570af302Sopenharmony_ci	UNSUPPORTED_API_VOID(LITEOS_A);
10570af302Sopenharmony_ci
11570af302Sopenharmony_ci	if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
12570af302Sopenharmony_ci		return -1;
13570af302Sopenharmony_ci
14570af302Sopenharmony_ci	if (ts.tv_sec > LONG_MAX/1000000
15570af302Sopenharmony_ci	 || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
16570af302Sopenharmony_ci		return -1;
17570af302Sopenharmony_ci
18570af302Sopenharmony_ci	return ts.tv_sec*1000000 + ts.tv_nsec/1000;
19570af302Sopenharmony_ci}
20

Indexes created Thu Nov 07 10:32:03 CST 2024