This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] PowerPC - Add a faster way to read the Time Base register
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>
- Cc: libc-alpha at sourceware dot org, sjmunroe at us dot ibm dot com, roland at hack dot frob dot com, joseph at codesourcery dot com, ryan dot arnold at gmail dot com
- Date: Tue, 6 Mar 2012 10:44:43 -0500
- Subject: Re: [PATCH 2/2] PowerPC - Add a faster way to read the Time Base register
- Authentication-results: mr.google.com; spf=pass (google.com: domain of patofiero@gmail.com designates 10.236.79.195 as permitted sender) smtp.mail=patofiero@gmail.com; dkim=pass header.i=patofiero@gmail.com
- References: <20120224164824.GB3455@linux.vnet.ibm.com><1331042262-25221-1-git-send-email-tuliom@linux.vnet.ibm.com><1331042262-25221-2-git-send-email-tuliom@linux.vnet.ibm.com>
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.