This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] A steadier steady_clock
- From: Ulrich Drepper <drepper at gmail dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>
- Cc: Sam Varshavchik <mrsam at courier-mta dot com>, gcc-patches at gcc dot gnu dot org, "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Sun, 21 Oct 2012 19:33:25 -0400
- Subject: Re: [PATCH] A steadier steady_clock
- References: <cone.1350828020.51066.30326.1000@monster.email-scan.com> <50841EA5.3000701@oracle.com>
On Sun, Oct 21, 2012 at 12:11 PM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
\>> @@ -70,7 +70,11 @@
>> {
>> timespec tp;
>> // -EINVAL, -EFAULT
>> +#ifdef CLOCK_MONOTONIC_RAW
>> + clock_gettime(CLOCK_MONOTONIC_RAW, &tp);
>> +#else
>> clock_gettime(CLOCK_MONOTONIC, &tp);
>> +#endif
>> return time_point(duration(chrono::seconds(tp.tv_sec)
>> + chrono::nanoseconds(tp.tv_nsec)));
>> }
That'll have to be something like
#ifdef CLOCK_MONOTONIC_RAW
if (clock_gettime(CLOCK_MONOTONIC_RAW, &tp) != 0)
#endif
clock_gettime(CLOCK_MONOTONIC, &tp);
Only way out of this is when you introduce a check for a minimum
kernel ABI somewhere, just like glibc does.