mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
7b5af2d8f2
In glibc 2.17, the functions clock_getcpuclockid, clock_getres, clock_gettime, clock_nanosleep, and clock_settime were moved from librt.so to libc.so, leaving compatibility stubs behind. Now that the dynamic linker no longer insists on finding versioned symbols in the same library that originally defined them, we do not need the stubs anymore, and this means we don't need GLIBC_PRIVATE __-prefix aliases for most of the functions anymore either. (clock_gettime still needs one.) For ports added before 2.17, libc.so needs to provide two symbol versions for each, the default at GLIBC_2.17 plus a compat version matching what librt had. While I'm at it, move the clock_*.c files and their tests from rt/ to time/.
44 lines
880 B
C
44 lines
880 B
C
/* Test setting the monotonic clock. */
|
|
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
|
|
|
|
# include <errno.h>
|
|
# include <stdio.h>
|
|
|
|
static int
|
|
do_test (void)
|
|
{
|
|
if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
|
|
return 0;
|
|
|
|
struct timespec ts;
|
|
if (clock_gettime (CLOCK_MONOTONIC, &ts) != 0)
|
|
{
|
|
puts ("clock_gettime(CLOCK_MONOTONIC) failed");
|
|
return 1;
|
|
}
|
|
|
|
/* Setting the monotonic clock must fail. */
|
|
if (clock_settime (CLOCK_MONOTONIC, &ts) != -1)
|
|
{
|
|
puts ("clock_settime(CLOCK_MONOTONIC) did not fail");
|
|
return 1;
|
|
}
|
|
if (errno != EINVAL)
|
|
{
|
|
printf ("clock_settime(CLOCK_MONOTONIC) set errno to %d, expected %d\n",
|
|
errno, EINVAL);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
# define TEST_FUNCTION do_test ()
|
|
|
|
#else
|
|
# define TEST_FUNCTION 0
|
|
#endif
|
|
#include "../test-skeleton.c"
|