1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Define CLOCKS_PER_SEC type to the type clock_t

C99 specifies that CLOCKS_PER_SEC is an expression with the type clock_t.
This patch adds a generic <bits/time2.h> to define CLOCKS_PER_SEC and
provides the Linux/x86-64 version of <bits/time2.h> to support x32.

	[BZ #17797]
	* bits/time.h (CLOCKS_PER_SEC): Changed to ((clock_t) 1000000).
	* sysdeps/unix/sysv/linux/bits/time.h (CLOCKS_PER_SEC): Likewise.
	* sysdeps/unix/sysv/linux/clock.c (clock): _Static_assert
	CLOCKS_PER_SEC == 1000000.
	* time/clocktest.c (main): Replace %ld with %jd and cast to
	intmax_t.
This commit is contained in:
H.J. Lu
2015-01-06 04:59:13 -08:00
parent 46abb64d62
commit 57ada0e7e7
6 changed files with 24 additions and 15 deletions

View File

@ -20,15 +20,14 @@
#include <time.h>
#include <unistd.h>
#if CLOCKS_PER_SEC != 1000000l
# error "CLOCKS_PER_SEC should be 1000000"
#endif
clock_t
clock (void)
{
struct timespec ts;
_Static_assert (CLOCKS_PER_SEC == 1000000,
"CLOCKS_PER_SEC should be 1000000");
/* clock_gettime shouldn't fail here since CLOCK_PROCESS_CPUTIME_ID is
supported since 2.6.12. Check the return value anyway in case the kernel
barfs on us for some reason. */