[nptl-intel] question about clock_settime() and CLOCK_REALTIME
Li, Adam
adam.li@intel.com
Thu Feb 19 08:26:00 GMT 2004
Hi all,
I ran a simple test case for clock_settime() using CLOCK_REALTIME on linux-2.6.1 kernel and libc-2004-02-01. But clock_settime()
failed with EINVAL. It seems there is some configuration problem when I build libc. The clock_settime() system will not be invloked
although I am running on 2.6.1 kernel. But I cannot found out what is the problem.
Platform:
--------------------
libc: 2004-02-01
Linux kernel: 2.6.1-mm2 SMP on ia32
gcc-3.3.3-20040209
Redhat EL-3.0-update1
My configurations:
------------------------
configure --prefix=/usr --enable-add-ons=nptl --with-tls --with-headers=/usr/src/linux-2.6.1/include --enable-kernel=2.6.0
Output:
-------------------
clock_gettime(): Success
clock_settime(): Invalid argument
clock_settime() failed
Thanks
-adam
test cases: (adapted from Posix Test project: conformance/interfaces/clock_settime/1-1.c)
--------------------------
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
int main(int argc, char *argv[])
{
struct timespec tpset;
clock_gettime(CLOCK_REALTIME, &tpset);
perror("clock_gettime()");
tpset.tv_sec++;
if (clock_settime(CLOCK_REALTIME, &tpset) == 0) {
printf("Test PASSED\n");
return 0;
}
perror("clock_settime()");
printf("clock_settime() failed\n");
return -1;
}
strace shows that clock_settime() did not invoke system call. libc returns EINVAL:
...........
clock_gettime(0, {1077213432, 77164000}) = 0
dup(2) = 3
fcntl64(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
brk(0) = 0x804a000
brk(0x806b000) = 0x806b000
brk(0) = 0x806b000
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40018000
_llseek(3, 0, 0xbfffefb8, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "clock_gettime(): Success\n", 25clock_gettime(): Success
) = 25
close(3) = 0
munmap(0x40018000, 4096) = 0
dup(2) = 3
fcntl64(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40018000
_llseek(3, 0, 0xbfffefb8, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "clock_settime(): Invalid argumen"..., 34clock_settime(): Invalid argument
) = 34
close(3)
.........................
------------------------------------------------
Message above is personal view, not my employer's.
More information about the Libc-alpha
mailing list