[PATCH 2/2] PowerPC - Add a faster way to read the Time Base register
Carlos O'Donell
carlos@systemhalted.org
Tue Mar 6 15:44:00 GMT 2012
On Tue, Mar 6, 2012 at 8:57 AM, Tulio Magno Quites Machado Filho
<tuliom@linux.vnet.ibm.com> wrote:
> Add function __ppc_get_timebase() to directly read the Time Base register.
> This is required for applications that measure time at high frequencies
> with high precision that can't afford a syscall.
Your test case could do a *little* more checking.
> +static int
> +do_test(void)
> +{
> + __ppc_timebase tb = __ppc_get_timebase ();
> + printf ("Time Base = %llx\n", tb);
> + return 0;
> +}
> +
> +#define TEST_FUNCTION do_test ()
> +#include "../test-skeleton.c"
Check the value.
Printf.
Check the value again.
Printf.
Check the values were different.
I'm sure that the time base has to advance after executing all of the
instructions involved in printf :-)
This way you ensure that the function has not been optimized away to a nop.
Cheers,
Carlos.
More information about the Libc-alpha
mailing list