This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] PowerPC - Add a faster way to read the Time Base register


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]