[Patch, libfortran] PR 47571 Some janitorial cleanup

Janne Blomqvist blomqvist.janne@gmail.com
Wed Feb 2 19:23:00 GMT 2011


Hi,

I reviewed the Gfortran time intrinsics, both standard and extensions,
and AFAIK the only place where a monotonic clock fits the API, and
where we can expose high resolution, is the SYSTEM_CLOCK intrinsic.

Now, due to the PR 47571 fix where we now call clock_gettime() via a
weakref, some of the original reason behind the gf_gettime() wrapper
has been lost, as now we still need to include fallback code in case
the weakref is not available. This needlessly bloats the code for
date_and_time() which is unable to use either the extra precision and
needs a realtime clock, not a monotonic clock. Additionally, in some
not quite bleeding edge Linux kernels, gettimeofday() is a vsyscall
and clock_gettime() isn't, leading to higher overhead for no benefit
(the difference is something like 1e6 vs 1e7 calls/s on current hw, so
it's exceedingly unlikely to actually matter in reality).  The only
fly in the ointment here is that POSIX 2008 has marked gettimeofday()
as obsolescent, however I don't see this mattering in reality for the
foreseeable future.

The attached patch moves all the weakref trickery and clock_gettime()
usage from time_1.h to system_clock.c, where the only benefactor also
lives.

Regtested on x86_64-unknown-linux-gnu, Ok for trunk?

2011-02-02  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/47571
	* intrinsics/time_1.h (GF_CLOCK_MONOTONIC): Move to system_clock.c.
	(weak_gettime): Likewise.
	(gf_gettime): Change API, move weak_gettime() usage to
	system_clock.c
	* intrinsics/system_clock.c (gf_gettime_mono): New function.
	(system_clock_4): Use gf_gettime_mono().
	(system_clock_8): Likewise.
	* intrinsics/date_and_time.c (date_and_time): Update gf_gettime()
	usage.


-- 
Janne Blomqvist
-------------- next part --------------
A non-text attachment was scrubbed...
Name: weak_gettime2.diff
Type: text/x-patch
Size: 6608 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20110202/23d2e25a/attachment.bin>


More information about the Fortran mailing list