clock.c\time\src - musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/time/clock.c
blob: 6724012b92ef69b8dfa19e087b940aaf6a141e10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <time.h>
#include <limits.h>
clock_t clock()
{
	struct timespec ts;
	if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
		return -1;
	if (ts.tv_sec > LONG_MAX/1000000
	 || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
		return -1;
	return ts.tv_sec*1000000 + ts.tv_nsec/1000;
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月15日 22:25:30 +0000

AltStyle によって変換されたページ (->オリジナル) /