This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] clock_gettime fix for undefined HANDLE_REALTIME.
- From: Carlos O'Donell <carlos at baldric dot uwo dot ca>
- To: libc-alpha <libc-alpha at sources dot redhat dot com>
- Date: Thu, 12 May 2005 16:14:19 -0400
- Subject: [PATCH] clock_gettime fix for undefined HANDLE_REALTIME.
libc-alpha,
Testing the build with the __NR_clock_* syscalls missing, and hence
checking the fallbacks.
If HANDLED_REALTIME is not defined then sysdeps/unix/clock_gettime.c
will not compile, because HANDLE_REALTIME is undefined and the build
fails.
This happens when building on a system that does not have
__NR_clock_gettime exported as a syscall, or if their userspace headers
are not updated (same effect).
HANDLED_REALTIME is defined in sysdeps/unix/sysv/linux/clock_gettime.c
which includes the later clock_gettime.c at the end of that file.
A look at sysdeps/unix/sysv/linux/clock_settime.c hints that a
reasonable fallback could be gettimeofday().
Tested on hppa with no regressions, by inspection it should work
everwhere else.
Is it the intent to fail the build here?
Cheers,
Carlos.
2005-05-08 Carlos O'Donell <carlos@systemhalted.org>
* sysdeps/unix/clock_gettime.c (HANDLE_REALTIME): Define.
Index: sysdeps/unix/clock_gettime.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/clock_gettime.c,v
retrieving revision 1.10
diff -u -p -r1.10 clock_gettime.c
--- sysdeps/unix/clock_gettime.c 27 Apr 2005 08:01:40 -0000 1.10
+++ sysdeps/unix/clock_gettime.c 12 May 2005 21:07:10 -0000
@@ -96,6 +96,13 @@ clock_gettime (clockid_t clock_id, struc
switch (clock_id)
{
+#define HANDLE_REALTIME \
+ do { \
+ struct timeval tv; \
+ retval = gettimeofday (&tv, NULL); \
+ TIMEVAL_TO_TIMESPEC (&tv, tp); \
+ } while (0)
+
#ifdef SYSDEP_GETTIME
SYSDEP_GETTIME;
#endif