From: Jes Sorensen <jes@wildopensource.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: davidm@hpl.hp.com, libc-hacker@sources.redhat.com
Subject: Re: ia64 clock_gettime and HP_TIMING
Date: Wed, 10 Dec 2003 09:57:00 -0000 [thread overview]
Message-ID: <yq0he09rogb.fsf@wildopensource.com> (raw)
In-Reply-To: <yq0isl08rlw.fsf@wildopensource.com>
Hi,
I didn't hear anything back on this one, so I just wanted to hear if
there were any objections to this patch?
Thanks,
Jes
>>>>> "Jes" == Jes Sorensen <jes@wildopensource.com> writes:
>>>>> "Ulrich" == Ulrich Drepper <drepper@redhat.com> writes:
Ulrich> Jes Sorensen wrote:
>>> Not knowing enough about HPET, my biggest worry is if we have to
>>> open up an extra file descriptor for a permanent mmap of it.
Ulrich> One immediately closes the filedescriptor after the mmap call
Ulrich> if this mmaped region is all that is needed.
Jes> Ok, what about something like this, it makes
Jes> clock_getcpuclokcid() return ENOENT if the itc drifts. I left
Jes> __itc_drift_internal as a global variable as I am not sure
Jes> whether clock_gettime should be change to check it as well before
Jes> allowing a call for CLOCK_PROCESS_CPUTIME_ID.
Jes> I still want to look into supporting the HPET and SN2 RTC at a
Jes> later stage.
2003-12-01 Jes Sorensen <jes@wildopensource.com>
* rt/tst-clock.c (do_test): Print message when skipping
CLOCK_PROCESS_CPUTIME_ID test.
* sysdeps/unix/sysv/linux/ia64/clock_getcpuclockid.c: New file.
Provide CLOCK_PROCESS_CPUTIME_ID only if /proc/sal/itc_drift is 0.
--- libc-old/rt/tst-clock.c 6 Jul 2001 04:55:39 -0000 1.3
+++ libc-2.3/rt/tst-clock.c 1 Dec 2003 14:52:07 -0000
@@ -113,6 +113,8 @@
if (clock_getcpuclockid (0, &cl) == 0)
/* XXX It's not yet a bug when this fails. */
clock_test (cl);
+ else
+ printf("CPU clock unavailble, skipping test\n");
return result;
}
--- /dev/null Wed Dec 31 16:00:00 1969
+++ libc-2.3/sysdeps/unix/sysv/linux/ia64/clock_getcpuclockid.c Mon Dec 1 06:21:42 2003
@@ -0,0 +1,75 @@
+/* Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+int __itc_drift_internal;
+
+int
+clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
+{
+ /* We don't allow any process ID but our own. */
+ if (pid != 0 && pid != getpid ())
+ return EPERM;
+
+#ifdef CLOCK_PROCESS_CPUTIME_ID
+ {
+ int retval = ENOENT;
+
+ if (__builtin_expect (__itc_drift_internal == 0, 0))
+ {
+ int fd;
+
+ fd = open ("/proc/sal/itc_drift", O_RDONLY);
+ if (__builtin_expect (fd != -1, 1))
+ {
+ char buf[16];
+ ssize_t n;
+ n = read (fd, buf, sizeof buf);
+ if (__builtin_expect (n, 1) > 0)
+ {
+ if (buf[0] != '0')
+ __itc_drift_internal = 1;
+ else
+ __itc_drift_internal = -1;
+ }
+ close (fd);
+ }
+ else
+ __itc_drift_internal = -1;
+ }
+
+ if (__itc_drift_internal != 1)
+ {
+ /* Store the number. */
+ *clock_id = CLOCK_PROCESS_CPUTIME_ID;
+ retval = 0;
+ }
+
+ return retval;
+ }
+#else
+ /* We don't have a timer for that. */
+ return ENOENT;
+#endif
+}
next prev parent reply other threads:[~2003-12-10 9:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-12 15:35 Jes Sorensen
2003-11-12 18:00 ` Ulrich Drepper
2003-11-13 8:25 ` Jes Sorensen
2003-11-13 9:15 ` Ulrich Drepper
2003-11-13 13:27 ` Jes Sorensen
2003-11-13 22:54 ` David Mosberger
2003-11-13 23:26 ` Ulrich Drepper
2003-11-14 9:46 ` Jes Sorensen
2003-11-14 17:57 ` Ulrich Drepper
2003-12-01 15:56 ` Jes Sorensen
2003-12-10 9:57 ` Jes Sorensen [this message]
2003-12-10 23:39 ` Ulrich Drepper
2003-12-11 10:50 ` Jes Sorensen
2003-12-11 19:29 ` David Mosberger
2003-12-11 20:48 ` Ulrich Drepper
2003-12-12 8:49 ` Jes Sorensen
2003-11-17 23:39 ` David Mosberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yq0he09rogb.fsf@wildopensource.com \
--to=jes@wildopensource.com \
--cc=davidm@hpl.hp.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).